@apexhub/apex-ui-react-source 0.0.0-stage → 1.2.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.
- package/LICENSE +21 -0
- package/README.md +97 -2
- package/bin/apex-ui-react-source.mjs +717 -0
- package/dist/files/AGENTS.md +89 -0
- package/dist/files/LICENSE +21 -0
- package/dist/files/_assets/adapt-to-page.raw.ts +3 -0
- package/dist/files/_assets/adapt-to-page.url.ts +3 -0
- package/dist/files/_assets/calendar.raw.ts +3 -0
- package/dist/files/_assets/doc-format.raw.ts +3 -0
- package/dist/files/_assets/docx-format.raw.ts +3 -0
- package/dist/files/_assets/full-screen.raw.ts +3 -0
- package/dist/files/_assets/full-screen.url.ts +3 -0
- package/dist/files/_assets/gif-format.raw.ts +3 -0
- package/dist/files/_assets/jpeg-format.raw.ts +3 -0
- package/dist/files/_assets/jpg-format.raw.ts +3 -0
- package/dist/files/_assets/ofd-format.raw.ts +3 -0
- package/dist/files/_assets/one-to-one.raw.ts +3 -0
- package/dist/files/_assets/one-to-one.url.ts +3 -0
- package/dist/files/_assets/pdf-format.raw.ts +3 -0
- package/dist/files/_assets/png-format.raw.ts +3 -0
- package/dist/files/_assets/rotate-left.raw.ts +3 -0
- package/dist/files/_assets/rotate-left.url.ts +3 -0
- package/dist/files/_assets/rotate-right.raw.ts +3 -0
- package/dist/files/_assets/rotate-right.url.ts +3 -0
- package/dist/files/_assets/table-empty.url.ts +3 -0
- package/dist/files/_assets/txt-format.raw.ts +3 -0
- package/dist/files/_assets/upload-file-doc-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-docx-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-gif-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-jpeg-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-jpg-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-ofd-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-pdf-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-png-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-txt-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-xlsx-20.raw.ts +3 -0
- package/dist/files/_assets/xlsx-format.raw.ts +3 -0
- package/dist/files/_assets/zoom-in.raw.ts +3 -0
- package/dist/files/_assets/zoom-in.url.ts +3 -0
- package/dist/files/_assets/zoom-out.raw.ts +3 -0
- package/dist/files/_assets/zoom-out.url.ts +3 -0
- package/dist/files/_headless/dismiss-intent.ts +1 -0
- package/dist/files/_headless/placement.ts +1 -0
- package/dist/files/_headless/use-embedded-scroll-lock-guard.ts +47 -0
- package/dist/files/_headless/use-floating-overlay.tsx +3 -0
- package/dist/files/_namespace/constants.ts +23 -0
- package/dist/files/_namespace/index.ts +1 -0
- package/dist/files/_overlay/auto-update-anchored-overlay.ts +11 -0
- package/dist/files/_overlay/collision-boundary.ts +78 -0
- package/dist/files/_overlay/dismiss-intent.ts +107 -0
- package/dist/files/_overlay/get-overlay-root.ts +157 -0
- package/dist/files/_overlay/index.ts +57 -0
- package/dist/files/_overlay/observe-anchor-lifecycle.ts +72 -0
- package/dist/files/_overlay/overlay-theme.ts +91 -0
- package/dist/files/_overlay/overlay-trigger.ts +100 -0
- package/dist/files/_overlay/overlay.css +29 -0
- package/dist/files/_overlay/placement.ts +18 -0
- package/dist/files/_overlay/resolve-portal-container.ts +13 -0
- package/dist/files/_overlay/use-anchored-overlay.tsx +493 -0
- package/dist/files/_overlay/zIndex.ts +17 -0
- package/dist/files/_tags/MaxTagList.tsx +336 -0
- package/dist/files/_tags/OverflowTagPopover.tsx +315 -0
- package/dist/files/_tags/get-max-tag-display.ts +26 -0
- package/dist/files/_tags/index.ts +15 -0
- package/dist/files/_tags/resolve-max-tag-popover.ts +28 -0
- package/dist/files/_tags/tags.css +126 -0
- package/dist/files/_tags/types.ts +46 -0
- package/dist/files/_tags/use-responsive-max-tag-count.ts +165 -0
- package/dist/files/alert/Alert.tsx +100 -0
- package/dist/files/alert/alert.css +85 -0
- package/dist/files/alert/index.ts +2 -0
- package/dist/files/alert/interface.ts +59 -0
- package/dist/files/alert/llm.txt +160 -0
- package/dist/files/alert/tokens.txt +44 -0
- package/dist/files/alert/variants.ts +17 -0
- package/dist/files/apex-env.d.ts +2 -0
- package/dist/files/apex-provider/ApexProvider.tsx +53 -0
- package/dist/files/apex-provider/apex-provider.css +0 -0
- package/dist/files/apex-provider/context.ts +17 -0
- package/dist/files/apex-provider/index.ts +18 -0
- package/dist/files/apex-provider/interface.ts +181 -0
- package/dist/files/apex-provider/llm.txt +367 -0
- package/dist/files/apex-provider/localeKind.ts +20 -0
- package/dist/files/auto-complete/AutoComplete.tsx +419 -0
- package/dist/files/auto-complete/auto-complete.css +108 -0
- package/dist/files/auto-complete/auto-complete.stories.css +17 -0
- package/dist/files/auto-complete/index.ts +8 -0
- package/dist/files/auto-complete/interface.ts +77 -0
- package/dist/files/auto-complete/llm.txt +374 -0
- package/dist/files/auto-complete/tokens.txt +77 -0
- package/dist/files/auto-complete/variants.ts +19 -0
- package/dist/files/avatar/Avatar.tsx +277 -0
- package/dist/files/avatar/avatar.css +159 -0
- package/dist/files/avatar/index.ts +2 -0
- package/dist/files/avatar/interface.ts +147 -0
- package/dist/files/avatar/llm.txt +195 -0
- package/dist/files/avatar/tokens.txt +38 -0
- package/dist/files/avatar/use-responsive-size.ts +66 -0
- package/dist/files/avatar/variants.ts +41 -0
- package/dist/files/breadcrumb/Breadcrumb.stories.css +5 -0
- package/dist/files/breadcrumb/Breadcrumb.tsx +238 -0
- package/dist/files/breadcrumb/BreadcrumbLink.tsx +63 -0
- package/dist/files/breadcrumb/BreadcrumbSeparatorIcon.tsx +30 -0
- package/dist/files/breadcrumb/breadcrumb.css +113 -0
- package/dist/files/breadcrumb/index.ts +12 -0
- package/dist/files/breadcrumb/interface.ts +81 -0
- package/dist/files/breadcrumb/llm.txt +249 -0
- package/dist/files/breadcrumb/tokens.txt +193 -0
- package/dist/files/breadcrumb/variants.ts +8 -0
- package/dist/files/button/Button.tsx +235 -0
- package/dist/files/button/button.css +261 -0
- package/dist/files/button/index.ts +2 -0
- package/dist/files/button/interface.ts +145 -0
- package/dist/files/button/llm.txt +254 -0
- package/dist/files/button/tokens.txt +470 -0
- package/dist/files/button/variants.ts +89 -0
- package/dist/files/card/Card.tsx +63 -0
- package/dist/files/card/card.css +66 -0
- package/dist/files/card/index.ts +2 -0
- package/dist/files/card/interface.ts +25 -0
- package/dist/files/card/llm.txt +93 -0
- package/dist/files/card/tokens.txt +27 -0
- package/dist/files/cascader/Cascader.tsx +955 -0
- package/dist/files/cascader/_adapter/locale.ts +4 -0
- package/dist/files/cascader/cascader-data.ts +354 -0
- package/dist/files/cascader/cascader.css +382 -0
- package/dist/files/cascader/index.ts +16 -0
- package/dist/files/cascader/interface.ts +358 -0
- package/dist/files/cascader/llm.txt +897 -0
- package/dist/files/cascader/tokens.txt +253 -0
- package/dist/files/cascader/variants.ts +35 -0
- package/dist/files/checkbox/Checkbox.tsx +477 -0
- package/dist/files/checkbox/checkbox.css +196 -0
- package/dist/files/checkbox/index.ts +9 -0
- package/dist/files/checkbox/interface.ts +162 -0
- package/dist/files/checkbox/llm.txt +326 -0
- package/dist/files/checkbox/tokens.txt +28 -0
- package/dist/files/checkbox/variants.ts +29 -0
- package/dist/files/clear/Clear.tsx +49 -0
- package/dist/files/clear/clear.css +60 -0
- package/dist/files/clear/index.ts +2 -0
- package/dist/files/clear/interface.ts +8 -0
- package/dist/files/collapse/Collapse.tsx +163 -0
- package/dist/files/collapse/collapse.css +174 -0
- package/dist/files/collapse/index.ts +2 -0
- package/dist/files/collapse/interface.ts +132 -0
- package/dist/files/collapse/llm.txt +328 -0
- package/dist/files/collapse/tokens.txt +84 -0
- package/dist/files/core/date-picker/index.ts +191 -0
- package/dist/files/core/form/index.ts +212 -0
- package/dist/files/core/index.ts +11 -0
- package/dist/files/core/input-number/index.ts +112 -0
- package/dist/files/core/namespace/index.ts +14 -0
- package/dist/files/core/overlay/index.ts +40 -0
- package/dist/files/core/pagination/index.ts +128 -0
- package/dist/files/core/table/access.ts +37 -0
- package/dist/files/core/table/columns.ts +4 -0
- package/dist/files/core/table/data-model.ts +58 -0
- package/dist/files/core/table/fixed-offset.ts +29 -0
- package/dist/files/core/table/grouped-header.ts +24 -0
- package/dist/files/core/table/index.ts +11 -0
- package/dist/files/core/table/merge.ts +132 -0
- package/dist/files/core/table/pagination.ts +51 -0
- package/dist/files/core/table/rowModel.ts +4 -0
- package/dist/files/core/table/types.ts +14 -0
- package/dist/files/core/typography/index.ts +125 -0
- package/dist/files/core/upload/file-type.ts +160 -0
- package/dist/files/core/upload/format-size.ts +17 -0
- package/dist/files/core/upload/index.ts +19 -0
- package/dist/files/core/upload/limits.ts +76 -0
- package/dist/files/core/utils/cn.ts +6 -0
- package/dist/files/core/utils/index.ts +2 -0
- package/dist/files/core/utils/svg.ts +101 -0
- package/dist/files/date-picker/DatePicker.tsx +601 -0
- package/dist/files/date-picker/RangePicker.tsx +1047 -0
- package/dist/files/date-picker/Trigger.tsx +115 -0
- package/dist/files/date-picker/_adapter/calendar.ts +136 -0
- package/dist/files/date-picker/_adapter/disable.ts +89 -0
- package/dist/files/date-picker/_adapter/format.ts +54 -0
- package/dist/files/date-picker/_adapter/keymap.ts +17 -0
- package/dist/files/date-picker/_adapter/locale.ts +4 -0
- package/dist/files/date-picker/_adapter/presets.ts +30 -0
- package/dist/files/date-picker/_adapter/range.ts +44 -0
- package/dist/files/date-picker/_adapter/types.ts +29 -0
- package/dist/files/date-picker/context.ts +60 -0
- package/dist/files/date-picker/date-picker.css +1093 -0
- package/dist/files/date-picker/index.ts +26 -0
- package/dist/files/date-picker/interface.ts +135 -0
- package/dist/files/date-picker/llm.txt +422 -0
- package/dist/files/date-picker/panels/DatePanel.tsx +110 -0
- package/dist/files/date-picker/panels/DecadePanel.tsx +49 -0
- package/dist/files/date-picker/panels/Footer.tsx +109 -0
- package/dist/files/date-picker/panels/Header.tsx +228 -0
- package/dist/files/date-picker/panels/MonthPanel.tsx +83 -0
- package/dist/files/date-picker/panels/Panel.tsx +339 -0
- package/dist/files/date-picker/panels/QuarterPanel.tsx +70 -0
- package/dist/files/date-picker/panels/TimePanel.tsx +171 -0
- package/dist/files/date-picker/panels/WeekPanel.tsx +145 -0
- package/dist/files/date-picker/panels/YearPanel.tsx +89 -0
- package/dist/files/date-picker/panels/time-panel-utils.ts +33 -0
- package/dist/files/date-picker/tokens.txt +171 -0
- package/dist/files/date-picker/variants.ts +20 -0
- package/dist/files/divider/Divider.tsx +80 -0
- package/dist/files/divider/divider.css +66 -0
- package/dist/files/divider/index.ts +7 -0
- package/dist/files/divider/interface.ts +58 -0
- package/dist/files/divider/llm.txt +158 -0
- package/dist/files/divider/tokens.txt +22 -0
- package/dist/files/drawer/Drawer.tsx +491 -0
- package/dist/files/drawer/drawer.css +201 -0
- package/dist/files/drawer/index.ts +13 -0
- package/dist/files/drawer/interface.ts +172 -0
- package/dist/files/drawer/llm.txt +374 -0
- package/dist/files/drawer/tokens.txt +71 -0
- package/dist/files/drawer/variants.ts +14 -0
- package/dist/files/dropdown/Dropdown.tsx +629 -0
- package/dist/files/dropdown/dropdown.css +243 -0
- package/dist/files/dropdown/index.ts +12 -0
- package/dist/files/dropdown/interface.ts +91 -0
- package/dist/files/dropdown/lib.ts +78 -0
- package/dist/files/dropdown/llm.txt +427 -0
- package/dist/files/dropdown/tokens.txt +59 -0
- package/dist/files/form/Form.tsx +229 -0
- package/dist/files/form/FormItem.tsx +526 -0
- package/dist/files/form/_adapter/bindField.ts +189 -0
- package/dist/files/form/_adapter/compileRules.ts +185 -0
- package/dist/files/form/_adapter/controlStatus.ts +23 -0
- package/dist/files/form/_adapter/deriveStatus.ts +42 -0
- package/dist/files/form/_adapter/instance.ts +281 -0
- package/dist/files/form/_adapter/messages.ts +15 -0
- package/dist/files/form/_adapter/types.ts +82 -0
- package/dist/files/form/_adapter/validationMeta.ts +29 -0
- package/dist/files/form/_adapter/validationTransaction.ts +69 -0
- package/dist/files/form/context.ts +38 -0
- package/dist/files/form/form.css +268 -0
- package/dist/files/form/index.ts +13 -0
- package/dist/files/form/interface.ts +99 -0
- package/dist/files/form/llm.txt +346 -0
- package/dist/files/form/tokens.txt +26 -0
- package/dist/files/form/useForm.ts +150 -0
- package/dist/files/form/utils.ts +28 -0
- package/dist/files/form/variants.ts +30 -0
- package/dist/files/global.css +8 -0
- package/dist/files/grid/Col.tsx +104 -0
- package/dist/files/grid/Grid.tsx +18 -0
- package/dist/files/grid/Row.tsx +129 -0
- package/dist/files/grid/grid.css +990 -0
- package/dist/files/grid/index.ts +12 -0
- package/dist/files/grid/interface.ts +109 -0
- package/dist/files/grid/llm.txt +419 -0
- package/dist/files/grid/useBreakpoint.ts +67 -0
- package/dist/files/icon/Icon.tsx +16 -0
- package/dist/files/icon/icon.css +26 -0
- package/dist/files/icon/icons-map.ts +1 -0
- package/dist/files/icon/index.ts +2 -0
- package/dist/files/icon/interface.ts +9 -0
- package/dist/files/icons/ActionIcons.tsx +105 -0
- package/dist/files/icons/AlertCloseIcon.tsx +21 -0
- package/dist/files/icons/CalendarIcon.tsx +6 -0
- package/dist/files/icons/CaretIcons.tsx +43 -0
- package/dist/files/icons/FileFormatIcons.tsx +27 -0
- package/dist/files/icons/Icons.tsx +10 -0
- package/dist/files/icons/MagnifyingGlassIcon.tsx +26 -0
- package/dist/files/icons/MessageIcons.tsx +111 -0
- package/dist/files/icons/NavigationIcons.tsx +126 -0
- package/dist/files/icons/PreviewIcons.tsx +18 -0
- package/dist/files/icons/StarIcons.tsx +71 -0
- package/dist/files/icons/UploadIcons.tsx +167 -0
- package/dist/files/icons/XCloseIcon.tsx +26 -0
- package/dist/files/icons/createAssetIcon.tsx +64 -0
- package/dist/files/icons/icons.css +4 -0
- package/dist/files/icons/index.ts +36 -0
- package/dist/files/icons/interface.ts +9 -0
- package/dist/files/icons/registry.ts +94 -0
- package/dist/files/image/Image.tsx +328 -0
- package/dist/files/image/ImageActionIcons.tsx +60 -0
- package/dist/files/image/ImagePreview.tsx +684 -0
- package/dist/files/image/_adapter/locale.ts +4 -0
- package/dist/files/image/image.css +451 -0
- package/dist/files/image/index.ts +7 -0
- package/dist/files/image/interface.ts +139 -0
- package/dist/files/image/llm.txt +429 -0
- package/dist/files/image/tokens.txt +28 -0
- package/dist/files/input/Input.tsx +261 -0
- package/dist/files/input/icons.tsx +3 -0
- package/dist/files/input/index.ts +12 -0
- package/dist/files/input/input-clear.stories.css +12 -0
- package/dist/files/input/input-size.ts +36 -0
- package/dist/files/input/input.css +366 -0
- package/dist/files/input/interface.ts +204 -0
- package/dist/files/input/lib.ts +51 -0
- package/dist/files/input/llm.txt +419 -0
- package/dist/files/input/tokens.txt +136 -0
- package/dist/files/input/variants.ts +17 -0
- package/dist/files/input-number/InputNumber.tsx +510 -0
- package/dist/files/input-number/icons.tsx +28 -0
- package/dist/files/input-number/index.ts +15 -0
- package/dist/files/input-number/input-number.css +440 -0
- package/dist/files/input-number/interface.ts +269 -0
- package/dist/files/input-number/lib.ts +128 -0
- package/dist/files/input-number/llm.txt +484 -0
- package/dist/files/input-number/tokens.txt +159 -0
- package/dist/files/input-number/variants.ts +27 -0
- package/dist/files/layout/Layout.tsx +360 -0
- package/dist/files/layout/index.ts +21 -0
- package/dist/files/layout/interface.ts +106 -0
- package/dist/files/layout/layout.css +278 -0
- package/dist/files/layout/llm.txt +296 -0
- package/dist/files/layout/tokens.txt +29 -0
- package/dist/files/llms-theme.txt +32 -0
- package/dist/files/llms.txt +895 -0
- package/dist/files/locale/en_US.ts +167 -0
- package/dist/files/locale/zh_CN.ts +166 -0
- package/dist/files/menu/Menu.stories.shared.tsx +85 -0
- package/dist/files/menu/Menu.tsx +713 -0
- package/dist/files/menu/demo/menu-sliding-panel.css +71 -0
- package/dist/files/menu/demo/use-sliding-panel.ts +35 -0
- package/dist/files/menu/icons.tsx +92 -0
- package/dist/files/menu/index.ts +17 -0
- package/dist/files/menu/interface.ts +229 -0
- package/dist/files/menu/lib.ts +160 -0
- package/dist/files/menu/llm.txt +686 -0
- package/dist/files/menu/menu.css +455 -0
- package/dist/files/menu/tokens.txt +87 -0
- package/dist/files/message/Message.tsx +217 -0
- package/dist/files/message/index.ts +2 -0
- package/dist/files/message/interface.ts +149 -0
- package/dist/files/message/lib/constants.ts +18 -0
- package/dist/files/message/lib/helpers.ts +26 -0
- package/dist/files/message/lib/motion.ts +117 -0
- package/dist/files/message/lib/store.ts +72 -0
- package/dist/files/message/llm.txt +301 -0
- package/dist/files/message/message.css +178 -0
- package/dist/files/message/tokens.txt +25 -0
- package/dist/files/modal/Modal.tsx +547 -0
- package/dist/files/modal/_adapter/locale.ts +4 -0
- package/dist/files/modal/index.ts +16 -0
- package/dist/files/modal/interface.ts +368 -0
- package/dist/files/modal/lib/ConfirmDialog.tsx +229 -0
- package/dist/files/modal/lib/confirm.tsx +112 -0
- package/dist/files/modal/lib/confirmIcons.tsx +21 -0
- package/dist/files/modal/lib/useModal.tsx +130 -0
- package/dist/files/modal/llm.txt +586 -0
- package/dist/files/modal/modal-padding.stories.css +22 -0
- package/dist/files/modal/modal.css +322 -0
- package/dist/files/modal/tokens.txt +96 -0
- package/dist/files/modal/variants.ts +41 -0
- package/dist/files/notification/Notification.tsx +354 -0
- package/dist/files/notification/index.ts +8 -0
- package/dist/files/notification/interface.ts +140 -0
- package/dist/files/notification/lib/constants.ts +40 -0
- package/dist/files/notification/lib/helpers.ts +31 -0
- package/dist/files/notification/lib/motion.ts +148 -0
- package/dist/files/notification/lib/store.ts +149 -0
- package/dist/files/notification/llm.txt +386 -0
- package/dist/files/notification/notification.css +416 -0
- package/dist/files/notification/tokens.txt +79 -0
- package/dist/files/pagination/PageButton.tsx +48 -0
- package/dist/files/pagination/PageSizeChanger.tsx +42 -0
- package/dist/files/pagination/Pagination.tsx +308 -0
- package/dist/files/pagination/QuickJumper.tsx +52 -0
- package/dist/files/pagination/TotalText.tsx +28 -0
- package/dist/files/pagination/_adapter/calculate.ts +33 -0
- package/dist/files/pagination/_adapter/locale.ts +4 -0
- package/dist/files/pagination/_adapter/responsive.ts +22 -0
- package/dist/files/pagination/_adapter/types.ts +27 -0
- package/dist/files/pagination/context.ts +15 -0
- package/dist/files/pagination/index.ts +3 -0
- package/dist/files/pagination/interface.ts +55 -0
- package/dist/files/pagination/llm.txt +204 -0
- package/dist/files/pagination/pagination.css +241 -0
- package/dist/files/pagination/tokens.txt +33 -0
- package/dist/files/pagination/useResizeObserver.ts +40 -0
- package/dist/files/pagination/variants.ts +3 -0
- package/dist/files/popover/Popover.tsx +353 -0
- package/dist/files/popover/index.ts +2 -0
- package/dist/files/popover/interface.ts +124 -0
- package/dist/files/popover/llm.txt +235 -0
- package/dist/files/popover/placement.ts +39 -0
- package/dist/files/popover/popover.css +65 -0
- package/dist/files/popover/popover.stories.css +42 -0
- package/dist/files/popover/tokens.txt +28 -0
- package/dist/files/progress/Progress.tsx +213 -0
- package/dist/files/progress/index.ts +4 -0
- package/dist/files/progress/interface.ts +89 -0
- package/dist/files/progress/llm.txt +277 -0
- package/dist/files/progress/progress.css +192 -0
- package/dist/files/progress/tokens.txt +83 -0
- package/dist/files/radio/Radio.tsx +315 -0
- package/dist/files/radio/context.tsx +16 -0
- package/dist/files/radio/helpers.ts +163 -0
- package/dist/files/radio/index.ts +13 -0
- package/dist/files/radio/interface.ts +207 -0
- package/dist/files/radio/llm.txt +344 -0
- package/dist/files/radio/radio.css +137 -0
- package/dist/files/radio/tokens.txt +21 -0
- package/dist/files/radio/variants.ts +20 -0
- package/dist/files/rate/Rate.tsx +199 -0
- package/dist/files/rate/RateItem.tsx +113 -0
- package/dist/files/rate/StarFilled.tsx +19 -0
- package/dist/files/rate/index.ts +11 -0
- package/dist/files/rate/interface.ts +116 -0
- package/dist/files/rate/lib.ts +72 -0
- package/dist/files/rate/llm.txt +237 -0
- package/dist/files/rate/rate.css +126 -0
- package/dist/files/rate/tokens.txt +20 -0
- package/dist/files/rate/variants.ts +19 -0
- package/dist/files/scrollbar.css +148 -0
- package/dist/files/select/Select.tsx +1366 -0
- package/dist/files/select/_adapter/locale.ts +4 -0
- package/dist/files/select/index.ts +17 -0
- package/dist/files/select/interface.ts +494 -0
- package/dist/files/select/llm.txt +828 -0
- package/dist/files/select/select-overflow.stories.css +3 -0
- package/dist/files/select/select.css +443 -0
- package/dist/files/select/tokens.txt +160 -0
- package/dist/files/select/variants.ts +63 -0
- package/dist/files/skeleton/Skeleton.tsx +345 -0
- package/dist/files/skeleton/index.ts +19 -0
- package/dist/files/skeleton/interface.ts +101 -0
- package/dist/files/skeleton/llm.txt +274 -0
- package/dist/files/skeleton/skeleton.css +171 -0
- package/dist/files/skeleton/tokens.txt +15 -0
- package/dist/files/skeleton/variants.ts +40 -0
- package/dist/files/spin/Spin.tsx +197 -0
- package/dist/files/spin/index.ts +2 -0
- package/dist/files/spin/interface.ts +69 -0
- package/dist/files/spin/llm.txt +294 -0
- package/dist/files/spin/spin.css +111 -0
- package/dist/files/spin/tokens.txt +21 -0
- package/dist/files/spin/variants.ts +19 -0
- package/dist/files/steps/Steps.tsx +211 -0
- package/dist/files/steps/index.ts +11 -0
- package/dist/files/steps/interface.ts +155 -0
- package/dist/files/steps/lib.ts +46 -0
- package/dist/files/steps/llm.txt +296 -0
- package/dist/files/steps/steps.css +268 -0
- package/dist/files/steps/tokens.txt +30 -0
- package/dist/files/steps/variants.ts +15 -0
- package/dist/files/switch/Switch.tsx +131 -0
- package/dist/files/switch/index.ts +2 -0
- package/dist/files/switch/interface.ts +92 -0
- package/dist/files/switch/llm.txt +212 -0
- package/dist/files/switch/switch.css +198 -0
- package/dist/files/switch/tokens.txt +38 -0
- package/dist/files/switch/variants.ts +15 -0
- package/dist/files/table/Table.stories.css +56 -0
- package/dist/files/table/Table.tsx +481 -0
- package/dist/files/table/_adapter/locale.ts +4 -0
- package/dist/files/table/constants.ts +7 -0
- package/dist/files/table/context.ts +46 -0
- package/dist/files/table/hooks/useColumnControl.ts +135 -0
- package/dist/files/table/hooks/useColumns.ts +87 -0
- package/dist/files/table/hooks/useExpandable.tsx +271 -0
- package/dist/files/table/hooks/useOverlayScrollbar.ts +304 -0
- package/dist/files/table/hooks/usePagination.ts +110 -0
- package/dist/files/table/hooks/useRowSelection.tsx +250 -0
- package/dist/files/table/hooks/useScrollShadow.ts +66 -0
- package/dist/files/table/hooks/useSkeletonRowCount.ts +78 -0
- package/dist/files/table/hooks/useTableLayoutScale.ts +38 -0
- package/dist/files/table/hooks/useTableModel.ts +91 -0
- package/dist/files/table/index.ts +24 -0
- package/dist/files/table/interface.ts +407 -0
- package/dist/files/table/llm.txt +1050 -0
- package/dist/files/table/parts/TableBody.tsx +396 -0
- package/dist/files/table/parts/TableCell.tsx +123 -0
- package/dist/files/table/parts/TableColgroup.tsx +35 -0
- package/dist/files/table/parts/TableEmpty.tsx +48 -0
- package/dist/files/table/parts/TableEmptyIllustration.tsx +27 -0
- package/dist/files/table/parts/TableHeader.tsx +102 -0
- package/dist/files/table/parts/TablePagination.tsx +46 -0
- package/dist/files/table/parts/TableRow.tsx +42 -0
- package/dist/files/table/parts/TableScrollbars.tsx +79 -0
- package/dist/files/table/parts/TableSkeleton.tsx +47 -0
- package/dist/files/table/parts/TableSummary.tsx +121 -0
- package/dist/files/table/table.css +850 -0
- package/dist/files/table/tokenScopes.ts +28 -0
- package/dist/files/table/tokens.txt +94 -0
- package/dist/files/table/utils/computeMergeGrid.ts +41 -0
- package/dist/files/table/utils/dataModel.ts +45 -0
- package/dist/files/table/utils/getCellValue.ts +7 -0
- package/dist/files/table/utils/getGroupedHeaderSpan.ts +73 -0
- package/dist/files/table/utils/getRowKey.ts +31 -0
- package/dist/files/table/utils/paginationState.ts +31 -0
- package/dist/files/table/utils/prefixSvgIds.ts +6 -0
- package/dist/files/table/utils/scaleFixedOffset.ts +19 -0
- package/dist/files/tabs/Tabs.tsx +140 -0
- package/dist/files/tabs/index.ts +2 -0
- package/dist/files/tabs/interface.ts +117 -0
- package/dist/files/tabs/llm.txt +305 -0
- package/dist/files/tabs/tabs.css +299 -0
- package/dist/files/tabs/tokens.txt +78 -0
- package/dist/files/tabs/variants.ts +51 -0
- package/dist/files/tag/Tag.tsx +180 -0
- package/dist/files/tag/index.ts +8 -0
- package/dist/files/tag/interface.ts +68 -0
- package/dist/files/tag/llm.txt +301 -0
- package/dist/files/tag/tag.css +96 -0
- package/dist/files/tag/tokens.txt +76 -0
- package/dist/files/tag/variants.ts +71 -0
- package/dist/files/theme/aliases.css +217 -0
- package/dist/files/theme/component-tokens.css +2211 -0
- package/dist/files/theme/index.css +4 -0
- package/dist/files/theme/primitives.css +182 -0
- package/dist/files/theme/static.css +13 -0
- package/dist/files/tooltip/Tooltip.tsx +362 -0
- package/dist/files/tooltip/index.ts +7 -0
- package/dist/files/tooltip/interface.ts +118 -0
- package/dist/files/tooltip/llm.txt +308 -0
- package/dist/files/tooltip/placement.ts +51 -0
- package/dist/files/tooltip/tokens.txt +22 -0
- package/dist/files/tooltip/tooltip.css +78 -0
- package/dist/files/tree/Tree.tsx +1069 -0
- package/dist/files/tree/constants.ts +2 -0
- package/dist/files/tree/index.ts +22 -0
- package/dist/files/tree/interface.ts +447 -0
- package/dist/files/tree/llm.txt +501 -0
- package/dist/files/tree/tokens.txt +36 -0
- package/dist/files/tree/tree-data.ts +260 -0
- package/dist/files/tree/tree.css +231 -0
- package/dist/files/tree/variants.ts +25 -0
- package/dist/files/tree-select/TreeSelect.tsx +864 -0
- package/dist/files/tree-select/_adapter/locale.ts +4 -0
- package/dist/files/tree-select/index.ts +23 -0
- package/dist/files/tree-select/interface.ts +415 -0
- package/dist/files/tree-select/llm.txt +754 -0
- package/dist/files/tree-select/tokens.txt +174 -0
- package/dist/files/tree-select/tree-select-data.ts +294 -0
- package/dist/files/tree-select/tree-select.css +303 -0
- package/dist/files/tree-select/variants.ts +42 -0
- package/dist/files/typography/Typography.tsx +739 -0
- package/dist/files/typography/_adapter/locale.ts +4 -0
- package/dist/files/typography/canvasTextMeasure.ts +148 -0
- package/dist/files/typography/index.ts +21 -0
- package/dist/files/typography/interface.ts +154 -0
- package/dist/files/typography/llm.txt +412 -0
- package/dist/files/typography/tokens.txt +60 -0
- package/dist/files/typography/typography.css +312 -0
- package/dist/files/typography/useEllipsisSuffix.ts +245 -0
- package/dist/files/typography/variants.ts +24 -0
- package/dist/files/upload/Upload.stories.css +54 -0
- package/dist/files/upload/Upload.stories.shared.ts +21 -0
- package/dist/files/upload/Upload.tsx +1108 -0
- package/dist/files/upload/UploadActionIcons.tsx +13 -0
- package/dist/files/upload/UploadFileIcon.tsx +52 -0
- package/dist/files/upload/_adapter/locale.ts +4 -0
- package/dist/files/upload/constants.ts +46 -0
- package/dist/files/upload/index.ts +38 -0
- package/dist/files/upload/interface.ts +302 -0
- package/dist/files/upload/lib/file-type.ts +60 -0
- package/dist/files/upload/lib/format-size.ts +6 -0
- package/dist/files/upload/lib/limits.ts +46 -0
- package/dist/files/upload/llm.txt +705 -0
- package/dist/files/upload/tokens.txt +201 -0
- package/dist/files/upload/upload.css +460 -0
- package/dist/files/utils/cn.ts +16 -0
- package/dist/files/utils/env.ts +16 -0
- package/dist/files/utils/normalizeRawSvg.ts +12 -0
- package/dist/manifest.json +580 -0
- package/package.json +41 -3
|
@@ -0,0 +1,1047 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import dayjs from 'dayjs'
|
|
4
|
+
import * as React from 'react'
|
|
5
|
+
import {
|
|
6
|
+
AnchoredOverlayContent,
|
|
7
|
+
useAnchoredOverlay,
|
|
8
|
+
warnDeprecatedGetPopupContainer,
|
|
9
|
+
} from '../_overlay'
|
|
10
|
+
import 'dayjs/locale/zh-cn.js'
|
|
11
|
+
import type { Dayjs } from 'dayjs'
|
|
12
|
+
import quarterOfYear from 'dayjs/plugin/quarterOfYear.js'
|
|
13
|
+
import weekOfYear from 'dayjs/plugin/weekOfYear.js'
|
|
14
|
+
import { useConfig } from '../apex-provider'
|
|
15
|
+
import { Button } from '../button'
|
|
16
|
+
import { Clear } from '../clear'
|
|
17
|
+
import { Icon } from '../icon'
|
|
18
|
+
import { resolveInputVariant } from '../input/input-size'
|
|
19
|
+
import { cn } from '../utils/cn'
|
|
20
|
+
import { getRangeRightViewDate, getYearNavStep } from './_adapter/calendar'
|
|
21
|
+
import { wrapDisabled } from './_adapter/disable'
|
|
22
|
+
import { DEFAULT_FORMATS, formatDate, mergeCalendarDate } from './_adapter/format'
|
|
23
|
+
import { defaultLocale } from './_adapter/locale'
|
|
24
|
+
import { isPresetRange, matchesPresetRange } from './_adapter/presets'
|
|
25
|
+
import type { RangeSelectionState } from './_adapter/range'
|
|
26
|
+
import { normalizeRange, selectRangeDate } from './_adapter/range'
|
|
27
|
+
import type { PanelView, RangeActivePart, RangeValue } from './_adapter/types'
|
|
28
|
+
import { DatePickerProvider } from './context'
|
|
29
|
+
import type { RangePickerPreset, RangePickerProps } from './interface'
|
|
30
|
+
import { Footer } from './panels/Footer'
|
|
31
|
+
import { initialViewForPicker, Panel } from './panels/Panel'
|
|
32
|
+
import { hasShowTimeDefault } from './panels/time-panel-utils'
|
|
33
|
+
import { Trigger } from './Trigger'
|
|
34
|
+
import { dpVariants } from './variants'
|
|
35
|
+
|
|
36
|
+
import './date-picker.css'
|
|
37
|
+
import { isDevelopment } from '../utils/env'
|
|
38
|
+
|
|
39
|
+
const EMPTY_PRESETS: RangePickerPreset[] = []
|
|
40
|
+
|
|
41
|
+
// Register dayjs plugins (idempotent)
|
|
42
|
+
dayjs.extend(weekOfYear)
|
|
43
|
+
dayjs.extend(quarterOfYear)
|
|
44
|
+
|
|
45
|
+
function CalendarSuffixIcon() {
|
|
46
|
+
return (
|
|
47
|
+
<span className="apex-input__suffix" data-slot="date-picker-suffix" aria-hidden="true">
|
|
48
|
+
<Icon name="calendar" />
|
|
49
|
+
</span>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* RangePicker — 区间日期选择器
|
|
55
|
+
*
|
|
56
|
+
* - H4: end < start 时自动 swap(由 selectRangeDate + normalizeRange 处理)
|
|
57
|
+
* - H5: timezone dev warn 仅 mount 一次
|
|
58
|
+
* - H9: 右面板 viewDate = 左 + 1 picker 单位
|
|
59
|
+
* - H10: showTime 时分步确认:先 start 日期+时间 → 确定 → 再 end 日期+时间 → 确定
|
|
60
|
+
*/
|
|
61
|
+
export const RangePicker: React.FC<RangePickerProps> = ({
|
|
62
|
+
value: valueProp,
|
|
63
|
+
defaultValue,
|
|
64
|
+
onChange,
|
|
65
|
+
picker = 'date',
|
|
66
|
+
format: formatProp,
|
|
67
|
+
showTime = false,
|
|
68
|
+
needConfirm = false,
|
|
69
|
+
allowClear = true,
|
|
70
|
+
disabled = false,
|
|
71
|
+
readOnly = false,
|
|
72
|
+
size = 'medium',
|
|
73
|
+
variant = 'default',
|
|
74
|
+
status,
|
|
75
|
+
open: openProp,
|
|
76
|
+
closeOnScroll = false,
|
|
77
|
+
onOpenChange,
|
|
78
|
+
popupClassName,
|
|
79
|
+
getPopupContainer,
|
|
80
|
+
timezone,
|
|
81
|
+
autoFocus = false,
|
|
82
|
+
className,
|
|
83
|
+
style,
|
|
84
|
+
ref,
|
|
85
|
+
disabledDate,
|
|
86
|
+
placeholder,
|
|
87
|
+
separator = '~',
|
|
88
|
+
presets = EMPTY_PRESETS,
|
|
89
|
+
}) => {
|
|
90
|
+
// ---------- format ----------
|
|
91
|
+
const resolvedFormat =
|
|
92
|
+
formatProp ??
|
|
93
|
+
(showTime
|
|
94
|
+
? typeof showTime === 'object' && showTime.format
|
|
95
|
+
? `YYYY-MM-DD ${showTime.format}`
|
|
96
|
+
: DEFAULT_FORMATS['date+time']
|
|
97
|
+
: DEFAULT_FORMATS[picker])
|
|
98
|
+
|
|
99
|
+
// ---------- controlled / uncontrolled value ----------
|
|
100
|
+
const isControlled = valueProp !== undefined
|
|
101
|
+
const [internalValue, setInternalValue] = React.useState<RangeValue>(defaultValue ?? [null, null])
|
|
102
|
+
const value: RangeValue = isControlled ? (valueProp ?? [null, null]) : internalValue
|
|
103
|
+
|
|
104
|
+
// ---------- open state ----------
|
|
105
|
+
const isOpenControlled = openProp !== undefined
|
|
106
|
+
const [internalOpen, setInternalOpen] = React.useState(false)
|
|
107
|
+
const openRaw = isOpenControlled ? openProp : internalOpen
|
|
108
|
+
const open = Boolean(openRaw) && !readOnly
|
|
109
|
+
|
|
110
|
+
const setOpen = React.useCallback(
|
|
111
|
+
(next: boolean) => {
|
|
112
|
+
if (next && (disabled || readOnly)) return
|
|
113
|
+
if (!isOpenControlled) setInternalOpen(next)
|
|
114
|
+
onOpenChange?.(next)
|
|
115
|
+
},
|
|
116
|
+
[disabled, isOpenControlled, onOpenChange, readOnly],
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
// ---------- active part ----------
|
|
120
|
+
const [activePart, setActivePart] = React.useState<RangeActivePart>('start')
|
|
121
|
+
const hasPresets = presets.length > 0
|
|
122
|
+
// Cached dynamic results never execute business callbacks during render or effects.
|
|
123
|
+
const [resolvedPresets, setResolvedPresets] = React.useState<Map<string, [Dayjs, Dayjs]>>(
|
|
124
|
+
() => new Map(),
|
|
125
|
+
)
|
|
126
|
+
const [preferredPresetKey, setPreferredPresetKey] = React.useState<string>()
|
|
127
|
+
const [confirmWholeRange, setConfirmWholeRange] = React.useState(false)
|
|
128
|
+
const presetKeys = React.useMemo(() => new Set(presets.map((preset) => preset.key)), [presets])
|
|
129
|
+
|
|
130
|
+
React.useEffect(() => {
|
|
131
|
+
if (isDevelopment() && presetKeys.size !== presets.length) {
|
|
132
|
+
console.warn('[RangePicker] presets keys must be unique.')
|
|
133
|
+
}
|
|
134
|
+
setResolvedPresets((prev) => {
|
|
135
|
+
if ([...prev.keys()].every((key) => presetKeys.has(key))) return prev
|
|
136
|
+
return new Map([...prev].filter(([key]) => presetKeys.has(key)))
|
|
137
|
+
})
|
|
138
|
+
}, [presetKeys, presets.length])
|
|
139
|
+
|
|
140
|
+
// ---------- range selection state ----------
|
|
141
|
+
const [rangeState, setRangeState] = React.useState<RangeSelectionState>({
|
|
142
|
+
start: value[0] ?? undefined,
|
|
143
|
+
end: value[1] ?? undefined,
|
|
144
|
+
hovered: undefined,
|
|
145
|
+
activePart: 'start',
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
const [timeEmptyParts, setTimeEmptyParts] = React.useState<[boolean, boolean]>(() => {
|
|
149
|
+
if (!showTime || hasShowTimeDefault(showTime)) return [false, false]
|
|
150
|
+
const initial = defaultValue ?? [null, null]
|
|
151
|
+
return [initial[0] === null, initial[1] === null]
|
|
152
|
+
})
|
|
153
|
+
const timeEmptyPartsRef = React.useRef(timeEmptyParts)
|
|
154
|
+
timeEmptyPartsRef.current = timeEmptyParts
|
|
155
|
+
const valueRef = React.useRef(value)
|
|
156
|
+
valueRef.current = value
|
|
157
|
+
|
|
158
|
+
React.useEffect(() => {
|
|
159
|
+
if (!showTime || !isControlled) return
|
|
160
|
+
setTimeEmptyParts([value[0] === null, value[1] === null])
|
|
161
|
+
}, [showTime, isControlled, value[0], value[1]])
|
|
162
|
+
|
|
163
|
+
// Sync rangeState when controlled value changes externally
|
|
164
|
+
// Use valueOf() to get primitive timestamps, avoiding Dayjs object reference equality issues
|
|
165
|
+
const startMs = value[0]?.valueOf() ?? null
|
|
166
|
+
const endMs = value[1]?.valueOf() ?? null
|
|
167
|
+
const prevOpenRef = React.useRef(false)
|
|
168
|
+
React.useEffect(() => {
|
|
169
|
+
const wasOpen = prevOpenRef.current
|
|
170
|
+
|
|
171
|
+
if (open && !wasOpen) {
|
|
172
|
+
setRangeState({
|
|
173
|
+
start: value[0] ?? undefined,
|
|
174
|
+
end: value[1] ?? undefined,
|
|
175
|
+
hovered: undefined,
|
|
176
|
+
activePart,
|
|
177
|
+
})
|
|
178
|
+
setConfirmWholeRange(false)
|
|
179
|
+
if (hasPresets) setViewDateLeft(value[0] ?? dayjs())
|
|
180
|
+
if (showTime) {
|
|
181
|
+
setPanelViewDate(
|
|
182
|
+
activePart === 'start' ? (value[0] ?? dayjs()) : (value[1] ?? value[0] ?? dayjs()),
|
|
183
|
+
)
|
|
184
|
+
setTimeEmptyParts([value[0] === null, value[1] === null])
|
|
185
|
+
}
|
|
186
|
+
} else if (!open && wasOpen) {
|
|
187
|
+
// 点击外部关闭时丢弃未提交的不完整区间选择
|
|
188
|
+
setRangeState({
|
|
189
|
+
start: value[0] ?? undefined,
|
|
190
|
+
end: value[1] ?? undefined,
|
|
191
|
+
hovered: undefined,
|
|
192
|
+
activePart: 'start',
|
|
193
|
+
})
|
|
194
|
+
setActivePart('start')
|
|
195
|
+
if (showTime) {
|
|
196
|
+
setTimeEmptyParts([value[0] === null, value[1] === null])
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
prevOpenRef.current = open
|
|
201
|
+
}, [open, showTime, value, activePart, hasPresets])
|
|
202
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: startMs/endMs are valueOf() primitives derived from value[0]/value[1]
|
|
203
|
+
React.useEffect(() => {
|
|
204
|
+
if (isControlled) {
|
|
205
|
+
setRangeState((prev) => ({
|
|
206
|
+
...prev,
|
|
207
|
+
start: value[0] ?? undefined,
|
|
208
|
+
end: value[1] ?? undefined,
|
|
209
|
+
}))
|
|
210
|
+
if (hasPresets) {
|
|
211
|
+
setViewDateLeft(value[0] ?? dayjs())
|
|
212
|
+
setPanelViewDate(value[0] ?? dayjs())
|
|
213
|
+
setRangeState((prev) => ({ ...prev, hovered: undefined, activePart: 'start' }))
|
|
214
|
+
setActivePart('start')
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
setConfirmWholeRange(false)
|
|
218
|
+
setPreferredPresetKey(undefined)
|
|
219
|
+
}, [isControlled, startMs, endMs, hasPresets])
|
|
220
|
+
|
|
221
|
+
// ---------- panel view state ----------
|
|
222
|
+
const [view, setView] = React.useState<PanelView>(() => initialViewForPicker(picker))
|
|
223
|
+
const [viewDateLeft, setViewDateLeft] = React.useState<Dayjs>(() => value[0] ?? dayjs())
|
|
224
|
+
const [panelViewDate, setPanelViewDate] = React.useState<Dayjs>(() => value[0] ?? dayjs())
|
|
225
|
+
|
|
226
|
+
// Right panel viewDate derived from left (H9)
|
|
227
|
+
const viewDateRight = getRangeRightViewDate(viewDateLeft, picker)
|
|
228
|
+
|
|
229
|
+
// ---------- H3: picker 变化时 reset ----------
|
|
230
|
+
const prevPickerRef = React.useRef(picker)
|
|
231
|
+
React.useEffect(() => {
|
|
232
|
+
if (picker !== prevPickerRef.current) {
|
|
233
|
+
prevPickerRef.current = picker
|
|
234
|
+
setView(initialViewForPicker(picker))
|
|
235
|
+
setViewDateLeft(value[0] ?? dayjs())
|
|
236
|
+
}
|
|
237
|
+
}, [picker, value[0]])
|
|
238
|
+
|
|
239
|
+
// ---------- H5: timezone dev warn ----------
|
|
240
|
+
const timezoneWarnedRef = React.useRef(false)
|
|
241
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: H5 spec requires mount-only warn
|
|
242
|
+
React.useEffect(() => {
|
|
243
|
+
if (timezone && !timezoneWarnedRef.current) {
|
|
244
|
+
timezoneWarnedRef.current = true
|
|
245
|
+
if (isDevelopment()) {
|
|
246
|
+
console.warn(
|
|
247
|
+
'[RangePicker] timezone prop v1 未实现,按本地时区处理。timezone 将在 v2 生效。',
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}, []) // mount only
|
|
252
|
+
|
|
253
|
+
// ---------- autoFocus ----------
|
|
254
|
+
const startTriggerRef = React.useRef<HTMLButtonElement>(null)
|
|
255
|
+
React.useEffect(() => {
|
|
256
|
+
if (autoFocus) startTriggerRef.current?.focus()
|
|
257
|
+
}, [autoFocus])
|
|
258
|
+
|
|
259
|
+
// ---------- portal container ----------
|
|
260
|
+
const wrapperRef = React.useRef<HTMLDivElement>(null)
|
|
261
|
+
const [, setTriggerNode] = React.useState<HTMLDivElement | null>(null)
|
|
262
|
+
|
|
263
|
+
const setWrapperRef = React.useCallback(
|
|
264
|
+
(node: HTMLDivElement | null) => {
|
|
265
|
+
wrapperRef.current = node
|
|
266
|
+
setTriggerNode(node)
|
|
267
|
+
if (typeof ref === 'function') ref(node)
|
|
268
|
+
else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node
|
|
269
|
+
},
|
|
270
|
+
[ref],
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
warnDeprecatedGetPopupContainer(getPopupContainer)
|
|
274
|
+
|
|
275
|
+
// ---------- disabled date wrapper ----------
|
|
276
|
+
const wrappedDisabled = React.useMemo(() => wrapDisabled(disabledDate), [disabledDate])
|
|
277
|
+
|
|
278
|
+
// ---------- focused state (shared for both panels) ----------
|
|
279
|
+
const [focused, setFocused] = React.useState<Dayjs | undefined>(undefined)
|
|
280
|
+
|
|
281
|
+
React.useEffect(() => {
|
|
282
|
+
if (!open) setFocused(undefined)
|
|
283
|
+
}, [open])
|
|
284
|
+
|
|
285
|
+
// ---------- handlers ----------
|
|
286
|
+
const hasRangeStart = Boolean(rangeState.start ?? value[0])
|
|
287
|
+
const handleSelectShowTimeDate = React.useCallback(
|
|
288
|
+
(picked: Dayjs) => {
|
|
289
|
+
const selectedTimePart = activePart === 'end' && hasRangeStart ? 1 : 0
|
|
290
|
+
setTimeEmptyParts((prev) => {
|
|
291
|
+
if (!prev[selectedTimePart]) return prev
|
|
292
|
+
const next: [boolean, boolean] = [...prev]
|
|
293
|
+
next[selectedTimePart] = false
|
|
294
|
+
return next
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
setRangeState((prev) => {
|
|
298
|
+
if (activePart === 'start') {
|
|
299
|
+
const isTimeEmpty = timeEmptyPartsRef.current[0]
|
|
300
|
+
const timeSource = prev.start
|
|
301
|
+
const merged =
|
|
302
|
+
timeSource && !isTimeEmpty
|
|
303
|
+
? mergeCalendarDate(picked, timeSource)
|
|
304
|
+
: picked.startOf('day')
|
|
305
|
+
return {
|
|
306
|
+
...prev,
|
|
307
|
+
start: merged,
|
|
308
|
+
end: undefined,
|
|
309
|
+
hovered: undefined,
|
|
310
|
+
activePart: 'start',
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const start = prev.start ?? valueRef.current[0]
|
|
315
|
+
if (!start) {
|
|
316
|
+
return {
|
|
317
|
+
...prev,
|
|
318
|
+
start: picked.startOf('day'),
|
|
319
|
+
end: undefined,
|
|
320
|
+
hovered: undefined,
|
|
321
|
+
activePart: 'start',
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const isTimeEmpty = timeEmptyPartsRef.current[1]
|
|
326
|
+
const timeSource = prev.end
|
|
327
|
+
const mergedEnd =
|
|
328
|
+
timeSource && !isTimeEmpty ? mergeCalendarDate(picked, timeSource) : picked.endOf('day')
|
|
329
|
+
const [s, e] = normalizeRange(start, mergedEnd)
|
|
330
|
+
return {
|
|
331
|
+
...prev,
|
|
332
|
+
start: s,
|
|
333
|
+
end: e,
|
|
334
|
+
hovered: undefined,
|
|
335
|
+
activePart: 'end',
|
|
336
|
+
}
|
|
337
|
+
})
|
|
338
|
+
},
|
|
339
|
+
[activePart, hasRangeStart],
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
const handleSelectRangeDate = React.useCallback(
|
|
343
|
+
(picked: Dayjs) => {
|
|
344
|
+
setConfirmWholeRange(false)
|
|
345
|
+
if (showTime) {
|
|
346
|
+
handleSelectShowTimeDate(picked)
|
|
347
|
+
return
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
setRangeState((prev) => {
|
|
351
|
+
const { next, complete } = selectRangeDate(prev, picked)
|
|
352
|
+
setActivePart(next.activePart)
|
|
353
|
+
|
|
354
|
+
if (complete && next.start && next.end) {
|
|
355
|
+
if (needConfirm) {
|
|
356
|
+
return next
|
|
357
|
+
}
|
|
358
|
+
const [s, e] = [next.start, next.end]
|
|
359
|
+
const newValue: RangeValue = [s, e]
|
|
360
|
+
if (!isControlled) setInternalValue(newValue)
|
|
361
|
+
onChange?.(newValue, [formatDate(s, resolvedFormat), formatDate(e, resolvedFormat)])
|
|
362
|
+
setOpen(false)
|
|
363
|
+
}
|
|
364
|
+
return next
|
|
365
|
+
})
|
|
366
|
+
},
|
|
367
|
+
[
|
|
368
|
+
showTime,
|
|
369
|
+
handleSelectShowTimeDate,
|
|
370
|
+
isControlled,
|
|
371
|
+
onChange,
|
|
372
|
+
resolvedFormat,
|
|
373
|
+
setOpen,
|
|
374
|
+
needConfirm,
|
|
375
|
+
],
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
const handleHoverDate = React.useCallback((d: Dayjs | undefined) => {
|
|
379
|
+
setRangeState((prev) => ({ ...prev, hovered: d }))
|
|
380
|
+
}, [])
|
|
381
|
+
|
|
382
|
+
const handleClear = React.useCallback(() => {
|
|
383
|
+
if (disabled || readOnly) return
|
|
384
|
+
const newValue: RangeValue = [null, null]
|
|
385
|
+
if (!isControlled) setInternalValue(newValue)
|
|
386
|
+
onChange?.(newValue, ['', ''])
|
|
387
|
+
setRangeState({ start: undefined, end: undefined, hovered: undefined, activePart: 'start' })
|
|
388
|
+
setConfirmWholeRange(false)
|
|
389
|
+
setActivePart('start')
|
|
390
|
+
if (showTime) setTimeEmptyParts([true, true])
|
|
391
|
+
}, [disabled, readOnly, isControlled, onChange, showTime])
|
|
392
|
+
|
|
393
|
+
const handlePresetClick = React.useCallback(
|
|
394
|
+
(preset: RangePickerPreset) => {
|
|
395
|
+
if (disabled || readOnly || preset.disabled) return
|
|
396
|
+
let next: unknown
|
|
397
|
+
try {
|
|
398
|
+
next = typeof preset.value === 'function' ? preset.value() : preset.value
|
|
399
|
+
} catch (error) {
|
|
400
|
+
if (isDevelopment()) {
|
|
401
|
+
console.warn(`[RangePicker] preset "${preset.key}" failed to resolve.`, error)
|
|
402
|
+
}
|
|
403
|
+
return
|
|
404
|
+
}
|
|
405
|
+
if (!isPresetRange(next)) return
|
|
406
|
+
const [start, end] = next
|
|
407
|
+
// Preserve exact times and info.from: calendar's day-level cache is not suitable here.
|
|
408
|
+
const info = { type: picker }
|
|
409
|
+
if (
|
|
410
|
+
disabledDate?.(start, info) ||
|
|
411
|
+
disabledDate?.(end, info) ||
|
|
412
|
+
disabledDate?.(end, { ...info, from: start })
|
|
413
|
+
)
|
|
414
|
+
return
|
|
415
|
+
const nextValue: RangeValue = [start, end]
|
|
416
|
+
setRangeState({ start, end, hovered: undefined, activePart: 'start' })
|
|
417
|
+
setActivePart('start')
|
|
418
|
+
setConfirmWholeRange(true)
|
|
419
|
+
setPreferredPresetKey(preset.key)
|
|
420
|
+
if (typeof preset.value === 'function') {
|
|
421
|
+
setResolvedPresets((prev) => new Map(prev).set(preset.key, next))
|
|
422
|
+
}
|
|
423
|
+
if (showTime) setTimeEmptyParts([false, false])
|
|
424
|
+
setFocused(undefined)
|
|
425
|
+
setView(initialViewForPicker(picker))
|
|
426
|
+
setViewDateLeft(start)
|
|
427
|
+
setPanelViewDate(start)
|
|
428
|
+
if (showTime || needConfirm) return
|
|
429
|
+
if (!isControlled) setInternalValue(nextValue)
|
|
430
|
+
onChange?.(nextValue, [formatDate(start, resolvedFormat), formatDate(end, resolvedFormat)])
|
|
431
|
+
setOpen(false)
|
|
432
|
+
},
|
|
433
|
+
[
|
|
434
|
+
disabled,
|
|
435
|
+
readOnly,
|
|
436
|
+
disabledDate,
|
|
437
|
+
picker,
|
|
438
|
+
showTime,
|
|
439
|
+
needConfirm,
|
|
440
|
+
isControlled,
|
|
441
|
+
onChange,
|
|
442
|
+
resolvedFormat,
|
|
443
|
+
setOpen,
|
|
444
|
+
],
|
|
445
|
+
)
|
|
446
|
+
|
|
447
|
+
const handleFooterClear = React.useCallback(() => {
|
|
448
|
+
handleClear()
|
|
449
|
+
if (showTime) {
|
|
450
|
+
setPanelViewDate(dayjs())
|
|
451
|
+
} else {
|
|
452
|
+
setViewDateLeft(dayjs())
|
|
453
|
+
}
|
|
454
|
+
setOpen(false)
|
|
455
|
+
}, [handleClear, showTime, setOpen])
|
|
456
|
+
|
|
457
|
+
const handleClose = React.useCallback(() => setOpen(false), [setOpen])
|
|
458
|
+
|
|
459
|
+
const handleInnerClick = React.useCallback(
|
|
460
|
+
(e: React.MouseEvent<HTMLDivElement>) => {
|
|
461
|
+
if (disabled || readOnly) return
|
|
462
|
+
const target = e.target as HTMLElement
|
|
463
|
+
if (target.closest('[data-slot="clear"], [data-slot="date-picker-clear"]')) return
|
|
464
|
+
if (target.closest('[data-slot="range-picker-trigger"]')) return
|
|
465
|
+
// 通过日历图标/壳层打开时默认选 start,避免残留 activePart='end' 导致首击即完成
|
|
466
|
+
setActivePart('start')
|
|
467
|
+
setConfirmWholeRange(false)
|
|
468
|
+
setRangeState((prev) => ({
|
|
469
|
+
...prev,
|
|
470
|
+
activePart: 'start',
|
|
471
|
+
hovered: undefined,
|
|
472
|
+
}))
|
|
473
|
+
if (showTime) {
|
|
474
|
+
setPanelViewDate(value[0] ?? dayjs())
|
|
475
|
+
}
|
|
476
|
+
setOpen(true)
|
|
477
|
+
},
|
|
478
|
+
[disabled, readOnly, setOpen, showTime, value],
|
|
479
|
+
)
|
|
480
|
+
|
|
481
|
+
const handleTimeChange = React.useCallback(
|
|
482
|
+
(hour: number, minute: number, second: number) => {
|
|
483
|
+
setConfirmWholeRange(false)
|
|
484
|
+
const idx = activePart === 'start' ? 0 : 1
|
|
485
|
+
setTimeEmptyParts((prev) => {
|
|
486
|
+
const next: [boolean, boolean] = [...prev]
|
|
487
|
+
next[idx] = false
|
|
488
|
+
return next
|
|
489
|
+
})
|
|
490
|
+
const base =
|
|
491
|
+
(showTime || needConfirm ? rangeState[idx === 0 ? 'start' : 'end'] : value[idx]) ??
|
|
492
|
+
(showTime ? panelViewDate : idx === 0 ? viewDateLeft : viewDateRight).startOf('day')
|
|
493
|
+
const updated = base.hour(hour).minute(minute).second(second)
|
|
494
|
+
if (showTime || needConfirm) {
|
|
495
|
+
setRangeState((prev) => ({
|
|
496
|
+
...prev,
|
|
497
|
+
[idx === 0 ? 'start' : 'end']: updated,
|
|
498
|
+
}))
|
|
499
|
+
return
|
|
500
|
+
}
|
|
501
|
+
const next: [Dayjs | null, Dayjs | null] = [...value] as [Dayjs | null, Dayjs | null]
|
|
502
|
+
next[idx] = updated
|
|
503
|
+
if (!isControlled) setInternalValue(next)
|
|
504
|
+
const fmt = (d: Dayjs | null) => (d ? formatDate(d, resolvedFormat) : '')
|
|
505
|
+
onChange?.(next, [fmt(next[0]), fmt(next[1])])
|
|
506
|
+
},
|
|
507
|
+
[
|
|
508
|
+
activePart,
|
|
509
|
+
value,
|
|
510
|
+
rangeState,
|
|
511
|
+
panelViewDate,
|
|
512
|
+
viewDateLeft,
|
|
513
|
+
viewDateRight,
|
|
514
|
+
isControlled,
|
|
515
|
+
resolvedFormat,
|
|
516
|
+
onChange,
|
|
517
|
+
needConfirm,
|
|
518
|
+
showTime,
|
|
519
|
+
],
|
|
520
|
+
)
|
|
521
|
+
|
|
522
|
+
const confirmDisabled = showTime
|
|
523
|
+
? activePart === 'start'
|
|
524
|
+
? !rangeState.start
|
|
525
|
+
: !rangeState.end
|
|
526
|
+
: !rangeState.start || !rangeState.end
|
|
527
|
+
const clearDisabled = !value[0] && !value[1] && !rangeState.start && !rangeState.end
|
|
528
|
+
const showRangeFooter = needConfirm || Boolean(showTime)
|
|
529
|
+
// Preview the open panel's draft without publishing it through value/onChange.
|
|
530
|
+
const displayValue: RangeValue =
|
|
531
|
+
open && showRangeFooter ? [rangeState.start ?? null, rangeState.end ?? null] : value
|
|
532
|
+
const handleConfirm = React.useCallback(() => {
|
|
533
|
+
if (confirmWholeRange && (!showTime || activePart === 'end')) {
|
|
534
|
+
const candidate = [rangeState.start, rangeState.end]
|
|
535
|
+
if (!isPresetRange(candidate)) return
|
|
536
|
+
const [start, end] = candidate
|
|
537
|
+
if (
|
|
538
|
+
disabledDate?.(start, { type: picker }) ||
|
|
539
|
+
disabledDate?.(end, { type: picker }) ||
|
|
540
|
+
disabledDate?.(end, { type: picker, from: start })
|
|
541
|
+
)
|
|
542
|
+
return
|
|
543
|
+
if (!isControlled) setInternalValue(candidate)
|
|
544
|
+
onChange?.(candidate, [formatDate(start, resolvedFormat), formatDate(end, resolvedFormat)])
|
|
545
|
+
setOpen(false)
|
|
546
|
+
return
|
|
547
|
+
}
|
|
548
|
+
if (showTime) {
|
|
549
|
+
if (activePart === 'start') {
|
|
550
|
+
if (!rangeState.start) return
|
|
551
|
+
const start = rangeState.start
|
|
552
|
+
setActivePart('end')
|
|
553
|
+
setRangeState((prev) => ({
|
|
554
|
+
start,
|
|
555
|
+
end: prev.end ?? value[1] ?? undefined,
|
|
556
|
+
hovered: undefined,
|
|
557
|
+
activePart: 'end',
|
|
558
|
+
}))
|
|
559
|
+
if (!value[1] && !rangeState.end) {
|
|
560
|
+
setTimeEmptyParts([false, true])
|
|
561
|
+
}
|
|
562
|
+
setPanelViewDate(rangeState.end ?? value[1] ?? start)
|
|
563
|
+
return
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
if (!rangeState.start || !rangeState.end) return
|
|
567
|
+
const [s, e] = normalizeRange(rangeState.start, rangeState.end)
|
|
568
|
+
const newValue: RangeValue = [s, e]
|
|
569
|
+
if (!isControlled) setInternalValue(newValue)
|
|
570
|
+
onChange?.(newValue, [formatDate(s, resolvedFormat), formatDate(e, resolvedFormat)])
|
|
571
|
+
setOpen(false)
|
|
572
|
+
return
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
if (rangeState.start && rangeState.end) {
|
|
576
|
+
const [s, e] = [rangeState.start, rangeState.end]
|
|
577
|
+
const newValue: RangeValue = [s, e]
|
|
578
|
+
if (!isControlled) setInternalValue(newValue)
|
|
579
|
+
onChange?.(newValue, [formatDate(s, resolvedFormat), formatDate(e, resolvedFormat)])
|
|
580
|
+
}
|
|
581
|
+
setOpen(false)
|
|
582
|
+
}, [
|
|
583
|
+
confirmWholeRange,
|
|
584
|
+
disabledDate,
|
|
585
|
+
picker,
|
|
586
|
+
showTime,
|
|
587
|
+
activePart,
|
|
588
|
+
rangeState,
|
|
589
|
+
isControlled,
|
|
590
|
+
value,
|
|
591
|
+
onChange,
|
|
592
|
+
resolvedFormat,
|
|
593
|
+
setOpen,
|
|
594
|
+
])
|
|
595
|
+
|
|
596
|
+
// ---------- root data-* ----------
|
|
597
|
+
const rootDataAttrs: Record<string, string | undefined> = {
|
|
598
|
+
'data-slot': 'range-picker',
|
|
599
|
+
'data-size': size,
|
|
600
|
+
'data-variant': resolveInputVariant(variant),
|
|
601
|
+
'data-picker': picker,
|
|
602
|
+
'data-disabled': disabled ? '' : undefined,
|
|
603
|
+
'data-readonly': readOnly ? '' : undefined,
|
|
604
|
+
'data-status': status,
|
|
605
|
+
'data-invalid': status === 'error' ? '' : undefined,
|
|
606
|
+
'data-open': open ? '' : undefined,
|
|
607
|
+
'data-active-part': activePart,
|
|
608
|
+
'data-show-time': showTime ? '' : undefined,
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// ---------- placeholders ----------
|
|
612
|
+
const resolvedLocale = useConfig()?.locale?.DatePicker ?? defaultLocale
|
|
613
|
+
const [startPlaceholder, endPlaceholder] = placeholder ?? [
|
|
614
|
+
resolvedLocale.placeholder.rangeStart,
|
|
615
|
+
resolvedLocale.placeholder.rangeEnd,
|
|
616
|
+
]
|
|
617
|
+
|
|
618
|
+
const showTimeRangeHighlight =
|
|
619
|
+
showTime && (confirmWholeRange || activePart === 'end') && Boolean(rangeState.start ?? value[0])
|
|
620
|
+
|
|
621
|
+
const ctxShowTime = React.useMemo(
|
|
622
|
+
() => ({
|
|
623
|
+
picker,
|
|
624
|
+
view,
|
|
625
|
+
setView,
|
|
626
|
+
viewDate: panelViewDate,
|
|
627
|
+
setViewDate: setPanelViewDate,
|
|
628
|
+
focused,
|
|
629
|
+
setFocused,
|
|
630
|
+
format: resolvedFormat,
|
|
631
|
+
showTime,
|
|
632
|
+
needConfirm,
|
|
633
|
+
disabledDate: wrappedDisabled,
|
|
634
|
+
size,
|
|
635
|
+
status,
|
|
636
|
+
disabled,
|
|
637
|
+
locale: resolvedLocale,
|
|
638
|
+
isRange: showTimeRangeHighlight,
|
|
639
|
+
showToday: false,
|
|
640
|
+
rangeState: showTimeRangeHighlight ? rangeState : undefined,
|
|
641
|
+
onHoverDate: showTimeRangeHighlight ? handleHoverDate : undefined,
|
|
642
|
+
value:
|
|
643
|
+
activePart === 'start'
|
|
644
|
+
? (rangeState.start ?? value[0] ?? null)
|
|
645
|
+
: (rangeState.end ?? value[1] ?? null),
|
|
646
|
+
onClose: handleClose,
|
|
647
|
+
onConfirm: handleConfirm,
|
|
648
|
+
onClear: handleFooterClear,
|
|
649
|
+
onTimeChange: handleTimeChange,
|
|
650
|
+
activePart,
|
|
651
|
+
timeEmpty: timeEmptyParts[activePart === 'start' ? 0 : 1],
|
|
652
|
+
}),
|
|
653
|
+
[
|
|
654
|
+
picker,
|
|
655
|
+
view,
|
|
656
|
+
panelViewDate,
|
|
657
|
+
focused,
|
|
658
|
+
resolvedFormat,
|
|
659
|
+
showTime,
|
|
660
|
+
needConfirm,
|
|
661
|
+
wrappedDisabled,
|
|
662
|
+
size,
|
|
663
|
+
status,
|
|
664
|
+
disabled,
|
|
665
|
+
resolvedLocale,
|
|
666
|
+
showTimeRangeHighlight,
|
|
667
|
+
rangeState,
|
|
668
|
+
handleHoverDate,
|
|
669
|
+
handleClose,
|
|
670
|
+
handleConfirm,
|
|
671
|
+
handleFooterClear,
|
|
672
|
+
handleTimeChange,
|
|
673
|
+
activePart,
|
|
674
|
+
timeEmptyParts,
|
|
675
|
+
value,
|
|
676
|
+
],
|
|
677
|
+
)
|
|
678
|
+
|
|
679
|
+
// ---------- shared context (dual panel, non-showTime) ----------
|
|
680
|
+
const makeCtxValue = React.useCallback(
|
|
681
|
+
(vd: Dayjs) => ({
|
|
682
|
+
picker,
|
|
683
|
+
view,
|
|
684
|
+
setView,
|
|
685
|
+
viewDate: vd,
|
|
686
|
+
setViewDate: setViewDateLeft,
|
|
687
|
+
focused,
|
|
688
|
+
setFocused,
|
|
689
|
+
format: resolvedFormat,
|
|
690
|
+
showTime,
|
|
691
|
+
needConfirm,
|
|
692
|
+
disabledDate: wrappedDisabled,
|
|
693
|
+
size,
|
|
694
|
+
status,
|
|
695
|
+
disabled,
|
|
696
|
+
locale: resolvedLocale,
|
|
697
|
+
isRange: true,
|
|
698
|
+
showToday: false,
|
|
699
|
+
rangeState,
|
|
700
|
+
onSelectRangeDate: handleSelectRangeDate,
|
|
701
|
+
onHoverDate: handleHoverDate,
|
|
702
|
+
value:
|
|
703
|
+
activePart === 'start'
|
|
704
|
+
? (rangeState.start ?? value[0] ?? null)
|
|
705
|
+
: (rangeState.end ?? value[1] ?? null),
|
|
706
|
+
onClose: handleClose,
|
|
707
|
+
onConfirm: handleConfirm,
|
|
708
|
+
onClear: handleFooterClear,
|
|
709
|
+
onTimeChange: handleTimeChange,
|
|
710
|
+
activePart,
|
|
711
|
+
timeEmpty: showTime ? timeEmptyParts[activePart === 'start' ? 0 : 1] : undefined,
|
|
712
|
+
}),
|
|
713
|
+
[
|
|
714
|
+
picker,
|
|
715
|
+
view,
|
|
716
|
+
focused,
|
|
717
|
+
resolvedFormat,
|
|
718
|
+
showTime,
|
|
719
|
+
needConfirm,
|
|
720
|
+
wrappedDisabled,
|
|
721
|
+
size,
|
|
722
|
+
status,
|
|
723
|
+
disabled,
|
|
724
|
+
resolvedLocale,
|
|
725
|
+
rangeState,
|
|
726
|
+
handleSelectRangeDate,
|
|
727
|
+
handleHoverDate,
|
|
728
|
+
handleClose,
|
|
729
|
+
handleConfirm,
|
|
730
|
+
handleFooterClear,
|
|
731
|
+
handleTimeChange,
|
|
732
|
+
activePart,
|
|
733
|
+
timeEmptyParts,
|
|
734
|
+
value,
|
|
735
|
+
],
|
|
736
|
+
)
|
|
737
|
+
|
|
738
|
+
const ctxLeft = React.useMemo(() => makeCtxValue(viewDateLeft), [makeCtxValue, viewDateLeft])
|
|
739
|
+
const ctxRight = React.useMemo(() => makeCtxValue(viewDateRight), [makeCtxValue, viewDateRight])
|
|
740
|
+
|
|
741
|
+
// ---------- navigation handlers for linked panels ----------
|
|
742
|
+
const yearNavStep = getYearNavStep(picker, view)
|
|
743
|
+
|
|
744
|
+
const handlePanelPrevYear = () => setPanelViewDate((vd) => vd.subtract(yearNavStep, 'year'))
|
|
745
|
+
const handlePanelPrevMonth = () => setPanelViewDate((vd) => vd.subtract(1, 'month'))
|
|
746
|
+
const handlePanelNextYear = () => setPanelViewDate((vd) => vd.add(yearNavStep, 'year'))
|
|
747
|
+
const handlePanelNextMonth = () => setPanelViewDate((vd) => vd.add(1, 'month'))
|
|
748
|
+
|
|
749
|
+
// Left panel: prev year/month navigates left (and right follows)
|
|
750
|
+
const handleLeftPrevYear = () => setViewDateLeft((vd) => vd.subtract(yearNavStep, 'year'))
|
|
751
|
+
const handleLeftPrevMonth = () => setViewDateLeft((vd) => vd.subtract(1, 'month'))
|
|
752
|
+
const handleLeftNextYear = () => setViewDateLeft((vd) => vd.add(yearNavStep, 'year'))
|
|
753
|
+
const handleLeftNextMonth = () => setViewDateLeft((vd) => vd.add(1, 'month'))
|
|
754
|
+
|
|
755
|
+
// Right panel: viewDate is derived from left, so navigate by changing left
|
|
756
|
+
const handleRightPrevYear = () => setViewDateLeft((vd) => vd.subtract(yearNavStep, 'year'))
|
|
757
|
+
const handleRightPrevMonth = () => setViewDateLeft((vd) => vd.subtract(1, 'month'))
|
|
758
|
+
const handleRightNextYear = () => setViewDateLeft((vd) => vd.add(yearNavStep, 'year'))
|
|
759
|
+
const handleRightNextMonth = () => setViewDateLeft((vd) => vd.add(1, 'month'))
|
|
760
|
+
|
|
761
|
+
const popupOverlay = useAnchoredOverlay({
|
|
762
|
+
open,
|
|
763
|
+
onOpenChange: setOpen,
|
|
764
|
+
closeWhenReferenceHidden: true,
|
|
765
|
+
closeOnScroll,
|
|
766
|
+
referenceElement: wrapperRef.current,
|
|
767
|
+
side: 'bottom',
|
|
768
|
+
align: 'start',
|
|
769
|
+
sideOffset: 4,
|
|
770
|
+
onPointerDownOutside: (e) => {
|
|
771
|
+
if (wrapperRef.current?.contains(e.target as Node)) e.preventDefault()
|
|
772
|
+
},
|
|
773
|
+
onInteractOutside: (e) => {
|
|
774
|
+
if (wrapperRef.current?.contains(e.target as Node)) e.preventDefault()
|
|
775
|
+
},
|
|
776
|
+
})
|
|
777
|
+
|
|
778
|
+
const matchingPresetIndexes = presets.flatMap((preset, index) => {
|
|
779
|
+
if (preset.disabled) return []
|
|
780
|
+
const cached = resolvedPresets.get(preset.key)
|
|
781
|
+
const resolved = typeof preset.value === 'function' ? cached : preset.value
|
|
782
|
+
return matchesPresetRange(rangeState.start, rangeState.end, resolved) ? [index] : []
|
|
783
|
+
})
|
|
784
|
+
const activePresetIndex =
|
|
785
|
+
matchingPresetIndexes.find((index) => presets[index].key === preferredPresetKey) ??
|
|
786
|
+
matchingPresetIndexes[0]
|
|
787
|
+
const seenKeys = new Map<string, number>()
|
|
788
|
+
const presetAside = hasPresets ? (
|
|
789
|
+
<div className="apex-datepicker-panel__shortcuts" data-slot="date-picker-shortcuts">
|
|
790
|
+
<div className="apex-datepicker-panel__shortcut-list apex-scrollbar">
|
|
791
|
+
{presets.map((preset, index) => {
|
|
792
|
+
const occurrence = seenKeys.get(preset.key) ?? 0
|
|
793
|
+
seenKeys.set(preset.key, occurrence + 1)
|
|
794
|
+
const selected = activePresetIndex === index
|
|
795
|
+
return (
|
|
796
|
+
<Button
|
|
797
|
+
key={JSON.stringify([preset.key, occurrence])}
|
|
798
|
+
variant="outline"
|
|
799
|
+
size="small"
|
|
800
|
+
className="apex-datepicker-panel__shortcut"
|
|
801
|
+
data-slot="date-picker-shortcut"
|
|
802
|
+
data-selected={selected ? '' : undefined}
|
|
803
|
+
aria-pressed={selected}
|
|
804
|
+
aria-disabled={preset.disabled || disabled || readOnly || undefined}
|
|
805
|
+
disabled={disabled || readOnly || preset.disabled}
|
|
806
|
+
onClick={() => handlePresetClick(preset)}
|
|
807
|
+
>
|
|
808
|
+
<span className="apex-datepicker-panel__shortcut-label">{preset.label}</span>
|
|
809
|
+
</Button>
|
|
810
|
+
)
|
|
811
|
+
})}
|
|
812
|
+
</div>
|
|
813
|
+
</div>
|
|
814
|
+
) : null
|
|
815
|
+
|
|
816
|
+
const panelContent = showTime ? (
|
|
817
|
+
<>
|
|
818
|
+
<DatePickerProvider value={ctxShowTime}>
|
|
819
|
+
<Panel
|
|
820
|
+
onSelect={handleSelectRangeDate}
|
|
821
|
+
onClose={handleClose}
|
|
822
|
+
onConfirm={handleConfirm}
|
|
823
|
+
onClear={handleFooterClear}
|
|
824
|
+
confirmDisabled={confirmDisabled}
|
|
825
|
+
clearDisabled={clearDisabled}
|
|
826
|
+
onPrevYear={handlePanelPrevYear}
|
|
827
|
+
onPrevMonth={handlePanelPrevMonth}
|
|
828
|
+
onNextYear={handlePanelNextYear}
|
|
829
|
+
onNextMonth={handlePanelNextMonth}
|
|
830
|
+
hideFooter
|
|
831
|
+
/>
|
|
832
|
+
</DatePickerProvider>
|
|
833
|
+
{showRangeFooter ? (
|
|
834
|
+
<DatePickerProvider value={ctxShowTime}>
|
|
835
|
+
<Footer
|
|
836
|
+
onConfirm={handleConfirm}
|
|
837
|
+
onClear={handleFooterClear}
|
|
838
|
+
confirmDisabled={confirmDisabled}
|
|
839
|
+
clearDisabled={clearDisabled}
|
|
840
|
+
/>
|
|
841
|
+
</DatePickerProvider>
|
|
842
|
+
) : null}
|
|
843
|
+
</>
|
|
844
|
+
) : (
|
|
845
|
+
<>
|
|
846
|
+
<div className="apex-datepicker-panel__range-body">
|
|
847
|
+
{/* Left panel */}
|
|
848
|
+
<div className="apex-datepicker-panel__half apex-datepicker-panel__half--left">
|
|
849
|
+
<DatePickerProvider value={ctxLeft}>
|
|
850
|
+
<Panel
|
|
851
|
+
onSelect={handleSelectRangeDate}
|
|
852
|
+
onClose={handleClose}
|
|
853
|
+
onConfirm={handleConfirm}
|
|
854
|
+
onClear={handleClear}
|
|
855
|
+
confirmDisabled={confirmDisabled}
|
|
856
|
+
clearDisabled={clearDisabled}
|
|
857
|
+
onPrevYear={handleLeftPrevYear}
|
|
858
|
+
onPrevMonth={handleLeftPrevMonth}
|
|
859
|
+
onNextYear={handleLeftNextYear}
|
|
860
|
+
onNextMonth={handleLeftNextMonth}
|
|
861
|
+
hideNextYear
|
|
862
|
+
hideNextMonth
|
|
863
|
+
hideFooter
|
|
864
|
+
/>
|
|
865
|
+
</DatePickerProvider>
|
|
866
|
+
</div>
|
|
867
|
+
|
|
868
|
+
{/* Right panel */}
|
|
869
|
+
<div className="apex-datepicker-panel__half apex-datepicker-panel__half--right">
|
|
870
|
+
<DatePickerProvider value={ctxRight}>
|
|
871
|
+
<Panel
|
|
872
|
+
onSelect={handleSelectRangeDate}
|
|
873
|
+
onClose={handleClose}
|
|
874
|
+
onConfirm={handleConfirm}
|
|
875
|
+
onClear={handleClear}
|
|
876
|
+
confirmDisabled={confirmDisabled}
|
|
877
|
+
clearDisabled={clearDisabled}
|
|
878
|
+
onPrevYear={handleRightPrevYear}
|
|
879
|
+
onPrevMonth={handleRightPrevMonth}
|
|
880
|
+
onNextYear={handleRightNextYear}
|
|
881
|
+
onNextMonth={handleRightNextMonth}
|
|
882
|
+
hidePrevYear
|
|
883
|
+
hidePrevMonth
|
|
884
|
+
hideFooter
|
|
885
|
+
bindDocumentKeys={false}
|
|
886
|
+
/>
|
|
887
|
+
</DatePickerProvider>
|
|
888
|
+
</div>
|
|
889
|
+
</div>
|
|
890
|
+
|
|
891
|
+
{showRangeFooter ? (
|
|
892
|
+
<DatePickerProvider value={ctxLeft}>
|
|
893
|
+
<Footer
|
|
894
|
+
onConfirm={handleConfirm}
|
|
895
|
+
onClear={handleFooterClear}
|
|
896
|
+
confirmDisabled={confirmDisabled}
|
|
897
|
+
clearDisabled={clearDisabled}
|
|
898
|
+
/>
|
|
899
|
+
</DatePickerProvider>
|
|
900
|
+
) : null}
|
|
901
|
+
</>
|
|
902
|
+
)
|
|
903
|
+
|
|
904
|
+
return (
|
|
905
|
+
<>
|
|
906
|
+
<div
|
|
907
|
+
ref={setWrapperRef}
|
|
908
|
+
className={cn(
|
|
909
|
+
dpVariants({ range: true, size, variant: resolveInputVariant(variant) }),
|
|
910
|
+
className,
|
|
911
|
+
)}
|
|
912
|
+
style={style}
|
|
913
|
+
{...rootDataAttrs}
|
|
914
|
+
>
|
|
915
|
+
<div
|
|
916
|
+
className="apex-datepicker__inner apex-input__inner"
|
|
917
|
+
data-status={status}
|
|
918
|
+
data-disabled={disabled ? true : undefined}
|
|
919
|
+
data-readonly={readOnly || undefined}
|
|
920
|
+
onClick={handleInnerClick}
|
|
921
|
+
>
|
|
922
|
+
{/* Start trigger */}
|
|
923
|
+
<Trigger
|
|
924
|
+
style={{ display: 'flex', justifyContent: 'center' }}
|
|
925
|
+
ref={startTriggerRef}
|
|
926
|
+
dateValue={displayValue[0]}
|
|
927
|
+
format={resolvedFormat}
|
|
928
|
+
placeholder={startPlaceholder}
|
|
929
|
+
disabled={disabled}
|
|
930
|
+
readOnly={readOnly}
|
|
931
|
+
allowClear={false}
|
|
932
|
+
isRange
|
|
933
|
+
isStart
|
|
934
|
+
data-slot="range-picker-trigger"
|
|
935
|
+
data-active={open && activePart === 'start' ? '' : undefined}
|
|
936
|
+
aria-label={startPlaceholder}
|
|
937
|
+
onClick={(e) => {
|
|
938
|
+
e.stopPropagation()
|
|
939
|
+
if (disabled || readOnly) return
|
|
940
|
+
setConfirmWholeRange(false)
|
|
941
|
+
setActivePart('start')
|
|
942
|
+
setRangeState((prev) => ({
|
|
943
|
+
...prev,
|
|
944
|
+
activePart: 'start',
|
|
945
|
+
hovered: undefined,
|
|
946
|
+
start: open ? prev.start : (value[0] ?? prev.start),
|
|
947
|
+
}))
|
|
948
|
+
if (showTime) {
|
|
949
|
+
setPanelViewDate(displayValue[0] ?? dayjs())
|
|
950
|
+
}
|
|
951
|
+
setOpen(true)
|
|
952
|
+
}}
|
|
953
|
+
/>
|
|
954
|
+
|
|
955
|
+
{/* Separator */}
|
|
956
|
+
<span className="apex-datepicker__separator" aria-hidden="true">
|
|
957
|
+
{separator}
|
|
958
|
+
</span>
|
|
959
|
+
|
|
960
|
+
{/* End trigger */}
|
|
961
|
+
<Trigger
|
|
962
|
+
style={{ display: 'flex', justifyContent: 'center' }}
|
|
963
|
+
dateValue={displayValue[1]}
|
|
964
|
+
format={resolvedFormat}
|
|
965
|
+
placeholder={endPlaceholder}
|
|
966
|
+
disabled={disabled}
|
|
967
|
+
readOnly={readOnly}
|
|
968
|
+
allowClear={false}
|
|
969
|
+
isRange
|
|
970
|
+
isEnd
|
|
971
|
+
data-slot="range-picker-trigger"
|
|
972
|
+
data-active={open && activePart === 'end' ? '' : undefined}
|
|
973
|
+
aria-label={endPlaceholder}
|
|
974
|
+
onClick={(e) => {
|
|
975
|
+
e.stopPropagation()
|
|
976
|
+
if (disabled || readOnly) return
|
|
977
|
+
setConfirmWholeRange(false)
|
|
978
|
+
if (showTime && !value[0] && !rangeState.start) {
|
|
979
|
+
setActivePart('start')
|
|
980
|
+
setRangeState((prev) => ({ ...prev, activePart: 'start', hovered: undefined }))
|
|
981
|
+
setPanelViewDate(dayjs())
|
|
982
|
+
setOpen(true)
|
|
983
|
+
return
|
|
984
|
+
}
|
|
985
|
+
setActivePart('end')
|
|
986
|
+
setRangeState((prev) => ({
|
|
987
|
+
...prev,
|
|
988
|
+
activePart: 'end',
|
|
989
|
+
hovered: undefined,
|
|
990
|
+
start: prev.start ?? value[0] ?? undefined,
|
|
991
|
+
}))
|
|
992
|
+
if (showTime) {
|
|
993
|
+
setPanelViewDate(
|
|
994
|
+
rangeState.end ?? value[1] ?? rangeState.start ?? value[0] ?? dayjs(),
|
|
995
|
+
)
|
|
996
|
+
}
|
|
997
|
+
setOpen(true)
|
|
998
|
+
}}
|
|
999
|
+
/>
|
|
1000
|
+
|
|
1001
|
+
{/* Clear button(须在 suffix 前,与单选 hover 隐藏图标规则一致) */}
|
|
1002
|
+
{!readOnly && allowClear && (value[0] || value[1]) ? (
|
|
1003
|
+
<Clear
|
|
1004
|
+
data-slot="date-picker-clear"
|
|
1005
|
+
aria-label={resolvedLocale.aria.clear}
|
|
1006
|
+
onClick={(e) => {
|
|
1007
|
+
e.stopPropagation()
|
|
1008
|
+
handleClear()
|
|
1009
|
+
}}
|
|
1010
|
+
/>
|
|
1011
|
+
) : null}
|
|
1012
|
+
|
|
1013
|
+
{!readOnly ? <CalendarSuffixIcon /> : null}
|
|
1014
|
+
</div>
|
|
1015
|
+
</div>
|
|
1016
|
+
|
|
1017
|
+
<AnchoredOverlayContent
|
|
1018
|
+
overlay={popupOverlay}
|
|
1019
|
+
overlayKind="range-picker"
|
|
1020
|
+
data-slot="range-picker-panel"
|
|
1021
|
+
data-picker={picker}
|
|
1022
|
+
data-view={view}
|
|
1023
|
+
className={cn(
|
|
1024
|
+
'apex-datepicker__popup apex-datepicker-panel apex-datepicker apex-default-datepicker apex-datepicker-button apex-default-datepicker-button shadow',
|
|
1025
|
+
showTime ? 'apex-datepicker-panel--with-time' : 'apex-datepicker-panel--range',
|
|
1026
|
+
hasPresets && 'apex-datepicker-panel--with-presets',
|
|
1027
|
+
popupClassName,
|
|
1028
|
+
)}
|
|
1029
|
+
aria-label={resolvedLocale.aria.rangePanel}
|
|
1030
|
+
data-active-part={showTime ? activePart : undefined}
|
|
1031
|
+
>
|
|
1032
|
+
{hasPresets ? (
|
|
1033
|
+
<div className="apex-datepicker-panel__preset-layout">
|
|
1034
|
+
{presetAside}
|
|
1035
|
+
<div className="apex-datepicker-panel__preset-content">{panelContent}</div>
|
|
1036
|
+
</div>
|
|
1037
|
+
) : (
|
|
1038
|
+
panelContent
|
|
1039
|
+
)}
|
|
1040
|
+
</AnchoredOverlayContent>
|
|
1041
|
+
</>
|
|
1042
|
+
)
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
RangePicker.displayName = 'ApexRangePicker'
|
|
1046
|
+
|
|
1047
|
+
export default RangePicker
|