@unofficialbox/box-open-elements 0.1.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/LICENSE +21 -0
- package/README.md +125 -0
- package/dist/components/actions/button-group.d.ts +22 -0
- package/dist/components/actions/button-group.js +255 -0
- package/dist/components/actions/button.d.ts +16 -0
- package/dist/components/actions/button.js +190 -0
- package/dist/components/actions/icon-button.d.ts +20 -0
- package/dist/components/actions/icon-button.js +187 -0
- package/dist/components/actions/link-button.d.ts +14 -0
- package/dist/components/actions/link-button.js +137 -0
- package/dist/components/actions/menu-item.d.ts +17 -0
- package/dist/components/actions/menu-item.js +137 -0
- package/dist/components/actions/menu.d.ts +22 -0
- package/dist/components/actions/menu.js +178 -0
- package/dist/components/actions/segmented-control.d.ts +27 -0
- package/dist/components/actions/segmented-control.js +273 -0
- package/dist/components/collections/card.d.ts +13 -0
- package/dist/components/collections/card.js +110 -0
- package/dist/components/collections/carousel.d.ts +40 -0
- package/dist/components/collections/carousel.js +406 -0
- package/dist/components/collections/datalist-item.d.ts +32 -0
- package/dist/components/collections/datalist-item.js +196 -0
- package/dist/components/collections/draggable-list.d.ts +33 -0
- package/dist/components/collections/draggable-list.js +306 -0
- package/dist/components/collections/grid-view.d.ts +38 -0
- package/dist/components/collections/grid-view.js +321 -0
- package/dist/components/collections/pagination.d.ts +19 -0
- package/dist/components/collections/pagination.js +147 -0
- package/dist/components/collections/tree-grid.d.ts +47 -0
- package/dist/components/collections/tree-grid.js +593 -0
- package/dist/components/collections/tree.d.ts +37 -0
- package/dist/components/collections/tree.js +526 -0
- package/dist/components/feedback/alert.d.ts +27 -0
- package/dist/components/feedback/alert.js +263 -0
- package/dist/components/feedback/badge.d.ts +12 -0
- package/dist/components/feedback/badge.js +99 -0
- package/dist/components/feedback/chip.d.ts +33 -0
- package/dist/components/feedback/chip.js +261 -0
- package/dist/components/feedback/empty-state.d.ts +19 -0
- package/dist/components/feedback/empty-state.js +137 -0
- package/dist/components/feedback/error-mask.d.ts +25 -0
- package/dist/components/feedback/error-mask.js +199 -0
- package/dist/components/feedback/help-text.d.ts +22 -0
- package/dist/components/feedback/help-text.js +176 -0
- package/dist/components/feedback/nudge.d.ts +32 -0
- package/dist/components/feedback/nudge.js +299 -0
- package/dist/components/feedback/progress-bar.d.ts +18 -0
- package/dist/components/feedback/progress-bar.js +128 -0
- package/dist/components/feedback/progress-ring.d.ts +21 -0
- package/dist/components/feedback/progress-ring.js +155 -0
- package/dist/components/feedback/progress-steps.d.ts +25 -0
- package/dist/components/feedback/progress-steps.js +276 -0
- package/dist/components/feedback/skeleton.d.ts +14 -0
- package/dist/components/feedback/skeleton.js +95 -0
- package/dist/components/feedback/spinner.d.ts +10 -0
- package/dist/components/feedback/spinner.js +80 -0
- package/dist/components/feedback/toast.d.ts +26 -0
- package/dist/components/feedback/toast.js +205 -0
- package/dist/components/files/drop-zone.d.ts +19 -0
- package/dist/components/files/drop-zone.js +169 -0
- package/dist/components/forms/calendar.d.ts +47 -0
- package/dist/components/forms/calendar.js +499 -0
- package/dist/components/forms/category-selector.d.ts +35 -0
- package/dist/components/forms/category-selector.js +269 -0
- package/dist/components/forms/checkbox-group.d.ts +31 -0
- package/dist/components/forms/checkbox-group.js +267 -0
- package/dist/components/forms/checkbox.d.ts +28 -0
- package/dist/components/forms/checkbox.js +250 -0
- package/dist/components/forms/color-picker.d.ts +34 -0
- package/dist/components/forms/color-picker.js +314 -0
- package/dist/components/forms/combobox.d.ts +37 -0
- package/dist/components/forms/combobox.js +234 -0
- package/dist/components/forms/date-field.d.ts +27 -0
- package/dist/components/forms/date-field.js +187 -0
- package/dist/components/forms/dropdown.d.ts +38 -0
- package/dist/components/forms/dropdown.js +405 -0
- package/dist/components/forms/dual-listbox.d.ts +44 -0
- package/dist/components/forms/dual-listbox.js +484 -0
- package/dist/components/forms/fieldset.d.ts +32 -0
- package/dist/components/forms/fieldset.js +168 -0
- package/dist/components/forms/multi-select.d.ts +30 -0
- package/dist/components/forms/multi-select.js +264 -0
- package/dist/components/forms/number-input.d.ts +32 -0
- package/dist/components/forms/number-input.js +245 -0
- package/dist/components/forms/pill-cloud.d.ts +35 -0
- package/dist/components/forms/pill-cloud.js +230 -0
- package/dist/components/forms/pill-selector-dropdown.d.ts +55 -0
- package/dist/components/forms/pill-selector-dropdown.js +499 -0
- package/dist/components/forms/radio-group.d.ts +32 -0
- package/dist/components/forms/radio-group.js +285 -0
- package/dist/components/forms/range-slider.d.ts +36 -0
- package/dist/components/forms/range-slider.js +294 -0
- package/dist/components/forms/rating.d.ts +31 -0
- package/dist/components/forms/rating.js +302 -0
- package/dist/components/forms/rich-text-input.d.ts +32 -0
- package/dist/components/forms/rich-text-input.js +403 -0
- package/dist/components/forms/search-field.d.ts +27 -0
- package/dist/components/forms/search-field.js +293 -0
- package/dist/components/forms/select.d.ts +30 -0
- package/dist/components/forms/select.js +198 -0
- package/dist/components/forms/slider.d.ts +31 -0
- package/dist/components/forms/slider.js +221 -0
- package/dist/components/forms/spin-button.d.ts +33 -0
- package/dist/components/forms/spin-button.js +352 -0
- package/dist/components/forms/switch.d.ts +32 -0
- package/dist/components/forms/switch.js +302 -0
- package/dist/components/forms/tag-input.d.ts +46 -0
- package/dist/components/forms/tag-input.js +420 -0
- package/dist/components/forms/text-area.d.ts +26 -0
- package/dist/components/forms/text-area.js +188 -0
- package/dist/components/forms/text-field.d.ts +24 -0
- package/dist/components/forms/text-field.js +151 -0
- package/dist/components/forms/time-field.d.ts +29 -0
- package/dist/components/forms/time-field.js +203 -0
- package/dist/components/identity/avatar.d.ts +21 -0
- package/dist/components/identity/avatar.js +191 -0
- package/dist/components/identity/contact-datalist-item.d.ts +31 -0
- package/dist/components/identity/contact-datalist-item.js +235 -0
- package/dist/components/identity/persona.d.ts +28 -0
- package/dist/components/identity/persona.js +272 -0
- package/dist/components/layout/app-shell.d.ts +26 -0
- package/dist/components/layout/app-shell.js +258 -0
- package/dist/components/layout/divider.d.ts +12 -0
- package/dist/components/layout/divider.js +119 -0
- package/dist/components/layout/nav-sidebar.d.ts +23 -0
- package/dist/components/layout/nav-sidebar.js +167 -0
- package/dist/components/layout/section.d.ts +20 -0
- package/dist/components/layout/section.js +143 -0
- package/dist/components/layout/sidebar-toggle-button.d.ts +26 -0
- package/dist/components/layout/sidebar-toggle-button.js +137 -0
- package/dist/components/layout/split-view.d.ts +19 -0
- package/dist/components/layout/split-view.js +157 -0
- package/dist/components/navigation/accordion.d.ts +25 -0
- package/dist/components/navigation/accordion.js +253 -0
- package/dist/components/navigation/tabs.d.ts +27 -0
- package/dist/components/navigation/tabs.js +289 -0
- package/dist/components/overlays/dialog.d.ts +26 -0
- package/dist/components/overlays/dialog.js +267 -0
- package/dist/components/overlays/drawer.d.ts +32 -0
- package/dist/components/overlays/drawer.js +323 -0
- package/dist/components/overlays/popover.d.ts +35 -0
- package/dist/components/overlays/popover.js +317 -0
- package/dist/components/overlays/tooltip.d.ts +26 -0
- package/dist/components/overlays/tooltip.js +204 -0
- package/dist/components/visuals/illustration.d.ts +26 -0
- package/dist/components/visuals/illustration.js +319 -0
- package/dist/core/controller.d.ts +11 -0
- package/dist/core/controller.js +23 -0
- package/dist/core/element.d.ts +22 -0
- package/dist/core/element.js +28 -0
- package/dist/core/event-emitter.d.ts +9 -0
- package/dist/core/event-emitter.js +33 -0
- package/dist/core/form-associated.d.ts +63 -0
- package/dist/core/form-associated.js +218 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.js +4 -0
- package/dist/core/json-schema.d.ts +1 -0
- package/dist/core/json-schema.js +1 -0
- package/dist/foundations/a11y/focus.d.ts +17 -0
- package/dist/foundations/a11y/focus.js +94 -0
- package/dist/foundations/a11y/heading.d.ts +26 -0
- package/dist/foundations/a11y/heading.js +40 -0
- package/dist/foundations/a11y/index.d.ts +5 -0
- package/dist/foundations/a11y/index.js +3 -0
- package/dist/foundations/a11y/keyboard.d.ts +28 -0
- package/dist/foundations/a11y/keyboard.js +77 -0
- package/dist/foundations/geometry/index.d.ts +1 -0
- package/dist/foundations/geometry/index.js +1 -0
- package/dist/foundations/geometry/tokens.d.ts +123 -0
- package/dist/foundations/geometry/tokens.js +154 -0
- package/dist/foundations/icons/box-iconography.d.ts +479 -0
- package/dist/foundations/icons/box-iconography.generated.d.ts +2370 -0
- package/dist/foundations/icons/box-iconography.generated.js +4010 -0
- package/dist/foundations/icons/box-iconography.js +39 -0
- package/dist/foundations/icons/index.d.ts +1 -0
- package/dist/foundations/icons/index.js +1 -0
- package/dist/foundations/motion/index.d.ts +2 -0
- package/dist/foundations/motion/index.js +1 -0
- package/dist/foundations/motion/tokens.d.ts +39 -0
- package/dist/foundations/motion/tokens.js +43 -0
- package/dist/foundations/tokens/box-dark.d.ts +11 -0
- package/dist/foundations/tokens/box-dark.js +46 -0
- package/dist/foundations/tokens/box-defaults.d.ts +5 -0
- package/dist/foundations/tokens/box-defaults.js +52 -0
- package/dist/foundations/tokens/index.d.ts +5 -0
- package/dist/foundations/tokens/index.js +4 -0
- package/dist/foundations/tokens/interaction.d.ts +28 -0
- package/dist/foundations/tokens/interaction.js +72 -0
- package/dist/foundations/tokens/registry.d.ts +14 -0
- package/dist/foundations/tokens/registry.js +92 -0
- package/dist/foundations/tokens/types.d.ts +16 -0
- package/dist/foundations/tokens/types.js +1 -0
- package/dist/foundations/typography/index.d.ts +2 -0
- package/dist/foundations/typography/index.js +1 -0
- package/dist/foundations/typography/tokens.d.ts +76 -0
- package/dist/foundations/typography/tokens.js +27 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.js +98 -0
- package/dist/patterns/content-explorer/actions/controller.d.ts +12 -0
- package/dist/patterns/content-explorer/actions/controller.js +36 -0
- package/dist/patterns/content-explorer/actions/index.d.ts +2 -0
- package/dist/patterns/content-explorer/actions/index.js +1 -0
- package/dist/patterns/content-explorer/actions/types.d.ts +13 -0
- package/dist/patterns/content-explorer/actions/types.js +1 -0
- package/dist/patterns/content-explorer/adapters/action-menu.d.ts +24 -0
- package/dist/patterns/content-explorer/adapters/action-menu.js +312 -0
- package/dist/patterns/content-explorer/adapters/breadcrumbs.d.ts +15 -0
- package/dist/patterns/content-explorer/adapters/breadcrumbs.js +161 -0
- package/dist/patterns/content-explorer/adapters/item-summary.d.ts +11 -0
- package/dist/patterns/content-explorer/adapters/item-summary.js +72 -0
- package/dist/patterns/content-explorer/adapters/items.d.ts +4 -0
- package/dist/patterns/content-explorer/adapters/items.js +12 -0
- package/dist/patterns/content-explorer/adapters/list.d.ts +28 -0
- package/dist/patterns/content-explorer/adapters/list.js +527 -0
- package/dist/patterns/content-explorer/adapters/table.d.ts +23 -0
- package/dist/patterns/content-explorer/adapters/table.js +467 -0
- package/dist/patterns/content-explorer/adapters/toolbar.d.ts +19 -0
- package/dist/patterns/content-explorer/adapters/toolbar.js +234 -0
- package/dist/patterns/content-explorer/box-transport.d.ts +44 -0
- package/dist/patterns/content-explorer/box-transport.js +229 -0
- package/dist/patterns/content-explorer/collection/controller.d.ts +17 -0
- package/dist/patterns/content-explorer/collection/controller.js +67 -0
- package/dist/patterns/content-explorer/collection/index.d.ts +2 -0
- package/dist/patterns/content-explorer/collection/index.js +1 -0
- package/dist/patterns/content-explorer/collection/types.d.ts +20 -0
- package/dist/patterns/content-explorer/collection/types.js +1 -0
- package/dist/patterns/content-explorer/content-explorer.d.ts +85 -0
- package/dist/patterns/content-explorer/content-explorer.js +745 -0
- package/dist/patterns/content-explorer/contracts.d.ts +32 -0
- package/dist/patterns/content-explorer/contracts.js +114 -0
- package/dist/patterns/content-explorer/controller.d.ts +34 -0
- package/dist/patterns/content-explorer/controller.js +399 -0
- package/dist/patterns/content-explorer/host-bindings.d.ts +50 -0
- package/dist/patterns/content-explorer/host-bindings.js +76 -0
- package/dist/patterns/content-explorer/index.d.ts +18 -0
- package/dist/patterns/content-explorer/index.js +24 -0
- package/dist/patterns/content-explorer/navigation/controller.d.ts +10 -0
- package/dist/patterns/content-explorer/navigation/controller.js +48 -0
- package/dist/patterns/content-explorer/navigation/index.d.ts +2 -0
- package/dist/patterns/content-explorer/navigation/index.js +1 -0
- package/dist/patterns/content-explorer/navigation/types.d.ts +20 -0
- package/dist/patterns/content-explorer/navigation/types.js +1 -0
- package/dist/patterns/content-explorer/schemas.d.ts +6 -0
- package/dist/patterns/content-explorer/schemas.js +120 -0
- package/dist/patterns/content-explorer/selection/controller.d.ts +12 -0
- package/dist/patterns/content-explorer/selection/controller.js +54 -0
- package/dist/patterns/content-explorer/selection/index.d.ts +2 -0
- package/dist/patterns/content-explorer/selection/index.js +1 -0
- package/dist/patterns/content-explorer/selection/types.d.ts +14 -0
- package/dist/patterns/content-explorer/selection/types.js +1 -0
- package/dist/patterns/content-explorer/types.d.ts +209 -0
- package/dist/patterns/content-explorer/types.js +10 -0
- package/dist/patterns/file-request/file-request-builder.d.ts +36 -0
- package/dist/patterns/file-request/file-request-builder.js +344 -0
- package/dist/patterns/file-request/index.d.ts +1 -0
- package/dist/patterns/file-request/index.js +1 -0
- package/dist/patterns/governance/governance-panel.d.ts +40 -0
- package/dist/patterns/governance/governance-panel.js +351 -0
- package/dist/patterns/governance/index.d.ts +1 -0
- package/dist/patterns/governance/index.js +1 -0
- package/dist/patterns/insights/bar-chart.d.ts +43 -0
- package/dist/patterns/insights/bar-chart.js +462 -0
- package/dist/patterns/insights/chart-panel.d.ts +43 -0
- package/dist/patterns/insights/chart-panel.js +436 -0
- package/dist/patterns/insights/donut-chart.d.ts +43 -0
- package/dist/patterns/insights/donut-chart.js +535 -0
- package/dist/patterns/insights/index.d.ts +5 -0
- package/dist/patterns/insights/index.js +5 -0
- package/dist/patterns/insights/line-chart.d.ts +46 -0
- package/dist/patterns/insights/line-chart.js +511 -0
- package/dist/patterns/insights/metric-card.d.ts +36 -0
- package/dist/patterns/insights/metric-card.js +278 -0
- package/dist/patterns/item/bulk-action-bar.d.ts +35 -0
- package/dist/patterns/item/bulk-action-bar.js +325 -0
- package/dist/patterns/item/index.d.ts +4 -0
- package/dist/patterns/item/index.js +4 -0
- package/dist/patterns/item/item-details-panel.d.ts +61 -0
- package/dist/patterns/item/item-details-panel.js +429 -0
- package/dist/patterns/item/item-form.d.ts +54 -0
- package/dist/patterns/item/item-form.js +485 -0
- package/dist/patterns/item/preview-header.d.ts +46 -0
- package/dist/patterns/item/preview-header.js +323 -0
- package/dist/patterns/metadata/contracts.d.ts +75 -0
- package/dist/patterns/metadata/contracts.js +91 -0
- package/dist/patterns/metadata/index.d.ts +4 -0
- package/dist/patterns/metadata/index.js +4 -0
- package/dist/patterns/metadata/metadata-filter-builder.d.ts +43 -0
- package/dist/patterns/metadata/metadata-filter-builder.js +362 -0
- package/dist/patterns/metadata/metadata-inspector.d.ts +31 -0
- package/dist/patterns/metadata/metadata-inspector.js +245 -0
- package/dist/patterns/metadata/schemas.d.ts +5 -0
- package/dist/patterns/metadata/schemas.js +66 -0
- package/dist/patterns/preview/annotation-inspector.d.ts +44 -0
- package/dist/patterns/preview/annotation-inspector.js +380 -0
- package/dist/patterns/preview/annotation-thread.d.ts +37 -0
- package/dist/patterns/preview/annotation-thread.js +338 -0
- package/dist/patterns/preview/annotation-toolbar.d.ts +42 -0
- package/dist/patterns/preview/annotation-toolbar.js +393 -0
- package/dist/patterns/preview/content-preview-adapter.d.ts +13 -0
- package/dist/patterns/preview/content-preview-adapter.js +30 -0
- package/dist/patterns/preview/index.d.ts +6 -0
- package/dist/patterns/preview/index.js +6 -0
- package/dist/patterns/preview/preview-element.d.ts +41 -0
- package/dist/patterns/preview/preview-element.js +429 -0
- package/dist/patterns/preview/provider-adapter.d.ts +36 -0
- package/dist/patterns/preview/provider-adapter.js +29 -0
- package/dist/patterns/search/filter-bar.d.ts +50 -0
- package/dist/patterns/search/filter-bar.js +379 -0
- package/dist/patterns/search/index.d.ts +3 -0
- package/dist/patterns/search/index.js +3 -0
- package/dist/patterns/search/saved-view-picker.d.ts +25 -0
- package/dist/patterns/search/saved-view-picker.js +239 -0
- package/dist/patterns/search/search-results-header.d.ts +34 -0
- package/dist/patterns/search/search-results-header.js +288 -0
- package/dist/patterns/share/access-stats.d.ts +19 -0
- package/dist/patterns/share/access-stats.js +204 -0
- package/dist/patterns/share/collaborator-avatars.d.ts +22 -0
- package/dist/patterns/share/collaborator-avatars.js +214 -0
- package/dist/patterns/share/contracts.d.ts +65 -0
- package/dist/patterns/share/contracts.js +75 -0
- package/dist/patterns/share/index.d.ts +14 -0
- package/dist/patterns/share/index.js +14 -0
- package/dist/patterns/share/invite-collaborators-contracts.d.ts +38 -0
- package/dist/patterns/share/invite-collaborators-contracts.js +1 -0
- package/dist/patterns/share/invite-collaborators-controller.d.ts +40 -0
- package/dist/patterns/share/invite-collaborators-controller.js +86 -0
- package/dist/patterns/share/invite-collaborators-modal.d.ts +46 -0
- package/dist/patterns/share/invite-collaborators-modal.js +465 -0
- package/dist/patterns/share/permission-matrix.d.ts +37 -0
- package/dist/patterns/share/permission-matrix.js +360 -0
- package/dist/patterns/share/presence-contracts.d.ts +26 -0
- package/dist/patterns/share/presence-contracts.js +1 -0
- package/dist/patterns/share/presence-controller.d.ts +31 -0
- package/dist/patterns/share/presence-controller.js +47 -0
- package/dist/patterns/share/presence.d.ts +32 -0
- package/dist/patterns/share/presence.js +255 -0
- package/dist/patterns/share/schemas.d.ts +4 -0
- package/dist/patterns/share/schemas.js +41 -0
- package/dist/patterns/share/share-panel.d.ts +75 -0
- package/dist/patterns/share/share-panel.js +565 -0
- package/dist/patterns/share/unified-share-controller.d.ts +52 -0
- package/dist/patterns/share/unified-share-controller.js +97 -0
- package/dist/patterns/share/unified-share-modal.d.ts +50 -0
- package/dist/patterns/share/unified-share-modal.js +646 -0
- package/dist/patterns/task/index.d.ts +2 -0
- package/dist/patterns/task/index.js +2 -0
- package/dist/patterns/task/review-queue-item.d.ts +45 -0
- package/dist/patterns/task/review-queue-item.js +403 -0
- package/dist/patterns/task/task-assignment-panel.d.ts +50 -0
- package/dist/patterns/task/task-assignment-panel.js +450 -0
- package/package.json +151 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { FormAssociatedElement, boeFormFieldErrorStyles, formDataFromNamedValues, formErrorMessageMarkup, stringValuesFromFormValue, } from "../../core/index.js";
|
|
2
|
+
import { boeMotionDuration, boeMotionEasing } from "../../foundations/motion/index.js";
|
|
3
|
+
const DEFAULT_TAG_NAME = "box-pill-cloud";
|
|
4
|
+
const escapeHtml = (value) => value
|
|
5
|
+
.replaceAll("&", "&")
|
|
6
|
+
.replaceAll("<", "<")
|
|
7
|
+
.replaceAll(">", ">")
|
|
8
|
+
.replaceAll('"', """)
|
|
9
|
+
.replaceAll("'", "'");
|
|
10
|
+
const pillCloudStyles = `
|
|
11
|
+
:host {
|
|
12
|
+
display: block;
|
|
13
|
+
color: inherit;
|
|
14
|
+
font: inherit;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[part="cloud"] {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-wrap: wrap;
|
|
20
|
+
gap: 0.4rem;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[part~="pill"] {
|
|
24
|
+
appearance: none;
|
|
25
|
+
padding: 0.35rem 0.75rem;
|
|
26
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 82%, transparent);
|
|
27
|
+
border-radius: 999px;
|
|
28
|
+
background: var(--boe-token-surface-surface, #ffffff);
|
|
29
|
+
color: var(--boe-token-text-text, #222222);
|
|
30
|
+
font: inherit;
|
|
31
|
+
font-size: 0.82rem;
|
|
32
|
+
font-weight: 600;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
transition: border-color ${boeMotionDuration.interactive} ${boeMotionEasing.standard}, background ${boeMotionDuration.interactive} ${boeMotionEasing.standard}, color ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
[part~="pill"]:hover:not(:disabled) {
|
|
38
|
+
border-color: var(--boe-token-stroke-stroke-hover, #bcbcbc);
|
|
39
|
+
background: var(--boe-token-surface-surface-hover, #f4f4f4);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
[part~="pill-selected"] {
|
|
43
|
+
border-color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
44
|
+
background: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 12%, var(--boe-token-surface-surface, #ffffff) 88%);
|
|
45
|
+
color: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 74%, var(--boe-token-text-text, #222222));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[part~="pill"]:focus-visible {
|
|
49
|
+
outline: none;
|
|
50
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 22%, transparent);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[part~="pill"]:disabled {
|
|
54
|
+
opacity: 0.55;
|
|
55
|
+
cursor: not-allowed;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
[part="empty"] {
|
|
59
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
60
|
+
font-size: 0.86rem;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
${boeFormFieldErrorStyles}
|
|
64
|
+
`;
|
|
65
|
+
/**
|
|
66
|
+
* A cloud of toggle pills for multi-select filtering — think facet chips. Data
|
|
67
|
+
* arrives via `options`; the selected set is exposed as `value` (a string[]) and
|
|
68
|
+
* announced with `value-changed`. Each pill is a toggle button with
|
|
69
|
+
* `aria-pressed`; the group is a labelled `role="group"`.
|
|
70
|
+
*/
|
|
71
|
+
export class BoxPillCloudElement extends FormAssociatedElement {
|
|
72
|
+
static get observedAttributes() {
|
|
73
|
+
return [
|
|
74
|
+
...FormAssociatedElement.formObservedAttributes,
|
|
75
|
+
"label",
|
|
76
|
+
"options",
|
|
77
|
+
"value",
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
valueInternal = [];
|
|
81
|
+
lastOptionsJson = "";
|
|
82
|
+
rootEl;
|
|
83
|
+
errorEl;
|
|
84
|
+
get label() {
|
|
85
|
+
return this.getAttribute("label") ?? "Filters";
|
|
86
|
+
}
|
|
87
|
+
set label(value) {
|
|
88
|
+
this.setAttribute("label", value);
|
|
89
|
+
}
|
|
90
|
+
get options() {
|
|
91
|
+
const raw = this.getAttribute("options");
|
|
92
|
+
if (!raw) {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const parsed = JSON.parse(raw);
|
|
97
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
set options(value) {
|
|
104
|
+
this.setAttribute("options", JSON.stringify(value));
|
|
105
|
+
}
|
|
106
|
+
get value() {
|
|
107
|
+
return [...this.valueInternal];
|
|
108
|
+
}
|
|
109
|
+
set value(nextValue) {
|
|
110
|
+
this.valueInternal = [...nextValue];
|
|
111
|
+
this.setAttribute("value", JSON.stringify(nextValue));
|
|
112
|
+
this.syncFormAssociation();
|
|
113
|
+
if (this.isRendered) {
|
|
114
|
+
this.update();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
118
|
+
if (name === "value") {
|
|
119
|
+
const raw = this.getAttribute("value");
|
|
120
|
+
if (!raw) {
|
|
121
|
+
this.valueInternal = [];
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
try {
|
|
125
|
+
const parsed = JSON.parse(raw);
|
|
126
|
+
this.valueInternal = Array.isArray(parsed) ? parsed : [];
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
this.valueInternal = [];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
134
|
+
}
|
|
135
|
+
getFormValue() {
|
|
136
|
+
return formDataFromNamedValues(this.name, this.valueInternal);
|
|
137
|
+
}
|
|
138
|
+
restoreFormValue(value) {
|
|
139
|
+
const next = stringValuesFromFormValue(value, this.name);
|
|
140
|
+
this.valueInternal = next;
|
|
141
|
+
this.setAttribute("value", JSON.stringify(next));
|
|
142
|
+
this.syncFormAssociation();
|
|
143
|
+
if (this.isRendered) {
|
|
144
|
+
this.update();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
toggle(value) {
|
|
148
|
+
const next = this.valueInternal.includes(value)
|
|
149
|
+
? this.valueInternal.filter(item => item !== value)
|
|
150
|
+
: [...this.valueInternal, value];
|
|
151
|
+
this.valueInternal = next;
|
|
152
|
+
this.setAttribute("value", JSON.stringify(next));
|
|
153
|
+
if (this.isRendered) {
|
|
154
|
+
this.update();
|
|
155
|
+
}
|
|
156
|
+
this.syncFormAssociation();
|
|
157
|
+
this.dispatchEvent(new CustomEvent("value-changed", {
|
|
158
|
+
bubbles: true,
|
|
159
|
+
composed: true,
|
|
160
|
+
detail: { value: [...next] },
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
renderTemplate() {
|
|
164
|
+
if (!this.shadowRoot) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
this.shadowRoot.innerHTML = `
|
|
168
|
+
<style>${pillCloudStyles}</style>
|
|
169
|
+
<div part="root"></div>
|
|
170
|
+
${formErrorMessageMarkup()}
|
|
171
|
+
`;
|
|
172
|
+
this.rootEl = this.shadowRoot.querySelector('[part="root"]');
|
|
173
|
+
this.errorEl = this.shadowRoot.querySelector('[part="error-message"]');
|
|
174
|
+
}
|
|
175
|
+
setupListeners() {
|
|
176
|
+
this.rootEl.addEventListener("click", event => {
|
|
177
|
+
const pill = event.target.closest('[part~="pill"]');
|
|
178
|
+
if (!pill || !this.rootEl.contains(pill)) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
this.toggle(pill.dataset.value ?? "");
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
update() {
|
|
185
|
+
if (!this.rootEl || !this.errorEl) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (!this.options.length) {
|
|
189
|
+
this.rootEl.innerHTML = `<div part="empty">No options</div>`;
|
|
190
|
+
this.lastOptionsJson = "";
|
|
191
|
+
this.applyInvalidStateToControls([], this.errorEl);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const optionsJson = JSON.stringify(this.options);
|
|
195
|
+
if (optionsJson !== this.lastOptionsJson || !this.rootEl.querySelector('[part="cloud"]')) {
|
|
196
|
+
this.rootEl.innerHTML = `
|
|
197
|
+
<div part="cloud" role="group" aria-label="${escapeHtml(this.label)}">
|
|
198
|
+
${this.options
|
|
199
|
+
.map(option => `
|
|
200
|
+
<button
|
|
201
|
+
type="button"
|
|
202
|
+
part="pill"
|
|
203
|
+
data-value="${escapeHtml(option.value)}"
|
|
204
|
+
${option.disabled ? "disabled" : ""}
|
|
205
|
+
>${escapeHtml(option.label)}</button>
|
|
206
|
+
`)
|
|
207
|
+
.join("")}
|
|
208
|
+
</div>
|
|
209
|
+
`;
|
|
210
|
+
this.lastOptionsJson = optionsJson;
|
|
211
|
+
}
|
|
212
|
+
const cloud = this.rootEl.querySelector('[part="cloud"]');
|
|
213
|
+
cloud?.setAttribute("aria-label", this.label);
|
|
214
|
+
this.rootEl.querySelectorAll('[part~="pill"]').forEach(node => {
|
|
215
|
+
const button = node;
|
|
216
|
+
const isSelected = this.valueInternal.includes(button.dataset.value ?? "");
|
|
217
|
+
button.setAttribute("part", isSelected ? "pill pill-selected" : "pill");
|
|
218
|
+
button.setAttribute("aria-pressed", String(isSelected));
|
|
219
|
+
});
|
|
220
|
+
this.applyInvalidStateToControls(Array.from(this.rootEl.querySelectorAll('[part~="pill"]')), this.errorEl);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
export const defineBoxPillCloudElement = (tagName = DEFAULT_TAG_NAME) => {
|
|
224
|
+
const existingElement = customElements.get(tagName);
|
|
225
|
+
if (existingElement) {
|
|
226
|
+
return existingElement;
|
|
227
|
+
}
|
|
228
|
+
customElements.define(tagName, BoxPillCloudElement);
|
|
229
|
+
return BoxPillCloudElement;
|
|
230
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { FormAssociatedElement } from "../../core/index.js";
|
|
2
|
+
import type { FormValue } from "../../core/index.js";
|
|
3
|
+
type PillOption = {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A multi-select pill field: the current selection shows as removable pills, and
|
|
9
|
+
* an "Add" dropdown offers the remaining options. Data arrives via `options`;
|
|
10
|
+
* the selection is exposed as `value` (a string[]) and every add/remove emits
|
|
11
|
+
* `value-changed`. The popup is a `role="menu"` of `role="menuitem"` buttons —
|
|
12
|
+
* opening focuses the first item; ArrowUp/Down/Home/End move focus, Escape (or
|
|
13
|
+
* moving focus outside) closes and returns focus to the trigger.
|
|
14
|
+
*/
|
|
15
|
+
export declare class BoxPillSelectorDropdownElement extends FormAssociatedElement {
|
|
16
|
+
static get observedAttributes(): string[];
|
|
17
|
+
private valueInternal;
|
|
18
|
+
private open;
|
|
19
|
+
private menuFocusValue;
|
|
20
|
+
private pendingFocus;
|
|
21
|
+
private fieldEl;
|
|
22
|
+
private pillsEl;
|
|
23
|
+
private dropdownEl;
|
|
24
|
+
private triggerEl;
|
|
25
|
+
private menuEl;
|
|
26
|
+
private errorEl;
|
|
27
|
+
private readonly onOutsidePointer;
|
|
28
|
+
get label(): string;
|
|
29
|
+
set label(value: string);
|
|
30
|
+
get placeholder(): string;
|
|
31
|
+
set placeholder(value: string);
|
|
32
|
+
get options(): PillOption[];
|
|
33
|
+
set options(value: PillOption[]);
|
|
34
|
+
get value(): string[];
|
|
35
|
+
set value(nextValue: string[]);
|
|
36
|
+
disconnectedCallback(): void;
|
|
37
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
38
|
+
protected getFormValue(): FormValue;
|
|
39
|
+
protected restoreFormValue(value: FormValue): void;
|
|
40
|
+
private availableOptions;
|
|
41
|
+
private labelFor;
|
|
42
|
+
private commit;
|
|
43
|
+
private addValue;
|
|
44
|
+
private removeValue;
|
|
45
|
+
private openMenu;
|
|
46
|
+
private closeMenu;
|
|
47
|
+
private moveMenuFocus;
|
|
48
|
+
private moveMenuFocusTo;
|
|
49
|
+
private applyPendingFocus;
|
|
50
|
+
protected renderTemplate(): void;
|
|
51
|
+
protected setupListeners(): void;
|
|
52
|
+
protected update(): void;
|
|
53
|
+
}
|
|
54
|
+
export declare const defineBoxPillSelectorDropdownElement: (tagName?: string) => typeof BoxPillSelectorDropdownElement;
|
|
55
|
+
export {};
|