@meethive/components 0.0.1

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 (303) hide show
  1. package/es/AutoComplete/AutoComplete.js +84 -0
  2. package/es/AutoComplete/index.js +7 -0
  3. package/es/BadgeStatus/Badge.js +51 -0
  4. package/es/BadgeStatus/color.js +14 -0
  5. package/es/BadgeStatus/index.js +8 -0
  6. package/es/CardSelect/CardSelect.js +141 -0
  7. package/es/CardSelect/index.js +7 -0
  8. package/es/CardSelect/style/index.js +29 -0
  9. package/es/CheckButton/CheckButton.js +122 -0
  10. package/es/CheckButton/index.js +7 -0
  11. package/es/CheckButton/style/index.js +44 -0
  12. package/es/ConfigProvider/ConfigProvider.js +73 -0
  13. package/es/ConfigProvider/context.js +26 -0
  14. package/es/ConfigProvider/index.js +9 -0
  15. package/es/DragModal/DragModal.js +212 -0
  16. package/es/DragModal/index.js +7 -0
  17. package/es/DragModal/style/index.js +86 -0
  18. package/es/EditTable/Body.js +189 -0
  19. package/es/EditTable/CellRender.js +12 -0
  20. package/es/EditTable/EditTable.js +434 -0
  21. package/es/EditTable/FormItem.js +169 -0
  22. package/es/EditTable/Group.js +204 -0
  23. package/es/EditTable/Header.js +63 -0
  24. package/es/EditTable/HeaderRender.js +12 -0
  25. package/es/EditTable/components/ContextMenu/Menu.js +86 -0
  26. package/es/EditTable/components/ContextMenu/index.js +96 -0
  27. package/es/EditTable/components/Search/Search.js +163 -0
  28. package/es/EditTable/components/Search/Sort.js +119 -0
  29. package/es/EditTable/components/Search/index.js +2 -0
  30. package/es/EditTable/consts.js +13 -0
  31. package/es/EditTable/context.js +88 -0
  32. package/es/EditTable/hooks/index.js +19 -0
  33. package/es/EditTable/hooks/useGroup.js +48 -0
  34. package/es/EditTable/hooks/useResizeObserver.js +27 -0
  35. package/es/EditTable/hooks/useValidate.js +112 -0
  36. package/es/EditTable/index.js +25 -0
  37. package/es/EditTable/props.js +60 -0
  38. package/es/EditTable/style/body.js +63 -0
  39. package/es/EditTable/style/form.js +33 -0
  40. package/es/EditTable/style/group.js +33 -0
  41. package/es/EditTable/style/header.js +72 -0
  42. package/es/EditTable/style/index.js +52 -0
  43. package/es/EditTable/style/menu.js +27 -0
  44. package/es/EditTable/style/table.js +46 -0
  45. package/es/EditTable/utils.js +110 -0
  46. package/es/Ellipsis/Ellipsis.js +148 -0
  47. package/es/Ellipsis/index.js +7 -0
  48. package/es/Ellipsis/style/index.js +26 -0
  49. package/es/Empty/Empty.js +63 -0
  50. package/es/Empty/image.js +3 -0
  51. package/es/Empty/index.js +7 -0
  52. package/es/FullPage/FullPage.js +19 -0
  53. package/es/FullPage/index.js +7 -0
  54. package/es/Icon/Icon.js +49 -0
  55. package/es/Icon/index.js +7 -0
  56. package/es/LocaleProvider/LocaleProvider.js +31 -0
  57. package/es/LocaleProvider/index.js +7 -0
  58. package/es/LocaleReciver/index.js +24 -0
  59. package/es/Markdown/Markdown.js +118 -0
  60. package/es/Markdown/index.js +7 -0
  61. package/es/PermissionButton/PermissionButton.js +118 -0
  62. package/es/PermissionButton/confirm.js +94 -0
  63. package/es/PermissionButton/index.js +9 -0
  64. package/es/PermissionButton/shared.js +1 -0
  65. package/es/ProLayout/Basic/BasicLayout.js +422 -0
  66. package/es/ProLayout/Basic/BasicLayoutStyle.js +51 -0
  67. package/es/ProLayout/Basic/Header.js +111 -0
  68. package/es/ProLayout/Basic/HeaderStyle.js +10 -0
  69. package/es/ProLayout/PageContainer/index.js +354 -0
  70. package/es/ProLayout/PageContainer/style.js +85 -0
  71. package/es/ProLayout/RouteContext.js +28 -0
  72. package/es/ProLayout/SiderMenu/BaseMenu.js +241 -0
  73. package/es/ProLayout/SiderMenu/SiderMenu.js +274 -0
  74. package/es/ProLayout/SiderMenu/index.js +2 -0
  75. package/es/ProLayout/SiderMenu/style.js +204 -0
  76. package/es/ProLayout/TopHeader/index.js +170 -0
  77. package/es/ProLayout/TopHeader/style.js +154 -0
  78. package/es/ProLayout/defaultSettings.js +113 -0
  79. package/es/ProLayout/index.js +10 -0
  80. package/es/ProLayout/style/index.js +14 -0
  81. package/es/ProLayout/util.js +58 -0
  82. package/es/ProTable/Alert.js +40 -0
  83. package/es/ProTable/Content.js +97 -0
  84. package/es/ProTable/Header.js +33 -0
  85. package/es/ProTable/Pagination.js +55 -0
  86. package/es/ProTable/ProTable.js +279 -0
  87. package/es/ProTable/hooks/index.js +2 -0
  88. package/es/ProTable/hooks/useTableInject.js +6 -0
  89. package/es/ProTable/hooks/useTableSelection.js +115 -0
  90. package/es/ProTable/index.js +8 -0
  91. package/es/ProTable/setting.js +138 -0
  92. package/es/ProTable/style/index.js +113 -0
  93. package/es/RadioButton/RadioButton.js +53 -0
  94. package/es/RadioButton/index.js +8 -0
  95. package/es/RadioButton/style/index.js +25 -0
  96. package/es/Scrollbar/Bar.js +76 -0
  97. package/es/Scrollbar/Scrollbar.js +161 -0
  98. package/es/Scrollbar/Thumb.js +150 -0
  99. package/es/Scrollbar/constants.js +1 -0
  100. package/es/Scrollbar/index.js +7 -0
  101. package/es/Scrollbar/scrollbarProps.js +100 -0
  102. package/es/Scrollbar/style/index.js +85 -0
  103. package/es/Scrollbar/thumbProps.js +10 -0
  104. package/es/Scrollbar/util.js +39 -0
  105. package/es/Search/Item.js +239 -0
  106. package/es/Search/Search.js +90 -0
  107. package/es/Search/hooks/index.js +117 -0
  108. package/es/Search/hooks/useRouteQuery.js +86 -0
  109. package/es/Search/hooks/useSearchItems.js +50 -0
  110. package/es/Search/hooks/useTermOptions.js +29 -0
  111. package/es/Search/index.js +10 -0
  112. package/es/Search/setting.js +245 -0
  113. package/es/Search/style/index.js +5 -0
  114. package/es/Search/style/item.js +40 -0
  115. package/es/Search/style/search.js +177 -0
  116. package/es/Search/util.js +270 -0
  117. package/es/Skeleton/Skeleton.js +27 -0
  118. package/es/Skeleton/components/DashBoardCard.js +27 -0
  119. package/es/Skeleton/components/DashBoardChart.js +27 -0
  120. package/es/Skeleton/components/Detail.js +27 -0
  121. package/es/Skeleton/components/Drawer.js +27 -0
  122. package/es/Skeleton/components/Item.js +54 -0
  123. package/es/Skeleton/components/List.js +27 -0
  124. package/es/Skeleton/components/ListCard.js +28 -0
  125. package/es/Skeleton/components/ListCardItem.js +20 -0
  126. package/es/Skeleton/components/ListTable.js +27 -0
  127. package/es/Skeleton/components/Page.js +26 -0
  128. package/es/Skeleton/components/Search.js +16 -0
  129. package/es/Skeleton/components/Tree.js +27 -0
  130. package/es/Skeleton/index.js +28 -0
  131. package/es/Skeleton/style/index.js +195 -0
  132. package/es/TimeFormat/TimeFormat.js +36 -0
  133. package/es/TimeFormat/index.js +7 -0
  134. package/es/Title/Title.js +26 -0
  135. package/es/Title/index.js +7 -0
  136. package/es/Title/style/index.js +34 -0
  137. package/es/ValueItem/ValueItem.js +113 -0
  138. package/es/ValueItem/index.js +7 -0
  139. package/es/ValueItem/util.js +17 -0
  140. package/es/VirtualTable/VirtualTable.js +271 -0
  141. package/es/VirtualTable/data.js +60 -0
  142. package/es/VirtualTable/index.js +7 -0
  143. package/es/VirtualTable/style/index.js +34 -0
  144. package/es/components.js +21 -0
  145. package/es/index.js +17 -0
  146. package/es/locale/en-US.js +120 -0
  147. package/es/locale/zh-CN.js +120 -0
  148. package/es/style/styleRegister.js +19 -0
  149. package/es/style/variable.js +4 -0
  150. package/es/style.js +1 -0
  151. package/es/utils/constants.js +10 -0
  152. package/lib/AutoComplete/AutoComplete.js +84 -0
  153. package/lib/AutoComplete/index.js +7 -0
  154. package/lib/BadgeStatus/Badge.js +51 -0
  155. package/lib/BadgeStatus/color.js +14 -0
  156. package/lib/BadgeStatus/index.js +8 -0
  157. package/lib/CardSelect/CardSelect.js +141 -0
  158. package/lib/CardSelect/index.js +7 -0
  159. package/lib/CardSelect/style/index.js +29 -0
  160. package/lib/CheckButton/CheckButton.js +122 -0
  161. package/lib/CheckButton/index.js +7 -0
  162. package/lib/CheckButton/style/index.js +44 -0
  163. package/lib/ConfigProvider/ConfigProvider.js +73 -0
  164. package/lib/ConfigProvider/context.js +26 -0
  165. package/lib/ConfigProvider/index.js +9 -0
  166. package/lib/DragModal/DragModal.js +212 -0
  167. package/lib/DragModal/index.js +7 -0
  168. package/lib/DragModal/style/index.js +86 -0
  169. package/lib/EditTable/Body.js +189 -0
  170. package/lib/EditTable/CellRender.js +12 -0
  171. package/lib/EditTable/EditTable.js +434 -0
  172. package/lib/EditTable/FormItem.js +169 -0
  173. package/lib/EditTable/Group.js +204 -0
  174. package/lib/EditTable/Header.js +63 -0
  175. package/lib/EditTable/HeaderRender.js +12 -0
  176. package/lib/EditTable/components/ContextMenu/Menu.js +86 -0
  177. package/lib/EditTable/components/ContextMenu/index.js +96 -0
  178. package/lib/EditTable/components/Search/Search.js +163 -0
  179. package/lib/EditTable/components/Search/Sort.js +119 -0
  180. package/lib/EditTable/components/Search/index.js +2 -0
  181. package/lib/EditTable/consts.js +13 -0
  182. package/lib/EditTable/context.js +88 -0
  183. package/lib/EditTable/hooks/index.js +19 -0
  184. package/lib/EditTable/hooks/useGroup.js +48 -0
  185. package/lib/EditTable/hooks/useResizeObserver.js +27 -0
  186. package/lib/EditTable/hooks/useValidate.js +112 -0
  187. package/lib/EditTable/index.js +25 -0
  188. package/lib/EditTable/props.js +60 -0
  189. package/lib/EditTable/style/body.js +63 -0
  190. package/lib/EditTable/style/form.js +33 -0
  191. package/lib/EditTable/style/group.js +33 -0
  192. package/lib/EditTable/style/header.js +72 -0
  193. package/lib/EditTable/style/index.js +52 -0
  194. package/lib/EditTable/style/menu.js +27 -0
  195. package/lib/EditTable/style/table.js +46 -0
  196. package/lib/EditTable/utils.js +110 -0
  197. package/lib/Ellipsis/Ellipsis.js +148 -0
  198. package/lib/Ellipsis/index.js +7 -0
  199. package/lib/Ellipsis/style/index.js +26 -0
  200. package/lib/Empty/Empty.js +63 -0
  201. package/lib/Empty/image.js +3 -0
  202. package/lib/Empty/index.js +7 -0
  203. package/lib/FullPage/FullPage.js +19 -0
  204. package/lib/FullPage/index.js +7 -0
  205. package/lib/Icon/Icon.js +49 -0
  206. package/lib/Icon/index.js +7 -0
  207. package/lib/LocaleProvider/LocaleProvider.js +31 -0
  208. package/lib/LocaleProvider/index.js +7 -0
  209. package/lib/LocaleReciver/index.js +24 -0
  210. package/lib/Markdown/Markdown.js +118 -0
  211. package/lib/Markdown/index.js +7 -0
  212. package/lib/PermissionButton/PermissionButton.js +118 -0
  213. package/lib/PermissionButton/confirm.js +94 -0
  214. package/lib/PermissionButton/index.js +9 -0
  215. package/lib/PermissionButton/shared.js +1 -0
  216. package/lib/ProLayout/Basic/BasicLayout.js +422 -0
  217. package/lib/ProLayout/Basic/BasicLayoutStyle.js +51 -0
  218. package/lib/ProLayout/Basic/Header.js +111 -0
  219. package/lib/ProLayout/Basic/HeaderStyle.js +10 -0
  220. package/lib/ProLayout/PageContainer/index.js +354 -0
  221. package/lib/ProLayout/PageContainer/style.js +85 -0
  222. package/lib/ProLayout/RouteContext.js +28 -0
  223. package/lib/ProLayout/SiderMenu/BaseMenu.js +241 -0
  224. package/lib/ProLayout/SiderMenu/SiderMenu.js +274 -0
  225. package/lib/ProLayout/SiderMenu/index.js +2 -0
  226. package/lib/ProLayout/SiderMenu/style.js +204 -0
  227. package/lib/ProLayout/TopHeader/index.js +170 -0
  228. package/lib/ProLayout/TopHeader/style.js +154 -0
  229. package/lib/ProLayout/defaultSettings.js +113 -0
  230. package/lib/ProLayout/index.js +10 -0
  231. package/lib/ProLayout/style/index.js +14 -0
  232. package/lib/ProLayout/util.js +58 -0
  233. package/lib/ProTable/Alert.js +40 -0
  234. package/lib/ProTable/Content.js +97 -0
  235. package/lib/ProTable/Header.js +33 -0
  236. package/lib/ProTable/Pagination.js +55 -0
  237. package/lib/ProTable/ProTable.js +279 -0
  238. package/lib/ProTable/hooks/index.js +2 -0
  239. package/lib/ProTable/hooks/useTableInject.js +6 -0
  240. package/lib/ProTable/hooks/useTableSelection.js +115 -0
  241. package/lib/ProTable/index.js +8 -0
  242. package/lib/ProTable/setting.js +138 -0
  243. package/lib/ProTable/style/index.js +113 -0
  244. package/lib/RadioButton/RadioButton.js +53 -0
  245. package/lib/RadioButton/index.js +8 -0
  246. package/lib/RadioButton/style/index.js +25 -0
  247. package/lib/Scrollbar/Bar.js +76 -0
  248. package/lib/Scrollbar/Scrollbar.js +161 -0
  249. package/lib/Scrollbar/Thumb.js +150 -0
  250. package/lib/Scrollbar/constants.js +1 -0
  251. package/lib/Scrollbar/index.js +7 -0
  252. package/lib/Scrollbar/scrollbarProps.js +100 -0
  253. package/lib/Scrollbar/style/index.js +85 -0
  254. package/lib/Scrollbar/thumbProps.js +10 -0
  255. package/lib/Scrollbar/util.js +39 -0
  256. package/lib/Search/Item.js +239 -0
  257. package/lib/Search/Search.js +90 -0
  258. package/lib/Search/hooks/index.js +117 -0
  259. package/lib/Search/hooks/useRouteQuery.js +86 -0
  260. package/lib/Search/hooks/useSearchItems.js +50 -0
  261. package/lib/Search/hooks/useTermOptions.js +29 -0
  262. package/lib/Search/index.js +10 -0
  263. package/lib/Search/setting.js +245 -0
  264. package/lib/Search/style/index.js +5 -0
  265. package/lib/Search/style/item.js +40 -0
  266. package/lib/Search/style/search.js +177 -0
  267. package/lib/Search/util.js +270 -0
  268. package/lib/Skeleton/Skeleton.js +27 -0
  269. package/lib/Skeleton/components/DashBoardCard.js +27 -0
  270. package/lib/Skeleton/components/DashBoardChart.js +27 -0
  271. package/lib/Skeleton/components/Detail.js +27 -0
  272. package/lib/Skeleton/components/Drawer.js +27 -0
  273. package/lib/Skeleton/components/Item.js +54 -0
  274. package/lib/Skeleton/components/List.js +27 -0
  275. package/lib/Skeleton/components/ListCard.js +28 -0
  276. package/lib/Skeleton/components/ListCardItem.js +20 -0
  277. package/lib/Skeleton/components/ListTable.js +27 -0
  278. package/lib/Skeleton/components/Page.js +26 -0
  279. package/lib/Skeleton/components/Search.js +16 -0
  280. package/lib/Skeleton/components/Tree.js +27 -0
  281. package/lib/Skeleton/index.js +28 -0
  282. package/lib/Skeleton/style/index.js +195 -0
  283. package/lib/TimeFormat/TimeFormat.js +36 -0
  284. package/lib/TimeFormat/index.js +7 -0
  285. package/lib/Title/Title.js +26 -0
  286. package/lib/Title/index.js +7 -0
  287. package/lib/Title/style/index.js +34 -0
  288. package/lib/ValueItem/ValueItem.js +113 -0
  289. package/lib/ValueItem/index.js +7 -0
  290. package/lib/ValueItem/util.js +17 -0
  291. package/lib/VirtualTable/VirtualTable.js +271 -0
  292. package/lib/VirtualTable/data.js +60 -0
  293. package/lib/VirtualTable/index.js +7 -0
  294. package/lib/VirtualTable/style/index.js +34 -0
  295. package/lib/components.js +21 -0
  296. package/lib/index.js +17 -0
  297. package/lib/locale/en-US.js +120 -0
  298. package/lib/locale/zh-CN.js +120 -0
  299. package/lib/style/styleRegister.js +19 -0
  300. package/lib/style/variable.js +4 -0
  301. package/lib/style.js +1 -0
  302. package/lib/utils/constants.js +10 -0
  303. package/package.json +164 -0
