@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,131 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import './switch.css'
|
|
4
|
+
import { Switch as SwitchPrimitive } from 'radix-ui'
|
|
5
|
+
import * as React from 'react'
|
|
6
|
+
import { cn } from '../utils/cn'
|
|
7
|
+
import type { SwitchChangeEvent, SwitchProps, SwitchRootProps, SwitchThumbProps } from './interface'
|
|
8
|
+
import { switchRootVariants } from './variants'
|
|
9
|
+
|
|
10
|
+
/** 读取当前选中态:受控用 prop,非受控读 Radix `data-state` */
|
|
11
|
+
function getIsChecked(checked: boolean | undefined, target: HTMLButtonElement): boolean {
|
|
12
|
+
if (checked !== undefined) return checked
|
|
13
|
+
return target.getAttribute('data-state') === 'checked'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Switch.Root — 底层 Radix 封装(组合用法保留)
|
|
18
|
+
*/
|
|
19
|
+
export const SwitchRoot: React.FC<SwitchRootProps> = ({
|
|
20
|
+
checked,
|
|
21
|
+
defaultChecked = false,
|
|
22
|
+
disabled = false,
|
|
23
|
+
loading = false,
|
|
24
|
+
size = 'medium',
|
|
25
|
+
checkedChildren,
|
|
26
|
+
unCheckedChildren,
|
|
27
|
+
className,
|
|
28
|
+
onChange,
|
|
29
|
+
onClick,
|
|
30
|
+
ref,
|
|
31
|
+
style,
|
|
32
|
+
children,
|
|
33
|
+
onKeyDown,
|
|
34
|
+
onPointerDown,
|
|
35
|
+
...rest
|
|
36
|
+
}) => {
|
|
37
|
+
const lastEventRef = React.useRef<SwitchChangeEvent | null>(null)
|
|
38
|
+
const onChangeRef = React.useRef(onChange)
|
|
39
|
+
onChangeRef.current = onChange
|
|
40
|
+
|
|
41
|
+
const isDisabled = disabled || loading
|
|
42
|
+
const hasInner = Boolean(checkedChildren ?? unCheckedChildren)
|
|
43
|
+
const isControlled = checked !== undefined
|
|
44
|
+
const radixCheckedProps = isControlled ? { checked } : { defaultChecked }
|
|
45
|
+
|
|
46
|
+
const handleCheckedChange = React.useCallback((next: boolean) => {
|
|
47
|
+
const event = lastEventRef.current
|
|
48
|
+
lastEventRef.current = null
|
|
49
|
+
onChangeRef.current?.(next, event ?? undefined)
|
|
50
|
+
}, [])
|
|
51
|
+
|
|
52
|
+
const handlePointerDown = (event: React.PointerEvent<HTMLButtonElement>) => {
|
|
53
|
+
lastEventRef.current = event
|
|
54
|
+
onPointerDown?.(event)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {
|
|
58
|
+
if (event.key === ' ') lastEventRef.current = event
|
|
59
|
+
onKeyDown?.(event)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
63
|
+
if (isDisabled) {
|
|
64
|
+
event.preventDefault()
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
const current = getIsChecked(checked, event.currentTarget)
|
|
68
|
+
onClick?.(!current, event)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<SwitchPrimitive.Root
|
|
73
|
+
ref={ref}
|
|
74
|
+
data-slot="switch"
|
|
75
|
+
data-size={size}
|
|
76
|
+
data-loading={loading ? true : undefined}
|
|
77
|
+
aria-busy={loading || undefined}
|
|
78
|
+
disabled={isDisabled}
|
|
79
|
+
className={cn(
|
|
80
|
+
switchRootVariants({ size }),
|
|
81
|
+
hasInner && 'apex-switch--with-inner',
|
|
82
|
+
loading && 'apex-switch--loading',
|
|
83
|
+
className,
|
|
84
|
+
)}
|
|
85
|
+
style={style}
|
|
86
|
+
{...radixCheckedProps}
|
|
87
|
+
onCheckedChange={handleCheckedChange}
|
|
88
|
+
onPointerDown={handlePointerDown}
|
|
89
|
+
onKeyDown={handleKeyDown}
|
|
90
|
+
onClick={handleClick}
|
|
91
|
+
{...rest}
|
|
92
|
+
>
|
|
93
|
+
{hasInner ? (
|
|
94
|
+
<span className="apex-switch__inner" aria-hidden="true">
|
|
95
|
+
{checkedChildren != null ? (
|
|
96
|
+
<span className="apex-switch__inner-checked">{checkedChildren}</span>
|
|
97
|
+
) : null}
|
|
98
|
+
{unCheckedChildren != null ? (
|
|
99
|
+
<span className="apex-switch__inner-unchecked">{unCheckedChildren}</span>
|
|
100
|
+
) : null}
|
|
101
|
+
</span>
|
|
102
|
+
) : null}
|
|
103
|
+
{children}
|
|
104
|
+
</SwitchPrimitive.Root>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
SwitchRoot.displayName = 'SwitchRoot'
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Switch.Thumb — 圆形滑块
|
|
111
|
+
*/
|
|
112
|
+
export const SwitchThumb: React.FC<SwitchThumbProps> = ({ className, ...props }) => (
|
|
113
|
+
<SwitchPrimitive.Thumb
|
|
114
|
+
data-slot="switch-thumb"
|
|
115
|
+
className={cn('apex-switch__thumb', 'shadow', className)}
|
|
116
|
+
{...props}
|
|
117
|
+
/>
|
|
118
|
+
)
|
|
119
|
+
SwitchThumb.displayName = 'SwitchThumb'
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Switch — antd 风格开箱即用开关
|
|
123
|
+
*/
|
|
124
|
+
export const Switch: React.FC<SwitchProps> = (props) => (
|
|
125
|
+
<SwitchRoot {...props}>
|
|
126
|
+
<SwitchThumb />
|
|
127
|
+
</SwitchRoot>
|
|
128
|
+
)
|
|
129
|
+
Switch.displayName = 'Switch'
|
|
130
|
+
|
|
131
|
+
export default Switch
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { Switch as SwitchPrimitive } from 'radix-ui'
|
|
2
|
+
import type * as React from 'react'
|
|
3
|
+
import type { SwitchVariants } from './variants'
|
|
4
|
+
|
|
5
|
+
/** `onChange` 的 event 参数(鼠标点击或 Space 键盘) */
|
|
6
|
+
export type SwitchChangeEvent =
|
|
7
|
+
| React.MouseEvent<HTMLButtonElement>
|
|
8
|
+
| React.KeyboardEvent<HTMLButtonElement>
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Switch 组件 Props(对齐 antd Switch)
|
|
12
|
+
*
|
|
13
|
+
* - 对外使用 `onChange`,不使用 Radix `onCheckedChange`
|
|
14
|
+
* - `ref` 指向底层 `button`(React 19 普通 prop)
|
|
15
|
+
* - 常用透传:`id`、`name`、`required`、`autoFocus`、`tabIndex`、`aria-label` 等
|
|
16
|
+
*/
|
|
17
|
+
export interface SwitchProps
|
|
18
|
+
extends Omit<
|
|
19
|
+
React.ComponentProps<typeof SwitchPrimitive.Root>,
|
|
20
|
+
| 'checked'
|
|
21
|
+
| 'defaultChecked'
|
|
22
|
+
| 'onCheckedChange'
|
|
23
|
+
| 'onChange'
|
|
24
|
+
| 'onClick'
|
|
25
|
+
| 'children'
|
|
26
|
+
| 'value'
|
|
27
|
+
| 'defaultValue'
|
|
28
|
+
| 'asChild'
|
|
29
|
+
> {
|
|
30
|
+
/**
|
|
31
|
+
* 受控选中状态;未传则为非受控
|
|
32
|
+
*/
|
|
33
|
+
checked?: boolean
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 非受控初始选中
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
defaultChecked?: boolean
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 是否禁用
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
disabled?: boolean
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 加载中,行为等同禁用,并设置 `data-loading` / `aria-busy`
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
loading?: boolean
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 开关尺寸
|
|
55
|
+
* @default 'medium'
|
|
56
|
+
*/
|
|
57
|
+
size?: SwitchVariants['size']
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 选中时轨道内内容(文案或图标)
|
|
61
|
+
*/
|
|
62
|
+
checkedChildren?: React.ReactNode
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 未选中时轨道内内容(文案或图标)
|
|
66
|
+
*/
|
|
67
|
+
unCheckedChildren?: React.ReactNode
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 状态变化;`event` 在用户点击或按 Space 时提供
|
|
71
|
+
*/
|
|
72
|
+
onChange?: (checked: boolean, event?: SwitchChangeEvent) => void
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 点击回调;`checked` 为切换后的状态
|
|
76
|
+
*/
|
|
77
|
+
onClick?: (checked: boolean, event: React.MouseEvent<HTMLButtonElement>) => void
|
|
78
|
+
|
|
79
|
+
/** 根节点 class */
|
|
80
|
+
className?: string
|
|
81
|
+
|
|
82
|
+
/** 根节点 ref(指向 `HTMLButtonElement`) */
|
|
83
|
+
ref?: React.Ref<HTMLButtonElement>
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** `Switch.Thumb` 组合用法 props */
|
|
87
|
+
export interface SwitchThumbProps extends React.ComponentProps<typeof SwitchPrimitive.Thumb> {}
|
|
88
|
+
|
|
89
|
+
/** `SwitchRoot` 组合用法:可传入子节点(如 `SwitchThumb`) */
|
|
90
|
+
export interface SwitchRootProps extends SwitchProps {
|
|
91
|
+
children?: React.ReactNode
|
|
92
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# Switch
|
|
2
|
+
|
|
3
|
+
> Switch:需要立即生效的开关型设置(如启用通知、暗色模式)时。
|
|
4
|
+
|
|
5
|
+
版本:`1.2.0`。组件源码在本目录,属于当前项目。
|
|
6
|
+
|
|
7
|
+
公开导出:`Switch`、`SwitchRoot`、`SwitchThumb`。
|
|
8
|
+
|
|
9
|
+
以下 API 属于 Apex UI;不要据 antd 的同名组件推断额外属性或默认值。默认值列的空缺表示未声明,不代表 `false`。
|
|
10
|
+
|
|
11
|
+
## 快速开始
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Switch } from '@/components/apex/switch'
|
|
15
|
+
|
|
16
|
+
export default () => <Switch defaultChecked aria-label="启用通知" />
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 何时使用
|
|
20
|
+
|
|
21
|
+
- 需要立即生效的开关型设置(如启用通知、暗色模式)时。
|
|
22
|
+
- 状态只有开/关两种,且切换后无需额外确认时。
|
|
23
|
+
- 若选项超过两个或需要展示全部可选项,请使用 Radio 或 Select,而不是 Switch。
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
仅使用类型定义支持的属性;原生属性、ref 目标和事件签名因组件而异。关联类型用于解释字段结构;只有「导出类型」中的名称可从包根导入。
|
|
28
|
+
|
|
29
|
+
### Switch
|
|
30
|
+
|
|
31
|
+
| 属性 | 说明 | 类型 | 必填 | 默认值 |
|
|
32
|
+
| --- | --- | --- | --- | --- |
|
|
33
|
+
| checked | 受控选中状态;未传则为非受控 | `boolean` | 否 | — |
|
|
34
|
+
| defaultChecked | 非受控初始选中 | `boolean` | 否 | `false` |
|
|
35
|
+
| disabled | 是否禁用 | `boolean` | 否 | `false` |
|
|
36
|
+
| loading | 加载中,行为等同禁用,并设置 `data-loading` / `aria-busy` | `boolean` | 否 | `false` |
|
|
37
|
+
| size | 开关尺寸 | `"small" \| "medium" \| null` | 否 | `'medium'` |
|
|
38
|
+
| checkedChildren | 选中时轨道内内容(文案或图标) | `React.ReactNode` | 否 | — |
|
|
39
|
+
| unCheckedChildren | 未选中时轨道内内容(文案或图标) | `React.ReactNode` | 否 | — |
|
|
40
|
+
| onChange | 状态变化;`event` 在用户点击或按 Space 时提供 | `(checked: boolean, event?: SwitchChangeEvent) => void` | 否 | — |
|
|
41
|
+
| onClick | 点击回调;`checked` 为切换后的状态 | `(checked: boolean, event: React.MouseEvent<HTMLButtonElement>) => void` | 否 | — |
|
|
42
|
+
| className | 根节点 class | `string` | 否 | — |
|
|
43
|
+
| ref | 根节点 ref(指向 `HTMLButtonElement`) | `React.Ref<HTMLButtonElement>` | 否 | — |
|
|
44
|
+
|
|
45
|
+
### SwitchChangeEvent
|
|
46
|
+
|
|
47
|
+
`onChange` 的 event 参数(鼠标点击或 Space 键盘)
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
type SwitchChangeEvent = | React.MouseEvent<HTMLButtonElement>
|
|
51
|
+
| React.KeyboardEvent<HTMLButtonElement>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### SwitchThumbProps
|
|
55
|
+
|
|
56
|
+
继承:`React.ComponentProps<typeof SwitchPrimitive.Thumb>`;本节列出新增或重声明字段。
|
|
57
|
+
|
|
58
|
+
`Switch.Thumb` 组合用法 props
|
|
59
|
+
|
|
60
|
+
(暂无属性)
|
|
61
|
+
|
|
62
|
+
### SwitchRootProps
|
|
63
|
+
|
|
64
|
+
继承:`SwitchProps`;本节列出新增或重声明字段。
|
|
65
|
+
|
|
66
|
+
`SwitchRoot` 组合用法:可传入子节点(如 `SwitchThumb`)
|
|
67
|
+
|
|
68
|
+
| 属性 | 说明 | 类型 | 必填 | 默认值 |
|
|
69
|
+
| --- | --- | --- | --- | --- |
|
|
70
|
+
| children | — | `React.ReactNode` | 否 | — |
|
|
71
|
+
|
|
72
|
+
### SwitchVariants
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
type SwitchVariants = VariantProps<typeof switchRootVariants>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 导出类型
|
|
79
|
+
|
|
80
|
+
类型从本组件目录导入:`SwitchProps`、`SwitchThumbProps`(与上文子类型配合使用)。
|
|
81
|
+
|
|
82
|
+
## 代码演示
|
|
83
|
+
|
|
84
|
+
### 禁用状态
|
|
85
|
+
|
|
86
|
+
通过 `disabled` 禁止切换。
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { Switch } from '@/components/apex/switch'
|
|
90
|
+
|
|
91
|
+
export default () => (
|
|
92
|
+
<div style={{ display: 'flex', gap: 16, alignItems: 'center' }}>
|
|
93
|
+
<Switch disabled aria-label="禁用未开" />
|
|
94
|
+
<Switch disabled defaultChecked aria-label="禁用已开" />
|
|
95
|
+
</div>
|
|
96
|
+
)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 轨道内内容
|
|
100
|
+
|
|
101
|
+
通过 `checkedChildren` 和 `unCheckedChildren` 在轨道内展示不同内容。
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
import { Switch } from '@/components/apex/switch'
|
|
105
|
+
|
|
106
|
+
export default () => (
|
|
107
|
+
<div style={{ display: 'flex', gap: 16, alignItems: 'center' }}>
|
|
108
|
+
<Switch checkedChildren="开" unCheckedChildren="关" defaultChecked aria-label="文字开关" />
|
|
109
|
+
<Switch checkedChildren="1" unCheckedChildren="0" aria-label="数字开关" />
|
|
110
|
+
</div>
|
|
111
|
+
)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 尺寸
|
|
115
|
+
|
|
116
|
+
支持 `medium`(默认)和 `small` 两种尺寸。
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
import { Switch } from '@/components/apex/switch'
|
|
120
|
+
|
|
121
|
+
export default () => (
|
|
122
|
+
<div style={{ display: 'flex', gap: 16, alignItems: 'center' }}>
|
|
123
|
+
<Switch size="medium" defaultChecked aria-label="中号开关" />
|
|
124
|
+
<Switch size="small" defaultChecked aria-label="小号开关" />
|
|
125
|
+
</div>
|
|
126
|
+
)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 加载中
|
|
130
|
+
|
|
131
|
+
`loading` 表示开关操作仍在执行中,行为等同禁用。
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import { Switch } from '@/components/apex/switch'
|
|
135
|
+
|
|
136
|
+
export default () => (
|
|
137
|
+
<div style={{ display: 'flex', gap: 16, alignItems: 'center' }}>
|
|
138
|
+
<Switch loading defaultChecked aria-label="加载中已开" />
|
|
139
|
+
<Switch loading size="small" aria-label="小号加载中" />
|
|
140
|
+
</div>
|
|
141
|
+
)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### 受控用法
|
|
145
|
+
|
|
146
|
+
通过 `checked` 和 变更事件 控制开关状态。
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import { Switch } from '@/components/apex/switch'
|
|
150
|
+
|
|
151
|
+
import { useState } from 'react'
|
|
152
|
+
|
|
153
|
+
export default () => {
|
|
154
|
+
const [checked, setChecked] = useState(false)
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<div style={{ display: 'flex', gap: 12, alignItems: 'center' }}>
|
|
158
|
+
<Switch checked={checked} onChange={setChecked} aria-label="受控开关" />
|
|
159
|
+
<span>{checked ? '已开启' : '已关闭'}</span>
|
|
160
|
+
</div>
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### 事件回调
|
|
166
|
+
|
|
167
|
+
变更事件 在状态变化时触发;点击事件 在点击时触发,二者都会收到切换后的 `checked` 值。
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
import { Switch } from '@/components/apex/switch'
|
|
171
|
+
|
|
172
|
+
import { useState } from 'react'
|
|
173
|
+
|
|
174
|
+
export default () => {
|
|
175
|
+
const [message, setMessage] = useState('等待操作')
|
|
176
|
+
|
|
177
|
+
return (
|
|
178
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, alignItems: 'flex-start' }}>
|
|
179
|
+
<Switch
|
|
180
|
+
aria-label="事件开关"
|
|
181
|
+
onChange={(checked) => setMessage(`onChange: ${checked ? '开启' : '关闭'}`)}
|
|
182
|
+
onClick={(checked) => setMessage(`onClick: ${checked ? '开启' : '关闭'}`)}
|
|
183
|
+
/>
|
|
184
|
+
<span>{message}</span>
|
|
185
|
+
</div>
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## DOM 结构
|
|
191
|
+
|
|
192
|
+
源码声明的静态 `data-slot`:`switch`、`switch-thumb`。具体节点随模式和状态出现,不表示固定嵌套顺序。
|
|
193
|
+
|
|
194
|
+
## 样式定制
|
|
195
|
+
|
|
196
|
+
优先使用本组件公开的尺寸、类型和状态属性。换肤与变量覆盖方式见 [主题指南](../llms-theme.txt)。
|
|
197
|
+
|
|
198
|
+
需要定制具体样式时再读取 [Token 明细](./tokens.txt),其中包含用途、定义值及适用作用域。常规组件使用无需加载该文件。
|
|
199
|
+
|
|
200
|
+
## FAQ
|
|
201
|
+
|
|
202
|
+
### 表单里应该用 `value` 还是 `checked`?
|
|
203
|
+
|
|
204
|
+
Switch 不提供 `value` / `defaultValue` 别名;与 Form 集成时请使用 `valuePropName="checked"`。
|
|
205
|
+
|
|
206
|
+
### `loading` 和 `disabled` 有什么区别?
|
|
207
|
+
|
|
208
|
+
二者都会阻止切换且不触发 `onChange` / `onClick`;`loading` 额外展示加载态并设置 `aria-busy`,表示操作仍在进行中。
|
|
209
|
+
|
|
210
|
+
### 为什么没有 `classNames` / `styles` 分段定制?
|
|
211
|
+
|
|
212
|
+
当前版本不支持 antd 式语义分段覆写;样式定制请通过根节点 `className`、`data-slot` 与 CSS Token 实现。
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/* ==========================================================================
|
|
2
|
+
Switch — 消费 component-tokens.css 局部变量(--switch-*)
|
|
3
|
+
作用域:apex-default-switch(色板)+ apex-md-switch / apex-sm-switch(尺寸)
|
|
4
|
+
========================================================================== */
|
|
5
|
+
|
|
6
|
+
:where(.apex-switch) {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: flex-start;
|
|
10
|
+
width: var(--switch-spacing-width);
|
|
11
|
+
height: var(--switch-spacing-height);
|
|
12
|
+
border-radius: var(--switch-radius-radius);
|
|
13
|
+
background-color: var(--switch-fill-off);
|
|
14
|
+
border: none;
|
|
15
|
+
padding: 0;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
flex-shrink: 0;
|
|
18
|
+
position: relative;
|
|
19
|
+
outline: none;
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.apex-switch:focus-visible {
|
|
25
|
+
outline: 2px solid var(--switch-fill-on);
|
|
26
|
+
outline-offset: 2px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.apex-switch[data-state='checked'] {
|
|
30
|
+
background-color: var(--switch-fill-on);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.apex-switch[data-disabled],
|
|
34
|
+
.apex-switch[data-loading] {
|
|
35
|
+
cursor: not-allowed;
|
|
36
|
+
background-color: var(--switch-fill-off-disabled);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.apex-switch[data-disabled][data-state='checked'],
|
|
40
|
+
.apex-switch[data-loading][data-state='checked'] {
|
|
41
|
+
background-color: var(--switch-fill-on-disabled);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* ── 轨道内文案 / 图标(antd:关→文字在右,开→文字在左)──────────────── */
|
|
45
|
+
|
|
46
|
+
.apex-switch--with-inner {
|
|
47
|
+
width: auto;
|
|
48
|
+
min-width: var(--switch-spacing-width);
|
|
49
|
+
padding-inline: calc(var(--switch-spacing-height-toggle) + var(--switch-spacing-padding-text))
|
|
50
|
+
calc(var(--switch-spacing-padding-text) * 2);
|
|
51
|
+
transition:
|
|
52
|
+
background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
|
|
53
|
+
padding-inline 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.apex-switch--with-inner[data-state='checked'] {
|
|
57
|
+
padding-inline: calc(var(--switch-spacing-padding-text) * 2)
|
|
58
|
+
calc(var(--switch-spacing-height-toggle) + var(--switch-spacing-padding-text));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.apex-switch__inner {
|
|
62
|
+
display: grid;
|
|
63
|
+
flex: 1;
|
|
64
|
+
align-self: stretch;
|
|
65
|
+
align-items: center;
|
|
66
|
+
min-width: 1.5em;
|
|
67
|
+
min-height: 1em;
|
|
68
|
+
overflow: hidden;
|
|
69
|
+
pointer-events: none;
|
|
70
|
+
user-select: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.apex-switch__inner-checked,
|
|
74
|
+
.apex-switch__inner-unchecked {
|
|
75
|
+
grid-area: 1 / 1;
|
|
76
|
+
overflow: hidden;
|
|
77
|
+
text-overflow: ellipsis;
|
|
78
|
+
white-space: nowrap;
|
|
79
|
+
font-size: var(--switch-icon-icon);
|
|
80
|
+
line-height: 1;
|
|
81
|
+
color: var(--switch-text-off);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.apex-switch__inner-checked {
|
|
85
|
+
justify-self: start;
|
|
86
|
+
visibility: hidden;
|
|
87
|
+
color: var(--switch-text-on);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.apex-switch__inner-unchecked {
|
|
91
|
+
justify-self: end;
|
|
92
|
+
visibility: visible;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.apex-switch[data-state='checked'] .apex-switch__inner-checked {
|
|
96
|
+
visibility: visible;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.apex-switch[data-state='checked'] .apex-switch__inner-unchecked {
|
|
100
|
+
visibility: hidden;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.apex-switch[data-disabled] .apex-switch__inner-unchecked,
|
|
104
|
+
.apex-switch[data-loading] .apex-switch__inner-unchecked {
|
|
105
|
+
color: var(--switch-text-off-desabled);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.apex-switch[data-disabled][data-state='checked'] .apex-switch__inner-checked,
|
|
109
|
+
.apex-switch[data-loading][data-state='checked'] .apex-switch__inner-checked {
|
|
110
|
+
color: var(--switch-text-on-disabled);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* ── Thumb ───────────────────────────────────────────────────────────────── */
|
|
114
|
+
|
|
115
|
+
.apex-switch__thumb {
|
|
116
|
+
position: absolute;
|
|
117
|
+
z-index: 1;
|
|
118
|
+
top: 50%;
|
|
119
|
+
left: var(--switch-spacing-padding-x);
|
|
120
|
+
width: var(--switch-spacing-height-toggle);
|
|
121
|
+
height: var(--switch-spacing-height-toggle);
|
|
122
|
+
margin-top: calc(var(--switch-spacing-height-toggle) / -2);
|
|
123
|
+
border-radius: 50%;
|
|
124
|
+
background-color: var(--switch-toggle-off);
|
|
125
|
+
transform: translateX(0);
|
|
126
|
+
transition:
|
|
127
|
+
transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
|
|
128
|
+
left 0.2s cubic-bezier(0.4, 0, 0.2, 1),
|
|
129
|
+
background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
130
|
+
pointer-events: none;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.apex-switch--with-inner .apex-switch__thumb {
|
|
134
|
+
transform: none;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.apex-switch[data-state='checked'] .apex-switch__thumb {
|
|
138
|
+
background-color: var(--switch-toggle-on);
|
|
139
|
+
transform: translateX(
|
|
140
|
+
calc(
|
|
141
|
+
var(--switch-spacing-width) - var(--switch-spacing-height-toggle) - var(--switch-spacing-padding-x) -
|
|
142
|
+
var(--switch-spacing-padding-x)
|
|
143
|
+
)
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.apex-switch--with-inner[data-state='checked'] .apex-switch__thumb {
|
|
148
|
+
left: calc(100% - var(--switch-spacing-height-toggle) - var(--switch-spacing-padding-x));
|
|
149
|
+
right: auto;
|
|
150
|
+
transform: none;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.apex-switch[data-disabled] .apex-switch__thumb,
|
|
154
|
+
.apex-switch[data-loading] .apex-switch__thumb {
|
|
155
|
+
background-color: var(--switch-toggle-off-disabled);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.apex-switch[data-disabled][data-state='checked'] .apex-switch__thumb,
|
|
159
|
+
.apex-switch[data-loading][data-state='checked'] .apex-switch__thumb {
|
|
160
|
+
background-color: var(--switch-toggle-on-disabled);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* ── Loading ─────────────────────────────────────────────────────────────── */
|
|
164
|
+
|
|
165
|
+
@keyframes apex-switch-spin {
|
|
166
|
+
from {
|
|
167
|
+
transform: rotate(0deg);
|
|
168
|
+
}
|
|
169
|
+
to {
|
|
170
|
+
transform: rotate(360deg);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.apex-switch--loading .apex-switch__thumb::after {
|
|
175
|
+
content: '';
|
|
176
|
+
position: absolute;
|
|
177
|
+
inset: 2px;
|
|
178
|
+
border: 2px solid currentColor;
|
|
179
|
+
border-top-color: transparent;
|
|
180
|
+
border-radius: 50%;
|
|
181
|
+
animation: apex-switch-spin 0.8s linear infinite;
|
|
182
|
+
opacity: 0.9;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.apex-switch--loading[data-state='checked'] .apex-switch__thumb {
|
|
186
|
+
transform: translateX(
|
|
187
|
+
calc(
|
|
188
|
+
var(--switch-spacing-width) - var(--switch-spacing-height-toggle) - var(--switch-spacing-padding-x) -
|
|
189
|
+
var(--switch-spacing-padding-x)
|
|
190
|
+
)
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.apex-switch--loading.apex-switch--with-inner[data-state='checked'] .apex-switch__thumb {
|
|
195
|
+
left: calc(100% - var(--switch-spacing-height-toggle) - var(--switch-spacing-padding-x));
|
|
196
|
+
right: auto;
|
|
197
|
+
transform: none;
|
|
198
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Switch Token 明细
|
|
2
|
+
|
|
3
|
+
包:`@apexhub/apex-ui-react`;版本:`1.2.0`(当前源码快照)。
|
|
4
|
+
|
|
5
|
+
按需读取:[组件用法](./llm.txt) · [主题与覆盖规则](../../llms-theme.txt)。
|
|
6
|
+
|
|
7
|
+
以下组件变量在设计 Token 源中已定义,并被组件或其共享样式使用;不包含仅在实现中声明的临时变量。用途来自实际 CSS 属性,不是对外新增的 Props。
|
|
8
|
+
|
|
9
|
+
定义值依赖所列尺寸、变体、状态和媒体作用域;Alias 引用还会随 light/dark 主题改变。它们不是统一默认值或最终计算值。作用域用于解释定义位置,不代表内部选择器是稳定的定制 API。
|
|
10
|
+
|
|
11
|
+
| Token | 用途(CSS 属性) | 定义值 | 定义作用域 |
|
|
12
|
+
| --- | --- | --- | --- |
|
|
13
|
+
| `--switch-fill-off` | `background-color` | `var(--apex-fill-neutral-septenary)` | `.apex-switch.apex-default-switch` |
|
|
14
|
+
| `--switch-fill-off-disabled` | `background-color` | `var(--apex-fill-neutral-septenary)` | `.apex-switch.apex-default-switch` |
|
|
15
|
+
| `--switch-fill-on` | `background-color`、`outline` | `var(--apex-fill-brand-primary)` | `.apex-switch.apex-default-switch` |
|
|
16
|
+
| `--switch-fill-on-disabled` | `background-color` | `var(--apex-fill-brand-disabled)` | `.apex-switch.apex-default-switch` |
|
|
17
|
+
| `--switch-icon-icon` | `font-size` | `var(--apex-icon-12)` | `.apex-switch.apex-md-switch` |
|
|
18
|
+
| `--switch-icon-icon` | `font-size` | `var(--apex-icon-12)` | `.apex-switch.apex-sm-switch` |
|
|
19
|
+
| `--switch-radius-radius` | `border-radius` | `var(--apex-radius-999)` | `.apex-switch.apex-md-switch` |
|
|
20
|
+
| `--switch-radius-radius` | `border-radius` | `var(--apex-radius-999)` | `.apex-switch.apex-sm-switch` |
|
|
21
|
+
| `--switch-spacing-height` | `height` | `var(--apex-size-24)` | `.apex-switch.apex-md-switch` |
|
|
22
|
+
| `--switch-spacing-height` | `height` | `var(--apex-size-16)` | `.apex-switch.apex-sm-switch` |
|
|
23
|
+
| `--switch-spacing-height-toggle` | `height`、`left`、`margin-top`、`padding-inline`、`transform`、`width` | `var(--apex-size-20)` | `.apex-switch.apex-md-switch` |
|
|
24
|
+
| `--switch-spacing-height-toggle` | `height`、`left`、`margin-top`、`padding-inline`、`transform`、`width` | `var(--apex-size-12)` | `.apex-switch.apex-sm-switch` |
|
|
25
|
+
| `--switch-spacing-padding-text` | `padding-inline` | `var(--apex-spacing-4)` | `.apex-switch.apex-md-switch` |
|
|
26
|
+
| `--switch-spacing-padding-text` | `padding-inline` | `var(--apex-spacing-4)` | `.apex-switch.apex-sm-switch` |
|
|
27
|
+
| `--switch-spacing-padding-x` | `left`、`transform` | `var(--apex-spacing-2)` | `.apex-switch.apex-md-switch` |
|
|
28
|
+
| `--switch-spacing-padding-x` | `left`、`transform` | `var(--apex-spacing-2)` | `.apex-switch.apex-sm-switch` |
|
|
29
|
+
| `--switch-spacing-width` | `min-width`、`transform`、`width` | `var(--apex-size-44)` | `.apex-switch.apex-md-switch` |
|
|
30
|
+
| `--switch-spacing-width` | `min-width`、`transform`、`width` | `var(--apex-size-28)` | `.apex-switch.apex-sm-switch` |
|
|
31
|
+
| `--switch-text-off` | `color` | `var(--apex-text-neutral-primary)` | `.apex-switch.apex-default-switch` |
|
|
32
|
+
| `--switch-text-off-desabled` | `color` | `var(--apex-text-neutral-disabled)` | `.apex-switch.apex-default-switch` |
|
|
33
|
+
| `--switch-text-on` | `color` | `var(--apex-text-neutral-primary)` | `.apex-switch.apex-default-switch` |
|
|
34
|
+
| `--switch-text-on-disabled` | `color` | `var(--apex-text-neutral-disabled)` | `.apex-switch.apex-default-switch` |
|
|
35
|
+
| `--switch-toggle-off` | `background-color` | `var(--apex-fill-neutral-denary-stable)` | `.apex-switch.apex-default-switch` |
|
|
36
|
+
| `--switch-toggle-off-disabled` | `background-color` | `var(--apex-fill-neutral-octonary-stable)` | `.apex-switch.apex-default-switch` |
|
|
37
|
+
| `--switch-toggle-on` | `background-color` | `var(--apex-fill-neutral-denary-stable)` | `.apex-switch.apex-default-switch` |
|
|
38
|
+
| `--switch-toggle-on-disabled` | `background-color` | `var(--apex-fill-neutral-octonary-stable)` | `.apex-switch.apex-default-switch` |
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
2
|
+
|
|
3
|
+
export const switchRootVariants = cva('apex-switch apex-default-switch', {
|
|
4
|
+
variants: {
|
|
5
|
+
size: {
|
|
6
|
+
small: 'apex-sm-switch',
|
|
7
|
+
medium: 'apex-md-switch',
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
defaultVariants: {
|
|
11
|
+
size: 'medium',
|
|
12
|
+
},
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export type SwitchVariants = VariantProps<typeof switchRootVariants>
|