@baishuyun/ai-design 2.0.38 → 2.1.0-alpha.0

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 (269) hide show
  1. package/.storybook/main.ts +31 -31
  2. package/.storybook/preview.ts +16 -16
  3. package/CHANGELOG.md +512 -501
  4. package/components.json +22 -22
  5. package/package.json +9 -6
  6. package/scripts/strip-layers.cjs +41 -41
  7. package/src/components/abs-fullscreen-gradient-bg.tsx +35 -35
  8. package/src/components/agent-helper/agent-category-select-menu/index.tsx +57 -57
  9. package/src/components/agent-helper/agent-entry-card/index.tsx +94 -94
  10. package/src/components/agent-helper/agent-helper-card/index.tsx +179 -179
  11. package/src/components/agent-helper/agent-helper-card-list/index.tsx +59 -59
  12. package/src/components/agent-helper/agent-helper-main-layout/index.tsx +60 -60
  13. package/src/components/agent-helper/agent-sort-select/index.tsx +89 -89
  14. package/src/components/agent-helper/agent-tag/index.tsx +29 -29
  15. package/src/components/agent-helper/app-select/index.tsx +559 -559
  16. package/src/components/agent-helper/condition-group/index.tsx +75 -75
  17. package/src/components/agent-helper/condition-input/index.tsx +233 -233
  18. package/src/components/agent-helper/condition-item/index.tsx +237 -237
  19. package/src/components/agent-helper/condition-quantifier-select/index.tsx +142 -142
  20. package/src/components/agent-helper/condition-trigger-description/index.tsx +49 -49
  21. package/src/components/agent-helper/date-picker/calendar-panel.tsx +164 -164
  22. package/src/components/agent-helper/date-picker/date-input.tsx +91 -91
  23. package/src/components/agent-helper/date-picker/date-picker.tsx +327 -327
  24. package/src/components/agent-helper/date-picker/footer-panel.tsx +44 -44
  25. package/src/components/agent-helper/date-picker/index.ts +3 -3
  26. package/src/components/agent-helper/date-picker/month-panel.tsx +82 -82
  27. package/src/components/agent-helper/date-picker/time-panel.tsx +146 -146
  28. package/src/components/agent-helper/date-picker/types.ts +37 -37
  29. package/src/components/agent-helper/date-picker/utils.ts +121 -121
  30. package/src/components/agent-helper/date-picker/year-panel.tsx +86 -86
  31. package/src/components/agent-helper/exec-log-filter/index.tsx +232 -232
  32. package/src/components/agent-helper/field-edit-preference-select/index.tsx +291 -291
  33. package/src/components/agent-helper/field-select/index.tsx +466 -466
  34. package/src/components/agent-helper/field-value-input/china-address-data.ts +4117 -4117
  35. package/src/components/agent-helper/field-value-input/display.tsx +71 -71
  36. package/src/components/agent-helper/field-value-input/icons.tsx +38 -38
  37. package/src/components/agent-helper/field-value-input/index.tsx +144 -144
  38. package/src/components/agent-helper/field-value-input/inputs.tsx +247 -247
  39. package/src/components/agent-helper/field-value-input/picker-inputs.tsx +1141 -1141
  40. package/src/components/agent-helper/flow-node-action-trigger-select/index.tsx +57 -57
  41. package/src/components/agent-helper/form-action-trigger-select/index.tsx +60 -60
  42. package/src/components/agent-helper/form-divider/index.tsx +44 -44
  43. package/src/components/agent-helper/form-select/index.tsx +732 -732
  44. package/src/components/agent-helper/monthdays-select/index.tsx +378 -378
  45. package/src/components/agent-helper/offset-preference-select/index.tsx +268 -268
  46. package/src/components/agent-helper/offset-type-select/index.tsx +66 -66
  47. package/src/components/agent-helper/offset-unit-select/index.tsx +54 -54
  48. package/src/components/agent-helper/placeholder-card/index.tsx +75 -75
  49. package/src/components/agent-helper/prompt-input/index.tsx +646 -646
  50. package/src/components/agent-helper/relational-operator-select/index.tsx +179 -179
  51. package/src/components/agent-helper/repeat-by-type-select/index.tsx +53 -53
  52. package/src/components/agent-helper/repeat-preference-select/index.tsx +162 -162
  53. package/src/components/agent-helper/repeat-preference-type-select/index.tsx +58 -58
  54. package/src/components/agent-helper/search-input/index.tsx +35 -35
  55. package/src/components/agent-helper/table/index.tsx +114 -114
  56. package/src/components/agent-helper/trigger-select/index.tsx +121 -121
  57. package/src/components/agent-helper/trigger-time-preference-select/index.tsx +189 -189
  58. package/src/components/agent-helper/trigger-time-source-type-select/index.tsx +53 -53
  59. package/src/components/agent-helper/weekdays-select/index.tsx +230 -230
  60. package/src/components/agent-scroll-selector.tsx +193 -193
  61. package/src/components/agent-select.tsx +154 -154
  62. package/src/components/attachment-part-group.tsx +35 -35
  63. package/src/components/attachment-part.tsx +296 -296
  64. package/src/components/attachments-previewer.tsx +272 -272
  65. package/src/components/base-button.tsx +49 -49
  66. package/src/components/border-animation.tsx +107 -107
  67. package/src/components/border-color-animation.tsx +66 -66
  68. package/src/components/bot-avatar-name.tsx +36 -36
  69. package/src/components/bot-icon.tsx +23 -23
  70. package/src/components/bs-entry-select/app-group-folder.tsx +61 -61
  71. package/src/components/bs-entry-select/bs-entry-select.tsx +296 -296
  72. package/src/components/bs-entry-select/build-tree.ts +265 -265
  73. package/src/components/bs-entry-select/entry-item.tsx +45 -45
  74. package/src/components/bs-entry-select/entry-popover.tsx +99 -99
  75. package/src/components/bs-entry-select/index.ts +7 -7
  76. package/src/components/bs-entry-select/other-app-section.tsx +96 -96
  77. package/src/components/bs-entry-select/scroll-slider.tsx +872 -872
  78. package/src/components/bs-entry-select/search-input.tsx +4 -4
  79. package/src/components/bs-entry-select/tree-item-node.tsx +84 -84
  80. package/src/components/bs-entry-select/types.ts +46 -46
  81. package/src/components/bs-icons.tsx +1362 -1362
  82. package/src/components/card-field.tsx +23 -23
  83. package/src/components/card.tsx +36 -36
  84. package/src/components/chat-area-header.tsx +65 -65
  85. package/src/components/check-card.tsx +77 -77
  86. package/src/components/circle-checker.tsx +66 -66
  87. package/src/components/collapsible-txt-msg.tsx +75 -75
  88. package/src/components/collapsible.tsx +9 -9
  89. package/src/components/confirm-dialog.tsx +139 -139
  90. package/src/components/date-range-picker.tsx +91 -91
  91. package/src/components/fake-bot-msg.tsx +51 -51
  92. package/src/components/field-checker-list-msg.tsx +146 -146
  93. package/src/components/field-checker.tsx +185 -185
  94. package/src/components/field-icon.tsx +13 -13
  95. package/src/components/field-value-checker.tsx +116 -116
  96. package/src/components/fields-design-info-table.tsx +160 -160
  97. package/src/components/fields-generating-indicator.tsx +95 -95
  98. package/src/components/fields-portal.tsx +18 -18
  99. package/src/components/fields-previewer.tsx +216 -216
  100. package/src/components/font-icon.tsx +65 -65
  101. package/src/components/form-info-editor.tsx +263 -263
  102. package/src/components/formula-tag.tsx +32 -32
  103. package/src/components/generate-animation.tsx +56 -56
  104. package/src/components/icon-btn.tsx +43 -43
  105. package/src/components/icon-card.tsx +67 -67
  106. package/src/components/icons/calendar-icon.tsx +5 -5
  107. package/src/components/icons/clear-all-icon.tsx +5 -5
  108. package/src/components/icons/empty-agent-icon.tsx +93 -93
  109. package/src/components/icons/empty-table-icon.tsx +104 -104
  110. package/src/components/icons/grids-icon.tsx +5 -5
  111. package/src/components/img-part.tsx +27 -27
  112. package/src/components/legacy-slot.tsx +110 -110
  113. package/src/components/line-checker.tsx +168 -168
  114. package/src/components/linear-gradient-border-btn.tsx +48 -48
  115. package/src/components/linear-gradient-color-bg-animation.tsx +103 -103
  116. package/src/components/memoized-markdown.tsx +32 -32
  117. package/src/components/message-content.tsx +21 -21
  118. package/src/components/number-part.tsx +46 -46
  119. package/src/components/office-container.tsx +289 -289
  120. package/src/components/option-item.tsx +27 -27
  121. package/src/components/output-config-editor.tsx +478 -478
  122. package/src/components/previewer-header.tsx +270 -270
  123. package/src/components/primary-confirm-btn.tsx +58 -58
  124. package/src/components/primary-entry-btn.tsx +48 -48
  125. package/src/components/radio-card.tsx +63 -63
  126. package/src/components/scroll-to-bottom-btn.tsx +28 -28
  127. package/src/components/split-line.tsx +9 -9
  128. package/src/components/square-checker.tsx +87 -87
  129. package/src/components/subform-fields-value-checker.tsx +184 -184
  130. package/src/components/tab-radio-group.tsx +83 -83
  131. package/src/components/tooltip.tsx +53 -53
  132. package/src/components/ui/button.tsx +51 -51
  133. package/src/components/ui/calendar.tsx +57 -57
  134. package/src/components/ui/dialog.tsx +104 -104
  135. package/src/components/ui/drawer.tsx +279 -279
  136. package/src/components/ui/form.tsx +202 -202
  137. package/src/components/ui/icons.tsx +1267 -1267
  138. package/src/components/ui/input.tsx +28 -28
  139. package/src/components/ui/label.tsx +30 -30
  140. package/src/components/ui/popover.tsx +85 -85
  141. package/src/components/ui/select.tsx +236 -236
  142. package/src/components/ui/spinner.tsx +17 -17
  143. package/src/components/ui/switch.tsx +33 -33
  144. package/src/components/ui/tabs.tsx +62 -62
  145. package/src/components/ui/textarea.tsx +28 -28
  146. package/src/components/ui/tooltip.tsx +53 -53
  147. package/src/components/user-txt-msg-bubble.tsx +47 -47
  148. package/src/components/warning-msg.tsx +27 -27
  149. package/src/const/ui.ts +119 -119
  150. package/src/css.d.ts +4 -4
  151. package/src/hooks/use-column-appear.ts +78 -78
  152. package/src/hooks/use-portal-container.ts +27 -27
  153. package/src/hooks/use-resizable-width.ts +129 -129
  154. package/src/hooks/use-select-popover-position.ts +74 -74
  155. package/src/hooks/use-shadow.ts +127 -127
  156. package/src/index.ts +226 -226
  157. package/src/lib/utils.ts +138 -138
  158. package/src/stories/AbsFullscreenGradientBg.stories.tsx +36 -36
  159. package/src/stories/AgentCategorySelectMenu.stories.tsx +33 -33
  160. package/src/stories/AgentEntryCard.stories.tsx +90 -90
  161. package/src/stories/AgentHelperCard.stories.tsx +105 -105
  162. package/src/stories/AgentHelperCardList.stories.tsx +120 -120
  163. package/src/stories/AgentHelperMainLayout.stories.tsx +71 -71
  164. package/src/stories/AgentScrollSelector.stories.tsx +95 -95
  165. package/src/stories/AgentSelect.stories.tsx +134 -134
  166. package/src/stories/AgentTag.stories.tsx +44 -44
  167. package/src/stories/AppSelect.stories.tsx +250 -250
  168. package/src/stories/AttachmentPart.stories.tsx +122 -122
  169. package/src/stories/AttachmentPartGroup.stories.tsx +152 -152
  170. package/src/stories/AttachmentsPreviewer.stories.tsx +306 -306
  171. package/src/stories/BaseButton.stories.tsx +33 -33
  172. package/src/stories/BorderAnimation.stories.tsx +116 -116
  173. package/src/stories/BorderColorAnimation.stories.tsx +63 -63
  174. package/src/stories/BotAvatarAndName.stories.ts +24 -24
  175. package/src/stories/BotIcon.stories.ts +22 -22
  176. package/src/stories/BsConditionInput.stories.tsx +460 -460
  177. package/src/stories/BsEntrySelect.stories.tsx +343 -343
  178. package/src/stories/BsTooltip.stories.tsx +32 -32
  179. package/src/stories/Card.stories.tsx +28 -28
  180. package/src/stories/CardField.stories.tsx +87 -87
  181. package/src/stories/ChatAreaHeader.stories.ts +26 -26
  182. package/src/stories/CheckCard.stories.tsx +114 -114
  183. package/src/stories/CircleChecker.stories.tsx +89 -89
  184. package/src/stories/CollapsibleTextMsg.stories.ts +44 -44
  185. package/src/stories/ConditionGroup.stories.tsx +216 -216
  186. package/src/stories/ConditionInput.stories.tsx +502 -502
  187. package/src/stories/ConditionItem.stories.tsx +163 -163
  188. package/src/stories/ConditonQuantifierSelect.stories.tsx +54 -54
  189. package/src/stories/ConditonTriggerDescription.stories.tsx +61 -61
  190. package/src/stories/ConfirmDialog.stories.tsx +123 -123
  191. package/src/stories/DataTable.stories.tsx +191 -191
  192. package/src/stories/DatePicker.stories.tsx +174 -174
  193. package/src/stories/ExecLogFilter.stories.tsx +145 -145
  194. package/src/stories/FakeBotMsg.stories.tsx +36 -36
  195. package/src/stories/FieldEditPreferenceSelect.stories.tsx +161 -161
  196. package/src/stories/FieldSelect.stories.tsx +228 -228
  197. package/src/stories/FieldValueInput.stories.tsx +442 -442
  198. package/src/stories/FlowNodeActionTriggerSelect.stories.tsx +80 -80
  199. package/src/stories/Form.stories.tsx +302 -302
  200. package/src/stories/FormActionTriggerSelect.stories.tsx +80 -80
  201. package/src/stories/FormDivider.stories.tsx +31 -31
  202. package/src/stories/FormInfoEditor.stories.tsx +173 -173
  203. package/src/stories/FormSelect.stories.tsx +222 -222
  204. package/src/stories/FormulaTag.stories.tsx +68 -68
  205. package/src/stories/GenerateAnimation.stories.ts +20 -20
  206. package/src/stories/IconBtn.stories.tsx +32 -32
  207. package/src/stories/IconCard.stories.tsx +35 -35
  208. package/src/stories/IconLib.tsx +45 -45
  209. package/src/stories/Icons.stories.ts +22 -22
  210. package/src/stories/ImgMsgPart.stories.tsx +42 -42
  211. package/src/stories/Input.stories.tsx +102 -102
  212. package/src/stories/Label.stories.tsx +66 -66
  213. package/src/stories/LegacySlot.stories.tsx +56 -56
  214. package/src/stories/LineChecker.stories.tsx +133 -133
  215. package/src/stories/LinearGradientBorderBtn.stories.tsx +86 -86
  216. package/src/stories/LinearGradientColorBgAnimation.stories.tsx +60 -60
  217. package/src/stories/MemoizedMarkdown.stories.tsx +102 -102
  218. package/src/stories/MessageContent.stories.tsx +36 -36
  219. package/src/stories/MonthdaysSelect.stories.tsx +78 -78
  220. package/src/stories/NumbersMsgPart.stories.tsx +42 -42
  221. package/src/stories/OfficeContainer.stories.tsx +287 -287
  222. package/src/stories/OffsetPreferenceSelect.stories.tsx +118 -118
  223. package/src/stories/OffsetTypeSelect.stories.tsx +75 -75
  224. package/src/stories/OffsetUnitSelect.stories.tsx +61 -61
  225. package/src/stories/OptionItem.stories.tsx +77 -77
  226. package/src/stories/OutputConfigEditor.stories.tsx +96 -96
  227. package/src/stories/PlaceholderCard.stories.tsx +35 -35
  228. package/src/stories/PreviewerHeader.stories.tsx +91 -91
  229. package/src/stories/PrimaryConfirmBtn.stories.tsx +60 -60
  230. package/src/stories/PrimaryEntryBtn.stories.tsx +74 -74
  231. package/src/stories/PromptInput.stories.tsx +228 -228
  232. package/src/stories/RadioCard.stories.tsx +103 -103
  233. package/src/stories/RelationalOperatorSelect.stories.tsx +61 -61
  234. package/src/stories/RepeatByTypeSelect.stories.tsx +58 -58
  235. package/src/stories/RepeatPreferenceSelect.stories.tsx +107 -107
  236. package/src/stories/RepeatPreferenceTypeSelect.stories.tsx +58 -58
  237. package/src/stories/ScrollToBottom.stories.tsx +24 -24
  238. package/src/stories/SearchInput.stories.tsx +50 -50
  239. package/src/stories/Select.stories.tsx +128 -128
  240. package/src/stories/SplitLine.stories.tsx +40 -40
  241. package/src/stories/SquareChecker.stories.tsx +96 -96
  242. package/src/stories/TabRadioGroup.stories.tsx +84 -84
  243. package/src/stories/Textarea.stories.tsx +67 -67
  244. package/src/stories/TriggerSelect.stories.tsx +48 -48
  245. package/src/stories/TriggerTimePreferenceSelect.stories.tsx +106 -106
  246. package/src/stories/TriggerTimeSourceTypeSelect.stories.tsx +68 -68
  247. package/src/stories/UserTextMsgBubble.stories.ts +24 -24
  248. package/src/stories/WarningMessage.stories.tsx +23 -23
  249. package/src/stories/WeekdaysSelect.stories.tsx +66 -66
  250. package/src/stories/assets/demo.css +539 -539
  251. package/src/stories/assets/demo_index.html +7988 -7988
  252. package/src/stories/assets/iconfont.css +1377 -1377
  253. package/src/stories/assets/iconfont.json +2382 -2382
  254. package/src/stories/assets/iconfont.svg +697 -697
  255. package/src/stories/collapsible.stories.tsx +47 -47
  256. package/src/stories/drawer.stories.tsx +196 -196
  257. package/src/stories/field-checker-list-msg.stories.tsx +95 -95
  258. package/src/stories/field-checker.stories.tsx +117 -117
  259. package/src/stories/field-icon.stories.tsx +70 -70
  260. package/src/stories/field-value-checker.stories.tsx +113 -113
  261. package/src/stories/fields-design-info-table.stories.tsx +203 -203
  262. package/src/stories/fields-generating.stories.tsx +41 -41
  263. package/src/stories/fields-previewer.stories.tsx +77 -77
  264. package/src/stories/subform-fields-value-checker.stories.tsx +98 -98
  265. package/src/style.css +226 -226
  266. package/src/types.ts +8 -8
  267. package/style.css +3652 -3652
  268. package/tsconfig.json +13 -13
  269. package/vite.config.ts +44 -44
