@wzyjs/uis 0.3.29 → 0.3.30

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 (221) hide show
  1. package/dist/advanced/Com2Canvas/index.d.ts +8 -0
  2. package/dist/advanced/Com2Canvas/index.js +39 -0
  3. package/dist/advanced/Crud/components/CardList/index.d.ts +2 -0
  4. package/dist/advanced/Crud/components/CardList/index.js +90 -0
  5. package/dist/advanced/Crud/components/CreateUpdate/index.d.ts +2 -0
  6. package/dist/advanced/Crud/components/CreateUpdate/index.js +78 -0
  7. package/dist/advanced/Crud/components/ListTabs/index.d.ts +8 -0
  8. package/dist/advanced/Crud/components/ListTabs/index.js +7 -0
  9. package/dist/advanced/Crud/components/Provider/index.d.ts +7 -0
  10. package/dist/advanced/Crud/components/Provider/index.js +42 -0
  11. package/dist/advanced/Crud/components/QuickFilters/index.d.ts +8 -0
  12. package/dist/advanced/Crud/components/QuickFilters/index.js +20 -0
  13. package/dist/advanced/Crud/components/Remove/index.d.ts +2 -0
  14. package/dist/advanced/Crud/components/Remove/index.js +18 -0
  15. package/dist/advanced/Crud/components/index.d.ts +6 -0
  16. package/dist/advanced/Crud/components/index.js +6 -0
  17. package/dist/advanced/Crud/hooks/index.d.ts +5 -0
  18. package/dist/advanced/Crud/hooks/index.js +5 -0
  19. package/dist/advanced/Crud/hooks/useColumns.d.ts +11 -0
  20. package/dist/advanced/Crud/hooks/useColumns.js +111 -0
  21. package/dist/advanced/Crud/hooks/useList.d.ts +12 -0
  22. package/dist/advanced/Crud/hooks/useList.js +53 -0
  23. package/dist/advanced/Crud/hooks/useListFilters.d.ts +11 -0
  24. package/dist/advanced/Crud/hooks/useListFilters.js +159 -0
  25. package/dist/advanced/Crud/hooks/useOrderable.d.ts +15 -0
  26. package/dist/advanced/Crud/hooks/useOrderable.js +75 -0
  27. package/dist/advanced/Crud/hooks/useRequest.d.ts +13 -0
  28. package/dist/advanced/Crud/hooks/useRequest.js +27 -0
  29. package/dist/advanced/Crud/index.d.ts +3 -0
  30. package/dist/advanced/Crud/index.js +46 -0
  31. package/dist/advanced/Crud/types/index.d.ts +176 -0
  32. package/dist/advanced/Crud/types/index.js +1 -0
  33. package/dist/advanced/Crud/utils/index.d.ts +7 -0
  34. package/dist/advanced/Crud/utils/index.js +80 -0
  35. package/dist/advanced/Crud/utils/query.d.ts +3 -0
  36. package/dist/advanced/Crud/utils/query.js +34 -0
  37. package/dist/advanced/MindMap/context.d.ts +12 -0
  38. package/dist/advanced/MindMap/context.js +12 -0
  39. package/dist/advanced/MindMap/hooks/useAlignmentSnap.d.ts +15 -0
  40. package/dist/advanced/MindMap/hooks/useAlignmentSnap.js +164 -0
  41. package/dist/advanced/MindMap/hooks/useCopyPaste.d.ts +11 -0
  42. package/dist/advanced/MindMap/hooks/useCopyPaste.js +209 -0
  43. package/dist/advanced/MindMap/hooks/useDropToReparent.d.ts +21 -0
  44. package/dist/advanced/MindMap/hooks/useDropToReparent.js +216 -0
  45. package/dist/advanced/MindMap/hooks/useExpandCollapse.d.ts +18 -0
  46. package/dist/advanced/MindMap/hooks/useExpandCollapse.js +108 -0
  47. package/dist/advanced/MindMap/hooks/useMoveDescendants.d.ts +12 -0
  48. package/dist/advanced/MindMap/hooks/useMoveDescendants.js +98 -0
  49. package/dist/advanced/MindMap/hooks/useUndoRedo.d.ts +14 -0
  50. package/dist/advanced/MindMap/hooks/useUndoRedo.js +181 -0
  51. package/dist/advanced/MindMap/index.d.ts +29 -0
  52. package/dist/advanced/MindMap/index.js +52 -0
  53. package/dist/advanced/index.d.ts +5 -0
  54. package/dist/advanced/index.js +5 -0
  55. package/dist/antd/index.d.ts +6 -0
  56. package/dist/antd/index.js +5 -0
  57. package/dist/buttons/ButtonGroup/index.d.ts +8 -0
  58. package/dist/buttons/ButtonGroup/index.js +13 -0
  59. package/dist/buttons/ConfirmButton/index.d.ts +5 -0
  60. package/dist/buttons/ConfirmButton/index.js +9 -0
  61. package/dist/buttons/CopyButton/index.d.ts +6 -0
  62. package/dist/buttons/CopyButton/index.js +26 -0
  63. package/dist/buttons/DrawerButton/index.d.ts +6 -0
  64. package/dist/buttons/DrawerButton/index.js +13 -0
  65. package/dist/buttons/ProgressButton/index.css +63 -0
  66. package/dist/buttons/ProgressButton/index.d.ts +17 -0
  67. package/dist/buttons/ProgressButton/index.js +31 -0
  68. package/dist/buttons/SectorButton/index.d.ts +20 -0
  69. package/dist/buttons/SectorButton/index.js +130 -0
  70. package/dist/buttons/index.d.ts +6 -0
  71. package/dist/buttons/index.js +6 -0
  72. package/dist/display/CodeView/index.d.ts +26 -0
  73. package/dist/display/CodeView/index.js +60 -0
  74. package/dist/display/EnumTag/index.d.ts +12 -0
  75. package/dist/display/EnumTag/index.js +10 -0
  76. package/dist/display/HtmlDataRenderer/index.d.ts +6 -0
  77. package/dist/display/HtmlDataRenderer/index.js +15 -0
  78. package/dist/display/HtmlView/index.d.ts +6 -0
  79. package/dist/display/HtmlView/index.js +6 -0
  80. package/dist/display/IframePro/index.d.ts +8 -0
  81. package/dist/display/IframePro/index.js +24 -0
  82. package/dist/display/JsonSchemaRenderer/index.d.ts +11 -0
  83. package/dist/display/JsonSchemaRenderer/index.js +62 -0
  84. package/dist/display/JsonView/index.d.ts +3 -0
  85. package/dist/display/JsonView/index.js +7 -0
  86. package/dist/display/MarkdownView/index.d.ts +7 -0
  87. package/dist/display/MarkdownView/index.js +80 -0
  88. package/dist/display/MarkdownView/style.d.ts +1 -0
  89. package/{src/components/Markdown/style.ts → dist/display/MarkdownView/style.js} +1 -1
  90. package/dist/display/VideoPro/index.d.ts +9 -0
  91. package/dist/display/VideoPro/index.js +15 -0
  92. package/dist/display/index.d.ts +9 -0
  93. package/dist/display/index.js +9 -0
  94. package/dist/inputs/CheckboxButton/index.css +22 -0
  95. package/dist/inputs/CheckboxButton/index.d.ts +12 -0
  96. package/dist/inputs/CheckboxButton/index.js +9 -0
  97. package/dist/inputs/DateSwitcher/index.css +10 -0
  98. package/dist/inputs/DateSwitcher/index.d.ts +8 -0
  99. package/dist/inputs/DateSwitcher/index.js +29 -0
  100. package/dist/inputs/FetchSelect/index.d.ts +3 -0
  101. package/dist/inputs/FetchSelect/index.js +121 -0
  102. package/dist/inputs/FetchSelect/types.d.ts +33 -0
  103. package/dist/inputs/FetchSelect/types.js +1 -0
  104. package/dist/inputs/FetchSelect/utils.d.ts +21 -0
  105. package/dist/inputs/FetchSelect/utils.js +67 -0
  106. package/dist/inputs/FileUploader/index.d.ts +22 -0
  107. package/dist/inputs/FileUploader/index.js +79 -0
  108. package/dist/inputs/IconSelect/index.d.ts +89 -0
  109. package/dist/inputs/IconSelect/index.js +54 -0
  110. package/dist/inputs/ImageUploader/index.d.ts +12 -0
  111. package/dist/inputs/ImageUploader/index.js +192 -0
  112. package/dist/inputs/RadioButton/index.d.ts +15 -0
  113. package/dist/inputs/RadioButton/index.js +11 -0
  114. package/dist/inputs/RangeInput/index.d.ts +8 -0
  115. package/dist/inputs/RangeInput/index.js +17 -0
  116. package/dist/inputs/TextInput/index.d.ts +6 -0
  117. package/dist/inputs/TextInput/index.js +30 -0
  118. package/dist/inputs/index.d.ts +9 -0
  119. package/dist/inputs/index.js +9 -0
  120. package/dist/layout/DragSort/index.d.ts +16 -0
  121. package/dist/layout/DragSort/index.js +12 -0
  122. package/dist/layout/FoldCard/index.d.ts +9 -0
  123. package/dist/layout/FoldCard/index.js +69 -0
  124. package/dist/layout/PageBase/index.d.ts +6 -0
  125. package/dist/layout/PageBase/index.js +6 -0
  126. package/dist/layout/ResizableGridLayout/index.d.ts +11 -0
  127. package/dist/layout/ResizableGridLayout/index.js +13 -0
  128. package/dist/layout/SideMenu/index.d.ts +27 -0
  129. package/dist/layout/SideMenu/index.js +40 -0
  130. package/dist/layout/TabsPro/index.d.ts +9 -0
  131. package/dist/layout/TabsPro/index.js +87 -0
  132. package/dist/layout/index.d.ts +6 -0
  133. package/dist/layout/index.js +6 -0
  134. package/dist/web.d.ts +6 -0
  135. package/dist/web.js +6 -0
  136. package/package.json +28 -11
  137. package/src/antd/form/CheckboxButton/index.module.scss +0 -24
  138. package/src/antd/form/CheckboxButton/index.tsx +0 -31
  139. package/src/antd/form/FileUploader/index.tsx +0 -163
  140. package/src/antd/form/RadioButton/index.tsx +0 -32
  141. package/src/antd/form/Upload/index.tsx +0 -65
  142. package/src/antd/form/UploadImage/index.tsx +0 -338
  143. package/src/antd/form/index.ts +0 -6
  144. package/src/antd/index.ts +0 -46
  145. package/src/antd/pro/FoldCard/index.tsx +0 -131
  146. package/src/antd/pro/RangeInput/index.tsx +0 -46
  147. package/src/antd/pro/Tabs/index.tsx +0 -135
  148. package/src/antd/pro/Typography/components/String.tsx +0 -72
  149. package/src/antd/pro/Typography/index.tsx +0 -9
  150. package/src/antd/pro/buttons/ButtonGroup.tsx +0 -26
  151. package/src/antd/pro/buttons/ConfirmButton.tsx +0 -24
  152. package/src/antd/pro/buttons/CopyButton.tsx +0 -47
  153. package/src/antd/pro/buttons/DrawerButton.tsx +0 -37
  154. package/src/antd/pro/buttons/index.tsx +0 -4
  155. package/src/antd/pro/index.ts +0 -5
  156. package/src/components/BottomBar/index.tsx +0 -28
  157. package/src/components/CodeView/index.tsx +0 -85
  158. package/src/components/Collapse/index.tsx +0 -26
  159. package/src/components/Com2Canvas/index.tsx +0 -60
  160. package/src/components/CompileHtml/index.tsx +0 -26
  161. package/src/components/Crud/components/CardList/index.tsx +0 -174
  162. package/src/components/Crud/components/CreateUpdate/index.tsx +0 -179
  163. package/src/components/Crud/components/Provider/index.tsx +0 -83
  164. package/src/components/Crud/components/Remove/index.tsx +0 -56
  165. package/src/components/Crud/components/index.ts +0 -4
  166. package/src/components/Crud/hooks/index.ts +0 -4
  167. package/src/components/Crud/hooks/useColumns.tsx +0 -169
  168. package/src/components/Crud/hooks/useList.ts +0 -65
  169. package/src/components/Crud/hooks/useOrderable.tsx +0 -107
  170. package/src/components/Crud/hooks/useRequest.ts +0 -41
  171. package/src/components/Crud/index.tsx +0 -91
  172. package/src/components/Crud/types/index.ts +0 -188
  173. package/src/components/Crud/utils/index.ts +0 -87
  174. package/src/components/DateSwitcher/index.module.scss +0 -10
  175. package/src/components/DateSwitcher/index.tsx +0 -75
  176. package/src/components/DownloadLink/index.tsx +0 -36
  177. package/src/components/DragSort/index.tsx +0 -77
  178. package/src/components/DynamicSelect/index.tsx +0 -76
  179. package/src/components/DynamicSelect/types.ts +0 -8
  180. package/src/components/DynamicSelect/utils.ts +0 -47
  181. package/src/components/EnumTag/index.tsx +0 -24
  182. package/src/components/FetchSelect/index.tsx +0 -57
  183. package/src/components/FormPro/index.tsx +0 -28
  184. package/src/components/GroupLayout/index.tsx +0 -45
  185. package/src/components/HtmlPro/index.tsx +0 -18
  186. package/src/components/IframePro/index.tsx +0 -52
  187. package/src/components/JsonRenderer/index.tsx +0 -114
  188. package/src/components/JsonView/index.tsx +0 -21
  189. package/src/components/Markdown/index.tsx +0 -152
  190. package/src/components/MindMap/context.tsx +0 -29
  191. package/src/components/MindMap/hooks/useAlignmentSnap.ts +0 -220
  192. package/src/components/MindMap/hooks/useCopyPaste.ts +0 -272
  193. package/src/components/MindMap/hooks/useDropToReparent.ts +0 -288
  194. package/src/components/MindMap/hooks/useExpandCollapse.ts +0 -146
  195. package/src/components/MindMap/hooks/useMoveDescendants.ts +0 -136
  196. package/src/components/MindMap/hooks/useUndoRedo.ts +0 -232
  197. package/src/components/MindMap/index.tsx +0 -117
  198. package/src/components/MultiImageDisplay/index.tsx +0 -63
  199. package/src/components/ProgressButton/index.module.scss +0 -65
  200. package/src/components/ProgressButton/index.tsx +0 -96
  201. package/src/components/SectorButton/index.tsx +0 -247
  202. package/src/components/TextInput/index.tsx +0 -61
  203. package/src/components/TimelineBar/components/CurrentWeekHighlight/index.tsx +0 -64
  204. package/src/components/TimelineBar/components/Guides/index.tsx +0 -61
  205. package/src/components/TimelineBar/components/Ticks/index.tsx +0 -56
  206. package/src/components/TimelineBar/components/TodayIndicator/index.tsx +0 -54
  207. package/src/components/TimelineBar/components/index.ts +0 -4
  208. package/src/components/TimelineBar/const.ts +0 -3
  209. package/src/components/TimelineBar/hooks/index.ts +0 -5
  210. package/src/components/TimelineBar/hooks/useHighlightRange.ts +0 -21
  211. package/src/components/TimelineBar/hooks/useMonthGuides.ts +0 -40
  212. package/src/components/TimelineBar/hooks/useTickValues.ts +0 -18
  213. package/src/components/TimelineBar/hooks/useVisibleRange.ts +0 -43
  214. package/src/components/TimelineBar/hooks/useWeekGuides.ts +0 -39
  215. package/src/components/TimelineBar/index.tsx +0 -63
  216. package/src/components/TimelineBar/utils.ts +0 -27
  217. package/src/components/Video/index.tsx +0 -37
  218. package/src/components/index.ts +0 -26
  219. package/src/rn.ts +0 -1
  220. package/src/rns/index.ts +0 -0
  221. package/src/web.ts +0 -2
