@zykj2024/much-library 1.1.7-beta.1 → 1.1.7-beta.3

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 (305) hide show
  1. package/package.json +10 -8
  2. package/LICENSE +0 -21
  3. package/README.md +0 -35
  4. package/dist/McCascader/city.js +0 -909
  5. package/dist/McCascader/index.css +0 -60
  6. package/dist/McCascader/index.d.ts +0 -19
  7. package/dist/McCascader/index.js +0 -221
  8. package/dist/McContainer/demo/actionBar.d.ts +0 -8
  9. package/dist/McContainer/demo/actionBar.js +0 -118
  10. package/dist/McContainer/demo/base.d.ts +0 -8
  11. package/dist/McContainer/demo/base.js +0 -82
  12. package/dist/McContainer/demo/batch.d.ts +0 -8
  13. package/dist/McContainer/demo/batch.js +0 -129
  14. package/dist/McContainer/demo/collapse.d.ts +0 -8
  15. package/dist/McContainer/demo/collapse.js +0 -77
  16. package/dist/McContainer/demo/expand.d.ts +0 -8
  17. package/dist/McContainer/demo/expand.js +0 -90
  18. package/dist/McContainer/demo/generic.d.ts +0 -8
  19. package/dist/McContainer/demo/generic.js +0 -91
  20. package/dist/McContainer/demo/pagination.d.ts +0 -7
  21. package/dist/McContainer/demo/pagination.js +0 -133
  22. package/dist/McContainer/demo/search.d.ts +0 -7
  23. package/dist/McContainer/demo/search.js +0 -102
  24. package/dist/McContainer/demo/standard.d.ts +0 -7
  25. package/dist/McContainer/demo/standard.js +0 -219
  26. package/dist/McContainer/index.css +0 -123
  27. package/dist/McContainer/index.d.ts +0 -192
  28. package/dist/McContainer/index.js +0 -522
  29. package/dist/McContainer/mock/index.d.ts +0 -21
  30. package/dist/McContainer/mock/index.js +0 -50
  31. package/dist/McDateRange/demo/base.d.ts +0 -6
  32. package/dist/McDateRange/demo/base.js +0 -22
  33. package/dist/McDateRange/demo/cancelPresets.d.ts +0 -6
  34. package/dist/McDateRange/demo/cancelPresets.js +0 -23
  35. package/dist/McDateRange/demo/overlap.d.ts +0 -2
  36. package/dist/McDateRange/demo/overlap.js +0 -32
  37. package/dist/McDateRange/index.css +0 -31
  38. package/dist/McDateRange/index.d.ts +0 -28
  39. package/dist/McDateRange/index.js +0 -167
  40. package/dist/McEllipsis/demo/base.d.ts +0 -6
  41. package/dist/McEllipsis/demo/base.js +0 -22
  42. package/dist/McEllipsis/demo/middle.d.ts +0 -6
  43. package/dist/McEllipsis/demo/middle.js +0 -24
  44. package/dist/McEllipsis/demo/table.d.ts +0 -5
  45. package/dist/McEllipsis/demo/table.js +0 -93
  46. package/dist/McEllipsis/demo/tooltip-size.d.ts +0 -6
  47. package/dist/McEllipsis/demo/tooltip-size.js +0 -20
  48. package/dist/McEllipsis/demo/tooltip.d.ts +0 -6
  49. package/dist/McEllipsis/demo/tooltip.js +0 -53
  50. package/dist/McEllipsis/index.css +0 -4
  51. package/dist/McEllipsis/index.d.ts +0 -40
  52. package/dist/McEllipsis/index.js +0 -115
  53. package/dist/McEllipsisMiddle/demo/base.d.ts +0 -6
  54. package/dist/McEllipsisMiddle/demo/base.js +0 -25
  55. package/dist/McEllipsisMiddle/demo/tooltip.d.ts +0 -6
  56. package/dist/McEllipsisMiddle/demo/tooltip.js +0 -35
  57. package/dist/McEllipsisMiddle/index.css +0 -4
  58. package/dist/McEllipsisMiddle/index.d.ts +0 -13
  59. package/dist/McEllipsisMiddle/index.js +0 -42
  60. package/dist/McFonts/index.d.ts +0 -8
  61. package/dist/McFonts/index.js +0 -7
  62. package/dist/McGroupPanel/comps/SelectedItem/index.d.ts +0 -4
  63. package/dist/McGroupPanel/comps/SelectedItem/index.js +0 -75
  64. package/dist/McGroupPanel/index.css +0 -169
  65. package/dist/McGroupPanel/index.d.ts +0 -30
  66. package/dist/McGroupPanel/index.js +0 -426
  67. package/dist/McIconFont/iconfont.js +0 -1
  68. package/dist/McIconFont/index.d.ts +0 -5
  69. package/dist/McIconFont/index.js +0 -8
  70. package/dist/McIcons/business.json +0 -137
  71. package/dist/McIcons/index.css +0 -33
  72. package/dist/McInput/Input.d.ts +0 -19
  73. package/dist/McInput/Input.js +0 -48
  74. package/dist/McInput/Search.d.ts +0 -39
  75. package/dist/McInput/Search.js +0 -81
  76. package/dist/McInput/TextArea.d.ts +0 -11
  77. package/dist/McInput/TextArea.js +0 -37
  78. package/dist/McInput/demo/Input/addonBefore.d.ts +0 -3
  79. package/dist/McInput/demo/Input/addonBefore.js +0 -67
  80. package/dist/McInput/demo/Input/base.d.ts +0 -2
  81. package/dist/McInput/demo/Input/base.js +0 -31
  82. package/dist/McInput/demo/Input/isTrim.d.ts +0 -2
  83. package/dist/McInput/demo/Input/isTrim.js +0 -22
  84. package/dist/McInput/demo/Input/label.d.ts +0 -2
  85. package/dist/McInput/demo/Input/label.js +0 -26
  86. package/dist/McInput/demo/Input/ref.d.ts +0 -3
  87. package/dist/McInput/demo/Input/ref.js +0 -53
  88. package/dist/McInput/demo/Input/status.d.ts +0 -2
  89. package/dist/McInput/demo/Input/status.js +0 -23
  90. package/dist/McInput/demo/Search/search-base.d.ts +0 -2
  91. package/dist/McInput/demo/Search/search-base.js +0 -38
  92. package/dist/McInput/demo/TextArea/text-area-base.d.ts +0 -2
  93. package/dist/McInput/demo/TextArea/text-area-base.js +0 -38
  94. package/dist/McInput/index.css +0 -71
  95. package/dist/McInput/index.d.ts +0 -13
  96. package/dist/McInput/index.js +0 -7
  97. package/dist/McInputNumber/demo/index.d.ts +0 -2
  98. package/dist/McInputNumber/demo/index.js +0 -34
  99. package/dist/McInputNumber/demo/label.d.ts +0 -2
  100. package/dist/McInputNumber/demo/label.js +0 -26
  101. package/dist/McInputNumber/demo/precision.d.ts +0 -2
  102. package/dist/McInputNumber/demo/precision.js +0 -20
  103. package/dist/McInputNumber/index.css +0 -36
  104. package/dist/McInputNumber/index.d.ts +0 -16
  105. package/dist/McInputNumber/index.js +0 -50
  106. package/dist/McLazyLoader/demo/basic.d.ts +0 -2
  107. package/dist/McLazyLoader/demo/basic.js +0 -33
  108. package/dist/McLazyLoader/demo/container.d.ts +0 -2
  109. package/dist/McLazyLoader/demo/container.js +0 -83
  110. package/dist/McLazyLoader/demo/form.d.ts +0 -2
  111. package/dist/McLazyLoader/demo/form.js +0 -38
  112. package/dist/McLazyLoader/demo/has-root.d.ts +0 -2
  113. package/dist/McLazyLoader/demo/has-root.js +0 -44
  114. package/dist/McLazyLoader/demo/hori.d.ts +0 -2
  115. package/dist/McLazyLoader/demo/hori.js +0 -39
  116. package/dist/McLazyLoader/demo/table.d.ts +0 -2
  117. package/dist/McLazyLoader/demo/table.js +0 -73
  118. package/dist/McLazyLoader/index.d.ts +0 -39
  119. package/dist/McLazyLoader/index.js +0 -88
  120. package/dist/McListSelect/comps/ListSelect.d.ts +0 -67
  121. package/dist/McListSelect/comps/ListSelect.js +0 -289
  122. package/dist/McListSelect/comps/ListSelectPanel.d.ts +0 -138
  123. package/dist/McListSelect/comps/ListSelectPanel.js +0 -451
  124. package/dist/McListSelect/comps/SelectedItem.d.ts +0 -17
  125. package/dist/McListSelect/comps/SelectedItem.js +0 -76
  126. package/dist/McListSelect/demo/base.d.ts +0 -6
  127. package/dist/McListSelect/demo/base.js +0 -125
  128. package/dist/McListSelect/demo/inexistent.d.ts +0 -6
  129. package/dist/McListSelect/demo/inexistent.js +0 -111
  130. package/dist/McListSelect/demo/layout.d.ts +0 -6
  131. package/dist/McListSelect/demo/layout.js +0 -70
  132. package/dist/McListSelect/demo/other.d.ts +0 -6
  133. package/dist/McListSelect/demo/other.js +0 -68
  134. package/dist/McListSelect/demo/panel-inexistent.d.ts +0 -6
  135. package/dist/McListSelect/demo/panel-inexistent.js +0 -86
  136. package/dist/McListSelect/index.css +0 -273
  137. package/dist/McListSelect/index.d.ts +0 -10
  138. package/dist/McListSelect/index.js +0 -5
  139. package/dist/McListSelect/mock/index.d.ts +0 -1
  140. package/dist/McListSelect/mock/index.js +0 -27
  141. package/dist/McModalProvider/index.d.ts +0 -174
  142. package/dist/McModalProvider/index.js +0 -498
  143. package/dist/McPeriodSelect/demo/base.d.ts +0 -6
  144. package/dist/McPeriodSelect/demo/base.js +0 -19
  145. package/dist/McPeriodSelect/demo/half.d.ts +0 -6
  146. package/dist/McPeriodSelect/demo/half.js +0 -20
  147. package/dist/McPeriodSelect/index.css +0 -189
  148. package/dist/McPeriodSelect/index.d.ts +0 -13
  149. package/dist/McPeriodSelect/index.js +0 -305
  150. package/dist/McPopoverButton/index.d.ts +0 -14
  151. package/dist/McPopoverButton/index.js +0 -52
  152. package/dist/McPopoverForm/index.d.ts +0 -14
  153. package/dist/McPopoverForm/index.js +0 -95
  154. package/dist/McProSelect/demo/async.d.ts +0 -2
  155. package/dist/McProSelect/demo/async.js +0 -66
  156. package/dist/McProSelect/demo/base.d.ts +0 -2
  157. package/dist/McProSelect/demo/base.js +0 -29
  158. package/dist/McProSelect/demo/exclusion-async-rename.d.ts +0 -3
  159. package/dist/McProSelect/demo/exclusion-async-rename.js +0 -103
  160. package/dist/McProSelect/demo/exclusion-rename.d.ts +0 -3
  161. package/dist/McProSelect/demo/exclusion-rename.js +0 -74
  162. package/dist/McProSelect/demo/exclusion.d.ts +0 -3
  163. package/dist/McProSelect/demo/exclusion.js +0 -70
  164. package/dist/McProSelect/demo/require.d.ts +0 -2
  165. package/dist/McProSelect/demo/require.js +0 -82
  166. package/dist/McProSelect/index.d.ts +0 -35
  167. package/dist/McProSelect/index.js +0 -152
  168. package/dist/McResult/default.d.ts +0 -1
  169. package/dist/McResult/default.js +0 -98
  170. package/dist/McResult/demo/403.d.ts +0 -6
  171. package/dist/McResult/demo/403.js +0 -17
  172. package/dist/McResult/demo/404.d.ts +0 -6
  173. package/dist/McResult/demo/404.js +0 -17
  174. package/dist/McResult/demo/500.d.ts +0 -6
  175. package/dist/McResult/demo/500.js +0 -17
  176. package/dist/McResult/demo/building.d.ts +0 -6
  177. package/dist/McResult/demo/building.js +0 -12
  178. package/dist/McResult/demo/empty.d.ts +0 -2
  179. package/dist/McResult/demo/empty.js +0 -11
  180. package/dist/McResult/demo/noFunction.d.ts +0 -2
  181. package/dist/McResult/demo/noFunction.js +0 -11
  182. package/dist/McResult/demo/noUser.d.ts +0 -6
  183. package/dist/McResult/demo/noUser.js +0 -12
  184. package/dist/McResult/demo/preview.d.ts +0 -2
  185. package/dist/McResult/demo/preview.js +0 -19
  186. package/dist/McResult/icon.d.ts +0 -25
  187. package/dist/McResult/icon.js +0 -1014
  188. package/dist/McResult/index.css +0 -20
  189. package/dist/McResult/index.d.ts +0 -31
  190. package/dist/McResult/index.js +0 -119
  191. package/dist/McResult/public/403.svg +0 -164
  192. package/dist/McResult/public/404.svg +0 -123
  193. package/dist/McResult/public/500.svg +0 -129
  194. package/dist/McResult/public/building.svg +0 -127
  195. package/dist/McResult/public/code403.svg +0 -7
  196. package/dist/McResult/public/code404.svg +0 -5
  197. package/dist/McResult/public/code500.svg +0 -5
  198. package/dist/McResult/public/detailEmpty.svg +0 -1
  199. package/dist/McResult/public/empty.svg +0 -1
  200. package/dist/McResult/public/noFunction.svg +0 -1
  201. package/dist/McResult/public/noUser.svg +0 -90
  202. package/dist/McSelect/components/PanelSearchInput/index.css +0 -6
  203. package/dist/McSelect/components/PanelSearchInput/index.d.ts +0 -12
  204. package/dist/McSelect/components/PanelSearchInput/index.js +0 -45
  205. package/dist/McSelect/demo/base.d.ts +0 -2
  206. package/dist/McSelect/demo/base.js +0 -63
  207. package/dist/McSelect/demo/changeOnHidden.d.ts +0 -2
  208. package/dist/McSelect/demo/changeOnHidden.js +0 -43
  209. package/dist/McSelect/demo/dropdownRender.d.ts +0 -7
  210. package/dist/McSelect/demo/dropdownRender.js +0 -78
  211. package/dist/McSelect/demo/exclusion.d.ts +0 -3
  212. package/dist/McSelect/demo/exclusion.js +0 -64
  213. package/dist/McSelect/demo/fetchOptions.d.ts +0 -7
  214. package/dist/McSelect/demo/fetchOptions.js +0 -211
  215. package/dist/McSelect/demo/inexistent.d.ts +0 -2
  216. package/dist/McSelect/demo/inexistent.js +0 -79
  217. package/dist/McSelect/demo/labelInValue.d.ts +0 -2
  218. package/dist/McSelect/demo/labelInValue.js +0 -72
  219. package/dist/McSelect/demo/maxTagCount.d.ts +0 -3
  220. package/dist/McSelect/demo/maxTagCount.js +0 -51
  221. package/dist/McSelect/demo/multiple.d.ts +0 -2
  222. package/dist/McSelect/demo/multiple.js +0 -46
  223. package/dist/McSelect/demo/optionRender.d.ts +0 -3
  224. package/dist/McSelect/demo/optionRender.js +0 -51
  225. package/dist/McSelect/demo/panelInSearch.d.ts +0 -2
  226. package/dist/McSelect/demo/panelInSearch.js +0 -47
  227. package/dist/McSelect/demo/tagRender.d.ts +0 -3
  228. package/dist/McSelect/demo/tagRender.js +0 -51
  229. package/dist/McSelect/index.css +0 -60
  230. package/dist/McSelect/index.d.ts +0 -47
  231. package/dist/McSelect/index.js +0 -436
  232. package/dist/McTag/demo/demo1.d.ts +0 -2
  233. package/dist/McTag/demo/demo1.js +0 -18
  234. package/dist/McTag/demo/demo2.d.ts +0 -2
  235. package/dist/McTag/demo/demo2.js +0 -20
  236. package/dist/McTag/demo/demo3.d.ts +0 -2
  237. package/dist/McTag/demo/demo3.js +0 -19
  238. package/dist/McTag/demo/demo4.d.ts +0 -2
  239. package/dist/McTag/demo/demo4.js +0 -22
  240. package/dist/McTag/index.d.ts +0 -22
  241. package/dist/McTag/index.js +0 -59
  242. package/dist/McThemeConfig/customToken.json +0 -39
  243. package/dist/McThemeConfig/demo/button.d.ts +0 -2
  244. package/dist/McThemeConfig/demo/button.js +0 -226
  245. package/dist/McThemeConfig/demo/card.d.ts +0 -2
  246. package/dist/McThemeConfig/demo/card.js +0 -60
  247. package/dist/McThemeConfig/demo/drawer.d.ts +0 -2
  248. package/dist/McThemeConfig/demo/drawer.js +0 -59
  249. package/dist/McThemeConfig/demo/modal.d.ts +0 -2
  250. package/dist/McThemeConfig/demo/modal.js +0 -78
  251. package/dist/McThemeConfig/demo/radio.d.ts +0 -2
  252. package/dist/McThemeConfig/demo/radio.js +0 -136
  253. package/dist/McThemeConfig/demo/switch.d.ts +0 -2
  254. package/dist/McThemeConfig/demo/switch.js +0 -96
  255. package/dist/McThemeConfig/demo/tabs.d.ts +0 -2
  256. package/dist/McThemeConfig/demo/tabs.js +0 -35
  257. package/dist/McThemeConfig/globalStyle.d.ts +0 -2
  258. package/dist/McThemeConfig/globalStyle.js +0 -198
  259. package/dist/McThemeConfig/index.d.ts +0 -9
  260. package/dist/McThemeConfig/index.js +0 -16
  261. package/dist/McThemeConfig/layoutStyle.d.ts +0 -2
  262. package/dist/McThemeConfig/layoutStyle.js +0 -1
  263. package/dist/McThemeConfig/provider.d.ts +0 -8
  264. package/dist/McThemeConfig/provider.js +0 -20
  265. package/dist/McThemeConfig/themeToken.json +0 -152
  266. package/dist/McTreePanel/SelectedItem.d.ts +0 -4
  267. package/dist/McTreePanel/SelectedItem.js +0 -75
  268. package/dist/McTreePanel/demo/base.d.ts +0 -6
  269. package/dist/McTreePanel/demo/base.js +0 -45
  270. package/dist/McTreePanel/demo/fieldNames.d.ts +0 -6
  271. package/dist/McTreePanel/demo/fieldNames.js +0 -37
  272. package/dist/McTreePanel/demo/inexistent.d.ts +0 -6
  273. package/dist/McTreePanel/demo/inexistent.js +0 -56
  274. package/dist/McTreePanel/demo/labelInValue.d.ts +0 -6
  275. package/dist/McTreePanel/demo/labelInValue.js +0 -56
  276. package/dist/McTreePanel/demo/sortable.d.ts +0 -6
  277. package/dist/McTreePanel/demo/sortable.js +0 -34
  278. package/dist/McTreePanel/index.css +0 -110
  279. package/dist/McTreePanel/index.d.ts +0 -27
  280. package/dist/McTreePanel/index.js +0 -315
  281. package/dist/McTreeSelect/demo/base.d.ts +0 -5
  282. package/dist/McTreeSelect/demo/base.js +0 -58
  283. package/dist/McTreeSelect/demo/inexistent.d.ts +0 -5
  284. package/dist/McTreeSelect/demo/inexistent.js +0 -63
  285. package/dist/McTreeSelect/demo/label.d.ts +0 -5
  286. package/dist/McTreeSelect/demo/label.js +0 -60
  287. package/dist/McTreeSelect/demo/multiple.d.ts +0 -5
  288. package/dist/McTreeSelect/demo/multiple.js +0 -71
  289. package/dist/McTreeSelect/index.css +0 -60
  290. package/dist/McTreeSelect/index.d.ts +0 -13
  291. package/dist/McTreeSelect/index.js +0 -182
  292. package/dist/Utils/index.d.ts +0 -13
  293. package/dist/Utils/index.js +0 -60
  294. package/dist/index.d.ts +0 -31
  295. package/dist/index.js +0 -31
  296. package/dist/styles/demo/basic.d.ts +0 -2
  297. package/dist/styles/demo/basic.js +0 -44
  298. package/dist/styles/demo/delete-icon.d.ts +0 -2
  299. package/dist/styles/demo/delete-icon.js +0 -72
  300. package/dist/styles/demo/form-bottom-0.d.ts +0 -2
  301. package/dist/styles/demo/form-bottom-0.js +0 -33
  302. package/dist/styles/index.css +0 -41
  303. package/dist/styles/mixins.css +0 -2
  304. package/dist/styles/utilities.css +0 -41
  305. package/dist/typings.d.ts +0 -20
