@meethive/components 0.0.3 → 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 +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 +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 +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 +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,150 +1,101 @@
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, computed, inject, onBeforeUnmount, ref, toRef } from 'vue'
3
- import { useEventListener } from '@vueuse/core'
4
- import { isClient } from '@meethive/utils'
5
- import { scrollbarContextKey } from './constants'
6
- import { BAR_MAP, renderThumbStyle } from './util'
7
- import { thumbProps } from './thumbProps'
8
- import useScrollbarStyle from './style'
9
-
10
- export default defineComponent({
11
- name: 'ScrollbarThumb',
12
- props: thumbProps,
13
- setup(props) {
14
- const scrollbar = inject(scrollbarContextKey)
15
- if (!scrollbar) throw new Error('can not inject scrollbar context')
16
-
17
- const instance = ref()
18
- const thumb = ref()
19
- const thumbState = ref({})
20
- const visible = ref(false)
21
-
22
- const prefixCls = computed(() => 'j-scrollbar')
23
- const [wrapSSR, hashId] = useScrollbarStyle(prefixCls)
24
-
25
- let cursorDown = false
26
- let cursorLeave = false
27
- let originalOnSelectStart = isClient
28
- ? document.onselectstart
29
- : null
30
-
31
- const bar = computed(() => BAR_MAP[props.vertical ? 'vertical' : 'horizontal'])
32
-
33
- const thumbStyle = computed(() =>
34
- renderThumbStyle({
35
- size: props.size ,
36
- move: props.move ,
37
- bar: bar.value
38
- })
39
- )
40
-
41
- const offsetRatio = computed(
42
- () =>
43
- _optionalChain([(instance.value ), 'optionalAccess', _ => _[bar.value.offset]]) ** 2 /
44
- scrollbar.wrapElement[bar.value.scrollSize] /
45
- props.ratio /
46
- _optionalChain([(thumb.value ), 'optionalAccess', _2 => _2[bar.value.offset]])
47
- )
48
-
49
- const clickThumbHandler = (e) => {
50
- // prevent click event of middle and right button
51
- e.stopPropagation()
52
- if (e.ctrlKey || [1, 2].includes(e.button)) return
53
-
54
- _optionalChain([window, 'access', _3 => _3.getSelection, 'call', _4 => _4(), 'optionalAccess', _5 => _5.removeAllRanges, 'call', _6 => _6()])
55
- startDrag(e)
56
-
57
- const el = e.currentTarget
58
- if (!el) return
59
-
60
- thumbState.value[bar.value.axis] =
61
- (el )[bar.value.offset] -
62
- (e[bar.value.client] - el.getBoundingClientRect()[bar.value.direction])
63
- }
64
-
65
- const clickTrackHandler = (e) => {
66
- if (!thumb.value || !instance.value || !scrollbar.wrapElement) return
67
-
68
- const offset = Math.abs(
69
- (e.target ).getBoundingClientRect()[bar.value.direction] - e[bar.value.client]
70
- )
71
- const thumbHalf = (thumb.value )[bar.value.offset] / 2
72
- const thumbPositionPercentage =
73
- ((offset - thumbHalf) * 100 * offsetRatio.value) /
74
- (instance.value )[bar.value.offset]
75
-
76
- scrollbar.wrapElement[bar.value.scroll] =
77
- (thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize]) / 100
78
- }
79
-
80
- const startDrag = (e) => {
81
- e.stopImmediatePropagation()
82
- cursorDown = true
83
- document.addEventListener('mousemove', mouseMoveDocumentHandler)
84
- document.addEventListener('mouseup', mouseUpDocumentHandler)
85
- originalOnSelectStart = document.onselectstart
86
- document.onselectstart = () => false
87
- }
88
-
89
- const mouseMoveDocumentHandler = (e) => {
90
- if (!instance.value || !thumb.value) return
91
- if (cursorDown === false) return
92
-
93
- const prevPage = thumbState.value[bar.value.axis]
94
- if (!prevPage) return
95
-
96
- const offset =
97
- (instance.value.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]) * -1
98
- const thumbClickPosition = (thumb.value )[bar.value.offset] - prevPage
99
- const thumbPositionPercentage =
100
- ((offset - thumbClickPosition) * 100 * offsetRatio.value) /
101
- (instance.value )[bar.value.offset]
102
-
103
- scrollbar.wrapElement[bar.value.scroll] =
104
- (thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize]) / 100
105
- }
106
-
107
- const mouseUpDocumentHandler = () => {
108
- cursorDown = false
109
- thumbState.value[bar.value.axis] = 0
110
- document.removeEventListener('mousemove', mouseMoveDocumentHandler)
111
- document.removeEventListener('mouseup', mouseUpDocumentHandler)
112
- restoreOnselectstart()
113
- if (cursorLeave) visible.value = false
114
- }
115
-
116
- const mouseMoveScrollbarHandler = () => {
117
- cursorLeave = false
118
- visible.value = !!props.size
119
- }
120
-
121
- const mouseLeaveScrollbarHandler = () => {
122
- cursorLeave = true
123
- visible.value = cursorDown
124
- }
125
-
126
- onBeforeUnmount(() => {
127
- restoreOnselectstart()
128
- document.removeEventListener('mouseup', mouseUpDocumentHandler)
129
- })
130
-
131
- const restoreOnselectstart = () => {
132
- if (document.onselectstart !== originalOnSelectStart)
133
- document.onselectstart = originalOnSelectStart
134
- }
135
-
136
- useEventListener(toRef(scrollbar, 'scrollbarElement'), 'mousemove', mouseMoveScrollbarHandler)
137
- useEventListener(toRef(scrollbar, 'scrollbarElement'), 'mouseleave', mouseLeaveScrollbarHandler)
138
-
139
- return {
140
- props,
141
- instance,
142
- thumb,
143
- visible,
144
- hashId,
145
- thumbStyle,
146
- clickThumbHandler,
147
- clickTrackHandler
148
- }
149
- }
150
- })
1
+ import { defineComponent, computed, inject, onBeforeUnmount, ref, toRef } from 'vue';
2
+ import { useEventListener } from '@vueuse/core';
3
+ import { isClient } from '@meethive/utils';
4
+ import { scrollbarContextKey } from './constants';
5
+ import { BAR_MAP, renderThumbStyle } from './util';
6
+ import { thumbProps } from './thumbProps';
7
+ import useScrollbarStyle from './style';
8
+ export default defineComponent({
9
+ name: 'ScrollbarThumb',
10
+ props: thumbProps,
11
+ setup(props) {
12
+ const scrollbar = inject(scrollbarContextKey);
13
+ if (!scrollbar) throw new Error('can not inject scrollbar context');
14
+ const instance = ref();
15
+ const thumb = ref();
16
+ const thumbState = ref({});
17
+ const visible = ref(false);
18
+ const prefixCls = computed(() => 'j-scrollbar');
19
+ const [wrapSSR, hashId] = useScrollbarStyle(prefixCls);
20
+ let cursorDown = false;
21
+ let cursorLeave = false;
22
+ let originalOnSelectStart = isClient ? document.onselectstart : null;
23
+ const bar = computed(() => BAR_MAP[props.vertical ? 'vertical' : 'horizontal']);
24
+ const thumbStyle = computed(() => renderThumbStyle({
25
+ size: props.size,
26
+ move: props.move,
27
+ bar: bar.value
28
+ }));
29
+ const offsetRatio = computed(() => instance.value?.[bar.value.offset] ** 2 / scrollbar.wrapElement[bar.value.scrollSize] / props.ratio / thumb.value?.[bar.value.offset]);
30
+ const clickThumbHandler = e => {
31
+ // prevent click event of middle and right button
32
+ e.stopPropagation();
33
+ if (e.ctrlKey || [1, 2].includes(e.button)) return;
34
+ window.getSelection()?.removeAllRanges();
35
+ startDrag(e);
36
+ const el = e.currentTarget;
37
+ if (!el) return;
38
+ thumbState.value[bar.value.axis] = el[bar.value.offset] - (e[bar.value.client] - el.getBoundingClientRect()[bar.value.direction]);
39
+ };
40
+ const clickTrackHandler = e => {
41
+ if (!thumb.value || !instance.value || !scrollbar.wrapElement) return;
42
+ const offset = Math.abs(e.target.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]);
43
+ const thumbHalf = thumb.value[bar.value.offset] / 2;
44
+ const thumbPositionPercentage = (offset - thumbHalf) * 100 * offsetRatio.value / instance.value[bar.value.offset];
45
+ scrollbar.wrapElement[bar.value.scroll] = thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize] / 100;
46
+ };
47
+ const startDrag = e => {
48
+ e.stopImmediatePropagation();
49
+ cursorDown = true;
50
+ document.addEventListener('mousemove', mouseMoveDocumentHandler);
51
+ document.addEventListener('mouseup', mouseUpDocumentHandler);
52
+ originalOnSelectStart = document.onselectstart;
53
+ document.onselectstart = () => false;
54
+ };
55
+ const mouseMoveDocumentHandler = e => {
56
+ if (!instance.value || !thumb.value) return;
57
+ if (cursorDown === false) return;
58
+ const prevPage = thumbState.value[bar.value.axis];
59
+ if (!prevPage) return;
60
+ const offset = (instance.value.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]) * -1;
61
+ const thumbClickPosition = thumb.value[bar.value.offset] - prevPage;
62
+ const thumbPositionPercentage = (offset - thumbClickPosition) * 100 * offsetRatio.value / instance.value[bar.value.offset];
63
+ scrollbar.wrapElement[bar.value.scroll] = thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize] / 100;
64
+ };
65
+ const mouseUpDocumentHandler = () => {
66
+ cursorDown = false;
67
+ thumbState.value[bar.value.axis] = 0;
68
+ document.removeEventListener('mousemove', mouseMoveDocumentHandler);
69
+ document.removeEventListener('mouseup', mouseUpDocumentHandler);
70
+ restoreOnselectstart();
71
+ if (cursorLeave) visible.value = false;
72
+ };
73
+ const mouseMoveScrollbarHandler = () => {
74
+ cursorLeave = false;
75
+ visible.value = !!props.size;
76
+ };
77
+ const mouseLeaveScrollbarHandler = () => {
78
+ cursorLeave = true;
79
+ visible.value = cursorDown;
80
+ };
81
+ onBeforeUnmount(() => {
82
+ restoreOnselectstart();
83
+ document.removeEventListener('mouseup', mouseUpDocumentHandler);
84
+ });
85
+ const restoreOnselectstart = () => {
86
+ if (document.onselectstart !== originalOnSelectStart) document.onselectstart = originalOnSelectStart;
87
+ };
88
+ useEventListener(toRef(scrollbar, 'scrollbarElement'), 'mousemove', mouseMoveScrollbarHandler);
89
+ useEventListener(toRef(scrollbar, 'scrollbarElement'), 'mouseleave', mouseLeaveScrollbarHandler);
90
+ return {
91
+ props,
92
+ instance,
93
+ thumb,
94
+ visible,
95
+ hashId,
96
+ thumbStyle,
97
+ clickThumbHandler,
98
+ clickTrackHandler
99
+ };
100
+ }
101
+ });