index-8540448e.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import { r as routeProps, u as useRoute } from "./use-route-726f0d0b.js";
  2. import { c as createNamespace, e as extend, z as makeStringProp, n as numericProp, t as truthProp, G as unknownProp, k as isDef, I as Icon, w as withInstall } from "./index-487cde8c.js";
  3. import { d as defineComponent, c as createVNode } from "./index-5e4623ce.js";
  4. const [name, bem] = createNamespace("cell");
  5. const cellSharedProps = {
  6. tag: makeStringProp("div"),
  7. icon: String,
  8. size: String,
  9. title: numericProp,
  10. value: numericProp,
  11. label: numericProp,
  12. center: Boolean,
  13. isLink: Boolean,
  14. border: truthProp,
  15. iconPrefix: String,
  16. valueClass: unknownProp,
  17. labelClass: unknownProp,
  18. titleClass: unknownProp,
  19. titleStyle: null,
  20. arrowDirection: String,
  21. required: {
  22. type: [Boolean, String],
  23. default: null
  24. },
  25. clickable: {
  26. type: Boolean,
  27. default: null
  28. }
  29. };
  30. const cellProps = extend({}, cellSharedProps, routeProps);
  31. var stdin_default = defineComponent({
  32. name,
  33. props: cellProps,
  34. setup(props, {
  35. slots
  36. }) {
  37. const route = useRoute();
  38. const renderLabel = () => {
  39. const showLabel = slots.label || isDef(props.label);
  40. if (showLabel) {
  41. return createVNode("div", {
  42. "class": [bem("label"), props.labelClass]
  43. }, [slots.label ? slots.label() : props.label]);
  44. }
  45. };
  46. const renderTitle = () => {
  47. var _a;
  48. if (slots.title || isDef(props.title)) {
  49. const titleSlot = (_a = slots.title) == null ? void 0 : _a.call(slots);
  50. if (Array.isArray(titleSlot) && titleSlot.length === 0) {
  51. return;
  52. }
  53. return createVNode("div", {
  54. "class": [bem("title"), props.titleClass],
  55. "style": props.titleStyle
  56. }, [titleSlot || createVNode("span", null, [props.title]), renderLabel()]);
  57. }
  58. };
  59. const renderValue = () => {
  60. const slot = slots.value || slots.default;
  61. const hasValue = slot || isDef(props.value);
  62. if (hasValue) {
  63. return createVNode("div", {
  64. "class": [bem("value"), props.valueClass]
  65. }, [slot ? slot() : createVNode("span", null, [props.value])]);
  66. }
  67. };
  68. const renderLeftIcon = () => {
  69. if (slots.icon) {
  70. return slots.icon();
  71. }
  72. if (props.icon) {
  73. return createVNode(Icon, {
  74. "name": props.icon,
  75. "class": bem("left-icon"),
  76. "classPrefix": props.iconPrefix
  77. }, null);
  78. }
  79. };
  80. const renderRightIcon = () => {
  81. if (slots["right-icon"]) {
  82. return slots["right-icon"]();
  83. }
  84. if (props.isLink) {
  85. const name2 = props.arrowDirection && props.arrowDirection !== "right" ? `arrow-${props.arrowDirection}` : "arrow";
  86. return createVNode(Icon, {
  87. "name": name2,
  88. "class": bem("right-icon")
  89. }, null);
  90. }
  91. };
  92. return () => {
  93. var _a;
  94. const {
  95. tag,
  96. size,
  97. center,
  98. border,
  99. isLink,
  100. required
  101. } = props;
  102. const clickable = (_a = props.clickable) != null ? _a : isLink;
  103. const classes = {
  104. center,
  105. required: !!required,
  106. clickable,
  107. borderless: !border
  108. };
  109. if (size) {
  110. classes[size] = !!size;
  111. }
  112. return createVNode(tag, {
  113. "class": bem(classes),
  114. "role": clickable ? "button" : void 0,
  115. "tabindex": clickable ? 0 : void 0,
  116. "onClick": route
  117. }, {
  118. default: () => {
  119. var _a2;
  120. return [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_a2 = slots.extra) == null ? void 0 : _a2.call(slots)];
  121. }
  122. });
  123. };
  124. }
  125. });
  126. const Cell = withInstall(stdin_default);
  127. const index = "";
  128. export {
  129. Cell as C,
  130. cellSharedProps as c
  131. };