@boostdev/design-system-components 1.1.0 → 1.1.2
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 +46 -5
- package/dist/client.cjs +206 -113
- package/dist/client.css +664 -624
- package/dist/client.d.cts +9 -3
- package/dist/client.d.ts +9 -3
- package/dist/client.js +241 -149
- package/dist/index.cjs +206 -113
- package/dist/index.css +664 -624
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +241 -149
- package/dist/web-components/chunk-2QA62WCQ.js +48 -0
- package/dist/web-components/chunk-4BX6AWXX.js +146 -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-6T3RKUKG.js +65 -0
- package/dist/web-components/chunk-7FMR53BW.js +127 -0
- package/dist/web-components/chunk-A67LCT7C.js +134 -0
- package/dist/web-components/chunk-AGKJTMJI.js +56 -0
- package/dist/web-components/chunk-BQLZ7I4G.js +56 -0
- package/dist/web-components/chunk-CAPI25CU.js +53 -0
- package/dist/web-components/chunk-CJ5ZOO42.js +229 -0
- package/dist/web-components/chunk-CR5PGUHV.js +109 -0
- package/dist/web-components/chunk-ECW3HHWA.js +185 -0
- package/dist/web-components/chunk-HGBNDR22.js +98 -0
- package/dist/web-components/chunk-IK3PTFZ4.js +133 -0
- package/dist/web-components/chunk-IQGLIQSO.js +188 -0
- package/dist/web-components/chunk-ITHLKR7Q.js +105 -0
- package/dist/web-components/chunk-K5CE6HSB.js +169 -0
- package/dist/web-components/chunk-L3XHOMN6.js +111 -0
- package/dist/{web-components.js → web-components/chunk-LGEZYFUU.js} +62 -834
- package/dist/web-components/chunk-LSC4N56Q.js +168 -0
- package/dist/web-components/chunk-LY62SAVN.js +64 -0
- package/dist/web-components/chunk-O4UFI2RX.js +244 -0
- package/dist/web-components/chunk-O7I63SQX.js +124 -0
- package/dist/web-components/chunk-OHUTLSIQ.js +69 -0
- package/dist/web-components/chunk-OQTRTMAB.js +27 -0
- package/dist/web-components/chunk-OTX4COSV.js +187 -0
- package/dist/web-components/chunk-PY62FTRW.js +179 -0
- package/dist/web-components/chunk-Q4T5BJT6.js +94 -0
- package/dist/web-components/chunk-QDRH46TF.js +281 -0
- package/dist/web-components/chunk-QDST57JC.js +119 -0
- package/dist/web-components/chunk-QPOKHLMQ.js +45 -0
- package/dist/web-components/chunk-SOQQ7RVJ.js +88 -0
- package/dist/web-components/chunk-UFFCKVZE.js +149 -0
- package/dist/web-components/chunk-VM3YHGQ2.js +152 -0
- package/dist/web-components/chunk-VMMVWLXL.js +53 -0
- package/dist/web-components/chunk-VSS5ITNE.js +109 -0
- package/dist/web-components/chunk-XIENXR7H.js +118 -0
- package/dist/web-components/chunk-Y4MAXTMA.js +80 -0
- package/dist/web-components/chunk-YLVTEY23.js +165 -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 +71 -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 +169 -4
- package/src/components/interaction/Button/Button.module.css +1 -1
- package/src/components/interaction/Button/Button.native.mdx +72 -0
- package/src/components/interaction/Command/Command.module.css +7 -7
- package/src/components/interaction/Command/Command.spec.tsx +37 -0
- package/src/components/interaction/Command/Command.tsx +37 -2
- package/src/components/interaction/Dialog/Dialog.module.css +10 -13
- package/src/components/interaction/Dialog/Dialog.spec.tsx +53 -1
- package/src/components/interaction/Dialog/Dialog.stories.tsx +17 -0
- package/src/components/interaction/Dialog/Dialog.tsx +50 -16
- package/src/components/interaction/Drawer/Drawer.module.css +11 -11
- package/src/components/interaction/Drawer/Drawer.spec.tsx +48 -1
- package/src/components/interaction/Drawer/Drawer.tsx +38 -4
- package/src/components/interaction/DropdownMenu/DropdownMenu.module.css +6 -6
- package/src/components/interaction/Popover/Popover.module.css +74 -15
- package/src/components/interaction/Popover/Popover.spec.tsx +94 -59
- package/src/components/interaction/Popover/Popover.tsx +44 -60
- package/src/components/interaction/Toast/Toast.module.css +7 -7
- package/src/components/interaction/form/Checkbox/Checkbox.module.css +6 -6
- package/src/components/interaction/form/Checkbox/Checkbox.native.mdx +74 -0
- package/src/components/interaction/form/Combobox/Combobox.module.css +7 -8
- package/src/components/interaction/form/FileInput/FileInput.module.css +4 -4
- package/src/components/interaction/form/NumberInput/NumberInput.module.css +1 -1
- package/src/components/interaction/form/Radio/Radio.module.css +6 -6
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.module.css +5 -6
- package/src/components/interaction/form/Select/Select.module.css +3 -3
- package/src/components/interaction/form/Slider/Slider.module.css +6 -6
- package/src/components/interaction/form/Switch/Switch.module.css +8 -8
- package/src/components/interaction/form/Textarea/Textarea.module.css +1 -1
- package/src/components/layout/IconWrapper/IconWrapper.module.css +2 -2
- package/src/components/ui/Accordion/Accordion.module.css +5 -5
- package/src/components/ui/Alert/Alert.native.mdx +62 -0
- package/src/components/ui/Avatar/Avatar.native.mdx +50 -0
- package/src/components/ui/Badge/Badge.native.mdx +54 -0
- package/src/components/ui/Calendar/Calendar.module.css +7 -7
- package/src/components/ui/Carousel/Carousel.module.css +5 -5
- package/src/components/ui/Collapsible/Collapsible.module.css +4 -4
- package/src/components/ui/Link/Link.module.css +2 -2
- package/src/components/ui/Loading/Loading.module.css +7 -7
- package/src/components/ui/NotificationBanner/NotificationBanner.module.css +3 -3
- package/src/components/ui/Pagination/Pagination.module.css +6 -6
- package/src/components/ui/Progress/Progress.module.css +5 -5
- package/src/components/ui/Separator/Separator.module.css +3 -3
- package/src/components/ui/Skeleton/Skeleton.module.css +1 -1
- package/src/components/ui/Table/Table.module.css +9 -9
- package/src/components/ui/Tabs/Tabs.module.css +3 -3
- package/src/components/ui/Tooltip/Tooltip.module.css +8 -8
- package/src/components/ui/Typography/Typography.native.mdx +56 -0
- package/src/polyfill-invoker-commands.ts +68 -0
- package/src/react-augment.d.ts +19 -0
- package/src/stories/ReactNative.mdx +121 -0
- package/src/web-components/index.ts +47 -0
- package/src/web-components/interaction/BdsButton.mdx +106 -0
- package/src/web-components/interaction/BdsPopover.mdx +120 -0
- package/src/web-components/interaction/BdsToastProvider.mdx +94 -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 +99 -0
- 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 +224 -0
- package/src/web-components/interaction/bds-drawer.spec.ts +113 -0
- package/src/web-components/interaction/bds-drawer.ts +266 -0
- package/src/web-components/interaction/bds-popover.spec.ts +49 -1
- package/src/web-components/interaction/bds-popover.ts +12 -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/bds-checkbox.spec.ts +63 -0
- package/src/web-components/interaction/form/bds-checkbox.ts +168 -0
- package/src/web-components/interaction/form/bds-combobox.spec.ts +117 -0
- package/src/web-components/interaction/form/bds-combobox.ts +336 -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 +221 -0
- package/src/web-components/interaction/form/bds-radio.spec.ts +70 -0
- package/src/web-components/interaction/form/bds-radio.ts +157 -0
- package/src/web-components/interaction/form/bds-segmented-control.spec.ts +74 -0
- package/src/web-components/interaction/form/bds-segmented-control.ts +211 -0
- package/src/web-components/interaction/form/bds-select.spec.ts +74 -0
- package/src/web-components/interaction/form/bds-select.ts +190 -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 +166 -0
- package/src/web-components/interaction/form/bds-textarea.spec.ts +55 -0
- package/src/web-components/interaction/form/bds-textarea.ts +143 -0
- package/src/web-components/test/helpers.ts +8 -0
- package/src/web-components/ui/BdsAlert.mdx +90 -0
- package/src/web-components/ui/BdsBadge.mdx +74 -0
- 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 +156 -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 +185 -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 -303
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
A,
|
|
3
|
+
T,
|
|
4
|
+
i,
|
|
5
|
+
i2
|
|
6
|
+
} from "./chunk-LGEZYFUU.js";
|
|
7
|
+
|
|
8
|
+
// src/web-components/ui/bds-progress.ts
|
|
9
|
+
var BdsProgress = class extends i2 {
|
|
10
|
+
static styles = i`
|
|
11
|
+
:host {
|
|
12
|
+
display: block;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.container {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
gap: var(--bds-space_xxs);
|
|
19
|
+
inline-size: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.label-row {
|
|
23
|
+
display: flex;
|
|
24
|
+
justify-content: space-between;
|
|
25
|
+
align-items: baseline;
|
|
26
|
+
font-size: var(--bds-font_size--body--s);
|
|
27
|
+
color: var(--bds-color_on-bg);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.value {
|
|
31
|
+
font-variant-numeric: tabular-nums;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.track {
|
|
35
|
+
inline-size: 100%;
|
|
36
|
+
block-size: var(--progress_height, var(--bds-space_xs));
|
|
37
|
+
background-color: var(--bds-color_bg--subtle);
|
|
38
|
+
border-radius: 999px;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:host([size='small']) .track { --progress_height: var(--bds-space_xxs); }
|
|
43
|
+
:host([size='medium']) .track { --progress_height: var(--bds-space_xs); }
|
|
44
|
+
:host([size='large']) .track { --progress_height: var(--bds-space_s); }
|
|
45
|
+
|
|
46
|
+
.fill {
|
|
47
|
+
block-size: 100%;
|
|
48
|
+
background-color: var(--progress_color-active, var(--bdc-color_active));
|
|
49
|
+
border-radius: 999px;
|
|
50
|
+
transition: inline-size var(--bds-animation_transition-duration) var(--bds-animation_easing);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@media (prefers-reduced-motion: reduce) {
|
|
54
|
+
.fill {
|
|
55
|
+
transition: none;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
static properties = {
|
|
60
|
+
value: { type: Number },
|
|
61
|
+
max: { type: Number },
|
|
62
|
+
label: { type: String },
|
|
63
|
+
showLabel: { type: Boolean, attribute: "show-label", reflect: true },
|
|
64
|
+
size: { type: String, reflect: true }
|
|
65
|
+
};
|
|
66
|
+
constructor() {
|
|
67
|
+
super();
|
|
68
|
+
this.value = 0;
|
|
69
|
+
this.max = 100;
|
|
70
|
+
this.label = "";
|
|
71
|
+
this.showLabel = false;
|
|
72
|
+
this.size = "medium";
|
|
73
|
+
}
|
|
74
|
+
get _percentage() {
|
|
75
|
+
return Math.min(100, Math.max(0, this.value / this.max * 100));
|
|
76
|
+
}
|
|
77
|
+
render() {
|
|
78
|
+
const pct = this._percentage;
|
|
79
|
+
return T`
|
|
80
|
+
<div class="container">
|
|
81
|
+
${this.showLabel ? T`
|
|
82
|
+
<div class="label-row">
|
|
83
|
+
<span class="label">${this.label}</span>
|
|
84
|
+
<span class="value">${Math.round(pct)}%</span>
|
|
85
|
+
</div>
|
|
86
|
+
` : A}
|
|
87
|
+
<div
|
|
88
|
+
class="track"
|
|
89
|
+
role="progressbar"
|
|
90
|
+
aria-label=${this.label}
|
|
91
|
+
aria-valuenow=${this.value}
|
|
92
|
+
aria-valuemin="0"
|
|
93
|
+
aria-valuemax=${this.max}
|
|
94
|
+
>
|
|
95
|
+
<div class="fill" style="inline-size: ${pct}%"></div>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
`;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
customElements.define("bds-progress", BdsProgress);
|
|
102
|
+
|
|
103
|
+
export {
|
|
104
|
+
BdsProgress
|
|
105
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import {
|
|
2
|
+
T,
|
|
3
|
+
i,
|
|
4
|
+
i2
|
|
5
|
+
} from "./chunk-LGEZYFUU.js";
|
|
6
|
+
|
|
7
|
+
// src/web-components/interaction/form/bds-segmented-control.ts
|
|
8
|
+
var BdsSegmentedControl = class extends i2 {
|
|
9
|
+
static formAssociated = true;
|
|
10
|
+
static styles = i`
|
|
11
|
+
:host {
|
|
12
|
+
display: inline-flex;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:host([disabled]) {
|
|
16
|
+
opacity: 0.5;
|
|
17
|
+
pointer-events: none;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.control {
|
|
21
|
+
display: inline-flex;
|
|
22
|
+
position: relative;
|
|
23
|
+
border-radius: var(--bds-border_radius--s);
|
|
24
|
+
background-color: var(--segmented_color_bg, var(--bds-color_bg--subtle));
|
|
25
|
+
padding: 0.25rem;
|
|
26
|
+
gap: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Sliding thumb */
|
|
30
|
+
.thumb {
|
|
31
|
+
position: absolute;
|
|
32
|
+
inset-block: 0.25rem;
|
|
33
|
+
border-radius: calc(var(--bds-border_radius--s) - 2px);
|
|
34
|
+
background-color: var(--segmented_thumb-color, var(--bds-color_bg));
|
|
35
|
+
box-shadow: var(--bds-shadow_m);
|
|
36
|
+
transition: inset-inline-start var(--bds-animation_transition-duration) var(--bds-animation_easing),
|
|
37
|
+
inline-size var(--bds-animation_transition-duration) var(--bds-animation_easing);
|
|
38
|
+
pointer-events: none;
|
|
39
|
+
/* Position set via JS in updated() */
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.radio {
|
|
43
|
+
position: absolute;
|
|
44
|
+
opacity: 0;
|
|
45
|
+
inline-size: 0;
|
|
46
|
+
block-size: 0;
|
|
47
|
+
margin: 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.item {
|
|
51
|
+
position: relative;
|
|
52
|
+
display: inline-flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
padding: var(--bds-space_xs) var(--bds-space_m);
|
|
56
|
+
font-size: var(--bds-font_size--body--s);
|
|
57
|
+
font-family: var(--bds-font_family--body);
|
|
58
|
+
font-weight: var(--bds-font_weight--semibold);
|
|
59
|
+
color: var(--segmented_color, var(--bds-color_on-bg));
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
border-radius: calc(var(--bds-border_radius--s) - 2px);
|
|
62
|
+
transition: color var(--bds-animation_transition-duration) var(--bds-animation_easing);
|
|
63
|
+
user-select: none;
|
|
64
|
+
white-space: nowrap;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.item.--active {
|
|
68
|
+
color: var(--segmented_color--active, var(--bds-color_interactive_on-bg));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.item.--disabled {
|
|
72
|
+
opacity: 0.4;
|
|
73
|
+
cursor: not-allowed;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.radio:focus-visible + .item-label {
|
|
77
|
+
outline: var(--bds-outline_default);
|
|
78
|
+
outline-offset: var(--bds-outline_offset);
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
static properties = {
|
|
82
|
+
name: { type: String, reflect: true },
|
|
83
|
+
value: { type: String },
|
|
84
|
+
options: { type: String },
|
|
85
|
+
disabled: { type: Boolean, reflect: true }
|
|
86
|
+
};
|
|
87
|
+
_internals;
|
|
88
|
+
_uid = Math.random().toString(36).slice(2, 8);
|
|
89
|
+
constructor() {
|
|
90
|
+
super();
|
|
91
|
+
this._internals = this.attachInternals();
|
|
92
|
+
this.name = "";
|
|
93
|
+
this.value = "";
|
|
94
|
+
this.options = "[]";
|
|
95
|
+
this.disabled = false;
|
|
96
|
+
}
|
|
97
|
+
get _options() {
|
|
98
|
+
try {
|
|
99
|
+
return JSON.parse(this.options);
|
|
100
|
+
} catch {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
updated(changed) {
|
|
105
|
+
super.updated(changed);
|
|
106
|
+
if (changed.has("value") || changed.has("options")) {
|
|
107
|
+
this._internals.setFormValue?.(this.value || null);
|
|
108
|
+
this._updateThumb();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
_updateThumb() {
|
|
112
|
+
const opts = this._options;
|
|
113
|
+
const selectedIndex = Math.max(0, opts.findIndex((o) => o.value === this.value));
|
|
114
|
+
const items = this.shadowRoot?.querySelectorAll(".item");
|
|
115
|
+
const thumb = this.shadowRoot?.querySelector(".thumb");
|
|
116
|
+
if (!items || !thumb || items.length === 0) return;
|
|
117
|
+
const item = items[selectedIndex];
|
|
118
|
+
if (!item) return;
|
|
119
|
+
const controlRect = item.parentElement.getBoundingClientRect();
|
|
120
|
+
const itemRect = item.getBoundingClientRect();
|
|
121
|
+
thumb.style.insetInlineStart = `${itemRect.left - controlRect.left}px`;
|
|
122
|
+
thumb.style.inlineSize = `${itemRect.width}px`;
|
|
123
|
+
}
|
|
124
|
+
formResetCallback() {
|
|
125
|
+
const firstOption = this._options[0];
|
|
126
|
+
this.value = firstOption?.value ?? "";
|
|
127
|
+
this._internals.setFormValue?.(this.value || null);
|
|
128
|
+
}
|
|
129
|
+
_handleChange(optionValue) {
|
|
130
|
+
this.value = optionValue;
|
|
131
|
+
this.dispatchEvent(new Event("change", { bubbles: true, composed: true }));
|
|
132
|
+
}
|
|
133
|
+
render() {
|
|
134
|
+
const opts = this._options;
|
|
135
|
+
return T`
|
|
136
|
+
<div class="control" role="group">
|
|
137
|
+
<span class="thumb" aria-hidden="true"></span>
|
|
138
|
+
${opts.map((opt, i3) => {
|
|
139
|
+
const id = `bds-seg-${this._uid}-${i3}`;
|
|
140
|
+
const isActive = opt.value === this.value;
|
|
141
|
+
const isDisabled = this.disabled || opt.disabled;
|
|
142
|
+
return T`
|
|
143
|
+
<label
|
|
144
|
+
class="item ${isActive ? "--active" : ""} ${isDisabled ? "--disabled" : ""}"
|
|
145
|
+
for=${id}
|
|
146
|
+
>
|
|
147
|
+
<input
|
|
148
|
+
id=${id}
|
|
149
|
+
type="radio"
|
|
150
|
+
class="radio"
|
|
151
|
+
name=${this.name || this._uid}
|
|
152
|
+
value=${opt.value}
|
|
153
|
+
.checked=${isActive}
|
|
154
|
+
?disabled=${isDisabled}
|
|
155
|
+
@change=${() => this._handleChange(opt.value)}
|
|
156
|
+
/>
|
|
157
|
+
${opt.label}
|
|
158
|
+
</label>
|
|
159
|
+
`;
|
|
160
|
+
})}
|
|
161
|
+
</div>
|
|
162
|
+
`;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
customElements.define("bds-segmented-control", BdsSegmentedControl);
|
|
166
|
+
|
|
167
|
+
export {
|
|
168
|
+
BdsSegmentedControl
|
|
169
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
T,
|
|
3
|
+
i,
|
|
4
|
+
i2
|
|
5
|
+
} from "./chunk-LGEZYFUU.js";
|
|
6
|
+
|
|
7
|
+
// src/web-components/interaction/bds-tabs.ts
|
|
8
|
+
var BdsTabs = class extends i2 {
|
|
9
|
+
static styles = i`
|
|
10
|
+
:host {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.tablist {
|
|
16
|
+
display: flex;
|
|
17
|
+
border-block-end: 1px solid var(--bds-color_bg--subtle);
|
|
18
|
+
gap: var(--bds-space_xxs);
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
_activeIndex = 0;
|
|
22
|
+
_mo = null;
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
super.connectedCallback();
|
|
25
|
+
this.addEventListener("bds-tab-select", this._handleTabSelect);
|
|
26
|
+
this.addEventListener("keydown", this._handleKeydown);
|
|
27
|
+
this._mo = new MutationObserver(() => {
|
|
28
|
+
this._applyState();
|
|
29
|
+
});
|
|
30
|
+
this._mo.observe(this, { childList: true, subtree: false });
|
|
31
|
+
Promise.resolve().then(() => this._applyState());
|
|
32
|
+
}
|
|
33
|
+
disconnectedCallback() {
|
|
34
|
+
super.disconnectedCallback();
|
|
35
|
+
this.removeEventListener("bds-tab-select", this._handleTabSelect);
|
|
36
|
+
this.removeEventListener("keydown", this._handleKeydown);
|
|
37
|
+
this._mo?.disconnect();
|
|
38
|
+
this._mo = null;
|
|
39
|
+
}
|
|
40
|
+
get _tabs() {
|
|
41
|
+
return [...this.querySelectorAll("bds-tab")];
|
|
42
|
+
}
|
|
43
|
+
get _panels() {
|
|
44
|
+
return [...this.querySelectorAll("bds-tab-panel")];
|
|
45
|
+
}
|
|
46
|
+
get _enabledIndexes() {
|
|
47
|
+
return this._tabs.map((tab, i3) => ({ tab, i: i3 })).filter(({ tab }) => !tab.disabled).map(({ i: i3 }) => i3);
|
|
48
|
+
}
|
|
49
|
+
_applyState() {
|
|
50
|
+
const tabs = this._tabs;
|
|
51
|
+
const panels = this._panels;
|
|
52
|
+
if (this._activeIndex >= tabs.length) {
|
|
53
|
+
this._activeIndex = Math.max(0, tabs.length - 1);
|
|
54
|
+
}
|
|
55
|
+
tabs.forEach((tab, i3) => {
|
|
56
|
+
tab.selected = i3 === this._activeIndex;
|
|
57
|
+
});
|
|
58
|
+
panels.forEach((panel, i3) => {
|
|
59
|
+
if (i3 === this._activeIndex) {
|
|
60
|
+
panel.removeAttribute("hidden");
|
|
61
|
+
} else {
|
|
62
|
+
panel.setAttribute("hidden", "");
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
_handleTabSelect = (e) => {
|
|
67
|
+
const tab = e.target;
|
|
68
|
+
const index = this._tabs.indexOf(tab);
|
|
69
|
+
if (index !== -1 && !tab.disabled) {
|
|
70
|
+
this._activeIndex = index;
|
|
71
|
+
this._applyState();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
_handleKeydown = (e) => {
|
|
75
|
+
const enabled = this._enabledIndexes;
|
|
76
|
+
if (!enabled.length) return;
|
|
77
|
+
const pos = enabled.indexOf(this._activeIndex);
|
|
78
|
+
let next = -1;
|
|
79
|
+
if (e.key === "ArrowRight") {
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
next = enabled[(pos + 1) % enabled.length];
|
|
82
|
+
} else if (e.key === "ArrowLeft") {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
next = enabled[(pos - 1 + enabled.length) % enabled.length];
|
|
85
|
+
} else if (e.key === "Home") {
|
|
86
|
+
e.preventDefault();
|
|
87
|
+
next = enabled[0];
|
|
88
|
+
} else if (e.key === "End") {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
next = enabled[enabled.length - 1];
|
|
91
|
+
}
|
|
92
|
+
if (next !== -1) {
|
|
93
|
+
this._activeIndex = next;
|
|
94
|
+
this._applyState();
|
|
95
|
+
this._tabs[next]?.focusButton?.();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
render() {
|
|
99
|
+
return T`
|
|
100
|
+
<div class="tablist" role="tablist">
|
|
101
|
+
<slot name="tab"></slot>
|
|
102
|
+
</div>
|
|
103
|
+
<slot name="panel"></slot>
|
|
104
|
+
`;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
customElements.define("bds-tabs", BdsTabs);
|
|
108
|
+
|
|
109
|
+
export {
|
|
110
|
+
BdsTabs
|
|
111
|
+
};
|