@wzyjs/uis 0.3.28 → 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 (230) 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 -12
  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/Alert/index.tsx +0 -24
  146. package/src/antd/pro/Button/components/Confirm.tsx +0 -24
  147. package/src/antd/pro/Button/components/Copy.tsx +0 -47
  148. package/src/antd/pro/Button/components/Drawer.tsx +0 -37
  149. package/src/antd/pro/Button/components/Group.tsx +0 -26
  150. package/src/antd/pro/Button/index.tsx +0 -11
  151. package/src/antd/pro/Card/index.tsx +0 -92
  152. package/src/antd/pro/Collapse/components/Item.tsx +0 -30
  153. package/src/antd/pro/Collapse/index.tsx +0 -27
  154. package/src/antd/pro/Image/index.tsx +0 -17
  155. package/src/antd/pro/Input/components/Range.tsx +0 -46
  156. package/src/antd/pro/Input/index.tsx +0 -61
  157. package/src/antd/pro/Popconfirm/index.tsx +0 -16
  158. package/src/antd/pro/Radio/components/Cancel.tsx +0 -30
  159. package/src/antd/pro/Radio/index.tsx +0 -7
  160. package/src/antd/pro/Space/index.tsx +0 -15
  161. package/src/antd/pro/Tabs/index.tsx +0 -135
  162. package/src/antd/pro/Typography/components/String.tsx +0 -72
  163. package/src/antd/pro/Typography/index.tsx +0 -9
  164. package/src/antd/pro/index.ts +0 -11
  165. package/src/components/BottomBar/index.tsx +0 -28
  166. package/src/components/CodeView/index.tsx +0 -85
  167. package/src/components/Collapse/index.tsx +0 -26
  168. package/src/components/Com2Canvas/index.tsx +0 -60
  169. package/src/components/CompileHtml/index.tsx +0 -26
  170. package/src/components/Crud/components/CardList/index.tsx +0 -174
  171. package/src/components/Crud/components/CreateUpdate/index.tsx +0 -179
  172. package/src/components/Crud/components/Provider/index.tsx +0 -83
  173. package/src/components/Crud/components/Remove/index.tsx +0 -56
  174. package/src/components/Crud/components/index.ts +0 -4
  175. package/src/components/Crud/hooks/index.ts +0 -4
  176. package/src/components/Crud/hooks/useColumns.tsx +0 -169
  177. package/src/components/Crud/hooks/useList.ts +0 -65
  178. package/src/components/Crud/hooks/useOrderable.tsx +0 -107
  179. package/src/components/Crud/hooks/useRequest.ts +0 -41
  180. package/src/components/Crud/index.tsx +0 -91
  181. package/src/components/Crud/types/index.ts +0 -188
  182. package/src/components/Crud/utils/index.ts +0 -87
  183. package/src/components/DateSwitcher/index.module.scss +0 -10
  184. package/src/components/DateSwitcher/index.tsx +0 -75
  185. package/src/components/DownloadLink/index.tsx +0 -36
  186. package/src/components/DragSort/index.tsx +0 -77
  187. package/src/components/DynamicSelect/index.tsx +0 -74
  188. package/src/components/DynamicSelect/utils.ts +0 -45
  189. package/src/components/EnumTag/index.tsx +0 -24
  190. package/src/components/FetchSelect/index.tsx +0 -57
  191. package/src/components/Fold/index.tsx +0 -52
  192. package/src/components/FormPro/index.tsx +0 -28
  193. package/src/components/GroupLayout/index.tsx +0 -45
  194. package/src/components/HtmlPro/index.tsx +0 -18
  195. package/src/components/IframePro/index.tsx +0 -52
  196. package/src/components/JsonRenderer/index.tsx +0 -114
  197. package/src/components/JsonView/index.tsx +0 -21
  198. package/src/components/Markdown/index.tsx +0 -152
  199. package/src/components/MindMap/context.tsx +0 -29
  200. package/src/components/MindMap/hooks/useAlignmentSnap.ts +0 -220
  201. package/src/components/MindMap/hooks/useCopyPaste.ts +0 -272
  202. package/src/components/MindMap/hooks/useDropToReparent.ts +0 -288
  203. package/src/components/MindMap/hooks/useExpandCollapse.ts +0 -146
  204. package/src/components/MindMap/hooks/useMoveDescendants.ts +0 -136
  205. package/src/components/MindMap/hooks/useUndoRedo.ts +0 -232
  206. package/src/components/MindMap/index.tsx +0 -117
  207. package/src/components/MultiImageDisplay/index.tsx +0 -63
  208. package/src/components/ProgressButton/index.module.scss +0 -65
  209. package/src/components/ProgressButton/index.tsx +0 -96
  210. package/src/components/SectorButton/index.tsx +0 -247
  211. package/src/components/TextInput/index.tsx +0 -61
  212. package/src/components/TimelineBar/components/CurrentWeekHighlight/index.tsx +0 -64
  213. package/src/components/TimelineBar/components/Guides/index.tsx +0 -61
  214. package/src/components/TimelineBar/components/Ticks/index.tsx +0 -56
  215. package/src/components/TimelineBar/components/TodayIndicator/index.tsx +0 -54
  216. package/src/components/TimelineBar/components/index.ts +0 -4
  217. package/src/components/TimelineBar/const.ts +0 -3
  218. package/src/components/TimelineBar/hooks/index.ts +0 -5
  219. package/src/components/TimelineBar/hooks/useHighlightRange.ts +0 -21
  220. package/src/components/TimelineBar/hooks/useMonthGuides.ts +0 -40
  221. package/src/components/TimelineBar/hooks/useTickValues.ts +0 -18
  222. package/src/components/TimelineBar/hooks/useVisibleRange.ts +0 -43
  223. package/src/components/TimelineBar/hooks/useWeekGuides.ts +0 -39
  224. package/src/components/TimelineBar/index.tsx +0 -63
  225. package/src/components/TimelineBar/utils.ts +0 -27
  226. package/src/components/Video/index.tsx +0 -37
  227. package/src/components/index.ts +0 -27
  228. package/src/rn.ts +0 -1
  229. package/src/rns/index.ts +0 -0
  230. package/src/web.ts +0 -2
