vue-devui 1.0.0-beta.1 → 1.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) hide show
  1. package/accordion/index.d.ts +7 -0
  2. package/accordion/index.es.js +186 -139
  3. package/accordion/index.umd.js +1 -1
  4. package/accordion/style.css +1 -1
  5. package/alert/index.d.ts +7 -0
  6. package/alert/index.es.js +2 -3
  7. package/alert/index.umd.js +1 -1
  8. package/alert/style.css +1 -1
  9. package/anchor/index.d.ts +7 -0
  10. package/avatar/index.d.ts +7 -0
  11. package/avatar/index.es.js +1 -1
  12. package/avatar/index.umd.js +1 -1
  13. package/back-top/index.d.ts +7 -0
  14. package/back-top/index.es.js +128 -0
  15. package/back-top/index.umd.js +1 -0
  16. package/back-top/package.json +7 -0
  17. package/back-top/style.css +1 -0
  18. package/badge/index.d.ts +7 -0
  19. package/badge/index.es.js +1 -1
  20. package/badge/index.umd.js +1 -1
  21. package/breadcrumb/index.d.ts +7 -0
  22. package/button/index.d.ts +7 -0
  23. package/button/index.es.js +9 -8
  24. package/button/index.umd.js +1 -1
  25. package/card/index.d.ts +7 -0
  26. package/card/index.es.js +1 -1
  27. package/card/index.umd.js +1 -1
  28. package/carousel/index.d.ts +7 -0
  29. package/carousel/index.es.js +5 -4
  30. package/carousel/index.umd.js +1 -1
  31. package/cascader/index.d.ts +7 -0
  32. package/cascader/index.es.js +1239 -83
  33. package/cascader/index.umd.js +1 -1
  34. package/cascader/style.css +1 -1
  35. package/checkbox/index.d.ts +7 -0
  36. package/checkbox/index.es.js +43 -8
  37. package/checkbox/index.umd.js +1 -1
  38. package/comment/index.d.ts +7 -0
  39. package/comment/index.es.js +85 -0
  40. package/comment/index.umd.js +1 -0
  41. package/comment/package.json +7 -0
  42. package/comment/style.css +1 -0
  43. package/countdown/index.d.ts +7 -0
  44. package/countdown/index.es.js +176 -0
  45. package/countdown/index.umd.js +1 -0
  46. package/countdown/package.json +7 -0
  47. package/countdown/style.css +1 -0
  48. package/date-picker/index.d.ts +7 -0
  49. package/date-picker/index.es.js +32 -21
  50. package/date-picker/index.umd.js +1 -1
  51. package/date-picker/style.css +1 -1
  52. package/dragdrop/index.d.ts +7 -0
  53. package/dragdrop/index.es.js +32 -0
  54. package/dragdrop/index.umd.js +1 -0
  55. package/dragdrop/package.json +7 -0
  56. package/drawer/index.d.ts +7 -0
  57. package/drawer/index.es.js +161 -41
  58. package/drawer/index.umd.js +1 -1
  59. package/drawer/style.css +1 -1
  60. package/dropdown/index.d.ts +7 -0
  61. package/dropdown/index.es.js +527 -0
  62. package/dropdown/index.umd.js +1 -0
  63. package/dropdown/package.json +7 -0
  64. package/dropdown/style.css +1 -0
  65. package/editable-select/index.d.ts +7 -0
  66. package/editable-select/index.es.js +5718 -469
  67. package/editable-select/index.umd.js +27 -1
  68. package/editable-select/style.css +1 -1
  69. package/form/index.d.ts +7 -0
  70. package/form/index.es.js +2244 -0
  71. package/form/index.umd.js +1 -0
  72. package/form/package.json +7 -0
  73. package/form/style.css +1 -0
  74. package/fullscreen/index.d.ts +7 -0
  75. package/fullscreen/index.es.js +14 -4
  76. package/fullscreen/index.umd.js +1 -1
  77. package/gantt/index.d.ts +7 -0
  78. package/gantt/index.es.js +535 -0
  79. package/gantt/index.umd.js +1 -0
  80. package/gantt/package.json +7 -0
  81. package/gantt/style.css +1 -0
  82. package/grid/index.d.ts +7 -0
  83. package/grid/index.es.js +269 -0
  84. package/grid/index.umd.js +1 -0
  85. package/grid/package.json +7 -0
  86. package/grid/style.css +1 -0
  87. package/icon/index.d.ts +7 -0
  88. package/icon/index.es.js +6 -5
  89. package/icon/index.umd.js +1 -1
  90. package/image-preview/index.d.ts +7 -0
  91. package/image-preview/index.es.js +72 -11
  92. package/image-preview/index.umd.js +1 -1
  93. package/image-preview/style.css +1 -1
  94. package/index.d.ts +7 -0
  95. package/input/index.d.ts +7 -0
  96. package/input/index.es.js +24 -13
  97. package/input/index.umd.js +1 -1
  98. package/input-icon/index.d.ts +7 -0
  99. package/input-icon/index.es.js +332 -0
  100. package/input-icon/index.umd.js +1 -0
  101. package/input-icon/package.json +7 -0
  102. package/input-icon/style.css +1 -0
  103. package/input-number/index.d.ts +7 -0
  104. package/input-number/index.es.js +5 -4
  105. package/input-number/index.umd.js +1 -1
  106. package/layout/index.d.ts +7 -0
  107. package/layout/index.es.js +1 -1
  108. package/layout/index.umd.js +1 -1
  109. package/loading/index.d.ts +7 -0
  110. package/loading/index.es.js +1 -1
  111. package/loading/index.umd.js +1 -1
  112. package/modal/index.d.ts +7 -0
  113. package/modal/index.es.js +117 -99
  114. package/modal/index.umd.js +1 -1
  115. package/modal/style.css +1 -1
  116. package/nav-sprite/index.d.ts +7 -0
  117. package/nuxt/components/Accordion.js +3 -0
  118. package/nuxt/components/Alert.js +3 -0
  119. package/nuxt/components/Anchor.js +3 -0
  120. package/nuxt/components/Aside.js +3 -0
  121. package/nuxt/components/Avatar.js +3 -0
  122. package/nuxt/components/BackTop.js +3 -0
  123. package/nuxt/components/Badge.js +3 -0
  124. package/nuxt/components/Breadcrumb.js +3 -0
  125. package/nuxt/components/Button.js +3 -0
  126. package/nuxt/components/Card.js +3 -0
  127. package/nuxt/components/Carousel.js +3 -0
  128. package/nuxt/components/Cascader.js +3 -0
  129. package/nuxt/components/Checkbox.js +3 -0
  130. package/nuxt/components/Col.js +3 -0
  131. package/nuxt/components/Column.js +3 -0
  132. package/nuxt/components/Comment.js +3 -0
  133. package/nuxt/components/Content.js +3 -0
  134. package/nuxt/components/Countdown.js +3 -0
  135. package/nuxt/components/DatePicker.js +3 -0
  136. package/nuxt/components/Drawer.js +3 -0
  137. package/nuxt/components/Dropdown.js +3 -0
  138. package/nuxt/components/EditableSelect.js +3 -0
  139. package/nuxt/components/FixedOverlay.js +3 -0
  140. package/nuxt/components/FlexibleOverlay.js +3 -0
  141. package/nuxt/components/Footer.js +3 -0
  142. package/nuxt/components/Form.js +3 -0
  143. package/nuxt/components/FormControl.js +3 -0
  144. package/nuxt/components/FormItem.js +3 -0
  145. package/nuxt/components/FormLabel.js +3 -0
  146. package/nuxt/components/FormOperation.js +3 -0
  147. package/nuxt/components/Fullscreen.js +3 -0
  148. package/nuxt/components/Gantt.js +3 -0
  149. package/nuxt/components/Header.js +3 -0
  150. package/nuxt/components/Icon.js +2 -0
  151. package/nuxt/components/ImagePreviewService.js +3 -0
  152. package/nuxt/components/Input.js +3 -0
  153. package/nuxt/components/InputIcon.js +3 -0
  154. package/nuxt/components/InputNumber.js +3 -0
  155. package/nuxt/components/Layout.js +3 -0
  156. package/nuxt/components/Loading.js +3 -0
  157. package/nuxt/components/LoadingService.js +3 -0
  158. package/nuxt/components/Modal.js +3 -0
  159. package/nuxt/components/MultiUpload.js +3 -0
  160. package/nuxt/components/NavSprite.js +2 -0
  161. package/nuxt/components/Pagination.js +3 -0
  162. package/nuxt/components/Panel.js +3 -0
  163. package/nuxt/components/Popover.js +3 -0
  164. package/nuxt/components/Progress.js +3 -0
  165. package/nuxt/components/QuadrantDiagram.js +3 -0
  166. package/nuxt/components/Radio.js +3 -0
  167. package/nuxt/components/RadioGroup.js +3 -0
  168. package/nuxt/components/Rate.js +3 -0
  169. package/nuxt/components/ReadTip.js +3 -0
  170. package/nuxt/components/Result.js +3 -0
  171. package/nuxt/components/Row.js +3 -0
  172. package/nuxt/components/Search.js +3 -0
  173. package/nuxt/components/Select.js +3 -0
  174. package/nuxt/components/Skeleton.js +3 -0
  175. package/nuxt/components/SkeletonItem.js +3 -0
  176. package/nuxt/components/Slider.js +3 -0
  177. package/nuxt/components/Splitter.js +3 -0
  178. package/nuxt/components/Statistic.js +3 -0
  179. package/nuxt/components/Status.js +3 -0
  180. package/nuxt/components/StepsGuide.js +3 -0
  181. package/nuxt/components/StickSlider.js +3 -0
  182. package/nuxt/components/Sticky.js +2 -0
  183. package/nuxt/components/Switch.js +3 -0
  184. package/nuxt/components/Table.js +3 -0
  185. package/nuxt/components/Tabs.js +3 -0
  186. package/nuxt/components/Tag.js +3 -0
  187. package/nuxt/components/TagInput.js +3 -0
  188. package/nuxt/components/Textarea.js +3 -0
  189. package/nuxt/components/TimeAxis.js +3 -0
  190. package/nuxt/components/TimeAxisItem.js +3 -0
  191. package/nuxt/components/TimePicker.js +3 -0
  192. package/nuxt/components/Toast.js +3 -0
  193. package/nuxt/components/ToastService.js +3 -0
  194. package/nuxt/components/Tooltip.js +3 -0
  195. package/nuxt/components/Transfer.js +3 -0
  196. package/nuxt/components/Tree.js +3 -0
  197. package/nuxt/components/TreeSelect.js +3 -0
  198. package/nuxt/components/Upload.js +3 -0
  199. package/nuxt/components/buttonProps.js +3 -0
  200. package/nuxt/index.js +13 -0
  201. package/overlay/index.d.ts +7 -0
  202. package/overlay/index.es.js +110 -93
  203. package/overlay/index.umd.js +1 -1
  204. package/overlay/style.css +1 -1
  205. package/package.json +6 -33
  206. package/pagination/index.d.ts +7 -0
  207. package/pagination/index.es.js +3 -3
  208. package/pagination/index.umd.js +1 -1
  209. package/panel/index.d.ts +7 -0
  210. package/panel/index.es.js +25 -22
  211. package/panel/index.umd.js +1 -1
  212. package/panel/style.css +1 -1
  213. package/popover/index.d.ts +7 -0
  214. package/popover/index.es.js +5 -2
  215. package/popover/index.umd.js +1 -1
  216. package/progress/index.d.ts +7 -0
  217. package/progress/index.es.js +1 -1
  218. package/progress/index.umd.js +2 -2
  219. package/quadrant-diagram/index.d.ts +7 -0
  220. package/radio/index.d.ts +7 -0
  221. package/radio/index.es.js +1 -1
  222. package/radio/index.umd.js +1 -1
  223. package/rate/index.d.ts +7 -0
  224. package/rate/index.es.js +1 -1
  225. package/rate/index.umd.js +1 -1
  226. package/read-tip/index.d.ts +7 -0
  227. package/read-tip/index.es.js +258 -0
  228. package/read-tip/index.umd.js +1 -0
  229. package/read-tip/package.json +7 -0
  230. package/read-tip/style.css +1 -0
  231. package/result/index.d.ts +7 -0
  232. package/result/index.es.js +119 -0
  233. package/result/index.umd.js +1 -0
  234. package/result/package.json +7 -0
  235. package/result/style.css +1 -0
  236. package/ripple/index.d.ts +7 -0
  237. package/ripple/index.es.js +5 -2
  238. package/ripple/index.umd.js +1 -1
  239. package/search/index.d.ts +7 -0
  240. package/search/index.es.js +35 -21
  241. package/search/index.umd.js +1 -1
  242. package/select/index.d.ts +7 -0
  243. package/select/index.es.js +47 -11
  244. package/select/index.umd.js +1 -1
  245. package/skeleton/index.d.ts +7 -0
  246. package/skeleton/index.es.js +148 -26
  247. package/skeleton/index.umd.js +1 -1
  248. package/skeleton/style.css +1 -1
  249. package/slider/index.d.ts +7 -0
  250. package/slider/index.es.js +30 -177
  251. package/slider/index.umd.js +1 -1
  252. package/slider/style.css +1 -1
  253. package/splitter/index.d.ts +7 -0
  254. package/splitter/index.es.js +107 -89
  255. package/splitter/index.umd.js +1 -1
  256. package/statistic/index.d.ts +7 -0
  257. package/statistic/index.es.js +280 -0
  258. package/statistic/index.umd.js +1 -0
  259. package/statistic/package.json +7 -0
  260. package/statistic/style.css +1 -0
  261. package/status/index.d.ts +7 -0
  262. package/status/index.es.js +2 -2
  263. package/status/index.umd.js +1 -1
  264. package/steps-guide/index.d.ts +7 -0
  265. package/steps-guide/index.es.js +101 -73
  266. package/steps-guide/index.umd.js +1 -1
  267. package/steps-guide/style.css +1 -1
  268. package/sticky/index.d.ts +7 -0
  269. package/style.css +1 -1
  270. package/switch/index.d.ts +7 -0
  271. package/switch/index.es.js +1 -1
  272. package/switch/index.umd.js +1 -1
  273. package/table/index.d.ts +7 -0
  274. package/table/index.es.js +1498 -156
  275. package/table/index.umd.js +1 -1
  276. package/table/style.css +1 -1
  277. package/tabs/index.d.ts +7 -0
  278. package/tabs/index.es.js +6 -3
  279. package/tabs/index.umd.js +1 -1
  280. package/tag/index.d.ts +7 -0
  281. package/tag/index.es.js +131 -0
  282. package/tag/index.umd.js +1 -0
  283. package/tag/package.json +7 -0
  284. package/tag/style.css +1 -0
  285. package/tag-input/index.d.ts +7 -0
  286. package/tag-input/index.es.js +1 -13
  287. package/tag-input/index.umd.js +1 -1
  288. package/textarea/index.d.ts +7 -0
  289. package/textarea/index.es.js +132 -0
  290. package/textarea/index.umd.js +1 -0
  291. package/textarea/package.json +7 -0
  292. package/textarea/style.css +1 -0
  293. package/time-axis/index.d.ts +7 -0
  294. package/time-axis/index.es.js +241 -21
  295. package/time-axis/index.umd.js +1 -1
  296. package/time-axis/style.css +1 -1
  297. package/time-picker/index.d.ts +7 -0
  298. package/time-picker/index.es.js +50 -26
  299. package/time-picker/index.umd.js +1 -1
  300. package/time-picker/style.css +1 -1
  301. package/toast/index.d.ts +7 -0
  302. package/toast/index.es.js +8 -7
  303. package/toast/index.umd.js +1 -1
  304. package/toast/style.css +1 -1
  305. package/tooltip/index.d.ts +7 -0
  306. package/transfer/index.d.ts +7 -0
  307. package/transfer/index.es.js +368 -79
  308. package/transfer/index.umd.js +1 -1
  309. package/transfer/style.css +1 -1
  310. package/tree/index.d.ts +7 -0
  311. package/tree/index.es.js +171 -35
  312. package/tree/index.umd.js +1 -1
  313. package/tree-select/index.d.ts +7 -0
  314. package/tree-select/index.es.js +528 -0
  315. package/tree-select/index.umd.js +1 -0
  316. package/tree-select/package.json +7 -0
  317. package/tree-select/style.css +1 -0
  318. package/upload/index.d.ts +7 -0
  319. package/upload/index.es.js +8 -7
  320. package/upload/index.umd.js +1 -1
  321. package/upload/style.css +1 -1
  322. package/vue-devui.es.js +19214 -7637
  323. package/vue-devui.umd.js +29 -3