@@ -1,174 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- export interface McModalState {
3
- id: string;
4
- args?: Record<string, unknown>;
5
- visible?: boolean;
6
- delayVisible?: boolean;
7
- keepMounted?: boolean;
8
- }
9
- export interface McModalStore {
10
- [key: string]: McModalState;
11
- }
12
- export interface McModalAction {
13
- type: string;
14
- payload: {
15
- modalId: string;
16
- args?: Record<string, unknown>;
17
- flags?: Record<string, unknown>;
18
- };
19
- }
20
- /**
21
- * The handler to manage a modal returned by {@link useModal | useModal} hook.
22
- */
23
- export interface McModalHandler<Props = Record<string, unknown>> extends McModalState {
24
- /**
25
- * Whether a modal is visible, it's controlled by {@link McModalHandler.show | show}/{@link McModalHandler.hide | hide} method.
26
- */
27
- visible: boolean;
28
- /**
29
- * If you don't want to remove the modal from the tree after hide when using helpers, set it to true.
30
- */
31
- keepMounted: boolean;
32
- /**
33
- * Show the modal, it will change {@link McModalHandler.visible | visible} state to true.
34
- * @param args - an object passed to modal component as props.
35
- */
36
- show: (args?: Props) => Promise<unknown>;
37
- /**
38
- * Hide the modal, it will change {@link McModalHandler.visible | visible} state to false.
39
- */
40
- hide: () => Promise<unknown>;
41
- /**
42
- * Resolve the promise returned by {@link McModalHandler.show | show} method.
43
- */
44
- resolve: (args?: unknown) => void;
45
- /**
46
- * Reject the promise returned by {@link McModalHandler.show | show} method.
47
- */
48
- reject: (args?: unknown) => void;
49
- /**
50
- * Remove the modal component from React component tree. It improves performance compared to just making a modal invisible.
51
- */
52
- remove: () => void;
53
- /**
54
- * Resolve the promise returned by {@link McModalHandler.hide | hide} method.
55
- */
56
- resolveHide: (args?: unknown) => void;
57
- }
58
- export interface McModalHocProps {
59
- id: string;
60
- defaultVisible?: boolean;
61
- keepMounted?: boolean;
62
- }
63
- export declare const McModalContext: React.Context<McModalStore>;
64
- declare let dispatch: React.Dispatch<McModalAction>;
65
- export declare const reducer: (state: McModalStore | undefined, action: McModalAction) => McModalStore;
66
- declare function getModal(modalId: string): React.FC<any> | undefined;
67
- export declare const register: <T extends React.FC<any>>(id: string, comp: T, props?: Partial<McModalArgs<T>>) => void;
68
- type McModalArgs<T> = T extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any> ? React.ComponentProps<T> : Record<string, unknown>;
69
- export declare function show<T extends any, C extends any, P extends Partial<McModalArgs<React.FC<C>>>>(modal: React.FC<C>, args?: P): Promise<T>;
70
- export declare function show<T extends any>(modal: string, args?: Record<string, unknown>): Promise<T>;
71
- export declare function show<T extends any, P extends any>(modal: string, args: P): Promise<T>;
72
- export declare function hide<T>(modal: string | React.FC<any>): Promise<T>;
73
- export declare const remove: (modal: string | React.FC<any>) => void;
74
- export declare function useModal(): McModalHandler;
75
- export declare function useModal(modal: string, args?: Record<string, unknown>): McModalHandler;
76
- export declare function useModal<C extends any, P extends Partial<McModalArgs<React.FC<C>>>>(modal: React.FC<C>, args?: P): Omit<McModalHandler, 'show'> & {
77
- show: (args?: P) => Promise<unknown>;
78
- };
79
- export declare const create: <P extends {}>(Comp: React.ComponentType<P>) => React.FC<P & McModalHocProps>;
80
- /**
81
- * Unregister a modal.
82
- * @param id - The id of the modal.
83
- */
84
- export declare const unregister: (id: string) => void;
85
- export declare const Provider: ({ children, dispatch: givenDispatch, modals: givenModals, }: {
86
- children: ReactNode;
87
- dispatch?: React.Dispatch<McModalAction> | undefined;
88
- modals?: McModalStore | undefined;
89
- }) => import("react/jsx-runtime").JSX.Element;
90
- /**
91
- * Declarative way to register a modal.
92
- * @param id - The id of the modal.
93
- * @param component - The modal Component.
94
- * @returns
95
- */
96
- export declare const ModalDef: ({ id, component, }: {
97
- id: string;
98
- component: React.FC<any>;
99
- }) => null;
100
- /**
101
- * A place holder allows to bind props to a modal.
102
- * It assigns show/hide methods to handler object to show/hide the modal.
103
- *
104
- * Comparing to use the <MyMcModal id=../> directly, this approach allows use registered modal id to find the modal component.
105
- * Also it avoids to create unique id for MyMcModal.
106
- *
107
- * @param modal - The modal id registered or a modal component.
108
- * @param handler - The handler object to control the modal.
109
- * @returns
110
- */
111
- export declare const ModalHolder: ({ modal, handler, ...restProps }: {
112
- [key: string]: any;
113
- modal: string | React.FC<any>;
114
- handler: any;
115
- }) => import("react/jsx-runtime").JSX.Element;
116
- export declare const antdModalV4: (modal: McModalHandler) => {
117
- visible: boolean;
118
- onCancel: () => void;
119
- onOk: () => void;
120
- afterClose: () => void;
121
- };
122
- export declare const antdModal: (modal: McModalHandler) => {
123
- open: boolean;
124
- onCancel: () => void;
125
- onOk: () => void;
126
- afterClose: () => void;
127
- };
128
- export declare const antdDrawerV4: (modal: McModalHandler) => {
129
- visible: boolean;
130
- onClose: () => void;
131
- afterVisibleChange: (visible: boolean) => void;
132
- };
133
- export declare const antdDrawer: (modal: McModalHandler) => {
134
- open: boolean;
135
- onClose: () => void;
136
- afterOpenChange: (visible: boolean) => void;
137
- };
138
- declare const McModal: {
139
- Provider: ({ children, dispatch: givenDispatch, modals: givenModals, }: {
140
- children: ReactNode;
141
- dispatch?: React.Dispatch<McModalAction> | undefined;
142
- modals?: McModalStore | undefined;
143
- }) => import("react/jsx-runtime").JSX.Element;
144
- ModalDef: ({ id, component, }: {
145
- id: string;
146
- component: React.FC<any>;
147
- }) => null;
148
- ModalHolder: ({ modal, handler, ...restProps }: {
149
- [key: string]: any;
150
- modal: string | React.FC<any>;
151
- handler: any;
152
- }) => import("react/jsx-runtime").JSX.Element;
153
- McModalContext: React.Context<McModalStore>;
154
- create: <P extends {}>(Comp: React.ComponentType<P>) => React.FC<P & McModalHocProps>;
155
- register: <T extends React.FC<any>>(id: string, comp: T, props?: Partial<McModalArgs<T>>) => void;
156
- getModal: typeof getModal;
157
- show: typeof show;
158
- hide: typeof hide;
159
- remove: (modal: string | React.FC<any>) => void;
160
- useModal: typeof useModal;
161
- reducer: (state: McModalStore | undefined, action: McModalAction) => McModalStore;
162
- antdModal: (modal: McModalHandler) => {
163
- open: boolean;
164
- onCancel: () => void;
165
- onOk: () => void;
166
- afterClose: () => void;
167
- };
168
- antdDrawer: (modal: McModalHandler) => {
169
- open: boolean;
170
- onClose: () => void;
171
- afterOpenChange: (visible: boolean) => void;
172
- };
173
- };
174
- export default McModal;
@@ -1,498 +0,0 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
- var _excluded = ["defaultVisible", "keepMounted", "id"],
5
- _excluded2 = ["modal", "handler"];
6
- import React, { useCallback, useContext, useEffect, useMemo, useReducer } from 'react';
7
-
8
- /**
9
- * The handler to manage a modal returned by {@link useModal | useModal} hook.
10
- */
11
-
12
- // Omit will not work if extends Record<string, unknown>, which is not needed here
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- import { Fragment as _Fragment } from "react/jsx-runtime";
15
- import { jsxs as _jsxs } from "react/jsx-runtime";
16
- var symModalId = Symbol('McModalId');
17
- var initialState = {};
18
- export var McModalContext = /*#__PURE__*/React.createContext(initialState);
19
- var McModalIdContext = /*#__PURE__*/React.createContext(null);
20
- var MODAL_REGISTRY = {};
21
- var ALREADY_MOUNTED = {};
22
- var uidSeed = 0;
23
- var dispatch = function dispatch() {
24
- throw new Error('No dispatch method detected, did you embed your app with McModal.Provider?');
25
- };
26
- var getUid = function getUid() {
27
- return "_mc_modal_".concat(uidSeed++);
28
- };
29
-
30
- // Modal reducer used in useReducer hook.
31
- export var reducer = function reducer() {
32
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
33
- var action = arguments.length > 1 ? arguments[1] : undefined;
34
- switch (action.type) {
35
- case 'McModal/show':
36
- {
37
- var _action$payload = action.payload,
38
- _modalId = _action$payload.modalId,
39
- _args = _action$payload.args;
40
- return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, _modalId, _objectSpread(_objectSpread({}, state[_modalId]), {}, {
41
- id: _modalId,
42
- args: _args,
43
- // If modal is not mounted, mount it first then make it visible.
44
- // There is logic inside HOC wrapper to make it visible after its first mount.
45
- // This mechanism ensures the entering transition.
46
- visible: !!ALREADY_MOUNTED[_modalId],
47
- delayVisible: !ALREADY_MOUNTED[_modalId]
48
- })));
49
- }
50
- case 'McModal/hide':
51
- {
52
- var _modalId2 = action.payload.modalId;
53
- if (!state[_modalId2]) return state;
54
- return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, _modalId2, _objectSpread(_objectSpread({}, state[_modalId2]), {}, {
55
- visible: false
56
- })));
57
- }
58
- case 'McModal/remove':
59
- {
60
- var _modalId3 = action.payload.modalId;
61
- var newState = _objectSpread({}, state);
62
- delete newState[_modalId3];
63
- return newState;
64
- }
65
- case 'McModal/setFlags':
66
- {
67
- var _action$payload2 = action.payload,
68
- _modalId4 = _action$payload2.modalId,
69
- flags = _action$payload2.flags;
70
- return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, _modalId4, _objectSpread(_objectSpread({}, state[_modalId4]), flags)));
71
- }
72
- default:
73
- return state;
74
- }
75
- };
76
-
77
- // Get modal component by modal id
78
- function getModal(modalId) {
79
- var _MODAL_REGISTRY$modal;
80
- return (_MODAL_REGISTRY$modal = MODAL_REGISTRY[modalId]) === null || _MODAL_REGISTRY$modal === void 0 ? void 0 : _MODAL_REGISTRY$modal.comp;
81
- }
82
-
83
- // action creator to show a modal
84
- function showModal(modalId, args) {
85
- return {
86
- type: 'McModal/show',
87
- payload: {
88
- modalId: modalId,
89
- args: args
90
- }
91
- };
92
- }
93
-
94
- // action creator to set flags of a modal
95
- function setModalFlags(modalId, flags) {
96
- return {
97
- type: 'McModal/setFlags',
98
- payload: {
99
- modalId: modalId,
100
- flags: flags
101
- }
102
- };
103
- }
104
- // action creator to hide a modal
105
- function hideModal(modalId) {
106
- return {
107
- type: 'McModal/hide',
108
- payload: {
109
- modalId: modalId
110
- }
111
- };
112
- }
113
-
114
- // action creator to remove a modal
115
- function removeModal(modalId) {
116
- return {
117
- type: 'McModal/remove',
118
- payload: {
119
- modalId: modalId
120
- }
121
- };
122
- }
123
- var modalCallbacks = {};
124
- var hideModalCallbacks = {};
125
- var getModalId = function getModalId(modal) {
126
- if (typeof modal === 'string') return modal;
127
- // @ts-ignore
128
- if (!modal[symModalId]) {
129
- // @ts-ignore
130
- modal[symModalId] = getUid();
131
- }
132
- // @ts-ignore
133
- return modal[symModalId];
134
- };
135
-
136
- // All registered modals will be rendered in modal placeholder
137
- export var register = function register(id, comp, props) {
138
- if (!MODAL_REGISTRY[id]) {
139
- MODAL_REGISTRY[id] = {
140
- comp: comp,
141
- props: props
142
- };
143
- } else {
144
- MODAL_REGISTRY[id].props = props;
145
- }
146
- };
147
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
148
- export function show(modal, args) {
149
- var modalId = getModalId(modal);
150
- if (typeof modal !== 'string' && !MODAL_REGISTRY[modalId]) {
151
- register(modalId, modal);
152
- }
153
- dispatch(showModal(modalId, args));
154
- if (!modalCallbacks[modalId]) {
155
- // `!` tell ts that theResolve will be written before it is used
156
- var theResolve;
157
- // `!` tell ts that theResolve will be written before it is used
158
- var theReject;
159
- var promise = new Promise(function (resolve, reject) {
160
- theResolve = resolve;
161
- theReject = reject;
162
- });
163
- modalCallbacks[modalId] = {
164
- resolve: theResolve,
165
- reject: theReject,
166
- promise: promise
167
- };
168
- }
169
- return modalCallbacks[modalId].promise;
170
- }
171
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
172
- export function hide(modal) {
173
- var modalId = getModalId(modal);
174
- dispatch(hideModal(modalId));
175
- // Should also delete the callback for modal.resolve #35
176
- delete modalCallbacks[modalId];
177
- if (!hideModalCallbacks[modalId]) {
178
- // `!` tell ts that theResolve will be written before it is used
179
- var theResolve;
180
- // `!` tell ts that theResolve will be written before it is used
181
- var theReject;
182
- var promise = new Promise(function (resolve, reject) {
183
- theResolve = resolve;
184
- theReject = reject;
185
- });
186
- hideModalCallbacks[modalId] = {
187
- resolve: theResolve,
188
- reject: theReject,
189
- promise: promise
190
- };
191
- }
192
- return hideModalCallbacks[modalId].promise;
193
- }
194
- export var remove = function remove(modal) {
195
- var modalId = getModalId(modal);
196
- dispatch(removeModal(modalId));
197
- delete modalCallbacks[modalId];
198
- delete hideModalCallbacks[modalId];
199
- };
200
- var setFlags = function setFlags(modalId, flags) {
201
- dispatch(setModalFlags(modalId, flags));
202
- };
203
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
204
- export function useModal(modal, args) {
205
- var modals = useContext(McModalContext);
206
- var contextModalId = useContext(McModalIdContext);
207
- var modalId = null;
208
- var isUseComponent = modal && typeof modal !== 'string';
209
- if (!modal) {
210
- modalId = contextModalId;
211
- } else {
212
- modalId = getModalId(modal);
213
- }
214
-
215
- // Only if contextModalId doesn't exist
216
- if (!modalId) throw new Error('No modal id found in McModal.useModal.');
217
- var mid = modalId;
218
- // If use a component directly, register it.
219
- useEffect(function () {
220
- if (isUseComponent && !MODAL_REGISTRY[mid]) {
221
- register(mid, modal, args);
222
- }
223
- }, [isUseComponent, mid, modal, args]);
224
- var modalInfo = modals[mid];
225
- var showCallback = useCallback(function (args) {
226
- return show(mid, args);
227
- }, [mid]);
228
- var hideCallback = useCallback(function () {
229
- return hide(mid);
230
- }, [mid]);
231
- var removeCallback = useCallback(function () {
232
- return remove(mid);
233
- }, [mid]);
234
- var resolveCallback = useCallback(function (args) {
235
- var _modalCallbacks$mid;
236
- (_modalCallbacks$mid = modalCallbacks[mid]) === null || _modalCallbacks$mid === void 0 || _modalCallbacks$mid.resolve(args);
237
- delete modalCallbacks[mid];
238
- }, [mid]);
239
- var rejectCallback = useCallback(function (args) {
240
- var _modalCallbacks$mid2;
241
- (_modalCallbacks$mid2 = modalCallbacks[mid]) === null || _modalCallbacks$mid2 === void 0 || _modalCallbacks$mid2.reject(args);
242
- delete modalCallbacks[mid];
243
- }, [mid]);
244
- var resolveHide = useCallback(function (args) {
245
- var _hideModalCallbacks$m;
246
- (_hideModalCallbacks$m = hideModalCallbacks[mid]) === null || _hideModalCallbacks$m === void 0 || _hideModalCallbacks$m.resolve(args);
247
- delete hideModalCallbacks[mid];
248
- }, [mid]);
249
- return useMemo(function () {
250
- return {
251
- id: mid,
252
- args: modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.args,
253
- visible: !!(modalInfo !== null && modalInfo !== void 0 && modalInfo.visible),
254
- keepMounted: !!(modalInfo !== null && modalInfo !== void 0 && modalInfo.keepMounted),
255
- show: showCallback,
256
- hide: hideCallback,
257
- remove: removeCallback,
258
- resolve: resolveCallback,
259
- reject: rejectCallback,
260
- resolveHide: resolveHide
261
- };
262
- }, [mid, modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.args, modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.visible, modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.keepMounted, showCallback, hideCallback, removeCallback, resolveCallback, rejectCallback, resolveHide]);
263
- }
264
- export var create = function create(Comp) {
265
- return function (_ref) {
266
- var _modals$id;
267
- var defaultVisible = _ref.defaultVisible,
268
- keepMounted = _ref.keepMounted,
269
- id = _ref.id,
270
- props = _objectWithoutProperties(_ref, _excluded);
271
- var _useModal = useModal(id),
272
- args = _useModal.args,
273
- show = _useModal.show;
274
-
275
- // If there's modal state, then should mount it.
276
- var modals = useContext(McModalContext);
277
- var shouldMount = !!modals[id];
278
- useEffect(function () {
279
- // If defaultVisible, show it after mounted.
280
- if (defaultVisible) {
281
- show();
282
- }
283
- ALREADY_MOUNTED[id] = true;
284
- return function () {
285
- delete ALREADY_MOUNTED[id];
286
- };
287
- }, [id, show, defaultVisible]);
288
- useEffect(function () {
289
- if (keepMounted) setFlags(id, {
290
- keepMounted: true
291
- });
292
- }, [id, keepMounted]);
293
- var delayVisible = (_modals$id = modals[id]) === null || _modals$id === void 0 ? void 0 : _modals$id.delayVisible;
294
- // If modal.show is called
295
- // 1. If modal was mounted, should make it visible directly
296
- // 2. If modal has not been mounted, should mount it first, then make it visible
297
- useEffect(function () {
298
- if (delayVisible) {
299
- // delayVisible: false => true, it means the modal.show() is called, should show it.
300
- show(args);
301
- }
302
- }, [delayVisible, args, show]);
303
- if (!shouldMount) return null;
304
- return /*#__PURE__*/_jsx(McModalIdContext.Provider, {
305
- value: id,
306
- children: /*#__PURE__*/_jsx(Comp, _objectSpread(_objectSpread({}, props), args))
307
- });
308
- };
309
- };
310
-
311
- /**
312
- * Unregister a modal.
313
- * @param id - The id of the modal.
314
- */
315
- export var unregister = function unregister(id) {
316
- delete MODAL_REGISTRY[id];
317
- };
318
-
319
- // The placeholder component is used to auto render modals when call modal.show()
320
- // When modal.show() is called, it means there've been modal info
321
- var McModalPlaceholder = function McModalPlaceholder() {
322
- var modals = useContext(McModalContext);
323
- var visibleModalIds = Object.keys(modals).filter(function (id) {
324
- return !!modals[id];
325
- });
326
- visibleModalIds.forEach(function (id) {
327
- if (!MODAL_REGISTRY[id] && !ALREADY_MOUNTED[id]) {
328
- console.warn("No modal found for id: ".concat(id, ". Please check the id or if it is registered or declared via JSX."));
329
- return;
330
- }
331
- });
332
- var toRender = visibleModalIds.filter(function (id) {
333
- return MODAL_REGISTRY[id];
334
- }).map(function (id) {
335
- return _objectSpread({
336
- id: id
337
- }, MODAL_REGISTRY[id]);
338
- });
339
- return /*#__PURE__*/_jsx(_Fragment, {
340
- children: toRender.map(function (t) {
341
- return /*#__PURE__*/_jsx(t.comp, _objectSpread({
342
- id: t.id
343
- }, t.props), t.id);
344
- })
345
- });
346
- };
347
- var InnerContextProvider = function InnerContextProvider(_ref2) {
348
- var children = _ref2.children;
349
- var arr = useReducer(reducer, initialState);
350
- var modals = arr[0];
351
- dispatch = arr[1];
352
- return /*#__PURE__*/_jsxs(McModalContext.Provider, {
353
- value: modals,
354
- children: [children, /*#__PURE__*/_jsx(McModalPlaceholder, {})]
355
- });
356
- };
357
- export var Provider = function Provider(_ref3) {
358
- var children = _ref3.children,
359
- givenDispatch = _ref3.dispatch,
360
- givenModals = _ref3.modals;
361
- if (!givenDispatch || !givenModals) {
362
- return /*#__PURE__*/_jsx(InnerContextProvider, {
363
- children: children
364
- });
365
- }
366
- dispatch = givenDispatch;
367
- return /*#__PURE__*/_jsxs(McModalContext.Provider, {
368
- value: givenModals,
369
- children: [children, /*#__PURE__*/_jsx(McModalPlaceholder, {})]
370
- });
371
- };
372
-
373
- /**
374
- * Declarative way to register a modal.
375
- * @param id - The id of the modal.
376
- * @param component - The modal Component.
377
- * @returns
378
- */
379
- export var ModalDef = function ModalDef(_ref4) {
380
- var id = _ref4.id,
381
- component = _ref4.component;
382
- useEffect(function () {
383
- register(id, component);
384
- return function () {
385
- unregister(id);
386
- };
387
- }, [id, component]);
388
- return null;
389
- };
390
-
391
- /**
392
- * A place holder allows to bind props to a modal.
393
- * It assigns show/hide methods to handler object to show/hide the modal.
394
- *
395
- * Comparing to use the <MyMcModal id=../> directly, this approach allows use registered modal id to find the modal component.
396
- * Also it avoids to create unique id for MyMcModal.
397
- *
398
- * @param modal - The modal id registered or a modal component.
399
- * @param handler - The handler object to control the modal.
400
- * @returns
401
- */
402
- export var ModalHolder = function ModalHolder(_ref5) {
403
- var _MODAL_REGISTRY$modal2;
404
- var modal = _ref5.modal,
405
- _ref5$handler = _ref5.handler,
406
- handler = _ref5$handler === void 0 ? {} : _ref5$handler,
407
- restProps = _objectWithoutProperties(_ref5, _excluded2);
408
- var mid = useMemo(function () {
409
- return getUid();
410
- }, []);
411
- var ModalComp = typeof modal === 'string' ? (_MODAL_REGISTRY$modal2 = MODAL_REGISTRY[modal]) === null || _MODAL_REGISTRY$modal2 === void 0 ? void 0 : _MODAL_REGISTRY$modal2.comp : modal;
412
- if (!handler) {
413
- throw new Error('No handler found in McModal.ModalHolder.');
414
- }
415
- if (!ModalComp) {
416
- throw new Error("No modal found for id: ".concat(modal, " in McModal.ModalHolder."));
417
- }
418
- handler.show = useCallback(function (args) {
419
- return show(mid, args);
420
- }, [mid]);
421
- handler.hide = useCallback(function () {
422
- return hide(mid);
423
- }, [mid]);
424
- return /*#__PURE__*/_jsx(ModalComp, _objectSpread({
425
- id: mid
426
- }, restProps));
427
- };
428
- export var antdModalV4 = function antdModalV4(modal) {
429
- return {
430
- visible: modal.visible,
431
- onOk: function onOk() {
432
- return modal.hide();
433
- },
434
- onCancel: function onCancel() {
435
- return modal.hide();
436
- },
437
- afterClose: function afterClose() {
438
- // Need to resolve before remove
439
- modal.resolveHide();
440
- if (!modal.keepMounted) modal.remove();
441
- }
442
- };
443
- };
444
- export var antdModal = function antdModal(modal) {
445
- var _antdModalV = antdModalV4(modal),
446
- onOk = _antdModalV.onOk,
447
- onCancel = _antdModalV.onCancel,
448
- afterClose = _antdModalV.afterClose;
449
- return {
450
- open: modal.visible,
451
- onOk: onOk,
452
- onCancel: onCancel,
453
- afterClose: afterClose
454
- };
455
- };
456
- export var antdDrawerV4 = function antdDrawerV4(modal) {
457
- return {
458
- visible: modal.visible,
459
- onClose: function onClose() {
460
- return modal.hide();
461
- },
462
- afterVisibleChange: function afterVisibleChange(v) {
463
- if (!v) {
464
- modal.resolveHide();
465
- }
466
- if (!v && !modal.keepMounted) {
467
- modal.remove();
468
- }
469
- }
470
- };
471
- };
472
- export var antdDrawer = function antdDrawer(modal) {
473
- var _antdDrawerV = antdDrawerV4(modal),
474
- onClose = _antdDrawerV.onClose,
475
- afterOpenChange = _antdDrawerV.afterVisibleChange;
476
- return {
477
- open: modal.visible,
478
- onClose: onClose,
479
- afterOpenChange: afterOpenChange
480
- };
481
- };
482
- var McModal = {
483
- Provider: Provider,
484
- ModalDef: ModalDef,
485
- ModalHolder: ModalHolder,
486
- McModalContext: McModalContext,
487
- create: create,
488
- register: register,
489
- getModal: getModal,
490
- show: show,
491
- hide: hide,
492
- remove: remove,
493
- useModal: useModal,
494
- reducer: reducer,
495
- antdModal: antdModal,
496
- antdDrawer: antdDrawer
497
- };
498
- export default McModal;
@@ -1,6 +0,0 @@
1
- /**
2
- * title: 基础用法
3
- * description: 通过 `value` 属性设置默认值,通过 `onChange` 事件获取当前值。
4
- */
5
- declare const _default: () => import("react/jsx-runtime").JSX.Element;
6
- export default _default;
@@ -1,19 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- /**
3
- * title: 基础用法
4
- * description: 通过 `value` 属性设置默认值,通过 `onChange` 事件获取当前值。
5
- */
6
-
7
- import { McPeriodSelect } from "../..";
8
- import { useState } from 'react';
9
- import { jsx as _jsx } from "react/jsx-runtime";
10
- export default (function () {
11
- var _useState = useState(),
12
- _useState2 = _slicedToArray(_useState, 2),
13
- value = _useState2[0],
14
- setValue = _useState2[1];
15
- return /*#__PURE__*/_jsx(McPeriodSelect, {
16
- value: value,
17
- onChange: setValue
18
- });
19
- });
@@ -1,6 +0,0 @@
1
- /**
2
- * title: 改变单位时间长度为半小时
3
- * description: 通过设置half属性为true,可以使选择的时间段的单位长度变为半小时。
4
- */
5
- declare const _default: () => import("react/jsx-runtime").JSX.Element;
6
- export default _default;