@meethive/components 0.0.2 → 0.0.4

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 (111) hide show
  1. package/es/AutoComplete/AutoComplete.js +71 -80
  2. package/es/BadgeStatus/Badge.js +38 -47
  3. package/es/CardSelect/CardSelect.js +115 -137
  4. package/es/CheckButton/CheckButton.js +102 -118
  5. package/es/ConfigProvider/ConfigProvider.js +44 -68
  6. package/es/DragModal/DragModal.js +191 -212
  7. package/es/EditTable/Body.js +158 -189
  8. package/es/EditTable/CellRender.js +10 -12
  9. package/es/EditTable/EditTable.js +385 -434
  10. package/es/EditTable/FormItem.js +140 -169
  11. package/es/EditTable/Group.js +171 -204
  12. package/es/EditTable/Header.js +57 -63
  13. package/es/EditTable/HeaderRender.js +10 -12
  14. package/es/EditTable/components/ContextMenu/Menu.js +78 -86
  15. package/es/EditTable/components/Search/Search.js +151 -163
  16. package/es/EditTable/components/Search/Sort.js +104 -119
  17. package/es/Ellipsis/Ellipsis.js +144 -148
  18. package/es/Empty/Empty.js +51 -57
  19. package/es/FullPage/FullPage.js +20 -19
  20. package/es/Icon/Icon.js +42 -49
  21. package/es/LocaleProvider/LocaleProvider.js +38 -31
  22. package/es/Markdown/Markdown.js +101 -118
  23. package/es/PermissionButton/PermissionButton.js +118 -118
  24. package/es/ProLayout/Basic/BasicLayout.js +301 -418
  25. package/es/ProLayout/Basic/Header.js +91 -111
  26. package/es/ProLayout/PageContainer/index.js +267 -344
  27. package/es/ProLayout/SiderMenu/BaseMenu.js +186 -240
  28. package/es/ProTable/Alert.js +39 -40
  29. package/es/ProTable/Content.js +84 -97
  30. package/es/ProTable/Header.js +32 -33
  31. package/es/ProTable/Pagination.js +56 -55
  32. package/es/ProTable/ProTable.js +256 -276
  33. package/es/RadioButton/RadioButton.js +48 -53
  34. package/es/Scrollbar/Bar.js +65 -76
  35. package/es/Scrollbar/Scrollbar.js +129 -161
  36. package/es/Scrollbar/Thumb.js +101 -150
  37. package/es/Search/Item.js +208 -236
  38. package/es/Search/Search.js +90 -90
  39. package/es/Skeleton/Skeleton.js +26 -27
  40. package/es/Skeleton/components/DashBoardCard.js +26 -27
  41. package/es/Skeleton/components/DashBoardChart.js +26 -27
  42. package/es/Skeleton/components/Detail.js +26 -27
  43. package/es/Skeleton/components/Drawer.js +26 -27
  44. package/es/Skeleton/components/Item.js +55 -54
  45. package/es/Skeleton/components/List.js +29 -27
  46. package/es/Skeleton/components/ListCard.js +28 -28
  47. package/es/Skeleton/components/ListCardItem.js +20 -20
  48. package/es/Skeleton/components/ListTable.js +26 -27
  49. package/es/Skeleton/components/Page.js +27 -26
  50. package/es/Skeleton/components/Search.js +16 -16
  51. package/es/Skeleton/components/Tree.js +26 -27
  52. package/es/TimeFormat/TimeFormat.js +32 -36
  53. package/es/Title/Title.js +23 -26
  54. package/es/ValueItem/ValueItem.js +100 -113
  55. package/es/VirtualTable/VirtualTable.js +235 -271
  56. package/lib/AutoComplete/AutoComplete.js +71 -80
  57. package/lib/BadgeStatus/Badge.js +38 -47
  58. package/lib/CardSelect/CardSelect.js +115 -137
  59. package/lib/CheckButton/CheckButton.js +102 -118
  60. package/lib/ConfigProvider/ConfigProvider.js +44 -68
  61. package/lib/DragModal/DragModal.js +191 -212
  62. package/lib/EditTable/Body.js +158 -189
  63. package/lib/EditTable/CellRender.js +10 -12
  64. package/lib/EditTable/EditTable.js +385 -434
  65. package/lib/EditTable/FormItem.js +140 -169
  66. package/lib/EditTable/Group.js +171 -204
  67. package/lib/EditTable/Header.js +57 -63
  68. package/lib/EditTable/HeaderRender.js +10 -12
  69. package/lib/EditTable/components/ContextMenu/Menu.js +78 -86
  70. package/lib/EditTable/components/Search/Search.js +151 -163
  71. package/lib/EditTable/components/Search/Sort.js +104 -119
  72. package/lib/Ellipsis/Ellipsis.js +144 -148
  73. package/lib/Empty/Empty.js +51 -57
  74. package/lib/FullPage/FullPage.js +20 -19
  75. package/lib/Icon/Icon.js +42 -49
  76. package/lib/LocaleProvider/LocaleProvider.js +38 -31
  77. package/lib/Markdown/Markdown.js +101 -118
  78. package/lib/PermissionButton/PermissionButton.js +118 -118
  79. package/lib/ProLayout/Basic/BasicLayout.js +301 -418
  80. package/lib/ProLayout/Basic/Header.js +91 -111
  81. package/lib/ProLayout/PageContainer/index.js +267 -344
  82. package/lib/ProLayout/SiderMenu/BaseMenu.js +186 -240
  83. package/lib/ProTable/Alert.js +39 -40
  84. package/lib/ProTable/Content.js +84 -97
  85. package/lib/ProTable/Header.js +32 -33
  86. package/lib/ProTable/Pagination.js +56 -55
  87. package/lib/ProTable/ProTable.js +256 -276
  88. package/lib/RadioButton/RadioButton.js +48 -53
  89. package/lib/Scrollbar/Bar.js +65 -76
  90. package/lib/Scrollbar/Scrollbar.js +129 -161
  91. package/lib/Scrollbar/Thumb.js +101 -150
  92. package/lib/Search/Item.js +208 -236
  93. package/lib/Search/Search.js +90 -90
  94. package/lib/Skeleton/Skeleton.js +26 -27
  95. package/lib/Skeleton/components/DashBoardCard.js +26 -27
  96. package/lib/Skeleton/components/DashBoardChart.js +26 -27
  97. package/lib/Skeleton/components/Detail.js +26 -27
  98. package/lib/Skeleton/components/Drawer.js +26 -27
  99. package/lib/Skeleton/components/Item.js +55 -54
  100. package/lib/Skeleton/components/List.js +29 -27
  101. package/lib/Skeleton/components/ListCard.js +28 -28
  102. package/lib/Skeleton/components/ListCardItem.js +20 -20
  103. package/lib/Skeleton/components/ListTable.js +26 -27
  104. package/lib/Skeleton/components/Page.js +27 -26
  105. package/lib/Skeleton/components/Search.js +16 -16
  106. package/lib/Skeleton/components/Tree.js +26 -27
  107. package/lib/TimeFormat/TimeFormat.js +32 -36
  108. package/lib/Title/Title.js +23 -26
  109. package/lib/ValueItem/ValueItem.js +100 -113
  110. package/lib/VirtualTable/VirtualTable.js +235 -271
  111. package/package.json +1 -1
