@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,101 @@
|
|
|
1
|
+
const BASE64_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
|
2
|
+
|
|
3
|
+
function decodeUtf8(bytes: readonly number[]): string {
|
|
4
|
+
let result = ''
|
|
5
|
+
|
|
6
|
+
for (let index = 0; index < bytes.length; index += 1) {
|
|
7
|
+
const first = bytes[index]
|
|
8
|
+
if (first < 0x80) {
|
|
9
|
+
result += String.fromCodePoint(first)
|
|
10
|
+
continue
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const sequenceLength = first >= 0xf0 ? 4 : first >= 0xe0 ? 3 : first >= 0xc2 ? 2 : 1
|
|
14
|
+
if (sequenceLength === 1 || index + sequenceLength > bytes.length) {
|
|
15
|
+
result += '\uFFFD'
|
|
16
|
+
continue
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let codePoint = first & (0x7f >> sequenceLength)
|
|
20
|
+
let valid = true
|
|
21
|
+
for (let offset = 1; offset < sequenceLength; offset += 1) {
|
|
22
|
+
const next = bytes[index + offset]
|
|
23
|
+
if ((next & 0xc0) !== 0x80) {
|
|
24
|
+
valid = false
|
|
25
|
+
break
|
|
26
|
+
}
|
|
27
|
+
codePoint = (codePoint << 6) | (next & 0x3f)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const minimum = sequenceLength === 2 ? 0x80 : sequenceLength === 3 ? 0x800 : 0x10000
|
|
31
|
+
if (
|
|
32
|
+
!valid ||
|
|
33
|
+
codePoint < minimum ||
|
|
34
|
+
codePoint > 0x10ffff ||
|
|
35
|
+
(codePoint >= 0xd800 && codePoint <= 0xdfff)
|
|
36
|
+
) {
|
|
37
|
+
result += '\uFFFD'
|
|
38
|
+
continue
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
result += String.fromCodePoint(codePoint)
|
|
42
|
+
index += sequenceLength - 1
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return result
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function decodeBase64Utf8(encoded: string): string {
|
|
49
|
+
const normalized = encoded.replace(/\s/g, '')
|
|
50
|
+
const paddingIndex = normalized.indexOf('=')
|
|
51
|
+
const content = paddingIndex === -1 ? normalized : normalized.slice(0, paddingIndex)
|
|
52
|
+
const padding = paddingIndex === -1 ? '' : normalized.slice(paddingIndex)
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
!/^[A-Za-z0-9+/]*$/.test(content) ||
|
|
56
|
+
!/^={0,2}$/.test(padding) ||
|
|
57
|
+
content.length % 4 === 1 ||
|
|
58
|
+
(padding.length > 0 && normalized.length % 4 !== 0)
|
|
59
|
+
) {
|
|
60
|
+
throw new TypeError('Invalid base64 SVG data URL')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const padded = content.padEnd(Math.ceil(content.length / 4) * 4, '=')
|
|
64
|
+
const bytes: number[] = []
|
|
65
|
+
for (let index = 0; index < padded.length; index += 4) {
|
|
66
|
+
const values = [...padded.slice(index, index + 4)].map((character) =>
|
|
67
|
+
character === '=' ? 0 : BASE64_ALPHABET.indexOf(character),
|
|
68
|
+
)
|
|
69
|
+
const combined = (values[0] << 18) | (values[1] << 12) | (values[2] << 6) | values[3]
|
|
70
|
+
bytes.push((combined >> 16) & 0xff)
|
|
71
|
+
if (padded[index + 2] !== '=') bytes.push((combined >> 8) & 0xff)
|
|
72
|
+
if (padded[index + 3] !== '=') bytes.push(combined & 0xff)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return decodeUtf8(bytes)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Normalize inline SVG source and supported SVG data URLs to markup. */
|
|
79
|
+
export function normalizeRawSvg(raw: string): string {
|
|
80
|
+
if (!raw.startsWith('data:image/svg+xml')) return raw
|
|
81
|
+
|
|
82
|
+
const base64Prefix = 'data:image/svg+xml;base64,'
|
|
83
|
+
if (raw.startsWith(base64Prefix)) {
|
|
84
|
+
return decodeBase64Utf8(raw.slice(base64Prefix.length))
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
for (const prefix of [
|
|
88
|
+
'data:image/svg+xml;charset=utf-8,',
|
|
89
|
+
'data:image/svg+xml;utf8,',
|
|
90
|
+
'data:image/svg+xml,',
|
|
91
|
+
]) {
|
|
92
|
+
if (raw.startsWith(prefix)) return decodeURIComponent(raw.slice(prefix.length))
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return raw
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** True when the string looks like inline SVG markup rather than a URL or hash. */
|
|
99
|
+
export function isInlineSvgMarkup(value: string): boolean {
|
|
100
|
+
return /<svg[\s>]/i.test(value)
|
|
101
|
+
}
|
|
@@ -0,0 +1,601 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import './date-picker.css'
|
|
4
|
+
import dayjs from 'dayjs'
|
|
5
|
+
import * as React from 'react'
|
|
6
|
+
import {
|
|
7
|
+
AnchoredOverlayContent,
|
|
8
|
+
useAnchoredOverlay,
|
|
9
|
+
warnDeprecatedGetPopupContainer,
|
|
10
|
+
} from '../_overlay'
|
|
11
|
+
import 'dayjs/locale/zh-cn.js'
|
|
12
|
+
import type { Dayjs } from 'dayjs'
|
|
13
|
+
import quarterOfYear from 'dayjs/plugin/quarterOfYear.js'
|
|
14
|
+
import weekOfYear from 'dayjs/plugin/weekOfYear.js'
|
|
15
|
+
import { useConfig } from '../apex-provider'
|
|
16
|
+
import { Button } from '../button/Button'
|
|
17
|
+
import { resolveInputVariant } from '../input/input-size'
|
|
18
|
+
import { cn } from '../utils/cn'
|
|
19
|
+
import { isDevelopment } from '../utils/env'
|
|
20
|
+
import { wrapDisabled } from './_adapter/disable'
|
|
21
|
+
import { DEFAULT_FORMATS, formatDate, mergeCalendarDate } from './_adapter/format'
|
|
22
|
+
import { defaultLocale } from './_adapter/locale'
|
|
23
|
+
import { isPresetDate, matchesPresetDate } from './_adapter/presets'
|
|
24
|
+
import type { DateValue, PanelView, PickerType } from './_adapter/types'
|
|
25
|
+
import { DatePickerProvider } from './context'
|
|
26
|
+
import type { DatePickerPreset, DatePickerProps } from './interface'
|
|
27
|
+
import { initialViewForPicker, Panel } from './panels/Panel'
|
|
28
|
+
import { hasShowTimeDefault } from './panels/time-panel-utils'
|
|
29
|
+
import { Trigger } from './Trigger'
|
|
30
|
+
import { dpVariants } from './variants'
|
|
31
|
+
|
|
32
|
+
// Register dayjs plugins (idempotent)
|
|
33
|
+
dayjs.extend(weekOfYear)
|
|
34
|
+
dayjs.extend(quarterOfYear)
|
|
35
|
+
|
|
36
|
+
const EMPTY_PRESETS: DatePickerPreset[] = []
|
|
37
|
+
|
|
38
|
+
function currentPeriodDate(picker: PickerType, weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6): Dayjs {
|
|
39
|
+
const now = dayjs()
|
|
40
|
+
switch (picker) {
|
|
41
|
+
case 'week': {
|
|
42
|
+
const diff = (now.day() - weekStartsOn + 7) % 7
|
|
43
|
+
return now.subtract(diff, 'day').startOf('day')
|
|
44
|
+
}
|
|
45
|
+
case 'month':
|
|
46
|
+
return now.startOf('month')
|
|
47
|
+
case 'quarter':
|
|
48
|
+
return now.startOf('quarter')
|
|
49
|
+
case 'year':
|
|
50
|
+
return now.startOf('year')
|
|
51
|
+
default:
|
|
52
|
+
return now
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* DatePicker — 单日期选择器
|
|
58
|
+
*
|
|
59
|
+
* - D7: 只读 button 触发器,无键盘文本输入
|
|
60
|
+
* - D8: 内置中文 locale,不暴露 locale prop
|
|
61
|
+
* - H1: 禁止 dayjs.locale() 全局调用,统一 .locale('zh-cn') 实例化
|
|
62
|
+
* - H3: picker 变化时重置 view 和 viewDate
|
|
63
|
+
* - H5: timezone prop 仅 mount 时 dev warn 一次,StrictMode 防双触发
|
|
64
|
+
*/
|
|
65
|
+
export const DatePicker: React.FC<DatePickerProps> = ({
|
|
66
|
+
value: valueProp,
|
|
67
|
+
defaultValue,
|
|
68
|
+
onChange,
|
|
69
|
+
picker = 'date',
|
|
70
|
+
format: formatProp,
|
|
71
|
+
showTime = false,
|
|
72
|
+
needConfirm = false,
|
|
73
|
+
allowClear = true,
|
|
74
|
+
disabled = false,
|
|
75
|
+
readOnly = false,
|
|
76
|
+
size = 'medium',
|
|
77
|
+
variant = 'default',
|
|
78
|
+
status,
|
|
79
|
+
open: openProp,
|
|
80
|
+
closeOnScroll = false,
|
|
81
|
+
onOpenChange,
|
|
82
|
+
popupClassName,
|
|
83
|
+
getPopupContainer,
|
|
84
|
+
timezone,
|
|
85
|
+
autoFocus = false,
|
|
86
|
+
className,
|
|
87
|
+
style,
|
|
88
|
+
ref,
|
|
89
|
+
disabledDate,
|
|
90
|
+
presets = EMPTY_PRESETS,
|
|
91
|
+
placeholder,
|
|
92
|
+
showToday = true,
|
|
93
|
+
}) => {
|
|
94
|
+
// ---------- format resolution ----------
|
|
95
|
+
const resolvedFormat =
|
|
96
|
+
formatProp ??
|
|
97
|
+
(showTime
|
|
98
|
+
? typeof showTime === 'object' && showTime.format
|
|
99
|
+
? `YYYY-MM-DD ${showTime.format}`
|
|
100
|
+
: DEFAULT_FORMATS['date+time']
|
|
101
|
+
: DEFAULT_FORMATS[picker])
|
|
102
|
+
|
|
103
|
+
// ---------- controlled / uncontrolled value ----------
|
|
104
|
+
const isControlled = valueProp !== undefined
|
|
105
|
+
const [internalValue, setInternalValue] = React.useState<DateValue>(
|
|
106
|
+
defaultValue !== undefined ? defaultValue : null,
|
|
107
|
+
)
|
|
108
|
+
const value = isControlled ? valueProp : internalValue
|
|
109
|
+
const hasPresets = presets.length > 0
|
|
110
|
+
// Dynamic business dates are resolved only on activation, never while rendering.
|
|
111
|
+
const [resolvedPresets, setResolvedPresets] = React.useState<Map<string, Dayjs>>(() => new Map())
|
|
112
|
+
const [preferredPresetKey, setPreferredPresetKey] = React.useState<string>()
|
|
113
|
+
const presetKeys = React.useMemo(() => new Set(presets.map((preset) => preset.key)), [presets])
|
|
114
|
+
React.useEffect(() => {
|
|
115
|
+
if (isDevelopment() && presetKeys.size !== presets.length) {
|
|
116
|
+
console.warn('[DatePicker] presets keys must be unique.')
|
|
117
|
+
}
|
|
118
|
+
setResolvedPresets((previous) => {
|
|
119
|
+
if ([...previous.keys()].every((key) => presetKeys.has(key))) return previous
|
|
120
|
+
return new Map([...previous].filter(([key]) => presetKeys.has(key)))
|
|
121
|
+
})
|
|
122
|
+
}, [presetKeys, presets.length])
|
|
123
|
+
|
|
124
|
+
// ---------- open state ----------
|
|
125
|
+
const isOpenControlled = openProp !== undefined
|
|
126
|
+
const [internalOpen, setInternalOpen] = React.useState(false)
|
|
127
|
+
const openRaw = isOpenControlled ? openProp : internalOpen
|
|
128
|
+
const open = Boolean(openRaw) && !readOnly
|
|
129
|
+
|
|
130
|
+
const setOpen = React.useCallback(
|
|
131
|
+
(next: boolean) => {
|
|
132
|
+
if (next && (disabled || readOnly)) return
|
|
133
|
+
if (!isOpenControlled) setInternalOpen(next)
|
|
134
|
+
onOpenChange?.(next)
|
|
135
|
+
},
|
|
136
|
+
[disabled, isOpenControlled, onOpenChange, readOnly],
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
// ---------- draft value (needConfirm / showTime) ----------
|
|
140
|
+
const usesPanelDraft = needConfirm || Boolean(showTime)
|
|
141
|
+
const [draftValue, setDraftValue] = React.useState<DateValue>(null)
|
|
142
|
+
|
|
143
|
+
const panelValue = usesPanelDraft ? draftValue : value
|
|
144
|
+
|
|
145
|
+
const [timeEmpty, setTimeEmpty] = React.useState(() => {
|
|
146
|
+
if (!showTime || hasShowTimeDefault(showTime)) return false
|
|
147
|
+
const initial = defaultValue !== undefined ? defaultValue : null
|
|
148
|
+
return initial === null
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
React.useEffect(() => {
|
|
152
|
+
if (!showTime) return
|
|
153
|
+
if (isControlled) {
|
|
154
|
+
setTimeEmpty(value === null)
|
|
155
|
+
}
|
|
156
|
+
}, [showTime, isControlled, value])
|
|
157
|
+
|
|
158
|
+
// ---------- panel view state ----------
|
|
159
|
+
const [view, setView] = React.useState<PanelView>(() => initialViewForPicker(picker))
|
|
160
|
+
const [viewDate, setViewDate] = React.useState<Dayjs>(() => value ?? dayjs())
|
|
161
|
+
const [focused, setFocused] = React.useState<Dayjs | undefined>(undefined)
|
|
162
|
+
|
|
163
|
+
const valueMs = value?.valueOf()
|
|
164
|
+
const [panelSnapshot, setPanelSnapshot] = React.useState({ open: false, valueMs })
|
|
165
|
+
// Reconcile before children mount: resetting in an effect lets the old draft's
|
|
166
|
+
// selected/disabled styles reach the DOM and animate on the first visible frame.
|
|
167
|
+
if (panelSnapshot.open !== open || !Object.is(panelSnapshot.valueMs, valueMs)) {
|
|
168
|
+
setPanelSnapshot({ open, valueMs })
|
|
169
|
+
if (open) {
|
|
170
|
+
if (usesPanelDraft) setDraftValue(value)
|
|
171
|
+
if (hasPresets) {
|
|
172
|
+
setView(initialViewForPicker(picker))
|
|
173
|
+
setViewDate(value ?? dayjs())
|
|
174
|
+
}
|
|
175
|
+
if (showTime) setTimeEmpty(value === null && !hasShowTimeDefault(showTime))
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
React.useEffect(() => {
|
|
180
|
+
if (!open) setFocused(undefined)
|
|
181
|
+
}, [open])
|
|
182
|
+
|
|
183
|
+
// ---------- H3: picker 变化时 reset view + viewDate ----------
|
|
184
|
+
const prevPickerRef = React.useRef(picker)
|
|
185
|
+
React.useEffect(() => {
|
|
186
|
+
if (picker !== prevPickerRef.current) {
|
|
187
|
+
prevPickerRef.current = picker
|
|
188
|
+
setView(initialViewForPicker(picker))
|
|
189
|
+
setViewDate(value ?? dayjs())
|
|
190
|
+
}
|
|
191
|
+
}, [picker, value])
|
|
192
|
+
|
|
193
|
+
// ---------- H5: timezone dev warn(mount 仅一次,StrictMode 防双触发)----------
|
|
194
|
+
const timezoneWarnedRef = React.useRef(false)
|
|
195
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: H5 spec requires mount-only warn
|
|
196
|
+
React.useEffect(() => {
|
|
197
|
+
if (timezone && !timezoneWarnedRef.current) {
|
|
198
|
+
timezoneWarnedRef.current = true
|
|
199
|
+
if (isDevelopment()) {
|
|
200
|
+
console.warn(
|
|
201
|
+
'[DatePicker] timezone prop v1 未实现,按本地时区处理。timezone 将在 v2 生效。',
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}, []) // eslint-disable-line react-hooks/exhaustive-deps — only on mount
|
|
206
|
+
|
|
207
|
+
// ---------- autoFocus ----------
|
|
208
|
+
const triggerRef = React.useRef<HTMLButtonElement>(null)
|
|
209
|
+
React.useEffect(() => {
|
|
210
|
+
if (autoFocus) {
|
|
211
|
+
triggerRef.current?.focus()
|
|
212
|
+
}
|
|
213
|
+
}, [autoFocus])
|
|
214
|
+
|
|
215
|
+
const config = useConfig()
|
|
216
|
+
|
|
217
|
+
// ---------- portal container ----------
|
|
218
|
+
const wrapperRef = React.useRef<HTMLDivElement>(null)
|
|
219
|
+
const [, setTriggerNode] = React.useState<HTMLDivElement | null>(null)
|
|
220
|
+
|
|
221
|
+
const setWrapperRef = React.useCallback(
|
|
222
|
+
(node: HTMLDivElement | null) => {
|
|
223
|
+
wrapperRef.current = node
|
|
224
|
+
setTriggerNode(node)
|
|
225
|
+
if (typeof ref === 'function') ref(node)
|
|
226
|
+
else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node
|
|
227
|
+
},
|
|
228
|
+
[ref],
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
warnDeprecatedGetPopupContainer(getPopupContainer)
|
|
232
|
+
|
|
233
|
+
// ---------- disabled date wrapper ----------
|
|
234
|
+
const wrappedDisabled = React.useMemo(() => wrapDisabled(disabledDate), [disabledDate])
|
|
235
|
+
|
|
236
|
+
const resolvedLocale = config?.locale?.DatePicker ?? defaultLocale
|
|
237
|
+
|
|
238
|
+
// ---------- placeholder ----------
|
|
239
|
+
const resolvedPlaceholder = placeholder ?? resolvedLocale.placeholder[picker]
|
|
240
|
+
|
|
241
|
+
// ---------- handlers ----------
|
|
242
|
+
const handleSelect = React.useCallback(
|
|
243
|
+
(date: Dayjs) => {
|
|
244
|
+
const timeSource = usesPanelDraft ? draftValue : value
|
|
245
|
+
let merged = date
|
|
246
|
+
if (showTime) {
|
|
247
|
+
merged =
|
|
248
|
+
timeSource && !timeEmpty ? mergeCalendarDate(date, timeSource) : date.startOf('day')
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (usesPanelDraft) {
|
|
252
|
+
setDraftValue(merged)
|
|
253
|
+
return
|
|
254
|
+
}
|
|
255
|
+
const formatted = formatDate(merged, resolvedFormat)
|
|
256
|
+
if (!isControlled) setInternalValue(merged)
|
|
257
|
+
onChange?.(merged, formatted)
|
|
258
|
+
if (!showTime) setOpen(false)
|
|
259
|
+
},
|
|
260
|
+
[
|
|
261
|
+
usesPanelDraft,
|
|
262
|
+
draftValue,
|
|
263
|
+
value,
|
|
264
|
+
showTime,
|
|
265
|
+
timeEmpty,
|
|
266
|
+
isControlled,
|
|
267
|
+
onChange,
|
|
268
|
+
resolvedFormat,
|
|
269
|
+
setOpen,
|
|
270
|
+
],
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
const handlePresetClick = (preset: DatePickerPreset) => {
|
|
274
|
+
if (disabled || readOnly || preset.disabled) return
|
|
275
|
+
let next: unknown
|
|
276
|
+
try {
|
|
277
|
+
next = typeof preset.value === 'function' ? preset.value() : preset.value
|
|
278
|
+
} catch (error) {
|
|
279
|
+
if (isDevelopment()) {
|
|
280
|
+
console.warn(`[DatePicker] preset "${preset.key}" failed to resolve.`, error)
|
|
281
|
+
}
|
|
282
|
+
return
|
|
283
|
+
}
|
|
284
|
+
// Preserve the exact business date; the calendar's day-level cache is unsuitable here.
|
|
285
|
+
if (!isPresetDate(next) || disabledDate?.(next, { type: picker })) return
|
|
286
|
+
setPreferredPresetKey(preset.key)
|
|
287
|
+
if (typeof preset.value === 'function') {
|
|
288
|
+
setResolvedPresets((previous) => new Map(previous).set(preset.key, next))
|
|
289
|
+
}
|
|
290
|
+
setView(initialViewForPicker(picker))
|
|
291
|
+
setViewDate(next)
|
|
292
|
+
setFocused(undefined)
|
|
293
|
+
if (showTime) setTimeEmpty(false)
|
|
294
|
+
if (usesPanelDraft) {
|
|
295
|
+
setDraftValue(next)
|
|
296
|
+
return
|
|
297
|
+
}
|
|
298
|
+
if (!isControlled) setInternalValue(next)
|
|
299
|
+
onChange?.(next, formatDate(next, resolvedFormat))
|
|
300
|
+
setOpen(false)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const handleClear = React.useCallback(
|
|
304
|
+
(e?: React.MouseEvent) => {
|
|
305
|
+
e?.stopPropagation?.()
|
|
306
|
+
if (disabled || readOnly) return
|
|
307
|
+
setDraftValue(null)
|
|
308
|
+
if (!isControlled) setInternalValue(null)
|
|
309
|
+
if (showTime) setTimeEmpty(true)
|
|
310
|
+
onChange?.(null, '')
|
|
311
|
+
},
|
|
312
|
+
[disabled, readOnly, isControlled, onChange, showTime],
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
/** 面板「重置」:立刻清空并关闭(与「确定」同为终结动作) */
|
|
316
|
+
const handleFooterClear = React.useCallback(() => {
|
|
317
|
+
if (usesPanelDraft) setDraftValue(null)
|
|
318
|
+
handleClear()
|
|
319
|
+
setOpen(false)
|
|
320
|
+
}, [usesPanelDraft, handleClear, setOpen])
|
|
321
|
+
|
|
322
|
+
const handleToday = React.useCallback(() => {
|
|
323
|
+
const target = currentPeriodDate(picker, resolvedLocale.weekStartsOn)
|
|
324
|
+
if (showTime) setTimeEmpty(false)
|
|
325
|
+
setView(initialViewForPicker(picker))
|
|
326
|
+
setViewDate(target)
|
|
327
|
+
// 快捷按钮是鼠标操作,不要留下键盘焦点框
|
|
328
|
+
setFocused(undefined)
|
|
329
|
+
if (usesPanelDraft) {
|
|
330
|
+
// date+showTime:写成此刻;周/月/季/年:写成当前周期起点
|
|
331
|
+
setDraftValue(target)
|
|
332
|
+
return
|
|
333
|
+
}
|
|
334
|
+
handleSelect(target)
|
|
335
|
+
}, [usesPanelDraft, handleSelect, showTime, picker, resolvedLocale.weekStartsOn])
|
|
336
|
+
|
|
337
|
+
const handleConfirm = React.useCallback(() => {
|
|
338
|
+
if (disabled || readOnly) return
|
|
339
|
+
const toCommit = usesPanelDraft ? draftValue : value
|
|
340
|
+
if (toCommit && disabledDate?.(toCommit, { type: picker })) return
|
|
341
|
+
if (toCommit) {
|
|
342
|
+
if (!isControlled) setInternalValue(toCommit)
|
|
343
|
+
onChange?.(toCommit, formatDate(toCommit, resolvedFormat))
|
|
344
|
+
} else if (usesPanelDraft) {
|
|
345
|
+
if (!isControlled) setInternalValue(null)
|
|
346
|
+
onChange?.(null, '')
|
|
347
|
+
}
|
|
348
|
+
setOpen(false)
|
|
349
|
+
}, [
|
|
350
|
+
disabled,
|
|
351
|
+
readOnly,
|
|
352
|
+
disabledDate,
|
|
353
|
+
picker,
|
|
354
|
+
usesPanelDraft,
|
|
355
|
+
draftValue,
|
|
356
|
+
value,
|
|
357
|
+
isControlled,
|
|
358
|
+
onChange,
|
|
359
|
+
resolvedFormat,
|
|
360
|
+
setOpen,
|
|
361
|
+
])
|
|
362
|
+
|
|
363
|
+
/** 确定:须有有效草稿;showTime 还须已选时间 */
|
|
364
|
+
const confirmDisabled = usesPanelDraft
|
|
365
|
+
? draftValue == null || (Boolean(showTime) && timeEmpty)
|
|
366
|
+
: value == null
|
|
367
|
+
/** 重置:有草稿或已提交值时可点 */
|
|
368
|
+
const clearDisabled = usesPanelDraft ? draftValue == null && value == null : value == null
|
|
369
|
+
|
|
370
|
+
const handleClose = React.useCallback(() => {
|
|
371
|
+
setOpen(false)
|
|
372
|
+
}, [setOpen])
|
|
373
|
+
|
|
374
|
+
const handleTriggerClick = React.useCallback(
|
|
375
|
+
(e: React.MouseEvent<HTMLButtonElement>) => {
|
|
376
|
+
e.stopPropagation()
|
|
377
|
+
if (disabled || readOnly) return
|
|
378
|
+
setOpen(!open)
|
|
379
|
+
},
|
|
380
|
+
[disabled, readOnly, open, setOpen],
|
|
381
|
+
)
|
|
382
|
+
|
|
383
|
+
const handleInnerClick = React.useCallback(
|
|
384
|
+
(e: React.MouseEvent<HTMLDivElement>) => {
|
|
385
|
+
if (disabled || readOnly) return
|
|
386
|
+
const target = e.target as HTMLElement
|
|
387
|
+
if (target.closest('[data-slot="clear"], [data-slot="date-picker-clear"]')) return
|
|
388
|
+
if (target.closest('[data-slot="date-picker-trigger"]')) return
|
|
389
|
+
setOpen(!open)
|
|
390
|
+
},
|
|
391
|
+
[disabled, readOnly, open, setOpen],
|
|
392
|
+
)
|
|
393
|
+
|
|
394
|
+
const handleTimeChange = React.useCallback(
|
|
395
|
+
(hour: number, minute: number, second: number) => {
|
|
396
|
+
setTimeEmpty(false)
|
|
397
|
+
const base = (usesPanelDraft ? draftValue : value) ?? viewDate.startOf('day')
|
|
398
|
+
const updated = base.hour(hour).minute(minute).second(second)
|
|
399
|
+
if (usesPanelDraft) {
|
|
400
|
+
setDraftValue(updated)
|
|
401
|
+
return
|
|
402
|
+
}
|
|
403
|
+
if (!isControlled) setInternalValue(updated)
|
|
404
|
+
onChange?.(updated, formatDate(updated, resolvedFormat))
|
|
405
|
+
},
|
|
406
|
+
[usesPanelDraft, draftValue, value, viewDate, isControlled, onChange, resolvedFormat],
|
|
407
|
+
)
|
|
408
|
+
|
|
409
|
+
// ---------- context value ----------
|
|
410
|
+
const ctxValue = React.useMemo(
|
|
411
|
+
() => ({
|
|
412
|
+
picker,
|
|
413
|
+
view,
|
|
414
|
+
setView,
|
|
415
|
+
viewDate,
|
|
416
|
+
setViewDate,
|
|
417
|
+
focused,
|
|
418
|
+
setFocused,
|
|
419
|
+
format: resolvedFormat,
|
|
420
|
+
showTime,
|
|
421
|
+
needConfirm,
|
|
422
|
+
disabledDate: wrappedDisabled,
|
|
423
|
+
size,
|
|
424
|
+
status,
|
|
425
|
+
disabled,
|
|
426
|
+
locale: resolvedLocale,
|
|
427
|
+
isRange: false,
|
|
428
|
+
showToday,
|
|
429
|
+
value: panelValue,
|
|
430
|
+
onClose: handleClose,
|
|
431
|
+
onConfirm: handleConfirm,
|
|
432
|
+
onClear: handleFooterClear,
|
|
433
|
+
onToday: handleToday,
|
|
434
|
+
onTimeChange: handleTimeChange,
|
|
435
|
+
timeEmpty: showTime ? timeEmpty : undefined,
|
|
436
|
+
}),
|
|
437
|
+
[
|
|
438
|
+
picker,
|
|
439
|
+
view,
|
|
440
|
+
viewDate,
|
|
441
|
+
focused,
|
|
442
|
+
resolvedFormat,
|
|
443
|
+
showTime,
|
|
444
|
+
needConfirm,
|
|
445
|
+
wrappedDisabled,
|
|
446
|
+
size,
|
|
447
|
+
status,
|
|
448
|
+
disabled,
|
|
449
|
+
resolvedLocale,
|
|
450
|
+
showToday,
|
|
451
|
+
panelValue,
|
|
452
|
+
timeEmpty,
|
|
453
|
+
handleClose,
|
|
454
|
+
handleConfirm,
|
|
455
|
+
handleFooterClear,
|
|
456
|
+
handleToday,
|
|
457
|
+
handleTimeChange,
|
|
458
|
+
],
|
|
459
|
+
)
|
|
460
|
+
|
|
461
|
+
// ---------- root data-* attributes ----------
|
|
462
|
+
const rootDataAttrs: Record<string, string | undefined> = {
|
|
463
|
+
'data-slot': 'date-picker',
|
|
464
|
+
'data-size': size,
|
|
465
|
+
'data-variant': resolveInputVariant(variant),
|
|
466
|
+
'data-picker': picker,
|
|
467
|
+
'data-disabled': disabled ? '' : undefined,
|
|
468
|
+
'data-readonly': readOnly ? '' : undefined,
|
|
469
|
+
'data-status': status,
|
|
470
|
+
'data-invalid': status === 'error' ? '' : undefined,
|
|
471
|
+
'data-open': open ? '' : undefined,
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const popupOverlay = useAnchoredOverlay({
|
|
475
|
+
open,
|
|
476
|
+
onOpenChange: setOpen,
|
|
477
|
+
closeWhenReferenceHidden: true,
|
|
478
|
+
closeOnScroll,
|
|
479
|
+
referenceElement: wrapperRef.current,
|
|
480
|
+
side: 'bottom',
|
|
481
|
+
align: 'start',
|
|
482
|
+
sideOffset: 4,
|
|
483
|
+
onPointerDownOutside: (e) => {
|
|
484
|
+
if (wrapperRef.current?.contains(e.target as Node)) e.preventDefault()
|
|
485
|
+
},
|
|
486
|
+
onInteractOutside: (e) => {
|
|
487
|
+
if (wrapperRef.current?.contains(e.target as Node)) e.preventDefault()
|
|
488
|
+
},
|
|
489
|
+
})
|
|
490
|
+
|
|
491
|
+
const matchingPresetIndexes = presets.flatMap((preset, index) => {
|
|
492
|
+
if (preset.disabled) return []
|
|
493
|
+
const resolved =
|
|
494
|
+
typeof preset.value === 'function' ? resolvedPresets.get(preset.key) : preset.value
|
|
495
|
+
return matchesPresetDate(panelValue, resolved) ? [index] : []
|
|
496
|
+
})
|
|
497
|
+
const activePresetIndex =
|
|
498
|
+
matchingPresetIndexes.find((index) => presets[index].key === preferredPresetKey) ??
|
|
499
|
+
matchingPresetIndexes[0]
|
|
500
|
+
const seenKeys = new Map<string, number>()
|
|
501
|
+
const panelContent = (
|
|
502
|
+
<DatePickerProvider value={ctxValue}>
|
|
503
|
+
<Panel
|
|
504
|
+
onSelect={handleSelect}
|
|
505
|
+
onClose={handleClose}
|
|
506
|
+
onConfirm={handleConfirm}
|
|
507
|
+
onToday={handleToday}
|
|
508
|
+
onClear={handleFooterClear}
|
|
509
|
+
confirmDisabled={confirmDisabled}
|
|
510
|
+
clearDisabled={clearDisabled}
|
|
511
|
+
popupClassName={hasPresets ? undefined : popupClassName}
|
|
512
|
+
/>
|
|
513
|
+
</DatePickerProvider>
|
|
514
|
+
)
|
|
515
|
+
|
|
516
|
+
return (
|
|
517
|
+
<>
|
|
518
|
+
<div
|
|
519
|
+
ref={setWrapperRef}
|
|
520
|
+
className={cn(
|
|
521
|
+
dpVariants({ range: false, size, variant: resolveInputVariant(variant) }),
|
|
522
|
+
className,
|
|
523
|
+
)}
|
|
524
|
+
style={style}
|
|
525
|
+
{...rootDataAttrs}
|
|
526
|
+
>
|
|
527
|
+
<div
|
|
528
|
+
className="apex-datepicker__inner apex-input__inner"
|
|
529
|
+
data-status={status}
|
|
530
|
+
data-disabled={disabled ? true : undefined}
|
|
531
|
+
data-readonly={readOnly || undefined}
|
|
532
|
+
onClick={handleInnerClick}
|
|
533
|
+
>
|
|
534
|
+
<Trigger
|
|
535
|
+
ref={triggerRef}
|
|
536
|
+
dateValue={value}
|
|
537
|
+
format={resolvedFormat}
|
|
538
|
+
placeholder={resolvedPlaceholder}
|
|
539
|
+
disabled={disabled}
|
|
540
|
+
readOnly={readOnly}
|
|
541
|
+
allowClear={allowClear}
|
|
542
|
+
onClear={handleClear}
|
|
543
|
+
aria-label={resolvedPlaceholder}
|
|
544
|
+
aria-expanded={open}
|
|
545
|
+
onClick={handleTriggerClick}
|
|
546
|
+
/>
|
|
547
|
+
</div>
|
|
548
|
+
</div>
|
|
549
|
+
|
|
550
|
+
<AnchoredOverlayContent
|
|
551
|
+
overlay={popupOverlay}
|
|
552
|
+
overlayKind="date-picker"
|
|
553
|
+
className={cn(
|
|
554
|
+
'apex-datepicker__popup',
|
|
555
|
+
hasPresets &&
|
|
556
|
+
'apex-datepicker-panel apex-datepicker apex-default-datepicker apex-datepicker-button apex-default-datepicker-button apex-datepicker-panel--with-presets shadow',
|
|
557
|
+
hasPresets && popupClassName,
|
|
558
|
+
)}
|
|
559
|
+
aria-label={resolvedLocale.aria.panel}
|
|
560
|
+
style={{ outline: 'none' }}
|
|
561
|
+
>
|
|
562
|
+
{hasPresets ? (
|
|
563
|
+
<div className="apex-datepicker-panel__preset-layout">
|
|
564
|
+
<div className="apex-datepicker-panel__shortcuts" data-slot="date-picker-shortcuts">
|
|
565
|
+
<div className="apex-datepicker-panel__shortcut-list apex-scrollbar">
|
|
566
|
+
{presets.map((preset, index) => {
|
|
567
|
+
const occurrence = seenKeys.get(preset.key) ?? 0
|
|
568
|
+
seenKeys.set(preset.key, occurrence + 1)
|
|
569
|
+
const selected = index === activePresetIndex
|
|
570
|
+
return (
|
|
571
|
+
<Button
|
|
572
|
+
key={JSON.stringify([preset.key, occurrence])}
|
|
573
|
+
variant="outline"
|
|
574
|
+
size="small"
|
|
575
|
+
className="apex-datepicker-panel__shortcut"
|
|
576
|
+
data-slot="date-picker-shortcut"
|
|
577
|
+
data-selected={selected ? '' : undefined}
|
|
578
|
+
aria-pressed={selected}
|
|
579
|
+
aria-disabled={disabled || readOnly || preset.disabled || undefined}
|
|
580
|
+
disabled={disabled || readOnly || preset.disabled}
|
|
581
|
+
onClick={() => handlePresetClick(preset)}
|
|
582
|
+
>
|
|
583
|
+
<span className="apex-datepicker-panel__shortcut-label">{preset.label}</span>
|
|
584
|
+
</Button>
|
|
585
|
+
)
|
|
586
|
+
})}
|
|
587
|
+
</div>
|
|
588
|
+
</div>
|
|
589
|
+
<div className="apex-datepicker-panel__preset-content">{panelContent}</div>
|
|
590
|
+
</div>
|
|
591
|
+
) : (
|
|
592
|
+
panelContent
|
|
593
|
+
)}
|
|
594
|
+
</AnchoredOverlayContent>
|
|
595
|
+
</>
|
|
596
|
+
)
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
DatePicker.displayName = 'ApexDatePicker'
|
|
600
|
+
|
|
601
|
+
export default DatePicker
|