@invoiceonline/ui-react 0.0.0-stage → 0.1.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/AGENTS.md +99 -0
- package/CHANGELOG.md +131 -0
- package/LICENSE +9 -0
- package/README.md +78 -2
- package/dist/assets/label-brush-1.svg +6 -0
- package/dist/assets/pattern-dark.svg +113 -0
- package/dist/components/action-row/ActionRow.d.ts +178 -0
- package/dist/components/action-row/ActionRow.js +340 -0
- package/dist/components/action-row/index.d.ts +2 -0
- package/dist/components/action-row/index.js +1 -0
- package/dist/components/alert/Alert.d.ts +314 -0
- package/dist/components/alert/Alert.js +446 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/alert/index.js +1 -0
- package/dist/components/anchored-panel/AnchoredPanel.d.ts +41 -0
- package/dist/components/anchored-panel/AnchoredPanel.js +72 -0
- package/dist/components/anchored-panel/index.d.ts +3 -0
- package/dist/components/anchored-panel/index.js +3 -0
- package/dist/components/badge/Badge.d.ts +146 -0
- package/dist/components/badge/Badge.js +258 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/badge/index.js +1 -0
- package/dist/components/banner/Banner.d.ts +209 -0
- package/dist/components/banner/Banner.js +339 -0
- package/dist/components/banner/index.d.ts +2 -0
- package/dist/components/banner/index.js +1 -0
- package/dist/components/button/Button.d.ts +54 -0
- package/dist/components/button/Button.js +312 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/button-group/ButtonGroup.d.ts +187 -0
- package/dist/components/button-group/ButtonGroup.js +217 -0
- package/dist/components/button-group/index.d.ts +2 -0
- package/dist/components/button-group/index.js +1 -0
- package/dist/components/card-select/CardSelect.d.ts +274 -0
- package/dist/components/card-select/CardSelect.js +561 -0
- package/dist/components/card-select/CardSelectGroup.d.ts +92 -0
- package/dist/components/card-select/CardSelectGroup.js +72 -0
- package/dist/components/card-select/index.d.ts +3 -0
- package/dist/components/card-select/index.js +3 -0
- package/dist/components/checkbox/Checkbox.d.ts +104 -0
- package/dist/components/checkbox/Checkbox.js +194 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/chip/Chip.d.ts +250 -0
- package/dist/components/chip/Chip.js +441 -0
- package/dist/components/chip/index.d.ts +2 -0
- package/dist/components/chip/index.js +1 -0
- package/dist/components/column-header/ColumnHeader.d.ts +144 -0
- package/dist/components/column-header/ColumnHeader.js +209 -0
- package/dist/components/column-header/index.d.ts +2 -0
- package/dist/components/column-header/index.js +1 -0
- package/dist/components/combobox-field/Combobox.d.ts +104 -0
- package/dist/components/combobox-field/Combobox.js +355 -0
- package/dist/components/combobox-field/ComboboxField.d.ts +76 -0
- package/dist/components/combobox-field/ComboboxField.js +98 -0
- package/dist/components/combobox-field/index.d.ts +3 -0
- package/dist/components/combobox-field/index.js +3 -0
- package/dist/components/date-field/DateField.d.ts +52 -0
- package/dist/components/date-field/DateField.js +45 -0
- package/dist/components/date-field/index.d.ts +2 -0
- package/dist/components/date-field/index.js +1 -0
- package/dist/components/date-picker/DatePicker.d.ts +53 -0
- package/dist/components/date-picker/DatePicker.js +329 -0
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/date-picker/index.js +1 -0
- package/dist/components/divider/Divider.d.ts +81 -0
- package/dist/components/divider/Divider.js +93 -0
- package/dist/components/divider/index.d.ts +2 -0
- package/dist/components/divider/index.js +1 -0
- package/dist/components/drawer/Drawer.d.ts +128 -0
- package/dist/components/drawer/Drawer.js +367 -0
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/drawer/index.js +1 -0
- package/dist/components/dropdown-button/DropdownButton.d.ts +72 -0
- package/dist/components/dropdown-button/DropdownButton.js +122 -0
- package/dist/components/dropdown-button/index.d.ts +2 -0
- package/dist/components/dropdown-button/index.js +1 -0
- package/dist/components/faq/FAQ.d.ts +135 -0
- package/dist/components/faq/FAQ.js +258 -0
- package/dist/components/faq/index.d.ts +2 -0
- package/dist/components/faq/index.js +1 -0
- package/dist/components/field/Field.d.ts +118 -0
- package/dist/components/field/Field.js +327 -0
- package/dist/components/field/index.d.ts +2 -0
- package/dist/components/field/index.js +1 -0
- package/dist/components/field-pair/FieldPair.d.ts +194 -0
- package/dist/components/field-pair/FieldPair.js +321 -0
- package/dist/components/field-pair/index.d.ts +2 -0
- package/dist/components/field-pair/index.js +1 -0
- package/dist/components/file-upload/FileUpload.d.ts +137 -0
- package/dist/components/file-upload/FileUpload.js +434 -0
- package/dist/components/file-upload/index.d.ts +2 -0
- package/dist/components/file-upload/index.js +1 -0
- package/dist/components/filter-chip/FilterChip.d.ts +373 -0
- package/dist/components/filter-chip/FilterChip.js +517 -0
- package/dist/components/filter-chip/index.d.ts +2 -0
- package/dist/components/filter-chip/index.js +1 -0
- package/dist/components/filter-facet/FilterFacet.d.ts +116 -0
- package/dist/components/filter-facet/FilterFacet.js +632 -0
- package/dist/components/filter-facet/index.d.ts +2 -0
- package/dist/components/filter-facet/index.js +1 -0
- package/dist/components/firm-avatar/FirmAvatar.d.ts +75 -0
- package/dist/components/firm-avatar/FirmAvatar.js +119 -0
- package/dist/components/firm-avatar/index.d.ts +2 -0
- package/dist/components/firm-avatar/index.js +1 -0
- package/dist/components/form-actions/FormActions.d.ts +123 -0
- package/dist/components/form-actions/FormActions.js +195 -0
- package/dist/components/form-actions/index.d.ts +2 -0
- package/dist/components/form-actions/index.js +1 -0
- package/dist/components/form-block/FormBlock.d.ts +252 -0
- package/dist/components/form-block/FormBlock.js +420 -0
- package/dist/components/form-block/index.d.ts +3 -0
- package/dist/components/form-block/index.js +3 -0
- package/dist/components/form-section/FormSection.d.ts +130 -0
- package/dist/components/form-section/FormSection.js +206 -0
- package/dist/components/form-section/index.d.ts +2 -0
- package/dist/components/form-section/index.js +1 -0
- package/dist/components/heading/Heading.d.ts +69 -0
- package/dist/components/heading/Heading.js +79 -0
- package/dist/components/heading/index.d.ts +2 -0
- package/dist/components/heading/index.js +1 -0
- package/dist/components/heading-group/HeadingGroup.d.ts +258 -0
- package/dist/components/heading-group/HeadingGroup.js +255 -0
- package/dist/components/heading-group/index.d.ts +2 -0
- package/dist/components/heading-group/index.js +1 -0
- package/dist/components/hero/Hero.d.ts +268 -0
- package/dist/components/hero/Hero.js +316 -0
- package/dist/components/hero/index.d.ts +2 -0
- package/dist/components/hero/index.js +1 -0
- package/dist/components/icon/Icon.d.ts +27 -0
- package/dist/components/icon/Icon.js +30 -0
- package/dist/components/icon/index.d.ts +3 -0
- package/dist/components/icon/index.js +3 -0
- package/dist/components/icon-button/IconButton.d.ts +75 -0
- package/dist/components/icon-button/IconButton.js +151 -0
- package/dist/components/icon-button/index.d.ts +2 -0
- package/dist/components/icon-button/index.js +1 -0
- package/dist/components/item-row/ItemRow.d.ts +253 -0
- package/dist/components/item-row/ItemRow.js +496 -0
- package/dist/components/item-row/index.d.ts +2 -0
- package/dist/components/item-row/index.js +1 -0
- package/dist/components/list-row/ListRow.d.ts +165 -0
- package/dist/components/list-row/ListRow.js +233 -0
- package/dist/components/list-row/index.d.ts +2 -0
- package/dist/components/list-row/index.js +1 -0
- package/dist/components/menu/Menu.d.ts +64 -0
- package/dist/components/menu/Menu.js +186 -0
- package/dist/components/menu/index.d.ts +2 -0
- package/dist/components/menu/index.js +1 -0
- package/dist/components/modal/Modal.d.ts +272 -0
- package/dist/components/modal/Modal.js +788 -0
- package/dist/components/modal/index.d.ts +2 -0
- package/dist/components/modal/index.js +1 -0
- package/dist/components/nav-link/NavLink.d.ts +123 -0
- package/dist/components/nav-link/NavLink.js +157 -0
- package/dist/components/nav-link/index.d.ts +2 -0
- package/dist/components/nav-link/index.js +1 -0
- package/dist/components/number-field/NumberField.d.ts +62 -0
- package/dist/components/number-field/NumberField.js +210 -0
- package/dist/components/number-field/index.d.ts +2 -0
- package/dist/components/number-field/index.js +1 -0
- package/dist/components/pagination/Pagination.d.ts +133 -0
- package/dist/components/pagination/Pagination.js +217 -0
- package/dist/components/pagination/index.d.ts +3 -0
- package/dist/components/pagination/index.js +3 -0
- package/dist/components/popover-surface/index.d.ts +2 -0
- package/dist/components/popover-surface/index.js +1 -0
- package/dist/components/progress-bar/ProgressBar.d.ts +260 -0
- package/dist/components/progress-bar/ProgressBar.js +470 -0
- package/dist/components/progress-bar/index.d.ts +2 -0
- package/dist/components/progress-bar/index.js +1 -0
- package/dist/components/promo-sticker/PromoSticker.d.ts +204 -0
- package/dist/components/promo-sticker/PromoSticker.js +177 -0
- package/dist/components/promo-sticker/index.d.ts +2 -0
- package/dist/components/promo-sticker/index.js +1 -0
- package/dist/components/promo-surface/PromoSurface.d.ts +94 -0
- package/dist/components/promo-surface/PromoSurface.js +119 -0
- package/dist/components/promo-surface/index.d.ts +2 -0
- package/dist/components/promo-surface/index.js +1 -0
- package/dist/components/radio/Radio.d.ts +92 -0
- package/dist/components/radio/Radio.js +171 -0
- package/dist/components/radio/index.d.ts +2 -0
- package/dist/components/radio/index.js +1 -0
- package/dist/components/radio-group/RadioGroup.d.ts +61 -0
- package/dist/components/radio-group/RadioGroup.js +51 -0
- package/dist/components/radio-group/index.d.ts +2 -0
- package/dist/components/radio-group/index.js +1 -0
- package/dist/components/select/Select.d.ts +65 -0
- package/dist/components/select/Select.js +176 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +1 -0
- package/dist/components/select-field/SelectField.d.ts +16 -0
- package/dist/components/select-field/SelectField.js +55 -0
- package/dist/components/select-field/index.d.ts +2 -0
- package/dist/components/select-field/index.js +1 -0
- package/dist/components/skeleton/Skeleton.d.ts +64 -0
- package/dist/components/skeleton/Skeleton.js +65 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.js +1 -0
- package/dist/components/split-button/SplitButton.d.ts +80 -0
- package/dist/components/split-button/SplitButton.js +182 -0
- package/dist/components/split-button/index.d.ts +2 -0
- package/dist/components/split-button/index.js +1 -0
- package/dist/components/status-summary-bar/StatusSummaryBar.d.ts +118 -0
- package/dist/components/status-summary-bar/StatusSummaryBar.js +278 -0
- package/dist/components/status-summary-bar/index.d.ts +2 -0
- package/dist/components/status-summary-bar/index.js +1 -0
- package/dist/components/subject-lookup-field/SubjectLookupField.d.ts +157 -0
- package/dist/components/subject-lookup-field/SubjectLookupField.js +663 -0
- package/dist/components/subject-lookup-field/index.d.ts +2 -0
- package/dist/components/subject-lookup-field/index.js +1 -0
- package/dist/components/switch/Switch.d.ts +152 -0
- package/dist/components/switch/Switch.js +307 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/index.js +1 -0
- package/dist/components/table/Table.d.ts +5 -0
- package/dist/components/table/Table.js +601 -0
- package/dist/components/table/index.d.ts +6 -0
- package/dist/components/table/index.js +6 -0
- package/dist/components/text-field/TextField.d.ts +65 -0
- package/dist/components/text-field/TextField.js +173 -0
- package/dist/components/text-field/index.d.ts +2 -0
- package/dist/components/text-field/index.js +1 -0
- package/dist/components/text-link/TextLink.d.ts +260 -0
- package/dist/components/text-link/TextLink.js +303 -0
- package/dist/components/text-link/index.d.ts +2 -0
- package/dist/components/text-link/index.js +1 -0
- package/dist/components/textarea/Textarea.d.ts +93 -0
- package/dist/components/textarea/Textarea.js +256 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/index.js +1 -0
- package/dist/components/tooltip/Tooltip.d.ts +129 -0
- package/dist/components/tooltip/Tooltip.js +457 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/unit-field/UnitField.d.ts +46 -0
- package/dist/components/unit-field/UnitField.js +133 -0
- package/dist/components/unit-field/index.d.ts +2 -0
- package/dist/components/unit-field/index.js +1 -0
- package/dist/icons/icon-registry.generated.js +500 -0
- package/dist/icons/icon-types.generated.d.ts +2 -0
- package/dist/icons/icon-types.generated.js +126 -0
- package/dist/index.d.ts +132 -0
- package/dist/index.js +75 -0
- package/dist/internal/BottomSheet.js +496 -0
- package/dist/internal/FodsProvider.d.ts +25 -0
- package/dist/internal/FodsProvider.js +32 -0
- package/dist/internal/MotionCaret.js +35 -0
- package/dist/internal/NumberFormatInput.d.ts +21 -0
- package/dist/internal/NumberFormatInput.js +126 -0
- package/dist/internal/SummaryDonut.d.ts +3 -0
- package/dist/internal/SummaryDonut.js +300 -0
- package/dist/internal/buttonSegment.d.ts +44 -0
- package/dist/internal/buttonSegment.js +126 -0
- package/dist/internal/collapseRoom.js +128 -0
- package/dist/internal/comboboxKeys.js +44 -0
- package/dist/internal/contentPresence.js +46 -0
- package/dist/internal/dayCell.js +95 -0
- package/dist/internal/dialogPortal.d.ts +2 -0
- package/dist/internal/dialogPortal.js +21 -0
- package/dist/internal/donutSweeps.js +65 -0
- package/dist/internal/enterOnViewGeometry.js +46 -0
- package/dist/internal/faqItem.js +80 -0
- package/dist/internal/floatingLabelMotion.js +68 -0
- package/dist/internal/formBlockContext.d.ts +22 -0
- package/dist/internal/formBlockContext.js +20 -0
- package/dist/internal/heightRoom.js +87 -0
- package/dist/internal/numberSeparators.js +62 -0
- package/dist/internal/overlayMotion.js +48 -0
- package/dist/internal/paginationItem.d.ts +8 -0
- package/dist/internal/paginationItem.js +22 -0
- package/dist/internal/popoverSurface.d.ts +8 -0
- package/dist/internal/popoverSurface.js +23 -0
- package/dist/internal/portalContainer.d.ts +1 -0
- package/dist/internal/portalContainer.js +6 -0
- package/dist/internal/progressBarItem.d.ts +207 -0
- package/dist/internal/progressBarItem.js +264 -0
- package/dist/internal/selectionControlText.js +12 -0
- package/dist/internal/statusSummaryParts.js +371 -0
- package/dist/internal/summaryMotion.js +75 -0
- package/dist/internal/table/ChildConnector.js +62 -0
- package/dist/internal/table/ChildRowPrefix.d.ts +9 -0
- package/dist/internal/table/ChildRowPrefix.js +27 -0
- package/dist/internal/table/ColumnSettings.js +135 -0
- package/dist/internal/table/ScrollRegion.js +114 -0
- package/dist/internal/table/TableEmpty.js +93 -0
- package/dist/internal/table/TableLayout.d.ts +17 -0
- package/dist/internal/table/TableLayout.js +29 -0
- package/dist/internal/table/TableLoadStatus.js +56 -0
- package/dist/internal/table/TableMobile.js +488 -0
- package/dist/internal/table/TruncatedCell.js +33 -0
- package/dist/internal/table/emptyValue.js +10 -0
- package/dist/internal/table/features.d.ts +41 -0
- package/dist/internal/table/features.js +31 -0
- package/dist/internal/table/recipes.js +227 -0
- package/dist/internal/table/rowClick.js +9 -0
- package/dist/internal/table/types.d.ts +325 -0
- package/dist/internal/table/types.js +13 -0
- package/dist/internal/tailwind-variants.d.ts +3 -0
- package/dist/internal/tailwind-variants.js +37 -0
- package/dist/internal/tooltipContext.js +5 -0
- package/dist/internal/tw-merge-config.generated.js +314 -0
- package/dist/internal/useAnchoredPanel.d.ts +87 -0
- package/dist/internal/useAnchoredPanel.js +108 -0
- package/dist/internal/useCountUp.js +53 -0
- package/dist/internal/useDateFieldTrigger.js +183 -0
- package/dist/internal/useEChart.js +59 -0
- package/dist/internal/useEnterOnView.js +42 -0
- package/dist/internal/useFloatingBar.js +100 -0
- package/dist/internal/useFormReset.js +37 -0
- package/dist/internal/useIsMobile.js +44 -0
- package/dist/internal/useOneRowOverflow.js +88 -0
- package/dist/internal/usePrefersReducedMotion.js +25 -0
- package/dist/internal/useReturnFocus.js +26 -0
- package/dist/internal/utils.d.ts +7 -0
- package/dist/internal/utils.js +58 -0
- package/dist/node_modules/@tanstack/store/dist/store.d.ts +29 -0
- package/dist/node_modules/@tanstack/store/dist/types.d.ts +38 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/cells/coreCellsFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/cells/coreCellsFeature.types.d.ts +53 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/columns/coreColumnsFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/columns/coreColumnsFeature.types.d.ts +90 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/coreFeatures.d.ts +17 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/headers/coreHeadersFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/headers/coreHeadersFeature.types.d.ts +114 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/reactivity/coreReactivityFeature.types.d.ts +51 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/row-models/coreRowModelsFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/row-models/coreRowModelsFeature.types.d.ts +29 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/rows/coreRowsFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/rows/coreRowsFeature.types.d.ts +129 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/table/coreTablesFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/table/coreTablesFeature.types.d.ts +203 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/cell-selection/cellSelectionFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/cell-selection/cellSelectionFeature.types.d.ts +294 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/cell-spanning/cellSpanningFeature.d.ts +11 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/cell-spanning/cellSpanningFeature.types.d.ts +148 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-faceting/columnFacetingFeature.d.ts +12 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-faceting/columnFacetingFeature.types.d.ts +63 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-filtering/columnFilteringFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-filtering/columnFilteringFeature.types.d.ts +209 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-filtering/filterFns.d.ts +35 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-grouping/columnGroupingFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-grouping/columnGroupingFeature.types.d.ts +128 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-ordering/columnOrderingFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-ordering/columnOrderingFeature.types.d.ts +82 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-pinning/columnPinningFeature.d.ts +11 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-pinning/columnPinningFeature.types.d.ts +195 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-resizing/columnResizingFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-resizing/columnResizingFeature.types.d.ts +73 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-sizing/columnSizingFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-sizing/columnSizingFeature.types.d.ts +134 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-visibility/columnVisibilityFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +92 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/global-filtering/globalFilteringFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/global-filtering/globalFilteringFeature.types.d.ts +67 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-aggregation/aggregationFns.d.ts +23 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-aggregation/rowAggregationFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-aggregation/rowAggregationFeature.types.d.ts +183 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-aggregation/rowAggregationFeature.utils.d.ts +18 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-expanding/rowExpandingFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-expanding/rowExpandingFeature.types.d.ts +125 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-pagination/rowPaginationFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-pagination/rowPaginationFeature.types.d.ts +135 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-pinning/rowPinningFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-pinning/rowPinningFeature.types.d.ts +76 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-selection/rowSelectionFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-selection/rowSelectionFeature.types.d.ts +187 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-sorting/rowSortingFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-sorting/rowSortingFeature.types.d.ts +236 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-sorting/sortFns.d.ts +23 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/stockFeatures.d.ts +37 -0
- package/dist/node_modules/@tanstack/table-core/dist/helpers/columnHelper.d.ts +47 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/Cell.d.ts +16 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/Column.d.ts +30 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/ColumnDef.d.ts +123 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/Header.d.ts +12 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/HeaderGroup.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/Row.d.ts +24 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/RowModel.d.ts +19 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/RowModelFns.d.ts +11 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/Table.d.ts +53 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/TableFeatures.d.ts +416 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/TableOptions.d.ts +78 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/TableState.d.ts +46 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/type-utils.d.ts +25 -0
- package/dist/shared.css +179 -0
- package/dist/styles.css +5467 -0
- package/dist/theme.css +314 -0
- package/dist/theme.map.json +278 -0
- package/dist/tokens/index.d.ts +2 -0
- package/dist/tokens/index.js +1 -0
- package/dist/tokens/tokens.generated.d.ts +2040 -0
- package/dist/tokens/tokens.generated.js +2053 -0
- package/dist/tokens.css +484 -0
- package/dist/tokens.flat.json +429 -0
- package/docs/Consuming.mdx +379 -0
- package/docs/Contributing.mdx +78 -0
- package/docs/ForAgents.mdx +53 -0
- package/docs/Introduction.mdx +54 -0
- package/llms.txt +556 -0
- package/package.json +357 -4
- package/src/components/action-row/ActionRow.mdx +686 -0
- package/src/components/action-row/ActionRow.stories.tsx +669 -0
- package/src/components/action-row/ActionRow.tsx +632 -0
- package/src/components/action-row/index.ts +9 -0
- package/src/components/alert/Alert.mdx +377 -0
- package/src/components/alert/Alert.stories.tsx +674 -0
- package/src/components/alert/Alert.tsx +579 -0
- package/src/components/alert/index.ts +13 -0
- package/src/components/anchored-panel/AnchoredPanel.mdx +381 -0
- package/src/components/anchored-panel/AnchoredPanel.stories.tsx +593 -0
- package/src/components/anchored-panel/AnchoredPanel.tsx +176 -0
- package/src/components/anchored-panel/index.ts +15 -0
- package/src/components/badge/Badge.mdx +487 -0
- package/src/components/badge/Badge.stories.tsx +375 -0
- package/src/components/badge/Badge.tsx +360 -0
- package/src/components/badge/index.ts +10 -0
- package/src/components/banner/Banner.mdx +704 -0
- package/src/components/banner/Banner.stories.tsx +448 -0
- package/src/components/banner/Banner.tsx +602 -0
- package/src/components/banner/index.ts +14 -0
- package/src/components/button/Button.mdx +286 -0
- package/src/components/button/Button.stories.tsx +381 -0
- package/src/components/button/Button.tsx +384 -0
- package/src/components/button/index.ts +1 -0
- package/src/components/button-group/ButtonGroup.mdx +512 -0
- package/src/components/button-group/ButtonGroup.stories.tsx +714 -0
- package/src/components/button-group/ButtonGroup.tsx +491 -0
- package/src/components/button-group/index.ts +10 -0
- package/src/components/card-select/CardSelect.mdx +662 -0
- package/src/components/card-select/CardSelect.stories.tsx +784 -0
- package/src/components/card-select/CardSelect.tsx +783 -0
- package/src/components/card-select/CardSelectGroup.tsx +169 -0
- package/src/components/card-select/index.ts +18 -0
- package/src/components/checkbox/Checkbox.mdx +269 -0
- package/src/components/checkbox/Checkbox.stories.tsx +306 -0
- package/src/components/checkbox/Checkbox.tsx +343 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/chip/Chip.mdx +683 -0
- package/src/components/chip/Chip.stories.tsx +734 -0
- package/src/components/chip/Chip.tsx +732 -0
- package/src/components/chip/index.ts +9 -0
- package/src/components/column-header/ColumnHeader.mdx +301 -0
- package/src/components/column-header/ColumnHeader.stories.tsx +319 -0
- package/src/components/column-header/ColumnHeader.tsx +287 -0
- package/src/components/column-header/index.ts +7 -0
- package/src/components/combobox-field/Combobox.tsx +693 -0
- package/src/components/combobox-field/ComboboxField.mdx +525 -0
- package/src/components/combobox-field/ComboboxField.stories.tsx +502 -0
- package/src/components/combobox-field/ComboboxField.tsx +259 -0
- package/src/components/combobox-field/index.ts +12 -0
- package/src/components/date-field/DateField.mdx +340 -0
- package/src/components/date-field/DateField.stories.tsx +221 -0
- package/src/components/date-field/DateField.tsx +176 -0
- package/src/components/date-field/index.ts +1 -0
- package/src/components/date-picker/DatePicker.mdx +436 -0
- package/src/components/date-picker/DatePicker.stories.tsx +458 -0
- package/src/components/date-picker/DatePicker.tsx +688 -0
- package/src/components/date-picker/index.ts +9 -0
- package/src/components/divider/Divider.mdx +256 -0
- package/src/components/divider/Divider.stories.tsx +177 -0
- package/src/components/divider/Divider.tsx +193 -0
- package/src/components/divider/index.ts +1 -0
- package/src/components/drawer/Drawer.mdx +518 -0
- package/src/components/drawer/Drawer.stories.tsx +392 -0
- package/src/components/drawer/Drawer.tsx +683 -0
- package/src/components/drawer/index.ts +1 -0
- package/src/components/dropdown-button/DropdownButton.mdx +285 -0
- package/src/components/dropdown-button/DropdownButton.stories.tsx +398 -0
- package/src/components/dropdown-button/DropdownButton.tsx +198 -0
- package/src/components/dropdown-button/index.ts +7 -0
- package/src/components/faq/FAQ.mdx +364 -0
- package/src/components/faq/FAQ.stories.tsx +343 -0
- package/src/components/faq/FAQ.tsx +337 -0
- package/src/components/faq/index.ts +1 -0
- package/src/components/field/Field.mdx +129 -0
- package/src/components/field/Field.stories.tsx +461 -0
- package/src/components/field/Field.tsx +765 -0
- package/src/components/field/index.ts +20 -0
- package/src/components/field-pair/FieldPair.mdx +308 -0
- package/src/components/field-pair/FieldPair.stories.tsx +530 -0
- package/src/components/field-pair/FieldPair.tsx +796 -0
- package/src/components/field-pair/index.ts +9 -0
- package/src/components/file-upload/FileUpload.mdx +345 -0
- package/src/components/file-upload/FileUpload.stories.tsx +698 -0
- package/src/components/file-upload/FileUpload.tsx +802 -0
- package/src/components/file-upload/index.ts +6 -0
- package/src/components/filter-chip/FilterChip.mdx +778 -0
- package/src/components/filter-chip/FilterChip.stories.tsx +827 -0
- package/src/components/filter-chip/FilterChip.tsx +881 -0
- package/src/components/filter-chip/index.ts +11 -0
- package/src/components/filter-facet/FilterFacet.mdx +536 -0
- package/src/components/filter-facet/FilterFacet.stories.tsx +506 -0
- package/src/components/filter-facet/FilterFacet.tsx +1160 -0
- package/src/components/filter-facet/index.ts +7 -0
- package/src/components/firm-avatar/FirmAvatar.mdx +280 -0
- package/src/components/firm-avatar/FirmAvatar.stories.tsx +147 -0
- package/src/components/firm-avatar/FirmAvatar.tsx +172 -0
- package/src/components/firm-avatar/index.ts +7 -0
- package/src/components/form-actions/FormActions.mdx +518 -0
- package/src/components/form-actions/FormActions.stories.tsx +621 -0
- package/src/components/form-actions/FormActions.tsx +273 -0
- package/src/components/form-actions/index.ts +6 -0
- package/src/components/form-block/FormBlock.mdx +728 -0
- package/src/components/form-block/FormBlock.stories.tsx +813 -0
- package/src/components/form-block/FormBlock.tsx +679 -0
- package/src/components/form-block/index.ts +13 -0
- package/src/components/form-section/FormSection.mdx +436 -0
- package/src/components/form-section/FormSection.stories.tsx +407 -0
- package/src/components/form-section/FormSection.tsx +290 -0
- package/src/components/form-section/index.ts +17 -0
- package/src/components/heading/Heading.mdx +206 -0
- package/src/components/heading/Heading.stories.tsx +169 -0
- package/src/components/heading/Heading.tsx +124 -0
- package/src/components/heading/index.ts +8 -0
- package/src/components/heading-group/HeadingGroup.mdx +521 -0
- package/src/components/heading-group/HeadingGroup.stories.tsx +353 -0
- package/src/components/heading-group/HeadingGroup.tsx +396 -0
- package/src/components/heading-group/index.ts +7 -0
- package/src/components/hero/Hero.mdx +742 -0
- package/src/components/hero/Hero.stories.tsx +527 -0
- package/src/components/hero/Hero.tsx +807 -0
- package/src/components/hero/index.ts +1 -0
- package/src/components/icon/Icon.mdx +329 -0
- package/src/components/icon/Icon.stories.tsx +398 -0
- package/src/components/icon/Icon.tsx +97 -0
- package/src/components/icon/index.ts +2 -0
- package/src/components/icon-button/IconButton.mdx +206 -0
- package/src/components/icon-button/IconButton.stories.tsx +341 -0
- package/src/components/icon-button/IconButton.tsx +273 -0
- package/src/components/icon-button/index.ts +1 -0
- package/src/components/item-row/ItemRow.mdx +533 -0
- package/src/components/item-row/ItemRow.stories.tsx +434 -0
- package/src/components/item-row/ItemRow.tsx +676 -0
- package/src/components/item-row/index.ts +9 -0
- package/src/components/list-row/ListRow.mdx +404 -0
- package/src/components/list-row/ListRow.stories.tsx +404 -0
- package/src/components/list-row/ListRow.tsx +424 -0
- package/src/components/list-row/index.ts +1 -0
- package/src/components/menu/Menu.mdx +268 -0
- package/src/components/menu/Menu.stories.tsx +455 -0
- package/src/components/menu/Menu.tsx +452 -0
- package/src/components/menu/index.ts +1 -0
- package/src/components/modal/Modal.mdx +854 -0
- package/src/components/modal/Modal.stories.tsx +881 -0
- package/src/components/modal/Modal.tsx +1434 -0
- package/src/components/modal/index.ts +1 -0
- package/src/components/nav-link/NavLink.mdx +196 -0
- package/src/components/nav-link/NavLink.stories.tsx +243 -0
- package/src/components/nav-link/NavLink.tsx +222 -0
- package/src/components/nav-link/index.ts +1 -0
- package/src/components/number-field/NumberField.mdx +223 -0
- package/src/components/number-field/NumberField.stories.tsx +291 -0
- package/src/components/number-field/NumberField.tsx +388 -0
- package/src/components/number-field/index.ts +6 -0
- package/src/components/pagination/Pagination.mdx +305 -0
- package/src/components/pagination/Pagination.stories.tsx +333 -0
- package/src/components/pagination/Pagination.tsx +343 -0
- package/src/components/pagination/index.ts +8 -0
- package/src/components/popover-surface/PopoverSurface.mdx +158 -0
- package/src/components/popover-surface/PopoverSurface.stories.tsx +421 -0
- package/src/components/popover-surface/index.ts +1 -0
- package/src/components/progress-bar/ProgressBar.mdx +802 -0
- package/src/components/progress-bar/ProgressBar.stories.tsx +533 -0
- package/src/components/progress-bar/ProgressBar.tsx +654 -0
- package/src/components/progress-bar/index.ts +9 -0
- package/src/components/promo-sticker/PromoSticker.mdx +436 -0
- package/src/components/promo-sticker/PromoSticker.stories.tsx +363 -0
- package/src/components/promo-sticker/PromoSticker.tsx +313 -0
- package/src/components/promo-sticker/index.ts +7 -0
- package/src/components/promo-surface/PromoSurface.mdx +399 -0
- package/src/components/promo-surface/PromoSurface.stories.tsx +270 -0
- package/src/components/promo-surface/PromoSurface.tsx +305 -0
- package/src/components/promo-surface/index.ts +7 -0
- package/src/components/radio/Radio.mdx +243 -0
- package/src/components/radio/Radio.stories.tsx +307 -0
- package/src/components/radio/Radio.tsx +288 -0
- package/src/components/radio/index.ts +1 -0
- package/src/components/radio-group/RadioGroup.mdx +119 -0
- package/src/components/radio-group/RadioGroup.stories.tsx +225 -0
- package/src/components/radio-group/RadioGroup.tsx +139 -0
- package/src/components/radio-group/index.ts +1 -0
- package/src/components/select/Select.mdx +241 -0
- package/src/components/select/Select.stories.tsx +404 -0
- package/src/components/select/Select.tsx +381 -0
- package/src/components/select/index.ts +1 -0
- package/src/components/select-field/SelectField.mdx +324 -0
- package/src/components/select-field/SelectField.stories.tsx +460 -0
- package/src/components/select-field/SelectField.tsx +138 -0
- package/src/components/select-field/index.ts +1 -0
- package/src/components/skeleton/Skeleton.mdx +194 -0
- package/src/components/skeleton/Skeleton.stories.tsx +260 -0
- package/src/components/skeleton/Skeleton.tsx +107 -0
- package/src/components/skeleton/index.ts +1 -0
- package/src/components/split-button/SplitButton.mdx +445 -0
- package/src/components/split-button/SplitButton.stories.tsx +465 -0
- package/src/components/split-button/SplitButton.tsx +361 -0
- package/src/components/split-button/index.ts +7 -0
- package/src/components/status-summary-bar/StatusSummaryBar.mdx +338 -0
- package/src/components/status-summary-bar/StatusSummaryBar.stories.tsx +408 -0
- package/src/components/status-summary-bar/StatusSummaryBar.tsx +428 -0
- package/src/components/status-summary-bar/index.ts +8 -0
- package/src/components/subject-lookup-field/SubjectLookupField.mdx +378 -0
- package/src/components/subject-lookup-field/SubjectLookupField.stories.tsx +393 -0
- package/src/components/subject-lookup-field/SubjectLookupField.tsx +1079 -0
- package/src/components/subject-lookup-field/index.ts +11 -0
- package/src/components/switch/Switch.mdx +376 -0
- package/src/components/switch/Switch.stories.tsx +296 -0
- package/src/components/switch/Switch.tsx +483 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/table/Table.mdx +575 -0
- package/src/components/table/Table.stories.tsx +1049 -0
- package/src/components/table/Table.tsx +745 -0
- package/src/components/table/TableConsumers.stories.tsx +195 -0
- package/src/components/table/_tableFixtures.ts +1189 -0
- package/src/components/table/index.ts +22 -0
- package/src/components/text-field/TextField.mdx +479 -0
- package/src/components/text-field/TextField.stories.tsx +366 -0
- package/src/components/text-field/TextField.tsx +391 -0
- package/src/components/text-field/index.ts +8 -0
- package/src/components/text-link/TextLink.mdx +353 -0
- package/src/components/text-link/TextLink.stories.tsx +458 -0
- package/src/components/text-link/TextLink.tsx +504 -0
- package/src/components/text-link/index.ts +10 -0
- package/src/components/textarea/Textarea.mdx +244 -0
- package/src/components/textarea/Textarea.stories.tsx +371 -0
- package/src/components/textarea/Textarea.tsx +489 -0
- package/src/components/textarea/index.ts +9 -0
- package/src/components/tooltip/Tooltip.mdx +462 -0
- package/src/components/tooltip/Tooltip.stories.tsx +500 -0
- package/src/components/tooltip/Tooltip.tsx +756 -0
- package/src/components/tooltip/index.ts +13 -0
- package/src/components/unit-field/UnitField.mdx +215 -0
- package/src/components/unit-field/UnitField.stories.tsx +291 -0
- package/src/components/unit-field/UnitField.tsx +255 -0
- package/src/components/unit-field/index.ts +7 -0
- package/src/icons/icon-registry.generated.ts +510 -0
- package/src/icons/icon-types.generated.ts +256 -0
- package/src/index.ts +71 -0
- package/src/internal/BottomSheet.tsx +714 -0
- package/src/internal/FodsProvider.tsx +36 -0
- package/src/internal/MotionCaret.tsx +53 -0
- package/src/internal/NumberFormatInput.tsx +276 -0
- package/src/internal/SummaryDonut.tsx +359 -0
- package/src/internal/buttonSegment.ts +241 -0
- package/src/internal/collapseRoom.ts +130 -0
- package/src/internal/comboboxKeys.ts +90 -0
- package/src/internal/contentPresence.ts +46 -0
- package/src/internal/dayCell.ts +274 -0
- package/src/internal/dialogPortal.ts +50 -0
- package/src/internal/donutSweeps.ts +77 -0
- package/src/internal/enterOnViewGeometry.ts +53 -0
- package/src/internal/faqItem.ts +104 -0
- package/src/internal/floatingLabelMotion.tsx +109 -0
- package/src/internal/formBlockContext.ts +27 -0
- package/src/internal/heightRoom.ts +135 -0
- package/src/internal/numberSeparators.ts +93 -0
- package/src/internal/overlayMotion.tsx +32 -0
- package/src/internal/paginationItem.ts +106 -0
- package/src/internal/popoverSurface.ts +78 -0
- package/src/internal/portalContainer.ts +11 -0
- package/src/internal/progressBarItem.ts +356 -0
- package/src/internal/selectionControlText.ts +42 -0
- package/src/internal/statusSummaryParts.tsx +475 -0
- package/src/internal/summaryMotion.ts +111 -0
- package/src/internal/table/ChildConnector.tsx +57 -0
- package/src/internal/table/ChildRowPrefix.tsx +21 -0
- package/src/internal/table/ColumnSettings.tsx +194 -0
- package/src/internal/table/ScrollRegion.tsx +176 -0
- package/src/internal/table/TableEmpty.tsx +99 -0
- package/src/internal/table/TableLayout.tsx +29 -0
- package/src/internal/table/TableLoadStatus.tsx +60 -0
- package/src/internal/table/TableMobile.tsx +582 -0
- package/src/internal/table/TruncatedCell.tsx +35 -0
- package/src/internal/table/emptyValue.ts +11 -0
- package/src/internal/table/features.ts +44 -0
- package/src/internal/table/recipes.ts +263 -0
- package/src/internal/table/rowClick.ts +8 -0
- package/src/internal/table/types.ts +342 -0
- package/src/internal/tailwind-variants.ts +65 -0
- package/src/internal/tooltipContext.ts +15 -0
- package/src/internal/tw-merge-config.generated.ts +275 -0
- package/src/internal/useAnchoredPanel.ts +340 -0
- package/src/internal/useCountUp.ts +65 -0
- package/src/internal/useDateFieldTrigger.tsx +357 -0
- package/src/internal/useEChart.ts +88 -0
- package/src/internal/useEnterOnView.ts +80 -0
- package/src/internal/useFloatingBar.ts +125 -0
- package/src/internal/useFormReset.ts +47 -0
- package/src/internal/useIsMobile.ts +64 -0
- package/src/internal/useNoImplicitSubmit.ts +41 -0
- package/src/internal/useOneRowOverflow.ts +103 -0
- package/src/internal/usePrefersReducedMotion.ts +27 -0
- package/src/internal/useReturnFocus.ts +34 -0
- package/src/internal/utils.ts +58 -0
- package/src/recipes/EmptyState.stories.tsx +105 -0
- package/src/recipes/Form.stories.tsx +355 -0
- package/src/recipes/ModalWithForm.stories.tsx +219 -0
- package/src/recipes/Recipes.mdx +61 -0
- package/src/recipes/TableWithFilters.stories.tsx +278 -0
- package/src/storybook/FodsFamily.tsx +39 -0
- package/src/storybook/Section.tsx +36 -0
- package/src/storybook/a11y.ts +24 -0
- package/src/storybook/assets/banner-character-bartender.webp +0 -0
- package/src/storybook/assets/banner-invoice-sheet-left.webp +0 -0
- package/src/storybook/assets/banner-invoice-sheet-right.webp +0 -0
- package/src/storybook/assets/invoice-hero.webp +0 -0
- package/src/storybook/assets/invoice.webp +0 -0
- package/src/storybook/assets/section-document-info.svg +21 -0
- package/src/storybook/assets/section-gear-checklist.svg +11 -0
- package/src/storybook/assets/section-person-arrow-in.svg +15 -0
- package/src/storybook/assets/section-person-arrow-out.svg +22 -0
- package/src/storybook/assets/section-receipt-dollar.svg +23 -0
- package/src/storybook/assets/table-empty-folder-empty.png +0 -0
- package/src/storybook/assets/table-empty-folder-magnifying-glass.png +0 -0
- package/src/storybook/assets/table-empty-funnel.png +0 -0
- package/src/storybook/assets/table-empty-load-failed.png +0 -0
- package/src/storybook/assets/wallet-spot.png +0 -0
- package/src/storybook/assets.d.ts +17 -0
- package/src/storybook/componentDoc.ts +41 -0
- package/src/storybook/fitFrame.tsx +70 -0
- package/src/storybook/forceStates.tsx +647 -0
- package/src/storybook/illustrations.tsx +66 -0
- package/src/storybook/viewportFrame.tsx +58 -0
- package/src/styles/assets/label-brush-1.svg +6 -0
- package/src/styles/assets/pattern-dark.svg +113 -0
- package/src/styles/base.css +106 -0
- package/src/styles/index.css +15 -0
- package/src/styles/motion.css +157 -0
- package/src/styles/promo-sticker.css +27 -0
- package/src/styles/promo-surface.css +49 -0
- package/src/styles/shared.css +11 -0
- package/src/styles/theme.generated.css +314 -0
- package/src/styles/theme.map.json +278 -0
- package/src/styles/tracking.generated.css +12 -0
- package/src/tokens/index.ts +4 -0
- package/src/tokens/tokens.generated.ts +542 -0
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { MotionConfig, motion, useReducedMotion, type Transition } from 'motion/react';
|
|
4
|
+
import { curves, springs } from '../../tokens';
|
|
5
|
+
import { tv } from '../../internal/tailwind-variants';
|
|
6
|
+
import { Icon, type IconSize } from '../icon/Icon';
|
|
7
|
+
import { Tooltip } from '../tooltip/Tooltip';
|
|
8
|
+
import { cn } from '../../internal/utils';
|
|
9
|
+
import { selectionControlTextWiring } from '../../internal/selectionControlText';
|
|
10
|
+
import { useFormReset } from '../../internal/useFormReset';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Switch — an instant-apply on/off control for a single setting (manifest
|
|
14
|
+
* `switch` 2.3.1). Flipping it IS the action; a value submitted with a form is a
|
|
15
|
+
* Checkbox.
|
|
16
|
+
*
|
|
17
|
+
* Wiring (manifest `delivery.react`): a visually hidden native
|
|
18
|
+
* `<input type="checkbox" role="switch">` inside a `<label>`, so the native
|
|
19
|
+
* checked state is what assistive tech reads and Space flips it. The drawn layers
|
|
20
|
+
* are SIBLINGS of the input and read its state through `peer-*` variants, so the
|
|
21
|
+
* component behaves identically controlled and uncontrolled.
|
|
22
|
+
*
|
|
23
|
+
* Three drawn layers, each animating ONE thing (manifest notes[0]):
|
|
24
|
+
* - TRACK — fill cross-fade, plus a 1 px border drawn on `::before` (inset, so the
|
|
25
|
+
* outer size never changes) whose opacity fades 1 → 0 on On.
|
|
26
|
+
* - KNOB BOX — a fixed square (sizes[].box) inset `--space-100` from the track
|
|
27
|
+
* edge; it only translates, by `--space-600` (16 px) at both sizes, on
|
|
28
|
+
* `springs.standard` through Motion (manifest 2.3.0): a second click mid-travel
|
|
29
|
+
* turns it around from where it is. Because Motion needs the selection in JS, an
|
|
30
|
+
* uncontrolled switch mirrors `checked` from its change events, form resets and
|
|
31
|
+
* programmatic writes to `input.checked` (react-hook-form `register`).
|
|
32
|
+
* - DISC — the knob's `::after`; it only scales: Off 12/box → On 16/box → Active 1,
|
|
33
|
+
* on `--spring-standard` in CSS (a pseudo-element cannot be a Motion node).
|
|
34
|
+
* The hover / active HALO is the knob's `::before`, centred on the box, painted
|
|
35
|
+
* with color-mix of the knob's own ink (8% hover, 12% active).
|
|
36
|
+
*
|
|
37
|
+
* Hit target (switch.md § States, single-sourced from checkbox.md): the TRIGGER
|
|
38
|
+
* is the whole row — the control and both text lines are `<label>`s for the
|
|
39
|
+
* input — while the paint stays on the control. The info icon is a SIBLING
|
|
40
|
+
* button outside every label, so activating it never flips the switch, and it
|
|
41
|
+
* stays live on a disabled switch (manifest notes[10]). Hover and active are read
|
|
42
|
+
* as "a label of THIS switch is under the pointer" (excludes the info icon):
|
|
43
|
+
* an arbitrary variant anchored on the root's `data-fods-component`, NOT a
|
|
44
|
+
* Tailwind `group`: `group-has-[label:hover]:` compiles to
|
|
45
|
+
* `:where(.group):has(label:hover) *`, so any ancestor `.group` (List Row, Card
|
|
46
|
+
* Select, Form Section…) with ANY hovered label would light the halo. The chain
|
|
47
|
+
* root > control <label> > input.peer ~ knob pins the `:has()` to the switch that
|
|
48
|
+
* owns the knob; `.peer:enabled` keeps it off a disabled switch, `:checked`
|
|
49
|
+
* selects the On twin. The class strings are spelled out in full (no template
|
|
50
|
+
* literals) so Tailwind's scanner and the FODS verifier both see them.
|
|
51
|
+
*
|
|
52
|
+
* Forced colours (WHCM): every fill here is a background-color the UA would force
|
|
53
|
+
* to Canvas, the On border is opacity 0 and the focus ring is a box-shadow the UA
|
|
54
|
+
* drops — so On would vanish, Off would lose its knob and focus would be
|
|
55
|
+
* invisible. The `forced-colors:` classes opt the track and knob out of forcing
|
|
56
|
+
* and repaint them in system colours (WCAG 1.4.11 / 2.4.7 in forced-colours mode).
|
|
57
|
+
*
|
|
58
|
+
* Disabled never uses opacity: Off steps its border and disc to
|
|
59
|
+
* `--outline-default` on the same washed fill, On greys to `--disabled-inverse`
|
|
60
|
+
* with a `--tertiary-foreground` disc (manifest families[].states.disabled).
|
|
61
|
+
*/
|
|
62
|
+
const switchVariants = tv({
|
|
63
|
+
slots: {
|
|
64
|
+
// The row. Cross-axis START (manifest notes[6]): against a wrapped label the
|
|
65
|
+
// control stays on the first line instead of centring on the block.
|
|
66
|
+
root: 'inline-flex items-start gap-400',
|
|
67
|
+
// The control column and the first of the row hit-targets. A FIXED height
|
|
68
|
+
// equal to the label line-height with the track centred inside it — the same
|
|
69
|
+
// carrier Checkbox uses — so the track sits on the label's first line.
|
|
70
|
+
control: 'relative inline-flex shrink-0 cursor-pointer items-center',
|
|
71
|
+
// Visually hidden native input, enlarged to a 32 px tall hit area (spec
|
|
72
|
+
// § Accessibility "Target": ≥32×32 label-less; both track widths already
|
|
73
|
+
// clear 32, only the height is padded out). `absolute` keeps it out of layout.
|
|
74
|
+
input:
|
|
75
|
+
'peer absolute left-0 top-1/2 h-900 w-full -translate-y-1/2 cursor-pointer opacity-0 outline-none disabled:cursor-not-allowed',
|
|
76
|
+
track: [
|
|
77
|
+
'pointer-events-none relative block shrink-0 rounded-full',
|
|
78
|
+
// Fill — Off washed, On solid, Disabled + On greyed. Disabled + Off keeps the
|
|
79
|
+
// same --bg-secondary fill; only its border and disc step lighter.
|
|
80
|
+
'bg-background-secondary peer-checked:bg-secondary-solid',
|
|
81
|
+
'peer-disabled:peer-checked:bg-disabled-inverse',
|
|
82
|
+
// The fill cross-fades on states.toggle (2.3.1), so the colour lands before the knob.
|
|
83
|
+
'transition-[background-color] duration-toggle ease-standard',
|
|
84
|
+
// The 1 px border as an inset pseudo-element (manifest notes[4]); it fades
|
|
85
|
+
// out on On rather than recolouring.
|
|
86
|
+
"before:pointer-events-none before:absolute before:inset-0 before:rounded-full before:content-['']",
|
|
87
|
+
'before:border-100 before:border-outline-strong peer-disabled:before:border-outline-default',
|
|
88
|
+
'peer-checked:before:opacity-0',
|
|
89
|
+
// The border fade rides states.toggle (manifest 2.3.1).
|
|
90
|
+
'before:transition-[opacity] before:duration-toggle before:ease-standard',
|
|
91
|
+
// Additive offset focus ring the control owns (manifest focus: offset,
|
|
92
|
+
// --outline-focus at --border-width-200, 2 px outside, --radius-full).
|
|
93
|
+
'peer-focus-visible:ring-200 peer-focus-visible:ring-outline-focus',
|
|
94
|
+
'peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-background-primary',
|
|
95
|
+
// Forced colours (see header): system colours instead of the forced Canvas,
|
|
96
|
+
// the border kept in BOTH selections, and an outline for the dropped ring.
|
|
97
|
+
// fods-lint-disable-next-line arbitrary-value — WHCM system colours (Canvas / Highlight / GrayText) have no token by definition
|
|
98
|
+
'forced-colors:forced-color-adjust-none forced-colors:bg-[color:Canvas] forced-colors:peer-checked:bg-[color:Highlight] forced-colors:peer-disabled:peer-checked:bg-[color:GrayText]',
|
|
99
|
+
// fods-lint-disable-next-line arbitrary-value — WHCM system colours (CanvasText / GrayText) have no token by definition
|
|
100
|
+
'forced-colors:before:border-[color:CanvasText] forced-colors:peer-disabled:before:border-[color:GrayText] forced-colors:peer-checked:before:opacity-100',
|
|
101
|
+
// fods-lint-disable-next-line arbitrary-value — WHCM system colour (Highlight) has no token by definition
|
|
102
|
+
'forced-colors:peer-focus-visible:outline forced-colors:peer-focus-visible:outline-200 forced-colors:peer-focus-visible:outline-offset-2 forced-colors:peer-focus-visible:outline-[color:Highlight]',
|
|
103
|
+
],
|
|
104
|
+
// The knob BOX: travels only — the x translate is Motion's (see `KnobTravel`).
|
|
105
|
+
knob: 'pointer-events-none absolute left-100 top-1/2 -translate-y-1/2 rounded-full',
|
|
106
|
+
// The HALO on the knob's ::before — the only hover paint. Default binds
|
|
107
|
+
// --bg-secondary at 0% ("nothing painted", manifest parts.halo). The ink is
|
|
108
|
+
// the knob's own: --outline-strong Off, --secondary-solid On. Never on
|
|
109
|
+
// Disabled (`.peer:enabled`). Active is `label:hover:active` so it outranks the
|
|
110
|
+
// hover rule on specificity rather than on stylesheet order.
|
|
111
|
+
halo: [
|
|
112
|
+
"before:pointer-events-none before:absolute before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:rounded-full before:content-['']",
|
|
113
|
+
// fods-lint-disable-next-line arbitrary-value — color-mix halo mandated by switch.manifest parts.halo (knob ink 0/8/12% with transparent); no token exists for the mixed step
|
|
114
|
+
'before:[background-color:color-mix(in_srgb,var(--bg-secondary)_0%,transparent)]',
|
|
115
|
+
// Hover wash on --duration-hover, press on --duration-press (2.3.1); CSS takes the
|
|
116
|
+
// duration from the target state, so release eases back on the hover timing.
|
|
117
|
+
'before:transition-[background-color] before:duration-hover before:ease-standard',
|
|
118
|
+
'[[data-fods-component=switch]:has(label:hover:active)>label>.peer:enabled~&]:before:duration-press',
|
|
119
|
+
// fods-lint-disable-next-line arbitrary-value — color-mix halo mandated by switch.manifest parts.halo (hover = knob ink 8%); no token exists for the mixed step
|
|
120
|
+
'[[data-fods-component=switch]:has(label:hover)>label>.peer:enabled~&]:before:[background-color:color-mix(in_srgb,var(--outline-strong)_8%,transparent)]',
|
|
121
|
+
// fods-lint-disable-next-line arbitrary-value — color-mix halo mandated by switch.manifest parts.halo note (On ink --secondary-solid 8%); no token exists for the mixed step
|
|
122
|
+
'[[data-fods-component=switch]:has(label:hover)>label>.peer:enabled:checked~&]:before:[background-color:color-mix(in_srgb,var(--secondary-solid)_8%,transparent)]',
|
|
123
|
+
// fods-lint-disable-next-line arbitrary-value — color-mix halo mandated by switch.manifest parts.halo (active = knob ink 12%); no token exists for the mixed step
|
|
124
|
+
'[[data-fods-component=switch]:has(label:hover:active)>label>.peer:enabled~&]:before:[background-color:color-mix(in_srgb,var(--outline-strong)_12%,transparent)]',
|
|
125
|
+
// fods-lint-disable-next-line arbitrary-value — color-mix halo mandated by switch.manifest parts.halo note (On ink --secondary-solid 12%); no token exists for the mixed step
|
|
126
|
+
'[[data-fods-component=switch]:has(label:hover:active)>label>.peer:enabled:checked~&]:before:[background-color:color-mix(in_srgb,var(--secondary-solid)_12%,transparent)]',
|
|
127
|
+
// A translucent hover wash means nothing in forced colours; drop it there.
|
|
128
|
+
'forced-colors:before:hidden',
|
|
129
|
+
],
|
|
130
|
+
// The DISC on the knob's ::after — scales only (sizes below). Ink per family:
|
|
131
|
+
// Off --outline-strong, On --secondary-foreground, Disabled Off
|
|
132
|
+
// --outline-default, Disabled On --tertiary-foreground. Scale on --spring-standard
|
|
133
|
+
// (the knob's spring, as CSS `<ms> linear(…)`), the ink flip on states.toggle
|
|
134
|
+
// (--duration-toggle / --easing-standard); under reduced motion the expressive grow
|
|
135
|
+
// is dropped and only colour moves.
|
|
136
|
+
disc: [
|
|
137
|
+
"after:pointer-events-none after:absolute after:inset-0 after:rounded-full after:content-['']",
|
|
138
|
+
'after:bg-outline-strong peer-checked:after:bg-secondary-foreground',
|
|
139
|
+
'peer-disabled:after:bg-outline-default peer-disabled:peer-checked:after:bg-tertiary-foreground',
|
|
140
|
+
'after:[transition:scale_var(--spring-standard),background-color_var(--duration-toggle)_var(--easing-standard)]',
|
|
141
|
+
'motion-reduce:after:[transition:background-color_var(--duration-toggle)_var(--easing-standard)]',
|
|
142
|
+
// Active: the disc grows to the full box before the knob moves (notes[3]).
|
|
143
|
+
'[[data-fods-component=switch]:has(label:hover:active)>label>.peer:enabled~&]:after:scale-100',
|
|
144
|
+
// Forced colours: the disc in system colours — CanvasText Off, HighlightText
|
|
145
|
+
// on the Highlight track On, GrayText / Canvas when disabled. All four
|
|
146
|
+
// selection × disabled combinations are spelled out because the
|
|
147
|
+
// non-forced `peer-*` rules above outrank a bare `forced-colors:after:` one.
|
|
148
|
+
// fods-lint-disable-next-line arbitrary-value — WHCM system colours (CanvasText / HighlightText) have no token by definition
|
|
149
|
+
'forced-colors:forced-color-adjust-none forced-colors:after:bg-[color:CanvasText] forced-colors:peer-checked:after:bg-[color:HighlightText]',
|
|
150
|
+
// fods-lint-disable-next-line arbitrary-value — WHCM system colours (GrayText / Canvas) have no token by definition
|
|
151
|
+
'forced-colors:peer-disabled:after:bg-[color:GrayText] forced-colors:peer-disabled:peer-checked:after:bg-[color:Canvas]',
|
|
152
|
+
],
|
|
153
|
+
// Label + support text, --space-100 apart (sizes[].descriptionGap).
|
|
154
|
+
textBlock: 'flex min-w-0 flex-col gap-100',
|
|
155
|
+
// Label + info icon, --space-200 apart, centred (manifest notes[9]).
|
|
156
|
+
labelRow: 'flex items-center gap-200',
|
|
157
|
+
labelText: 'cursor-pointer text-text-primary',
|
|
158
|
+
// The ⓘ Tooltip trigger. --text-primary in EVERY state, including on a
|
|
159
|
+
// disabled switch (manifest parts.info-icon). Rings itself; a centred ::before
|
|
160
|
+
// grows the hit area to 24×24 without moving the glyph.
|
|
161
|
+
infoIcon: [
|
|
162
|
+
'relative inline-flex size-icon-xsmall shrink-0 cursor-pointer items-center justify-center rounded-200 text-text-primary',
|
|
163
|
+
"before:absolute before:left-1/2 before:top-1/2 before:size-800 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']",
|
|
164
|
+
'focus-visible:outline focus-visible:outline-200 focus-visible:outline-outline-focus focus-visible:outline-offset-2',
|
|
165
|
+
],
|
|
166
|
+
// Body/XS at BOTH sizes (manifest typography.runs.support-text).
|
|
167
|
+
supportText: 'cursor-pointer text-body-xs text-text-secondary',
|
|
168
|
+
},
|
|
169
|
+
variants: {
|
|
170
|
+
size: {
|
|
171
|
+
sm: {
|
|
172
|
+
control: 'h-[calc(var(--font-size-sm)*var(--leading-loose))]',
|
|
173
|
+
// sizes[sm].width = 36 = --space-1000 (40) − --space-200 (4); no single step renders 36.
|
|
174
|
+
track: 'h-700 w-[calc(var(--space-1000)_-_var(--space-200))]',
|
|
175
|
+
knob: 'size-600',
|
|
176
|
+
halo: 'before:size-700',
|
|
177
|
+
// Disc Off 12/16, On 16/16 (sizes[sm].note) — at sm On and Active coincide.
|
|
178
|
+
disc: 'after:scale-75 peer-checked:after:scale-100',
|
|
179
|
+
labelText: 'text-body-sm',
|
|
180
|
+
},
|
|
181
|
+
md: {
|
|
182
|
+
control: 'h-[calc(var(--font-size-base)*var(--leading-relaxed))]',
|
|
183
|
+
track: 'h-800 w-1000',
|
|
184
|
+
knob: 'size-700',
|
|
185
|
+
// sizes[md].note halo = 28 = --space-800 (24) + --space-200 (4); no single step renders 28.
|
|
186
|
+
halo: 'before:size-[calc(var(--space-800)_+_var(--space-200))]',
|
|
187
|
+
// Disc Off 12/20, On 16/20, Active 20/20 (sizes[md].note).
|
|
188
|
+
disc: 'after:scale-60 peer-checked:after:scale-80',
|
|
189
|
+
labelText: 'text-body-base',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
disabled: {
|
|
193
|
+
true: {
|
|
194
|
+
control: 'cursor-not-allowed',
|
|
195
|
+
labelText: 'cursor-not-allowed text-disabled-foreground',
|
|
196
|
+
supportText: 'cursor-not-allowed text-disabled-foreground',
|
|
197
|
+
},
|
|
198
|
+
false: {},
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
defaultVariants: {
|
|
202
|
+
size: 'md',
|
|
203
|
+
disabled: false,
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
/** Glyph size of the ⓘ — --size-icon-xsmall (sizes[].icon, both sizes). */
|
|
208
|
+
const INFO_ICON_SIZE: IconSize = 'xsmall';
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* The knob box's travel (manifest 2.3.1 `motion.enter` / `reducedMotion`): --space-600 on
|
|
212
|
+
* `springs.standard`. Its movement IS the state change, so under reduced motion it still
|
|
213
|
+
* moves — opted out of the app-root `MotionConfig` here and given a --duration-toggle /
|
|
214
|
+
* --easing-standard tween instead of the spring. `initial={false}`: a switch that renders
|
|
215
|
+
* already on shows its knob at the end, with no animation (also in SSR).
|
|
216
|
+
*/
|
|
217
|
+
function KnobTravel({ on, instant, className }: { on: boolean; instant: boolean; className: string }) {
|
|
218
|
+
const reduce = useReducedMotion() === true;
|
|
219
|
+
let transition: Transition = reduce
|
|
220
|
+
? { duration: curves.duration.toggle, ease: curves.easing.standard }
|
|
221
|
+
: springs.standard;
|
|
222
|
+
if (instant) {
|
|
223
|
+
transition = { duration: 0 };
|
|
224
|
+
}
|
|
225
|
+
return (
|
|
226
|
+
<MotionConfig reducedMotion="never">
|
|
227
|
+
<motion.span
|
|
228
|
+
data-fods-part="knob"
|
|
229
|
+
data-knob={on ? 'on' : 'off'}
|
|
230
|
+
className={className}
|
|
231
|
+
aria-hidden
|
|
232
|
+
initial={false}
|
|
233
|
+
animate={{ x: on ? 'var(--space-600)' : 0 }}
|
|
234
|
+
transition={transition}
|
|
235
|
+
/>
|
|
236
|
+
</MotionConfig>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface SwitchBaseProps
|
|
241
|
+
extends Omit<
|
|
242
|
+
React.InputHTMLAttributes<HTMLInputElement>,
|
|
243
|
+
| 'size'
|
|
244
|
+
| 'type'
|
|
245
|
+
| 'role'
|
|
246
|
+
| 'checked'
|
|
247
|
+
| 'defaultChecked'
|
|
248
|
+
| 'children'
|
|
249
|
+
| 'aria-checked'
|
|
250
|
+
| 'aria-label'
|
|
251
|
+
| 'aria-labelledby'
|
|
252
|
+
> {
|
|
253
|
+
/** Track size: `sm` = 36×20, `md` = 40×24 (default). */
|
|
254
|
+
size?: 'sm' | 'md';
|
|
255
|
+
/**
|
|
256
|
+
* The setting's name — visible label and accessible name. Phrase it as a
|
|
257
|
+
* capability ("Posílat upomínky"), never as a statement agreed to. Without it
|
|
258
|
+
* the switch must be named by `aria-label` / `aria-labelledby`.
|
|
259
|
+
*/
|
|
260
|
+
label?: string;
|
|
261
|
+
/** Controlled state. Pair with `onCheckedChange`. */
|
|
262
|
+
checked?: boolean;
|
|
263
|
+
/** Initial state for an uncontrolled switch. */
|
|
264
|
+
defaultChecked?: boolean;
|
|
265
|
+
/** Called with the NEW state (a boolean, not a DOM event) — the Radix signature. */
|
|
266
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
267
|
+
/**
|
|
268
|
+
* The native change event, forwarded for form libraries (react-hook-form
|
|
269
|
+
* `register`). App code listens with `onCheckedChange`.
|
|
270
|
+
*/
|
|
271
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
272
|
+
/**
|
|
273
|
+
* Optional description line under the label (manifest `Support text`). Says
|
|
274
|
+
* what the setting DOES when on. Inert without `label`.
|
|
275
|
+
*/
|
|
276
|
+
supportText?: string;
|
|
277
|
+
/**
|
|
278
|
+
* The optional ⓘ after the label (manifest `Info icon`) — the Tooltip `content`
|
|
279
|
+
* and the trigger's accessible `label` as ONE prop, so an icon can never be
|
|
280
|
+
* asked for without a name (Chip `info` precedent). The switch does not own
|
|
281
|
+
* the tooltip copy; it renders the Tooltip atom around the trigger. Stays
|
|
282
|
+
* focusable and operable when the switch is disabled. Inert without `label`.
|
|
283
|
+
* The Tooltip needs a `TooltipProvider` ancestor, or it throws "`Tooltip` must be
|
|
284
|
+
* used within `TooltipProvider`".
|
|
285
|
+
*/
|
|
286
|
+
infoIcon?: { content: React.ReactNode; label: string };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Accessible name. With a visible `label` the label text names the switch. Without
|
|
291
|
+
* one (manifest `Show label` = false) the consumer MUST supply `aria-label` or
|
|
292
|
+
* `aria-labelledby` — "a nameless switch is a defect, not a configuration".
|
|
293
|
+
*/
|
|
294
|
+
type SwitchA11yName =
|
|
295
|
+
| { label: string; 'aria-label'?: never; 'aria-labelledby'?: never }
|
|
296
|
+
| { label?: undefined; 'aria-label': string; 'aria-labelledby'?: never }
|
|
297
|
+
| { label?: undefined; 'aria-labelledby': string; 'aria-label'?: never };
|
|
298
|
+
|
|
299
|
+
export type SwitchProps = SwitchBaseProps & SwitchA11yName;
|
|
300
|
+
|
|
301
|
+
const Switch = React.forwardRef<HTMLInputElement, SwitchProps>(
|
|
302
|
+
(
|
|
303
|
+
{
|
|
304
|
+
className,
|
|
305
|
+
size = 'md',
|
|
306
|
+
label,
|
|
307
|
+
supportText,
|
|
308
|
+
infoIcon,
|
|
309
|
+
id,
|
|
310
|
+
disabled = false,
|
|
311
|
+
checked,
|
|
312
|
+
defaultChecked,
|
|
313
|
+
onCheckedChange,
|
|
314
|
+
onChange,
|
|
315
|
+
'aria-describedby': consumerDescribedBy,
|
|
316
|
+
...props
|
|
317
|
+
},
|
|
318
|
+
ref,
|
|
319
|
+
) => {
|
|
320
|
+
const generatedId = React.useId();
|
|
321
|
+
const inputId = id ?? generatedId;
|
|
322
|
+
|
|
323
|
+
const {
|
|
324
|
+
labelTextId,
|
|
325
|
+
supportTextId,
|
|
326
|
+
'aria-labelledby': ownLabelledBy,
|
|
327
|
+
'aria-describedby': ownDescribedBy,
|
|
328
|
+
} = selectionControlTextWiring(inputId, label, supportText);
|
|
329
|
+
const ariaDescribedBy = [ownDescribedBy, consumerDescribedBy].filter(Boolean).join(' ') || undefined;
|
|
330
|
+
|
|
331
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
332
|
+
// The types forbid omitting every name source, but not an EMPTY one
|
|
333
|
+
// (`label=""`, `aria-label=""`) — a nameless switch is a defect (switch.md).
|
|
334
|
+
const named = [label, props['aria-label'], props['aria-labelledby']].some(
|
|
335
|
+
source => typeof source === 'string' && source.trim() !== '',
|
|
336
|
+
);
|
|
337
|
+
if (!named) {
|
|
338
|
+
console.error('Switch: no accessible name — pass a non-empty `label`, `aria-label` or `aria-labelledby`.');
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const innerRef = React.useRef<HTMLInputElement>(null);
|
|
343
|
+
|
|
344
|
+
// The knob's travel runs in Motion, which needs the selection in JS: an uncontrolled
|
|
345
|
+
// switch mirrors it (a native form reset restores `checked` without a change event).
|
|
346
|
+
const [uncontrolledChecked, setUncontrolledChecked] = React.useState(Boolean(defaultChecked));
|
|
347
|
+
// True while a value set before the first frame is being applied — the knob jumps there.
|
|
348
|
+
const [knobInstant, setKnobInstant] = React.useState(false);
|
|
349
|
+
useFormReset(innerRef, element => setUncontrolledChecked(element.checked), props.form);
|
|
350
|
+
|
|
351
|
+
// A programmatic `input.checked = …` (react-hook-form `register` + `setValue` / `reset`,
|
|
352
|
+
// or its defaultValues applied through the ref) fires no change event, so the
|
|
353
|
+
// `peer-checked` track would flip while the Motion knob stayed put. Wrap the instance
|
|
354
|
+
// `checked` accessor to mirror every write. React already installed its own
|
|
355
|
+
// value-tracker accessor on the node at mount; it is WRAPPED, not replaced — the
|
|
356
|
+
// tracker must see the write too, or the next click would compare against a stale
|
|
357
|
+
// value and React would swallow its change event. Declared before
|
|
358
|
+
// `useImperativeHandle`, so a ref callback that writes `checked` already hits it.
|
|
359
|
+
const isControlled = checked !== undefined;
|
|
360
|
+
React.useLayoutEffect(() => {
|
|
361
|
+
const node = innerRef.current;
|
|
362
|
+
if (isControlled || !node) {
|
|
363
|
+
return undefined;
|
|
364
|
+
}
|
|
365
|
+
const ownDescriptor = Object.getOwnPropertyDescriptor(node, 'checked');
|
|
366
|
+
const descriptor = ownDescriptor ?? Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'checked');
|
|
367
|
+
if (!descriptor?.get || !descriptor.set || descriptor.configurable === false) {
|
|
368
|
+
return undefined;
|
|
369
|
+
}
|
|
370
|
+
const { get, set } = descriptor;
|
|
371
|
+
// Writes before the first frame (mount-time defaults) land without travel: a switch
|
|
372
|
+
// that renders already on shows its knob at the end (manifest `motion`).
|
|
373
|
+
let beforeFirstFrame = true;
|
|
374
|
+
const mirror = (value: boolean, changed: boolean) => {
|
|
375
|
+
if (changed && beforeFirstFrame) {
|
|
376
|
+
setKnobInstant(true);
|
|
377
|
+
}
|
|
378
|
+
setUncontrolledChecked(value);
|
|
379
|
+
};
|
|
380
|
+
Object.defineProperty(node, 'checked', {
|
|
381
|
+
configurable: true,
|
|
382
|
+
enumerable: descriptor.enumerable,
|
|
383
|
+
get() {
|
|
384
|
+
return get.call(this);
|
|
385
|
+
},
|
|
386
|
+
set(value: boolean) {
|
|
387
|
+
const previous = get.call(this);
|
|
388
|
+
set.call(this, value);
|
|
389
|
+
const next = get.call(this);
|
|
390
|
+
mirror(next, next !== previous);
|
|
391
|
+
},
|
|
392
|
+
});
|
|
393
|
+
// Catches a write that reached the node before the wrapper was in place.
|
|
394
|
+
mirror(node.checked, node.checked !== node.defaultChecked);
|
|
395
|
+
const frame = requestAnimationFrame(() => {
|
|
396
|
+
beforeFirstFrame = false;
|
|
397
|
+
setKnobInstant(false);
|
|
398
|
+
});
|
|
399
|
+
return () => {
|
|
400
|
+
cancelAnimationFrame(frame);
|
|
401
|
+
if (ownDescriptor) {
|
|
402
|
+
Object.defineProperty(node, 'checked', ownDescriptor);
|
|
403
|
+
} else {
|
|
404
|
+
Reflect.deleteProperty(node, 'checked');
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
}, [isControlled]);
|
|
408
|
+
|
|
409
|
+
React.useImperativeHandle(ref, () => innerRef.current as HTMLInputElement, []);
|
|
410
|
+
const isOn = isControlled ? checked : uncontrolledChecked;
|
|
411
|
+
|
|
412
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
413
|
+
setUncontrolledChecked(event.target.checked);
|
|
414
|
+
onCheckedChange?.(event.target.checked);
|
|
415
|
+
onChange?.(event);
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
const slots = switchVariants({ size, disabled });
|
|
419
|
+
|
|
420
|
+
return (
|
|
421
|
+
// data-fods-part marks the component's parts for measurement in the browser.
|
|
422
|
+
// Not inert in this package: `styles/base.css` scopes its reset to these attributes.
|
|
423
|
+
<div data-fods-component="switch" data-fods-part="root" className={cn(slots.root(), className)}>
|
|
424
|
+
<label htmlFor={inputId} className={slots.control()}>
|
|
425
|
+
<input
|
|
426
|
+
// The consumer's `aria-label` / `aria-labelledby` (label-less case) and
|
|
427
|
+
// native attributes (`name`, `value`, `form`…) spread first, so the
|
|
428
|
+
// component's own wiring below always wins.
|
|
429
|
+
{...props}
|
|
430
|
+
ref={innerRef}
|
|
431
|
+
id={inputId}
|
|
432
|
+
type="checkbox"
|
|
433
|
+
role="switch"
|
|
434
|
+
disabled={disabled}
|
|
435
|
+
checked={checked}
|
|
436
|
+
defaultChecked={defaultChecked}
|
|
437
|
+
onChange={handleChange}
|
|
438
|
+
aria-labelledby={ownLabelledBy ?? props['aria-labelledby']}
|
|
439
|
+
aria-describedby={ariaDescribedBy}
|
|
440
|
+
className={slots.input()}
|
|
441
|
+
/>
|
|
442
|
+
<span data-fods-part="track" className={slots.track()} aria-hidden />
|
|
443
|
+
{/* The knob box; its ::before is the halo, its ::after the disc. */}
|
|
444
|
+
<KnobTravel on={isOn} instant={knobInstant} className={cn(slots.knob(), slots.halo(), slots.disc())} />
|
|
445
|
+
</label>
|
|
446
|
+
{label && (
|
|
447
|
+
<span className={slots.textBlock()}>
|
|
448
|
+
<span className={slots.labelRow()}>
|
|
449
|
+
<label htmlFor={inputId} id={labelTextId} data-fods-part="label" className={slots.labelText()}>
|
|
450
|
+
{label}
|
|
451
|
+
</label>
|
|
452
|
+
{infoIcon && (
|
|
453
|
+
<Tooltip content={infoIcon.content}>
|
|
454
|
+
<button
|
|
455
|
+
type="button"
|
|
456
|
+
data-fods-part="info-icon"
|
|
457
|
+
aria-label={infoIcon.label}
|
|
458
|
+
className={slots.infoIcon()}
|
|
459
|
+
>
|
|
460
|
+
<Icon name="info" size={INFO_ICON_SIZE} />
|
|
461
|
+
</button>
|
|
462
|
+
</Tooltip>
|
|
463
|
+
)}
|
|
464
|
+
</span>
|
|
465
|
+
{supportText && (
|
|
466
|
+
<label
|
|
467
|
+
htmlFor={inputId}
|
|
468
|
+
id={supportTextId}
|
|
469
|
+
data-fods-part="support-text"
|
|
470
|
+
className={slots.supportText()}
|
|
471
|
+
>
|
|
472
|
+
{supportText}
|
|
473
|
+
</label>
|
|
474
|
+
)}
|
|
475
|
+
</span>
|
|
476
|
+
)}
|
|
477
|
+
</div>
|
|
478
|
+
);
|
|
479
|
+
},
|
|
480
|
+
);
|
|
481
|
+
Switch.displayName = 'Switch';
|
|
482
|
+
|
|
483
|
+
export { Switch, switchVariants };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Switch, switchVariants, type SwitchProps, type SwitchBaseProps } from './Switch';
|