@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,247 +0,0 @@
1
- 'use client'
2
-
3
- import React, { useState } from 'react'
4
-
5
- export interface SectorButtonSector<T> {
6
- id: T;
7
- label?: string;
8
- color?: string;
9
- hoverColor?: string;
10
- }
11
-
12
- export interface SectorButtonProps<T> {
13
- sectors: SectorButtonSector<T>[];
14
- size?: number;
15
- className?: string;
16
- onClick?: (id: T) => void;
17
- borderRadius?: number;
18
- showPlusSign?: boolean;
19
- plusSignColor?: string;
20
- plusSignSize?: number;
21
- shape?: 'circle' | 'rounded-rect';
22
- rectWidth?: number;
23
- rectHeight?: number;
24
- }
25
-
26
- export const SectorButton = <T = string>(props: SectorButtonProps<T>) => {
27
- const {
28
- shape = 'rounded-rect',
29
- size = 40,
30
- rectWidth = size,
31
- rectHeight = size,
32
- sectors,
33
- className,
34
- borderRadius = 12,
35
- showPlusSign = true,
36
- plusSignColor = '#bbb',
37
- plusSignSize = 0.3,
38
- onClick,
39
- } = props
40
-
41
- const [hoveredSector, setHoveredSector] = useState<T | null>(null)
42
-
43
- const anglePerSector = 360 / sectors.length
44
- const radius = size / 2
45
-
46
- // 添加额外边距确保虚线显示完整
47
- const padding = 2
48
- const svgWidth = shape === 'circle' ? size + padding * 2 : rectWidth + padding * 2
49
- const svgHeight = shape === 'circle' ? size + padding * 2 : rectHeight + padding * 2
50
-
51
- const handleSectorClick = (id: T) => {
52
- onClick?.(id)
53
- }
54
-
55
- // 先渲染非悬停的扇形,然后渲染悬停的扇形,确保悬停的扇形在最顶层
56
- const nonHoveredSectors = sectors.filter(sector => sector.id !== hoveredSector)
57
- const hoveredSector1 = sectors.find(sector => sector.id === hoveredSector)
58
- const orderedSectors = [...nonHoveredSectors]
59
- if (hoveredSector1) {
60
- orderedSectors.push(hoveredSector1)
61
- }
62
-
63
- // 生成圆角矩形或扇形的路径
64
- const generatePath = (sector: SectorButtonSector<T>, originalIndex: number) => {
65
- const centerX = svgWidth / 2
66
- const centerY = svgHeight / 2
67
-
68
- if (shape === 'circle') {
69
- // 原来的扇形路径生成逻辑
70
- const startAngle = originalIndex * anglePerSector
71
- const endAngle = (originalIndex + 1) * anglePerSector
72
-
73
- const startRad = (startAngle - 90) * Math.PI / 180
74
- const endRad = (endAngle - 90) * Math.PI / 180
75
-
76
- return [
77
- `M ${centerX} ${centerY}`,
78
- `L ${centerX + radius * Math.cos(startRad)} ${centerY + radius * Math.sin(startRad)}`,
79
- `A ${radius} ${radius} 0 ${anglePerSector > 180 ? 1 : 0} 1 ${centerX + radius * Math.cos(endRad)} ${centerY + radius * Math.sin(endRad)}`,
80
- `Z`,
81
- ].join(' ')
82
- } else {
83
- // 圆角矩形的分块逻辑
84
- const rectX = padding
85
- const rectY = padding
86
- const rectW = rectWidth
87
- const rectH = rectHeight
88
-
89
- // 当只有2个扇形时,使用左右布局
90
- if (sectors.length === 2) {
91
- const secWidth = rectW / 2
92
- const secHeight = rectH
93
- const x = rectX + originalIndex * secWidth
94
- const y = rectY
95
-
96
- // 使用圆角矩形绘制单个部分
97
- const br = borderRadius > 0 ? Math.min(borderRadius, secWidth / 4, secHeight / 4) : 0
98
-
99
- // 确定是左侧还是右侧
100
- const isLeft = originalIndex === 0
101
- const isRight = originalIndex === 1
102
-
103
- // 构建路径 - 根据位置决定哪些角有圆角
104
- return [
105
- `M ${x + (isLeft ? br : 0)} ${y}`,
106
-
107
- // 上边
108
- `H ${x + secWidth - (isRight ? br : 0)}`,
109
- isRight ? `A ${br} ${br} 0 0 1 ${x + secWidth} ${y + br}` : '',
110
-
111
- // 右边
112
- `V ${y + secHeight - (isRight ? br : 0)}`,
113
- isRight ? `A ${br} ${br} 0 0 1 ${x + secWidth - br} ${y + secHeight}` : '',
114
-
115
- // 下边
116
- `H ${x + (isLeft ? br : 0)}`,
117
- isLeft ? `A ${br} ${br} 0 0 1 ${x} ${y + secHeight - br}` : '',
118
-
119
- // 左边
120
- `V ${y + (isLeft ? br : 0)}`,
121
- isLeft ? `A ${br} ${br} 0 0 1 ${x + br} ${y}` : '',
122
-
123
- 'Z',
124
- ].filter(Boolean).join(' ')
125
- } else {
126
- // 原有的上下布局逻辑
127
- const secWidth = rectW / (sectors.length % 2 === 0 ? sectors.length / 2 : Math.ceil(sectors.length / 2))
128
- const secHeight = rectH / 2
129
-
130
- // 确定当前扇区在矩形中的位置
131
- const isTopRow = originalIndex < Math.ceil(sectors.length / 2)
132
- const rowIndex = isTopRow ? originalIndex : originalIndex - Math.ceil(sectors.length / 2)
133
-
134
- const x = rectX + rowIndex * secWidth
135
- const y = isTopRow ? rectY : rectY + secHeight
136
-
137
- // 使用圆角矩形绘制单个部分
138
- const br = borderRadius > 0 ? Math.min(borderRadius, secWidth / 4, secHeight / 4) : 0
139
-
140
- // 确定哪些边需要圆角
141
- const isLeftEdge = (isTopRow && rowIndex === 0) || (!isTopRow && rowIndex === 0)
142
- const isRightEdge = (isTopRow && rowIndex === Math.ceil(sectors.length / 2) - 1) ||
143
- (!isTopRow && rowIndex === (sectors.length - Math.ceil(sectors.length / 2)) - 1)
144
- const isTopEdge = isTopRow
145
- const isBottomEdge = !isTopRow
146
-
147
- // 构建路径 - 根据位置决定哪些角有圆角
148
- return [
149
- `M ${x + (isLeftEdge && isTopEdge ? br : 0)} ${y}`,
150
-
151
- // 上边
152
- `H ${x + secWidth - (isRightEdge && isTopEdge ? br : 0)}`,
153
- isRightEdge && isTopEdge ? `A ${br} ${br} 0 0 1 ${x + secWidth} ${y + br}` : '',
154
-
155
- // 右边
156
- `V ${y + secHeight - (isRightEdge && isBottomEdge ? br : 0)}`,
157
- isRightEdge && isBottomEdge ? `A ${br} ${br} 0 0 1 ${x + secWidth - br} ${y + secHeight}` : '',
158
-
159
- // 下边
160
- `H ${x + (isLeftEdge && isBottomEdge ? br : 0)}`,
161
- isLeftEdge && isBottomEdge ? `A ${br} ${br} 0 0 1 ${x} ${y + secHeight - br}` : '',
162
-
163
- // 左边
164
- `V ${y + (isLeftEdge && isTopEdge ? br : 0)}`,
165
- isLeftEdge && isTopEdge ? `A ${br} ${br} 0 0 1 ${x + br} ${y}` : '',
166
-
167
- 'Z',
168
- ].filter(Boolean).join(' ')
169
- }
170
- }
171
- }
172
-
173
- return (
174
- <div
175
- className={`relative ${className}`}
176
- style={{
177
- width: shape === 'circle' ? size : rectWidth,
178
- height: shape === 'circle' ? size : rectHeight,
179
- borderRadius,
180
- backgroundColor: 'transparent',
181
- }}
182
- >
183
- <svg
184
- width={svgWidth}
185
- height={svgHeight}
186
- viewBox={`0 0 ${svgWidth} ${svgHeight}`}
187
- style={{
188
- position: 'absolute',
189
- top: -padding,
190
- left: -padding,
191
- }}
192
- >
193
- <g>
194
- {orderedSectors.map(sector => {
195
- const originalIndex = sectors.findIndex(s => s.id === sector.id)
196
- const pathData = generatePath(sector, originalIndex)
197
-
198
- const isHovered = hoveredSector === sector.id
199
- const fillColor = (isHovered ? sector.hoverColor : sector.color) || 'white'
200
- const strokeColor = isHovered ? '#90cdf4' : '#e2e8f0'
201
- const strokeWidth = isHovered ? 1.5 : 1
202
-
203
- return (
204
- <g key={sector.id as string}>
205
- <path
206
- d={pathData}
207
- fill={fillColor}
208
- stroke={strokeColor}
209
- strokeWidth={strokeWidth}
210
- strokeDasharray='4,1'
211
- className='transition-colors duration-200 cursor-pointer'
212
- onMouseEnter={() => setHoveredSector(sector.id)}
213
- onMouseLeave={() => setHoveredSector(null)}
214
- onClick={() => handleSectorClick(sector.id)}
215
- />
216
- </g>
217
- )
218
- })}
219
-
220
- {/* 在中间添加加号 */}
221
- {showPlusSign && (
222
- <g>
223
- <line
224
- x1={svgWidth / 2 - (plusSignSize * (shape === 'circle' ? size : Math.min(rectWidth, rectHeight)) / 2)}
225
- y1={svgHeight / 2}
226
- x2={svgWidth / 2 + (plusSignSize * (shape === 'circle' ? size : Math.min(rectWidth, rectHeight)) / 2)}
227
- y2={svgHeight / 2}
228
- stroke={plusSignColor}
229
- strokeWidth={2}
230
- strokeLinecap='round'
231
- />
232
- <line
233
- x1={svgWidth / 2}
234
- y1={svgHeight / 2 - (plusSignSize * (shape === 'circle' ? size : Math.min(rectWidth, rectHeight)) / 2)}
235
- x2={svgWidth / 2}
236
- y2={svgHeight / 2 + (plusSignSize * (shape === 'circle' ? size : Math.min(rectWidth, rectHeight)) / 2)}
237
- stroke={plusSignColor}
238
- strokeWidth={2}
239
- strokeLinecap='round'
240
- />
241
- </g>
242
- )}
243
- </g>
244
- </svg>
245
- </div>
246
- )
247
- }
@@ -1,61 +0,0 @@
1
- 'use client'
2
-
3
- import React, { useState } from 'react'
4
-
5
- import { Input } from 'antd'
6
- import { useBoolean } from '@wzyjs/hooks/web'
7
-
8
- interface TextInputProps {
9
- value: string
10
- onChange?: (value: string) => void
11
- }
12
-
13
- export const TextInput = (props: TextInputProps) => {
14
- const { value, onChange } = props
15
-
16
- const [text, setText] = useState(value)
17
-
18
- const [isEditing, { setTrue, setFalse }] = useBoolean(false)
19
-
20
- const onSubmit = () => {
21
- if (!text.trim()) {
22
- return
23
- }
24
-
25
- if (text === value) {
26
- setFalse()
27
- return
28
- }
29
-
30
- onChange?.(text.trim())
31
- setFalse()
32
- }
33
-
34
- const onBlur = () => {
35
- onSubmit()
36
- }
37
-
38
- const onKeyDown = (e: React.KeyboardEvent) => {
39
- if (e.key === 'Enter') {
40
- onSubmit()
41
- }
42
- }
43
-
44
- return (
45
- <div onDoubleClick={setTrue}>
46
- {!isEditing ? (
47
- <span>{text}</span>
48
- ) : (
49
- <Input
50
- value={text}
51
- onChange={ev => setText(ev.target.value)}
52
- onBlur={onBlur}
53
- onKeyDown={onKeyDown}
54
- autoFocus
55
- size='small'
56
- style={{ width: 200 }}
57
- />
58
- )}
59
- </div>
60
- )
61
- }
@@ -1,64 +0,0 @@
1
- import React from 'react'
2
- import type { ReactElement } from 'react'
3
-
4
- import { dayjs } from '@/utils'
5
- import { HEIGHT } from '../../const'
6
- import { useHighlightRange } from '../../hooks'
7
-
8
- interface CurrentWeekHighlightProps {
9
- originTime: number
10
- timePxPerDay: number
11
- }
12
-
13
- export const CurrentWeekHighlight = (props: CurrentWeekHighlightProps): ReactElement | null => {
14
- const { originTime, timePxPerDay } = props
15
-
16
- const today = dayjs().startOf('day')
17
-
18
- const weekStart = today.startOf('week').startOf('day')
19
- const weekEnd = weekStart.add(1, 'week')
20
-
21
- const currentWeekHighlight = useHighlightRange({
22
- originTime,
23
- timePxPerDay,
24
- startTime: weekStart.valueOf(),
25
- endTime: weekEnd.valueOf(),
26
- })
27
-
28
- const monthStart = today.startOf('month').startOf('day')
29
- const monthEnd = monthStart.add(1, 'month')
30
-
31
- const currentMonthHighlight = useHighlightRange({
32
- originTime,
33
- timePxPerDay,
34
- startTime: monthStart.valueOf(),
35
- endTime: monthEnd.valueOf(),
36
- })
37
-
38
- return (
39
- <>
40
- <div
41
- style={{
42
- position: 'absolute',
43
- top: 0,
44
- left: currentMonthHighlight.left,
45
- width: currentMonthHighlight.width,
46
- height: HEIGHT,
47
- background: 'linear-gradient(180deg, rgba(0,0,0,0.04), rgba(0,0,0,0.04))',
48
- pointerEvents: 'none',
49
- }}
50
- />
51
- <div
52
- style={{
53
- position: 'absolute',
54
- top: 0,
55
- left: currentWeekHighlight.left,
56
- width: currentWeekHighlight.width,
57
- height: HEIGHT,
58
- background: 'linear-gradient(180deg, rgba(0,0,0,0.05), rgba(0,0,0,0.05))',
59
- pointerEvents: 'none',
60
- }}
61
- />
62
- </>
63
- )
64
- }
@@ -1,61 +0,0 @@
1
- import React from 'react'
2
- import type { CSSProperties, ReactElement } from 'react'
3
-
4
- import { HEIGHT } from '../../const'
5
- import { useMonthGuides, useWeekGuides } from '../../hooks'
6
-
7
- interface MonthGuidesProps {
8
- originTime: number
9
- visibleDates: Date[]
10
- timePxPerDay: number
11
- }
12
-
13
- const baseStyles: CSSProperties = {
14
- position: 'absolute',
15
- pointerEvents: 'none',
16
- width: 1,
17
- background: '#cbd5e1',
18
- }
19
-
20
- export const Guides = (props: MonthGuidesProps): ReactElement => {
21
- const { originTime, visibleDates, timePxPerDay } = props
22
-
23
- const monthGuides = useMonthGuides({
24
- originTime,
25
- visibleDates,
26
- timePxPerDay,
27
- })
28
-
29
- const weekGuides = useWeekGuides({
30
- originTime,
31
- visibleDates,
32
- timePxPerDay,
33
- })
34
-
35
- return (
36
- <>
37
- {weekGuides.map(week => (
38
- <div
39
- key={`week-line-${week.key}`}
40
- style={{
41
- ...baseStyles,
42
- bottom: 0,
43
- height: 20,
44
- left: week.offset,
45
- }}
46
- />
47
- ))}
48
- {monthGuides.map(month => (
49
- <div
50
- key={`month-line-${month.key}`}
51
- style={{
52
- ...baseStyles,
53
- top: 0,
54
- height: HEIGHT / 1.75,
55
- left: month.offset,
56
- }}
57
- />
58
- ))}
59
- </>
60
- )
61
- }
@@ -1,56 +0,0 @@
1
- import React, { type ReactElement, useMemo } from 'react'
2
-
3
- import { dayjs } from '@/utils'
4
- import { WEEKDAY_LABELS } from '../../const'
5
- import { calcOffsetByTime } from '../../utils'
6
-
7
- interface TicksProps {
8
- originTime: number
9
- timePxPerDay: number
10
- visibleDates: Date[]
11
- }
12
-
13
- export const Ticks = (props: TicksProps): ReactElement => {
14
- const { visibleDates, timePxPerDay, originTime } = props
15
-
16
- const ticks = useMemo(() => {
17
- return visibleDates.map(value => {
18
- const d = dayjs(value)
19
- const time = d.valueOf()
20
-
21
- return {
22
- time,
23
- monthLabel: d.date() === 15 ? d.format('YYYY-M') : '',
24
- weekLabel: WEEKDAY_LABELS[d.day()],
25
- dayLabel: d.format('DD'),
26
- offset: calcOffsetByTime({ originTime, time, timePxPerDay })
27
- }
28
- })
29
- }, [visibleDates])
30
-
31
- return (
32
- <>
33
- {ticks.map(tick => (
34
- <div key={tick.time}>
35
- <div
36
- className="absolute text-center pt-[2] pb-[4] top-0 h-full text-[11px] leading-[12px] text-slate-600 whitespace-nowrap pointer-events-none"
37
- style={{ left: tick.offset, width: timePxPerDay }}
38
- >
39
- <div className="flex h-full flex-col">
40
- <div className="flex-1 text-[10px] text-slate-500">
41
- {tick.monthLabel || ''}
42
- </div>
43
- <div className="flex-1 text-[11px] text-slate-600">
44
- {tick.dayLabel}
45
- </div>
46
- <div className={'flex-1 text-[10px] text-slate-500'}>
47
- {tick.weekLabel}
48
- </div>
49
- </div>
50
- </div>
51
- </div>
52
- )
53
- )}
54
- </>
55
- )
56
- }
@@ -1,54 +0,0 @@
1
- import React from 'react'
2
- import type { ReactElement } from 'react'
3
-
4
- import { dayjs } from '@/utils'
5
- import { calcOffsetByTime } from '../../utils'
6
-
7
- interface TodayIndicatorProps {
8
- originTime: number
9
- timePxPerDay: number
10
- }
11
-
12
- export const TodayIndicator = (props: TodayIndicatorProps): ReactElement | null => {
13
- const { originTime, timePxPerDay } = props
14
-
15
- const offset = calcOffsetByTime({
16
- originTime,
17
- timePxPerDay,
18
- time: dayjs().startOf('day').valueOf(),
19
- })
20
-
21
- return (
22
- <>
23
- <div
24
- style={{
25
- position: 'absolute',
26
- top: 1,
27
- left: offset + (timePxPerDay - 30) / 2,
28
- width: 30,
29
- fontSize: 8,
30
- lineHeight: '12px',
31
- textAlign: 'center',
32
- borderRadius: 999,
33
- background: '#0ea5e9',
34
- color: '#fff',
35
- whiteSpace: 'nowrap',
36
- pointerEvents: 'none',
37
- }}
38
- >
39
- 今天
40
- </div>
41
- <div
42
- style={{
43
- position: 'absolute',
44
- left: offset + (timePxPerDay - 7) / 2,
45
- bottom: 0,
46
- borderLeft: '4px solid transparent',
47
- borderRight: '4px solid transparent',
48
- borderBottom: '7px solid #0ea5e9',
49
- pointerEvents: 'none',
50
- }}
51
- />
52
- </>
53
- )
54
- }
@@ -1,4 +0,0 @@
1
- export * from './Ticks'
2
- export * from './Guides'
3
- export * from './TodayIndicator'
4
- export * from './CurrentWeekHighlight'
@@ -1,3 +0,0 @@
1
- export const HEIGHT = 50
2
- export const ONE_DAY_MS = 24 * 60 * 60 * 1000
3
- export const WEEKDAY_LABELS = ['日', '一', '二', '三', '四', '五', '六']
@@ -1,5 +0,0 @@
1
- export * from './useTickValues'
2
- export * from './useVisibleRange'
3
- export * from './useMonthGuides'
4
- export * from './useWeekGuides'
5
- export * from './useHighlightRange'
@@ -1,21 +0,0 @@
1
- import { calcOffsetByTime } from '../utils'
2
-
3
- interface HighlightRangeOption {
4
- originTime: number
5
- startTime: number
6
- endTime: number
7
- timePxPerDay: number
8
- }
9
-
10
- export const useHighlightRange = (option: HighlightRangeOption) => {
11
- const { originTime, startTime, endTime, timePxPerDay } = option
12
-
13
- const start = calcOffsetByTime({ originTime, time: startTime, timePxPerDay })
14
- const end = calcOffsetByTime({ originTime, time: endTime, timePxPerDay })
15
-
16
- const safeLeft = start
17
- const safeRight = Math.max(safeLeft, end)
18
- const safeWidth = Math.max(0, safeRight - safeLeft)
19
-
20
- return { left: safeLeft, width: safeWidth }
21
- }
@@ -1,40 +0,0 @@
1
- import { dayjs } from '@/utils'
2
- import { calcOffsetByTime } from '../utils'
3
-
4
- interface GuideLine {
5
- key: string
6
- offset: number
7
- }
8
-
9
- interface MonthGuidesOption {
10
- originTime: number
11
- visibleDates: Date[]
12
- timePxPerDay: number
13
- }
14
-
15
- export const useMonthGuides = (option: MonthGuidesOption): GuideLine[] => {
16
- const { originTime, visibleDates, timePxPerDay } = option
17
-
18
- if (!visibleDates.length) {
19
- return []
20
- }
21
-
22
- const result: GuideLine[] = []
23
-
24
- for (const date of visibleDates) {
25
- const d = dayjs(date)
26
- if (d.date() !== 1) {
27
- continue
28
- }
29
-
30
- const time: number = d.startOf('month').startOf('day').valueOf()
31
- const offset = calcOffsetByTime({ originTime, time, timePxPerDay })
32
-
33
- result.push({
34
- key: `${d.format('YYYY-MM')}-start`,
35
- offset,
36
- })
37
- }
38
-
39
- return result
40
- }
@@ -1,18 +0,0 @@
1
- import { dayjs } from '@/utils'
2
-
3
- interface TickValuesOption {
4
- visibleStart: number
5
- visibleEnd: number
6
- }
7
-
8
- export const useTickValues = (option: TickValuesOption) => {
9
- const { visibleStart, visibleEnd } = option
10
-
11
- const start = dayjs(visibleStart).startOf('day')
12
- const end = dayjs(visibleEnd).endOf('day')
13
- const days = end.diff(start, 'day') + 1
14
-
15
- return Array.from({ length: days }).map((_, i: number) => (
16
- start.add(i, 'day').toDate()
17
- ))
18
- }
@@ -1,43 +0,0 @@
1
- import { useTickValues } from '../hooks'
2
- import { calcTimeByScreenOffset } from '.././utils'
3
-
4
- interface VisibleRangeOption {
5
- x: number
6
- originTime: number
7
- containerWidth: number
8
- timePxPerDay: number
9
- minTime?: number
10
- maxTime?: number
11
- }
12
-
13
- export const useVisibleRange = (option: VisibleRangeOption) => {
14
- const { x, originTime, containerWidth, timePxPerDay, minTime, maxTime } = option
15
-
16
- const lower: number = typeof minTime === 'number' ? minTime : Number.NEGATIVE_INFINITY
17
- const upper: number = typeof maxTime === 'number' ? maxTime : Number.POSITIVE_INFINITY
18
- const safeLower: number = Math.min(lower, upper)
19
- const safeUpper: number = Math.max(lower, upper)
20
-
21
- const rawVisibleStart: number = calcTimeByScreenOffset({ screenOffset: 0, x, originTime, timePxPerDay })
22
- const rawVisibleEnd: number = calcTimeByScreenOffset({ screenOffset: containerWidth, x, originTime, timePxPerDay })
23
-
24
- const visibleStart: number = Math.min(
25
- safeUpper,
26
- Math.max(safeLower, Math.min(rawVisibleStart, rawVisibleEnd)),
27
- )
28
- const visibleEnd: number = Math.max(
29
- visibleStart,
30
- Math.min(safeUpper, Math.max(safeLower, Math.max(rawVisibleStart, rawVisibleEnd))),
31
- )
32
-
33
- const visibleDates = useTickValues({
34
- visibleStart,
35
- visibleEnd,
36
- })
37
-
38
- return {
39
- visibleStart,
40
- visibleEnd,
41
- visibleDates,
42
- }
43
- }