package/table/index.es.js CHANGED
@@ -1,4 +1,23 @@
1
- import { computed, ref, watch, defineComponent, inject, createVNode, toRefs, getCurrentInstance, provide, createTextVNode, onBeforeMount, onMounted } from "vue";
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { computed, ref, watch, defineComponent, inject, createVNode, mergeProps, toRef, provide, Teleport, Transition, renderSlot, isVNode, onMounted, onUnmounted, withDirectives, vShow, reactive, isRef, toRefs, Fragment, shallowRef, getCurrentInstance, createTextVNode, resolveDirective, onBeforeMount, h, onBeforeUnmount } from "vue";
2
21
  const TableProps = {
3
22
  data: {
4
23
  type: Array,
@@ -7,177 +26,1445 @@ const TableProps = {
7
26
  striped: {
8
27
  type: Boolean,
9
28
  default: false
29
+ },
30
+ scrollable: {
31
+ type: Boolean,
32
+ default: false
33
+ },
34
+ maxWidth: {
35
+ type: String
36
+ },
37
+ maxHeight: {
38
+ type: String
39
+ },
40
+ tableWidth: {
41
+ type: String
42
+ },
43
+ tableHeight: {
44
+ type: String
45
+ },
46
+ size: {
47
+ type: String,
48
+ validator(value) {
49
+ return value === "sm" || value === "md" || value === "lg";
50
+ }
51
+ },
52
+ rowHoveredHighlight: {
53
+ type: Boolean,
54
+ default: true
55
+ },
56
+ fixHeader: {
57
+ type: Boolean,
58
+ default: false
59
+ },
60
+ checkable: {
61
+ type: Boolean,
62
+ default: true
63
+ },
64
+ tableLayout: {
65
+ type: String,
66
+ default: "auto",
67
+ validator(v) {
68
+ return v === "fixed" || v === "auto";
69
+ }
70
+ },
71
+ showLoading: {
72
+ type: Boolean,
73
+ default: false
74
+ },
75
+ headerBg: {
76
+ type: Boolean,
77
+ default: false
10
78
  }
11
79
  };
80
+ const TABLE_TOKEN = Symbol();
12
81
  function useTable(props) {
13
82
  const classes = computed(() => ({
14
83
  "devui-table": true,
15
- "devui-table-striped": props.striped
84
+ "devui-table-striped": props.striped,
85
+ "header-bg": props.headerBg,
86
+ "table-layout-auto": props.tableLayout === "auto"
87
+ }));
88
+ const style = computed(() => ({
89
+ maxHeight: props.maxHeight,
90
+ maxWidth: props.maxWidth,
91
+ height: props.tableHeight,
92
+ width: props.tableWidth
16
93
  }));
17
- return { classes };
94
+ return { classes, style };
18
95
  }
19
- function createStore(props) {
96
+ const useFixedColumn = (column) => {
97
+ const stickyCell = computed(() => {
98
+ const col = column.value;
99
+ if (col.fixedLeft) {
100
+ return `devui-sticky-cell left`;
101
+ }
102
+ if (col.fixedRight) {
103
+ return `devui-sticky-cell right`;
104
+ }
105
+ return void 0;
106
+ });
107
+ const offsetStyle = computed(() => {
108
+ const col = column.value;
109
+ if (col.fixedLeft) {
110
+ return `left:${col.fixedLeft}`;
111
+ }
112
+ if (col.fixedRight) {
113
+ return `right:${col.fixedRight}`;
114
+ }
115
+ return void 0;
116
+ });
117
+ return {
118
+ stickyCell,
119
+ offsetStyle
120
+ };
121
+ };
122
+ function createStore(dataSource) {
20
123
  const _data = ref([]);
124
+ watch(dataSource, (value) => {
125
+ _data.value = [...value];
126
+ }, { deep: true, immediate: true });
127
+ const { _columns, insertColumn, removeColumn, sortColumn } = createColumnGenerator();
128
+ const { _checkAll, _checkList, _halfChecked, getCheckedRows } = createSelection(dataSource, _data);
129
+ const { sortData } = createSorter(dataSource, _data);
130
+ const { filterData, resetFilterData } = createFilter(dataSource, _data);
131
+ const { isFixedLeft } = createFixedLogic(_columns);
132
+ return {
133
+ states: {
134
+ _data,
135
+ _columns,
136
+ _checkList,
137
+ _checkAll,
138
+ _halfChecked,
139
+ isFixedLeft
140
+ },
141
+ insertColumn,
142
+ sortColumn,
143
+ removeColumn,
144
+ getCheckedRows,
145
+ sortData,
146
+ filterData,
147
+ resetFilterData
148
+ };
149
+ }
150
+ const createColumnGenerator = () => {
21
151
  const _columns = ref([]);
22
- updateData();
23
- watch(() => props.data, updateData, { deep: true });
24
- function updateData() {
25
- _data.value = [];
26
- props.data.forEach((item) => {
27
- _data.value.push(item);
28
- });
29
- }
30
152
  const insertColumn = (column) => {
31
153
  _columns.value.push(column);
154
+ _columns.value.sort((a, b) => a.order > b.order ? 1 : -1);
155
+ };
156
+ const sortColumn = () => {
157
+ _columns.value.sort((a, b) => a.order > b.order ? 1 : -1);
158
+ };
159
+ const removeColumn = (column) => {
160
+ const i = _columns.value.findIndex((v) => v === column);
161
+ if (i === -1) {
162
+ return;
163
+ }
164
+ _columns.value.splice(i, 1);
165
+ };
166
+ return { _columns, insertColumn, removeColumn, sortColumn };
167
+ };
168
+ const createSelection = (dataSource, _data) => {
169
+ const _checkList = ref([]);
170
+ const _checkAllRecord = ref(false);
171
+ const _checkAll = computed({
172
+ get: () => _checkAllRecord.value,
173
+ set: (val) => {
174
+ _checkAllRecord.value = val;
175
+ for (let i = 0; i < _checkList.value.length; i++) {
176
+ _checkList.value[i] = val;
177
+ }
178
+ }
179
+ });
180
+ const _halfChecked = ref(false);
181
+ watch(dataSource, (value) => {
182
+ _checkList.value = new Array(value.length).fill(false);
183
+ }, { deep: true, immediate: true });
184
+ watch(_checkList, (list) => {
185
+ if (list.length === 0) {
186
+ return;
187
+ }
188
+ let allTrue = true;
189
+ let allFalse = true;
190
+ for (let i = 0; i < list.length; i++) {
191
+ allTrue && (allTrue = list[i]);
192
+ allFalse && (allFalse = !list[i]);
193
+ }
194
+ _checkAllRecord.value = allTrue;
195
+ _halfChecked.value = !(allFalse || allTrue);
196
+ }, { immediate: true, deep: true });
197
+ const getCheckedRows = () => {
198
+ return _data.value.filter((_, index2) => _checkList.value[index2]);
32
199
  };
33
200
  return {
34
- insertColumn,
35
- states: {
36
- _data,
37
- _columns
201
+ _checkList,
202
+ _checkAll,
203
+ _halfChecked,
204
+ getCheckedRows
205
+ };
206
+ };
207
+ const createSorter = (dataSource, _data) => {
208
+ const sortData = (field, direction, compareFn = (field2, a, b) => a[field2] > b[field2]) => {
209
+ if (direction === "ASC") {
210
+ _data.value = _data.value.sort((a, b) => compareFn(field, a, b) ? 1 : -1);
211
+ } else if (direction === "DESC") {
212
+ _data.value = _data.value.sort((a, b) => !compareFn(field, a, b) ? 1 : -1);
213
+ } else {
214
+ _data.value = [...dataSource.value];
38
215
  }
39
216
  };
40
- }
217
+ return { sortData };
218
+ };
219
+ const createFilter = (dataSource, _data) => {
220
+ const fieldSet = new Set();
221
+ const filterData = (field, results) => {
222
+ fieldSet.add(field);
223
+ const fields = [...fieldSet];
224
+ _data.value = dataSource.value.filter((item) => {
225
+ return fields.reduce((prev, field2) => {
226
+ return prev && results.indexOf(item[field2]) !== -1;
227
+ }, true);
228
+ });
229
+ };
230
+ const resetFilterData = () => {
231
+ fieldSet.clear();
232
+ _data.value = [...dataSource.value];
233
+ };
234
+ return { filterData, resetFilterData };
235
+ };
236
+ const createFixedLogic = (columns) => {
237
+ const isFixedLeft = computed(() => {
238
+ return columns.value.reduce((prev, current) => prev || !!current.fixedLeft, false);
239
+ });
240
+ return { isFixedLeft };
241
+ };
41
242
  var ColGroup = defineComponent({
42
243
  name: "DColGroup",
43
244
  setup() {
44
- const parent = inject("table");
245
+ const parent = inject(TABLE_TOKEN);
45
246
  const columns = parent.store.states._columns;
46
- return {
47
- columns
48
- };
49
- },
50
- render() {
51
- const {
52
- columns
53
- } = this;
54
- return createVNode("colgroup", null, [columns.map((column, index2) => {
247
+ return () => parent.props.tableLayout === "fixed" ? createVNode("colgroup", null, [parent.props.checkable ? createVNode("col", {
248
+ "width": 36
249
+ }, null) : null, columns.value.map((column, index2) => {
55
250
  return createVNode("col", {
56
251
  "key": index2,
57
252
  "width": column.realWidth
58
253
  }, null);
59
- })]);
254
+ })]) : null;
60
255
  }
61
256
  });
62
- const TableHeaderProps = {
63
- store: {
64
- type: Object,
65
- default: {}
257
+ var checkbox = "";
258
+ const commonProps = {
259
+ name: {
260
+ type: String,
261
+ default: void 0
262
+ },
263
+ halfchecked: {
264
+ type: Boolean,
265
+ default: false
266
+ },
267
+ isShowTitle: {
268
+ type: Boolean,
269
+ default: true
270
+ },
271
+ title: {
272
+ type: String
273
+ },
274
+ color: {
275
+ type: String,
276
+ default: void 0
277
+ },
278
+ showAnimation: {
279
+ type: Boolean,
280
+ default: true
281
+ },
282
+ disabled: {
283
+ type: Boolean,
284
+ default: false
285
+ },
286
+ beforeChange: {
287
+ type: Function,
288
+ default: void 0
66
289
  }
67
290
  };
68
- var header = "";
69
- var TableHeader = defineComponent({
70
- name: "DTableHeader",
71
- props: TableHeaderProps,
72
- setup(props) {
291
+ const checkboxProps = __spreadProps(__spreadValues({}, commonProps), {
292
+ halfchecked: {
293
+ type: Boolean,
294
+ default: false
295
+ },
296
+ checked: {
297
+ type: Boolean,
298
+ default: false
299
+ },
300
+ value: {
301
+ type: String
302
+ },
303
+ label: {
304
+ type: String,
305
+ default: void 0
306
+ },
307
+ title: {
308
+ type: String,
309
+ default: void 0
310
+ },
311
+ "onUpdate:checked": {
312
+ type: Function,
313
+ default: void 0
314
+ },
315
+ onChange: {
316
+ type: Function,
317
+ default: void 0
318
+ },
319
+ modelValue: {
320
+ type: Boolean
321
+ },
322
+ "onUpdate:modelValue": {
323
+ type: Function
324
+ }
325
+ });
326
+ const checkboxGroupProps = __spreadProps(__spreadValues({}, commonProps), {
327
+ modelValue: {
328
+ type: Array,
329
+ required: true
330
+ },
331
+ direction: {
332
+ type: String,
333
+ default: "column"
334
+ },
335
+ itemWidth: {
336
+ type: Number,
337
+ default: void 0
338
+ },
339
+ options: {
340
+ type: Array,
341
+ default: () => []
342
+ },
343
+ onChange: {
344
+ type: Function,
345
+ default: void 0
346
+ },
347
+ "onUpdate:modelValue": {
348
+ type: Function,
349
+ default: void 0
350
+ }
351
+ });
352
+ const checkboxGroupInjectionKey = Symbol("d-checkbox-group");
353
+ var Checkbox = defineComponent({
354
+ name: "DCheckbox",
355
+ props: checkboxProps,
356
+ emits: ["change", "update:checked", "update:modelValue"],
357
+ setup(props, ctx) {
358
+ const checkboxGroupConf = inject(checkboxGroupInjectionKey, null);
359
+ const isChecked = computed(() => props.checked || props.modelValue);
360
+ const mergedDisabled = computed(() => {
361
+ return (checkboxGroupConf == null ? void 0 : checkboxGroupConf.disabled.value) || props.disabled;
362
+ });
363
+ const mergedChecked = computed(() => {
364
+ var _a, _b;
365
+ return (_b = (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isItemChecked) == null ? void 0 : _a.call(checkboxGroupConf, props.value)) != null ? _b : isChecked.value;
366
+ });
367
+ const mergedIsShowTitle = computed(() => {
368
+ var _a;
369
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isShowTitle.value) != null ? _a : props.isShowTitle;
370
+ });
371
+ const mergedShowAnimation = computed(() => {
372
+ var _a;
373
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.showAnimation.value) != null ? _a : props.showAnimation;
374
+ });
375
+ const mergedColor = computed(() => {
376
+ var _a;
377
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.color.value) != null ? _a : props.color;
378
+ });
379
+ const itemWidth = checkboxGroupConf == null ? void 0 : checkboxGroupConf.itemWidth.value;
380
+ const direction = checkboxGroupConf == null ? void 0 : checkboxGroupConf.direction.value;
381
+ const canChange = (isChecked2, val) => {
382
+ var _a;
383
+ if (mergedDisabled.value) {
384
+ return Promise.resolve(false);
385
+ }
386
+ const beforeChange = (_a = props.beforeChange) != null ? _a : checkboxGroupConf == null ? void 0 : checkboxGroupConf.beforeChange;
387
+ if (beforeChange) {
388
+ const res = beforeChange(isChecked2, val);
389
+ if (typeof res === "boolean") {
390
+ return Promise.resolve(res);
391
+ }
392
+ return res;
393
+ }
394
+ return Promise.resolve(true);
395
+ };
396
+ const toggle = () => {
397
+ const current = !isChecked.value;
398
+ checkboxGroupConf == null ? void 0 : checkboxGroupConf.toggleGroupVal(props.value);
399
+ ctx.emit("update:checked", current);
400
+ ctx.emit("update:modelValue", current);
401
+ ctx.emit("change", current);
402
+ };
403
+ const handleClick = () => {
404
+ canChange(!isChecked.value, props.label).then((res) => res && toggle());
405
+ };
406
+ return {
407
+ itemWidth,
408
+ direction,
409
+ mergedColor,
410
+ mergedDisabled,
411
+ mergedIsShowTitle,
412
+ mergedChecked,
413
+ mergedShowAnimation,
414
+ handleClick
415
+ };
416
+ },
417
+ render() {
418
+ var _a;
73
419
  const {
74
- store
75
- } = toRefs(props);
76
- const columns = store.value.states._columns.value;
420
+ itemWidth,
421
+ direction,
422
+ mergedChecked,
423
+ mergedDisabled,
424
+ mergedIsShowTitle,
425
+ mergedShowAnimation,
426
+ halfchecked,
427
+ title,
428
+ label,
429
+ handleClick,
430
+ name,
431
+ value,
432
+ mergedColor,
433
+ $slots
434
+ } = this;
435
+ const wrapperCls = {
436
+ "devui-checkbox-column-margin": direction === "column",
437
+ "devui-checkbox-wrap": typeof itemWidth !== "undefined"
438
+ };
439
+ const wrapperStyle = itemWidth ? [`width: ${itemWidth}px`] : [];
440
+ const checkboxCls = {
441
+ "devui-checkbox": true,
442
+ active: mergedChecked,
443
+ halfchecked,
444
+ disabled: mergedDisabled,
445
+ unchecked: !mergedChecked
446
+ };
447
+ const labelTitle = mergedIsShowTitle ? title || label : "";
448
+ const bgImgStyle = mergedColor && halfchecked || mergedColor ? `linear-gradient(${mergedColor}, ${mergedColor})` : "";
449
+ const spanStyle = [`border-color:${(mergedChecked || halfchecked) && mergedColor ? mergedColor : ""}`, `background-image:${bgImgStyle}`, `background-color:${mergedColor && halfchecked ? mergedColor : ""}`];
450
+ const spanCls = {
451
+ "devui-checkbox-material": true,
452
+ "custom-color": mergedColor,
453
+ "devui-checkbox-no-label": !label && !$slots.default,
454
+ "devui-no-animation": !mergedShowAnimation,
455
+ "devui-checkbox-default-background": !halfchecked
456
+ };
457
+ const polygonCls = {
458
+ "devui-tick": true,
459
+ "devui-no-animation": !mergedShowAnimation
460
+ };
461
+ const stopPropagation = ($event) => $event.stopPropagation();
462
+ const inputProps = {
463
+ indeterminate: halfchecked
464
+ };
465
+ return createVNode("div", {
466
+ "class": wrapperCls,
467
+ "style": wrapperStyle
468
+ }, [createVNode("div", {
469
+ "class": checkboxCls
470
+ }, [createVNode("label", {
471
+ "title": labelTitle,
472
+ "onClick": handleClick
473
+ }, [createVNode("input", mergeProps({
474
+ "name": name || value,
475
+ "class": "devui-checkbox-input",
476
+ "type": "checkbox"
477
+ }, inputProps, {
478
+ "checked": mergedChecked,
479
+ "disabled": mergedDisabled,
480
+ "onClick": stopPropagation,
481
+ "onChange": stopPropagation
482
+ }), null), createVNode("span", {
483
+ "style": spanStyle,
484
+ "class": spanCls
485
+ }, [createVNode("span", {
486
+ "class": "devui-checkbox-halfchecked-bg"
487
+ }, null), createVNode("svg", {
488
+ "viewBox": "0 0 16 16",
489
+ "version": "1.1",
490
+ "xmlns": "http://www.w3.org/2000/svg",
491
+ "class": "devui-checkbox-tick"
492
+ }, [createVNode("g", {
493
+ "stroke": "none",
494
+ "stroke-width": "1",
495
+ "fill": "none",
496
+ "fill-rule": "evenodd"
497
+ }, [createVNode("polygon", {
498
+ "fill-rule": "nonzero",
499
+ "points": "5.17391304 6.56521739 7.7173913 9.10869565 11.826087 5 13 6.17391304 7.7173913 11.4565217 4 7.73913043",
500
+ "class": polygonCls
501
+ }, null)])])]), label || ((_a = $slots.default) == null ? void 0 : _a.call($slots))])])]);
502
+ }
503
+ });
504
+ var checkboxGroup = "";
505
+ var CheckboxGroup = defineComponent({
506
+ name: "DCheckboxGroup",
507
+ props: checkboxGroupProps,
508
+ emits: ["change", "update:modelValue"],
509
+ setup(props, ctx) {
510
+ const valList = toRef(props, "modelValue");
511
+ const defaultOpt = {
512
+ checked: false,
513
+ isShowTitle: true,
514
+ halfchecked: false,
515
+ showAnimation: true,
516
+ disabled: false
517
+ };
518
+ const toggleGroupVal = (val) => {
519
+ let index2 = -1;
520
+ if (typeof valList.value[0] === "string") {
521
+ index2 = valList.value.findIndex((item) => item === val);
522
+ } else if (typeof valList.value[0] === "object") {
523
+ index2 = valList.value.findIndex((item) => item.value === val);
524
+ }
525
+ if (index2 === -1) {
526
+ if (typeof props.options[0] === "object") {
527
+ const newOne = props.options.find((item) => item.value === val);
528
+ const res2 = [...valList.value, newOne];
529
+ ctx.emit("update:modelValue", res2);
530
+ ctx.emit("change", res2);
531
+ return;
532
+ }
533
+ const res = [...valList.value, val];
534
+ ctx.emit("update:modelValue", res);
535
+ ctx.emit("change", res);
536
+ return;
537
+ }
538
+ valList.value.splice(index2, 1);
539
+ ctx.emit("update:modelValue", valList.value);
540
+ ctx.emit("change", valList.value);
541
+ };
542
+ const isItemChecked = (itemVal) => {
543
+ if (typeof valList.value[0] === "string") {
544
+ return valList.value.includes(itemVal);
545
+ } else if (typeof valList.value[0] === "object") {
546
+ return valList.value.some((item) => item.value === itemVal);
547
+ }
548
+ };
549
+ provide(checkboxGroupInjectionKey, {
550
+ disabled: toRef(props, "disabled"),
551
+ isShowTitle: toRef(props, "isShowTitle"),
552
+ color: toRef(props, "color"),
553
+ showAnimation: toRef(props, "showAnimation"),
554
+ beforeChange: props.beforeChange,
555
+ isItemChecked,
556
+ toggleGroupVal,
557
+ itemWidth: toRef(props, "itemWidth"),
558
+ direction: toRef(props, "direction")
559
+ });
77
560
  return {
78
- columns
561
+ defaultOpt
79
562
  };
80
563
  },
81
564
  render() {
565
+ var _a;
82
566
  const {
83
- columns
567
+ direction,
568
+ $slots,
569
+ defaultOpt,
570
+ options
84
571
  } = this;
85
- return createVNode("thead", {
86
- "class": "devui-thead"
87
- }, [createVNode("tr", null, [columns.map((column, index2) => {
88
- return createVNode("th", {
89
- "key": index2
90
- }, [column.renderHeader()]);
91
- })])]);
572
+ let children = (_a = $slots.default) == null ? void 0 : _a.call($slots);
573
+ if ((options == null ? void 0 : options.length) > 0) {
574
+ children = options.map((opt) => {
575
+ let mergedOpt = null;
576
+ if (typeof opt === "string") {
577
+ mergedOpt = Object.assign({}, defaultOpt, {
578
+ label: opt,
579
+ value: opt
580
+ });
581
+ } else if (typeof opt === "object") {
582
+ mergedOpt = Object.assign({}, defaultOpt, __spreadProps(__spreadValues({}, opt), {
583
+ label: opt.name
584
+ }));
585
+ }
586
+ return createVNode(Checkbox, mergedOpt, null);
587
+ });
588
+ }
589
+ return createVNode("div", {
590
+ "class": "devui-checkbox-group"
591
+ }, [createVNode("div", {
592
+ "class": {
593
+ "devui-checkbox-list-inline": direction === "row"
594
+ }
595
+ }, [children])]);
92
596
  }
93
597
  });
94
- const TableBodyProps = {
95
- store: {
96
- type: Object,
97
- default: {}
598
+ Checkbox.install = function(app) {
599
+ app.component(Checkbox.name, Checkbox);
600
+ };
601
+ CheckboxGroup.install = function(app) {
602
+ app.component(CheckboxGroup.name, CheckboxGroup);
603
+ };
604
+ var sort = "";
605
+ const Sort = defineComponent({
606
+ props: {
607
+ modelValue: {
608
+ type: String,
609
+ default: ""
610
+ },
611
+ "onUpdate:modelValue": {
612
+ type: Function
613
+ }
614
+ },
615
+ emits: ["update:modelValue"],
616
+ setup(props, ctx) {
617
+ const changeDirection = () => {
618
+ let direction = "";
619
+ if (props.modelValue === "ASC") {
620
+ direction = "DESC";
621
+ } else if (props.modelValue === "DESC") {
622
+ direction = "";
623
+ } else {
624
+ direction = "ASC";
625
+ }
626
+ ctx.emit("update:modelValue", direction);
627
+ };
628
+ return () => createVNode("span", {
629
+ "onClick": changeDirection,
630
+ "class": "sort-clickable"
631
+ }, [createVNode("i", {
632
+ "class": ["datatable-svg", {
633
+ "sort-icon-default": !props.modelValue,
634
+ "sort-icon-asc": props.modelValue === "ASC",
635
+ "sort-icon-desc": props.modelValue === "DESC"
636
+ }]
637
+ }, [createVNode("svg", {
638
+ "width": "16px",
639
+ "height": "16px",
640
+ "viewBox": "0 0 16 16",
641
+ "version": "1.1",
642
+ "xmlns": "http://www.w3.org/2000/svg",
643
+ "xmlns:xlink": "http://www.w3.org/1999/xlink"
644
+ }, [createVNode("defs", null, [createVNode("circle", {
645
+ "id": "sort-svg-path-1",
646
+ "cx": "8",
647
+ "cy": "8",
648
+ "r": "8"
649
+ }, null), createVNode("filter", {
650
+ "x": "-34.4%",
651
+ "y": "-21.9%",
652
+ "width": "168.8%",
653
+ "height": "168.8%",
654
+ "filterUnits": "objectBoundingBox",
655
+ "id": "filter-2"
656
+ }, [createVNode("feOffset", {
657
+ "dx": "0",
658
+ "dy": "2",
659
+ "in": "SourceAlpha",
660
+ "result": "shadowOffsetOuter1"
661
+ }, null), createVNode("feGaussianBlur", {
662
+ "stdDeviation": "1.5",
663
+ "in": "shadowOffsetOuter1",
664
+ "result": "shadowBlurOuter1"
665
+ }, null), createVNode("feColorMatrix", {
666
+ "values": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.085309222 0",
667
+ "type": "matrix",
668
+ "in": "shadowBlurOuter1"
669
+ }, null)])]), createVNode("g", {
670
+ "stroke": "none",
671
+ "stroke-width": "1",
672
+ "fill": "none",
673
+ "fill-rule": "evenodd"
674
+ }, [createVNode("use", {
675
+ "fill-rule": "evenodd",
676
+ "xlink:href": "#sort-svg-path-1"
677
+ }, null), createVNode("polygon", {
678
+ "points": "8 4 11 7 5 7"
679
+ }, null), createVNode("polygon", {
680
+ "points": "8 12 5 9 11 9"
681
+ }, null)])])])]);
682
+ }
683
+ });
684
+ const dropdownProps = {
685
+ origin: {
686
+ type: Object
687
+ },
688
+ isOpen: {
689
+ type: Boolean,
690
+ default: false
691
+ },
692
+ disabled: {
693
+ type: Boolean,
694
+ default: false
695
+ },
696
+ trigger: {
697
+ type: String,
698
+ default: "click"
699
+ },
700
+ closeScope: {
701
+ type: String,
702
+ default: "all"
703
+ },
704
+ closeOnMouseLeaveMenu: {
705
+ type: Boolean,
706
+ default: false
707
+ },
708
+ showAnimation: {
709
+ type: Boolean,
710
+ default: true
711
+ }
712
+ };
713
+ function isComponent(target) {
714
+ return !!(target == null ? void 0 : target.$el);
715
+ }
716
+ function getElement(element) {
717
+ if (element instanceof Element) {
718
+ return element;
719
+ }
720
+ if (element && typeof element === "object" && element.$el instanceof Element) {
721
+ return element.$el;
722
+ }
723
+ return null;
724
+ }
725
+ function subscribeEvent(dom, type, callback) {
726
+ dom == null ? void 0 : dom.addEventListener(type, callback);
727
+ return () => {
728
+ dom == null ? void 0 : dom.removeEventListener(type, callback);
729
+ };
730
+ }
731
+ const useDropdown = ({
732
+ visible,
733
+ trigger,
734
+ origin,
735
+ closeScope,
736
+ closeOnMouseLeaveMenu
737
+ }) => {
738
+ const dropdownElRef = ref();
739
+ const closeByScope = () => {
740
+ if (closeScope.value === "none") {
741
+ return;
742
+ }
743
+ visible.value = false;
744
+ };
745
+ watch([trigger, origin, dropdownElRef], ([trigger2, origin2, dropdownEl], ov, onInvalidate) => {
746
+ const originEl = getElement(origin2);
747
+ if (!originEl || !dropdownEl) {
748
+ return;
749
+ }
750
+ const subscriptions = [
751
+ subscribeEvent(dropdownEl, "click", () => {
752
+ if (closeScope.value === "all") {
753
+ visible.value = false;
754
+ }
755
+ })
756
+ ];
757
+ if (trigger2 === "click") {
758
+ subscriptions.push(subscribeEvent(originEl, "click", () => visible.value = !visible.value), subscribeEvent(document, "click", (e) => {
759
+ if (!visible.value) {
760
+ return;
761
+ }
762
+ const target = e.target;
763
+ const isContain = originEl.contains(target) || dropdownEl.contains(target);
764
+ if (isContain) {
765
+ return;
766
+ }
767
+ closeByScope();
768
+ }), subscribeEvent(dropdownEl, "mouseleave", () => {
769
+ if (closeOnMouseLeaveMenu.value) {
770
+ visible.value = false;
771
+ }
772
+ }));
773
+ } else if (trigger2 === "hover") {
774
+ let overlayEnter = false;
775
+ let originEnter = false;
776
+ const handleLeave = async (elementType) => {
777
+ await new Promise((resolve) => setTimeout(resolve, 50));
778
+ if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
779
+ return;
780
+ }
781
+ closeByScope();
782
+ };
783
+ subscriptions.push(subscribeEvent(originEl, "mouseenter", () => {
784
+ originEnter = true;
785
+ visible.value = true;
786
+ }), subscribeEvent(originEl, "mouseleave", () => {
787
+ originEnter = false;
788
+ if (!closeOnMouseLeaveMenu.value) {
789
+ handleLeave("origin");
790
+ }
791
+ }), subscribeEvent(dropdownEl, "mouseenter", () => {
792
+ overlayEnter = true;
793
+ visible.value = true;
794
+ }), subscribeEvent(dropdownEl, "mouseleave", () => {
795
+ overlayEnter = false;
796
+ handleLeave("dropdown");
797
+ }));
798
+ }
799
+ onInvalidate(() => subscriptions.forEach((v) => v()));
800
+ });
801
+ return { dropdownEl: dropdownElRef };
802
+ };
803
+ var overlay = "";
804
+ function _isSlot(s) {
805
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
806
+ }
807
+ const CommonOverlay = defineComponent({
808
+ setup(props, ctx) {
809
+ return () => {
810
+ let _slot;
811
+ return createVNode(Teleport, {
812
+ "to": "#d-overlay-anchor"
813
+ }, {
814
+ default: () => [createVNode(Transition, {
815
+ "name": "devui-overlay-fade"
816
+ }, _isSlot(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
817
+ default: () => [_slot]
818
+ })]
819
+ });
820
+ };
821
+ }
822
+ });
823
+ const overlayProps = {
824
+ visible: {
825
+ type: Boolean
826
+ },
827
+ backgroundBlock: {
828
+ type: Boolean,
829
+ default: false
830
+ },
831
+ backgroundClass: {
832
+ type: String,
833
+ default: ""
834
+ },
835
+ backgroundStyle: {
836
+ type: [String, Object]
837
+ },
838
+ onBackdropClick: {
839
+ type: Function
840
+ },
841
+ backdropClose: {
842
+ type: Boolean,
843
+ default: true
844
+ },
845
+ hasBackdrop: {
846
+ type: Boolean,
847
+ default: true
98
848
  }
99
849
  };
100
- function useTableBody(props) {
101
- const storeData = props.store.states;
102
- const rowColumns = computed(() => {
103
- return storeData._data.value.map((row) => {
104
- const obj = Object.assign({}, row);
105
- obj.columns = storeData._columns.value;
106
- return obj;
850
+ const overlayEmits = ["update:visible", "backdropClick"];
851
+ const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
852
+ overlayStyle: {
853
+ type: [String, Object],
854
+ default: void 0
855
+ }
856
+ });
857
+ const flexibleOverlayProps = __spreadValues({
858
+ origin: {
859
+ type: Object,
860
+ require: true
861
+ },
862
+ position: {
863
+ type: Object,
864
+ default: () => ({
865
+ originX: "left",
866
+ originY: "top",
867
+ overlayX: "left",
868
+ overlayY: "top"
869
+ })
870
+ }
871
+ }, overlayProps);
872
+ function useOverlayLogic(props, ctx) {
873
+ const backgroundClass = computed(() => {
874
+ return [
875
+ "devui-overlay-background",
876
+ props.backgroundClass,
877
+ !props.hasBackdrop ? "devui-overlay-background__disabled" : "devui-overlay-background__color"
878
+ ];
879
+ });
880
+ const overlayClass = computed(() => {
881
+ return "devui-overlay";
882
+ });
883
+ const handleBackdropClick = (event) => {
884
+ var _a;
885
+ event.preventDefault();
886
+ (_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
887
+ if (props.backdropClose) {
888
+ ctx.emit("update:visible", false);
889
+ }
890
+ };
891
+ const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
892
+ onMounted(() => {
893
+ const body2 = document.body;
894
+ const originOverflow = body2.style.overflow;
895
+ const originPosition = body2.style.position;
896
+ watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
897
+ if (backgroundBlock) {
898
+ const top = body2.getBoundingClientRect().y;
899
+ if (visible) {
900
+ body2.style.overflowY = "scroll";
901
+ body2.style.position = visible ? "fixed" : "";
902
+ body2.style.top = `${top}px`;
903
+ } else {
904
+ body2.style.overflowY = originOverflow;
905
+ body2.style.position = originPosition;
906
+ body2.style.top = "";
907
+ window.scrollTo(0, -top);
908
+ }
909
+ }
910
+ });
911
+ onUnmounted(() => {
912
+ document.body.style.overflow = originOverflow;
107
913
  });
108
914
  });
109
- return { rowColumns };
915
+ return {
916
+ backgroundClass,
917
+ overlayClass,
918
+ handleBackdropClick,
919
+ handleOverlayBubbleCancel
920
+ };
110
921
  }
111
- var body = "";
112
- var TableBody = defineComponent({
113
- name: "DTableBody",
114
- props: TableBodyProps,
922
+ const FixedOverlay = defineComponent({
923
+ name: "DFixedOverlay",
924
+ props: fixedOverlayProps,
925
+ emits: overlayEmits,
926
+ setup(props, ctx) {
927
+ const {
928
+ backgroundClass,
929
+ overlayClass,
930
+ handleBackdropClick,
931
+ handleOverlayBubbleCancel
932
+ } = useOverlayLogic(props, ctx);
933
+ return () => createVNode(CommonOverlay, null, {
934
+ default: () => [withDirectives(createVNode("div", {
935
+ "class": backgroundClass.value,
936
+ "style": props.backgroundStyle,
937
+ "onClick": handleBackdropClick
938
+ }, [createVNode("div", {
939
+ "class": overlayClass.value,
940
+ "style": props.overlayStyle,
941
+ "onClick": handleOverlayBubbleCancel
942
+ }, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
943
+ });
944
+ }
945
+ });
946
+ const FlexibleOverlay = defineComponent({
947
+ name: "DFlexibleOverlay",
948
+ props: flexibleOverlayProps,
949
+ emits: overlayEmits,
950
+ setup(props, ctx) {
951
+ const overlayRef = ref(null);
952
+ const positionedStyle = reactive({
953
+ position: "absolute"
954
+ });
955
+ onMounted(async () => {
956
+ const handleRectChange = (position, rect, origin) => {
957
+ const point = calculatePosition(position, rect, origin);
958
+ positionedStyle.left = `${point.x}px`;
959
+ positionedStyle.top = `${point.y}px`;
960
+ };
961
+ const locationElements = computed(() => {
962
+ const overlay2 = overlayRef.value;
963
+ const origin = getOrigin(props.origin);
964
+ if (!overlay2 || !origin) {
965
+ return;
966
+ }
967
+ return {
968
+ origin,
969
+ overlay: overlay2
970
+ };
971
+ });
972
+ const visibleRef = toRef(props, "visible");
973
+ const positionRef = toRef(props, "position");
974
+ watch([locationElements, visibleRef, positionRef], async ([locationElements2, visible, position], ov, onInvalidate) => {
975
+ if (!visible || !locationElements2) {
976
+ return;
977
+ }
978
+ const {
979
+ origin,
980
+ overlay: overlay2
981
+ } = locationElements2;
982
+ handleRectChange(position, overlay2.getBoundingClientRect(), origin);
983
+ const unsubscriptions = [subscribeLayoutEvent(() => handleRectChange(position, overlay2.getBoundingClientRect(), origin)), subscribeOverlayResize(overlay2, (entries) => handleRectChange(position, entries[0].contentRect, origin)), subscribeOriginResize(origin, () => handleRectChange(position, overlay2.getBoundingClientRect(), origin))];
984
+ onInvalidate(() => {
985
+ unsubscriptions.forEach((fn) => fn());
986
+ });
987
+ });
988
+ });
989
+ const {
990
+ backgroundClass,
991
+ overlayClass,
992
+ handleBackdropClick,
993
+ handleOverlayBubbleCancel
994
+ } = useOverlayLogic(props);
995
+ return () => createVNode(CommonOverlay, null, {
996
+ default: () => [withDirectives(createVNode("div", {
997
+ "style": props.backgroundStyle,
998
+ "class": backgroundClass.value,
999
+ "onClick": handleBackdropClick
1000
+ }, [createVNode("div", {
1001
+ "ref": overlayRef,
1002
+ "class": overlayClass.value,
1003
+ "style": positionedStyle,
1004
+ "onClick": handleOverlayBubbleCancel
1005
+ }, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
1006
+ });
1007
+ }
1008
+ });
1009
+ function getOrigin(origin) {
1010
+ if (origin instanceof Element) {
1011
+ return origin;
1012
+ }
1013
+ if (isRef(origin)) {
1014
+ return getElement(origin.value);
1015
+ }
1016
+ if (isComponent(origin)) {
1017
+ return getElement(origin);
1018
+ }
1019
+ return origin;
1020
+ }
1021
+ function calculatePosition(position, rect, origin) {
1022
+ const originRect = getOriginRect(origin);
1023
+ const originPoint = getOriginRelativePoint(originRect, position);
1024
+ return getOverlayPoint(originPoint, rect, position);
1025
+ }
1026
+ function getOriginRect(origin) {
1027
+ if (origin instanceof Element) {
1028
+ return origin.getBoundingClientRect();
1029
+ }
1030
+ const width = origin.width || 0;
1031
+ const height = origin.height || 0;
1032
+ return {
1033
+ top: origin.y,
1034
+ bottom: origin.y + height,
1035
+ left: origin.x,
1036
+ right: origin.x + width,
1037
+ height,
1038
+ width
1039
+ };
1040
+ }
1041
+ function getOverlayPoint(originPoint, rect, position) {
1042
+ let x;
1043
+ const {
1044
+ width,
1045
+ height
1046
+ } = rect;
1047
+ if (position.overlayX == "center") {
1048
+ x = originPoint.x - width / 2;
1049
+ } else {
1050
+ x = position.overlayX == "left" ? originPoint.x : originPoint.x - width;
1051
+ }
1052
+ let y;
1053
+ if (position.overlayY == "center") {
1054
+ y = originPoint.y - height / 2;
1055
+ } else {
1056
+ y = position.overlayY == "top" ? originPoint.y : originPoint.y - height;
1057
+ }
1058
+ return {
1059
+ x,
1060
+ y
1061
+ };
1062
+ }
1063
+ function getOriginRelativePoint(originRect, position) {
1064
+ let x;
1065
+ if (position.originX == "center") {
1066
+ x = originRect.left + originRect.width / 2;
1067
+ } else {
1068
+ const startX = originRect.left;
1069
+ const endX = originRect.right;
1070
+ x = position.originX == "left" ? startX : endX;
1071
+ }
1072
+ let y;
1073
+ if (position.originY == "center") {
1074
+ y = originRect.top + originRect.height / 2;
1075
+ } else {
1076
+ y = position.originY == "top" ? originRect.top : originRect.bottom;
1077
+ }
1078
+ return {
1079
+ x,
1080
+ y
1081
+ };
1082
+ }
1083
+ function subscribeLayoutEvent(event) {
1084
+ window.addEventListener("scroll", event, true);
1085
+ window.addEventListener("resize", event);
1086
+ window.addEventListener("orientationchange", event);
1087
+ return () => {
1088
+ window.removeEventListener("scroll", event, true);
1089
+ window.removeEventListener("resize", event);
1090
+ window.removeEventListener("orientationchange", event);
1091
+ };
1092
+ }
1093
+ function subscribeOverlayResize(overlay2, callback) {
1094
+ if (overlay2 instanceof Element) {
1095
+ const resizeObserver = new ResizeObserver(callback);
1096
+ resizeObserver.observe(overlay2);
1097
+ return () => resizeObserver.disconnect();
1098
+ }
1099
+ return () => {
1100
+ };
1101
+ }
1102
+ function subscribeOriginResize(origin, callback) {
1103
+ if (origin instanceof Element) {
1104
+ const observer = new MutationObserver(callback);
1105
+ observer.observe(origin, {
1106
+ attributeFilter: ["style"]
1107
+ });
1108
+ return () => observer.disconnect();
1109
+ }
1110
+ return () => {
1111
+ };
1112
+ }
1113
+ FlexibleOverlay.install = function(app) {
1114
+ app.component(FlexibleOverlay.name, FlexibleOverlay);
1115
+ };
1116
+ FixedOverlay.install = function(app) {
1117
+ app.component(FixedOverlay.name, FixedOverlay);
1118
+ };
1119
+ var dropdown = "";
1120
+ var Dropdown = defineComponent({
1121
+ name: "DDropdown",
1122
+ props: dropdownProps,
1123
+ emits: [],
1124
+ setup(props, ctx) {
1125
+ const {
1126
+ isOpen,
1127
+ origin,
1128
+ trigger,
1129
+ closeScope,
1130
+ closeOnMouseLeaveMenu
1131
+ } = toRefs(props);
1132
+ const visible = ref(false);
1133
+ watch(isOpen, (value) => {
1134
+ visible.value = value;
1135
+ }, {
1136
+ immediate: true
1137
+ });
1138
+ const position = {
1139
+ originX: "center",
1140
+ originY: "bottom",
1141
+ overlayX: "center",
1142
+ overlayY: "top"
1143
+ };
1144
+ const {
1145
+ dropdownEl
1146
+ } = useDropdown({
1147
+ visible,
1148
+ origin,
1149
+ trigger,
1150
+ closeScope,
1151
+ closeOnMouseLeaveMenu
1152
+ });
1153
+ const animatedVisible = computed(() => {
1154
+ return props.showAnimation ? visible.value : true;
1155
+ });
1156
+ return () => {
1157
+ return createVNode(Fragment, null, [createVNode(FlexibleOverlay, {
1158
+ "origin": props.origin,
1159
+ "visible": visible.value,
1160
+ "onUpdate:visible": ($event) => visible.value = $event,
1161
+ "position": position,
1162
+ "hasBackdrop": false
1163
+ }, {
1164
+ default: () => [createVNode(Transition, {
1165
+ "name": "devui-dropdown-fade"
1166
+ }, {
1167
+ default: () => {
1168
+ var _a, _b;
1169
+ return [withDirectives(createVNode("div", {
1170
+ "ref": dropdownEl,
1171
+ "style": "min-width:102px"
1172
+ }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), [[vShow, animatedVisible.value]])];
1173
+ }
1174
+ })]
1175
+ })]);
1176
+ };
1177
+ }
1178
+ });
1179
+ Dropdown.install = function(app) {
1180
+ app.component(Dropdown.name, Dropdown);
1181
+ };
1182
+ var filter = "";
1183
+ const Filter = defineComponent({
1184
+ props: {
1185
+ modelValue: {
1186
+ type: Array,
1187
+ default: []
1188
+ },
1189
+ "onUpdate:modelValue": {
1190
+ type: Function
1191
+ },
1192
+ customTemplate: {
1193
+ type: Function
1194
+ },
1195
+ filterList: {
1196
+ type: Array,
1197
+ required: true
1198
+ },
1199
+ filterMultiple: {
1200
+ type: Boolean,
1201
+ default: true
1202
+ }
1203
+ },
1204
+ emits: ["update:modelValue"],
115
1205
  setup(props) {
1206
+ const filterOrigin = ref(null);
1207
+ const onUpdateChecked = (config, value) => {
1208
+ const checkedList = props.modelValue;
1209
+ const update = props["onUpdate:modelValue"];
1210
+ const contained = !!checkedList.find((item) => item === config.value);
1211
+ if (value && !contained) {
1212
+ update == null ? void 0 : update([...checkedList, config.value]);
1213
+ } else if (!value && contained) {
1214
+ update == null ? void 0 : update(checkedList.filter((item) => config.value !== item));
1215
+ }
1216
+ };
1217
+ const updateSingleChecked = (config) => {
1218
+ var _a;
1219
+ (_a = props["onUpdate:modelValue"]) == null ? void 0 : _a.call(props, [config.value]);
1220
+ };
1221
+ const dropdownContent = computed(() => {
1222
+ const checkedList = props.modelValue;
1223
+ const isContained = (config) => !!checkedList.find((item) => item === config.value);
1224
+ return () => createVNode("ul", {
1225
+ "class": "devui-dropdown-menu data-table-column-filter-content",
1226
+ "style": "padding:10px"
1227
+ }, [props.filterList.map((item, index2) => {
1228
+ return createVNode("li", {
1229
+ "style": index2 > 0 ? "margin-top:10px" : ""
1230
+ }, [props.filterMultiple ? createVNode(Checkbox, {
1231
+ "modelValue": isContained(item),
1232
+ "onUpdate:modelValue": (value) => onUpdateChecked(item, value)
1233
+ }, {
1234
+ default: () => [item.name]
1235
+ }) : createVNode("span", {
1236
+ "onClick": () => updateSingleChecked(item)
1237
+ }, [item.name])]);
1238
+ })]);
1239
+ });
1240
+ return () => createVNode(Fragment, null, [createVNode("span", {
1241
+ "ref": filterOrigin
1242
+ }, [createVNode("i", {
1243
+ "class": ["filter-icon", {
1244
+ "filter-icon-active": true
1245
+ }]
1246
+ }, [createVNode("svg", {
1247
+ "width": "16px",
1248
+ "height": "16px",
1249
+ "viewBox": "0 0 16 16",
1250
+ "version": "1.1",
1251
+ "xmlns": "http://www.w3.org/2000/svg",
1252
+ "xmlns:xlink": "http://www.w3.org/1999/xlink"
1253
+ }, [createVNode("g", {
1254
+ "stroke": "none",
1255
+ "stroke-width": "1",
1256
+ "fill": "none",
1257
+ "fill-rule": "evenodd"
1258
+ }, [createVNode("g", null, [createVNode("polygon", {
1259
+ "points": "10.0085775 7 10.0085775 15 6 13 6 7 2 3 2 1 14 1 14 3"
1260
+ }, null)])])])])]), createVNode(Dropdown, {
1261
+ "origin": filterOrigin.value,
1262
+ "closeScope": "blank"
1263
+ }, {
1264
+ default: () => {
1265
+ var _a, _b;
1266
+ return [(_b = (_a = props.customTemplate) == null ? void 0 : _a.call(props, {
1267
+ value: props.modelValue,
1268
+ onChange: props["onUpdate:modelValue"]
1269
+ })) != null ? _b : dropdownContent.value()];
1270
+ }
1271
+ })]);
1272
+ }
1273
+ });
1274
+ var header = "";
1275
+ var body = "";
1276
+ const useSort = (store, column) => {
1277
+ const directionRef = ref("DESC");
1278
+ watch([directionRef, column], ([direction, column2]) => {
1279
+ if (column2.sortable) {
1280
+ store.sortData(column2.field, direction, column2.compareFn);
1281
+ }
1282
+ }, { immediate: true });
1283
+ return directionRef;
1284
+ };
1285
+ const useFliter = (store, column) => {
1286
+ const filteredRef = shallowRef();
1287
+ watch(filteredRef, (results) => {
1288
+ store.filterData(column.value.field, results);
1289
+ });
1290
+ return filteredRef;
1291
+ };
1292
+ var TableHeader = defineComponent({
1293
+ name: "DTableHeader",
1294
+ setup() {
1295
+ const table2 = inject(TABLE_TOKEN);
116
1296
  const {
117
- rowColumns
118
- } = useTableBody(props);
119
- return {
120
- rowColumns
1297
+ _checkAll: checkAll,
1298
+ _halfChecked: halfChecked,
1299
+ _columns: columns,
1300
+ isFixedLeft
1301
+ } = table2.store.states;
1302
+ const thAttrs = computed(() => isFixedLeft.value ? {
1303
+ class: "devui-sticky-cell left",
1304
+ style: "left:0;"
1305
+ } : null);
1306
+ const checkbox2 = computed(() => table2.props.checkable ? createVNode("th", thAttrs.value, [createVNode(Checkbox, {
1307
+ "style": "padding:10px;",
1308
+ "modelValue": checkAll.value,
1309
+ "onUpdate:modelValue": ($event) => checkAll.value = $event,
1310
+ "halfchecked": halfChecked.value
1311
+ }, null)]) : null);
1312
+ return () => {
1313
+ return createVNode("thead", {
1314
+ "class": "devui-thead"
1315
+ }, [createVNode("tr", null, [checkbox2.value, columns.value.map((column, index2) => createVNode(Th, {
1316
+ "key": index2,
1317
+ "column": column
1318
+ }, null))])]);
121
1319
  };
1320
+ }
1321
+ });
1322
+ const Th = defineComponent({
1323
+ props: {
1324
+ column: {
1325
+ type: Object,
1326
+ required: true
1327
+ }
122
1328
  },
123
- render() {
1329
+ setup(props) {
1330
+ const table2 = inject(TABLE_TOKEN);
124
1331
  const {
125
- rowColumns
126
- } = this;
127
- return createVNode("tbody", {
1332
+ column
1333
+ } = toRefs(props);
1334
+ const directionRef = useSort(table2.store, column);
1335
+ const filteredRef = useFliter(table2.store, column);
1336
+ const {
1337
+ stickyCell,
1338
+ offsetStyle
1339
+ } = useFixedColumn(column);
1340
+ return () => createVNode("th", {
1341
+ "class": stickyCell.value,
1342
+ "style": offsetStyle.value
1343
+ }, [createVNode("div", {
1344
+ "class": "header-container"
1345
+ }, [props.column.renderHeader(), props.column.filterable && createVNode(Filter, {
1346
+ "modelValue": filteredRef.value,
1347
+ "onUpdate:modelValue": ($event) => filteredRef.value = $event,
1348
+ "filterList": props.column.filterList,
1349
+ "customTemplate": props.column.customFilterTemplate
1350
+ }, null)]), props.column.sortable && createVNode(Sort, {
1351
+ "modelValue": directionRef.value,
1352
+ "onUpdate:modelValue": ($event) => directionRef.value = $event
1353
+ }, null)]);
1354
+ }
1355
+ });
1356
+ var TableBody = defineComponent({
1357
+ name: "DTableBody",
1358
+ setup() {
1359
+ const table2 = inject(TABLE_TOKEN);
1360
+ const {
1361
+ _data: data,
1362
+ _columns: columns,
1363
+ _checkList: checkList,
1364
+ isFixedLeft
1365
+ } = table2.store.states;
1366
+ const hoverEnabled = computed(() => table2.props.rowHoveredHighlight);
1367
+ const tdAttrs = computed(() => isFixedLeft.value ? {
1368
+ class: "devui-sticky-cell left",
1369
+ style: "left:0;"
1370
+ } : null);
1371
+ const renderCheckbox = (index2) => table2.props.checkable ? createVNode("td", tdAttrs.value, [createVNode(Checkbox, {
1372
+ "modelValue": checkList.value[index2],
1373
+ "onUpdate:modelValue": ($event) => checkList.value[index2] = $event
1374
+ }, null)]) : null;
1375
+ return () => createVNode("tbody", {
128
1376
  "class": "devui-tbody"
129
- }, [rowColumns.map((row, rowIndex) => {
1377
+ }, [data.value.map((row, rowIndex) => {
130
1378
  return createVNode("tr", {
131
- "key": rowIndex
132
- }, [row.columns.map((column, index2) => {
133
- return createVNode("td", {
134
- "key": index2
135
- }, [column.renderCell({
136
- row,
137
- column,
138
- $index: index2
139
- })]);
140
- })]);
1379
+ "key": rowIndex,
1380
+ "class": {
1381
+ "hover-enabled": hoverEnabled.value
1382
+ }
1383
+ }, [renderCheckbox(rowIndex), columns.value.map((column, index2) => createVNode(TD, {
1384
+ "column": column,
1385
+ "index": index2,
1386
+ "row": row
1387
+ }, null))]);
141
1388
  })]);
142
1389
  }
143
1390
  });
1391
+ const TD = defineComponent({
1392
+ props: {
1393
+ column: {
1394
+ type: Object
1395
+ },
1396
+ row: {
1397
+ type: Object
1398
+ },
1399
+ index: {
1400
+ type: Number
1401
+ }
1402
+ },
1403
+ setup(props) {
1404
+ const column = toRef(props, "column");
1405
+ const {
1406
+ stickyCell,
1407
+ offsetStyle
1408
+ } = useFixedColumn(column);
1409
+ return () => createVNode("td", {
1410
+ "class": stickyCell.value,
1411
+ "style": offsetStyle.value
1412
+ }, [column.value.renderCell(props.row, props.index)]);
1413
+ }
1414
+ });
144
1415
  var table = "";
145
1416
  var Table = defineComponent({
146
1417
  name: "DTable",
147
1418
  props: TableProps,
148
- setup(props) {
1419
+ setup(props, ctx) {
149
1420
  const table2 = getCurrentInstance();
150
- const store = createStore(props);
1421
+ const store = createStore(toRef(props, "data"));
151
1422
  table2.store = store;
1423
+ provide(TABLE_TOKEN, table2);
152
1424
  const {
153
- classes
154
- } = useTable(props);
155
- provide("table", table2);
156
- return {
157
1425
  classes,
158
- store
159
- };
160
- },
161
- render() {
162
- const {
163
- classes,
164
- data,
165
- store,
166
- $slots
167
- } = this;
168
- return createVNode("div", {
169
- "class": "devui-table-wrapper"
170
- }, [$slots.default(), createVNode("table", {
171
- "class": classes,
172
- "cellpadding": "0",
173
- "cellspacing": "0"
174
- }, [createVNode(ColGroup, null, null), createVNode(TableHeader, {
175
- "store": store
176
- }, null), !!data.length && createVNode(TableBody, {
177
- "store": store
178
- }, null)]), !data.length && createVNode("div", {
1426
+ style
1427
+ } = useTable(props);
1428
+ const isEmpty = computed(() => props.data.length === 0);
1429
+ const fixHeaderCompo = computed(() => {
1430
+ return createVNode("div", {
1431
+ "class": "devui-table-view"
1432
+ }, [createVNode("div", {
1433
+ "style": "overflow: hidden scroll;"
1434
+ }, [createVNode("table", {
1435
+ "class": classes.value,
1436
+ "cellpadding": "0",
1437
+ "cellspacing": "0"
1438
+ }, [createVNode(ColGroup, null, null), createVNode(TableHeader, null, null)])]), createVNode("div", {
1439
+ "class": "scroll-view"
1440
+ }, [createVNode("table", {
1441
+ "class": classes.value,
1442
+ "cellpadding": "0",
1443
+ "cellspacing": "0"
1444
+ }, [createVNode(ColGroup, null, null), !isEmpty.value && createVNode(TableBody, {
1445
+ "style": "flex: 1"
1446
+ }, null)])])]);
1447
+ });
1448
+ const normalHeaderCompo = computed(() => {
1449
+ return createVNode("table", {
1450
+ "class": classes.value,
1451
+ "cellpadding": "0",
1452
+ "cellspacing": "0"
1453
+ }, [createVNode(ColGroup, null, null), createVNode(TableHeader, {
1454
+ "style": "position: relative"
1455
+ }, null), !isEmpty.value && createVNode(TableBody, null, null)]);
1456
+ });
1457
+ ctx.expose({
1458
+ getCheckedRows() {
1459
+ return store.getCheckedRows();
1460
+ }
1461
+ });
1462
+ return () => withDirectives(createVNode("div", {
1463
+ "class": "devui-table-wrapper",
1464
+ "style": style.value
1465
+ }, [ctx.slots.default(), props.fixHeader ? fixHeaderCompo.value : normalHeaderCompo.value, isEmpty.value && createVNode("div", {
179
1466
  "class": "devui-table-empty"
180
- }, [createTextVNode("No Data")])]);
1467
+ }, [createTextVNode("No Data")])]), [[resolveDirective("dLoading"), props.showLoading]]);
181
1468
  }
182
1469
  });
183
1470
  const TableColumnProps = {
@@ -199,6 +1486,36 @@ const TableColumnProps = {
199
1486
  },
200
1487
  formatter: {
201
1488
  type: Function
1489
+ },
1490
+ order: {
1491
+ type: Number,
1492
+ default: 0
1493
+ },
1494
+ sortable: {
1495
+ type: Boolean,
1496
+ default: false
1497
+ },
1498
+ compareFn: {
1499
+ type: Function,
1500
+ default: (field, a, b) => a[field] < b[field]
1501
+ },
1502
+ filterable: {
1503
+ type: Boolean,
1504
+ default: false
1505
+ },
1506
+ filterMultiple: {
1507
+ type: Boolean,
1508
+ default: false
1509
+ },
1510
+ filterList: {
1511
+ type: Array,
1512
+ default: []
1513
+ },
1514
+ fixedLeft: {
1515
+ type: String
1516
+ },
1517
+ fixedRight: {
1518
+ type: String
202
1519
  }
203
1520
  };
204
1521
  function formatWidth(width) {
@@ -210,59 +1527,84 @@ function formatWidth(width) {
210
1527
  function formatMinWidth(minWidth) {
211
1528
  return formatWidth(minWidth) || 80;
212
1529
  }
213
- function useRender(props) {
214
- const formatedWidth = ref(formatWidth(props.width));
215
- const formatedMinWidth = ref(formatMinWidth(props.minWidth));
216
- const setColumnWidth = (column) => {
217
- column.width = formatedWidth.value;
218
- column.minWidth = formatedMinWidth.value;
1530
+ function createColumn(props, templates) {
1531
+ const {
1532
+ field,
1533
+ header: header2,
1534
+ sortable,
1535
+ width,
1536
+ minWidth,
1537
+ formatter,
1538
+ compareFn,
1539
+ filterable,
1540
+ filterList,
1541
+ filterMultiple,
1542
+ order,
1543
+ fixedLeft,
1544
+ fixedRight
1545
+ } = props;
1546
+ const column = reactive({});
1547
+ watch([field, header2, order], ([field2, header22, order2]) => {
1548
+ column.field = field2;
1549
+ column.header = header22;
1550
+ column.order = order2;
1551
+ }, { immediate: true });
1552
+ watch([sortable, compareFn], ([sortable2, compareFn2]) => {
1553
+ column.sortable = sortable2;
1554
+ column.compareFn = compareFn2;
1555
+ });
1556
+ watch([
1557
+ filterable,
1558
+ filterList,
1559
+ filterMultiple
1560
+ ], ([filterable2, filterList2, filterMultiple2]) => {
1561
+ column.filterable = filterable2;
1562
+ column.filterMultiple = filterMultiple2;
1563
+ column.filterList = filterList2;
1564
+ }, { immediate: true });
1565
+ watch([fixedLeft, fixedRight], ([left, right]) => {
1566
+ column.fixedLeft = left;
1567
+ column.fixedRight = right;
1568
+ }, { immediate: true });
1569
+ watch([width, minWidth], ([width2, minWidth2]) => {
1570
+ column.width = formatWidth(width2);
1571
+ column.minWidth = formatMinWidth(minWidth2);
219
1572
  column.realWidth = column.width || column.minWidth;
220
- return column;
221
- };
222
- const setColumnRender = (column) => {
223
- column.renderHeader = () => {
224
- return defaultRenderHeader(column);
225
- };
226
- column.renderCell = (data) => {
227
- return defaultRenderCell(data);
228
- };
229
- };
230
- return { setColumnWidth, setColumnRender };
1573
+ });
1574
+ onBeforeMount(() => {
1575
+ column.renderHeader = defaultRenderHeader;
1576
+ column.renderCell = defaultRenderCell;
1577
+ column.formatter = formatter.value;
1578
+ column.customFilterTemplate = templates.customFilterTemplate;
1579
+ column.subColumns = templates.subColumns;
1580
+ });
1581
+ return column;
231
1582
  }
232
- function defaultRenderHeader(column) {
233
- return column.header;
1583
+ function defaultRenderHeader() {
1584
+ return h("span", { class: "title" }, this.header);
234
1585
  }
235
- function defaultRenderCell({
236
- row,
237
- column,
238
- $index
239
- }) {
240
- var _a;
241
- const value = row[column.field];
242
- if (column.formatter) {
243
- return column.formatter(row, column, value, $index);
244
- }
245
- return ((_a = value == null ? void 0 : value.toString) == null ? void 0 : _a.call(value)) || "";
1586
+ function defaultRenderCell(rowData, index2) {
1587
+ var _a, _b;
1588
+ const value = rowData[this.field];
1589
+ if (this.formatter) {
1590
+ return this.formatter(rowData, value, index2);
1591
+ }
1592
+ return (_b = (_a = value == null ? void 0 : value.toString) == null ? void 0 : _a.call(value)) != null ? _b : "";
246
1593
  }
247
1594
  var Column = defineComponent({
248
1595
  name: "DColumn",
249
1596
  props: TableColumnProps,
250
- setup(props) {
251
- const column = {
252
- field: props.field,
253
- header: props.header
254
- };
255
- const parent = inject("table");
256
- const {
257
- setColumnWidth,
258
- setColumnRender
259
- } = useRender(props);
260
- onBeforeMount(() => {
261
- setColumnWidth(column);
262
- setColumnRender(column);
263
- });
1597
+ setup(props, ctx) {
1598
+ const column = createColumn(toRefs(props), ctx.slots);
1599
+ const parent = inject(TABLE_TOKEN);
264
1600
  onMounted(() => {
265
1601
  parent.store.insertColumn(column);
1602
+ watch(() => column.order, () => {
1603
+ parent.store.sortColumn();
1604
+ });
1605
+ });
1606
+ onBeforeUnmount(() => {
1607
+ parent.store.removeColumn(column);
266
1608
  });
267
1609
  },
268
1610
  render() {