@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
@@ -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,26 +0,0 @@
1
- 'use client'
2
-
3
- import React from 'react'
4
- import { Space } from 'antd'
5
- import { ConfirmButton, ConfirmButtonProps } from './ConfirmButton'
6
-
7
- export interface ButtonGroupProps {
8
- list?: (ConfirmButtonProps & { visible?: boolean, title?: string })[]
9
- }
10
-
11
- // 1. 按钮组
12
- export const ButtonGroup = (props: ButtonGroupProps) => {
13
- const { list = [] } = props
14
-
15
- if (!list?.length) {
16
- return null
17
- }
18
-
19
- return (
20
- <Space.Compact>
21
- {list.filter(item => item.visible).map((item, index) => (
22
- <ConfirmButton key={index} {...item}>{item.title}</ConfirmButton>
23
- ))}
24
- </Space.Compact>
25
- )
26
- }
@@ -1,24 +0,0 @@
1
- 'use client'
2
-
3
- import React from 'react'
4
- import { _ } from '@wzyjs/utils/web'
5
- import { Button, Popconfirm, PopconfirmProps, ButtonProps } from 'antd'
6
-
7
- export interface ConfirmButtonProps extends PopconfirmProps {
8
- btnProps?: ButtonProps
9
- }
10
-
11
- // 1. 给按钮增加了确认功能
12
- export const ConfirmButton = (props: ConfirmButtonProps) => {
13
- const { children, btnProps } = props
14
-
15
- return (
16
- <Popconfirm
17
- okText='是'
18
- cancelText='否'
19
- {..._.omit(props, ['children', 'btnProps'])}
20
- >
21
- <Button type='link' {...btnProps}>{children}</Button>
22
- </Popconfirm>
23
- )
24
- }
@@ -1,47 +0,0 @@
1
- 'use client'
2
-
3
- import React, { useState, ReactNode } from 'react'
4
-
5
- import { App, Button, ButtonProps } from 'antd'
6
- import { CheckOutlined } from '@ant-design/icons'
7
-
8
- import { copy, readClipboard } from '@wzyjs/utils/web'
9
- import { useControllableValue } from '@wzyjs/hooks/web'
10
-
11
- export interface CopyButtonProps extends ButtonProps {
12
- value?: string,
13
- canPaste?: boolean,
14
- }
15
-
16
- export const CopyButton = (props: CopyButtonProps) => {
17
- const [icon, setIcon] = useState<ReactNode>(null)
18
- const { message } = App.useApp()
19
-
20
- const [value, setValue] = useControllableValue<string>(props, {
21
- defaultValue: props.value,
22
- })
23
-
24
- const onContextMenu = async () => {
25
- setValue(await readClipboard())
26
- }
27
-
28
- return (
29
- <Button
30
- {...props}
31
- icon={icon}
32
- onContextMenu={props.canPaste ? onContextMenu : undefined}
33
- children={props.children || value || '记录'}
34
- onClick={(ev: any) => {
35
- props.onClick?.(ev)
36
-
37
- copy(value)
38
- message.success('复制成功')
39
-
40
- setIcon(<CheckOutlined />)
41
- setTimeout(() => {
42
- setIcon(null)
43
- }, 1000)
44
- }}
45
- />
46
- )
47
- }
@@ -1,37 +0,0 @@
1
- 'use client'
2
-
3
- import React, { useState } from 'react'
4
- import { _ } from '@wzyjs/utils/web'
5
- import { Button, Drawer as AntdDrawer, DrawerProps as AntdDrawerProps, ButtonProps } from 'antd'
6
-
7
- export interface DrawerButtonProps extends AntdDrawerProps {
8
- btnProps?: ButtonProps
9
- defaultOpen?: boolean
10
- }
11
-
12
- export const DrawerButton = (props: DrawerButtonProps) => {
13
- const { children, defaultOpen, btnProps } = props
14
- const [open, setOpen] = useState<boolean>(defaultOpen ?? false)
15
-
16
- return (
17
- <>
18
- <Button
19
- type='link'
20
- {...btnProps}
21
- onClick={ev => {
22
- btnProps?.onClick?.(ev)
23
- setOpen(true)
24
- }}
25
- />
26
- <AntdDrawer
27
- title={btnProps?.children}
28
- open={open}
29
- onClose={() => setOpen(false)}
30
- destroyOnHidden
31
- {..._.omit(props, ['children', 'btnProps'])}
32
- >
33
- {children}
34
- </AntdDrawer>
35
- </>
36
- )
37
- }
@@ -1,4 +0,0 @@
1
- export * from './ButtonGroup'
2
- export * from './ConfirmButton'
3
- export * from './CopyButton'
4
- export * from './DrawerButton'
@@ -1,5 +0,0 @@
1
- export * from './buttons'
2
- export * from './FoldCard'
3
- export * from './RangeInput'
4
- export * from './Tabs'
5
- export * from './Typography'
@@ -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
- }
@@ -1,174 +0,0 @@
1
- 'use client'
2
-
3
- import React, { type ReactNode } from 'react'
4
-
5
- import { Card, Col, Row, Avatar } from 'antd'
6
- import { Remove } from '../Remove'
7
- import { CreateUpdate } from '../CreateUpdate'
8
-
9
- import type { ListProps } from '../../types'
10
-
11
- export const CardList = (props: ListProps) => {
12
- const { crud, columns, list, update, remove } = props
13
-
14
- const cardConfig = list.cardConfig!
15
- const {
16
- gutter = [16, 16],
17
- col = { xs: 24, md: 8, lg: 6 },
18
- height = 'calc(100vh - 210px)',
19
- render: customRender,
20
- card,
21
- } = cardConfig
22
-
23
- const dataSource = crud.listState.data || []
24
-
25
- // 默认操作按钮生成函数
26
- const getDefaultActions = (record: any): ReactNode[] => {
27
- const actions: ReactNode[] = []
28
-
29
- if (update !== false) {
30
- actions.push(
31
- <CreateUpdate
32
- key='edit'
33
- crud={crud}
34
- columns={columns}
35
- config={update || {}}
36
- record={record}
37
- />
38
- )
39
- }
40
-
41
- if (remove !== false) {
42
- actions.push(
43
- <Remove
44
- key='delete'
45
- crud={crud}
46
- config={remove || {}}
47
- record={record}
48
- />
49
- )
50
- }
51
-
52
- return actions
53
- }
54
-
55
- // 解析卡片字段值
56
- const parseFieldValue = (field: any, record: any): any => {
57
- if (typeof field === 'string') {
58
- return record[field]
59
- }
60
- return field
61
- }
62
-
63
- // 渲染单个卡片项
64
- const renderCardItem = (record: any, index: number) => {
65
- const defaultActions = getDefaultActions(record)
66
-
67
- // 如果有完全自定义渲染函数,直接使用
68
- if (customRender) {
69
- return customRender(record, index, defaultActions)
70
- }
71
-
72
- // 获取卡片配置(支持函数和对象两种形式)
73
- const cardConfig = typeof card === 'function' ? card(record, index) : card
74
- const {
75
- title,
76
- extra,
77
- content,
78
- cover,
79
- meta,
80
- actions: configActions,
81
- props: cardProps = {},
82
- } = cardConfig
83
-
84
- // 渲染封面
85
- const renderCover = () => {
86
- if (!cover) return undefined
87
- return parseFieldValue(cover, record)
88
- }
89
-
90
- // 渲染标题
91
- const renderTitle = () => {
92
- if (title !== undefined) {
93
- return parseFieldValue(title, record)
94
- }
95
- // 默认标题逻辑
96
- return record.title || record.name || record.id
97
- }
98
-
99
- // 渲染右上角
100
- const renderExtra = () => {
101
- if (extra !== undefined) {
102
- return parseFieldValue(extra, record)
103
- }
104
- return null
105
- }
106
-
107
- // 渲染内容
108
- const renderContent = () => {
109
- if (content !== undefined) {
110
- return parseFieldValue(content, record)
111
- }
112
- return null
113
- }
114
-
115
- // 渲染操作按钮
116
- const renderActions = () => {
117
- if (configActions && configActions.length > 0) {
118
- return configActions.map(action => parseFieldValue(action, record))
119
- }
120
- return defaultActions
121
- }
122
-
123
- // 渲染元数据
124
- const renderMeta = () => {
125
- if (!meta) return undefined
126
-
127
- const metaTitle = meta.title ? parseFieldValue(meta.title, record) : undefined
128
- const metaDescription = meta.description ? parseFieldValue(meta.description, record) : undefined
129
- const metaAvatar = meta.avatar ? parseFieldValue(meta.avatar, record) : undefined
130
-
131
- if (!metaTitle && !metaDescription && !metaAvatar) {
132
- return undefined
133
- }
134
-
135
- return (
136
- <Card.Meta
137
- title={metaTitle}
138
- description={metaDescription}
139
- avatar={metaAvatar && (
140
- typeof metaAvatar === 'string' ? (
141
- <Avatar src={metaAvatar} />
142
- ) : (
143
- metaAvatar
144
- )
145
- )}
146
- />
147
- )
148
- }
149
-
150
- return (
151
- <Card
152
- size='small'
153
- title={renderTitle()}
154
- extra={renderExtra()}
155
- cover={renderCover()}
156
- actions={renderActions()}
157
- {...cardProps}
158
- >
159
- {renderMeta()}
160
- {renderContent()}
161
- </Card>
162
- )
163
- }
164
-
165
- return (
166
- <Row gutter={gutter} style={{ overflow: 'auto', height }}>
167
- {dataSource.map((record, index) => (
168
- <Col key={record.id || index} {...col}>
169
- {renderCardItem(record, index)}
170
- </Col>
171
- ))}
172
- </Row>
173
- )
174
- }