@meethive/components 0.0.3 → 0.0.5

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 +32 -38
  22. package/es/Markdown/Markdown.js +101 -118
  23. package/es/PermissionButton/PermissionButton.js +118 -118
  24. package/es/ProLayout/Basic/BasicLayout.js +361 -418
  25. package/es/ProLayout/Basic/Header.js +97 -111
  26. package/es/ProLayout/PageContainer/index.js +298 -344
  27. package/es/ProLayout/SiderMenu/BaseMenu.js +233 -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 +32 -38
  77. package/lib/Markdown/Markdown.js +101 -118
  78. package/lib/PermissionButton/PermissionButton.js +118 -118
  79. package/lib/ProLayout/Basic/BasicLayout.js +361 -418
  80. package/lib/ProLayout/Basic/Header.js +97 -111
  81. package/lib/ProLayout/PageContainer/index.js +298 -344
  82. package/lib/ProLayout/SiderMenu/BaseMenu.js +233 -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,189 +1,158 @@
1
- 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, ref, reactive, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue'
3
- import ContextMenu from './components/ContextMenu'
4
- import { useHScroll, useRightMenuContext } from './hooks'
5
- import { randomString } from '@meethive/utils'
6
- import { bodyProps } from './props'
7
- import Empty from '../Empty/Empty.js'
8
- import CellRender from './CellRender.js'
9
- import genEditTableStyle from './style'
10
-
11
- export default defineComponent({
12
- name: 'JEditTableBody',
13
- components: {
14
- Empty,
15
- CellRender
16
- },
17
- props: {
18
- ...bodyProps(),
19
- groupKey: {
20
- type: [String, Number],
21
- default: undefined
22
- },
23
- width: {
24
- type: Number
25
- },
26
- readonly: {
27
- type: Boolean,
28
- default: false
29
- }
30
- } ,
31
- emits: ['update:dataSource', 'scrollDown'],
32
- setup(props, { emit, expose }) {
33
- const prefixCls = computed(() => 'jetlinks-edit-table')
34
- const [wrapSSR, hashId] = genEditTableStyle(prefixCls)
35
-
36
- const viewScrollRef = ref()
37
- const tableCenterRef = ref()
38
- const virtualRang = reactive({
39
- start: 0,
40
- end: 15
41
- })
42
- const containerStyle = ref(0)
43
- const context = useRightMenuContext()
44
- const hScroll = useHScroll()
45
-
46
- let scrollLock = ref(false)
47
- let menuInstance
48
-
49
- const maxLen = computed(() => {
50
- return Math.trunc(props.height / props.cellHeight)
51
- })
52
-
53
- const selectedRowKeys = ref([])
54
-
55
- const virtualData = computed(() => {
56
- return props.dataSource.slice(virtualRang.start, virtualRang.end)
57
- })
58
-
59
- const onScroll = () => {
60
- if (!viewScrollRef.value) return
61
- const height = viewScrollRef.value.scrollTop
62
- const clientHeight = viewScrollRef.value.clientHeight
63
-
64
- const _index = Math.round(height / props.cellHeight) - 1
65
- const start = _index < 0 ? 0 : _index
66
- const end = start + maxLen.value + 4
67
-
68
- if (
69
- height + clientHeight >= props.dataSource.length * props.cellHeight &&
70
- !scrollLock.value
71
- ) {
72
- emit('scrollDown')
73
- scrollLock.value = true
74
- }
75
-
76
- virtualRang.start = start
77
- virtualRang.end = end
78
- }
79
-
80
- const scrollTo = (index) => {
81
- if (viewScrollRef.value) {
82
- viewScrollRef.value.scrollTop = index * props.cellHeight
83
- }
84
- }
85
-
86
- const showContextMenu = (e, record, _index) => {
87
- e.preventDefault()
88
- if (props.disableMenu) {
89
- const newRecord = {
90
- ...record,
91
- __index: _index
92
- }
93
- menuInstance = ContextMenu(e, newRecord, context)
94
- }
95
- }
96
-
97
- const rowClick = (record) => {
98
- if (_optionalChain([props, 'access', _ => _.rowSelection, 'optionalAccess', _2 => _2.selectedRowKeys])) {
99
- const rowSet = new Set(selectedRowKeys.value)
100
- const key = record[props.rowKey]
101
- const selected = !rowSet.has(key)
102
- if (selected) {
103
- rowSet.delete(key)
104
- } else {
105
- rowSet.add(key)
106
- }
107
- _optionalChain([props, 'access', _3 => _3.rowSelection, 'access', _4 => _4.onSelect, 'optionalCall', _5 => _5(record, selected)])
108
- selectedRowKeys.value = [...rowSet.values()]
109
- }
110
- }
111
-
112
- const updateSelectedKeys = (keys) => {
113
- selectedRowKeys.value = keys
114
- }
115
-
116
- onMounted(() => {
117
- nextTick(() => {
118
- onScroll()
119
- })
120
- })
121
-
122
- onBeforeUnmount(() => {
123
- _optionalChain([menuInstance, 'optionalAccess', _6 => _6.destroy, 'optionalCall', _7 => _7()])
124
- _optionalChain([menuInstance, 'optionalAccess', _8 => _8.cleanCopy, 'optionalCall', _9 => _9()])
125
- })
126
-
127
- watch(
128
- () => JSON.stringify(_optionalChain([props, 'access', _10 => _10.rowSelection, 'optionalAccess', _11 => _11.selectedRowKeys])),
129
- (val) => {
130
- selectedRowKeys.value = JSON.parse(val || '[]')
131
- },
132
- { immediate: true }
133
- )
134
-
135
- watch(
136
- () => props.dataSource,
137
- () => {
138
- props.dataSource.forEach((item) => {
139
- if (!item.__key) {
140
- item.__key = randomString()
141
- }
142
- })
143
- },
144
- { immediate: true, deep: true }
145
- )
146
-
147
- watch(
148
- () => props.dataSource.length,
149
- () => {
150
- scrollLock.value = false
151
- containerStyle.value = {
152
- height: props.dataSource.length * props.cellHeight + 'px'
153
- }
154
- if (props.dataSource.length <= maxLen.value || props.dataSource.length === 0) {
155
- emit('scrollDown', maxLen.value - props.dataSource.length + 3)
156
- }
157
- },
158
- { immediate: true }
159
- )
160
-
161
- watch(
162
- () => props.groupKey,
163
- () => {
164
- if (props.openGroup) {
165
- scrollTo(0)
166
- }
167
- }
168
- )
169
-
170
- expose({
171
- scrollTo,
172
- updateSelectedKeys
173
- })
174
-
175
- return {
176
- hashId,
177
- viewScrollRef,
178
- tableCenterRef,
179
- virtualRang,
180
- containerStyle,
181
- hScroll,
182
- selectedRowKeys,
183
- virtualData,
184
- onScroll,
185
- showContextMenu,
186
- rowClick
187
- }
188
- }
189
- })
1
+ import { defineComponent, ref, reactive, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue';
2
+ import ContextMenu from './components/ContextMenu';
3
+ import { useHScroll, useRightMenuContext } from './hooks';
4
+ import { randomString } from '@meethive/utils';
5
+ import { bodyProps } from './props';
6
+ import Empty from '../Empty/Empty.js';
7
+ import CellRender from './CellRender.js';
8
+ import genEditTableStyle from './style';
9
+ export default defineComponent({
10
+ name: 'JEditTableBody',
11
+ components: {
12
+ Empty,
13
+ CellRender
14
+ },
15
+ props: {
16
+ ...bodyProps(),
17
+ groupKey: {
18
+ type: [String, Number],
19
+ default: undefined
20
+ },
21
+ width: {
22
+ type: Number
23
+ },
24
+ readonly: {
25
+ type: Boolean,
26
+ default: false
27
+ }
28
+ },
29
+ emits: ['update:dataSource', 'scrollDown'],
30
+ setup(props, {
31
+ emit,
32
+ expose
33
+ }) {
34
+ const prefixCls = computed(() => 'jetlinks-edit-table');
35
+ const [wrapSSR, hashId] = genEditTableStyle(prefixCls);
36
+ const viewScrollRef = ref();
37
+ const tableCenterRef = ref();
38
+ const virtualRang = reactive({
39
+ start: 0,
40
+ end: 15
41
+ });
42
+ const containerStyle = ref(0);
43
+ const context = useRightMenuContext();
44
+ const hScroll = useHScroll();
45
+ let scrollLock = ref(false);
46
+ let menuInstance;
47
+ const maxLen = computed(() => {
48
+ return Math.trunc(props.height / props.cellHeight);
49
+ });
50
+ const selectedRowKeys = ref([]);
51
+ const virtualData = computed(() => {
52
+ return props.dataSource.slice(virtualRang.start, virtualRang.end);
53
+ });
54
+ const onScroll = () => {
55
+ if (!viewScrollRef.value) return;
56
+ const height = viewScrollRef.value.scrollTop;
57
+ const clientHeight = viewScrollRef.value.clientHeight;
58
+ const _index = Math.round(height / props.cellHeight) - 1;
59
+ const start = _index < 0 ? 0 : _index;
60
+ const end = start + maxLen.value + 4;
61
+ if (height + clientHeight >= props.dataSource.length * props.cellHeight && !scrollLock.value) {
62
+ emit('scrollDown');
63
+ scrollLock.value = true;
64
+ }
65
+ virtualRang.start = start;
66
+ virtualRang.end = end;
67
+ };
68
+ const scrollTo = index => {
69
+ if (viewScrollRef.value) {
70
+ viewScrollRef.value.scrollTop = index * props.cellHeight;
71
+ }
72
+ };
73
+ const showContextMenu = (e, record, _index) => {
74
+ e.preventDefault();
75
+ if (props.disableMenu) {
76
+ const newRecord = {
77
+ ...record,
78
+ __index: _index
79
+ };
80
+ menuInstance = ContextMenu(e, newRecord, context);
81
+ }
82
+ };
83
+ const rowClick = record => {
84
+ if (props.rowSelection?.selectedRowKeys) {
85
+ const rowSet = new Set(selectedRowKeys.value);
86
+ const key = record[props.rowKey];
87
+ const selected = !rowSet.has(key);
88
+ if (selected) {
89
+ rowSet.delete(key);
90
+ } else {
91
+ rowSet.add(key);
92
+ }
93
+ props.rowSelection.onSelect?.(record, selected);
94
+ selectedRowKeys.value = [...rowSet.values()];
95
+ }
96
+ };
97
+ const updateSelectedKeys = keys => {
98
+ selectedRowKeys.value = keys;
99
+ };
100
+ onMounted(() => {
101
+ nextTick(() => {
102
+ onScroll();
103
+ });
104
+ });
105
+ onBeforeUnmount(() => {
106
+ menuInstance?.destroy?.();
107
+ menuInstance?.cleanCopy?.();
108
+ });
109
+ watch(() => JSON.stringify(props.rowSelection?.selectedRowKeys), val => {
110
+ selectedRowKeys.value = JSON.parse(val || '[]');
111
+ }, {
112
+ immediate: true
113
+ });
114
+ watch(() => props.dataSource, () => {
115
+ props.dataSource.forEach(item => {
116
+ if (!item.__key) {
117
+ item.__key = randomString();
118
+ }
119
+ });
120
+ }, {
121
+ immediate: true,
122
+ deep: true
123
+ });
124
+ watch(() => props.dataSource.length, () => {
125
+ scrollLock.value = false;
126
+ containerStyle.value = {
127
+ height: props.dataSource.length * props.cellHeight + 'px'
128
+ };
129
+ if (props.dataSource.length <= maxLen.value || props.dataSource.length === 0) {
130
+ emit('scrollDown', maxLen.value - props.dataSource.length + 3);
131
+ }
132
+ }, {
133
+ immediate: true
134
+ });
135
+ watch(() => props.groupKey, () => {
136
+ if (props.openGroup) {
137
+ scrollTo(0);
138
+ }
139
+ });
140
+ expose({
141
+ scrollTo,
142
+ updateSelectedKeys
143
+ });
144
+ return {
145
+ hashId,
146
+ viewScrollRef,
147
+ tableCenterRef,
148
+ virtualRang,
149
+ containerStyle,
150
+ hScroll,
151
+ selectedRowKeys,
152
+ virtualData,
153
+ onScroll,
154
+ showContextMenu,
155
+ rowClick
156
+ };
157
+ }
158
+ });
@@ -1,12 +1,10 @@
1
-
2
- import { defineComponent } from 'vue'
3
-
4
- export default defineComponent({
5
- name: 'CellRender',
6
- props: ['renderFn', 'value', 'record', 'index'],
7
- setup(props) {
8
- return () => {
9
- return props.renderFn(props.value, props.record, props.index)
10
- }
11
- }
12
- })
1
+ import { defineComponent } from 'vue';
2
+ export default defineComponent({
3
+ name: 'CellRender',
4
+ props: ['renderFn', 'value', 'record', 'index'],
5
+ setup(props) {
6
+ return () => {
7
+ return props.renderFn(props.value, props.record, props.index);
8
+ };
9
+ }
10
+ });