@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,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
A,
|
|
3
|
+
T,
|
|
4
|
+
i,
|
|
5
|
+
i2
|
|
6
|
+
} from "./chunk-LGEZYFUU.js";
|
|
7
|
+
|
|
8
|
+
// src/web-components/ui/bds-link.ts
|
|
9
|
+
var BdsLink = class extends i2 {
|
|
10
|
+
static styles = i`
|
|
11
|
+
:host {
|
|
12
|
+
display: inline;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.link {
|
|
16
|
+
color: var(--link_color, var(--bds-color_interactive_on-bg));
|
|
17
|
+
text-decoration: underline;
|
|
18
|
+
text-underline-offset: 0.2em;
|
|
19
|
+
transition: var(--bds-animation_transition);
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.link:focus-visible {
|
|
24
|
+
outline: var(--bds-outline_default);
|
|
25
|
+
outline-offset: var(--bds-outline_offset);
|
|
26
|
+
border-radius: var(--bds-border_radius--xs);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@media (hover: hover) and (pointer: fine) {
|
|
30
|
+
.link:hover {
|
|
31
|
+
--link_color: var(--link_color-hover, var(--bds-color_blue--strong));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.link.--variant_default {
|
|
36
|
+
--link_color: var(--bds-color_interactive_on-bg);
|
|
37
|
+
--link_color-hover: var(--bds-color_blue--strong);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.link.--variant_subtle {
|
|
41
|
+
--link_color: var(--bds-color_on-bg);
|
|
42
|
+
--link_color-hover: var(--bds-color_interactive_on-bg);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.link.--variant_standalone {
|
|
46
|
+
--link_color: var(--bds-color_interactive_on-bg);
|
|
47
|
+
--link_color-hover: var(--bds-color_blue--strong);
|
|
48
|
+
display: inline-flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
gap: var(--bds-space_xxs);
|
|
51
|
+
font-weight: var(--bds-font_weight--semibold);
|
|
52
|
+
text-decoration: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@media (hover: hover) and (pointer: fine) {
|
|
56
|
+
.link.--variant_standalone:hover {
|
|
57
|
+
text-decoration: underline;
|
|
58
|
+
text-underline-offset: 0.2em;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.external-label {
|
|
63
|
+
position: absolute;
|
|
64
|
+
inline-size: 1px;
|
|
65
|
+
block-size: 1px;
|
|
66
|
+
padding: 0;
|
|
67
|
+
margin: -1px;
|
|
68
|
+
overflow: hidden;
|
|
69
|
+
clip: rect(0, 0, 0, 0);
|
|
70
|
+
white-space: nowrap;
|
|
71
|
+
border-width: 0;
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
static properties = {
|
|
75
|
+
href: { type: String },
|
|
76
|
+
target: { type: String },
|
|
77
|
+
variant: { type: String, reflect: true },
|
|
78
|
+
external: { type: Boolean, reflect: true },
|
|
79
|
+
externalLabel: { type: String, attribute: "external-label" }
|
|
80
|
+
};
|
|
81
|
+
constructor() {
|
|
82
|
+
super();
|
|
83
|
+
this.href = "";
|
|
84
|
+
this.target = "";
|
|
85
|
+
this.variant = "default";
|
|
86
|
+
this.external = false;
|
|
87
|
+
this.externalLabel = "(opens in new tab)";
|
|
88
|
+
}
|
|
89
|
+
render() {
|
|
90
|
+
const rel = this.external ? "noreferrer noopener" : A;
|
|
91
|
+
const target = this.external ? "_blank" : this.target || A;
|
|
92
|
+
return T`
|
|
93
|
+
<a
|
|
94
|
+
class="link --variant_${this.variant}"
|
|
95
|
+
href=${this.href || A}
|
|
96
|
+
target=${target}
|
|
97
|
+
rel=${rel}
|
|
98
|
+
>
|
|
99
|
+
<slot></slot>
|
|
100
|
+
${this.external ? T`<span class="external-label">${this.externalLabel}</span>` : A}
|
|
101
|
+
</a>
|
|
102
|
+
`;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
customElements.define("bds-link", BdsLink);
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
BdsLink
|
|
109
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import {
|
|
2
|
+
T,
|
|
3
|
+
i,
|
|
4
|
+
i2
|
|
5
|
+
} from "./chunk-LGEZYFUU.js";
|
|
6
|
+
|
|
7
|
+
// src/web-components/interaction/bds-popover.ts
|
|
8
|
+
var BdsPopover = class extends i2 {
|
|
9
|
+
static styles = i`
|
|
10
|
+
:host {
|
|
11
|
+
display: inline-flex;
|
|
12
|
+
position: relative;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/* The wrapper IS the CSS anchor — anchor-name resolves via the custom
|
|
16
|
+
property injected on :host in connectedCallback(), so each instance
|
|
17
|
+
gets its own unique name without colliding with siblings. */
|
|
18
|
+
.wrapper {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
anchor-name: var(--bds-popover-anchor);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.panel {
|
|
24
|
+
display: none;
|
|
25
|
+
position: absolute;
|
|
26
|
+
position-anchor: var(--bds-popover-anchor);
|
|
27
|
+
margin: 0;
|
|
28
|
+
overflow-y: auto;
|
|
29
|
+
z-index: var(--popover_z-index, 100);
|
|
30
|
+
min-width: 12rem;
|
|
31
|
+
padding: var(--bds-space_m);
|
|
32
|
+
border-radius: var(--bds-border_radius--s);
|
|
33
|
+
background-color: var(--popover_color, var(--bds-color_bg));
|
|
34
|
+
box-shadow: var(--popover_shadow, var(--bds-shadow_m));
|
|
35
|
+
color: var(--popover_on-color, var(--bds-color_on-bg));
|
|
36
|
+
font-size: var(--bds-font_size--body);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.panel.open {
|
|
40
|
+
display: block;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* Primary placements */
|
|
44
|
+
|
|
45
|
+
.panel[data-placement='bottom'] {
|
|
46
|
+
top: anchor(bottom);
|
|
47
|
+
left: anchor(left);
|
|
48
|
+
margin-top: var(--bds-space_xs, 8px);
|
|
49
|
+
position-try-fallbacks: --bds-popover-top, --bds-popover-right, --bds-popover-left;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.panel[data-placement='top'] {
|
|
53
|
+
bottom: anchor(top);
|
|
54
|
+
left: anchor(left);
|
|
55
|
+
margin-bottom: var(--bds-space_xs, 8px);
|
|
56
|
+
position-try-fallbacks: --bds-popover-bottom, --bds-popover-right, --bds-popover-left;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.panel[data-placement='right'] {
|
|
60
|
+
top: anchor(top);
|
|
61
|
+
left: anchor(right);
|
|
62
|
+
margin-left: var(--bds-space_xs, 8px);
|
|
63
|
+
position-try-fallbacks: --bds-popover-left, --bds-popover-bottom, --bds-popover-top;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.panel[data-placement='left'] {
|
|
67
|
+
top: anchor(top);
|
|
68
|
+
right: anchor(left);
|
|
69
|
+
margin-right: var(--bds-space_xs, 8px);
|
|
70
|
+
position-try-fallbacks: --bds-popover-right, --bds-popover-bottom, --bds-popover-top;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Fallback placements */
|
|
74
|
+
|
|
75
|
+
@position-try --bds-popover-bottom {
|
|
76
|
+
top: anchor(bottom);
|
|
77
|
+
right: unset;
|
|
78
|
+
bottom: unset;
|
|
79
|
+
left: anchor(left);
|
|
80
|
+
margin: 0;
|
|
81
|
+
margin-top: var(--bds-space_xs, 8px);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@position-try --bds-popover-top {
|
|
85
|
+
top: unset;
|
|
86
|
+
right: unset;
|
|
87
|
+
bottom: anchor(top);
|
|
88
|
+
left: anchor(left);
|
|
89
|
+
margin: 0;
|
|
90
|
+
margin-bottom: var(--bds-space_xs, 8px);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@position-try --bds-popover-right {
|
|
94
|
+
top: anchor(top);
|
|
95
|
+
right: unset;
|
|
96
|
+
bottom: unset;
|
|
97
|
+
left: anchor(right);
|
|
98
|
+
margin: 0;
|
|
99
|
+
margin-left: var(--bds-space_xs, 8px);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@position-try --bds-popover-left {
|
|
103
|
+
top: anchor(top);
|
|
104
|
+
right: anchor(left);
|
|
105
|
+
bottom: unset;
|
|
106
|
+
left: unset;
|
|
107
|
+
margin: 0;
|
|
108
|
+
margin-right: var(--bds-space_xs, 8px);
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
static properties = {
|
|
112
|
+
placement: { type: String, reflect: true },
|
|
113
|
+
open: { type: Boolean, reflect: true }
|
|
114
|
+
};
|
|
115
|
+
_anchorName;
|
|
116
|
+
constructor() {
|
|
117
|
+
super();
|
|
118
|
+
this.placement = "bottom";
|
|
119
|
+
this.open = false;
|
|
120
|
+
const uid = Math.random().toString(36).slice(2, 8);
|
|
121
|
+
this._anchorName = `--bds-popover-${uid}`;
|
|
122
|
+
}
|
|
123
|
+
connectedCallback() {
|
|
124
|
+
super.connectedCallback();
|
|
125
|
+
this.style.setProperty("--bds-popover-anchor", this._anchorName);
|
|
126
|
+
document.addEventListener("keydown", this._onKeydown);
|
|
127
|
+
document.addEventListener("mousedown", this._onOutsideClick);
|
|
128
|
+
this.addEventListener("command", this._onCommand);
|
|
129
|
+
}
|
|
130
|
+
disconnectedCallback() {
|
|
131
|
+
super.disconnectedCallback();
|
|
132
|
+
document.removeEventListener("keydown", this._onKeydown);
|
|
133
|
+
document.removeEventListener("mousedown", this._onOutsideClick);
|
|
134
|
+
this.removeEventListener("command", this._onCommand);
|
|
135
|
+
}
|
|
136
|
+
_onKeydown = (e) => {
|
|
137
|
+
if (this.open && e.key === "Escape") this._close();
|
|
138
|
+
};
|
|
139
|
+
_onCommand = (e) => {
|
|
140
|
+
const command = e.command;
|
|
141
|
+
if (command === "--toggle") this._toggle();
|
|
142
|
+
else if (command === "--open") this._open();
|
|
143
|
+
else if (command === "--close") this._close();
|
|
144
|
+
};
|
|
145
|
+
_onOutsideClick = (e) => {
|
|
146
|
+
if (this.open && !this.contains(e.target)) this._close();
|
|
147
|
+
};
|
|
148
|
+
_toggle() {
|
|
149
|
+
if (this.open) {
|
|
150
|
+
this._close();
|
|
151
|
+
} else {
|
|
152
|
+
this._open();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
_open() {
|
|
156
|
+
if (this.open) return;
|
|
157
|
+
this.open = true;
|
|
158
|
+
this.dispatchEvent(new CustomEvent("bds-open", { bubbles: true, composed: true }));
|
|
159
|
+
}
|
|
160
|
+
_close() {
|
|
161
|
+
if (!this.open) return;
|
|
162
|
+
this.open = false;
|
|
163
|
+
this.dispatchEvent(new CustomEvent("bds-close", { bubbles: true, composed: true }));
|
|
164
|
+
}
|
|
165
|
+
render() {
|
|
166
|
+
return T`
|
|
167
|
+
<span class="wrapper">
|
|
168
|
+
<slot name="trigger" @click=${this._toggle}></slot>
|
|
169
|
+
</span>
|
|
170
|
+
<div
|
|
171
|
+
class="panel ${this.open ? "open" : ""}"
|
|
172
|
+
data-placement=${this.placement}
|
|
173
|
+
role="region"
|
|
174
|
+
aria-label="Popover"
|
|
175
|
+
>
|
|
176
|
+
<slot></slot>
|
|
177
|
+
</div>
|
|
178
|
+
`;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
customElements.define("bds-popover", BdsPopover);
|
|
182
|
+
|
|
183
|
+
export {
|
|
184
|
+
BdsPopover
|
|
185
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import {
|
|
2
|
+
T,
|
|
3
|
+
i,
|
|
4
|
+
i2
|
|
5
|
+
} from "./chunk-LGEZYFUU.js";
|
|
6
|
+
|
|
7
|
+
// src/web-components/interaction/bds-tooltip.ts
|
|
8
|
+
var BdsTooltip = class extends i2 {
|
|
9
|
+
static styles = i`
|
|
10
|
+
:host {
|
|
11
|
+
display: inline-flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
position: relative;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.tooltip {
|
|
17
|
+
position: absolute;
|
|
18
|
+
z-index: var(--bds-z-index_popover, 200);
|
|
19
|
+
padding: var(--bds-space_xxs) var(--bds-space_xs);
|
|
20
|
+
border-radius: var(--bds-border_radius--xs);
|
|
21
|
+
background-color: var(--tooltip_bg, var(--bds-color_on-bg));
|
|
22
|
+
color: var(--tooltip_text, var(--bds-color_bg));
|
|
23
|
+
font-size: var(--bds-font_size--body--s);
|
|
24
|
+
line-height: var(--bds-font_line-height--body);
|
|
25
|
+
white-space: nowrap;
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
|
|
28
|
+
/* Hidden by default */
|
|
29
|
+
visibility: hidden;
|
|
30
|
+
opacity: 0;
|
|
31
|
+
transition: opacity var(--bds-animation_transition-duration) var(--bds-animation_easing);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* Show on hover and keyboard focus */
|
|
35
|
+
:host(:hover) .tooltip,
|
|
36
|
+
:host(:focus-within) .tooltip {
|
|
37
|
+
visibility: visible;
|
|
38
|
+
opacity: 1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* Placement: top (default) */
|
|
42
|
+
.tooltip.--placement_top {
|
|
43
|
+
inset-block-end: calc(100% + var(--bds-space_xs));
|
|
44
|
+
inset-inline-start: 50%;
|
|
45
|
+
transform: translateX(-50%);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Placement: bottom */
|
|
49
|
+
.tooltip.--placement_bottom {
|
|
50
|
+
inset-block-start: calc(100% + var(--bds-space_xs));
|
|
51
|
+
inset-inline-start: 50%;
|
|
52
|
+
transform: translateX(-50%);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Placement: left */
|
|
56
|
+
.tooltip.--placement_left {
|
|
57
|
+
inset-inline-end: calc(100% + var(--bds-space_xs));
|
|
58
|
+
inset-block-start: 50%;
|
|
59
|
+
transform: translateY(-50%);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Placement: right */
|
|
63
|
+
.tooltip.--placement_right {
|
|
64
|
+
inset-inline-start: calc(100% + var(--bds-space_xs));
|
|
65
|
+
inset-block-start: 50%;
|
|
66
|
+
transform: translateY(-50%);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@media (prefers-reduced-motion: reduce) {
|
|
70
|
+
.tooltip {
|
|
71
|
+
transition: none;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
static properties = {
|
|
76
|
+
content: { type: String },
|
|
77
|
+
placement: { type: String, reflect: true }
|
|
78
|
+
};
|
|
79
|
+
constructor() {
|
|
80
|
+
super();
|
|
81
|
+
this.content = "";
|
|
82
|
+
this.placement = "top";
|
|
83
|
+
}
|
|
84
|
+
render() {
|
|
85
|
+
return T`
|
|
86
|
+
<slot></slot>
|
|
87
|
+
<span
|
|
88
|
+
class="tooltip --placement_${this.placement}"
|
|
89
|
+
role="tooltip"
|
|
90
|
+
>${this.content}</span>
|
|
91
|
+
`;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
customElements.define("bds-tooltip", BdsTooltip);
|
|
95
|
+
|
|
96
|
+
export {
|
|
97
|
+
BdsTooltip
|
|
98
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import {
|
|
2
|
+
T,
|
|
3
|
+
i,
|
|
4
|
+
i2
|
|
5
|
+
} from "./chunk-LGEZYFUU.js";
|
|
6
|
+
|
|
7
|
+
// src/web-components/interaction/form/bds-checkbox.ts
|
|
8
|
+
var BdsCheckbox = class extends i2 {
|
|
9
|
+
static formAssociated = true;
|
|
10
|
+
static styles = i`
|
|
11
|
+
:host {
|
|
12
|
+
display: inline-flex;
|
|
13
|
+
align-items: flex-start;
|
|
14
|
+
gap: var(--bds-space_xs);
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
font-size: var(--bds-font_size--body);
|
|
17
|
+
font-family: var(--bds-font_family--body);
|
|
18
|
+
color: var(--bds-color_on-bg);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
:host([disabled]) {
|
|
22
|
+
opacity: 0.5;
|
|
23
|
+
cursor: not-allowed;
|
|
24
|
+
pointer-events: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.input {
|
|
28
|
+
--inputSize: calc(var(--bds-space_s) * 2);
|
|
29
|
+
margin-block-start: 0.25em;
|
|
30
|
+
inline-size: var(--inputSize);
|
|
31
|
+
block-size: var(--inputSize);
|
|
32
|
+
flex-shrink: 0;
|
|
33
|
+
--bdc_color: currentcolor;
|
|
34
|
+
--bdc-outline_radius: var(--bds-border_radius--xs);
|
|
35
|
+
|
|
36
|
+
outline: var(--bdc-outline_width) solid var(--bdc_color);
|
|
37
|
+
outline-offset: var(--bdc-outline_offset);
|
|
38
|
+
border-radius: var(--checkbox_radius, var(--bdc-outline_radius));
|
|
39
|
+
box-shadow: var(--checkbox_shadow, var(--bdc-outline_shadow));
|
|
40
|
+
border: none;
|
|
41
|
+
appearance: none;
|
|
42
|
+
background-color: var(--checkbox_color_bg, var(--bds-color_bg));
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
position: relative;
|
|
45
|
+
transition: --bdc_color 0.3s ease, background-color 0.3s ease;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.input:checked {
|
|
49
|
+
background-color: var(--checkbox_color-active, var(--bdc-color_active));
|
|
50
|
+
--bdc_color: var(--checkbox_color-active, var(--bdc-color_active));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.input:checked::after {
|
|
54
|
+
content: '';
|
|
55
|
+
position: absolute;
|
|
56
|
+
inset-inline-start: 0.6em;
|
|
57
|
+
inset-block-start: 0.2em;
|
|
58
|
+
inline-size: 0.5em;
|
|
59
|
+
block-size: 1em;
|
|
60
|
+
border: solid var(--checkbox_color-on-active, var(--bdc-color_on-active));
|
|
61
|
+
border-width: 0 2px 2px 0;
|
|
62
|
+
transform: rotate(45deg);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.input:focus-visible {
|
|
66
|
+
outline: var(--bds-outline_default);
|
|
67
|
+
outline-offset: var(--bds-outline_offset);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
label {
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
flex: 1;
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
static properties = {
|
|
76
|
+
name: { type: String, reflect: true },
|
|
77
|
+
value: { type: String },
|
|
78
|
+
checked: { type: Boolean, reflect: true },
|
|
79
|
+
required: { type: Boolean, reflect: true },
|
|
80
|
+
disabled: { type: Boolean, reflect: true }
|
|
81
|
+
};
|
|
82
|
+
_internals;
|
|
83
|
+
_uid = Math.random().toString(36).slice(2, 8);
|
|
84
|
+
constructor() {
|
|
85
|
+
super();
|
|
86
|
+
this._internals = this.attachInternals();
|
|
87
|
+
this.name = "";
|
|
88
|
+
this.value = "on";
|
|
89
|
+
this.checked = false;
|
|
90
|
+
this.required = false;
|
|
91
|
+
this.disabled = false;
|
|
92
|
+
}
|
|
93
|
+
updated(changed) {
|
|
94
|
+
super.updated(changed);
|
|
95
|
+
if (changed.has("checked") || changed.has("value")) {
|
|
96
|
+
this._internals.setFormValue?.(this.checked ? this.value : null);
|
|
97
|
+
}
|
|
98
|
+
if (changed.has("required")) {
|
|
99
|
+
if (this.required && !this.checked) {
|
|
100
|
+
this._internals.setValidity?.({ valueMissing: true }, "Required");
|
|
101
|
+
} else {
|
|
102
|
+
this._internals.setValidity?.({});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
formResetCallback() {
|
|
107
|
+
this.checked = false;
|
|
108
|
+
this._internals.setFormValue?.(null);
|
|
109
|
+
}
|
|
110
|
+
_handleChange(e) {
|
|
111
|
+
this.checked = e.target.checked;
|
|
112
|
+
}
|
|
113
|
+
render() {
|
|
114
|
+
const id = `bds-checkbox-${this._uid}`;
|
|
115
|
+
return T`
|
|
116
|
+
<input
|
|
117
|
+
id=${id}
|
|
118
|
+
type="checkbox"
|
|
119
|
+
class="input"
|
|
120
|
+
.checked=${this.checked}
|
|
121
|
+
?required=${this.required}
|
|
122
|
+
?disabled=${this.disabled}
|
|
123
|
+
@change=${this._handleChange}
|
|
124
|
+
/>
|
|
125
|
+
<label for=${id}><slot></slot></label>
|
|
126
|
+
`;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
customElements.define("bds-checkbox", BdsCheckbox);
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
BdsCheckbox
|
|
133
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import {
|
|
2
|
+
T,
|
|
3
|
+
i,
|
|
4
|
+
i2
|
|
5
|
+
} from "./chunk-LGEZYFUU.js";
|
|
6
|
+
|
|
7
|
+
// src/web-components/interaction/bds-dialog.ts
|
|
8
|
+
var FOCUSABLE = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
9
|
+
var BdsDialog = class extends i2 {
|
|
10
|
+
static styles = i`
|
|
11
|
+
:host {
|
|
12
|
+
display: contents;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.dialog {
|
|
16
|
+
font-size: var(--bds-font_size--body--s);
|
|
17
|
+
border: var(--dialog_border, none);
|
|
18
|
+
--bdc_color: currentcolor;
|
|
19
|
+
--bdc-outline_radius: var(--bds-border_radius--m);
|
|
20
|
+
|
|
21
|
+
outline: var(--bdc-outline_width) solid var(--bdc_color);
|
|
22
|
+
outline-offset: var(--bdc-outline_offset);
|
|
23
|
+
border-radius: var(--dialog_radius, var(--bdc-outline_radius));
|
|
24
|
+
box-shadow: var(--dialog_shadow, var(--bdc-outline_shadow));
|
|
25
|
+
background-color: var(--dialog_color, var(--bds-color_grey--subtle));
|
|
26
|
+
color: var(--dialog_on-color, var(--bds-color_on-grey--subtle));
|
|
27
|
+
padding: var(--bds-space_l);
|
|
28
|
+
max-inline-size: 90svw;
|
|
29
|
+
max-block-size: 90svh;
|
|
30
|
+
overflow: visible;
|
|
31
|
+
position: relative;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.dialog-content {
|
|
35
|
+
display: grid;
|
|
36
|
+
gap: var(--bds-grid_gap);
|
|
37
|
+
overflow-block: auto;
|
|
38
|
+
min-block-size: 0;
|
|
39
|
+
flex: 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.close-button {
|
|
43
|
+
all: unset;
|
|
44
|
+
position: absolute;
|
|
45
|
+
inset-block-start: -1em;
|
|
46
|
+
inset-inline-end: -1em;
|
|
47
|
+
inline-size: 2em;
|
|
48
|
+
block-size: 2em;
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
border-radius: 50%;
|
|
53
|
+
background-color: var(--bds-color_bg);
|
|
54
|
+
color: currentcolor;
|
|
55
|
+
border: var(--dialog_close-border, none);
|
|
56
|
+
--bdc_color: currentcolor;
|
|
57
|
+
|
|
58
|
+
outline: var(--bdc-outline_width) solid var(--bdc_color);
|
|
59
|
+
outline-offset: var(--bdc-outline_offset);
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.close-button svg {
|
|
64
|
+
inline-size: 1.25em;
|
|
65
|
+
block-size: 1.25em;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.dialog::backdrop {
|
|
69
|
+
background-color: var(--color_backdrop, rgb(0 0 0 / 50%));
|
|
70
|
+
backdrop-filter: blur(3px);
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
static properties = {
|
|
74
|
+
open: { type: Boolean, reflect: true }
|
|
75
|
+
};
|
|
76
|
+
_triggerEl = null;
|
|
77
|
+
constructor() {
|
|
78
|
+
super();
|
|
79
|
+
this.open = false;
|
|
80
|
+
}
|
|
81
|
+
connectedCallback() {
|
|
82
|
+
super.connectedCallback();
|
|
83
|
+
this.addEventListener("command", this._onCommand);
|
|
84
|
+
}
|
|
85
|
+
disconnectedCallback() {
|
|
86
|
+
super.disconnectedCallback();
|
|
87
|
+
this.removeEventListener("command", this._onCommand);
|
|
88
|
+
}
|
|
89
|
+
updated(changed) {
|
|
90
|
+
super.updated(changed);
|
|
91
|
+
if (changed.has("open")) {
|
|
92
|
+
const dialog = this._dialog;
|
|
93
|
+
if (!dialog) return;
|
|
94
|
+
if (this.open && !dialog.open) {
|
|
95
|
+
this._triggerEl = document.activeElement;
|
|
96
|
+
dialog.showModal();
|
|
97
|
+
document.body.style.overflow = "hidden";
|
|
98
|
+
} else if (!this.open && dialog.open) {
|
|
99
|
+
dialog.close();
|
|
100
|
+
document.body.style.overflow = "";
|
|
101
|
+
this._triggerEl?.focus();
|
|
102
|
+
this._triggerEl = null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
get _dialog() {
|
|
107
|
+
return this.shadowRoot?.querySelector("dialog") ?? null;
|
|
108
|
+
}
|
|
109
|
+
_onCommand = (e) => {
|
|
110
|
+
const command = e.command;
|
|
111
|
+
if (command === "show-modal") this._openDialog();
|
|
112
|
+
else if (command === "close") this._closeDialog();
|
|
113
|
+
};
|
|
114
|
+
_openDialog() {
|
|
115
|
+
if (this.open) return;
|
|
116
|
+
this._triggerEl = document.activeElement;
|
|
117
|
+
this.open = true;
|
|
118
|
+
this.dispatchEvent(new CustomEvent("bds-open", { bubbles: true, composed: true }));
|
|
119
|
+
}
|
|
120
|
+
_closeDialog() {
|
|
121
|
+
if (!this.open) return;
|
|
122
|
+
this.open = false;
|
|
123
|
+
this.dispatchEvent(new CustomEvent("bds-close", { bubbles: true, composed: true }));
|
|
124
|
+
}
|
|
125
|
+
_handleBackdropClick(e) {
|
|
126
|
+
if (e.target === this._dialog) this._closeDialog();
|
|
127
|
+
}
|
|
128
|
+
_handleCancel(e) {
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
this._closeDialog();
|
|
131
|
+
}
|
|
132
|
+
_handleKeydown(e) {
|
|
133
|
+
if (e.key !== "Tab") return;
|
|
134
|
+
const dialog = this._dialog;
|
|
135
|
+
if (!dialog) return;
|
|
136
|
+
const focusable = Array.from(dialog.querySelectorAll(FOCUSABLE));
|
|
137
|
+
const slot = dialog.querySelector("slot");
|
|
138
|
+
const slottedFocusable = slot ? slot.assignedElements({ flatten: true }).flatMap((el) => [
|
|
139
|
+
...el.matches(FOCUSABLE) ? [el] : [],
|
|
140
|
+
...Array.from(el.querySelectorAll(FOCUSABLE))
|
|
141
|
+
]) : [];
|
|
142
|
+
const all = [...focusable, ...slottedFocusable];
|
|
143
|
+
if (all.length === 0) return;
|
|
144
|
+
const first = all[0];
|
|
145
|
+
const last = all[all.length - 1];
|
|
146
|
+
if (e.shiftKey) {
|
|
147
|
+
if (document.activeElement === first) {
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
last.focus();
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
if (document.activeElement === last) {
|
|
153
|
+
e.preventDefault();
|
|
154
|
+
first.focus();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
render() {
|
|
159
|
+
return T`
|
|
160
|
+
<dialog
|
|
161
|
+
class="dialog"
|
|
162
|
+
aria-modal="true"
|
|
163
|
+
@click=${this._handleBackdropClick}
|
|
164
|
+
@cancel=${this._handleCancel}
|
|
165
|
+
@keydown=${this._handleKeydown}
|
|
166
|
+
>
|
|
167
|
+
<button
|
|
168
|
+
type="button"
|
|
169
|
+
class="close-button"
|
|
170
|
+
aria-label="Close dialog"
|
|
171
|
+
@click=${this._closeDialog}
|
|
172
|
+
>
|
|
173
|
+
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
174
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M18 6L6 18M6 6l12 12" />
|
|
175
|
+
</svg>
|
|
176
|
+
</button>
|
|
177
|
+
<div class="dialog-content">
|
|
178
|
+
<slot></slot>
|
|
179
|
+
</div>
|
|
180
|
+
</dialog>
|
|
181
|
+
`;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
customElements.define("bds-dialog", BdsDialog);
|
|
185
|
+
|
|
186
|
+
export {
|
|
187
|
+
BdsDialog
|
|
188
|
+
};
|