@@ -1,327 +1,327 @@
1
- import { useState, useCallback, useMemo, useEffect } from 'react';
2
- import { ChevronLeft, ChevronRight } from 'lucide-react';
3
- import { cn } from '../../../lib/utils';
4
- import { CalendarPanel } from './calendar-panel';
5
- import { MonthPanel } from './month-panel';
6
- import { YearPanel } from './year-panel';
7
- import { TimePanel } from './time-panel';
8
- import { FooterPanel } from './footer-panel';
9
- import {
10
- MIN_YEAR,
11
- MAX_YEAR,
12
- MONTH_NAMES,
13
- getDaysInMonth,
14
- checkDateValidate,
15
- getCloserDate,
16
- } from './utils';
17
- import type { DatePickerProps, TimeObj } from './types';
18
-
19
- export type { DateFormat, DatePickerProps } from './types';
20
-
21
- export function DatePicker({
22
- value,
23
- onChange,
24
- format = 'yyyy-MM-dd',
25
- minDate: minDateProp,
26
- maxDate: maxDateProp,
27
- week: weekProp,
28
- className,
29
- }: DatePickerProps) {
30
- const initialDate = value ? new Date(value) : new Date();
31
-
32
- const [year, setYear] = useState(initialDate.getFullYear());
33
- const [month, setMonth] = useState(initialDate.getMonth());
34
- const [day, setDay] = useState(initialDate.getDate());
35
- const [hours, setHours] = useState(initialDate.getHours());
36
- const [minutes, setMinutes] = useState(initialDate.getMinutes());
37
- const [seconds, setSeconds] = useState(initialDate.getSeconds());
38
- const [showMonth, setShowMonth] = useState(false);
39
- const [showYear, setShowYear] = useState(false);
40
- const [showHms, setShowHms] = useState(format.includes('HH'));
41
-
42
- const minDate = useMemo(
43
- () => minDateProp ?? new Date(MIN_YEAR, 0, 1, 0, 0, 0, 0),
44
- [minDateProp]
45
- );
46
- const maxDate = useMemo(
47
- () => maxDateProp ?? new Date(MAX_YEAR, 11, 31, 23, 59, 59, 999),
48
- [maxDateProp]
49
- );
50
- const week = useMemo(
51
- () => (weekProp ? weekProp.map((i) => parseInt(String(i))) : []),
52
- [weekProp]
53
- );
54
-
55
- const startTime = useMemo<TimeObj>(() => {
56
- if (format === 'yyyy-MM-dd HH:mm:ss') {
57
- return { h: minDate.getHours(), m: minDate.getMinutes(), s: minDate.getSeconds(), ms: minDate.getMilliseconds() };
58
- }
59
- return { h: 0, m: 0, s: 0, ms: 0 };
60
- }, [format, minDate]);
61
-
62
- const endTime = useMemo<TimeObj>(() => {
63
- if (format === 'yyyy-MM-dd HH:mm:ss') {
64
- return { h: maxDate.getHours(), m: maxDate.getMinutes(), s: maxDate.getSeconds(), ms: maxDate.getMilliseconds() };
65
- }
66
- return { h: 23, m: 59, s: 59, ms: 999 };
67
- }, [format, maxDate]);
68
-
69
- // Sync with external value
70
- useEffect(() => {
71
- if (value) {
72
- setYear(value.getFullYear());
73
- setMonth(value.getMonth());
74
- setDay(value.getDate());
75
- setHours(value.getHours());
76
- setMinutes(value.getMinutes());
77
- setSeconds(value.getSeconds());
78
- }
79
- }, [value]);
80
-
81
- // Auto-select closer valid date on mount when value is null
82
- useEffect(() => {
83
- if (!value && checkDateValidate(new Date(), minDate, maxDate, week, 'day')) {
84
- const closerDate = getCloserDate(new Date(), minDate, maxDate);
85
- setYear(closerDate.getFullYear());
86
- setMonth(closerDate.getMonth());
87
- setDay(closerDate.getDate());
88
- }
89
- }, []);
90
-
91
- const fireOnChange = useCallback(
92
- (d: Date | null, closeFloat?: boolean) => onChange?.(d, closeFloat),
93
- [onChange]
94
- );
95
-
96
- const checkValidate = useCallback(
97
- (d: Date, mode: 'day' | 'month' | 'year' = 'day') =>
98
- checkDateValidate(d, minDate, maxDate, week, mode),
99
- [minDate, maxDate, week]
100
- );
101
-
102
- const onDateUpdate = useCallback(
103
- (closeFloat?: boolean) => {
104
- const d = new Date(year, month, day, hours, minutes, seconds);
105
- fireOnChange(checkValidate(d) ? d : null, closeFloat);
106
- },
107
- [year, month, day, hours, minutes, seconds, checkValidate, fireOnChange]
108
- );
109
-
110
- const handleMonthReduce = useCallback(() => {
111
- let newYear = year, newMonth = month, newDay = day;
112
- if (month === 0) { newMonth = 11; newYear = year - 1; }
113
- else { newMonth = month - 1; }
114
- const dim = getDaysInMonth(newYear, newMonth);
115
- if (newDay > dim) newDay = dim;
116
- setYear(newYear); setMonth(newMonth); setDay(newDay);
117
- }, [year, month, day]);
118
-
119
- const handleMonthAdd = useCallback(() => {
120
- let newYear = year, newMonth = month, newDay = day;
121
- if (month === 11) { newMonth = 0; newYear = year + 1; }
122
- else { newMonth = month + 1; }
123
- const dim = getDaysInMonth(newYear, newMonth);
124
- if (newDay > dim) newDay = dim;
125
- setYear(newYear); setMonth(newMonth); setDay(newDay);
126
- }, [year, month, day]);
127
-
128
- const handleYearReduce = useCallback(() => { if (year > MIN_YEAR) setYear((y) => y - 1); }, [year]);
129
- const handleYearAdd = useCallback(() => { if (year < MAX_YEAR) setYear((y) => y + 1); }, [year]);
130
- const handleYearFReduce = useCallback(() => { if (year > MIN_YEAR) setYear((y) => y - 20); }, [year]);
131
- const handleYearFAdd = useCallback(() => { if (year < MAX_YEAR) setYear((y) => y + 20); }, [year]);
132
-
133
- const handleSelectYear = useCallback((selectedYear: number) => {
134
- setYear(selectedYear);
135
- setShowYear(false);
136
- if (format === 'yyyy-MM') { setDay(1); setHours(0); setMinutes(0); setSeconds(0); setShowMonth(false); }
137
- if (format === 'yyyy') {
138
- const newDate = new Date(selectedYear, 0, 1, 0, 0, 0);
139
- fireOnChange(checkValidate(newDate, 'year') ? newDate : null, true);
140
- }
141
- setShowHms(format.includes('HH'));
142
- }, [format, checkValidate, fireOnChange]);
143
-
144
- const handleMountOk = useCallback((m: number) => {
145
- setMonth(m);
146
- setShowMonth(false);
147
- setShowYear(false);
148
- if (format === 'yyyy-MM') {
149
- setDay(1); setHours(0); setMinutes(0); setSeconds(0);
150
- const newDate = new Date(year, m, 1, 0, 0, 0);
151
- fireOnChange(checkValidate(newDate, 'month') ? newDate : null, true);
152
- }
153
- setShowHms(format.includes('HH'));
154
- }, [format, year, checkValidate, fireOnChange]);
155
-
156
- const handleChangeDay = useCallback((d: number, m: number, y: number, css: string) => {
157
- if (css.includes('disabled')) return;
158
- setYear(y); setMonth(m); setDay(d);
159
- if (!['HH:mm:ss', 'yyyy-MM-dd HH:mm:ss', 'yyyy-MM-dd HH:mm', 'HH:mm'].includes(format)) {
160
- const newDate = new Date(y, m, d, 0, 0, 0);
161
- fireOnChange(checkValidate(newDate) ? newDate : null, true);
162
- }
163
- }, [format, checkValidate, fireOnChange]);
164
-
165
- const handleToDay = useCallback(() => {
166
- const today = new Date();
167
- setYear(today.getFullYear()); setMonth(today.getMonth()); setDay(today.getDate());
168
- setHours(today.getHours()); setMinutes(today.getMinutes()); setSeconds(today.getSeconds());
169
- if (!['HH:mm:ss', 'yyyy-MM-dd HH:mm:ss', 'yyyy-MM-dd HH:mm', 'HH:mm'].includes(format)) {
170
- const newDate = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);
171
- fireOnChange(checkValidate(newDate) ? newDate : null, true);
172
- }
173
- }, [format, checkValidate, fireOnChange]);
174
-
175
- const handleOkDay = useCallback(() => onDateUpdate(true), [onDateUpdate]);
176
-
177
- const checkValiToday = useCallback(
178
- (date?: Date) => checkDateValidate(date ?? new Date(), minDate, maxDate, week, 'day') ? '' : 'disabled',
179
- [minDate, maxDate, week]
180
- );
181
-
182
- const handleHoursChange = useCallback((v: number) => setHours(v), []);
183
- const handleMinutesChange = useCallback((v: number) => setMinutes(v), []);
184
- const handleSecondsChange = useCallback((v: number) => setSeconds(v), []);
185
-
186
- const hasDatePart = format.includes('yyyy');
187
- const hasTimePart = format.includes('HH');
188
- const hasDayPart = format.includes('dd');
189
- const isMonthOnly = format === 'yyyy-MM';
190
- const isYearOnly = format === 'yyyy';
191
- const todayCls = checkValiToday();
192
-
193
- const openMonthMenu = useCallback(() => { setShowMonth(true); setShowYear(false); setShowHms(false); }, []);
194
- const openYearMenu = useCallback(() => { setShowYear(true); setShowHms(false); }, []);
195
-
196
- const dataRangeMinHeight = hasDayPart ? 'min-h-[270px]' : (isMonthOnly ? 'min-h-[180px]' : 'min-h-[270px]');
197
-
198
- return (
199
- <div className={cn('relative inline-block text-sm text-[#333] bg-white rounded-[4px] leading-none border-none', format, className)}>
200
- <div className="flex">
201
- {hasDatePart && (
202
- <div className={cn('data-range', dataRangeMinHeight)} style={{ minWidth: isYearOnly ? 220 : 270 }}>
203
- {/* Calendar with day grid, OR month-only picker */}
204
- {!isYearOnly && (
205
- <div className="relative">
206
- <table cellSpacing={0} cellPadding={0} className="dt p-[3px] rounded-[4px]" style={{ width: isMonthOnly ? '100%' : 270 }}>
207
- {/* Month-only: show month picker with year header */}
208
- {isMonthOnly && !showYear && (
209
- <>
210
- <thead>
211
- <tr>
212
- <td className="text-center p-0.5 min-w-[36px] h-[36px] cursor-pointer align-middle rounded-[4px] btn prevy hover:text-[#0265ff] grid place-content-center" colSpan={1} onClick={handleYearReduce}>
213
- <ChevronLeft size={14} className="inline" />
214
- </td>
215
- <td className="text-center p-0.5 min-w-[36px] h-[36px] cursor-pointer align-middle rounded-[4px] year title font-bold" colSpan={1}>
216
- <span className="title-year hover:text-[#0265ff] cursor-pointer" onClick={openYearMenu}>{year}</span>
217
- </td>
218
- <td className="text-center p-0.5 min-w-[36px] h-[36px] cursor-pointer align-middle rounded-[4px] btn nexty hover:text-[#0265ff] grid place-content-center" colSpan={1} onClick={handleYearAdd}>
219
- <ChevronRight size={14} className="inline" />
220
- </td>
221
- </tr>
222
- </thead>
223
- <tbody>
224
- {[0, 1, 2].map((rowIdx) => (
225
- <tr key={rowIdx}>
226
- {[0, 1, 2].map((colIdx) => {
227
- const m = rowIdx * 3 + colIdx;
228
- const valid = checkValidate(new Date(year, m, 1), 'month');
229
- const isSelected = month === m;
230
- const isDisabled = !valid;
231
- return (
232
- <td
233
- key={m}
234
- className={cn(
235
- 'text-center p-0.5 min-w-[36px] h-[36px] cursor-pointer align-middle rounded-[4px] month hover:bg-[rgba(2,101,255,0.08)]',
236
- isSelected && 'font-bold p-[1px] text-white border border-[#0265ff] bg-[#0265ff] hover:border-[#0265ff] hover:bg-[#0265ff]',
237
- isDisabled && 'text-[#999] relative pointer-events-none before:absolute before:left-0 before:right-0 before:top-[14px] before:h-[28px] before:bg-[#f3f3f3] before:opacity-60 before:content-[""]'
238
- )}
239
- onClick={() => { if (!isDisabled) handleMountOk(m); }}
240
- >
241
- {MONTH_NAMES[m]}
242
- </td>
243
- );
244
- })}
245
- </tr>
246
- ))}
247
- </tbody>
248
- </>
249
- )}
250
-
251
- {/* Day grid: full calendar */}
252
- {hasDayPart && (
253
- <CalendarPanel
254
- year={year} month={month} day={day}
255
- format={format} minDate={minDate} maxDate={maxDate} week={week}
256
- onYearReduce={handleYearReduce} onYearAdd={handleYearAdd}
257
- onMonthReduce={handleMonthReduce} onMonthAdd={handleMonthAdd}
258
- onMonthMenu={openMonthMenu} onYearMenu={openYearMenu}
259
- onChangeDay={handleChangeDay}
260
- />
261
- )}
262
- </table>
263
-
264
- {/* Month picker overlay (for day formats) */}
265
- {hasDayPart && !isMonthOnly && showMonth && !showYear && (
266
- <div className="absolute inset-0 z-[1]">
267
- <MonthPanel
268
- year={year} month={month} showYear={showYear}
269
- position="absolute" minDate={minDate} maxDate={maxDate} week={week}
270
- onYearReduce={handleYearReduce} onYearAdd={handleYearAdd}
271
- onYearMenu={openYearMenu} onMountOk={handleMountOk}
272
- />
273
- </div>
274
- )}
275
-
276
- {/* Year picker overlay (for day/month formats) */}
277
- {!isYearOnly && showYear && (
278
- <div className={cn(isMonthOnly ? 'relative' : 'absolute inset-0 z-[1]')}>
279
- <YearPanel
280
- year={year} position={isMonthOnly ? 'relative' : 'absolute'}
281
- showYearLabel={isMonthOnly}
282
- minDate={minDate} maxDate={maxDate} week={week}
283
- onYearFReduce={handleYearFReduce} onYearFAdd={handleYearFAdd}
284
- onSelectYear={handleSelectYear}
285
- />
286
- </div>
287
- )}
288
- </div>
289
- )}
290
-
291
- {/* Year-only mode */}
292
- {isYearOnly && (
293
- <YearPanel
294
- year={year} position="relative" showYearLabel
295
- minDate={minDate} maxDate={maxDate} week={week}
296
- onYearFReduce={handleYearFReduce} onYearFAdd={handleYearFAdd}
297
- onSelectYear={handleSelectYear}
298
- />
299
- )}
300
- </div>
301
- )}
302
-
303
- {/* Time picker */}
304
- {showHms && hasTimePart && (
305
- <TimePanel
306
- hours={hours} minutes={minutes} seconds={seconds}
307
- year={year} month={month} day={day}
308
- format={format} minDate={minDate} maxDate={maxDate}
309
- startTime={startTime} endTime={endTime}
310
- onHoursChange={handleHoursChange}
311
- onMinutesChange={handleMinutesChange}
312
- onSecondsChange={handleSecondsChange}
313
- />
314
- )}
315
- </div>
316
-
317
- {/* Footer */}
318
- <FooterPanel
319
- hasTime={hasTimePart}
320
- hasDay={hasDayPart}
321
- todayCls={todayCls}
322
- onToday={handleToDay}
323
- onOk={handleOkDay}
324
- />
325
- </div>
326
- );
327
- }
1
+ import { useState, useCallback, useMemo, useEffect } from 'react';
2
+ import { ChevronLeft, ChevronRight } from 'lucide-react';
3
+ import { cn } from '../../../lib/utils';
4
+ import { CalendarPanel } from './calendar-panel';
5
+ import { MonthPanel } from './month-panel';
6
+ import { YearPanel } from './year-panel';
7
+ import { TimePanel } from './time-panel';
8
+ import { FooterPanel } from './footer-panel';
9
+ import {
10
+ MIN_YEAR,
11
+ MAX_YEAR,
12
+ MONTH_NAMES,
13
+ getDaysInMonth,
14
+ checkDateValidate,
15
+ getCloserDate,
16
+ } from './utils';
17
+ import type { DatePickerProps, TimeObj } from './types';
18
+
19
+ export type { DateFormat, DatePickerProps } from './types';
20
+
21
+ export function DatePicker({
22
+ value,
23
+ onChange,
24
+ format = 'yyyy-MM-dd',
25
+ minDate: minDateProp,
26
+ maxDate: maxDateProp,
27
+ week: weekProp,
28
+ className,
29
+ }: DatePickerProps) {
30
+ const initialDate = value ? new Date(value) : new Date();
31
+
32
+ const [year, setYear] = useState(initialDate.getFullYear());
33
+ const [month, setMonth] = useState(initialDate.getMonth());
34
+ const [day, setDay] = useState(initialDate.getDate());
35
+ const [hours, setHours] = useState(initialDate.getHours());
36
+ const [minutes, setMinutes] = useState(initialDate.getMinutes());
37
+ const [seconds, setSeconds] = useState(initialDate.getSeconds());
38
+ const [showMonth, setShowMonth] = useState(false);
39
+ const [showYear, setShowYear] = useState(false);
40
+ const [showHms, setShowHms] = useState(format.includes('HH'));
41
+
42
+ const minDate = useMemo(
43
+ () => minDateProp ?? new Date(MIN_YEAR, 0, 1, 0, 0, 0, 0),
44
+ [minDateProp]
45
+ );
46
+ const maxDate = useMemo(
47
+ () => maxDateProp ?? new Date(MAX_YEAR, 11, 31, 23, 59, 59, 999),
48
+ [maxDateProp]
49
+ );
50
+ const week = useMemo(
51
+ () => (weekProp ? weekProp.map((i) => parseInt(String(i))) : []),
52
+ [weekProp]
53
+ );
54
+
55
+ const startTime = useMemo<TimeObj>(() => {
56
+ if (format === 'yyyy-MM-dd HH:mm:ss') {
57
+ return { h: minDate.getHours(), m: minDate.getMinutes(), s: minDate.getSeconds(), ms: minDate.getMilliseconds() };
58
+ }
59
+ return { h: 0, m: 0, s: 0, ms: 0 };
60
+ }, [format, minDate]);
61
+
62
+ const endTime = useMemo<TimeObj>(() => {
63
+ if (format === 'yyyy-MM-dd HH:mm:ss') {
64
+ return { h: maxDate.getHours(), m: maxDate.getMinutes(), s: maxDate.getSeconds(), ms: maxDate.getMilliseconds() };
65
+ }
66
+ return { h: 23, m: 59, s: 59, ms: 999 };
67
+ }, [format, maxDate]);
68
+
69
+ // Sync with external value
70
+ useEffect(() => {
71
+ if (value) {
72
+ setYear(value.getFullYear());
73
+ setMonth(value.getMonth());
74
+ setDay(value.getDate());
75
+ setHours(value.getHours());
76
+ setMinutes(value.getMinutes());
77
+ setSeconds(value.getSeconds());
78
+ }
79
+ }, [value]);
80
+
81
+ // Auto-select closer valid date on mount when value is null
82
+ useEffect(() => {
83
+ if (!value && checkDateValidate(new Date(), minDate, maxDate, week, 'day')) {
84
+ const closerDate = getCloserDate(new Date(), minDate, maxDate);
85
+ setYear(closerDate.getFullYear());
86
+ setMonth(closerDate.getMonth());
87
+ setDay(closerDate.getDate());
88
+ }
89
+ }, []);
90
+
91
+ const fireOnChange = useCallback(
92
+ (d: Date | null, closeFloat?: boolean) => onChange?.(d, closeFloat),
93
+ [onChange]
94
+ );
95
+
96
+ const checkValidate = useCallback(
97
+ (d: Date, mode: 'day' | 'month' | 'year' = 'day') =>
98
+ checkDateValidate(d, minDate, maxDate, week, mode),
99
+ [minDate, maxDate, week]
100
+ );
101
+
102
+ const onDateUpdate = useCallback(
103
+ (closeFloat?: boolean) => {
104
+ const d = new Date(year, month, day, hours, minutes, seconds);
105
+ fireOnChange(checkValidate(d) ? d : null, closeFloat);
106
+ },
107
+ [year, month, day, hours, minutes, seconds, checkValidate, fireOnChange]
108
+ );
109
+
110
+ const handleMonthReduce = useCallback(() => {
111
+ let newYear = year, newMonth = month, newDay = day;
112
+ if (month === 0) { newMonth = 11; newYear = year - 1; }
113
+ else { newMonth = month - 1; }
114
+ const dim = getDaysInMonth(newYear, newMonth);
115
+ if (newDay > dim) newDay = dim;
116
+ setYear(newYear); setMonth(newMonth); setDay(newDay);
117
+ }, [year, month, day]);
118
+
119
+ const handleMonthAdd = useCallback(() => {
120
+ let newYear = year, newMonth = month, newDay = day;
121
+ if (month === 11) { newMonth = 0; newYear = year + 1; }
122
+ else { newMonth = month + 1; }
123
+ const dim = getDaysInMonth(newYear, newMonth);
124
+ if (newDay > dim) newDay = dim;
125
+ setYear(newYear); setMonth(newMonth); setDay(newDay);
126
+ }, [year, month, day]);
127
+
128
+ const handleYearReduce = useCallback(() => { if (year > MIN_YEAR) setYear((y) => y - 1); }, [year]);
129
+ const handleYearAdd = useCallback(() => { if (year < MAX_YEAR) setYear((y) => y + 1); }, [year]);
130
+ const handleYearFReduce = useCallback(() => { if (year > MIN_YEAR) setYear((y) => y - 20); }, [year]);
131
+ const handleYearFAdd = useCallback(() => { if (year < MAX_YEAR) setYear((y) => y + 20); }, [year]);
132
+
133
+ const handleSelectYear = useCallback((selectedYear: number) => {
134
+ setYear(selectedYear);
135
+ setShowYear(false);
136
+ if (format === 'yyyy-MM') { setDay(1); setHours(0); setMinutes(0); setSeconds(0); setShowMonth(false); }
137
+ if (format === 'yyyy') {
138
+ const newDate = new Date(selectedYear, 0, 1, 0, 0, 0);
139
+ fireOnChange(checkValidate(newDate, 'year') ? newDate : null, true);
140
+ }
141
+ setShowHms(format.includes('HH'));
142
+ }, [format, checkValidate, fireOnChange]);
143
+
144
+ const handleMountOk = useCallback((m: number) => {
145
+ setMonth(m);
146
+ setShowMonth(false);
147
+ setShowYear(false);
148
+ if (format === 'yyyy-MM') {
149
+ setDay(1); setHours(0); setMinutes(0); setSeconds(0);
150
+ const newDate = new Date(year, m, 1, 0, 0, 0);
151
+ fireOnChange(checkValidate(newDate, 'month') ? newDate : null, true);
152
+ }
153
+ setShowHms(format.includes('HH'));
154
+ }, [format, year, checkValidate, fireOnChange]);
155
+
156
+ const handleChangeDay = useCallback((d: number, m: number, y: number, css: string) => {
157
+ if (css.includes('disabled')) return;
158
+ setYear(y); setMonth(m); setDay(d);
159
+ if (!['HH:mm:ss', 'yyyy-MM-dd HH:mm:ss', 'yyyy-MM-dd HH:mm', 'HH:mm'].includes(format)) {
160
+ const newDate = new Date(y, m, d, 0, 0, 0);
161
+ fireOnChange(checkValidate(newDate) ? newDate : null, true);
162
+ }
163
+ }, [format, checkValidate, fireOnChange]);
164
+
165
+ const handleToDay = useCallback(() => {
166
+ const today = new Date();
167
+ setYear(today.getFullYear()); setMonth(today.getMonth()); setDay(today.getDate());
168
+ setHours(today.getHours()); setMinutes(today.getMinutes()); setSeconds(today.getSeconds());
169
+ if (!['HH:mm:ss', 'yyyy-MM-dd HH:mm:ss', 'yyyy-MM-dd HH:mm', 'HH:mm'].includes(format)) {
170
+ const newDate = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);
171
+ fireOnChange(checkValidate(newDate) ? newDate : null, true);
172
+ }
173
+ }, [format, checkValidate, fireOnChange]);
174
+
175
+ const handleOkDay = useCallback(() => onDateUpdate(true), [onDateUpdate]);
176
+
177
+ const checkValiToday = useCallback(
178
+ (date?: Date) => checkDateValidate(date ?? new Date(), minDate, maxDate, week, 'day') ? '' : 'disabled',
179
+ [minDate, maxDate, week]
180
+ );
181
+
182
+ const handleHoursChange = useCallback((v: number) => setHours(v), []);
183
+ const handleMinutesChange = useCallback((v: number) => setMinutes(v), []);
184
+ const handleSecondsChange = useCallback((v: number) => setSeconds(v), []);
185
+
186
+ const hasDatePart = format.includes('yyyy');
187
+ const hasTimePart = format.includes('HH');
188
+ const hasDayPart = format.includes('dd');
189
+ const isMonthOnly = format === 'yyyy-MM';
190
+ const isYearOnly = format === 'yyyy';
191
+ const todayCls = checkValiToday();
192
+
193
+ const openMonthMenu = useCallback(() => { setShowMonth(true); setShowYear(false); setShowHms(false); }, []);
194
+ const openYearMenu = useCallback(() => { setShowYear(true); setShowHms(false); }, []);
195
+
196
+ const dataRangeMinHeight = hasDayPart ? 'min-h-[270px]' : (isMonthOnly ? 'min-h-[180px]' : 'min-h-[270px]');
197
+
198
+ return (
199
+ <div className={cn('relative inline-block text-sm text-[#333] bg-white rounded-[4px] leading-none border-none', format, className)}>
200
+ <div className="flex">
201
+ {hasDatePart && (
202
+ <div className={cn('data-range', dataRangeMinHeight)} style={{ minWidth: isYearOnly ? 220 : 270 }}>
203
+ {/* Calendar with day grid, OR month-only picker */}
204
+ {!isYearOnly && (
205
+ <div className="relative">
206
+ <table cellSpacing={0} cellPadding={0} className="dt p-[3px] rounded-[4px]" style={{ width: isMonthOnly ? '100%' : 270 }}>
207
+ {/* Month-only: show month picker with year header */}
208
+ {isMonthOnly && !showYear && (
209
+ <>
210
+ <thead>
211
+ <tr>
212
+ <td className="text-center p-0.5 min-w-[36px] h-[36px] cursor-pointer align-middle rounded-[4px] btn prevy hover:text-[#0265ff] grid place-content-center" colSpan={1} onClick={handleYearReduce}>
213
+ <ChevronLeft size={14} className="inline" />
214
+ </td>
215
+ <td className="text-center p-0.5 min-w-[36px] h-[36px] cursor-pointer align-middle rounded-[4px] year title font-bold" colSpan={1}>
216
+ <span className="title-year hover:text-[#0265ff] cursor-pointer" onClick={openYearMenu}>{year}</span>
217
+ </td>
218
+ <td className="text-center p-0.5 min-w-[36px] h-[36px] cursor-pointer align-middle rounded-[4px] btn nexty hover:text-[#0265ff] grid place-content-center" colSpan={1} onClick={handleYearAdd}>
219
+ <ChevronRight size={14} className="inline" />
220
+ </td>
221
+ </tr>
222
+ </thead>
223
+ <tbody>
224
+ {[0, 1, 2].map((rowIdx) => (
225
+ <tr key={rowIdx}>
226
+ {[0, 1, 2].map((colIdx) => {
227
+ const m = rowIdx * 3 + colIdx;
228
+ const valid = checkValidate(new Date(year, m, 1), 'month');
229
+ const isSelected = month === m;
230
+ const isDisabled = !valid;
231
+ return (
232
+ <td
233
+ key={m}
234
+ className={cn(
235
+ 'text-center p-0.5 min-w-[36px] h-[36px] cursor-pointer align-middle rounded-[4px] month hover:bg-[rgba(2,101,255,0.08)]',
236
+ isSelected && 'font-bold p-[1px] text-white border border-[#0265ff] bg-[#0265ff] hover:border-[#0265ff] hover:bg-[#0265ff]',
237
+ isDisabled && 'text-[#999] relative pointer-events-none before:absolute before:left-0 before:right-0 before:top-[14px] before:h-[28px] before:bg-[#f3f3f3] before:opacity-60 before:content-[""]'
238
+ )}
239
+ onClick={() => { if (!isDisabled) handleMountOk(m); }}
240
+ >
241
+ {MONTH_NAMES[m]}
242
+ </td>
243
+ );
244
+ })}
245
+ </tr>
246
+ ))}
247
+ </tbody>
248
+ </>
249
+ )}
250
+
251
+ {/* Day grid: full calendar */}
252
+ {hasDayPart && (
253
+ <CalendarPanel
254
+ year={year} month={month} day={day}
255
+ format={format} minDate={minDate} maxDate={maxDate} week={week}
256
+ onYearReduce={handleYearReduce} onYearAdd={handleYearAdd}
257
+ onMonthReduce={handleMonthReduce} onMonthAdd={handleMonthAdd}
258
+ onMonthMenu={openMonthMenu} onYearMenu={openYearMenu}
259
+ onChangeDay={handleChangeDay}
260
+ />
261
+ )}
262
+ </table>
263
+
264
+ {/* Month picker overlay (for day formats) */}
265
+ {hasDayPart && !isMonthOnly && showMonth && !showYear && (
266
+ <div className="absolute inset-0 z-[1]">
267
+ <MonthPanel
268
+ year={year} month={month} showYear={showYear}
269
+ position="absolute" minDate={minDate} maxDate={maxDate} week={week}
270
+ onYearReduce={handleYearReduce} onYearAdd={handleYearAdd}
271
+ onYearMenu={openYearMenu} onMountOk={handleMountOk}
272
+ />
273
+ </div>
274
+ )}
275
+
276
+ {/* Year picker overlay (for day/month formats) */}
277
+ {!isYearOnly && showYear && (
278
+ <div className={cn(isMonthOnly ? 'relative' : 'absolute inset-0 z-[1]')}>
279
+ <YearPanel
280
+ year={year} position={isMonthOnly ? 'relative' : 'absolute'}
281
+ showYearLabel={isMonthOnly}
282
+ minDate={minDate} maxDate={maxDate} week={week}
283
+ onYearFReduce={handleYearFReduce} onYearFAdd={handleYearFAdd}
284
+ onSelectYear={handleSelectYear}
285
+ />
286
+ </div>
287
+ )}
288
+ </div>
289
+ )}
290
+
291
+ {/* Year-only mode */}
292
+ {isYearOnly && (
293
+ <YearPanel
294
+ year={year} position="relative" showYearLabel
295
+ minDate={minDate} maxDate={maxDate} week={week}
296
+ onYearFReduce={handleYearFReduce} onYearFAdd={handleYearFAdd}
297
+ onSelectYear={handleSelectYear}
298
+ />
299
+ )}
300
+ </div>
301
+ )}
302
+
303
+ {/* Time picker */}
304
+ {showHms && hasTimePart && (
305
+ <TimePanel
306
+ hours={hours} minutes={minutes} seconds={seconds}
307
+ year={year} month={month} day={day}
308
+ format={format} minDate={minDate} maxDate={maxDate}
309
+ startTime={startTime} endTime={endTime}
310
+ onHoursChange={handleHoursChange}
311
+ onMinutesChange={handleMinutesChange}
312
+ onSecondsChange={handleSecondsChange}
313
+ />
314
+ )}
315
+ </div>
316
+
317
+ {/* Footer */}
318
+ <FooterPanel
319
+ hasTime={hasTimePart}
320
+ hasDay={hasDayPart}
321
+ todayCls={todayCls}
322
+ onToday={handleToDay}
323
+ onOk={handleOkDay}
324
+ />
325
+ </div>
326
+ );
327
+ }