@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,119 @@
1
+
2
+ import { defineComponent, ref, reactive } from 'vue'
3
+ import { Popover as APopover, Table as ATable, Space as ASpace, Button as AButton } from 'ant-design-vue'
4
+ import { useTableTool, useTableWrapper } from '../../context'
5
+ import { useLocaleReceiver } from '../../../LocaleReciver'
6
+ import AIcon from '../../../Icon'
7
+
8
+ export default defineComponent({
9
+ name: 'JEditTableSearchSort',
10
+ components: {
11
+ APopover,
12
+ ATable,
13
+ ASpace,
14
+ AButton,
15
+ AIcon
16
+ },
17
+ props: {
18
+ dataSource: {
19
+ type: [Function, Array],
20
+ default: () => []
21
+ },
22
+ sortKey: {
23
+ type: [String, Array],
24
+ default: undefined
25
+ },
26
+ dataIndex: {
27
+ type: [Number, String],
28
+ default: undefined
29
+ },
30
+ selectedRowKeys: {
31
+ type: Array,
32
+ default: () => []
33
+ },
34
+ active: {
35
+ type: Boolean,
36
+ default: false
37
+ }
38
+ },
39
+ emits: ['click'],
40
+ setup(props, { emit }) {
41
+ const [contextLocale] = useLocaleReceiver('EditTable')
42
+ const tableWrapperRef = useTableWrapper()
43
+ const tableTool = useTableTool()
44
+
45
+ const visible = ref(false)
46
+ const localDataSource = ref([])
47
+ const mySelectedRowKeys = ref([])
48
+
49
+ const columns = reactive([
50
+ {
51
+ dataIndex: 'name',
52
+ title: contextLocale.value.columns.name
53
+ },
54
+ {
55
+ dataIndex: 'total',
56
+ title: contextLocale.value.columns.count,
57
+ width: 70
58
+ }
59
+ ])
60
+
61
+ const visibleChange = (e) => {
62
+ if (e) {
63
+ mySelectedRowKeys.value = props.selectedRowKeys
64
+ const ds = typeof props.dataSource === 'function' ? props.dataSource() : props.dataSource
65
+ localDataSource.value = (ds || []).map((item, index) =>
66
+ Object.assign(item, { __index: index + 1 })
67
+ )
68
+ }
69
+ if (!e) {
70
+ setTimeout(() => {
71
+ visible.value = e
72
+ }, 300)
73
+ } else {
74
+ visible.value = e
75
+ }
76
+ }
77
+
78
+ const onSelectChange = (keys) => {
79
+ mySelectedRowKeys.value = keys
80
+ }
81
+
82
+ const cleanParams = () => {
83
+ mySelectedRowKeys.value = []
84
+ tableTool.cleanOrder()
85
+ }
86
+
87
+ const handleSortRowKeys = () => {
88
+ return localDataSource.value
89
+ .filter((item) => mySelectedRowKeys.value.includes(item.key))
90
+ .sort((a, b) => b.__index - a.__index)
91
+ .map((item) => item.key)
92
+ }
93
+
94
+ const onAsc = () => {
95
+ tableTool.order('asc', props.sortKey, handleSortRowKeys(), props.dataIndex)
96
+ emit('click')
97
+ }
98
+
99
+ const onDesc = () => {
100
+ tableTool.order('desc', props.sortKey, handleSortRowKeys(), props.dataIndex)
101
+ emit('click')
102
+ }
103
+
104
+ return {
105
+ props,
106
+ contextLocale,
107
+ tableWrapperRef,
108
+ visible,
109
+ localDataSource,
110
+ mySelectedRowKeys,
111
+ columns,
112
+ visibleChange,
113
+ onSelectChange,
114
+ cleanParams,
115
+ onAsc,
116
+ onDesc
117
+ }
118
+ }
119
+ })
@@ -0,0 +1,2 @@
1
+ export { default as SearchModal } from './Search.js'
2
+ export { default as Sort } from './Sort.js'
@@ -0,0 +1,13 @@
1
+ export const METADATA_GROUP_OPTIONS = Symbol('metadata-group-options')
2
+ export const TABLE_WRAPPER = Symbol('table-wrapper')
3
+ export const FULL_SCREEN = Symbol('full')
4
+ export const RIGHT_MENU = Symbol('right-menu')
5
+ export const TABLE_ERROR = Symbol('table-error')
6
+ export const TABLE_GROUP_ERROR = Symbol('table-group-error')
7
+ export const TABLE_GROUP_OPTIONS = Symbol('table-group-options')
8
+ export const TABLE_DATA_SOURCE = Symbol('table-data-source')
9
+ export const TABLE_OPEN_GROUP = Symbol('table-open-group')
10
+ export const TABLE_TOOL = Symbol('table-tool')
11
+ export const TABLE_FORM_ITEM_ERROR = Symbol('table-form-item-error')
12
+ export const TABLE_GROUP_ACTIVE = Symbol('table-group-active')
13
+ export const TABLE_H_SCROLL = Symbol('table-h-scroll')
@@ -0,0 +1,88 @@
1
+ import { provide, inject, computed, } from 'vue'
2
+ import {
3
+ RIGHT_MENU,
4
+ TABLE_DATA_SOURCE,
5
+ TABLE_ERROR,
6
+ TABLE_GROUP_ERROR,
7
+ TABLE_WRAPPER,
8
+ TABLE_OPEN_GROUP,
9
+ TABLE_TOOL,
10
+ TABLE_GROUP_OPTIONS,
11
+ TABLE_FORM_ITEM_ERROR,
12
+ TABLE_GROUP_ACTIVE,
13
+ FULL_SCREEN,
14
+ TABLE_H_SCROLL
15
+ } from './consts'
16
+
17
+ const FormContextKey = 'form-context'
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+ export const useFormContext = (options) => {
31
+ provide(FormContextKey, options)
32
+ }
33
+
34
+ export const useInjectForm = () => {
35
+ return inject(FormContextKey, {
36
+ addField: (key, field) => {},
37
+ dataSource: computed(() => []),
38
+ rules: computed(() => undefined)
39
+ })
40
+ }
41
+
42
+ export const useInjectError = () => {
43
+ return inject(TABLE_ERROR)
44
+ }
45
+
46
+ export const useTableWrapper = () => {
47
+ return inject(TABLE_WRAPPER)
48
+ }
49
+
50
+ export const useRightMenuContext = () => {
51
+ return inject(RIGHT_MENU)
52
+ }
53
+
54
+ export const useTableGroupError = () => {
55
+ return inject(TABLE_GROUP_ERROR)
56
+ }
57
+
58
+ export const useTableDataSource = () => {
59
+ return inject(TABLE_DATA_SOURCE, computed(() => []))
60
+ }
61
+
62
+ export const useTableOpenGroup = () => {
63
+ return inject(TABLE_OPEN_GROUP, false)
64
+ }
65
+
66
+ export const useTableTool = () => {
67
+ return inject(TABLE_TOOL, false)
68
+ }
69
+
70
+ export const useGroupOptions = () => {
71
+ return inject(TABLE_GROUP_OPTIONS, { value: [] } )
72
+ }
73
+
74
+ export const useFormItemError = () => {
75
+ return inject(TABLE_FORM_ITEM_ERROR)
76
+ }
77
+
78
+ export const useGroupActive = () => {
79
+ return inject(TABLE_GROUP_ACTIVE)
80
+ }
81
+
82
+ export const useTableFullScreen = () => {
83
+ return inject(FULL_SCREEN)
84
+ }
85
+
86
+ export const useHScroll = () => {
87
+ return inject(TABLE_H_SCROLL)
88
+ }
@@ -0,0 +1,19 @@
1
+ export * from './useResizeObserver'
2
+ export * from './useValidate'
3
+ export * from './useGroup'
4
+ export {
5
+ useFormContext,
6
+ useInjectForm,
7
+ useInjectError,
8
+ useTableWrapper,
9
+ useRightMenuContext,
10
+ useTableGroupError,
11
+ useTableDataSource,
12
+ useTableOpenGroup,
13
+ useTableTool,
14
+ useGroupOptions,
15
+ useFormItemError,
16
+ useGroupActive,
17
+ useTableFullScreen,
18
+ useHScroll
19
+ } from '../context'
@@ -0,0 +1,48 @@
1
+ import { ref, reactive } from 'vue'
2
+
3
+ export const useGroup = (openGroup = false) => {
4
+ const groupOptions = ref([])
5
+ const groupActive = reactive({
6
+ value: undefined,
7
+ label: undefined
8
+ })
9
+
10
+ /**
11
+ * 更新当前选择的分组id
12
+ * @param key
13
+ * @param name
14
+ */
15
+ const updateGroupActive = (key, name) => {
16
+ if (openGroup) {
17
+ groupActive.value = key
18
+ groupActive.label = name
19
+ }
20
+ }
21
+
22
+ const addGroup = (val) => {
23
+ if (openGroup) {
24
+ groupOptions.value.push(val)
25
+ }
26
+ }
27
+
28
+ const removeGroup = (index) => {
29
+ if (openGroup) {
30
+ groupOptions.value.splice(index, 1)
31
+ }
32
+ }
33
+
34
+ const updateGroupOptions = (options = []) => {
35
+ if (openGroup) {
36
+ groupOptions.value = options
37
+ }
38
+ }
39
+
40
+ return {
41
+ groupOptions,
42
+ groupActive,
43
+ updateGroupActive,
44
+ addGroup,
45
+ removeGroup,
46
+ updateGroupOptions
47
+ }
48
+ }
@@ -0,0 +1,27 @@
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; }import { onBeforeUnmount, onMounted, } from 'vue'
2
+ import ResizeObserver from 'resize-observer-polyfill'
3
+ import { debounce } from 'lodash-es'
4
+
5
+ export const useResizeObserver = (
6
+ tableWrapper,
7
+ cb
8
+ ) => {
9
+ let observer
10
+
11
+ const onResize = (entries) => {
12
+ let rect = {}
13
+ for (const entry of entries) {
14
+ rect = entry.contentRect
15
+ }
16
+ cb(rect , entries)
17
+ }
18
+
19
+ onMounted(() => {
20
+ observer = new ResizeObserver(debounce(onResize, 100))
21
+ observer.observe(tableWrapper.value)
22
+ })
23
+
24
+ onBeforeUnmount(() => {
25
+ _optionalChain([observer, 'optionalAccess', _ => _.unobserve, 'call', _2 => _2(tableWrapper.value)])
26
+ })
27
+ }
@@ -0,0 +1,112 @@
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; }import Schema from 'async-validator'
2
+ import { handlePureRecord, collectValidateRules } from '../utils'
3
+ import { ref, } from 'vue'
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ export const useValidate = (
13
+ dataSource,
14
+ columns,
15
+ rowKey,
16
+ options = {}
17
+ ) => {
18
+ const errorMap = ref({})
19
+ let schemaInstance
20
+ const rules = ref({})
21
+
22
+ const _options = {
23
+ validateRowKey: false,
24
+ ...options
25
+ }
26
+
27
+ const validateItem = (data, index = 0) => {
28
+ return new Promise((resolve, reject) => {
29
+ schemaInstance.validate(
30
+ data,
31
+ {
32
+ firstFields: true,
33
+ // @ts-ignore
34
+ index: index
35
+ },
36
+ (err) => {
37
+ if (_optionalChain([err, 'optionalAccess', _ => _.length])) {
38
+ reject(
39
+ err.map((item) => ({
40
+ ...item,
41
+ __serial: data.__serial,
42
+ __dataIndex: index
43
+ }))
44
+ )
45
+ } else {
46
+ resolve(data)
47
+ }
48
+ }
49
+ )
50
+ })
51
+ }
52
+
53
+ const validate = () => {
54
+ return new Promise((resolve, reject) => {
55
+ const filterDataSource = dataSource.value
56
+ const len = filterDataSource.length
57
+ const error = []
58
+ const success = []
59
+ let validateLen = 0
60
+
61
+ const end = () => {
62
+ validateLen += 1
63
+ if (validateLen === len) {
64
+ const isSuccess = !Object.keys(error).length
65
+ if (isSuccess) {
66
+ resolve(success)
67
+ _optionalChain([_options, 'access', _2 => _2.onSuccess, 'optionalCall', _3 => _3()])
68
+ } else {
69
+ _optionalChain([_options, 'access', _4 => _4.onError, 'optionalCall', _5 => _5(error)])
70
+ reject(error)
71
+ }
72
+ }
73
+ }
74
+
75
+ const { validateRowKey } = _options
76
+
77
+ if (filterDataSource.length) {
78
+ filterDataSource.forEach((record, index) => {
79
+ if (validateRowKey || record[rowKey]) {
80
+ validateItem(record, index)
81
+ .then((res) => {
82
+ success.push(handlePureRecord(res))
83
+ end()
84
+ })
85
+ .catch((err) => {
86
+ error.push(err)
87
+ end()
88
+ })
89
+ } else {
90
+ end()
91
+ }
92
+ })
93
+ } else {
94
+ resolve(filterDataSource)
95
+ }
96
+ })
97
+ }
98
+
99
+ const createValidate = () => {
100
+ rules.value = collectValidateRules(columns)
101
+ schemaInstance = new Schema(rules.value)
102
+ }
103
+
104
+ createValidate()
105
+
106
+ return {
107
+ validate,
108
+ validateItem,
109
+ errorMap,
110
+ rules
111
+ }
112
+ }
@@ -0,0 +1,25 @@
1
+ import EditTable from './EditTable.js'
2
+ import EditTableBody from './Body.js'
3
+ import EditTableHeader from './Header.js'
4
+ import FormItem from './FormItem.js'
5
+
6
+
7
+ export * from './props'
8
+ export * from './consts'
9
+ export * from './context'
10
+ export { EditTable, EditTableBody, EditTableHeader, FormItem }
11
+
12
+
13
+
14
+
15
+
16
+ const _EditTable = EditTable
17
+
18
+ _EditTable.install = (app) => {
19
+ app.component(EditTable.name || 'JEditTable', EditTable)
20
+ app.component(EditTableBody.name || 'JEditTableBody', EditTableBody)
21
+ app.component(EditTableHeader.name || 'JEditTableHeader', EditTableHeader)
22
+ app.component(FormItem.name || 'JFormItem', FormItem)
23
+ }
24
+
25
+ export default _EditTable
@@ -0,0 +1,60 @@
1
+ export const defaultProps = () => {
2
+ return {
3
+ rowKey: {
4
+ type: String,
5
+ default: 'id'
6
+ },
7
+ columns: {
8
+ type: Array,
9
+ default: () => []
10
+ },
11
+ searchColumns: {
12
+ type: Array,
13
+ default: () => [
14
+ { title: '标识', dataIndex: 'id' },
15
+ { title: '名称', dataIndex: 'name' }
16
+ ]
17
+ }
18
+ }
19
+ }
20
+
21
+ export const bodyProps = () => {
22
+ return {
23
+ dataSource: {
24
+ type: Array,
25
+ default: () => []
26
+ },
27
+ columns: {
28
+ type: Array,
29
+ default: () => []
30
+ },
31
+ cellHeight: {
32
+ type: Number,
33
+ default: 65
34
+ },
35
+ height: {
36
+ type: Number,
37
+ default: 300
38
+ },
39
+ style: {
40
+ type: Object,
41
+ default: () => ({})
42
+ },
43
+ disableMenu: {
44
+ type: Boolean,
45
+ default: true
46
+ },
47
+ rowKey: {
48
+ type: String,
49
+ default: 'id'
50
+ },
51
+ openGroup: {
52
+ type: Boolean,
53
+ default: false
54
+ },
55
+ rowSelection: {
56
+ type: Object,
57
+ default: undefined
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,63 @@
1
+ export const genEditTableBodyStyle = (config) => {
2
+ const { token } = config
3
+ return {
4
+ '.jetlinks-edit-table-body-viewport': {
5
+ maxHeight: '100%',
6
+ width: '100%',
7
+ overflow: 'hidden auto',
8
+ position: 'relative',
9
+ '.jetlinks-edit-scrollbar': {
10
+ position: 'absolute',
11
+ left: 0,
12
+ top: 0,
13
+ right: 0,
14
+ zIndex: -1
15
+ },
16
+ '.jetlinks-edit-table-body-container': {
17
+ overflow: 'hidden',
18
+ height: '100%'
19
+ },
20
+ '.jetlinks-edit-table-center': {
21
+ position: 'relative',
22
+ flex: '1 1 auto',
23
+ minWidth: 0,
24
+ height: '100%',
25
+ '.jetlinks-edit-table-row': {
26
+ width: '100%',
27
+ display: 'flex',
28
+ alignItems: 'center',
29
+ transition: 'top .2s, height .2s, background-color .1s',
30
+ borderBottom: '1px solid #eebebeb',
31
+ '.jetlinks-edit-table-cell': {
32
+ position: 'absolute',
33
+ minWidth: 0
34
+ },
35
+ '&:hover': {
36
+ backgroundColor: 'rgb(248, 248, 248)'
37
+ },
38
+ '&.jetlinks-edit-table-row-selected': {
39
+ backgroundColor: 'var(--ant-primary-1)'
40
+ },
41
+ '.body-cell-box': {
42
+ padding: '0 12px',
43
+ position: 'relative'
44
+ }
45
+ },
46
+ '.readonly-mask': {
47
+ position: 'absolute',
48
+ top: 0,
49
+ left: 0,
50
+ right: 0,
51
+ bottom: 0,
52
+ zIndex: 4
53
+ }
54
+ }
55
+ },
56
+ '.jetlinks-edit-table-body-empty': {
57
+ display: 'flex',
58
+ width: '100%',
59
+ justifyContent: 'center',
60
+ paddingTop: 24
61
+ }
62
+ }
63
+ }
@@ -0,0 +1,33 @@
1
+ export const genEditTableFormItemStyle = (config) => {
2
+ const { token } = config
3
+ return {
4
+ '.jetlinks-table-form-error-target': {
5
+ position: 'absolute',
6
+ right: '2px',
7
+ top: '-9px',
8
+ border: '16px solid transparent',
9
+ borderTopColor: token.colorError,
10
+ borderRightWidth: 0,
11
+ borderBottomWidth: 0
12
+ },
13
+ '.jetlinks-edit-table-form-has-error': {
14
+ '.select-no-value': {
15
+ '.ant-select-selector': {
16
+ borderColor: `${token.colorError} !important`,
17
+ '&:focus': {
18
+ boxShadow: '0 0 0 2px var(--ant-error-color-outlined) !important'
19
+ }
20
+ }
21
+ },
22
+ '> input': {
23
+ borderColor: `${token.colorError} !important`,
24
+ '&:focus': {
25
+ boxShadow: '0 0 0 2px var(--ant-error-color-outlined) !important'
26
+ }
27
+ },
28
+ '.jetlinks-table-form-required-aicon': {
29
+ color: token.colorError
30
+ }
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,33 @@
1
+ export const genEditTableGroupStyle = (config) => {
2
+ const { token } = config
3
+ return {
4
+ '.jetlinks-table-group-warp': {
5
+ '.ant-tabs-nav': {
6
+ marginBottom: 0,
7
+ '.ant-tabs-tab': {
8
+ overflow: 'hidden',
9
+ position: 'relative'
10
+ },
11
+ '.ant-tabs-tab-active': {
12
+ backgroundColor: '#BAE0FF !important',
13
+ borderColor: '#91CAFF !important'
14
+ },
15
+ '.ant-tabs-nav-add': {
16
+ border: 'none'
17
+ }
18
+ }
19
+ },
20
+ '.jetlinks-table-group-error-warp': {
21
+ color: '#1a1a1a !important',
22
+ '.jetlinks-table-group-error-target': {
23
+ position: 'absolute',
24
+ right: 0,
25
+ top: 0,
26
+ border: '16px solid transparent',
27
+ borderTopColor: token.colorError,
28
+ borderRightWidth: 0,
29
+ borderBottomWidth: 0
30
+ }
31
+ }
32
+ }
33
+ }