@@ -1,271 +1,235 @@
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
- })
1
+ import { defineComponent, computed, ref, watch, onMounted, nextTick, h } from 'vue';
2
+ import { Table, Checkbox } from 'ant-design-vue';
3
+ import { isNumber, map, omit } from 'lodash-es';
4
+ import AIcon from '../Icon';
5
+ import useVirtualTableStyle from './style';
6
+ import { useLocaleReceiver } from '../LocaleReciver';
7
+ import { findAllChildren, flattenTree } from './data';
8
+ const buffer = 5;
9
+ export default defineComponent({
10
+ name: 'JVirtualTable',
11
+ components: {
12
+ Table,
13
+ Checkbox,
14
+ AIcon
15
+ },
16
+ props: {
17
+ dataSource: {
18
+ type: Array,
19
+ default: () => []
20
+ },
21
+ columns: {
22
+ type: Array,
23
+ default: () => []
24
+ },
25
+ expandedRowKeys: {
26
+ type: Array,
27
+ default: () => []
28
+ },
29
+ rowSelection: {
30
+ type: Object
31
+ },
32
+ rowKey: {
33
+ type: [String, Function],
34
+ default: 'id'
35
+ },
36
+ height: {
37
+ type: Number,
38
+ default: 500
39
+ }
40
+ },
41
+ emits: ['update:expandedRowKeys'],
42
+ setup(props, {
43
+ emit
44
+ }) {
45
+ const prefixCls = computed(() => 'virtual-table');
46
+ const [wrapSSR, hashId] = useVirtualTableStyle(prefixCls);
47
+ const [contextLocale] = useLocaleReceiver('ProTable');
48
+ const container = ref(null);
49
+ const rowHeights = ref([]);
50
+ const prefixSum = ref([]);
51
+ const start = ref(0);
52
+ const end = ref(15);
53
+ const offsetY = ref(0);
54
+ const selectedAll = ref(false);
55
+ // 被展开的所有数据
56
+ const visibleNodes = ref([]);
57
+ const flattenData = ref([]);
58
+ const firstColumn = computed(() => props.columns[0]);
59
+ const totalHeight = computed(() => prefixSum.value.length ? prefixSum.value[prefixSum.value.length - 1] : 0);
60
+ const visibleRows = computed(() => visibleNodes.value.slice(start.value, end.value));
61
+ const _indeterminate = computed(() => !selectedAll.value && (props.rowSelection?.selectedRowKeys?.length ?? 0) > 0);
62
+ const viewportHeight = computed(() => props.height || 500);
63
+ const _columns = computed(() => {
64
+ const arr = [];
65
+ if (props.rowSelection) {
66
+ const _width = props.rowSelection.columnWidth || 32;
67
+ arr.push({
68
+ key: '__selection__',
69
+ title: contextLocale.value.select.all,
70
+ dataIndex: '__selection__',
71
+ width: isNumber(_width) ? `${_width}px` : _width,
72
+ customHeaderCell: props => {
73
+ return {
74
+ class: 'ant-table-selection-column'
75
+ };
76
+ }
77
+ });
78
+ }
79
+ arr.push(...props.columns);
80
+ return arr;
81
+ });
82
+ const _rowSelection = computed(() => {
83
+ return props.rowSelection ? {
84
+ ...props.rowSelection,
85
+ onSelect: (record, selected, selectedRows, nativeEvent) => {
86
+ const _selectedRowKeys = props.rowSelection.selectedRowKeys || [];
87
+ const _set = new Set([..._selectedRowKeys]);
88
+ if (props.rowSelection.type === 'radio') {
89
+ _set.clear();
90
+ _set.add(record[props.rowKey]);
91
+ } else {
92
+ const _checkStrictly = props.rowSelection.checkStrictly !== undefined ? props.rowSelection.checkStrictly : true;
93
+ let __arr = [];
94
+ if (_checkStrictly) {
95
+ // 需要获取子
96
+ __arr = [record[props.rowKey]];
97
+ } else {
98
+ __arr = map(findAllChildren(flattenData.value, record[props.rowKey]), props.rowKey);
99
+ __arr.push(record[props.rowKey]);
100
+ }
101
+ if (selected) {
102
+ __arr.forEach(i => _set.add(i));
103
+ } else {
104
+ __arr.forEach(i => _set.delete(i));
105
+ }
106
+ }
107
+ const _selectedRows = flattenData.value.filter(i => _set.has(i[props.rowKey])).map(item => omit(item, ['expanded', 'hasChildren', 'visible']));
108
+ if (props.rowSelection.onSelect) {
109
+ props.rowSelection.onSelect(record, selected, _selectedRows, nativeEvent);
110
+ }
111
+ if (props.rowSelection.onChange) {
112
+ props.rowSelection.onChange([..._set], _selectedRows);
113
+ }
114
+ },
115
+ onChange: () => {},
116
+ onSelectAll: () => {},
117
+ onSelectNone: () => {
118
+ if (props.rowSelection.onSelectNone) {
119
+ props.rowSelection.onSelectNone();
120
+ }
121
+ }
122
+ } : undefined;
123
+ });
124
+ const onSelectedAllChange = e => {
125
+ const selected = e.target.checked;
126
+ const arr = flattenData.value.map(i => omit(i, ['expanded', 'hasChildren', 'visible']));
127
+ const _checked = selected;
128
+ const _selectedRowKeys = _checked ? map(arr, props.rowKey) : [];
129
+ if (props.rowSelection.onSelectAll) {
130
+ props.rowSelection.onSelectAll(_checked, _checked ? arr : []);
131
+ }
132
+ if (props.rowSelection.onChange) {
133
+ props.rowSelection.onChange(_selectedRowKeys, _checked ? arr : []);
134
+ }
135
+ };
136
+ const onScroll = e => {
137
+ const scrollTop = e.target.scrollTop;
138
+ const vh = viewportHeight.value || 500;
139
+ const total = totalHeight.value;
140
+ // 防止 scrollTop 超出范围
141
+ const clampedScrollTop = Math.min(scrollTop, total - vh);
142
+ // 二分查找
143
+ let low = 0,
144
+ high = prefixSum.value.length - 1;
145
+ while (low < high) {
146
+ const mid = Math.floor((low + high) / 2);
147
+ if (prefixSum.value[mid] <= clampedScrollTop) low = mid + 1;else high = mid;
148
+ }
149
+ const newStart = Math.max(0, low - 1);
150
+ // 如果 start 没变化,直接跳过,避免重复计算导致闪动
151
+ if (newStart === start.value) return;
152
+ start.value = newStart;
153
+ // 计算 end
154
+ let y = prefixSum.value[start.value] || 0;
155
+ let i = start.value;
156
+ while (i < visibleNodes.value.length && y < clampedScrollTop + vh) {
157
+ y += rowHeights.value[i] || 40;
158
+ i++;
159
+ }
160
+ end.value = Math.min(i + buffer, visibleNodes.value.length);
161
+ // 防止 offsetY 波动
162
+ offsetY.value = prefixSum.value[start.value - 1] || 0;
163
+ };
164
+ const toggleExpand = row => {
165
+ row.expanded = !row.expanded;
166
+ const stack = [...flattenData.value.filter(n => n.parentId === row[props.rowKey])];
167
+ while (stack.length) {
168
+ const child = stack.pop();
169
+ child.visible = row.expanded;
170
+ if (!child.visible) {
171
+ child.expanded = false;
172
+ }
173
+ if (!row.expanded && child.hasChildren) {
174
+ stack.push(...flattenData.value.filter(n => n.parentId === child[props.rowKey]));
175
+ }
176
+ }
177
+ updateVisibleNodes();
178
+ };
179
+ const updatePrefixSum = () => {
180
+ rowHeights.value = visibleNodes.value.map(() => 40); // 默认行高
181
+ prefixSum.value = [];
182
+ let sum = 0;
183
+ for (let h of rowHeights.value) {
184
+ sum += h;
185
+ prefixSum.value.push(sum);
186
+ }
187
+ };
188
+ const updateVisibleNodes = () => {
189
+ visibleNodes.value = flattenData.value.filter(i => i.visible);
190
+ updatePrefixSum();
191
+ console.log('123');
192
+ nextTick(() => onScroll({
193
+ target: container.value
194
+ }));
195
+ };
196
+ watch(() => [JSON.stringify(props.dataSource), JSON.stringify(props.expandedRowKeys)], () => {
197
+ flattenData.value = flattenTree(props.dataSource, 0, null);
198
+ flattenData.value.forEach(i => {
199
+ if (props.expandedRowKeys.includes(i[props.rowKey])) {
200
+ toggleExpand(i);
201
+ }
202
+ });
203
+ updateVisibleNodes();
204
+ }, {
205
+ immediate: true
206
+ });
207
+ watch(() => props.rowSelection?.selectedRowKeys, val => {
208
+ if (val) {
209
+ selectedAll.value = val.length > 0 && flattenData.value.length === val.length;
210
+ }
211
+ }, {
212
+ immediate: true
213
+ });
214
+ onMounted(() => {
215
+ updateVisibleNodes();
216
+ });
217
+ return {
218
+ h,
219
+ hashId,
220
+ container,
221
+ selectedAll,
222
+ visibleRows,
223
+ _indeterminate,
224
+ viewportHeight,
225
+ _columns,
226
+ _rowSelection,
227
+ totalHeight,
228
+ offsetY,
229
+ firstColumn,
230
+ onSelectedAllChange,
231
+ onScroll,
232
+ toggleExpand
233
+ };
234
+ }
235
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meethive/components",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",