@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,117 @@
|
|
|
1
|
+
import { fixture, cleanup } from '../../test/helpers';
|
|
2
|
+
import { BdsCombobox } from './bds-combobox';
|
|
3
|
+
|
|
4
|
+
const OPTIONS = JSON.stringify([
|
|
5
|
+
{ value: 'nl', label: 'Netherlands' },
|
|
6
|
+
{ value: 'be', label: 'Belgium' },
|
|
7
|
+
{ value: 'de', label: 'Germany', disabled: true },
|
|
8
|
+
]);
|
|
9
|
+
|
|
10
|
+
describe('bds-combobox', () => {
|
|
11
|
+
it('is registered as a custom element', () => {
|
|
12
|
+
expect(customElements.get('bds-combobox')).toBe(BdsCombobox);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('renders a text input with role="combobox"', async () => {
|
|
16
|
+
const el = await fixture(`<bds-combobox name="country" options='${OPTIONS}'></bds-combobox>`);
|
|
17
|
+
const input = el.shadowRoot!.querySelector<HTMLInputElement>('input')!;
|
|
18
|
+
expect(input).not.toBeNull();
|
|
19
|
+
expect(input.getAttribute('role')).toBe('combobox');
|
|
20
|
+
cleanup(el);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('forwards placeholder to the input', async () => {
|
|
24
|
+
const el = await fixture(`<bds-combobox name="country" placeholder="Search…" options='${OPTIONS}'></bds-combobox>`);
|
|
25
|
+
const input = el.shadowRoot!.querySelector<HTMLInputElement>('input')!;
|
|
26
|
+
expect(input.placeholder).toBe('Search…');
|
|
27
|
+
cleanup(el);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('input is disabled when disabled attribute is set', async () => {
|
|
31
|
+
const el = await fixture(`<bds-combobox name="country" disabled options='${OPTIONS}'></bds-combobox>`);
|
|
32
|
+
const input = el.shadowRoot!.querySelector<HTMLInputElement>('input')!;
|
|
33
|
+
expect(input.disabled).toBe(true);
|
|
34
|
+
cleanup(el);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('shows listbox when input is focused', async () => {
|
|
38
|
+
const el = await fixture(`<bds-combobox name="country" options='${OPTIONS}'></bds-combobox>`);
|
|
39
|
+
const input = el.shadowRoot!.querySelector<HTMLInputElement>('input')!;
|
|
40
|
+
input.dispatchEvent(new Event('focus'));
|
|
41
|
+
await el.updateComplete;
|
|
42
|
+
expect(el.shadowRoot!.querySelector('[role="listbox"]')).not.toBeNull();
|
|
43
|
+
cleanup(el);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('renders options in the listbox', async () => {
|
|
47
|
+
const el = await fixture(`<bds-combobox name="country" options='${OPTIONS}'></bds-combobox>`);
|
|
48
|
+
const input = el.shadowRoot!.querySelector<HTMLInputElement>('input')!;
|
|
49
|
+
input.dispatchEvent(new Event('focus'));
|
|
50
|
+
await el.updateComplete;
|
|
51
|
+
const listItems = el.shadowRoot!.querySelectorAll('[role="option"]');
|
|
52
|
+
expect(listItems.length).toBe(3);
|
|
53
|
+
cleanup(el);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('selects an option on mousedown', async () => {
|
|
57
|
+
const el = await fixture(`<bds-combobox name="country" options='${OPTIONS}'></bds-combobox>`) as BdsCombobox;
|
|
58
|
+
const input = el.shadowRoot!.querySelector<HTMLInputElement>('input')!;
|
|
59
|
+
input.dispatchEvent(new Event('focus'));
|
|
60
|
+
await el.updateComplete;
|
|
61
|
+
const option = el.shadowRoot!.querySelector<HTMLElement>('[role="option"]')!;
|
|
62
|
+
option.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));
|
|
63
|
+
expect(el.value).toBe('nl');
|
|
64
|
+
cleanup(el);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('fires bds-change when an option is selected', async () => {
|
|
68
|
+
const el = await fixture(`<bds-combobox name="country" options='${OPTIONS}'></bds-combobox>`);
|
|
69
|
+
const handler = vi.fn();
|
|
70
|
+
el.addEventListener('bds-change', handler);
|
|
71
|
+
const input = el.shadowRoot!.querySelector<HTMLInputElement>('input')!;
|
|
72
|
+
input.dispatchEvent(new Event('focus'));
|
|
73
|
+
await el.updateComplete;
|
|
74
|
+
const option = el.shadowRoot!.querySelector<HTMLElement>('[role="option"]')!;
|
|
75
|
+
option.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));
|
|
76
|
+
expect(handler).toHaveBeenCalledOnce();
|
|
77
|
+
expect(handler.mock.calls[0][0].detail).toMatchObject({ value: 'nl' });
|
|
78
|
+
cleanup(el);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('filters options based on input text', async () => {
|
|
82
|
+
const el = await fixture(`<bds-combobox name="country" options='${OPTIONS}'></bds-combobox>`);
|
|
83
|
+
const input = el.shadowRoot!.querySelector<HTMLInputElement>('input')!;
|
|
84
|
+
input.value = 'Neth';
|
|
85
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
86
|
+
await el.updateComplete;
|
|
87
|
+
const options = el.shadowRoot!.querySelectorAll('[role="option"]');
|
|
88
|
+
expect(options.length).toBe(1);
|
|
89
|
+
expect(options[0].textContent?.trim()).toBe('Netherlands');
|
|
90
|
+
cleanup(el);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('shows no results message when filter matches nothing', async () => {
|
|
94
|
+
const el = await fixture(`<bds-combobox name="country" options='${OPTIONS}'></bds-combobox>`);
|
|
95
|
+
const input = el.shadowRoot!.querySelector<HTMLInputElement>('input')!;
|
|
96
|
+
input.value = 'zzz';
|
|
97
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
98
|
+
await el.updateComplete;
|
|
99
|
+
expect(el.shadowRoot!.querySelector('.no-results')).not.toBeNull();
|
|
100
|
+
cleanup(el);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('closes listbox on Escape key', async () => {
|
|
104
|
+
const el = await fixture(`<bds-combobox name="country" options='${OPTIONS}'></bds-combobox>`);
|
|
105
|
+
const input = el.shadowRoot!.querySelector<HTMLInputElement>('input')!;
|
|
106
|
+
input.dispatchEvent(new Event('focus'));
|
|
107
|
+
await el.updateComplete;
|
|
108
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
|
|
109
|
+
await el.updateComplete;
|
|
110
|
+
expect(el.shadowRoot!.querySelector('[role="listbox"]')).toBeNull();
|
|
111
|
+
cleanup(el);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('is form-associated', () => {
|
|
115
|
+
expect(BdsCombobox.formAssociated).toBe(true);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { LitElement, css, html } from 'lit';
|
|
2
|
+
|
|
3
|
+
export interface ComboboxOption {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* `<bds-combobox>` — form-associated Combobox (autocomplete) custom element.
|
|
11
|
+
*
|
|
12
|
+
* Renders a text input with a filterable dropdown. Keyboard navigation:
|
|
13
|
+
* ArrowDown/ArrowUp to move focus, Enter to select, Escape to close.
|
|
14
|
+
*
|
|
15
|
+
* Attributes:
|
|
16
|
+
* name — form field name
|
|
17
|
+
* value — currently selected value
|
|
18
|
+
* options — JSON array of `{ value, label, disabled? }` option objects
|
|
19
|
+
* placeholder — input placeholder text
|
|
20
|
+
* disabled — boolean
|
|
21
|
+
*
|
|
22
|
+
* Events:
|
|
23
|
+
* bds-change — fired with `{ detail: { value, label } }` when an option is selected
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* <bds-combobox
|
|
27
|
+
* name="country"
|
|
28
|
+
* placeholder="Search…"
|
|
29
|
+
* options='[{"value":"nl","label":"Netherlands"},{"value":"be","label":"Belgium"}]'
|
|
30
|
+
* ></bds-combobox>
|
|
31
|
+
*/
|
|
32
|
+
export class BdsCombobox extends LitElement {
|
|
33
|
+
static formAssociated = true;
|
|
34
|
+
|
|
35
|
+
static styles = css`
|
|
36
|
+
:host {
|
|
37
|
+
display: block;
|
|
38
|
+
position: relative;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
:host([disabled]) {
|
|
42
|
+
opacity: 0.5;
|
|
43
|
+
pointer-events: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.wrapper {
|
|
47
|
+
position: relative;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.input {
|
|
51
|
+
inline-size: 100%;
|
|
52
|
+
font-family: var(--bds-font_family--body);
|
|
53
|
+
font-size: var(--bds-font_size--body);
|
|
54
|
+
padding: var(--bds-space_s);
|
|
55
|
+
padding-inline-end: var(--bds-space_xl);
|
|
56
|
+
border: none;
|
|
57
|
+
--bdc_color: currentcolor;
|
|
58
|
+
--bdc-outline_radius: var(--bds-border_radius--xs);
|
|
59
|
+
|
|
60
|
+
border-radius: var(--combobox_radius, var(--bdc-outline_radius));
|
|
61
|
+
box-shadow: inset 0 0 0 var(--bdc-outline_width) var(--bdc_color), var(--combobox_shadow, var(--bdc-outline_shadow));
|
|
62
|
+
background-color: var(--combobox_color_bg, var(--bds-color_bg));
|
|
63
|
+
color: var(--combobox_color, var(--bds-color_on-bg));
|
|
64
|
+
box-sizing: border-box;
|
|
65
|
+
transition: --bdc_color var(--bds-animation_transition-duration) var(--bds-animation_easing);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.input:focus {
|
|
69
|
+
--bdc_color: var(--bdc_color--focus);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.input:focus-visible {
|
|
73
|
+
outline: var(--bds-outline_default);
|
|
74
|
+
outline-offset: var(--bds-outline_offset);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.chevron {
|
|
78
|
+
position: absolute;
|
|
79
|
+
inset-inline-end: var(--bds-space_s);
|
|
80
|
+
inset-block-start: 50%;
|
|
81
|
+
transform: translateY(-50%);
|
|
82
|
+
pointer-events: none;
|
|
83
|
+
inline-size: 1rem;
|
|
84
|
+
block-size: 1rem;
|
|
85
|
+
color: currentcolor;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.chevron svg {
|
|
89
|
+
inline-size: 100%;
|
|
90
|
+
block-size: 100%;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.listbox {
|
|
94
|
+
position: absolute;
|
|
95
|
+
inset-block-start: calc(100% + var(--bds-space_xs));
|
|
96
|
+
inset-inline-start: 0;
|
|
97
|
+
inline-size: 100%;
|
|
98
|
+
max-block-size: 15rem;
|
|
99
|
+
overflow-y: auto;
|
|
100
|
+
background-color: var(--combobox_list-bg, var(--bds-color_bg));
|
|
101
|
+
border-radius: var(--bds-border_radius--s);
|
|
102
|
+
box-shadow: var(--bds-shadow_m);
|
|
103
|
+
z-index: var(--combobox_z-index, 100);
|
|
104
|
+
padding-block: var(--bds-space_xs);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.option {
|
|
108
|
+
display: block;
|
|
109
|
+
padding: var(--bds-space_s) var(--bds-space_m);
|
|
110
|
+
cursor: pointer;
|
|
111
|
+
font-family: var(--bds-font_family--body);
|
|
112
|
+
font-size: var(--bds-font_size--body);
|
|
113
|
+
color: var(--bds-color_on-bg);
|
|
114
|
+
transition: background-color var(--bds-animation_transition-duration) var(--bds-animation_easing);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.option:hover,
|
|
118
|
+
.option[aria-selected='true'] {
|
|
119
|
+
background-color: var(--bds-color_bg--subtle);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.option[aria-disabled='true'] {
|
|
123
|
+
opacity: 0.4;
|
|
124
|
+
cursor: not-allowed;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.option.--focused {
|
|
128
|
+
background-color: var(--bds-color_bg--subtle);
|
|
129
|
+
outline: none;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.no-results {
|
|
133
|
+
padding: var(--bds-space_s) var(--bds-space_m);
|
|
134
|
+
font-family: var(--bds-font_family--body);
|
|
135
|
+
font-size: var(--bds-font_size--body--s);
|
|
136
|
+
color: var(--bds-color_on-bg--subtle);
|
|
137
|
+
}
|
|
138
|
+
`;
|
|
139
|
+
|
|
140
|
+
static properties = {
|
|
141
|
+
name: { type: String, reflect: true },
|
|
142
|
+
value: { type: String },
|
|
143
|
+
options: { type: String },
|
|
144
|
+
placeholder: { type: String },
|
|
145
|
+
disabled: { type: Boolean, reflect: true },
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
declare name: string;
|
|
149
|
+
declare value: string;
|
|
150
|
+
declare options: string;
|
|
151
|
+
declare placeholder: string;
|
|
152
|
+
declare disabled: boolean;
|
|
153
|
+
|
|
154
|
+
private _internals!: ElementInternals;
|
|
155
|
+
private _open = false;
|
|
156
|
+
private _query = '';
|
|
157
|
+
private _focusedIndex = -1;
|
|
158
|
+
|
|
159
|
+
constructor() {
|
|
160
|
+
super();
|
|
161
|
+
this._internals = this.attachInternals();
|
|
162
|
+
this.name = '';
|
|
163
|
+
this.value = '';
|
|
164
|
+
this.options = '[]';
|
|
165
|
+
this.placeholder = '';
|
|
166
|
+
this.disabled = false;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private get _options(): ComboboxOption[] {
|
|
170
|
+
try {
|
|
171
|
+
return JSON.parse(this.options) as ComboboxOption[];
|
|
172
|
+
} catch {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private get _filtered(): ComboboxOption[] {
|
|
178
|
+
const q = this._query.toLowerCase();
|
|
179
|
+
return q
|
|
180
|
+
? this._options.filter(o => o.label.toLowerCase().includes(q))
|
|
181
|
+
: this._options;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
private get _displayLabel(): string {
|
|
185
|
+
if (this.value) {
|
|
186
|
+
return this._options.find(o => o.value === this.value)?.label ?? '';
|
|
187
|
+
}
|
|
188
|
+
return '';
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
updated(changed: Map<string, unknown>) {
|
|
192
|
+
super.updated(changed);
|
|
193
|
+
if (changed.has('value')) {
|
|
194
|
+
this._internals.setFormValue?.(this.value || null);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
formResetCallback() {
|
|
199
|
+
this.value = '';
|
|
200
|
+
this._query = '';
|
|
201
|
+
this._open = false;
|
|
202
|
+
this._internals.setFormValue?.(null);
|
|
203
|
+
this.requestUpdate();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
private _openList() {
|
|
207
|
+
this._open = true;
|
|
208
|
+
this._focusedIndex = this._filtered.findIndex(o => o.value === this.value);
|
|
209
|
+
this.requestUpdate();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
private _closeList() {
|
|
213
|
+
this._open = false;
|
|
214
|
+
this._query = '';
|
|
215
|
+
this._focusedIndex = -1;
|
|
216
|
+
this.requestUpdate();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private _selectOption(opt: ComboboxOption) {
|
|
220
|
+
if (opt.disabled) return;
|
|
221
|
+
this.value = opt.value;
|
|
222
|
+
this._closeList();
|
|
223
|
+
this.dispatchEvent(new CustomEvent('bds-change', {
|
|
224
|
+
bubbles: true,
|
|
225
|
+
composed: true,
|
|
226
|
+
detail: { value: opt.value, label: opt.label },
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
private _handleInput(e: Event) {
|
|
231
|
+
this._query = (e.target as HTMLInputElement).value;
|
|
232
|
+
this._open = true;
|
|
233
|
+
this._focusedIndex = -1;
|
|
234
|
+
this.requestUpdate();
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
private _handleFocus() {
|
|
238
|
+
this._openList();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
private _handleBlur() {
|
|
242
|
+
// Delay close so option clicks register first
|
|
243
|
+
setTimeout(() => {
|
|
244
|
+
this._closeList();
|
|
245
|
+
}, 150);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
private _handleKeydown(e: KeyboardEvent) {
|
|
249
|
+
const filtered = this._filtered;
|
|
250
|
+
if (!this._open) {
|
|
251
|
+
if (e.key === 'ArrowDown' || e.key === 'Enter') {
|
|
252
|
+
e.preventDefault();
|
|
253
|
+
this._openList();
|
|
254
|
+
}
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (e.key === 'ArrowDown') {
|
|
259
|
+
e.preventDefault();
|
|
260
|
+
let next = this._focusedIndex + 1;
|
|
261
|
+
while (next < filtered.length && filtered[next].disabled) next++;
|
|
262
|
+
if (next < filtered.length) this._focusedIndex = next;
|
|
263
|
+
} else if (e.key === 'ArrowUp') {
|
|
264
|
+
e.preventDefault();
|
|
265
|
+
let prev = this._focusedIndex - 1;
|
|
266
|
+
while (prev >= 0 && filtered[prev].disabled) prev--;
|
|
267
|
+
if (prev >= 0) this._focusedIndex = prev;
|
|
268
|
+
} else if (e.key === 'Enter') {
|
|
269
|
+
e.preventDefault();
|
|
270
|
+
if (this._focusedIndex >= 0 && this._focusedIndex < filtered.length) {
|
|
271
|
+
this._selectOption(filtered[this._focusedIndex]);
|
|
272
|
+
}
|
|
273
|
+
} else if (e.key === 'Escape') {
|
|
274
|
+
e.preventDefault();
|
|
275
|
+
this._closeList();
|
|
276
|
+
}
|
|
277
|
+
this.requestUpdate();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
render() {
|
|
281
|
+
const filtered = this._filtered;
|
|
282
|
+
const inputValue = this._open ? this._query : this._displayLabel;
|
|
283
|
+
|
|
284
|
+
return html`
|
|
285
|
+
<div class="wrapper">
|
|
286
|
+
<input
|
|
287
|
+
type="text"
|
|
288
|
+
class="input"
|
|
289
|
+
role="combobox"
|
|
290
|
+
aria-expanded=${this._open}
|
|
291
|
+
aria-autocomplete="list"
|
|
292
|
+
aria-haspopup="listbox"
|
|
293
|
+
name=${this.name}
|
|
294
|
+
placeholder=${this.placeholder}
|
|
295
|
+
.value=${inputValue}
|
|
296
|
+
?disabled=${this.disabled}
|
|
297
|
+
@input=${this._handleInput}
|
|
298
|
+
@focus=${this._handleFocus}
|
|
299
|
+
@blur=${this._handleBlur}
|
|
300
|
+
@keydown=${this._handleKeydown}
|
|
301
|
+
/>
|
|
302
|
+
<span class="chevron" aria-hidden="true">
|
|
303
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
304
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M6 9l6 6 6-6" />
|
|
305
|
+
</svg>
|
|
306
|
+
</span>
|
|
307
|
+
${this._open ? html`
|
|
308
|
+
<ul class="listbox" role="listbox" aria-label="Options">
|
|
309
|
+
${filtered.length === 0
|
|
310
|
+
? html`<li class="no-results">No results</li>`
|
|
311
|
+
: filtered.map((opt, i) => html`
|
|
312
|
+
<li
|
|
313
|
+
class="option ${i === this._focusedIndex ? '--focused' : ''}"
|
|
314
|
+
role="option"
|
|
315
|
+
aria-selected=${opt.value === this.value}
|
|
316
|
+
aria-disabled=${opt.disabled ?? false}
|
|
317
|
+
@mousedown=${(e: Event) => { e.preventDefault(); this._selectOption(opt); }}
|
|
318
|
+
>${opt.label}</li>
|
|
319
|
+
`)
|
|
320
|
+
}
|
|
321
|
+
</ul>
|
|
322
|
+
` : ''}
|
|
323
|
+
</div>
|
|
324
|
+
`;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
customElements.define('bds-combobox', BdsCombobox);
|
|
329
|
+
|
|
330
|
+
declare global {
|
|
331
|
+
interface HTMLElementTagNameMap {
|
|
332
|
+
'bds-combobox': BdsCombobox;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { fixture, cleanup } from '../../test/helpers';
|
|
2
|
+
import { BdsFileInput } from './bds-file-input';
|
|
3
|
+
|
|
4
|
+
describe('bds-file-input', () => {
|
|
5
|
+
it('is registered as a custom element', () => {
|
|
6
|
+
expect(customElements.get('bds-file-input')).toBe(BdsFileInput);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('renders a file input in shadow DOM', async () => {
|
|
10
|
+
const el = await fixture('<bds-file-input name="avatar"></bds-file-input>');
|
|
11
|
+
expect(el.shadowRoot!.querySelector('input[type="file"]')).not.toBeNull();
|
|
12
|
+
cleanup(el);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('renders a drop zone with role="button"', async () => {
|
|
16
|
+
const el = await fixture('<bds-file-input name="avatar"></bds-file-input>');
|
|
17
|
+
expect(el.shadowRoot!.querySelector('[role="button"]')).not.toBeNull();
|
|
18
|
+
cleanup(el);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('drop zone has aria-label="Upload file"', async () => {
|
|
22
|
+
const el = await fixture('<bds-file-input name="avatar"></bds-file-input>');
|
|
23
|
+
const zone = el.shadowRoot!.querySelector('[role="button"]')!;
|
|
24
|
+
expect(zone.getAttribute('aria-label')).toBe('Upload file');
|
|
25
|
+
cleanup(el);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('input is disabled when disabled attribute is set', async () => {
|
|
29
|
+
const el = await fixture('<bds-file-input name="avatar" disabled></bds-file-input>');
|
|
30
|
+
const input = el.shadowRoot!.querySelector<HTMLInputElement>('input')!;
|
|
31
|
+
expect(input.disabled).toBe(true);
|
|
32
|
+
cleanup(el);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('forwards accept attribute to input', async () => {
|
|
36
|
+
const el = await fixture('<bds-file-input name="avatar" accept="image/*"></bds-file-input>');
|
|
37
|
+
const input = el.shadowRoot!.querySelector<HTMLInputElement>('input')!;
|
|
38
|
+
expect(input.accept).toBe('image/*');
|
|
39
|
+
cleanup(el);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('forwards multiple attribute to input', async () => {
|
|
43
|
+
const el = await fixture('<bds-file-input name="files" multiple></bds-file-input>');
|
|
44
|
+
const input = el.shadowRoot!.querySelector<HTMLInputElement>('input')!;
|
|
45
|
+
expect(input.multiple).toBe(true);
|
|
46
|
+
cleanup(el);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('renders slotted label text', async () => {
|
|
50
|
+
const el = await fixture('<bds-file-input name="avatar">Upload photo</bds-file-input>');
|
|
51
|
+
expect(el.textContent?.trim()).toBe('Upload photo');
|
|
52
|
+
cleanup(el);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('is form-associated', () => {
|
|
56
|
+
expect(BdsFileInput.formAssociated).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
});
|