@@ -0,0 +1 @@
1
+ export declare const style = "\n code {\n color: #c7254e;\n background-color: #f9f2f4;\n border-radius: 4px;\n }\n\n /* \u76EE\u5F55\u5BB9\u5668\u6837\u5F0F */\n .markdown-toc .markdown-body {\n position: relative;\n }\n\n /* \u951A\u70B9\u94FE\u63A5\u6837\u5F0F */\n .markdown-toc .anchor {\n text-decoration: none !important;\n color: inherit !important;\n display: contents !important;\n }\n\n .markdown-toc .anchor:hover {\n text-decoration: underline !important;\n }\n\n /* \u6807\u9898\u60AC\u6D6E\u6548\u679C */\n .markdown-toc h1:hover .anchor::after,\n .markdown-toc h2:hover .anchor::after,\n .markdown-toc h3:hover .anchor::after,\n .markdown-toc h4:hover .anchor::after,\n .markdown-toc h5:hover .anchor::after,\n .markdown-toc h6:hover .anchor::after {\n content: \" \uD83D\uDD17\";\n opacity: 0.6;\n font-size: 0.8em;\n }\n\n /* \u76EE\u5F55\u6807\u9898\u6837\u5F0F */\n // .markdown-toc h2:first-of-type {\n // display: block !important;\n // color: #24292f !important;\n // font-size: 18px !important;\n // font-weight: 600 !important;\n // line-height: 1.4 !important;\n // border-bottom: 1px solid #d1d9e0 !important;\n // padding-bottom: 8px !important;\n // margin: 0 0 16px 0 !important;\n // }\n\n /* \u76EE\u5F55\u4E13\u7528\u6837\u5F0F - \u53EA\u5BF9\u7B2C\u4E00\u4E2Ah2\u4E0B\u7684\u5217\u8868\u751F\u6548 */\n .markdown-toc h2:first-of-type + ul {\n background: #f8f9fa !important;\n border: 1px solid #e1e4e8 !important;\n border-radius: 6px !important;\n padding: 16px !important;\n margin: 16px 0 24px 0 !important;\n list-style: none !important;\n }\n\n .markdown-toc h2:first-of-type + ul li {\n margin: 8px 0 !important;\n padding-left: 0 !important;\n list-style: none !important;\n }\n\n .markdown-toc h2:first-of-type + ul li::before {\n content: \"\uD83D\uDCD6 \" !important;\n margin-right: 8px !important;\n }\n\n .markdown-toc h2:first-of-type + ul li ul {\n margin: 4px 0 0 0 !important;\n padding-left: 20px !important;\n list-style: none !important;\n }\n\n .markdown-toc h2:first-of-type + ul li ul li {\n margin: 4px 0 !important;\n padding-left: 0 !important;\n }\n\n .markdown-toc h2:first-of-type + ul li ul li::before {\n content: \"\u25B8 \" !important;\n margin-right: 6px !important;\n color: #666 !important;\n }\n\n .markdown-toc h2:first-of-type + ul li ul li ul {\n padding-left: 16px !important;\n }\n\n .markdown-toc h2:first-of-type + ul li ul li ul li::before {\n content: \"\u25E6 \" !important;\n color: #999 !important;\n }\n\n /* \u76EE\u5F55\u94FE\u63A5\u6837\u5F0F */\n .markdown-toc h2:first-of-type + ul a {\n color: #0969da !important;\n text-decoration: none !important;\n font-weight: 500 !important;\n }\n\n .markdown-toc h2:first-of-type + ul a:hover {\n text-decoration: underline !important;\n color: #0550ae !important;\n }\n";
@@ -103,4 +103,4 @@ export const style = `
103
103
  text-decoration: underline !important;
104
104
  color: #0550ae !important;
105
105
  }
106
- `
106
+ `;
@@ -0,0 +1,9 @@
1
+ import { CSSProperties } from 'react';
2
+ interface VideoProProps {
3
+ url: string;
4
+ width?: number;
5
+ height?: number;
6
+ style?: CSSProperties;
7
+ }
8
+ export declare const VideoPro: (props: VideoProProps) => import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useRef } from 'react';
4
+ export const VideoPro = (props) => {
5
+ const { url, width = 175, height = 310, style } = props;
6
+ const videoRef = useRef(null);
7
+ if (!url) {
8
+ return null;
9
+ }
10
+ return (_jsx("video", { ref: videoRef, width: width, height: height, style: style, onMouseEnter: () => {
11
+ videoRef.current?.play();
12
+ }, onMouseLeave: () => {
13
+ videoRef.current?.pause();
14
+ }, children: _jsx("source", { src: url, type: 'video/mp4' }) }));
15
+ };
@@ -0,0 +1,9 @@
1
+ export * from './CodeView';
2
+ export * from './MarkdownView';
3
+ export * from './HtmlView';
4
+ export * from './IframePro';
5
+ export * from './JsonSchemaRenderer';
6
+ export * from './JsonView';
7
+ export * from './EnumTag';
8
+ export * from './VideoPro';
9
+ export * from './HtmlDataRenderer';
@@ -0,0 +1,9 @@
1
+ export * from './CodeView';
2
+ export * from './MarkdownView';
3
+ export * from './HtmlView';
4
+ export * from './IframePro';
5
+ export * from './JsonSchemaRenderer';
6
+ export * from './JsonView';
7
+ export * from './EnumTag';
8
+ export * from './VideoPro';
9
+ export * from './HtmlDataRenderer';
@@ -0,0 +1,22 @@
1
+ .wzy-ui-checkbox-button .ant-pro-checkcard-content {
2
+ padding: 0 !important;
3
+ }
4
+
5
+ .wzy-ui-checkbox-button .ant-pro-checkcard {
6
+ margin-bottom: 0 !important;
7
+ text-align: center !important;
8
+ display: flex;
9
+ justify-content: center;
10
+ border-radius: 0 !important;
11
+ }
12
+
13
+ .wzy-ui-checkbox-button .ant-pro-checkcard-title {
14
+ height: 100%;
15
+ }
16
+
17
+ .wzy-ui-checkbox-button .ant-pro-checkcard div {
18
+ width: 100%;
19
+ font-weight: 400 !important;
20
+ height: 30px !important;
21
+ line-height: 28px !important;
22
+ }
@@ -0,0 +1,12 @@
1
+ import { CheckCardValueType, CheckGroupValueType } from '@ant-design/pro-card/es/components/CheckCard/Group';
2
+ import './index.css';
3
+ interface CheckboxButtonProps {
4
+ options: {
5
+ label: string;
6
+ value: CheckCardValueType;
7
+ }[];
8
+ value?: CheckGroupValueType;
9
+ onChange?: (value: CheckGroupValueType) => void;
10
+ }
11
+ export declare const CheckboxButton: (props: CheckboxButtonProps) => import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Col, Row } from 'antd';
4
+ import { CheckCard } from '@ant-design/pro-components';
5
+ import './index.css';
6
+ export const CheckboxButton = (props) => {
7
+ const { options, value, onChange } = props;
8
+ return (_jsx("div", { className: 'wzy-ui-checkbox-button', children: _jsx(CheckCard.Group, { style: { width: '100%' }, size: 'small', multiple: true, value: value, onChange: onChange, children: _jsx(Row, { children: options.map((item, index) => (_jsx(Col, { children: _jsx(CheckCard, { title: item.label, value: item.value, style: { width: 60, height: 30 } }) }, index))) }) }) }));
9
+ };
@@ -0,0 +1,10 @@
1
+ .wzy-ui-date-switcher {
2
+ display: flex;
3
+ align-items: center;
4
+ gap: 0.5rem;
5
+ }
6
+
7
+ .wzy-ui-date-switcher .ant-picker-input input {
8
+ text-align: center !important;
9
+ cursor: pointer;
10
+ }
@@ -0,0 +1,8 @@
1
+ import { type Dayjs } from '@wzyjs/utils/web';
2
+ import './index.css';
3
+ interface DateSwitcherProps {
4
+ value?: Dayjs;
5
+ onChange?: (date: Dayjs) => void;
6
+ }
7
+ export declare const DateSwitcher: (props: DateSwitcherProps) => import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,29 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from 'react';
4
+ import { DatePicker, Button } from 'antd';
5
+ import { LeftOutlined, RightOutlined } from '@ant-design/icons';
6
+ import { dayjs } from '@wzyjs/utils/web';
7
+ import './index.css';
8
+ export const DateSwitcher = (props) => {
9
+ const { value = dayjs(), onChange } = props;
10
+ const [selectedDate, setSelectedDate] = useState(value);
11
+ const handleDateChange = (date) => {
12
+ if (date) {
13
+ setSelectedDate(date);
14
+ onChange?.(date);
15
+ }
16
+ };
17
+ const handlePrevDay = () => {
18
+ const newDate = selectedDate.subtract(1, 'day');
19
+ handleDateChange(newDate);
20
+ };
21
+ const handleNextDay = () => {
22
+ const newDate = selectedDate.add(1, 'day');
23
+ handleDateChange(newDate);
24
+ };
25
+ const isToday = selectedDate.isSame(dayjs(), 'day');
26
+ return (_jsxs("div", { className: 'wzy-ui-date-switcher', children: [_jsx(Button, { type: 'text', icon: _jsx(LeftOutlined, {}), onClick: handlePrevDay, className: 'flex items-center justify-center' }), _jsx(DatePicker, { value: selectedDate, onChange: handleDateChange, allowClear: false, suffixIcon: null, className: 'w-40 text-center cursor-pointer', style: { border: 'none' }, components: {
27
+ input: props => (_jsxs("div", { ...props, className: isToday ? 'text-blue-600' : '', children: [_jsx("span", { children: selectedDate.format('YYYY-MM-DD') }), _jsxs("span", { style: { marginLeft: 5 }, children: ["(\u5468", ['日', '一', '二', '三', '四', '五', '六'][dayjs(selectedDate).day()], ")"] })] })),
28
+ } }), _jsx(Button, { type: 'text', icon: _jsx(RightOutlined, {}), onClick: handleNextDay, className: 'flex items-center justify-center' })] }));
29
+ };
@@ -0,0 +1,3 @@
1
+ import type { FetchSelectProps } from './types';
2
+ export type { FetchSelectProps } from './types';
3
+ export declare const FetchSelect: <TItem extends Record<string, any> = Record<string, any>>(props: FetchSelectProps<TItem>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,121 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect, useMemo } from 'react';
4
+ import { useCacheState, useControllableValue } from '@wzyjs/hooks/web';
5
+ import { Select } from 'antd';
6
+ import { getChangeItem, getChangeOption, getCurrentValue, getOptionMapByValue, getOptions, isOptionValue, } from './utils';
7
+ export const FetchSelect = (props) => {
8
+ const { query, queryInput, fieldNames, optionMap, optionListMap, placeholder = '请选择', allowClear = true, selectFirst = false, clearIfNotInOptions = false, clearWhenOptionsEmpty = false, cacheKey, value, onChange, ...selectProps } = props;
9
+ const isMultipleMode = selectProps.mode === 'multiple' || selectProps.mode === 'tags';
10
+ const [selectedValue, setSelectedValue] = useControllableValue(props, {
11
+ trigger: 'onValueChange',
12
+ defaultValue: value,
13
+ });
14
+ const { data, isLoading } = query.useQuery(queryInput);
15
+ const currentValue = useMemo(() => {
16
+ return getCurrentValue(selectedValue, isMultipleMode);
17
+ }, [isMultipleMode, selectedValue]);
18
+ const { updateValue } = useCacheState(cacheKey, currentValue, val => {
19
+ setSelectedValue(val);
20
+ onChange?.(val, undefined, undefined);
21
+ });
22
+ const labelField = fieldNames?.label ?? 'title';
23
+ const valueField = fieldNames?.value ?? 'id';
24
+ const options = useMemo(() => {
25
+ return getOptions({
26
+ data,
27
+ optionMap,
28
+ optionListMap,
29
+ labelField,
30
+ valueField,
31
+ });
32
+ }, [data, optionMap, optionListMap, labelField, valueField]);
33
+ const optionMapByValue = useMemo(() => {
34
+ return getOptionMapByValue(options);
35
+ }, [options]);
36
+ const emitChange = (nextValue, option) => {
37
+ const changeOption = getChangeOption({
38
+ nextValue,
39
+ option,
40
+ optionMapByValue,
41
+ });
42
+ const changeItem = getChangeItem(changeOption);
43
+ if (Array.isArray(nextValue)) {
44
+ const nextValues = nextValue.filter(isOptionValue);
45
+ if (nextValues.length) {
46
+ updateValue(nextValues);
47
+ }
48
+ else {
49
+ updateValue(undefined);
50
+ }
51
+ onChange?.(nextValue, changeItem, changeOption);
52
+ return;
53
+ }
54
+ if (!isOptionValue(nextValue)) {
55
+ updateValue(undefined);
56
+ onChange?.(nextValue, changeItem, changeOption);
57
+ return;
58
+ }
59
+ updateValue(nextValue);
60
+ onChange?.(nextValue, changeItem, changeOption);
61
+ };
62
+ const handleChange = (nextValue, option) => {
63
+ emitChange(nextValue, option);
64
+ };
65
+ useEffect(() => {
66
+ if (isLoading) {
67
+ return;
68
+ }
69
+ const optionValues = options.map(item => item.value);
70
+ if (isMultipleMode) {
71
+ const selectedValues = Array.isArray(currentValue) ? currentValue : [];
72
+ if (!options.length) {
73
+ if (clearIfNotInOptions && clearWhenOptionsEmpty && selectedValues.length) {
74
+ emitChange([], undefined);
75
+ }
76
+ return;
77
+ }
78
+ if (selectFirst && !selectedValues.length) {
79
+ const firstOption = options[0];
80
+ if (firstOption) {
81
+ emitChange([firstOption.value], [firstOption]);
82
+ }
83
+ return;
84
+ }
85
+ if (clearIfNotInOptions && selectedValues.length) {
86
+ const validValues = selectedValues.filter(valueItem => optionValues.includes(valueItem));
87
+ if (validValues.length !== selectedValues.length) {
88
+ emitChange(validValues, undefined);
89
+ }
90
+ }
91
+ return;
92
+ }
93
+ if (!options.length) {
94
+ if (clearIfNotInOptions && clearWhenOptionsEmpty && currentValue !== undefined) {
95
+ emitChange(undefined, undefined);
96
+ }
97
+ return;
98
+ }
99
+ const singleCurrentValue = Array.isArray(currentValue) ? undefined : currentValue;
100
+ const hasSelected = singleCurrentValue !== undefined && optionValues.includes(singleCurrentValue);
101
+ if (selectFirst && !hasSelected) {
102
+ const firstOption = options[0];
103
+ if (firstOption) {
104
+ emitChange(firstOption.value, firstOption);
105
+ }
106
+ return;
107
+ }
108
+ if (clearIfNotInOptions && singleCurrentValue !== undefined && !hasSelected) {
109
+ emitChange(undefined, undefined);
110
+ }
111
+ }, [
112
+ isLoading,
113
+ options,
114
+ currentValue,
115
+ selectFirst,
116
+ clearIfNotInOptions,
117
+ clearWhenOptionsEmpty,
118
+ isMultipleMode,
119
+ ]);
120
+ return (_jsx(Select, { styles: { root: { width: '100%' } }, value: selectedValue, onChange: handleChange, placeholder: placeholder, allowClear: allowClear, loading: isLoading, options: options, showSearch: { optionFilterProp: 'label' }, ...selectProps }));
121
+ };
@@ -0,0 +1,33 @@
1
+ import type { SelectProps } from 'antd';
2
+ import type { ReactNode } from 'react';
3
+ export type QueryLike<TItem = any> = {
4
+ useQuery: (...args: any[]) => {
5
+ data?: TItem[];
6
+ isLoading: boolean;
7
+ };
8
+ };
9
+ export type SelectOnChange = NonNullable<SelectProps['onChange']>;
10
+ export type SelectChangeValue = Parameters<SelectOnChange>[0];
11
+ export type SelectChangeOption = Parameters<SelectOnChange>[1];
12
+ export type FetchSelectOption = {
13
+ label: ReactNode;
14
+ value: string | number;
15
+ } & Record<string, unknown>;
16
+ export type OptionValue = string | number;
17
+ export type FetchSelectChangeOption = FetchSelectOption | FetchSelectOption[] | undefined;
18
+ export type FetchSelectChangeItem<TItem> = TItem | undefined;
19
+ export interface FetchSelectProps<TItem extends Record<string, any> = Record<string, any>> extends Omit<SelectProps, 'options' | 'loading' | 'onChange'> {
20
+ query: QueryLike<TItem>;
21
+ queryInput?: Record<string, any>;
22
+ fieldNames?: {
23
+ label: keyof TItem & string;
24
+ value: keyof TItem & string;
25
+ };
26
+ optionMap?: (item: TItem) => FetchSelectOption;
27
+ optionListMap?: (item: TItem) => FetchSelectOption[];
28
+ selectFirst?: boolean;
29
+ clearIfNotInOptions?: boolean;
30
+ clearWhenOptionsEmpty?: boolean;
31
+ cacheKey?: string;
32
+ onChange?: (value: SelectChangeValue, item: FetchSelectChangeItem<TItem>, option: FetchSelectChangeOption) => void;
33
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { FetchSelectChangeItem, FetchSelectChangeOption, FetchSelectOption, OptionValue, SelectChangeOption, SelectChangeValue } from './types';
2
+ export declare const isOptionValue: (value: unknown) => value is OptionValue;
3
+ export declare const getCurrentValue: (value: unknown, isMultipleMode: boolean) => OptionValue | OptionValue[] | undefined;
4
+ export declare const getOptions: <TItem extends Record<string, any>>(params: {
5
+ data?: TItem[];
6
+ optionMap?: (item: TItem) => FetchSelectOption;
7
+ optionListMap?: (item: TItem) => FetchSelectOption[];
8
+ labelField: keyof TItem & string;
9
+ valueField: keyof TItem & string;
10
+ }) => FetchSelectOption[] | {
11
+ label: TItem[keyof TItem & string];
12
+ value: TItem[keyof TItem & string];
13
+ item: TItem;
14
+ }[];
15
+ export declare const getOptionMapByValue: (options: FetchSelectOption[]) => Map<OptionValue, FetchSelectOption>;
16
+ export declare const getChangeOption: (params: {
17
+ nextValue: SelectChangeValue;
18
+ option: SelectChangeOption;
19
+ optionMapByValue: Map<OptionValue, FetchSelectOption>;
20
+ }) => FetchSelectChangeOption;
21
+ export declare const getChangeItem: <TItem>(changeOption: FetchSelectChangeOption) => FetchSelectChangeItem<TItem>;
@@ -0,0 +1,67 @@
1
+ import { _ } from '@wzyjs/utils/web';
2
+ export const isOptionValue = (value) => {
3
+ return typeof value === 'string' || typeof value === 'number';
4
+ };
5
+ export const getCurrentValue = (value, isMultipleMode) => {
6
+ if (isMultipleMode) {
7
+ if (!Array.isArray(value)) {
8
+ return undefined;
9
+ }
10
+ return value.filter(isOptionValue);
11
+ }
12
+ if (isOptionValue(value)) {
13
+ return value;
14
+ }
15
+ return undefined;
16
+ };
17
+ export const getOptions = (params) => {
18
+ const { data, optionMap, optionListMap, labelField, valueField } = params;
19
+ if (!data) {
20
+ return [];
21
+ }
22
+ if (optionListMap) {
23
+ return data.flatMap(optionListMap);
24
+ }
25
+ if (optionMap) {
26
+ return data.map(optionMap);
27
+ }
28
+ return data.map(item => ({
29
+ label: _.get(item, labelField),
30
+ value: _.get(item, valueField),
31
+ item,
32
+ }));
33
+ };
34
+ export const getOptionMapByValue = (options) => {
35
+ return new Map(options.map(item => [item.value, item]));
36
+ };
37
+ export const getChangeOption = (params) => {
38
+ const { nextValue, option, optionMapByValue } = params;
39
+ if (Array.isArray(nextValue)) {
40
+ const mappedOptions = nextValue
41
+ .filter(isOptionValue)
42
+ .map(valueItem => optionMapByValue.get(valueItem))
43
+ .filter(Boolean);
44
+ return mappedOptions.length ? mappedOptions : undefined;
45
+ }
46
+ if (isOptionValue(nextValue)) {
47
+ return optionMapByValue.get(nextValue);
48
+ }
49
+ const currentOption = Array.isArray(option) ? option[0] : option;
50
+ if (!currentOption) {
51
+ return undefined;
52
+ }
53
+ return currentOption;
54
+ };
55
+ export const getChangeItem = (changeOption) => {
56
+ if (Array.isArray(changeOption)) {
57
+ const firstOption = changeOption[0];
58
+ if (!firstOption) {
59
+ return undefined;
60
+ }
61
+ return firstOption.item;
62
+ }
63
+ if (!changeOption) {
64
+ return undefined;
65
+ }
66
+ return changeOption.item;
67
+ };
@@ -0,0 +1,22 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { UploadProps, UploadFile as AntUploadFile } from 'antd';
3
+ export interface FileUploaderProps {
4
+ value?: AntUploadFile[];
5
+ onChange?: (fileList: AntUploadFile[]) => void;
6
+ mode?: 'file' | 'http';
7
+ accept?: string;
8
+ multiple?: boolean;
9
+ maxCount?: number;
10
+ trigger?: 'button' | 'dragger' | ReactElement;
11
+ listType?: UploadProps['listType'];
12
+ beforeUpload?: (file: AntUploadFile) => boolean | Promise<void>;
13
+ immediateUpload?: boolean;
14
+ action?: string;
15
+ data?: Record<string, unknown> | ((file: AntUploadFile) => Record<string, unknown>);
16
+ headers?: UploadProps['headers'];
17
+ withCredentials?: boolean;
18
+ disabled?: boolean;
19
+ showUploadList?: boolean;
20
+ onUploadChange?: UploadProps['onChange'];
21
+ }
22
+ export declare const FileUploader: (props: FileUploaderProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,79 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from 'react';
4
+ import { Upload, Button, } from 'antd';
5
+ import { UploadOutlined, InboxOutlined } from '@ant-design/icons';
6
+ export const FileUploader = (props) => {
7
+ const { value, onChange, mode = 'file', accept, multiple = true, maxCount, trigger = 'dragger', listType = 'text', beforeUpload, immediateUpload = false, action = '/api/file/upload', data, headers, withCredentials, disabled, showUploadList = trigger === 'dragger', onUploadChange, } = props;
8
+ const [internalFileList, setInternalFileList] = useState([]);
9
+ const fileList = value || internalFileList;
10
+ const handleChange = (info) => {
11
+ let newFileList = [...info.fileList];
12
+ // 限制数量
13
+ if (maxCount && newFileList.length > maxCount) {
14
+ newFileList = newFileList.slice(-maxCount);
15
+ }
16
+ // 如果不是立即上传模式,我们需要手动管理状态
17
+ if (!immediateUpload) {
18
+ // 这里的逻辑主要依赖 beforeUpload 返回 false 来阻止上传
19
+ // 但 onChange 依然会被触发
20
+ }
21
+ // 更新状态
22
+ if (!value) {
23
+ setInternalFileList(newFileList);
24
+ }
25
+ // 通知外部
26
+ onChange?.(newFileList);
27
+ onUploadChange?.(info);
28
+ };
29
+ const handleBeforeUpload = async (file) => {
30
+ // 1. 外部校验
31
+ if (beforeUpload) {
32
+ const result = await beforeUpload(file);
33
+ if (result === false) {
34
+ return Upload.LIST_IGNORE;
35
+ }
36
+ }
37
+ // 2. 立即上传模式
38
+ if (immediateUpload) {
39
+ return true;
40
+ }
41
+ // 3. 非立即上传模式,阻止默认上传行为,但添加到列表
42
+ return false;
43
+ };
44
+ const uploadProps = {
45
+ fileList,
46
+ accept,
47
+ multiple,
48
+ maxCount,
49
+ listType,
50
+ disabled,
51
+ showUploadList,
52
+ beforeUpload: handleBeforeUpload,
53
+ onChange: handleChange,
54
+ onDrop: (e) => {
55
+ // console.log('Dropped files', e.dataTransfer.files)
56
+ },
57
+ };
58
+ // 立即上传相关配置
59
+ if (immediateUpload) {
60
+ uploadProps.action = action;
61
+ uploadProps.data = data;
62
+ uploadProps.headers = headers;
63
+ uploadProps.withCredentials = withCredentials;
64
+ }
65
+ else {
66
+ // 非立即上传模式,不需要 action
67
+ uploadProps.customRequest = () => undefined; // 覆盖默认上传行为,防止自动上传尝试
68
+ }
69
+ if (mode === 'http') {
70
+ return _jsx("div", { children: "HTTP \u8F93\u5165\u6A21\u5F0F\u6682\u672A\u652F\u6301" });
71
+ }
72
+ if (trigger === 'button') {
73
+ return (_jsx(Upload, { ...uploadProps, children: _jsx(Button, { type: "primary", icon: _jsx(UploadOutlined, {}), children: "\u4E0A\u4F20\u6587\u4EF6" }) }));
74
+ }
75
+ if (trigger === 'dragger') {
76
+ return (_jsxs(Upload.Dragger, { ...uploadProps, children: [_jsx("p", { className: "ant-upload-drag-icon", children: _jsx(InboxOutlined, {}) }), _jsx("p", { className: "ant-upload-text", children: "\u70B9\u51FB\u6216\u62D6\u62FD\u6587\u4EF6\u5230\u6B64\u533A\u57DF\u4E0A\u4F20" }), _jsxs("p", { className: "ant-upload-hint", children: ["\u652F\u6301\u5355\u4E2A\u6216\u6279\u91CF\u4E0A\u4F20", maxCount ? `,最多 ${maxCount} 个文件` : ''] })] }));
77
+ }
78
+ return trigger;
79
+ };
@@ -0,0 +1,89 @@
1
+ import type { ReactElement, ReactNode } from 'react';
2
+ export declare const iconSelectOptions: readonly [{
3
+ readonly value: "home";
4
+ readonly label: "Home";
5
+ readonly icon: import("react/jsx-runtime").JSX.Element;
6
+ }, {
7
+ readonly value: "calendar";
8
+ readonly label: "Calendar";
9
+ readonly icon: import("react/jsx-runtime").JSX.Element;
10
+ }, {
11
+ readonly value: "appstore";
12
+ readonly label: "Appstore";
13
+ readonly icon: import("react/jsx-runtime").JSX.Element;
14
+ }, {
15
+ readonly value: "fileText";
16
+ readonly label: "FileText";
17
+ readonly icon: import("react/jsx-runtime").JSX.Element;
18
+ }, {
19
+ readonly value: "bulb";
20
+ readonly label: "Bulb";
21
+ readonly icon: import("react/jsx-runtime").JSX.Element;
22
+ }, {
23
+ readonly value: "user";
24
+ readonly label: "User";
25
+ readonly icon: import("react/jsx-runtime").JSX.Element;
26
+ }, {
27
+ readonly value: "shopping";
28
+ readonly label: "Shopping";
29
+ readonly icon: import("react/jsx-runtime").JSX.Element;
30
+ }, {
31
+ readonly value: "book";
32
+ readonly label: "Book";
33
+ readonly icon: import("react/jsx-runtime").JSX.Element;
34
+ }, {
35
+ readonly value: "database";
36
+ readonly label: "Database";
37
+ readonly icon: import("react/jsx-runtime").JSX.Element;
38
+ }, {
39
+ readonly value: "apartment";
40
+ readonly label: "Apartment";
41
+ readonly icon: import("react/jsx-runtime").JSX.Element;
42
+ }, {
43
+ readonly value: "folderAdd";
44
+ readonly label: "FolderAdd";
45
+ readonly icon: import("react/jsx-runtime").JSX.Element;
46
+ }, {
47
+ readonly value: "send";
48
+ readonly label: "Send";
49
+ readonly icon: import("react/jsx-runtime").JSX.Element;
50
+ }, {
51
+ readonly value: "plus";
52
+ readonly label: "Plus";
53
+ readonly icon: import("react/jsx-runtime").JSX.Element;
54
+ }, {
55
+ readonly value: "minus";
56
+ readonly label: "Minus";
57
+ readonly icon: import("react/jsx-runtime").JSX.Element;
58
+ }, {
59
+ readonly value: "eye";
60
+ readonly label: "Eye";
61
+ readonly icon: import("react/jsx-runtime").JSX.Element;
62
+ }, {
63
+ readonly value: "edit";
64
+ readonly label: "Edit";
65
+ readonly icon: import("react/jsx-runtime").JSX.Element;
66
+ }, {
67
+ readonly value: "delete";
68
+ readonly label: "Delete";
69
+ readonly icon: import("react/jsx-runtime").JSX.Element;
70
+ }, {
71
+ readonly value: "star";
72
+ readonly label: "Star";
73
+ readonly icon: import("react/jsx-runtime").JSX.Element;
74
+ }, {
75
+ readonly value: "down";
76
+ readonly label: "Down";
77
+ readonly icon: import("react/jsx-runtime").JSX.Element;
78
+ }, {
79
+ readonly value: "question";
80
+ readonly label: "Question";
81
+ readonly icon: import("react/jsx-runtime").JSX.Element;
82
+ }];
83
+ export type IconSelectKey = (typeof iconSelectOptions)[number]['value'];
84
+ export declare const getIconNode: (value?: string | null) => ReactNode | null;
85
+ export interface IconSelectProps {
86
+ value?: unknown;
87
+ onChange?: (value: unknown) => void;
88
+ }
89
+ export declare const IconSelect: (props: IconSelectProps) => ReactElement;