Col.mjs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { createVNode as _createVNode } from "vue";
  2. import { computed, defineComponent } from "vue";
  3. import { numericProp, createNamespace, makeNumericProp, makeStringProp } from "../utils/index.mjs";
  4. import { useParent } from "@vant/use";
  5. import { ROW_KEY } from "../row/Row.mjs";
  6. const [name, bem] = createNamespace("col");
  7. const colProps = {
  8. tag: makeStringProp("div"),
  9. span: makeNumericProp(0),
  10. offset: numericProp
  11. };
  12. var stdin_default = defineComponent({
  13. name,
  14. props: colProps,
  15. setup(props, {
  16. slots
  17. }) {
  18. const {
  19. parent,
  20. index
  21. } = useParent(ROW_KEY);
  22. const style = computed(() => {
  23. if (!parent) {
  24. return;
  25. }
  26. const {
  27. spaces
  28. } = parent;
  29. if (spaces && spaces.value && spaces.value[index.value]) {
  30. const {
  31. left,
  32. right
  33. } = spaces.value[index.value];
  34. return {
  35. paddingLeft: left ? `${left}px` : null,
  36. paddingRight: right ? `${right}px` : null
  37. };
  38. }
  39. });
  40. return () => {
  41. const {
  42. tag,
  43. span,
  44. offset
  45. } = props;
  46. return _createVNode(tag, {
  47. "style": style.value,
  48. "class": bem({
  49. [span]: span,
  50. [`offset-${offset}`]: offset
  51. })
  52. }, {
  53. default: () => {
  54. var _a;
  55. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  56. }
  57. });
  58. };
  59. }
  60. });
  61. export {
  62. stdin_default as default
  63. };