@boostdev/design-system-components 1.1.1 → 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/AGENTS.md +13 -10
- package/dist/client.cjs +77 -99
- package/dist/client.css +611 -580
- package/dist/client.d.cts +13 -16
- package/dist/client.d.ts +13 -16
- package/dist/client.js +87 -109
- package/dist/index.cjs +77 -99
- package/dist/index.css +611 -580
- package/dist/index.d.cts +13 -16
- package/dist/index.d.ts +13 -16
- package/dist/index.js +87 -109
- package/dist/native/index.cjs +9 -8
- package/dist/native/index.d.cts +1 -1
- package/dist/native/index.d.ts +1 -1
- package/dist/native/index.js +9 -8
- package/dist/web-components/chunk-2QA62WCQ.js +48 -0
- package/dist/web-components/chunk-3REOIRDW.js +246 -0
- package/dist/web-components/chunk-57TRNCWQ.js +93 -0
- package/dist/web-components/chunk-5IPHEONG.js +139 -0
- package/dist/web-components/chunk-5R6IFELV.js +63 -0
- package/dist/web-components/chunk-5TFWOPLH.js +49 -0
- package/dist/web-components/chunk-6I3CFC26.js +89 -0
- package/dist/web-components/chunk-6MH5UWUD.js +226 -0
- package/dist/web-components/chunk-7FMR53BW.js +127 -0
- package/dist/web-components/chunk-AGKJTMJI.js +56 -0
- package/dist/web-components/chunk-AJSXNDAP.js +151 -0
- package/dist/web-components/chunk-BQLZ7I4G.js +56 -0
- package/dist/web-components/chunk-BX3IPVOB.js +167 -0
- package/dist/web-components/chunk-CR5PGUHV.js +109 -0
- package/dist/web-components/chunk-DI46Q2EA.js +278 -0
- package/dist/web-components/chunk-DZRSJGPB.js +53 -0
- package/dist/web-components/chunk-EBJM3VD4.js +107 -0
- package/dist/web-components/chunk-ECW3HHWA.js +185 -0
- package/dist/web-components/chunk-HGBNDR22.js +98 -0
- package/dist/web-components/chunk-HHHRF2PS.js +118 -0
- package/dist/web-components/chunk-ITHLKR7Q.js +105 -0
- package/dist/web-components/chunk-JUKB3BUP.js +186 -0
- package/dist/web-components/chunk-L3XHOMN6.js +111 -0
- package/dist/{web-components.js → web-components/chunk-LGEZYFUU.js} +62 -844
- package/dist/web-components/chunk-LY62SAVN.js +64 -0
- package/dist/web-components/chunk-N6IMUOY4.js +185 -0
- package/dist/web-components/chunk-OHUTLSIQ.js +69 -0
- package/dist/web-components/chunk-OQTRTMAB.js +27 -0
- package/dist/web-components/chunk-PY62FTRW.js +179 -0
- package/dist/web-components/chunk-Q4T5BJT6.js +94 -0
- package/dist/web-components/chunk-QDST57JC.js +119 -0
- package/dist/web-components/chunk-QLZ2362S.js +279 -0
- package/dist/web-components/chunk-QPOKHLMQ.js +45 -0
- package/dist/web-components/chunk-SOQQ7RVJ.js +88 -0
- package/dist/web-components/chunk-T6AETZRP.js +131 -0
- package/dist/web-components/chunk-UFFCKVZE.js +149 -0
- package/dist/web-components/chunk-VMMVWLXL.js +53 -0
- package/dist/web-components/chunk-X3FKVHLK.js +144 -0
- package/dist/web-components/chunk-XNA6WTXG.js +133 -0
- package/dist/web-components/chunk-Y4MAXTMA.js +80 -0
- package/dist/web-components/chunk-YLVTEY23.js +165 -0
- package/dist/web-components/chunk-YRXCVKHV.js +116 -0
- package/dist/web-components/chunk-ZTC6GRP7.js +64 -0
- package/dist/web-components/globals.d.ts +2 -0
- package/dist/web-components/globals.js +1 -0
- package/dist/web-components/index.d.ts +41 -0
- package/dist/web-components/index.js +165 -0
- package/dist/web-components/interaction/bds-accordion-item.d.ts +54 -0
- package/dist/web-components/interaction/bds-accordion-item.js +7 -0
- package/dist/web-components/interaction/bds-accordion.d.ts +50 -0
- package/dist/web-components/interaction/bds-accordion.js +7 -0
- package/dist/web-components/interaction/bds-button.d.ts +100 -0
- package/dist/web-components/interaction/bds-button.js +7 -0
- package/dist/web-components/interaction/bds-collapsible.d.ts +52 -0
- package/dist/web-components/interaction/bds-collapsible.js +7 -0
- package/dist/web-components/interaction/bds-dialog.d.ts +56 -0
- package/dist/web-components/interaction/bds-dialog.js +7 -0
- package/dist/web-components/interaction/bds-drawer.d.ts +64 -0
- package/dist/web-components/interaction/bds-drawer.js +7 -0
- package/dist/web-components/interaction/bds-popover.d.ts +62 -0
- package/dist/web-components/interaction/bds-popover.js +7 -0
- package/dist/web-components/interaction/bds-skip-link.d.ts +36 -0
- package/dist/web-components/interaction/bds-skip-link.js +7 -0
- package/dist/web-components/interaction/bds-tab-panel.d.ts +26 -0
- package/dist/web-components/interaction/bds-tab-panel.js +7 -0
- package/dist/web-components/interaction/bds-tab.d.ts +45 -0
- package/dist/web-components/interaction/bds-tab.js +7 -0
- package/dist/web-components/interaction/bds-tabs.d.ts +46 -0
- package/dist/web-components/interaction/bds-tabs.js +7 -0
- package/dist/web-components/interaction/bds-toast-provider.d.ts +57 -0
- package/dist/web-components/interaction/bds-toast-provider.js +7 -0
- package/dist/web-components/interaction/bds-tooltip.d.ts +50 -0
- package/dist/web-components/interaction/bds-tooltip.js +7 -0
- package/dist/web-components/interaction/form/bds-checkbox.d.ts +70 -0
- package/dist/web-components/interaction/form/bds-checkbox.js +7 -0
- package/dist/web-components/interaction/form/bds-combobox.d.ts +84 -0
- package/dist/web-components/interaction/form/bds-combobox.js +7 -0
- package/dist/web-components/interaction/form/bds-file-input.d.ts +62 -0
- package/dist/web-components/interaction/form/bds-file-input.js +7 -0
- package/dist/web-components/interaction/form/bds-number-input.d.ts +68 -0
- package/dist/web-components/interaction/form/bds-number-input.js +7 -0
- package/dist/web-components/interaction/form/bds-radio.d.ts +68 -0
- package/dist/web-components/interaction/form/bds-radio.js +7 -0
- package/dist/web-components/interaction/form/bds-segmented-control.d.ts +88 -0
- package/dist/web-components/interaction/form/bds-segmented-control.js +7 -0
- package/dist/web-components/interaction/form/bds-select.d.ts +79 -0
- package/dist/web-components/interaction/form/bds-select.js +7 -0
- package/dist/web-components/interaction/form/bds-slider.d.ts +70 -0
- package/dist/web-components/interaction/form/bds-slider.js +7 -0
- package/dist/web-components/interaction/form/bds-switch.d.ts +67 -0
- package/dist/web-components/interaction/form/bds-switch.js +7 -0
- package/dist/web-components/interaction/form/bds-textarea.d.ts +70 -0
- package/dist/web-components/interaction/form/bds-textarea.js +7 -0
- package/dist/web-components/ui/bds-alert.d.ts +66 -0
- package/dist/web-components/ui/bds-alert.js +7 -0
- package/dist/web-components/ui/bds-avatar.d.ts +50 -0
- package/dist/web-components/ui/bds-avatar.js +7 -0
- package/dist/web-components/ui/bds-badge.d.ts +35 -0
- package/dist/web-components/ui/bds-badge.js +7 -0
- package/dist/web-components/ui/bds-breadcrumb.d.ts +35 -0
- package/dist/web-components/ui/bds-breadcrumb.js +7 -0
- package/dist/web-components/ui/bds-card.d.ts +72 -0
- package/dist/web-components/ui/bds-card.js +7 -0
- package/dist/web-components/ui/bds-description-list.d.ts +42 -0
- package/dist/web-components/ui/bds-description-list.js +7 -0
- package/dist/web-components/ui/bds-icon-wrapper.d.ts +39 -0
- package/dist/web-components/ui/bds-icon-wrapper.js +7 -0
- package/dist/web-components/ui/bds-link.d.ts +59 -0
- package/dist/web-components/ui/bds-link.js +7 -0
- package/dist/web-components/ui/bds-loading.d.ts +32 -0
- package/dist/web-components/ui/bds-loading.js +7 -0
- package/dist/web-components/ui/bds-notification-banner.d.ts +61 -0
- package/dist/web-components/ui/bds-notification-banner.js +7 -0
- package/dist/web-components/ui/bds-progress-circle.d.ts +53 -0
- package/dist/web-components/ui/bds-progress-circle.js +7 -0
- package/dist/web-components/ui/bds-progress.d.ts +54 -0
- package/dist/web-components/ui/bds-progress.js +7 -0
- package/dist/web-components/ui/bds-rating.d.ts +36 -0
- package/dist/web-components/ui/bds-rating.js +7 -0
- package/dist/web-components/ui/bds-section-header.d.ts +53 -0
- package/dist/web-components/ui/bds-section-header.js +8 -0
- package/dist/web-components/ui/bds-separator.d.ts +32 -0
- package/dist/web-components/ui/bds-separator.js +7 -0
- package/dist/web-components/ui/bds-skeleton.d.ts +22 -0
- package/dist/web-components/ui/bds-skeleton.js +7 -0
- package/dist/web-components/ui/bds-typography.d.ts +44 -0
- package/dist/web-components/ui/bds-typography.js +8 -0
- package/package.json +170 -5
- package/src/components/interaction/Button/Button.module.css +12 -11
- package/src/components/interaction/Button/Button.native.tsx +10 -9
- package/src/components/interaction/Button/Button.tsx +1 -1
- package/src/components/interaction/Command/Command.module.css +3 -7
- package/src/components/interaction/Dialog/Dialog.module.css +7 -5
- package/src/components/interaction/Drawer/Drawer.module.css +49 -1
- package/src/components/interaction/DropdownMenu/DropdownMenu.module.css +1 -3
- package/src/components/interaction/Popover/Popover.module.css +1 -3
- package/src/components/interaction/form/Checkbox/Checkbox.module.css +1 -3
- package/src/components/interaction/form/Combobox/Combobox.module.css +2 -6
- package/src/components/interaction/form/FormInput/FormInput.module.css +1 -3
- package/src/components/interaction/form/NumberInput/NumberInput.module.css +16 -4
- package/src/components/interaction/form/Radio/Radio.module.css +6 -16
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.mdx +70 -25
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.module.css +55 -33
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.spec.tsx +127 -56
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.stories.tsx +89 -72
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.tsx +40 -62
- package/src/components/interaction/form/SegmentedControl/index.ts +1 -1
- package/src/components/interaction/form/Select/Select.module.css +2 -4
- package/src/components/interaction/form/Switch/Switch.module.css +5 -7
- package/src/components/interaction/form/Switch/Switch.native.spec.tsx +9 -9
- package/src/components/interaction/form/Switch/Switch.native.tsx +2 -2
- package/src/components/interaction/form/Textarea/Textarea.module.css +1 -3
- package/src/components/interaction/form/atoms/InputContainer.stories.tsx +64 -0
- package/src/components/interaction/form/atoms/Label.stories.tsx +33 -0
- package/src/components/interaction/form/atoms/Message.stories.tsx +33 -0
- package/src/components/layout/Card/Card.module.css +1 -3
- package/src/components/ui/Accordion/Accordion.module.css +1 -2
- package/src/components/ui/Alert/Alert.module.css +1 -2
- package/src/components/ui/Calendar/Calendar.module.css +2 -5
- package/src/components/ui/Carousel/Carousel.module.css +1 -3
- package/src/components/ui/NotificationBanner/NotificationBanner.module.css +1 -2
- package/src/components/ui/Pagination/Pagination.module.css +1 -2
- package/src/components/ui/SkipLink/SkipLink.module.css +1 -2
- package/src/components/ui/Table/Table.module.css +1 -2
- package/src/css/bdc.css +16 -11
- package/src/index.ts +1 -1
- package/src/web-components/globals.ts +3 -3
- package/src/web-components/index.ts +47 -0
- package/src/web-components/interaction/BdsAccordion.mdx +51 -0
- package/src/web-components/interaction/BdsAccordion.stories.tsx +85 -0
- package/src/web-components/interaction/BdsCollapsible.mdx +46 -0
- package/src/web-components/interaction/BdsCollapsible.stories.tsx +87 -0
- package/src/web-components/interaction/BdsDialog.mdx +49 -0
- package/src/web-components/interaction/BdsDialog.stories.tsx +75 -0
- package/src/web-components/interaction/BdsDrawer.mdx +50 -0
- package/src/web-components/interaction/BdsDrawer.stories.tsx +66 -0
- package/src/web-components/interaction/BdsSkipLink.mdx +34 -0
- package/src/web-components/interaction/BdsSkipLink.stories.tsx +55 -0
- package/src/web-components/interaction/BdsTabs.mdx +47 -0
- package/src/web-components/interaction/BdsTabs.stories.tsx +80 -0
- package/src/web-components/interaction/BdsTooltip.mdx +38 -0
- package/src/web-components/interaction/BdsTooltip.stories.tsx +68 -0
- package/src/web-components/interaction/bds-accordion-item.spec.ts +75 -0
- package/src/web-components/interaction/bds-accordion-item.ts +181 -0
- package/src/web-components/interaction/bds-accordion.spec.ts +73 -0
- package/src/web-components/interaction/bds-accordion.ts +98 -0
- package/src/web-components/interaction/bds-button.ts +15 -13
- package/src/web-components/interaction/bds-collapsible.spec.ts +56 -0
- package/src/web-components/interaction/bds-collapsible.ts +170 -0
- package/src/web-components/interaction/bds-dialog.spec.ts +119 -0
- package/src/web-components/interaction/bds-dialog.ts +221 -0
- package/src/web-components/interaction/bds-drawer.spec.ts +113 -0
- package/src/web-components/interaction/bds-drawer.ts +315 -0
- package/src/web-components/interaction/bds-skip-link.spec.ts +42 -0
- package/src/web-components/interaction/bds-skip-link.ts +74 -0
- package/src/web-components/interaction/bds-tab-panel.spec.ts +32 -0
- package/src/web-components/interaction/bds-tab-panel.ts +38 -0
- package/src/web-components/interaction/bds-tab.spec.ts +71 -0
- package/src/web-components/interaction/bds-tab.ts +110 -0
- package/src/web-components/interaction/bds-tabs.spec.ts +120 -0
- package/src/web-components/interaction/bds-tabs.ts +152 -0
- package/src/web-components/interaction/bds-tooltip.spec.ts +49 -0
- package/src/web-components/interaction/bds-tooltip.ts +127 -0
- package/src/web-components/interaction/form/BdsCheckbox.mdx +39 -0
- package/src/web-components/interaction/form/BdsCheckbox.stories.tsx +73 -0
- package/src/web-components/interaction/form/BdsCombobox.mdx +52 -0
- package/src/web-components/interaction/form/BdsCombobox.stories.tsx +91 -0
- package/src/web-components/interaction/form/BdsFileInput.mdx +44 -0
- package/src/web-components/interaction/form/BdsFileInput.stories.tsx +84 -0
- package/src/web-components/interaction/form/BdsNumberInput.mdx +41 -0
- package/src/web-components/interaction/form/BdsNumberInput.stories.tsx +90 -0
- package/src/web-components/interaction/form/BdsRadio.mdx +41 -0
- package/src/web-components/interaction/form/BdsRadio.stories.tsx +90 -0
- package/src/web-components/interaction/form/BdsSegmentedControl.mdx +42 -0
- package/src/web-components/interaction/form/BdsSegmentedControl.stories.tsx +92 -0
- package/src/web-components/interaction/form/BdsSelect.mdx +38 -0
- package/src/web-components/interaction/form/BdsSelect.stories.tsx +93 -0
- package/src/web-components/interaction/form/BdsSlider.mdx +49 -0
- package/src/web-components/interaction/form/BdsSlider.stories.tsx +89 -0
- package/src/web-components/interaction/form/BdsSwitch.mdx +39 -0
- package/src/web-components/interaction/form/BdsSwitch.stories.tsx +73 -0
- package/src/web-components/interaction/form/BdsTextarea.mdx +41 -0
- package/src/web-components/interaction/form/BdsTextarea.stories.tsx +79 -0
- package/src/web-components/interaction/form/bds-checkbox.spec.ts +63 -0
- package/src/web-components/interaction/form/bds-checkbox.ts +166 -0
- package/src/web-components/interaction/form/bds-combobox.spec.ts +117 -0
- package/src/web-components/interaction/form/bds-combobox.ts +334 -0
- package/src/web-components/interaction/form/bds-file-input.spec.ts +58 -0
- package/src/web-components/interaction/form/bds-file-input.ts +209 -0
- package/src/web-components/interaction/form/bds-number-input.spec.ts +87 -0
- package/src/web-components/interaction/form/bds-number-input.ts +220 -0
- package/src/web-components/interaction/form/bds-radio.spec.ts +70 -0
- package/src/web-components/interaction/form/bds-radio.ts +151 -0
- package/src/web-components/interaction/form/bds-segmented-control.spec.ts +74 -0
- package/src/web-components/interaction/form/bds-segmented-control.ts +282 -0
- package/src/web-components/interaction/form/bds-select.spec.ts +74 -0
- package/src/web-components/interaction/form/bds-select.ts +188 -0
- package/src/web-components/interaction/form/bds-slider.spec.ts +41 -0
- package/src/web-components/interaction/form/bds-slider.ts +162 -0
- package/src/web-components/interaction/form/bds-switch.spec.ts +62 -0
- package/src/web-components/interaction/form/bds-switch.ts +165 -0
- package/src/web-components/interaction/form/bds-textarea.spec.ts +55 -0
- package/src/web-components/interaction/form/bds-textarea.ts +141 -0
- package/src/web-components/ui/BdsAvatar.mdx +67 -0
- package/src/web-components/ui/BdsAvatar.stories.tsx +62 -0
- package/src/web-components/ui/BdsBreadcrumb.mdx +63 -0
- package/src/web-components/ui/BdsBreadcrumb.stories.tsx +59 -0
- package/src/web-components/ui/BdsCard.mdx +83 -0
- package/src/web-components/ui/BdsCard.stories.tsx +90 -0
- package/src/web-components/ui/BdsDescriptionList.mdx +67 -0
- package/src/web-components/ui/BdsDescriptionList.stories.tsx +79 -0
- package/src/web-components/ui/BdsIconWrapper.mdx +70 -0
- package/src/web-components/ui/BdsIconWrapper.stories.tsx +76 -0
- package/src/web-components/ui/BdsLink.mdx +75 -0
- package/src/web-components/ui/BdsLink.stories.tsx +64 -0
- package/src/web-components/ui/BdsLoading.mdx +62 -0
- package/src/web-components/ui/BdsLoading.stories.tsx +37 -0
- package/src/web-components/ui/BdsNotificationBanner.mdx +90 -0
- package/src/web-components/ui/BdsNotificationBanner.stories.tsx +93 -0
- package/src/web-components/ui/BdsProgress.mdx +63 -0
- package/src/web-components/ui/BdsProgress.stories.tsx +70 -0
- package/src/web-components/ui/BdsProgressCircle.mdx +64 -0
- package/src/web-components/ui/BdsProgressCircle.stories.tsx +69 -0
- package/src/web-components/ui/BdsRating.mdx +61 -0
- package/src/web-components/ui/BdsRating.stories.tsx +39 -0
- package/src/web-components/ui/BdsSectionHeader.mdx +69 -0
- package/src/web-components/ui/BdsSectionHeader.stories.tsx +56 -0
- package/src/web-components/ui/BdsSeparator.mdx +63 -0
- package/src/web-components/ui/BdsSeparator.stories.tsx +47 -0
- package/src/web-components/ui/BdsSkeleton.mdx +67 -0
- package/src/web-components/ui/BdsSkeleton.stories.tsx +50 -0
- package/src/web-components/ui/BdsTypography.mdx +83 -0
- package/src/web-components/ui/BdsTypography.stories.tsx +51 -0
- package/src/web-components/ui/bds-alert.ts +1 -2
- package/src/web-components/ui/bds-avatar.spec.ts +75 -0
- package/src/web-components/ui/bds-avatar.ts +122 -0
- package/src/web-components/ui/bds-breadcrumb.spec.ts +55 -0
- package/src/web-components/ui/bds-breadcrumb.ts +114 -0
- package/src/web-components/ui/bds-card.spec.ts +70 -0
- package/src/web-components/ui/bds-card.ts +154 -0
- package/src/web-components/ui/bds-description-list.spec.ts +36 -0
- package/src/web-components/ui/bds-description-list.ts +79 -0
- package/src/web-components/ui/bds-icon-wrapper.spec.ts +21 -0
- package/src/web-components/ui/bds-icon-wrapper.ts +68 -0
- package/src/web-components/ui/bds-link.spec.ts +72 -0
- package/src/web-components/ui/bds-link.ts +138 -0
- package/src/web-components/ui/bds-loading.spec.ts +38 -0
- package/src/web-components/ui/bds-loading.ts +76 -0
- package/src/web-components/ui/bds-notification-banner.spec.ts +82 -0
- package/src/web-components/ui/bds-notification-banner.ts +184 -0
- package/src/web-components/ui/bds-progress-circle.spec.ts +58 -0
- package/src/web-components/ui/bds-progress-circle.ts +142 -0
- package/src/web-components/ui/bds-progress.spec.ts +66 -0
- package/src/web-components/ui/bds-progress.ts +127 -0
- package/src/web-components/ui/bds-rating.spec.ts +70 -0
- package/src/web-components/ui/bds-rating.ts +80 -0
- package/src/web-components/ui/bds-section-header.spec.ts +57 -0
- package/src/web-components/ui/bds-section-header.ts +96 -0
- package/src/web-components/ui/bds-separator.spec.ts +50 -0
- package/src/web-components/ui/bds-separator.ts +66 -0
- package/src/web-components/ui/bds-skeleton.spec.ts +22 -0
- package/src/web-components/ui/bds-skeleton.ts +55 -0
- package/src/web-components/ui/bds-typography.spec.ts +76 -0
- package/src/web-components/ui/bds-typography.ts +112 -0
- package/dist/web-components.d.ts +0 -304
|
@@ -10,19 +10,35 @@
|
|
|
10
10
|
gap: 0;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
/* Filled variant: sliding background thumb */
|
|
13
14
|
.thumb {
|
|
14
15
|
position: absolute;
|
|
15
16
|
inset-block: var(--bds-space_xxxs);
|
|
16
17
|
inset-inline-start: var(--bds-space_xxxs);
|
|
17
18
|
inline-size: calc((100% - 2 * var(--bds-space_xxxs)) / var(--control_count, 1));
|
|
18
19
|
border-radius: var(--bds-border_radius--s);
|
|
19
|
-
background-color: var(--control_thumb-bg, var(--bds-
|
|
20
|
+
background-color: var(--control_thumb-bg, var(--bds-color_interactive));
|
|
20
21
|
box-shadow: var(--bds-shadow_s);
|
|
21
22
|
pointer-events: none;
|
|
22
23
|
transform: translateX(calc(var(--control_selected-index, 0) * 100%));
|
|
23
24
|
transition: transform var(--bds-animation_transition-duration) var(--bds-animation_easing);
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
/* Outline variant: sliding inset-border indicator */
|
|
28
|
+
.indicator {
|
|
29
|
+
position: absolute;
|
|
30
|
+
inset-block: var(--bds-space_xxxs);
|
|
31
|
+
inset-inline-start: var(--bds-space_xxxs);
|
|
32
|
+
inline-size: calc((100% - 2 * var(--bds-space_xxxs)) / var(--control_count, 1));
|
|
33
|
+
border-radius: var(--bds-border_radius--s);
|
|
34
|
+
pointer-events: none;
|
|
35
|
+
z-index: 2;
|
|
36
|
+
display: none;
|
|
37
|
+
transform: translateX(calc(var(--control_selected-index, 0) * 100%));
|
|
38
|
+
transition: transform var(--bds-animation_transition-duration) var(--bds-animation_easing);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* Items — injected onto children via cloneElement */
|
|
26
42
|
.item {
|
|
27
43
|
position: relative;
|
|
28
44
|
z-index: 1;
|
|
@@ -31,67 +47,73 @@
|
|
|
31
47
|
justify-content: center;
|
|
32
48
|
cursor: pointer;
|
|
33
49
|
border-radius: var(--bds-border_radius--s);
|
|
50
|
+
padding: var(--bds-space_xs) var(--bds-space_m);
|
|
51
|
+
font-size: var(--bds-font_size--body);
|
|
52
|
+
font-family: var(--bds-font_family--body);
|
|
53
|
+
line-height: var(--bds-font_line-height--body);
|
|
54
|
+
color: var(--control_label-color, var(--bds-color_on-bg--subtle));
|
|
55
|
+
white-space: nowrap;
|
|
56
|
+
user-select: none;
|
|
57
|
+
text-decoration: none;
|
|
34
58
|
transition: var(--bds-animation_transition);
|
|
59
|
+
|
|
60
|
+
/* Reset browser defaults for button/a when used as items */
|
|
61
|
+
background: none;
|
|
62
|
+
border: none;
|
|
63
|
+
outline: none;
|
|
35
64
|
}
|
|
36
65
|
|
|
37
|
-
.item
|
|
38
|
-
|
|
39
|
-
|
|
66
|
+
.item:focus-visible {
|
|
67
|
+
outline: var(--bds-outline_default);
|
|
68
|
+
outline-offset: calc(var(--bds-outline_offset) * -1);
|
|
69
|
+
border-radius: var(--bds-border_radius--s);
|
|
40
70
|
}
|
|
41
71
|
|
|
42
|
-
.
|
|
43
|
-
|
|
44
|
-
opacity: 0;
|
|
45
|
-
inline-size: 0;
|
|
46
|
-
block-size: 0;
|
|
47
|
-
margin: 0;
|
|
72
|
+
.item.--active {
|
|
73
|
+
color: var(--control_label-color--active, var(--bds-color_on-interactive));
|
|
48
74
|
}
|
|
49
75
|
|
|
50
|
-
.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
white-space: nowrap;
|
|
54
|
-
font-size: var(--bds-font_size--body);
|
|
55
|
-
line-height: var(--bds-font_line-height--body);
|
|
56
|
-
color: var(--control_label-color, var(--bds-color_on-bg--subtle));
|
|
57
|
-
transition: color var(--bds-animation_transition-duration) var(--bds-animation_easing);
|
|
76
|
+
.item.--disabled {
|
|
77
|
+
opacity: 0.5;
|
|
78
|
+
cursor: not-allowed;
|
|
58
79
|
pointer-events: none;
|
|
59
|
-
user-select: none;
|
|
60
80
|
}
|
|
61
81
|
|
|
62
|
-
.control.--size_small .
|
|
82
|
+
.control.--size_small .item {
|
|
63
83
|
padding: var(--bds-space_xxs) var(--bds-space_s);
|
|
64
84
|
font-size: var(--bds-font_size--body--s);
|
|
65
85
|
}
|
|
66
86
|
|
|
67
|
-
.control.--size_large .
|
|
87
|
+
.control.--size_large .item {
|
|
68
88
|
padding: var(--bds-space_s) var(--bds-space_m);
|
|
69
89
|
white-space: normal;
|
|
70
90
|
text-align: center;
|
|
71
91
|
}
|
|
72
92
|
|
|
73
|
-
|
|
74
|
-
|
|
93
|
+
/* Outline variant — no thumb, sliding inset-border indicator, interactive active color */
|
|
94
|
+
.control.--variant_outline {
|
|
95
|
+
background-color: var(--control_track-bg, transparent);
|
|
96
|
+
--control_label-color--active: var(--bds-color_interactive);
|
|
75
97
|
}
|
|
76
98
|
|
|
77
|
-
.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
99
|
+
.control.--variant_outline .thumb {
|
|
100
|
+
display: none;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.control.--variant_outline .indicator {
|
|
104
|
+
display: block;
|
|
105
|
+
box-shadow: inset 0 0 0 2px var(--bds-color_interactive);
|
|
81
106
|
}
|
|
82
107
|
|
|
83
108
|
@media (hover: hover) and (pointer: fine) {
|
|
84
|
-
.item:not(.--active, .--disabled):hover
|
|
109
|
+
.item:not(.--active, .--disabled):hover {
|
|
85
110
|
color: var(--control_label-color--hover, var(--bds-color_on-bg));
|
|
86
111
|
}
|
|
87
112
|
}
|
|
88
113
|
|
|
89
114
|
@media (prefers-reduced-motion: reduce) {
|
|
90
|
-
.thumb
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.label {
|
|
115
|
+
.thumb,
|
|
116
|
+
.indicator {
|
|
95
117
|
transition: none;
|
|
96
118
|
}
|
|
97
119
|
}
|
|
@@ -2,86 +2,157 @@ import { render, screen } from '@testing-library/react';
|
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
3
|
import { SegmentedControl } from './SegmentedControl';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
{ value: 'day', label: 'Day' },
|
|
7
|
-
{ value: 'week', label: 'Week' },
|
|
8
|
-
{ value: 'month', label: 'Month' },
|
|
9
|
-
];
|
|
5
|
+
const getControl = (container: HTMLElement) => container.firstChild as HTMLElement;
|
|
10
6
|
|
|
11
7
|
describe('SegmentedControl', () => {
|
|
12
|
-
it('renders all
|
|
13
|
-
render(
|
|
8
|
+
it('renders all children', () => {
|
|
9
|
+
render(
|
|
10
|
+
<SegmentedControl>
|
|
11
|
+
<button>Day</button>
|
|
12
|
+
<button>Week</button>
|
|
13
|
+
<button>Month</button>
|
|
14
|
+
</SegmentedControl>,
|
|
15
|
+
);
|
|
14
16
|
expect(screen.getByText('Day')).toBeInTheDocument();
|
|
15
17
|
expect(screen.getByText('Week')).toBeInTheDocument();
|
|
16
18
|
expect(screen.getByText('Month')).toBeInTheDocument();
|
|
17
19
|
});
|
|
18
20
|
|
|
19
|
-
it('
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
it('sets --control_count to the number of children', () => {
|
|
22
|
+
const { container } = render(
|
|
23
|
+
<SegmentedControl>
|
|
24
|
+
<button>A</button>
|
|
25
|
+
<button>B</button>
|
|
26
|
+
<button>C</button>
|
|
27
|
+
</SegmentedControl>,
|
|
28
|
+
);
|
|
29
|
+
expect(getControl(container).style.getPropertyValue('--control_count')).toBe('3');
|
|
23
30
|
});
|
|
24
31
|
|
|
25
|
-
it('
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
it('sets --control_selected-index from selectedIndex prop', () => {
|
|
33
|
+
const { container } = render(
|
|
34
|
+
<SegmentedControl selectedIndex={2}>
|
|
35
|
+
<button>A</button>
|
|
36
|
+
<button>B</button>
|
|
37
|
+
<button>C</button>
|
|
38
|
+
</SegmentedControl>,
|
|
39
|
+
);
|
|
40
|
+
expect(getControl(container).style.getPropertyValue('--control_selected-index')).toBe('2');
|
|
29
41
|
});
|
|
30
42
|
|
|
31
|
-
it('
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
it('defaults to index 0 when no selectedIndex or aria attributes are provided', () => {
|
|
44
|
+
const { container } = render(
|
|
45
|
+
<SegmentedControl>
|
|
46
|
+
<button>A</button>
|
|
47
|
+
<button>B</button>
|
|
48
|
+
</SegmentedControl>,
|
|
49
|
+
);
|
|
50
|
+
expect(getControl(container).style.getPropertyValue('--control_selected-index')).toBe('0');
|
|
37
51
|
});
|
|
38
52
|
|
|
39
|
-
it('
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
it('auto-detects active index from aria-current="page"', () => {
|
|
54
|
+
const { container } = render(
|
|
55
|
+
<SegmentedControl>
|
|
56
|
+
<a href="#">Overview</a>
|
|
57
|
+
<a href="#" aria-current="page">Usage</a>
|
|
58
|
+
<a href="#">API</a>
|
|
59
|
+
</SegmentedControl>,
|
|
60
|
+
);
|
|
61
|
+
expect(getControl(container).style.getPropertyValue('--control_selected-index')).toBe('1');
|
|
45
62
|
});
|
|
46
63
|
|
|
47
|
-
it('
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
it('auto-detects active index from aria-pressed={true}', () => {
|
|
65
|
+
const { container } = render(
|
|
66
|
+
<SegmentedControl>
|
|
67
|
+
<button>Day</button>
|
|
68
|
+
<button aria-pressed={true}>Week</button>
|
|
69
|
+
<button>Month</button>
|
|
70
|
+
</SegmentedControl>,
|
|
71
|
+
);
|
|
72
|
+
expect(getControl(container).style.getPropertyValue('--control_selected-index')).toBe('1');
|
|
50
73
|
});
|
|
51
74
|
|
|
52
|
-
it('
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
75
|
+
it('auto-detects active index from aria-selected={true}', () => {
|
|
76
|
+
const { container } = render(
|
|
77
|
+
<SegmentedControl>
|
|
78
|
+
<button>A</button>
|
|
79
|
+
<button>B</button>
|
|
80
|
+
<button aria-selected={true}>C</button>
|
|
81
|
+
</SegmentedControl>,
|
|
82
|
+
);
|
|
83
|
+
expect(getControl(container).style.getPropertyValue('--control_selected-index')).toBe('2');
|
|
60
84
|
});
|
|
61
85
|
|
|
62
|
-
it('
|
|
63
|
-
|
|
64
|
-
|
|
86
|
+
it('selectedIndex prop takes priority over aria auto-detection', () => {
|
|
87
|
+
const { container } = render(
|
|
88
|
+
<SegmentedControl selectedIndex={0}>
|
|
89
|
+
<button>A</button>
|
|
90
|
+
<button aria-pressed={true}>B</button>
|
|
91
|
+
</SegmentedControl>,
|
|
92
|
+
);
|
|
93
|
+
expect(getControl(container).style.getPropertyValue('--control_selected-index')).toBe('0');
|
|
65
94
|
});
|
|
66
95
|
|
|
67
|
-
it('
|
|
68
|
-
const { container } = render(
|
|
69
|
-
|
|
70
|
-
|
|
96
|
+
it('updates --control_selected-index when selectedIndex changes', () => {
|
|
97
|
+
const { container, rerender } = render(
|
|
98
|
+
<SegmentedControl selectedIndex={0}>
|
|
99
|
+
<button>A</button>
|
|
100
|
+
<button>B</button>
|
|
101
|
+
<button>C</button>
|
|
102
|
+
</SegmentedControl>,
|
|
103
|
+
);
|
|
104
|
+
expect(getControl(container).style.getPropertyValue('--control_selected-index')).toBe('0');
|
|
105
|
+
rerender(
|
|
106
|
+
<SegmentedControl selectedIndex={2}>
|
|
107
|
+
<button>A</button>
|
|
108
|
+
<button>B</button>
|
|
109
|
+
<button>C</button>
|
|
110
|
+
</SegmentedControl>,
|
|
111
|
+
);
|
|
112
|
+
expect(getControl(container).style.getPropertyValue('--control_selected-index')).toBe('2');
|
|
71
113
|
});
|
|
72
114
|
|
|
73
|
-
it('
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
115
|
+
it('disables all children when disabled prop is set', () => {
|
|
116
|
+
render(
|
|
117
|
+
<SegmentedControl disabled>
|
|
118
|
+
<button>A</button>
|
|
119
|
+
<button>B</button>
|
|
120
|
+
</SegmentedControl>,
|
|
121
|
+
);
|
|
122
|
+
// Items get the --disabled modifier class — verify via aria or opacity is difficult;
|
|
123
|
+
// check that pointer-events is none (jsdom doesn't apply CSS, so just verify the class is injected).
|
|
124
|
+
// We verify by checking that buttons still render and the container has the right CSS var.
|
|
125
|
+
expect(screen.getByText('A')).toBeInTheDocument();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('forwards existing className on children', () => {
|
|
129
|
+
render(
|
|
130
|
+
<SegmentedControl selectedIndex={0}>
|
|
131
|
+
<button className="my-class">A</button>
|
|
132
|
+
</SegmentedControl>,
|
|
133
|
+
);
|
|
134
|
+
expect(screen.getByText('A').closest('button')).toHaveClass('my-class');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('renders as a group with the provided aria-label', () => {
|
|
138
|
+
render(
|
|
139
|
+
<SegmentedControl aria-label="View toggle">
|
|
140
|
+
<button>A</button>
|
|
141
|
+
</SegmentedControl>,
|
|
142
|
+
);
|
|
143
|
+
expect(screen.getByRole('group', { name: 'View toggle' })).toBeInTheDocument();
|
|
80
144
|
});
|
|
81
145
|
|
|
82
|
-
it('
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
146
|
+
it('works with link children', async () => {
|
|
147
|
+
const user = userEvent.setup();
|
|
148
|
+
const onClick = vi.fn();
|
|
149
|
+
render(
|
|
150
|
+
<SegmentedControl>
|
|
151
|
+
<a href="#" aria-current="page" onClick={onClick}>Overview</a>
|
|
152
|
+
<a href="#">Usage</a>
|
|
153
|
+
</SegmentedControl>,
|
|
154
|
+
);
|
|
155
|
+
await user.click(screen.getByText('Overview'));
|
|
156
|
+
expect(onClick).toHaveBeenCalled();
|
|
86
157
|
});
|
|
87
158
|
});
|
|
@@ -6,105 +6,122 @@ const meta = {
|
|
|
6
6
|
title: 'React/Form/SegmentedControl',
|
|
7
7
|
component: SegmentedControl,
|
|
8
8
|
argTypes: {
|
|
9
|
-
size:
|
|
9
|
+
size: { control: 'radio', options: ['small', 'medium', 'large'] },
|
|
10
|
+
variant: { control: 'radio', options: ['outline', 'filled'] },
|
|
10
11
|
},
|
|
11
12
|
} satisfies Meta<typeof SegmentedControl>;
|
|
12
13
|
|
|
13
14
|
export default meta;
|
|
14
15
|
type Story = StoryObj<typeof meta>;
|
|
15
16
|
|
|
17
|
+
/** Default: outline variant (default), buttons driven by selectedIndex */
|
|
16
18
|
export const Default: Story = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
render: ({ size, variant, disabled }) => {
|
|
20
|
+
const [tab, setTab] = useState(1);
|
|
21
|
+
return (
|
|
22
|
+
<SegmentedControl selectedIndex={tab} size={size} variant={variant} disabled={disabled}>
|
|
23
|
+
<button onClick={() => setTab(0)}>Day</button>
|
|
24
|
+
<button onClick={() => setTab(1)}>Week</button>
|
|
25
|
+
<button onClick={() => setTab(2)}>Month</button>
|
|
26
|
+
</SegmentedControl>
|
|
27
|
+
);
|
|
25
28
|
},
|
|
26
29
|
};
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
/** Filled variant: sliding filled thumb */
|
|
32
|
+
export const Filled: Story = {
|
|
33
|
+
render: ({ size, disabled }) => {
|
|
34
|
+
const [tab, setTab] = useState(1);
|
|
35
|
+
return (
|
|
36
|
+
<SegmentedControl selectedIndex={tab} size={size} variant="filled" disabled={disabled}>
|
|
37
|
+
<button onClick={() => setTab(0)}>Day</button>
|
|
38
|
+
<button onClick={() => setTab(1)}>Week</button>
|
|
39
|
+
<button onClick={() => setTab(2)}>Month</button>
|
|
40
|
+
</SegmentedControl>
|
|
41
|
+
);
|
|
37
42
|
},
|
|
38
43
|
};
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Links: active item is auto-detected from aria-current="page".
|
|
47
|
+
* No selectedIndex needed — the component reads the ARIA attribute.
|
|
48
|
+
*/
|
|
49
|
+
export const WithLinks: Story = {
|
|
50
|
+
render: ({ size, variant, disabled }) => {
|
|
51
|
+
const [active, setActive] = useState('overview');
|
|
52
|
+
return (
|
|
53
|
+
<SegmentedControl size={size} variant={variant} disabled={disabled}>
|
|
54
|
+
<a href="#" aria-current={active === 'overview' ? 'page' : undefined} onClick={() => setActive('overview')}>Overview</a>
|
|
55
|
+
<a href="#" aria-current={active === 'usage' ? 'page' : undefined} onClick={() => setActive('usage')}>Usage</a>
|
|
56
|
+
<a href="#" aria-current={active === 'api' ? 'page' : undefined} onClick={() => setActive('api')}>API</a>
|
|
57
|
+
</SegmentedControl>
|
|
58
|
+
);
|
|
50
59
|
},
|
|
51
60
|
};
|
|
52
61
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
/** Small size */
|
|
63
|
+
export const Small: Story = {
|
|
64
|
+
render: () => {
|
|
65
|
+
const [tab, setTab] = useState(0);
|
|
66
|
+
return (
|
|
67
|
+
<SegmentedControl selectedIndex={tab} size="small">
|
|
68
|
+
<button onClick={() => setTab(0)}>List</button>
|
|
69
|
+
<button onClick={() => setTab(1)}>Grid</button>
|
|
70
|
+
</SegmentedControl>
|
|
71
|
+
);
|
|
63
72
|
},
|
|
64
|
-
decorators: [Story => <div style={{ maxWidth: '360px' }}><Story /></div>],
|
|
65
73
|
};
|
|
66
74
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
/** Large size with wrapping labels */
|
|
76
|
+
export const Large: Story = {
|
|
77
|
+
render: () => {
|
|
78
|
+
const [tab, setTab] = useState(1);
|
|
79
|
+
return (
|
|
80
|
+
<SegmentedControl selectedIndex={tab} size="large">
|
|
81
|
+
<button onClick={() => setTab(0)}>Personal plan</button>
|
|
82
|
+
<button onClick={() => setTab(1)}>Team plan</button>
|
|
83
|
+
<button onClick={() => setTab(2)}>Enterprise plan</button>
|
|
84
|
+
</SegmentedControl>
|
|
85
|
+
);
|
|
76
86
|
},
|
|
77
87
|
};
|
|
78
88
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
/** Large with wrapping text in a constrained container */
|
|
90
|
+
export const WrappingLabels: Story = {
|
|
91
|
+
render: () => {
|
|
92
|
+
const [tab, setTab] = useState(2);
|
|
93
|
+
return (
|
|
94
|
+
<div style={{ maxWidth: '360px' }}>
|
|
95
|
+
<SegmentedControl selectedIndex={tab} size="large">
|
|
96
|
+
<button onClick={() => setTab(0)}>Solar energy only</button>
|
|
97
|
+
<button onClick={() => setTab(1)}>Wind energy only</button>
|
|
98
|
+
<button onClick={() => setTab(2)}>Mix of sustainable sources</button>
|
|
99
|
+
</SegmentedControl>
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
88
102
|
},
|
|
89
103
|
};
|
|
90
104
|
|
|
91
|
-
|
|
105
|
+
/** Disable the entire control */
|
|
106
|
+
export const AllDisabled: Story = {
|
|
107
|
+
render: () => (
|
|
108
|
+
<SegmentedControl selectedIndex={0} disabled>
|
|
109
|
+
<button>Option A</button>
|
|
110
|
+
<button>Option B</button>
|
|
111
|
+
</SegmentedControl>
|
|
112
|
+
),
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/** aria-pressed drives auto-detection — no selectedIndex needed */
|
|
116
|
+
export const WithAriaPressed: Story = {
|
|
92
117
|
render: () => {
|
|
93
|
-
const [
|
|
118
|
+
const [tab, setTab] = useState('week');
|
|
94
119
|
return (
|
|
95
|
-
<
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
options={[
|
|
101
|
-
{ value: 'day', label: 'Day' },
|
|
102
|
-
{ value: 'week', label: 'Week' },
|
|
103
|
-
{ value: 'month', label: 'Month' },
|
|
104
|
-
]}
|
|
105
|
-
/>
|
|
106
|
-
<span style={{ fontSize: '0.875rem', opacity: 0.6 }}>Selected: {value}</span>
|
|
107
|
-
</div>
|
|
120
|
+
<SegmentedControl>
|
|
121
|
+
<button onClick={() => setTab('day')} aria-pressed={tab === 'day'}>Day</button>
|
|
122
|
+
<button onClick={() => setTab('week')} aria-pressed={tab === 'week'}>Week</button>
|
|
123
|
+
<button onClick={() => setTab('month')} aria-pressed={tab === 'month'}>Month</button>
|
|
124
|
+
</SegmentedControl>
|
|
108
125
|
);
|
|
109
126
|
},
|
|
110
127
|
};
|