@@ -0,0 +1,271 @@
1
+ function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+ import { defineComponent, computed, ref, watch, onMounted, nextTick, h } from 'vue'
3
+ import { Table, Checkbox } from 'ant-design-vue'
4
+ import { isNumber, map, omit } from 'lodash-es'
5
+ import AIcon from '../Icon'
6
+ import useVirtualTableStyle from './style'
7
+ import { useLocaleReceiver } from '../LocaleReciver'
8
+ import { findAllChildren, flattenTree } from './data'
9
+
10
+ const buffer = 5
11
+
12
+ export default defineComponent({
13
+ name: 'JVirtualTable',
14
+ components: {
15
+ Table,
16
+ Checkbox,
17
+ AIcon
18
+ },
19
+ props: {
20
+ dataSource: {
21
+ type: Array,
22
+ default: () => []
23
+ },
24
+ columns: {
25
+ type: Array,
26
+ default: () => []
27
+ },
28
+ expandedRowKeys: {
29
+ type: Array,
30
+ default: () => []
31
+ },
32
+ rowSelection: {
33
+ type: Object
34
+ },
35
+ rowKey: {
36
+ type: [String, Function],
37
+ default: 'id'
38
+ },
39
+ height: {
40
+ type: Number,
41
+ default: 500
42
+ }
43
+ } ,
44
+ emits: ['update:expandedRowKeys'],
45
+ setup(props, { emit }) {
46
+ const prefixCls = computed(() => 'virtual-table')
47
+ const [wrapSSR, hashId] = useVirtualTableStyle(prefixCls)
48
+ const [contextLocale] = useLocaleReceiver('ProTable')
49
+
50
+ const container = ref(null)
51
+ const rowHeights = ref([])
52
+ const prefixSum = ref([])
53
+ const start = ref(0)
54
+ const end = ref(15)
55
+ const offsetY = ref(0)
56
+
57
+ const selectedAll = ref(false)
58
+ // 被展开的所有数据
59
+ const visibleNodes = ref([])
60
+ const flattenData = ref([])
61
+
62
+ const firstColumn = computed(() => props.columns[0])
63
+ const totalHeight = computed(() =>
64
+ prefixSum.value.length ? prefixSum.value[prefixSum.value.length - 1] : 0
65
+ )
66
+ const visibleRows = computed(() => visibleNodes.value.slice(start.value, end.value))
67
+ const _indeterminate = computed(
68
+ () => !selectedAll.value && (_nullishCoalesce(_optionalChain([props, 'access', _ => _.rowSelection, 'optionalAccess', _2 => _2.selectedRowKeys, 'optionalAccess', _3 => _3.length]), () => ( 0))) > 0
69
+ )
70
+ const viewportHeight = computed(() => props.height || 500)
71
+
72
+ const _columns = computed(() => {
73
+ const arr = []
74
+ if (props.rowSelection) {
75
+ const _width = props.rowSelection.columnWidth || 32
76
+ arr.push({
77
+ key: '__selection__',
78
+ title: contextLocale.value.select.all,
79
+ dataIndex: '__selection__',
80
+ width: isNumber(_width) ? `${_width}px` : _width,
81
+ customHeaderCell: (props) => {
82
+ return {
83
+ class: 'ant-table-selection-column'
84
+ }
85
+ }
86
+ })
87
+ }
88
+ arr.push(...props.columns)
89
+ return arr
90
+ })
91
+
92
+ const _rowSelection = computed(() => {
93
+ return props.rowSelection
94
+ ? {
95
+ ...props.rowSelection,
96
+ onSelect: (record, selected, selectedRows, nativeEvent) => {
97
+ const _selectedRowKeys = props.rowSelection.selectedRowKeys || []
98
+ const _set = new Set([..._selectedRowKeys])
99
+ if (props.rowSelection.type === 'radio') {
100
+ _set.clear()
101
+ _set.add(record[props.rowKey ])
102
+ } else {
103
+ const _checkStrictly =
104
+ props.rowSelection.checkStrictly !== undefined
105
+ ? props.rowSelection.checkStrictly
106
+ : true
107
+ let __arr = []
108
+ if (_checkStrictly) {
109
+ // 需要获取子
110
+ __arr = [record[props.rowKey ]]
111
+ } else {
112
+ __arr = map(
113
+ findAllChildren(flattenData.value, record[props.rowKey ]),
114
+ props.rowKey
115
+ )
116
+ __arr.push(record[props.rowKey ])
117
+ }
118
+ if (selected) {
119
+ __arr.forEach((i) => _set.add(i))
120
+ } else {
121
+ __arr.forEach((i) => _set.delete(i))
122
+ }
123
+ }
124
+ const _selectedRows = flattenData.value
125
+ .filter((i) => _set.has(i[props.rowKey ]))
126
+ .map((item) => omit(item, ['expanded', 'hasChildren', 'visible']))
127
+ if (props.rowSelection.onSelect) {
128
+ props.rowSelection.onSelect(record, selected, _selectedRows, nativeEvent)
129
+ }
130
+ if (props.rowSelection.onChange) {
131
+ props.rowSelection.onChange([..._set], _selectedRows)
132
+ }
133
+ },
134
+ onChange: () => {},
135
+ onSelectAll: () => {},
136
+ onSelectNone: () => {
137
+ if (props.rowSelection.onSelectNone) {
138
+ props.rowSelection.onSelectNone()
139
+ }
140
+ }
141
+ }
142
+ : undefined
143
+ })
144
+
145
+ const onSelectedAllChange = (e) => {
146
+ const selected = e.target.checked
147
+ const arr = flattenData.value.map((i) => omit(i, ['expanded', 'hasChildren', 'visible']))
148
+ const _checked = selected
149
+ const _selectedRowKeys = _checked ? map(arr, props.rowKey ) : []
150
+ if (props.rowSelection.onSelectAll) {
151
+ props.rowSelection.onSelectAll(_checked, _checked ? arr : [])
152
+ }
153
+ if (props.rowSelection.onChange) {
154
+ props.rowSelection.onChange(_selectedRowKeys, _checked ? arr : [])
155
+ }
156
+ }
157
+
158
+ const onScroll = (e) => {
159
+ const scrollTop = e.target.scrollTop
160
+ const vh = viewportHeight.value || 500
161
+ const total = totalHeight.value
162
+ // 防止 scrollTop 超出范围
163
+ const clampedScrollTop = Math.min(scrollTop, total - vh)
164
+ // 二分查找
165
+ let low = 0,
166
+ high = prefixSum.value.length - 1
167
+ while (low < high) {
168
+ const mid = Math.floor((low + high) / 2)
169
+ if (prefixSum.value[mid] <= clampedScrollTop) low = mid + 1
170
+ else high = mid
171
+ }
172
+ const newStart = Math.max(0, low - 1)
173
+ // 如果 start 没变化,直接跳过,避免重复计算导致闪动
174
+ if (newStart === start.value) return
175
+ start.value = newStart
176
+ // 计算 end
177
+ let y = prefixSum.value[start.value] || 0
178
+ let i = start.value
179
+ while (i < visibleNodes.value.length && y < clampedScrollTop + vh) {
180
+ y += rowHeights.value[i] || 40
181
+ i++
182
+ }
183
+ end.value = Math.min(i + buffer, visibleNodes.value.length)
184
+ // 防止 offsetY 波动
185
+ offsetY.value = prefixSum.value[start.value - 1] || 0
186
+ }
187
+
188
+ const toggleExpand = (row) => {
189
+ row.expanded = !row.expanded
190
+ const stack = [...flattenData.value.filter((n) => n.parentId === row[props.rowKey ])]
191
+ while (stack.length) {
192
+ const child = stack.pop()
193
+ child.visible = row.expanded
194
+ if (!child.visible) {
195
+ child.expanded = false
196
+ }
197
+ if (!row.expanded && child.hasChildren) {
198
+ stack.push(...flattenData.value.filter((n) => n.parentId === child[props.rowKey ]))
199
+ }
200
+ }
201
+ updateVisibleNodes()
202
+ }
203
+
204
+ const updatePrefixSum = () => {
205
+ rowHeights.value = visibleNodes.value.map(() => 40) // 默认行高
206
+ prefixSum.value = []
207
+ let sum = 0
208
+ for (let h of rowHeights.value) {
209
+ sum += h
210
+ prefixSum.value.push(sum)
211
+ }
212
+ }
213
+
214
+ const updateVisibleNodes = () => {
215
+ visibleNodes.value = flattenData.value.filter((i) => i.visible)
216
+ updatePrefixSum()
217
+ console.log('123')
218
+ nextTick(() => onScroll({ target: container.value }))
219
+ }
220
+
221
+ watch(
222
+ () => [JSON.stringify(props.dataSource), JSON.stringify(props.expandedRowKeys)],
223
+ () => {
224
+ flattenData.value = flattenTree(props.dataSource , 0, null)
225
+ flattenData.value.forEach((i) => {
226
+ if ((props.expandedRowKeys ).includes(i[props.rowKey ])) {
227
+ toggleExpand(i)
228
+ }
229
+ })
230
+ updateVisibleNodes()
231
+ },
232
+ {
233
+ immediate: true
234
+ }
235
+ )
236
+
237
+ watch(
238
+ () => _optionalChain([props, 'access', _4 => _4.rowSelection, 'optionalAccess', _5 => _5.selectedRowKeys]),
239
+ (val) => {
240
+ if (val) {
241
+ selectedAll.value = val.length > 0 && flattenData.value.length === val.length
242
+ }
243
+ },
244
+ {
245
+ immediate: true
246
+ }
247
+ )
248
+
249
+ onMounted(() => {
250
+ updateVisibleNodes()
251
+ })
252
+
253
+ return {
254
+ h,
255
+ hashId,
256
+ container,
257
+ selectedAll,
258
+ visibleRows,
259
+ _indeterminate,
260
+ viewportHeight,
261
+ _columns,
262
+ _rowSelection,
263
+ totalHeight,
264
+ offsetY,
265
+ firstColumn,
266
+ onSelectedAllChange,
267
+ onScroll,
268
+ toggleExpand
269
+ }
270
+ }
271
+ })
@@ -0,0 +1,60 @@
1
+ function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// 扁平化数据
2
+ import { omit } from 'lodash-es'
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+ export const flattenTree = (
21
+ tree,
22
+ level = 0,
23
+ parentId = null
24
+ ) => {
25
+ return tree.flatMap((item) => {
26
+ const _children = (item.children || []).map((i) => {
27
+ return { ...omit(i, 'children') }
28
+ })
29
+ const flatNode = {
30
+ ...omit(item, 'children'),
31
+ _children,
32
+ level,
33
+ parentId,
34
+ expanded: false,
35
+ hasChildren: (_nullishCoalesce(_optionalChain([item, 'access', _ => _.children, 'optionalAccess', _2 => _2.length]), () => ( 0))) > 0,
36
+ visible: level === 0
37
+ }
38
+ const children = item.children ? flattenTree(item.children, level + 1, item.id) : []
39
+ return [flatNode, ...children]
40
+ })
41
+ }
42
+
43
+ export const findAllChildren = (
44
+ data = [],
45
+ parentId = null
46
+ ) => {
47
+ const result = []
48
+
49
+ function recursive(pid) {
50
+ data.forEach((item) => {
51
+ if (item.parentId === pid) {
52
+ result.push(item)
53
+ recursive(item.id) // 递归查找这个子节点的孩子
54
+ }
55
+ })
56
+ }
57
+
58
+ recursive(parentId)
59
+ return result
60
+ }
@@ -0,0 +1,7 @@
1
+ import VirtualTable from './VirtualTable.js'
2
+
3
+ VirtualTable.install = function (app) {
4
+ app.component(VirtualTable.name, VirtualTable)
5
+ }
6
+
7
+ export default VirtualTable
@@ -0,0 +1,34 @@
1
+ import genComponentStyle from '../../style/styleRegister'
2
+
3
+ const genVirtualTableStyle = () => {
4
+ return {
5
+ '.virtual-table-wrapper': {
6
+ display: 'flex',
7
+ 'flex-direction': 'column',
8
+ '.virtual-table-header': {
9
+ '.ant-table': {
10
+ '.ant-table-container': {
11
+ '.ant-table-content': {
12
+ '.ant-table-tbody': {
13
+ display: 'none'
14
+ }
15
+ }
16
+ }
17
+ }
18
+ },
19
+ '.virtual-table-body': {
20
+ 'overflow-y': 'auto',
21
+ position: 'relative',
22
+ 'min-height': '100px'
23
+ },
24
+ '.virtual-table-row-expand-icon': {
25
+ 'margin-right': '8px',
26
+ 'font-size': 'relative',
27
+ width: '16px',
28
+ display: 'inline-block'
29
+ }
30
+ }
31
+ }
32
+ }
33
+
34
+ export default genComponentStyle([genVirtualTableStyle])
@@ -0,0 +1,21 @@
1
+ export { default as BadgeStatus } from './BadgeStatus'
2
+ export { default as CardSelect } from './CardSelect'
3
+ export { default as CheckButton } from './CheckButton'
4
+ export { default as ConfigProvider } from './ConfigProvider'
5
+ export { default as Ellipsis } from './Ellipsis'
6
+ export { default as Empty } from './Empty'
7
+ export { default as FullPage } from './FullPage'
8
+ export { default as AIcon } from './Icon'
9
+ export { default as PermissionButton } from './PermissionButton'
10
+ export { default as ProLayout, PageContainer } from './ProLayout'
11
+ export { default as ProTable } from './ProTable'
12
+ export { default as Scrollbar } from './Scrollbar'
13
+ export { default as Search } from './Search'
14
+ export { default as ValueItem } from './ValueItem'
15
+ export { default as TimeFormat } from './TimeFormat'
16
+ export { default as DragModal } from './DragModal'
17
+ export { default as EditTable } from './EditTable'
18
+ export { default as Markdown } from './Markdown'
19
+ export { default as AutoComplete } from './AutoComplete'
20
+ export { default as Title } from './Title'
21
+ export { default as VirtualTable } from './VirtualTable'
package/lib/index.js ADDED
@@ -0,0 +1,17 @@
1
+ /*eslint import/namespace: ['error', { allowComputed: true }]*/
2
+ import * as components from './components'
3
+ export * from './components'
4
+
5
+ export const install = function (app, options = {}) {
6
+ Object.keys(components).forEach(function (key) {
7
+ const component = (components )[key]
8
+ if (component.install) {
9
+ app.use(component)
10
+ }
11
+ })
12
+ return app
13
+ }
14
+
15
+ export default {
16
+ install,
17
+ }
@@ -0,0 +1,120 @@
1
+ export default {
2
+ DragModal: {
3
+ cancel: 'Cancel',
4
+ confirm: 'Confirm'
5
+ },
6
+ Search: {
7
+ search: {
8
+ reset: 'Reset',
9
+ search: 'Search'
10
+ },
11
+ advanced: {
12
+ search: 'Search',
13
+ reset: 'Reset',
14
+ more: 'More',
15
+ saveHistory: {
16
+ searchName: 'Search name',
17
+ placeholder: 'Please enter a name',
18
+ ruleName: 'Up to 64 characters',
19
+ save: 'Save',
20
+ success: 'Operation successful',
21
+ fail: 'Operation fail'
22
+ },
23
+ history: {
24
+ confirmDelete: 'Confirm Delete?',
25
+ search: 'Search'
26
+ }
27
+ },
28
+ item: {
29
+ firstGroup: 'Group One',
30
+ secondGroup: 'Group Two',
31
+ placeholder: 'Please select'
32
+ },
33
+ setting: {
34
+ or: 'Or',
35
+ and: 'And',
36
+ include: 'Include',
37
+ exclude: 'Exclude',
38
+ in: 'In',
39
+ notIn: 'Not in',
40
+ between: 'Between',
41
+ notBetween: 'Not Between'
42
+ }
43
+ },
44
+ Empty: {
45
+ description: 'No Data'
46
+ },
47
+ ProTable: {
48
+ pagination: {
49
+ page: 'Articles {0} - {1}/Total of',
50
+ total: '',
51
+ lastPage: 'It is already the last page'
52
+ },
53
+ alert: {
54
+ cancelChoose: 'Cancel selection',
55
+ selectItem: 'Select {0} items'
56
+ },
57
+ select: {
58
+ all: 'Select all'
59
+ }
60
+ },
61
+ ProLayout: {
62
+ pageContainer: {
63
+ back: 'Back'
64
+ }
65
+ },
66
+ EditTable: {
67
+ serial: 'Serial',
68
+ columns: {
69
+ sign: 'Sign',
70
+ name: 'Name',
71
+ count: 'count'
72
+ },
73
+ contextMenu: {
74
+ add: 'Add',
75
+ copy: 'Copy',
76
+ paste: 'Paste',
77
+ detail: 'View details',
78
+ delete: 'Delete'
79
+ },
80
+ Search: {
81
+ find: 'Find',
82
+ placeholder: 'Please enter the search content',
83
+ all: 'Find all',
84
+ prev: 'Previous',
85
+ next: 'Next',
86
+ close: 'Close',
87
+ rows: 'Rows',
88
+ row: 'Line',
89
+ rd: '',
90
+ found: 'Found',
91
+ related: 'Related'
92
+ },
93
+ Sort: {
94
+ sort: 'Sort',
95
+ clean: 'Clear conditions',
96
+ up: 'Ascending order',
97
+ down: 'Descending order'
98
+ },
99
+ Group: {
100
+ one: 'Grouping_',
101
+ edit: 'Edit',
102
+ delete: 'Delete',
103
+ validate: 'Verify non-compliance',
104
+ editGroup: 'Edit Group',
105
+ addGroup: 'Add Group',
106
+ placeholder: 'Please enter the group name',
107
+ max: 'Up to 16 characters can be entered',
108
+ deleteMessage: 'Will the data within the group be synchronously deleted? Are you sure about deletion?'
109
+ }
110
+ },
111
+ ValueItem: {
112
+ placeholder: 'Please enter the link',
113
+ cancel: 'Cancel',
114
+ confirm: 'Confirm',
115
+ title: 'Edit'
116
+ },
117
+ PermissionButton: {
118
+ hasPermission: 'No permission, please contact the administrator'
119
+ }
120
+ }
@@ -0,0 +1,120 @@
1
+ export default {
2
+ DragModal: {
3
+ cancel: '取消',
4
+ confirm: '确定'
5
+ },
6
+ Search: {
7
+ search: {
8
+ reset: '重置',
9
+ search: '搜索'
10
+ },
11
+ advanced: {
12
+ search: '搜索',
13
+ reset: '重置',
14
+ more: '更多筛选',
15
+ saveHistory: {
16
+ searchName: '搜索名称',
17
+ placeholder: '请输入名称',
18
+ ruleName: '最多64个字符',
19
+ save: '保存',
20
+ success: '操作成功',
21
+ fail: '操作失败'
22
+ },
23
+ history: {
24
+ confirmDelete: '确认删除吗?',
25
+ search: '搜索'
26
+ }
27
+ },
28
+ item: {
29
+ firstGroup: '第一组',
30
+ secondGroup: '第二组',
31
+ placeholder: '请选择'
32
+ },
33
+ setting: {
34
+ or: '或者',
35
+ and: '并且',
36
+ include: '包含',
37
+ exclude: '不包含',
38
+ in: '在...之中',
39
+ notIn: '不在...之中',
40
+ between: '在...之间',
41
+ notBetween: '不在...之间'
42
+ }
43
+ },
44
+ Empty: {
45
+ description: '暂无数据'
46
+ },
47
+ ProTable: {
48
+ pagination: {
49
+ page: '第 {0} - {1} 条/总共',
50
+ total: '条',
51
+ lastPage: '已是最后一页'
52
+ },
53
+ alert: {
54
+ cancelChoose: '取消选择',
55
+ selectItem: '已选择 {0} 项'
56
+ },
57
+ select: {
58
+ all: '全选'
59
+ }
60
+ },
61
+ ProLayout: {
62
+ pageContainer: {
63
+ back: '返回'
64
+ }
65
+ },
66
+ EditTable: {
67
+ serial: '序号',
68
+ columns: {
69
+ sign: '标识',
70
+ name: '名称',
71
+ count: '计数'
72
+ },
73
+ contextMenu: {
74
+ add: '新增行',
75
+ copy: '复制行',
76
+ paste: '粘贴行',
77
+ detail: '查看详情',
78
+ delete: '删除'
79
+ },
80
+ Search: {
81
+ find: '查找',
82
+ placeholder: '请输入查找内容',
83
+ all: '查找全部',
84
+ prev: '上一个',
85
+ next: '下一个',
86
+ close: '关闭',
87
+ rows: '行数',
88
+ row: '行',
89
+ rd: '第',
90
+ found: '查找到',
91
+ related: '条相关属性'
92
+ },
93
+ Sort: {
94
+ sort: '排序',
95
+ clean: '清空条件',
96
+ up: '升序',
97
+ down: '降序'
98
+ },
99
+ Group: {
100
+ one: '分组_',
101
+ edit: '编辑',
102
+ delete: '删除',
103
+ validate: '校验不合规',
104
+ editGroup: '编辑分组',
105
+ addGroup: '新增分组',
106
+ placeholder: '请输入分组名称',
107
+ max: '最多可输入16个字符',
108
+ deleteMessage: '将会同步删除分组内的数据,确认删除?'
109
+ }
110
+ },
111
+ ValueItem: {
112
+ placeholder: '请输入链接',
113
+ cancel: '取消',
114
+ confirm: '确定',
115
+ title: '编辑'
116
+ },
117
+ PermissionButton: {
118
+ hasPermission: '暂无权限,请联系管理员'
119
+ }
120
+ }
@@ -0,0 +1,19 @@
1
+ import { genComponentStyleHook } from 'ant-design-vue/es/theme/internal'
2
+ import { theme } from 'ant-design-vue'
3
+ import variableToken from './variable'
4
+
5
+
6
+
7
+ const genComponentStyle = (styleFn) => {
8
+ return genComponentStyleHook('jetlinks-components', (_token) => {
9
+ const { token, hashId } = theme.useToken()
10
+ const componentToken = {
11
+ token: { ..._token, ...variableToken },
12
+ hashId: hashId.value,
13
+ componentCls: `.${_token.prefixCls}`
14
+ }
15
+ return [...styleFn.map((item) => item(componentToken))]
16
+ })
17
+ }
18
+
19
+ export default genComponentStyle
@@ -0,0 +1,4 @@
1
+ export default {
2
+ textColorTitle: '#000',
3
+ textColorSubtitle: '#263237'
4
+ }
package/lib/style.js ADDED
@@ -0,0 +1 @@
1
+ // Style entry - import component styles here if needed
@@ -0,0 +1,10 @@
1
+ export const ComponentsEnum = {
2
+ Icon: Symbol('jetlinks-icon'),
3
+ Permission: Symbol('permission')
4
+ }
5
+
6
+ export const MAPConfig = Symbol('map_key')
7
+ export const SearchConfig = Symbol('search-config')
8
+ export const PermissionButtonConfig = Symbol('permission-button')
9
+ export const FullPageConfig = Symbol('full-page')
10
+ export const TableConfig = Symbol('table-config')