@@ -1,27 +0,0 @@
1
- 'use client'
2
-
3
- import React from 'react'
4
- import { Collapse, CollapseProps } from 'antd'
5
- import { Item, CollapseItemProps } from './components/Item'
6
-
7
- export interface CollapseProProps extends CollapseProps {
8
- list?: CollapseItemProps[],
9
- step?: boolean; // 为true自动给标题添加 `第{index}步:`
10
- space?: boolean; // 子元素是否有间距
11
- }
12
-
13
- export const CollapsePro = (props: CollapseProProps) => {
14
- const { list = [], step = false, space = true, accordion = true } = props
15
-
16
- if (!props.children && list.length) {
17
- props.children = list.map((item, index) => (
18
- <Item key={index} step={step} space={space} index={index + 1} {...item} />
19
- ))
20
- }
21
-
22
- return (
23
- <Collapse accordion={accordion} {...props} />
24
- )
25
- }
26
-
27
- CollapsePro.Pane = Item
@@ -1,17 +0,0 @@
1
- 'use client'
2
-
3
- import React from 'react'
4
- import { Image, ImageProps } from 'antd'
5
-
6
- export type ImageProProps = ImageProps
7
-
8
- export const ImagePro = (props: ImageProProps) => {
9
- const { preview = false } = props
10
-
11
- return (
12
- <Image
13
- {...props}
14
- preview={preview}
15
- />
16
- )
17
- }
@@ -1,46 +0,0 @@
1
- 'use client'
2
-
3
- import React from 'react'
4
- import { InputNumber, InputNumberProps, Space } from 'antd'
5
- import { _ } from '@wzyjs/utils/web'
6
-
7
- export interface RangeProps extends Omit<InputNumberProps, 'value' | 'onChange'> {
8
- value?: number[];
9
- min?: number;
10
- max?: number;
11
- onChange?: (numbers: number[]) => void;
12
- }
13
-
14
- // 最小值 最大值 的输入框
15
- export const Range = (props: RangeProps) => {
16
- const { value = [], min, max, onChange } = props
17
-
18
- const onNumberChange = (index: 0 | 1, v: number | null) => {
19
- if (Number.isNaN(v) || v === null) {
20
- return
21
- }
22
-
23
- const numbers = _.cloneDeep(value) || []
24
- numbers[index] = v
25
-
26
- onChange?.(numbers)
27
- }
28
-
29
- return (
30
- <Space>
31
- <InputNumber
32
- min={min}
33
- max={max}
34
- value={value[0]}
35
- onChange={(v: number | null) => onNumberChange(0, v)}
36
- />
37
- <span style={{ margin: '0 3px' }}> - </span>
38
- <InputNumber
39
- min={min}
40
- max={max}
41
- value={value[1]}
42
- onChange={(v: number | null) => onNumberChange(1, v)}
43
- />
44
- </Space>
45
- )
46
- }
@@ -1,61 +0,0 @@
1
- 'use client'
2
-
3
- import React, { useState, useEffect, useMemo } from 'react'
4
- import { Input, InputProps } from 'antd'
5
- import { getStrLength } from '@wzyjs/utils/web'
6
- import { Range } from './components/Range'
7
-
8
- export interface InputProProps extends Omit<InputProps, 'onChange'> {
9
- maxLengthChinese?: boolean; // 限制长度:中文算2个字符
10
- onChange?: (value: string) => void
11
- }
12
-
13
- // 1. 增加对中文字符串的长度限制 (Input的maxLength会认为汉字为1个长度)
14
- export const InputPro = (props: InputProProps) => {
15
- const {
16
- value: _value,
17
- onChange: _onChange,
18
- addonAfter: _addonAfter,
19
- maxLength,
20
- maxLengthChinese,
21
- ...rest
22
- } = props
23
-
24
- const [value, setValue] = useState<string>('')
25
-
26
- const addonAfter = useMemo(() => {
27
- if (!maxLengthChinese) {
28
- return _addonAfter
29
- }
30
-
31
- return (
32
- <>
33
- {_addonAfter}
34
- {maxLength ? `${getStrLength(value)} / ${maxLength}` : null}
35
- </>
36
- )
37
- }, [_addonAfter, value, maxLength])
38
-
39
- useEffect(() => {
40
- _onChange?.(value)
41
- }, [value])
42
-
43
- const onChange = (ev: React.ChangeEvent<HTMLInputElement>) => {
44
- if (maxLengthChinese && maxLength && getStrLength(ev.target.value) > maxLength) {
45
- return
46
- }
47
- setValue(ev.target.value)
48
- }
49
-
50
- return (
51
- <Input
52
- value={value}
53
- onChange={onChange}
54
- addonAfter={addonAfter}
55
- maxLength={maxLength}
56
- {...rest}
57
- />
58
- )
59
- }
60
-
61
- InputPro.Range = Range
@@ -1,16 +0,0 @@
1
- 'use client'
2
-
3
- import React from 'react'
4
- import { Popconfirm, PopconfirmProps } from 'antd'
5
-
6
- export type PopconfirmProProps = PopconfirmProps
7
-
8
- export const PopconfirmPro = (props: PopconfirmProProps) => {
9
- return (
10
- <Popconfirm
11
- okText="确定"
12
- cancelText="取消"
13
- {...props}
14
- />
15
- )
16
- }
@@ -1,30 +0,0 @@
1
- 'use client'
2
-
3
- import React from 'react'
4
- import { Checkbox, CheckboxProps, CheckboxOptionType } from 'antd'
5
-
6
- export interface CancelProps {
7
- value: CheckboxProps['value'];
8
- options: CheckboxOptionType[];
9
- onChange?: CheckboxProps['onChange'];
10
- }
11
-
12
- // 给Radio组件增加取消选择的功能,是用Checkbox组件实现的
13
- export const Cancel = (props: CancelProps) => {
14
- const { value, options, onChange } = props
15
-
16
- const evs = {
17
- onChange: (checkedValue: CheckboxProps['value'][]) => {
18
- onChange?.(checkedValue.find(i => i !== value) || '')
19
- },
20
- }
21
-
22
- return (
23
- <Checkbox.Group
24
- value={[value]}
25
- prefixCls='ant-radio'
26
- options={options}
27
- onChange={evs.onChange}
28
- />
29
- )
30
- }
@@ -1,7 +0,0 @@
1
- 'use client'
2
-
3
- import { Cancel } from './components/Cancel'
4
-
5
- export const RadioPro = {
6
- Cancel,
7
- }
@@ -1,15 +0,0 @@
1
- 'use client'
2
-
3
- import React from 'react'
4
- import { Space, SpaceProps } from 'antd'
5
-
6
- export type SpaceProProps = SpaceProps
7
-
8
- export const SpacePro = (props: SpaceProProps) => {
9
- return (
10
- <Space
11
- style={{ width: '100%' }}
12
- {...props}
13
- />
14
- )
15
- }
@@ -1,135 +0,0 @@
1
- 'use client'
2
-
3
- import React from 'react'
4
- import { Tabs, type TabsProps } from 'antd'
5
-
6
- type SyncMode = 'replace' | 'push'
7
-
8
- export interface TabsProProps extends TabsProps {
9
- syncToUrl?: boolean
10
- queryKey?: string
11
- historyMode?: SyncMode
12
- }
13
-
14
- const getItemKeys = (items?: TabsProps['items']): string[] => {
15
- return (items || [])
16
- .map(item => item?.key)
17
- .filter((key): key is string => typeof key === 'string' && !!key)
18
- }
19
-
20
- const getUrlTabKey = (queryKey: string): string | undefined => {
21
- if (typeof window === 'undefined') {
22
- return undefined
23
- }
24
-
25
- const value = new URLSearchParams(window.location.search).get(queryKey)
26
- return value || undefined
27
- }
28
-
29
- const updateUrlTabKey = (queryKey: string, key: string, mode: SyncMode) => {
30
- if (typeof window === 'undefined') {
31
- return
32
- }
33
-
34
- const url = new URL(window.location.href)
35
- url.searchParams.set(queryKey, key)
36
-
37
- const nextUrl = `${url.pathname}${url.search}${url.hash}`
38
- if (mode === 'push') {
39
- window.history.pushState(window.history.state, '', nextUrl)
40
- return
41
- }
42
-
43
- window.history.replaceState(window.history.state, '', nextUrl)
44
- }
45
-
46
- export const TabsPro = (props: TabsProProps) => {
47
- const {
48
- syncToUrl = false,
49
- queryKey = 'tab',
50
- historyMode = 'replace',
51
- activeKey,
52
- defaultActiveKey,
53
- items,
54
- onChange,
55
- ...rest
56
- } = props
57
-
58
- const itemKeys = React.useMemo(() => getItemKeys(items), [items])
59
-
60
- const initialKey = React.useMemo(() => {
61
- const urlKey = syncToUrl ? getUrlTabKey(queryKey) : undefined
62
- if (urlKey && itemKeys.includes(urlKey)) {
63
- return urlKey
64
- }
65
-
66
- if (typeof defaultActiveKey === 'string' && itemKeys.includes(defaultActiveKey)) {
67
- return defaultActiveKey
68
- }
69
-
70
- return itemKeys[0]
71
- }, [defaultActiveKey, itemKeys, queryKey, syncToUrl])
72
-
73
- const [innerActiveKey, setInnerActiveKey] = React.useState<string | undefined>(initialKey)
74
-
75
- const mergedActiveKey = typeof activeKey === 'string' ? activeKey : innerActiveKey
76
-
77
- React.useEffect(() => {
78
- if (typeof activeKey === 'string') {
79
- return
80
- }
81
-
82
- setInnerActiveKey(prev => {
83
- if (prev && itemKeys.includes(prev)) {
84
- return prev
85
- }
86
- return initialKey
87
- })
88
- }, [activeKey, initialKey, itemKeys])
89
-
90
- React.useEffect(() => {
91
- if (!syncToUrl || !mergedActiveKey) {
92
- return
93
- }
94
-
95
- updateUrlTabKey(queryKey, mergedActiveKey, historyMode)
96
- }, [historyMode, mergedActiveKey, queryKey, syncToUrl])
97
-
98
- React.useEffect(() => {
99
- if (!syncToUrl) {
100
- return
101
- }
102
-
103
- const onPopState = () => {
104
- const urlKey = getUrlTabKey(queryKey)
105
- if (!urlKey || !itemKeys.includes(urlKey)) {
106
- return
107
- }
108
-
109
- if (typeof activeKey !== 'string') {
110
- setInnerActiveKey(urlKey)
111
- }
112
-
113
- onChange?.(urlKey)
114
- }
115
-
116
- window.addEventListener('popstate', onPopState)
117
- return () => {
118
- window.removeEventListener('popstate', onPopState)
119
- }
120
- }, [activeKey, itemKeys, onChange, queryKey, syncToUrl])
121
-
122
- return (
123
- <Tabs
124
- {...rest}
125
- items={items}
126
- activeKey={mergedActiveKey}
127
- onChange={key => {
128
- if (typeof activeKey !== 'string') {
129
- setInnerActiveKey(key)
130
- }
131
- onChange?.(key)
132
- }}
133
- />
134
- )
135
- }
@@ -1,72 +0,0 @@
1
- 'use client'
2
-
3
- import React, { useMemo } from 'react'
4
-
5
- import { Typography } from 'antd'
6
- import { TextProps } from 'antd/lib/typography/Text'
7
-
8
- import { replaceByRules } from '@wzyjs/utils/web'
9
-
10
- export interface StringProps extends TextProps {
11
- isCopy?: boolean;
12
- isEllipsis?: boolean;
13
- }
14
-
15
- export const String = (props: StringProps) => {
16
- const { isEllipsis, isCopy, children } = props
17
-
18
- const { source = '', __html = '' } = useMemo<{ source?: string, __html?: string }>(() => {
19
- if (typeof children !== 'string') {
20
- return {}
21
- }
22
-
23
- if (!children.includes('’')) {
24
- return {
25
- source: children.trim(),
26
- }
27
- }
28
-
29
- return {
30
- source: children.trim(),
31
- __html: replaceByRules(children.trim(), [
32
- [
33
- '‘',
34
- '<xmp style="display: inline-block; color: #d56161; margin: 0 3px; font-family: Consolas, Monaco, monospace;">',
35
- ],
36
- ['’', '</xmp>'],
37
- ]),
38
- }
39
- }, [])
40
-
41
- const ellipsis = useMemo(() => {
42
- if (!isEllipsis) {
43
- return false
44
- }
45
- return { rows: 100, expandable: true }
46
- }, [isEllipsis])
47
-
48
- const copyable = useMemo(() => {
49
- if (!isCopy) {
50
- return
51
- }
52
- return {
53
- text: replaceByRules(source, [
54
- ['‘', ''],
55
- ['’', ''],
56
- ]),
57
- }
58
- }, [isCopy, source])
59
-
60
- return (
61
- <Typography.Paragraph
62
- {...props}
63
- ellipsis={ellipsis}
64
- copyable={copyable}
65
- >
66
- <span
67
- style={{ whiteSpace: 'pre' }}
68
- dangerouslySetInnerHTML={{ __html: __html || source }}
69
- />
70
- </Typography.Paragraph>
71
- )
72
- }
@@ -1,9 +0,0 @@
1
- 'use client'
2
-
3
- import { String as String_ } from './components/String'
4
-
5
- export const TypographyPro = {
6
- String: String_,
7
- }
8
-
9
- export const String = String_
@@ -1,11 +0,0 @@
1
- export * from './Alert'
2
- export * from './Button'
3
- export * from './Card'
4
- export * from './Collapse'
5
- export * from './Image'
6
- export * from './Input'
7
- export * from './Radio'
8
- export * from './Space'
9
- export * from './Tabs'
10
- export * from './Typography'
11
- export * from './Popconfirm'
@@ -1,28 +0,0 @@
1
- 'use client'
2
-
3
- import { ReactNode } from 'react'
4
-
5
- interface BottomBarProps {
6
- children?: ReactNode
7
- collapsed?: boolean
8
- }
9
-
10
- const style = {
11
- display: 'flex',
12
- justifyContent: 'center',
13
- padding: 10,
14
- right: 0,
15
- bottom: 0,
16
- boxShadow: '0 0 2px 0 rgba(0, 0, 0, 0.1)',
17
- background: '#fff',
18
- }
19
-
20
- export const BottomBar = (props: BottomBarProps) => {
21
- const { children, collapsed } = props
22
-
23
- return (
24
- <div style={{ ...style, left: collapsed ? 64 : 256, position: 'fixed' }}>
25
- {children}
26
- </div>
27
- )
28
- }
@@ -1,85 +0,0 @@
1
- 'use client'
2
-
3
- import React, { CSSProperties, useEffect, useMemo, useRef } from 'react'
4
-
5
- import Prism from 'prismjs'
6
- import { format } from 'prettier/standalone'
7
- import parserBabel from 'prettier/parser-babel'
8
- import parserTs from 'prettier/parser-typescript'
9
- import { js_beautify, html_beautify, css_beautify } from 'js-beautify'
10
-
11
- import 'prismjs/components/prism-jsx'
12
- import 'prismjs/components/prism-tsx'
13
- import 'prismjs/components/prism-json'
14
-
15
- import 'prismjs/components/prism-javascript'
16
- import 'prismjs/components/prism-typescript'
17
-
18
- import 'prismjs/components/prism-css'
19
- import 'prismjs/components/prism-less'
20
- import 'prismjs/components/prism-sass'
21
- import 'prismjs/components/prism-scss'
22
-
23
- import 'prismjs/components/prism-bash'
24
- import 'prismjs/components/prism-http'
25
- import 'prismjs/components/prism-editorconfig'
26
- import 'prismjs/components/prism-docker'
27
- import 'prismjs/components/prism-git'
28
- import 'prismjs/components/prism-ignore'
29
- import 'prismjs/components/prism-yaml'
30
-
31
- import 'prismjs/themes/prism.css'
32
-
33
- interface CodeViewProps {
34
- language?: 'html' | 'jsx' | 'tsx' | 'vue' | 'json' | 'javascript' | 'typescript' | 'css' | 'less' | 'sass' | 'scss' | 'bash' | 'http' | 'editorconfig' | 'dockerfile' | 'git' | 'ignore' | 'yaml'
35
- code?: string,
36
- children?: any,
37
- style?: CSSProperties,
38
- }
39
-
40
- export const CodeView = (props: CodeViewProps) => {
41
- const { language = 'javascript', style, children, code = children } = props
42
-
43
- const preRef = useRef(null)
44
- useEffect(() => {
45
- if (!preRef.current) {
46
- return
47
- }
48
- Prism.highlightElement(preRef.current)
49
- }, [])
50
-
51
- const beautifydCode = useMemo(() => {
52
- if (language === 'html') {
53
- return html_beautify(code, { indent_size: 2 })
54
- }
55
- if (language === 'css') {
56
- return css_beautify(code, { indent_size: 2 })
57
- }
58
- if (language === 'javascript') {
59
- return js_beautify(code, { indent_size: 2 })
60
- }
61
-
62
- try {
63
- return format(code, {
64
- semi: false,
65
- parser: 'babel',
66
- singleQuote: true,
67
- tabWidth: 2,
68
- jsxSingleQuote: true,
69
- plugins: [parserBabel, parserTs],
70
- })
71
- } catch (e) {
72
- return code
73
- }
74
- }, [code])
75
-
76
- return (
77
- <div style={{ overflow: 'scroll', ...style }}>
78
- <pre style={{ margin: 0, backgroundColor: 'transparent' }}>
79
- <code ref={preRef} className={`language-${language}`}>
80
- {beautifydCode}
81
- </code>
82
- </pre>
83
- </div>
84
- )
85
- }
@@ -1,26 +0,0 @@
1
- 'use client'
2
-
3
- import { ReactNode } from 'react'
4
- import { useBoolean } from '@wzyjs/hooks/web'
5
- import { RightOutlined, LeftOutlined } from '@ant-design/icons'
6
-
7
- interface CollapseProps {
8
- children: ReactNode
9
- }
10
-
11
- export const Collapse = (props: CollapseProps) => {
12
- const { children } = props
13
-
14
- const [collapse, { setTrue, setFalse }] = useBoolean(false)
15
-
16
- return (
17
- <div>
18
- <div style={{ transform: 'translateY(100px)' }}>
19
- {collapse ? <LeftOutlined onClick={setFalse} /> : <RightOutlined onClick={setTrue} />}
20
- </div>
21
- <div style={{ width: collapse ? 0 : 'auto', visibility: collapse ? 'hidden' : 'visible' }}>
22
- {children}
23
- </div>
24
- </div>
25
- )
26
- }
@@ -1,60 +0,0 @@
1
- 'use client'
2
-
3
- import React, { useEffect, useRef, ReactNode } from 'react'
4
-
5
- import html2canvas from 'html2canvas'
6
-
7
- import { useDebounceFn } from '@wzyjs/hooks/web'
8
- import { getRandomColor } from '@wzyjs/utils/web'
9
-
10
- interface Com2CanvasProps {
11
- children: ReactNode;
12
- downloadName?: string;
13
- onChange?: (url: string) => void;
14
- }
15
-
16
- export const Com2Canvas = (props: Com2CanvasProps) => {
17
- const { children, downloadName, onChange } = props
18
-
19
- const random = useRef(getRandomColor())
20
- const htmlId = `h2c_html_${random.current}`
21
- const canvasId = `htc_canvas_${random.current}`
22
-
23
- const { run } = useDebounceFn(() => {
24
- const el = document.querySelector(`#${canvasId}`) as HTMLElement
25
- if (!el) {
26
- return
27
- }
28
-
29
- html2canvas(el, {
30
- allowTaint: true, // 允许污染
31
- useCORS: true, // 使用跨域(当allowTaint为true时这段代码没什么用)
32
- scale: 2,
33
- }).then((canvas: any) => {
34
- el.innerHTML = ''
35
- el.appendChild(canvas)
36
-
37
- onChange?.(canvas.toDataURL('image/png'))
38
-
39
- if (downloadName) {
40
- el.onclick = () => {
41
- const a = document.createElement('a')
42
- a.download = downloadName
43
- a.href = canvas.toDataURL('image/png')
44
- document.body.appendChild(a)
45
- a.click()
46
- a.remove()
47
- }
48
- }
49
- })
50
- }, { wait: 500 })
51
-
52
- useEffect(run, [children])
53
-
54
- return (
55
- <span style={{ position: 'relative' }}>
56
- <span id={htmlId}>{children}</span>
57
- <span id={canvasId} style={{ position: 'absolute', top: 0 }} />
58
- </span>
59
- )
60
- }
@@ -1,26 +0,0 @@
1
- 'use client'
2
-
3
- import React, { useMemo } from 'react'
4
- import Handlebars from 'handlebars'
5
-
6
- interface Props {
7
- template?: string
8
- data: any
9
- }
10
-
11
- export default (props: Props) => {
12
- const { template, data } = props
13
-
14
- const html = useMemo(() => {
15
- const html = Handlebars.compile(template || '')(data)
16
- return html.replaceAll('\n', '').replaceAll('\t', '')
17
- }, [template, data])
18
-
19
- if (!html) {
20
- return null
21
- }
22
-
23
- return (
24
- <div dangerouslySetInnerHTML={{ __html: html }} />
25
- )
26
- }