@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
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import type { ComboboxOption } from './bds-combobox';
|
|
4
|
+
import '../../index';
|
|
5
|
+
|
|
6
|
+
const COUNTRIES: ComboboxOption[] = [
|
|
7
|
+
{ value: 'nl', label: 'Netherlands' },
|
|
8
|
+
{ value: 'be', label: 'Belgium' },
|
|
9
|
+
{ value: 'de', label: 'Germany' },
|
|
10
|
+
{ value: 'fr', label: 'France' },
|
|
11
|
+
{ value: 'es', label: 'Spain' },
|
|
12
|
+
{ value: 'it', label: 'Italy' },
|
|
13
|
+
{ value: 'gb', label: 'United Kingdom', disabled: true },
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
function BdsCombobox({
|
|
17
|
+
placeholder = 'Search…',
|
|
18
|
+
disabled,
|
|
19
|
+
}: {
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
}) {
|
|
23
|
+
return React.createElement('bds-combobox', {
|
|
24
|
+
options: JSON.stringify(COUNTRIES),
|
|
25
|
+
placeholder,
|
|
26
|
+
disabled: disabled || undefined,
|
|
27
|
+
style: { display: 'block', maxInlineSize: '280px' },
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const meta = {
|
|
32
|
+
title: 'Web Components/Interaction/Form/Combobox',
|
|
33
|
+
component: BdsCombobox,
|
|
34
|
+
tags: ['!stable', 'experimental'],
|
|
35
|
+
parameters: { layout: 'padded' },
|
|
36
|
+
argTypes: {
|
|
37
|
+
disabled: { control: 'boolean' },
|
|
38
|
+
},
|
|
39
|
+
} satisfies Meta<typeof BdsCombobox>;
|
|
40
|
+
|
|
41
|
+
export default meta;
|
|
42
|
+
type Story = StoryObj<typeof meta>;
|
|
43
|
+
|
|
44
|
+
export const Default: Story = { args: { placeholder: 'Select a country…' } };
|
|
45
|
+
export const Disabled: Story = { args: { placeholder: 'Select a country…', disabled: true } };
|
|
46
|
+
export const WithValue: Story = {
|
|
47
|
+
render: () =>
|
|
48
|
+
React.createElement('bds-combobox', {
|
|
49
|
+
options: JSON.stringify(COUNTRIES),
|
|
50
|
+
value: 'nl',
|
|
51
|
+
placeholder: 'Search…',
|
|
52
|
+
style: { display: 'block', maxInlineSize: '280px' },
|
|
53
|
+
}),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const AllVariants: Story = {
|
|
57
|
+
render: () => (
|
|
58
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px', maxInlineSize: '280px' }}>
|
|
59
|
+
<div>
|
|
60
|
+
<p style={{ margin: '0 0 4px', fontSize: '0.75rem', color: '#888' }}>Default</p>
|
|
61
|
+
{React.createElement('bds-combobox', { options: JSON.stringify(COUNTRIES), placeholder: 'Search…' })}
|
|
62
|
+
</div>
|
|
63
|
+
<div>
|
|
64
|
+
<p style={{ margin: '0 0 4px', fontSize: '0.75rem', color: '#888' }}>With pre-selected value</p>
|
|
65
|
+
{React.createElement('bds-combobox', { options: JSON.stringify(COUNTRIES), value: 'be', placeholder: 'Search…' })}
|
|
66
|
+
</div>
|
|
67
|
+
<div>
|
|
68
|
+
<p style={{ margin: '0 0 4px', fontSize: '0.75rem', color: '#888' }}>Disabled</p>
|
|
69
|
+
{React.createElement('bds-combobox', { options: JSON.stringify(COUNTRIES), placeholder: 'Search…', disabled: true })}
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const Interactive: Story = {
|
|
76
|
+
render: () => {
|
|
77
|
+
const [selected, setSelected] = React.useState<{ value: string; label: string } | null>(null);
|
|
78
|
+
return (
|
|
79
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px', maxInlineSize: '280px' }}>
|
|
80
|
+
<p style={{ margin: '0 0 8px', fontSize: '0.875rem' }}>
|
|
81
|
+
Selected: {selected ? `${selected.label} (${selected.value})` : '(none)'}
|
|
82
|
+
</p>
|
|
83
|
+
{React.createElement('bds-combobox', {
|
|
84
|
+
options: JSON.stringify(COUNTRIES),
|
|
85
|
+
placeholder: 'Type to filter…',
|
|
86
|
+
'onbds-change': (e: CustomEvent<{ value: string; label: string }>) => setSelected(e.detail),
|
|
87
|
+
})}
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
},
|
|
91
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Meta, Canvas, ArgTypes } from '@storybook/blocks';
|
|
2
|
+
import * as Stories from './BdsFileInput.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={Stories} />
|
|
5
|
+
|
|
6
|
+
# File Input
|
|
7
|
+
|
|
8
|
+
`<bds-file-input>` is a form-associated file upload zone with drag-and-drop support. The slot content customises the zone label text.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<bds-file-input name="avatar" accept="image/*">Upload your photo</bds-file-input>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Attributes
|
|
17
|
+
|
|
18
|
+
| Attribute | Type | Default | Description |
|
|
19
|
+
|------------|-----------|---------|------------------------------------------|
|
|
20
|
+
| `name` | `string` | `""` | Form field name |
|
|
21
|
+
| `accept` | `string` | `""` | File types to accept (e.g. `"image/*"`) |
|
|
22
|
+
| `multiple` | `boolean` | `false` | Allow selecting multiple files |
|
|
23
|
+
| `disabled` | `boolean` | `false` | Disables the drop zone |
|
|
24
|
+
|
|
25
|
+
## Events
|
|
26
|
+
|
|
27
|
+
| Event | Detail | Description |
|
|
28
|
+
|--------------|-------------|------------------------------------------|
|
|
29
|
+
| `bds-change` | `FileList` | Fired when files are selected or dropped |
|
|
30
|
+
|
|
31
|
+
## Slots
|
|
32
|
+
|
|
33
|
+
| Slot | Description |
|
|
34
|
+
|-----------|--------------------------------|
|
|
35
|
+
| (default) | Custom label text for the zone |
|
|
36
|
+
|
|
37
|
+
## Stories
|
|
38
|
+
|
|
39
|
+
<Canvas of={Stories.Default} />
|
|
40
|
+
<Canvas of={Stories.AllVariants} />
|
|
41
|
+
|
|
42
|
+
## Controls
|
|
43
|
+
|
|
44
|
+
<ArgTypes of={Stories} />
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import '../../index';
|
|
4
|
+
|
|
5
|
+
function BdsFileInput({
|
|
6
|
+
accept,
|
|
7
|
+
multiple,
|
|
8
|
+
disabled,
|
|
9
|
+
}: {
|
|
10
|
+
accept?: string;
|
|
11
|
+
multiple?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
}) {
|
|
14
|
+
return React.createElement('bds-file-input', {
|
|
15
|
+
accept,
|
|
16
|
+
multiple: multiple || undefined,
|
|
17
|
+
disabled: disabled || undefined,
|
|
18
|
+
style: { display: 'block', maxInlineSize: '480px' },
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const meta = {
|
|
23
|
+
title: 'Web Components/Interaction/Form/FileInput',
|
|
24
|
+
component: BdsFileInput,
|
|
25
|
+
tags: ['!stable', 'experimental'],
|
|
26
|
+
parameters: { layout: 'padded' },
|
|
27
|
+
argTypes: {
|
|
28
|
+
multiple: { control: 'boolean' },
|
|
29
|
+
disabled: { control: 'boolean' },
|
|
30
|
+
},
|
|
31
|
+
} satisfies Meta<typeof BdsFileInput>;
|
|
32
|
+
|
|
33
|
+
export default meta;
|
|
34
|
+
type Story = StoryObj<typeof meta>;
|
|
35
|
+
|
|
36
|
+
export const Default: Story = { args: {} };
|
|
37
|
+
export const ImagesOnly: Story = { args: { accept: 'image/*' } };
|
|
38
|
+
export const Multiple: Story = { args: { multiple: true } };
|
|
39
|
+
export const Disabled: Story = { args: { disabled: true } };
|
|
40
|
+
|
|
41
|
+
export const AllVariants: Story = {
|
|
42
|
+
render: () => (
|
|
43
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '24px', maxInlineSize: '480px' }}>
|
|
44
|
+
<div>
|
|
45
|
+
<p style={{ margin: '0 0 8px', fontSize: '0.75rem', color: '#888' }}>Any file type</p>
|
|
46
|
+
{React.createElement('bds-file-input', { style: { display: 'block' } })}
|
|
47
|
+
</div>
|
|
48
|
+
<div>
|
|
49
|
+
<p style={{ margin: '0 0 8px', fontSize: '0.75rem', color: '#888' }}>Images only</p>
|
|
50
|
+
{React.createElement('bds-file-input', { accept: 'image/*', style: { display: 'block' } })}
|
|
51
|
+
</div>
|
|
52
|
+
<div>
|
|
53
|
+
<p style={{ margin: '0 0 8px', fontSize: '0.75rem', color: '#888' }}>Multiple files</p>
|
|
54
|
+
{React.createElement('bds-file-input', { multiple: true, style: { display: 'block' } })}
|
|
55
|
+
</div>
|
|
56
|
+
<div>
|
|
57
|
+
<p style={{ margin: '0 0 8px', fontSize: '0.75rem', color: '#888' }}>Disabled</p>
|
|
58
|
+
{React.createElement('bds-file-input', { disabled: true, style: { display: 'block' } })}
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const Interactive: Story = {
|
|
65
|
+
render: () => {
|
|
66
|
+
const [files, setFiles] = React.useState<string[]>([]);
|
|
67
|
+
return (
|
|
68
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px', maxInlineSize: '480px' }}>
|
|
69
|
+
{React.createElement('bds-file-input', {
|
|
70
|
+
multiple: true,
|
|
71
|
+
style: { display: 'block' },
|
|
72
|
+
'onbds-change': (e: CustomEvent<FileList>) => {
|
|
73
|
+
setFiles(Array.from(e.detail).map(f => f.name));
|
|
74
|
+
},
|
|
75
|
+
})}
|
|
76
|
+
{files.length > 0 && (
|
|
77
|
+
<ul style={{ margin: 0, padding: '0 0 0 16px', fontSize: '0.875rem' }}>
|
|
78
|
+
{files.map(name => <li key={name}>{name}</li>)}
|
|
79
|
+
</ul>
|
|
80
|
+
)}
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
},
|
|
84
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Meta, Canvas, ArgTypes } from '@storybook/blocks';
|
|
2
|
+
import * as Stories from './BdsNumberInput.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={Stories} />
|
|
5
|
+
|
|
6
|
+
# Number Input
|
|
7
|
+
|
|
8
|
+
`<bds-number-input>` is a form-associated number input with decrement/increment stepper buttons. The native browser spin buttons are hidden in favour of the custom steppers.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<bds-number-input name="qty" value="1" min="0" max="99" step="1"></bds-number-input>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Attributes
|
|
17
|
+
|
|
18
|
+
| Attribute | Type | Default | Description |
|
|
19
|
+
|------------|-----------|-------------|------------------------------------|
|
|
20
|
+
| `name` | `string` | `""` | Form field name |
|
|
21
|
+
| `value` | `number` | `0` | Current numeric value |
|
|
22
|
+
| `min` | `number` | `undefined` | Minimum allowed value |
|
|
23
|
+
| `max` | `number` | `undefined` | Maximum allowed value |
|
|
24
|
+
| `step` | `number` | `1` | Increment/decrement step |
|
|
25
|
+
| `disabled` | `boolean` | `false` | Disables all interaction |
|
|
26
|
+
|
|
27
|
+
## Events
|
|
28
|
+
|
|
29
|
+
| Event | Description |
|
|
30
|
+
|----------|--------------------------------------------|
|
|
31
|
+
| `input` | Fired on stepper click and native input |
|
|
32
|
+
| `change` | Native change event |
|
|
33
|
+
|
|
34
|
+
## Stories
|
|
35
|
+
|
|
36
|
+
<Canvas of={Stories.Default} />
|
|
37
|
+
<Canvas of={Stories.AllVariants} />
|
|
38
|
+
|
|
39
|
+
## Controls
|
|
40
|
+
|
|
41
|
+
<ArgTypes of={Stories} />
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import '../../index';
|
|
4
|
+
|
|
5
|
+
function BdsNumberInput({
|
|
6
|
+
value,
|
|
7
|
+
min,
|
|
8
|
+
max,
|
|
9
|
+
step,
|
|
10
|
+
disabled,
|
|
11
|
+
}: {
|
|
12
|
+
value?: number;
|
|
13
|
+
min?: number;
|
|
14
|
+
max?: number;
|
|
15
|
+
step?: number;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
}) {
|
|
18
|
+
return React.createElement('bds-number-input', {
|
|
19
|
+
value,
|
|
20
|
+
min,
|
|
21
|
+
max,
|
|
22
|
+
step,
|
|
23
|
+
disabled: disabled || undefined,
|
|
24
|
+
style: { display: 'block', maxInlineSize: '160px' },
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const meta = {
|
|
29
|
+
title: 'Web Components/Interaction/Form/NumberInput',
|
|
30
|
+
component: BdsNumberInput,
|
|
31
|
+
tags: ['!stable', 'experimental'],
|
|
32
|
+
parameters: { layout: 'padded' },
|
|
33
|
+
argTypes: {
|
|
34
|
+
value: { control: 'number' },
|
|
35
|
+
min: { control: 'number' },
|
|
36
|
+
max: { control: 'number' },
|
|
37
|
+
step: { control: 'number' },
|
|
38
|
+
disabled: { control: 'boolean' },
|
|
39
|
+
},
|
|
40
|
+
} satisfies Meta<typeof BdsNumberInput>;
|
|
41
|
+
|
|
42
|
+
export default meta;
|
|
43
|
+
type Story = StoryObj<typeof meta>;
|
|
44
|
+
|
|
45
|
+
export const Default: Story = { args: { value: 0 } };
|
|
46
|
+
export const WithBounds: Story = { args: { value: 5, min: 0, max: 10 } };
|
|
47
|
+
export const WithStep: Story = { args: { value: 0, min: 0, max: 100, step: 5 } };
|
|
48
|
+
export const Disabled: Story = { args: { value: 42, disabled: true } };
|
|
49
|
+
|
|
50
|
+
export const AllVariants: Story = {
|
|
51
|
+
render: () => (
|
|
52
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
|
|
53
|
+
<div>
|
|
54
|
+
<p style={{ margin: '0 0 4px', fontSize: '0.75rem', color: '#888' }}>Default</p>
|
|
55
|
+
{React.createElement('bds-number-input', { value: 0, style: { display: 'block', maxInlineSize: '160px' } })}
|
|
56
|
+
</div>
|
|
57
|
+
<div>
|
|
58
|
+
<p style={{ margin: '0 0 4px', fontSize: '0.75rem', color: '#888' }}>Bounded (0–10)</p>
|
|
59
|
+
{React.createElement('bds-number-input', { value: 5, min: 0, max: 10, style: { display: 'block', maxInlineSize: '160px' } })}
|
|
60
|
+
</div>
|
|
61
|
+
<div>
|
|
62
|
+
<p style={{ margin: '0 0 4px', fontSize: '0.75rem', color: '#888' }}>Step 5</p>
|
|
63
|
+
{React.createElement('bds-number-input', { value: 50, min: 0, max: 100, step: 5, style: { display: 'block', maxInlineSize: '160px' } })}
|
|
64
|
+
</div>
|
|
65
|
+
<div>
|
|
66
|
+
<p style={{ margin: '0 0 4px', fontSize: '0.75rem', color: '#888' }}>Disabled</p>
|
|
67
|
+
{React.createElement('bds-number-input', { value: 7, disabled: true, style: { display: 'block', maxInlineSize: '160px' } })}
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
),
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const Interactive: Story = {
|
|
74
|
+
render: () => {
|
|
75
|
+
const [qty, setQty] = React.useState(1);
|
|
76
|
+
return (
|
|
77
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
|
|
78
|
+
<p style={{ margin: '0 0 4px', fontSize: '0.875rem' }}>Quantity: {qty}</p>
|
|
79
|
+
{React.createElement('bds-number-input', {
|
|
80
|
+
value: qty,
|
|
81
|
+
min: 1,
|
|
82
|
+
max: 99,
|
|
83
|
+
step: 1,
|
|
84
|
+
style: { display: 'block', maxInlineSize: '160px' },
|
|
85
|
+
onInput: (e: Event) => setQty(parseInt((e.target as HTMLInputElement).value, 10) || 1),
|
|
86
|
+
})}
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
},
|
|
90
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Meta, Canvas, ArgTypes } from '@storybook/blocks';
|
|
2
|
+
import * as Stories from './BdsRadio.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={Stories} />
|
|
5
|
+
|
|
6
|
+
# Radio
|
|
7
|
+
|
|
8
|
+
`<bds-radio>` is a form-associated radio button custom element. Use multiple elements with the same `name` to create a radio group where only one option can be selected.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<bds-radio name="size" value="s">Small</bds-radio>
|
|
14
|
+
<bds-radio name="size" value="m" checked>Medium</bds-radio>
|
|
15
|
+
<bds-radio name="size" value="l">Large</bds-radio>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Attributes
|
|
19
|
+
|
|
20
|
+
| Attribute | Type | Default | Description |
|
|
21
|
+
|------------|-----------|---------|-------------------------------------|
|
|
22
|
+
| `name` | `string` | `""` | Groups radio buttons together |
|
|
23
|
+
| `value` | `string` | `""` | Submitted value when selected |
|
|
24
|
+
| `checked` | `boolean` | `false` | Whether this option is selected |
|
|
25
|
+
| `required` | `boolean` | `false` | Marks the field as required |
|
|
26
|
+
| `disabled` | `boolean` | `false` | Disables this option |
|
|
27
|
+
|
|
28
|
+
## Slots
|
|
29
|
+
|
|
30
|
+
| Slot | Description |
|
|
31
|
+
|-----------|---------------|
|
|
32
|
+
| (default) | Label text |
|
|
33
|
+
|
|
34
|
+
## Stories
|
|
35
|
+
|
|
36
|
+
<Canvas of={Stories.Group} />
|
|
37
|
+
<Canvas of={Stories.AllVariants} />
|
|
38
|
+
|
|
39
|
+
## Controls
|
|
40
|
+
|
|
41
|
+
<ArgTypes of={Stories} />
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import '../../index';
|
|
4
|
+
|
|
5
|
+
function BdsRadio({
|
|
6
|
+
label = 'Option',
|
|
7
|
+
value = 'option',
|
|
8
|
+
checked,
|
|
9
|
+
disabled,
|
|
10
|
+
}: {
|
|
11
|
+
label?: string;
|
|
12
|
+
value?: string;
|
|
13
|
+
checked?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}) {
|
|
16
|
+
return React.createElement(
|
|
17
|
+
'bds-radio',
|
|
18
|
+
{
|
|
19
|
+
name: 'demo',
|
|
20
|
+
value,
|
|
21
|
+
checked: checked || undefined,
|
|
22
|
+
disabled: disabled || undefined,
|
|
23
|
+
},
|
|
24
|
+
label,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const meta = {
|
|
29
|
+
title: 'Web Components/Interaction/Form/Radio',
|
|
30
|
+
component: BdsRadio,
|
|
31
|
+
tags: ['!stable', 'experimental'],
|
|
32
|
+
parameters: { layout: 'padded' },
|
|
33
|
+
argTypes: {
|
|
34
|
+
checked: { control: 'boolean' },
|
|
35
|
+
disabled: { control: 'boolean' },
|
|
36
|
+
},
|
|
37
|
+
} satisfies Meta<typeof BdsRadio>;
|
|
38
|
+
|
|
39
|
+
export default meta;
|
|
40
|
+
type Story = StoryObj<typeof meta>;
|
|
41
|
+
|
|
42
|
+
export const Default: Story = { args: { label: 'Option A', value: 'a' } };
|
|
43
|
+
export const Checked: Story = { args: { label: 'Pre-selected', value: 'b', checked: true } };
|
|
44
|
+
export const Disabled: Story = { args: { label: 'Disabled option', value: 'c', disabled: true } };
|
|
45
|
+
|
|
46
|
+
export const Group: Story = {
|
|
47
|
+
render: () => (
|
|
48
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
|
|
49
|
+
{React.createElement('bds-radio', { name: 'size', value: 's' }, 'Small')}
|
|
50
|
+
{React.createElement('bds-radio', { name: 'size', value: 'm', checked: true }, 'Medium')}
|
|
51
|
+
{React.createElement('bds-radio', { name: 'size', value: 'l' }, 'Large')}
|
|
52
|
+
{React.createElement('bds-radio', { name: 'size', value: 'xl', disabled: true }, 'Extra Large (unavailable)')}
|
|
53
|
+
</div>
|
|
54
|
+
),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const AllVariants: Story = {
|
|
58
|
+
render: () => (
|
|
59
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
|
60
|
+
{React.createElement('bds-radio', { name: 'v', value: 'a' }, 'Unselected')}
|
|
61
|
+
{React.createElement('bds-radio', { name: 'v', value: 'b', checked: true }, 'Selected')}
|
|
62
|
+
{React.createElement('bds-radio', { name: 'v', value: 'c', disabled: true }, 'Disabled')}
|
|
63
|
+
{React.createElement('bds-radio', { name: 'v', value: 'd', checked: true, disabled: true }, 'Disabled selected')}
|
|
64
|
+
</div>
|
|
65
|
+
),
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const Interactive: Story = {
|
|
69
|
+
render: () => {
|
|
70
|
+
const [value, setValue] = React.useState('m');
|
|
71
|
+
return (
|
|
72
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
|
|
73
|
+
<p style={{ margin: '0 0 8px', fontSize: '0.875rem' }}>Selected: {value}</p>
|
|
74
|
+
{(['s', 'm', 'l'] as const).map(v =>
|
|
75
|
+
React.createElement(
|
|
76
|
+
'bds-radio',
|
|
77
|
+
{
|
|
78
|
+
key: v,
|
|
79
|
+
name: 'ctrl',
|
|
80
|
+
value: v,
|
|
81
|
+
checked: value === v || undefined,
|
|
82
|
+
onChange: () => setValue(v),
|
|
83
|
+
},
|
|
84
|
+
v === 's' ? 'Small' : v === 'm' ? 'Medium' : 'Large',
|
|
85
|
+
),
|
|
86
|
+
)}
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
},
|
|
90
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Meta, Canvas, ArgTypes } from '@storybook/blocks';
|
|
2
|
+
import * as Stories from './BdsSegmentedControl.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={Stories} />
|
|
5
|
+
|
|
6
|
+
# Segmented Control
|
|
7
|
+
|
|
8
|
+
`<bds-segmented-control>` renders a group of radio buttons styled as a unified segmented control with an animated sliding thumb. Uses a JSON `options` attribute.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<bds-segmented-control
|
|
14
|
+
name="view"
|
|
15
|
+
value="list"
|
|
16
|
+
options='[{"value":"list","label":"List"},{"value":"grid","label":"Grid"}]'
|
|
17
|
+
></bds-segmented-control>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Attributes
|
|
21
|
+
|
|
22
|
+
| Attribute | Type | Default | Description |
|
|
23
|
+
|------------|-----------|---------|-----------------------------------------------------|
|
|
24
|
+
| `name` | `string` | `""` | Form field name (also used for radio group) |
|
|
25
|
+
| `value` | `string` | `""` | Currently selected value |
|
|
26
|
+
| `options` | `string` | `"[]"` | JSON array of `{ value, label, disabled? }` objects |
|
|
27
|
+
| `disabled` | `boolean` | `false` | Disables all options |
|
|
28
|
+
|
|
29
|
+
## Events
|
|
30
|
+
|
|
31
|
+
| Event | Description |
|
|
32
|
+
|----------|--------------------------------------|
|
|
33
|
+
| `change` | Fired when a new segment is selected |
|
|
34
|
+
|
|
35
|
+
## Stories
|
|
36
|
+
|
|
37
|
+
<Canvas of={Stories.Default} />
|
|
38
|
+
<Canvas of={Stories.AllVariants} />
|
|
39
|
+
|
|
40
|
+
## Controls
|
|
41
|
+
|
|
42
|
+
<ArgTypes of={Stories} />
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import type { SegmentedOption } from './bds-segmented-control';
|
|
4
|
+
import '../../index';
|
|
5
|
+
|
|
6
|
+
const VIEW_OPTIONS: SegmentedOption[] = [
|
|
7
|
+
{ value: 'list', label: 'List' },
|
|
8
|
+
{ value: 'grid', label: 'Grid' },
|
|
9
|
+
{ value: 'table', label: 'Table' },
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
const PERIOD_OPTIONS: SegmentedOption[] = [
|
|
13
|
+
{ value: 'day', label: 'Day' },
|
|
14
|
+
{ value: 'week', label: 'Week' },
|
|
15
|
+
{ value: 'month', label: 'Month' },
|
|
16
|
+
{ value: 'year', label: 'Year', disabled: true },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
function BdsSegmentedControl({
|
|
20
|
+
value = 'list',
|
|
21
|
+
disabled,
|
|
22
|
+
}: {
|
|
23
|
+
value?: string;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
}) {
|
|
26
|
+
return React.createElement('bds-segmented-control', {
|
|
27
|
+
name: 'view',
|
|
28
|
+
value,
|
|
29
|
+
options: JSON.stringify(VIEW_OPTIONS),
|
|
30
|
+
disabled: disabled || undefined,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const meta = {
|
|
35
|
+
title: 'Web Components/Interaction/Form/SegmentedControl',
|
|
36
|
+
component: BdsSegmentedControl,
|
|
37
|
+
tags: ['!stable', 'experimental'],
|
|
38
|
+
parameters: { layout: 'padded' },
|
|
39
|
+
argTypes: {
|
|
40
|
+
disabled: { control: 'boolean' },
|
|
41
|
+
},
|
|
42
|
+
} satisfies Meta<typeof BdsSegmentedControl>;
|
|
43
|
+
|
|
44
|
+
export default meta;
|
|
45
|
+
type Story = StoryObj<typeof meta>;
|
|
46
|
+
|
|
47
|
+
export const Default: Story = { args: { value: 'list' } };
|
|
48
|
+
export const Disabled: Story = { args: { value: 'grid', disabled: true } };
|
|
49
|
+
export const WithDisabledOption: Story = {
|
|
50
|
+
render: () =>
|
|
51
|
+
React.createElement('bds-segmented-control', {
|
|
52
|
+
name: 'period',
|
|
53
|
+
value: 'week',
|
|
54
|
+
options: JSON.stringify(PERIOD_OPTIONS),
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const AllVariants: Story = {
|
|
59
|
+
render: () => (
|
|
60
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '24px' }}>
|
|
61
|
+
<div>
|
|
62
|
+
<p style={{ margin: '0 0 8px', fontSize: '0.75rem', color: '#888' }}>View mode</p>
|
|
63
|
+
{React.createElement('bds-segmented-control', { name: 'view1', value: 'grid', options: JSON.stringify(VIEW_OPTIONS) })}
|
|
64
|
+
</div>
|
|
65
|
+
<div>
|
|
66
|
+
<p style={{ margin: '0 0 8px', fontSize: '0.75rem', color: '#888' }}>Time period (year disabled)</p>
|
|
67
|
+
{React.createElement('bds-segmented-control', { name: 'period1', value: 'week', options: JSON.stringify(PERIOD_OPTIONS) })}
|
|
68
|
+
</div>
|
|
69
|
+
<div>
|
|
70
|
+
<p style={{ margin: '0 0 8px', fontSize: '0.75rem', color: '#888' }}>Disabled</p>
|
|
71
|
+
{React.createElement('bds-segmented-control', { name: 'view2', value: 'list', options: JSON.stringify(VIEW_OPTIONS), disabled: true })}
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
),
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const Interactive: Story = {
|
|
78
|
+
render: () => {
|
|
79
|
+
const [view, setView] = React.useState('list');
|
|
80
|
+
return (
|
|
81
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
|
82
|
+
<p style={{ margin: 0, fontSize: '0.875rem' }}>Active view: {view}</p>
|
|
83
|
+
{React.createElement('bds-segmented-control', {
|
|
84
|
+
name: 'view-ctrl',
|
|
85
|
+
value: view,
|
|
86
|
+
options: JSON.stringify(VIEW_OPTIONS),
|
|
87
|
+
onChange: (e: Event) => setView((e.target as HTMLInputElement).value),
|
|
88
|
+
})}
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Meta, Canvas, ArgTypes } from '@storybook/blocks';
|
|
2
|
+
import * as Stories from './BdsSelect.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={Stories} />
|
|
5
|
+
|
|
6
|
+
# Select
|
|
7
|
+
|
|
8
|
+
`<bds-select>` is a form-associated Select custom element. It uses a JSON `options` attribute because slotting `<option>` elements into a shadow DOM `<select>` is not cross-browser supported.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<bds-select
|
|
14
|
+
name="country"
|
|
15
|
+
placeholder="Choose…"
|
|
16
|
+
options='[{"value":"nl","label":"Netherlands"},{"value":"be","label":"Belgium"}]'
|
|
17
|
+
></bds-select>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Attributes
|
|
21
|
+
|
|
22
|
+
| Attribute | Type | Default | Description |
|
|
23
|
+
|---------------|-----------|---------|------------------------------------------------------|
|
|
24
|
+
| `name` | `string` | `""` | Form field name |
|
|
25
|
+
| `value` | `string` | `""` | Currently selected value |
|
|
26
|
+
| `options` | `string` | `"[]"` | JSON array of `{ value, label, disabled? }` objects |
|
|
27
|
+
| `placeholder` | `string` | `""` | Placeholder option label (disabled, empty value) |
|
|
28
|
+
| `required` | `boolean` | `false` | Marks the field as required |
|
|
29
|
+
| `disabled` | `boolean` | `false` | Disables the select |
|
|
30
|
+
|
|
31
|
+
## Stories
|
|
32
|
+
|
|
33
|
+
<Canvas of={Stories.Default} />
|
|
34
|
+
<Canvas of={Stories.AllVariants} />
|
|
35
|
+
|
|
36
|
+
## Controls
|
|
37
|
+
|
|
38
|
+
<ArgTypes of={Stories} />
|