@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,30 @@
|
|
|
1
|
+
import { FormAssociatedElement } from "../../core/index.js";
|
|
2
|
+
import type { FormValue } from "../../core/index.js";
|
|
3
|
+
type MultiSelectOption = {
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class BoxMultiSelectElement extends FormAssociatedElement {
|
|
9
|
+
static get observedAttributes(): string[];
|
|
10
|
+
private valueInternal;
|
|
11
|
+
private lastOptionsJson;
|
|
12
|
+
private legendEl;
|
|
13
|
+
private summaryEl;
|
|
14
|
+
private optionsContainerEl;
|
|
15
|
+
private errorEl;
|
|
16
|
+
get label(): string;
|
|
17
|
+
set label(value: string);
|
|
18
|
+
get options(): MultiSelectOption[];
|
|
19
|
+
set options(value: MultiSelectOption[]);
|
|
20
|
+
get value(): string[];
|
|
21
|
+
set value(nextValue: string[]);
|
|
22
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
23
|
+
protected getFormValue(): FormValue;
|
|
24
|
+
protected restoreFormValue(value: FormValue): void;
|
|
25
|
+
protected renderTemplate(): void;
|
|
26
|
+
protected setupListeners(): void;
|
|
27
|
+
protected update(): void;
|
|
28
|
+
}
|
|
29
|
+
export declare const defineBoxMultiSelectElement: (tagName?: string) => typeof BoxMultiSelectElement;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { FormAssociatedElement, boeFormFieldErrorStyles, formDataFromNamedValues, formErrorMessageMarkup, stringValuesFromFormValue, } from "../../core/index.js";
|
|
2
|
+
import { boeFocusRingShadow, boeFocusVisibleStyles, } from "../../foundations/tokens/index.js";
|
|
3
|
+
import { boeMotionDuration, boeMotionEasing } from "../../foundations/motion/index.js";
|
|
4
|
+
import { boeRadius } from "../../foundations/geometry/index.js";
|
|
5
|
+
const DEFAULT_TAG_NAME = "box-multi-select";
|
|
6
|
+
const escapeHtml = (value) => value
|
|
7
|
+
.replaceAll("&", "&")
|
|
8
|
+
.replaceAll("<", "<")
|
|
9
|
+
.replaceAll(">", ">")
|
|
10
|
+
.replaceAll('"', """)
|
|
11
|
+
.replaceAll("'", "'");
|
|
12
|
+
const multiSelectStyles = `
|
|
13
|
+
:host {
|
|
14
|
+
display: block;
|
|
15
|
+
color: inherit;
|
|
16
|
+
font: inherit;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
[part="field"] {
|
|
20
|
+
margin: 0;
|
|
21
|
+
padding: 0;
|
|
22
|
+
border: none;
|
|
23
|
+
min-inline-size: 0;
|
|
24
|
+
display: grid;
|
|
25
|
+
gap: 0.45rem;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
[part="label"] {
|
|
29
|
+
margin: 0 0 0.2rem;
|
|
30
|
+
padding: 0;
|
|
31
|
+
font-size: 0.8rem;
|
|
32
|
+
font-weight: 700;
|
|
33
|
+
letter-spacing: 0.08em;
|
|
34
|
+
text-transform: uppercase;
|
|
35
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[part="summary"] {
|
|
39
|
+
justify-self: start;
|
|
40
|
+
display: inline-flex;
|
|
41
|
+
padding: 0.35rem 0.6rem;
|
|
42
|
+
border-radius: 999px;
|
|
43
|
+
background: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 12%, var(--boe-token-surface-surface, #ffffff) 88%);
|
|
44
|
+
color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
45
|
+
font-size: 0.8rem;
|
|
46
|
+
font-weight: 700;
|
|
47
|
+
letter-spacing: 0.05em;
|
|
48
|
+
text-transform: uppercase;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[part="options"] {
|
|
52
|
+
display: grid;
|
|
53
|
+
gap: 0.15rem;
|
|
54
|
+
padding: 0.35rem;
|
|
55
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 78%, var(--boe-token-surface-surface, #ffffff) 22%);
|
|
56
|
+
border-radius: ${boeRadius.xlarge};
|
|
57
|
+
background: var(--boe-token-surface-surface, #ffffff);
|
|
58
|
+
box-shadow: 0 12px 30px color-mix(in srgb, #0b1e33 14%, transparent);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[part="option"] {
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
gap: 0.45rem;
|
|
65
|
+
padding: 0.55rem 0.7rem;
|
|
66
|
+
border-radius: ${boeRadius.med};
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
color: var(--boe-token-text-text, #222222);
|
|
69
|
+
transition:
|
|
70
|
+
background ${boeMotionDuration.interactive} ${boeMotionEasing.standard},
|
|
71
|
+
color ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
[part="option"]:hover:not(:has([part="input"]:disabled)) {
|
|
75
|
+
background: var(--boe-token-surface-surface-hover, #f4f4f4);
|
|
76
|
+
border-color: var(--boe-token-stroke-stroke-hover, #bcbcbc);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
[part="option"]:active:not(:has([part="input"]:disabled)) {
|
|
80
|
+
background: color-mix(in srgb, var(--boe-token-surface-surface-hover, #f4f4f4) 70%, var(--boe-token-surface-surface-secondary, #fbfbfb) 30%);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
[part="option"]:has([part="input"]:checked) {
|
|
84
|
+
background: var(--boe-token-surface-item-surface-selected, #f2f7fd);
|
|
85
|
+
color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
[part="option"]:focus-within {
|
|
89
|
+
outline: none;
|
|
90
|
+
box-shadow: ${boeFocusRingShadow};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[part="option"]:has([part="input"]:disabled) {
|
|
94
|
+
opacity: 0.55;
|
|
95
|
+
cursor: not-allowed;
|
|
96
|
+
box-shadow: none;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
[part="input"] {
|
|
100
|
+
inline-size: 1rem;
|
|
101
|
+
block-size: 1rem;
|
|
102
|
+
accent-color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
103
|
+
margin: 0;
|
|
104
|
+
flex: 0 0 auto;
|
|
105
|
+
cursor: inherit;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
${boeFocusVisibleStyles('[part="input"]')}
|
|
109
|
+
|
|
110
|
+
[part="option-label"] {
|
|
111
|
+
font-weight: 500;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
${boeFormFieldErrorStyles}
|
|
115
|
+
`;
|
|
116
|
+
export class BoxMultiSelectElement extends FormAssociatedElement {
|
|
117
|
+
static get observedAttributes() {
|
|
118
|
+
return [
|
|
119
|
+
...FormAssociatedElement.formObservedAttributes,
|
|
120
|
+
"label",
|
|
121
|
+
"options",
|
|
122
|
+
"value",
|
|
123
|
+
];
|
|
124
|
+
}
|
|
125
|
+
valueInternal = [];
|
|
126
|
+
lastOptionsJson = "";
|
|
127
|
+
legendEl;
|
|
128
|
+
summaryEl;
|
|
129
|
+
optionsContainerEl;
|
|
130
|
+
errorEl;
|
|
131
|
+
get label() {
|
|
132
|
+
return this.getAttribute("label") ?? "Multi Select";
|
|
133
|
+
}
|
|
134
|
+
set label(value) {
|
|
135
|
+
this.setAttribute("label", value);
|
|
136
|
+
}
|
|
137
|
+
get options() {
|
|
138
|
+
const raw = this.getAttribute("options");
|
|
139
|
+
if (!raw) {
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
const parsed = JSON.parse(raw);
|
|
144
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return [];
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
set options(value) {
|
|
151
|
+
this.setAttribute("options", JSON.stringify(value));
|
|
152
|
+
}
|
|
153
|
+
get value() {
|
|
154
|
+
return [...this.valueInternal];
|
|
155
|
+
}
|
|
156
|
+
set value(nextValue) {
|
|
157
|
+
this.valueInternal = [...nextValue];
|
|
158
|
+
this.setAttribute("value", JSON.stringify(nextValue));
|
|
159
|
+
this.syncFormAssociation();
|
|
160
|
+
if (this.isRendered) {
|
|
161
|
+
this.update();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
165
|
+
if (name === "value") {
|
|
166
|
+
const raw = this.getAttribute("value");
|
|
167
|
+
if (!raw) {
|
|
168
|
+
this.valueInternal = [];
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
try {
|
|
172
|
+
const parsed = JSON.parse(raw);
|
|
173
|
+
this.valueInternal = Array.isArray(parsed) ? parsed : [];
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
this.valueInternal = [];
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
181
|
+
}
|
|
182
|
+
getFormValue() {
|
|
183
|
+
return formDataFromNamedValues(this.name, this.valueInternal);
|
|
184
|
+
}
|
|
185
|
+
restoreFormValue(value) {
|
|
186
|
+
const next = stringValuesFromFormValue(value, this.name);
|
|
187
|
+
this.valueInternal = next;
|
|
188
|
+
this.setAttribute("value", JSON.stringify(next));
|
|
189
|
+
this.syncFormAssociation();
|
|
190
|
+
if (this.isRendered) {
|
|
191
|
+
this.update();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
renderTemplate() {
|
|
195
|
+
if (!this.shadowRoot) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
this.shadowRoot.innerHTML = `
|
|
199
|
+
<style>${multiSelectStyles}</style>
|
|
200
|
+
<fieldset part="field">
|
|
201
|
+
<legend part="label"></legend>
|
|
202
|
+
<span part="summary"></span>
|
|
203
|
+
<div part="options"></div>
|
|
204
|
+
${formErrorMessageMarkup()}
|
|
205
|
+
</fieldset>
|
|
206
|
+
`;
|
|
207
|
+
this.legendEl = this.shadowRoot.querySelector('[part="label"]');
|
|
208
|
+
this.summaryEl = this.shadowRoot.querySelector('[part="summary"]');
|
|
209
|
+
this.optionsContainerEl = this.shadowRoot.querySelector('[part="options"]');
|
|
210
|
+
this.errorEl = this.shadowRoot.querySelector('[part="error-message"]');
|
|
211
|
+
}
|
|
212
|
+
setupListeners() {
|
|
213
|
+
this.optionsContainerEl.addEventListener("change", event => {
|
|
214
|
+
const target = event.target;
|
|
215
|
+
if (target.getAttribute("part") !== "input") {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const selected = Array.from(this.optionsContainerEl.querySelectorAll('[part="input"]:checked')).map(node => node.value);
|
|
219
|
+
this.valueInternal = selected;
|
|
220
|
+
this.setAttribute("value", JSON.stringify(selected));
|
|
221
|
+
this.summaryEl.textContent =
|
|
222
|
+
selected.length === 0 ? "No selections" : `${selected.length} selected`;
|
|
223
|
+
this.syncFormAssociation();
|
|
224
|
+
this.dispatchEvent(new CustomEvent("value-changed", {
|
|
225
|
+
bubbles: true,
|
|
226
|
+
composed: true,
|
|
227
|
+
detail: { value: [...selected] },
|
|
228
|
+
}));
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
update() {
|
|
232
|
+
if (!this.legendEl || !this.summaryEl || !this.optionsContainerEl || !this.errorEl) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
this.legendEl.textContent = this.label;
|
|
236
|
+
this.summaryEl.textContent =
|
|
237
|
+
this.valueInternal.length === 0 ? "No selections" : `${this.valueInternal.length} selected`;
|
|
238
|
+
const optionsJson = JSON.stringify(this.options);
|
|
239
|
+
if (optionsJson !== this.lastOptionsJson) {
|
|
240
|
+
this.optionsContainerEl.innerHTML = this.options
|
|
241
|
+
.map(option => `
|
|
242
|
+
<label part="option">
|
|
243
|
+
<input type="checkbox" part="input" value="${escapeHtml(option.value)}" ${option.disabled ? "disabled" : ""} />
|
|
244
|
+
<span part="option-label">${escapeHtml(option.label)}</span>
|
|
245
|
+
</label>
|
|
246
|
+
`)
|
|
247
|
+
.join("");
|
|
248
|
+
this.lastOptionsJson = optionsJson;
|
|
249
|
+
}
|
|
250
|
+
this.optionsContainerEl.querySelectorAll('[part="input"]').forEach(node => {
|
|
251
|
+
const input = node;
|
|
252
|
+
input.checked = this.valueInternal.includes(input.value);
|
|
253
|
+
});
|
|
254
|
+
this.applyInvalidStateToControls(Array.from(this.optionsContainerEl.querySelectorAll('[part="input"]')), this.errorEl);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
export const defineBoxMultiSelectElement = (tagName = DEFAULT_TAG_NAME) => {
|
|
258
|
+
const existingElement = customElements.get(tagName);
|
|
259
|
+
if (existingElement) {
|
|
260
|
+
return existingElement;
|
|
261
|
+
}
|
|
262
|
+
customElements.define(tagName, BoxMultiSelectElement);
|
|
263
|
+
return BoxMultiSelectElement;
|
|
264
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FormAssociatedElement } from "../../core/index.js";
|
|
2
|
+
import type { FormValue } from "../../core/index.js";
|
|
3
|
+
export declare class BoxNumberInputElement extends FormAssociatedElement {
|
|
4
|
+
static get observedAttributes(): string[];
|
|
5
|
+
private valueInternal;
|
|
6
|
+
private inputEl;
|
|
7
|
+
private labelEl;
|
|
8
|
+
private errorEl;
|
|
9
|
+
get disabled(): boolean;
|
|
10
|
+
set disabled(value: boolean);
|
|
11
|
+
get label(): string;
|
|
12
|
+
set label(value: string);
|
|
13
|
+
get max(): number | null;
|
|
14
|
+
set max(value: number | null);
|
|
15
|
+
get min(): number | null;
|
|
16
|
+
set min(value: number | null);
|
|
17
|
+
get placeholder(): string;
|
|
18
|
+
set placeholder(value: string);
|
|
19
|
+
get step(): number;
|
|
20
|
+
set step(value: number);
|
|
21
|
+
get value(): number;
|
|
22
|
+
set value(nextValue: number);
|
|
23
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
24
|
+
protected getFormValue(): FormValue;
|
|
25
|
+
protected restoreFormValue(value: FormValue): void;
|
|
26
|
+
private clamp;
|
|
27
|
+
private syncValue;
|
|
28
|
+
protected renderTemplate(): void;
|
|
29
|
+
protected setupListeners(): void;
|
|
30
|
+
protected update(): void;
|
|
31
|
+
}
|
|
32
|
+
export declare const defineBoxNumberInputElement: (tagName?: string) => typeof BoxNumberInputElement;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { FormAssociatedElement, boeFormFieldErrorStyles, formErrorMessageMarkup, } from "../../core/index.js";
|
|
2
|
+
import { boeNeutralInteractiveStyles } from "../../foundations/tokens/index.js";
|
|
3
|
+
import { boeMotionDuration, boeMotionEasing } from "../../foundations/motion/index.js";
|
|
4
|
+
import { boeRadius } from "../../foundations/geometry/index.js";
|
|
5
|
+
const DEFAULT_TAG_NAME = "box-number-input";
|
|
6
|
+
const parseNumber = (value, fallback) => {
|
|
7
|
+
if (value == null || value === "") {
|
|
8
|
+
return fallback;
|
|
9
|
+
}
|
|
10
|
+
const parsed = Number(value);
|
|
11
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
12
|
+
};
|
|
13
|
+
const numberInputStyles = `
|
|
14
|
+
:host {
|
|
15
|
+
display: block;
|
|
16
|
+
color: inherit;
|
|
17
|
+
font: inherit;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
[part="field"] {
|
|
21
|
+
display: grid;
|
|
22
|
+
gap: 0.45rem;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[part="label"] {
|
|
26
|
+
font-size: 0.8rem;
|
|
27
|
+
font-weight: 700;
|
|
28
|
+
letter-spacing: 0.08em;
|
|
29
|
+
text-transform: uppercase;
|
|
30
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[part="input"] {
|
|
34
|
+
font: inherit;
|
|
35
|
+
color: var(--boe-token-text-text, #222222);
|
|
36
|
+
padding: 0.45rem 0.7rem;
|
|
37
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 78%, var(--boe-token-surface-surface, #ffffff) 22%);
|
|
38
|
+
border-radius: ${boeRadius.control};
|
|
39
|
+
background: var(--boe-token-surface-surface, #ffffff);
|
|
40
|
+
transition:
|
|
41
|
+
border-color ${boeMotionDuration.interactive} ${boeMotionEasing.standard},
|
|
42
|
+
background ${boeMotionDuration.interactive} ${boeMotionEasing.standard},
|
|
43
|
+
box-shadow ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[part="input"]::placeholder {
|
|
47
|
+
color: var(--boe-token-text-text-placeholder, #909090);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
${boeNeutralInteractiveStyles('[part="input"]')}
|
|
51
|
+
|
|
52
|
+
[part="input"]:focus-visible {
|
|
53
|
+
border-color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
${boeFormFieldErrorStyles}
|
|
57
|
+
`;
|
|
58
|
+
export class BoxNumberInputElement extends FormAssociatedElement {
|
|
59
|
+
static get observedAttributes() {
|
|
60
|
+
return [
|
|
61
|
+
...FormAssociatedElement.formObservedAttributes,
|
|
62
|
+
"disabled",
|
|
63
|
+
"label",
|
|
64
|
+
"max",
|
|
65
|
+
"min",
|
|
66
|
+
"placeholder",
|
|
67
|
+
"step",
|
|
68
|
+
"value",
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
valueInternal = 0;
|
|
72
|
+
inputEl;
|
|
73
|
+
labelEl;
|
|
74
|
+
errorEl;
|
|
75
|
+
get disabled() {
|
|
76
|
+
return this.hasAttribute("disabled");
|
|
77
|
+
}
|
|
78
|
+
set disabled(value) {
|
|
79
|
+
if (value) {
|
|
80
|
+
this.setAttribute("disabled", "");
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
this.removeAttribute("disabled");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
get label() {
|
|
87
|
+
return this.getAttribute("label") ?? "Number";
|
|
88
|
+
}
|
|
89
|
+
set label(value) {
|
|
90
|
+
this.setAttribute("label", value);
|
|
91
|
+
}
|
|
92
|
+
get max() {
|
|
93
|
+
return this.hasAttribute("max") ? parseNumber(this.getAttribute("max"), 0) : null;
|
|
94
|
+
}
|
|
95
|
+
set max(value) {
|
|
96
|
+
if (value == null) {
|
|
97
|
+
this.removeAttribute("max");
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
this.setAttribute("max", String(value));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
get min() {
|
|
104
|
+
return this.hasAttribute("min") ? parseNumber(this.getAttribute("min"), 0) : null;
|
|
105
|
+
}
|
|
106
|
+
set min(value) {
|
|
107
|
+
if (value == null) {
|
|
108
|
+
this.removeAttribute("min");
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
this.setAttribute("min", String(value));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
get placeholder() {
|
|
115
|
+
return this.getAttribute("placeholder") ?? "";
|
|
116
|
+
}
|
|
117
|
+
set placeholder(value) {
|
|
118
|
+
this.setAttribute("placeholder", value);
|
|
119
|
+
}
|
|
120
|
+
get step() {
|
|
121
|
+
return parseNumber(this.getAttribute("step"), 1);
|
|
122
|
+
}
|
|
123
|
+
set step(value) {
|
|
124
|
+
this.setAttribute("step", String(value));
|
|
125
|
+
}
|
|
126
|
+
get value() {
|
|
127
|
+
return this.valueInternal;
|
|
128
|
+
}
|
|
129
|
+
set value(nextValue) {
|
|
130
|
+
const normalizedValue = this.clamp(Number.isFinite(nextValue) ? nextValue : 0);
|
|
131
|
+
this.valueInternal = normalizedValue;
|
|
132
|
+
this.setAttribute("value", String(normalizedValue));
|
|
133
|
+
if (this.isRendered) {
|
|
134
|
+
this.update();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
138
|
+
if (name === "value") {
|
|
139
|
+
this.valueInternal = this.clamp(parseNumber(newValue, this.valueInternal));
|
|
140
|
+
}
|
|
141
|
+
else if (name === "min" || name === "max") {
|
|
142
|
+
const clamped = this.clamp(this.valueInternal);
|
|
143
|
+
this.valueInternal = clamped;
|
|
144
|
+
if (this.getAttribute("value") !== String(clamped)) {
|
|
145
|
+
this.setAttribute("value", String(clamped));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
149
|
+
}
|
|
150
|
+
getFormValue() {
|
|
151
|
+
return String(this.valueInternal);
|
|
152
|
+
}
|
|
153
|
+
restoreFormValue(value) {
|
|
154
|
+
const parsed = typeof value === "string" ? parseNumber(value, this.valueInternal) : this.valueInternal;
|
|
155
|
+
this.valueInternal = this.clamp(parsed);
|
|
156
|
+
this.setAttribute("value", String(this.valueInternal));
|
|
157
|
+
if (this.isRendered) {
|
|
158
|
+
this.update();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
clamp(nextValue) {
|
|
162
|
+
let normalizedValue = nextValue;
|
|
163
|
+
if (this.min != null) {
|
|
164
|
+
normalizedValue = Math.max(this.min, normalizedValue);
|
|
165
|
+
}
|
|
166
|
+
if (this.max != null) {
|
|
167
|
+
normalizedValue = Math.min(this.max, normalizedValue);
|
|
168
|
+
}
|
|
169
|
+
return normalizedValue;
|
|
170
|
+
}
|
|
171
|
+
syncValue(nextValue) {
|
|
172
|
+
const normalizedValue = this.clamp(nextValue);
|
|
173
|
+
this.valueInternal = normalizedValue;
|
|
174
|
+
this.setAttribute("value", String(normalizedValue));
|
|
175
|
+
this.syncFormAssociation();
|
|
176
|
+
this.dispatchEvent(new CustomEvent("value-changed", {
|
|
177
|
+
bubbles: true,
|
|
178
|
+
composed: true,
|
|
179
|
+
detail: { value: normalizedValue },
|
|
180
|
+
}));
|
|
181
|
+
}
|
|
182
|
+
renderTemplate() {
|
|
183
|
+
if (!this.shadowRoot) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
this.shadowRoot.innerHTML = `
|
|
187
|
+
<style>${numberInputStyles}</style>
|
|
188
|
+
<label part="field">
|
|
189
|
+
<span part="label"></span>
|
|
190
|
+
<input type="number" part="input" />
|
|
191
|
+
${formErrorMessageMarkup()}
|
|
192
|
+
</label>
|
|
193
|
+
`;
|
|
194
|
+
this.labelEl = this.shadowRoot.querySelector('[part="label"]');
|
|
195
|
+
this.inputEl = this.shadowRoot.querySelector('[part="input"]');
|
|
196
|
+
this.errorEl = this.shadowRoot.querySelector('[part="error-message"]');
|
|
197
|
+
}
|
|
198
|
+
setupListeners() {
|
|
199
|
+
this.inputEl.addEventListener("input", event => {
|
|
200
|
+
const nextValue = Number(event.currentTarget.value);
|
|
201
|
+
if (!Number.isFinite(nextValue)) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
this.syncValue(nextValue);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
update() {
|
|
208
|
+
if (!this.inputEl || !this.labelEl || !this.errorEl) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
this.labelEl.textContent = this.label;
|
|
212
|
+
this.inputEl.placeholder = this.placeholder;
|
|
213
|
+
this.inputEl.step = String(this.step);
|
|
214
|
+
if (this.min == null) {
|
|
215
|
+
this.inputEl.removeAttribute("min");
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
this.inputEl.min = String(this.min);
|
|
219
|
+
}
|
|
220
|
+
if (this.max == null) {
|
|
221
|
+
this.inputEl.removeAttribute("max");
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
this.inputEl.max = String(this.max);
|
|
225
|
+
}
|
|
226
|
+
if (this.shadowRoot?.activeElement !== this.inputEl) {
|
|
227
|
+
this.inputEl.value = String(this.valueInternal);
|
|
228
|
+
}
|
|
229
|
+
if (this.disabled) {
|
|
230
|
+
this.inputEl.setAttribute("disabled", "");
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
this.inputEl.removeAttribute("disabled");
|
|
234
|
+
}
|
|
235
|
+
this.applyInvalidState(this.inputEl, this.errorEl);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
export const defineBoxNumberInputElement = (tagName = DEFAULT_TAG_NAME) => {
|
|
239
|
+
const existingElement = customElements.get(tagName);
|
|
240
|
+
if (existingElement) {
|
|
241
|
+
return existingElement;
|
|
242
|
+
}
|
|
243
|
+
customElements.define(tagName, BoxNumberInputElement);
|
|
244
|
+
return BoxNumberInputElement;
|
|
245
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FormAssociatedElement } from "../../core/index.js";
|
|
2
|
+
import type { FormValue } from "../../core/index.js";
|
|
3
|
+
type PillCloudOption = {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A cloud of toggle pills for multi-select filtering — think facet chips. Data
|
|
10
|
+
* arrives via `options`; the selected set is exposed as `value` (a string[]) and
|
|
11
|
+
* announced with `value-changed`. Each pill is a toggle button with
|
|
12
|
+
* `aria-pressed`; the group is a labelled `role="group"`.
|
|
13
|
+
*/
|
|
14
|
+
export declare class BoxPillCloudElement extends FormAssociatedElement {
|
|
15
|
+
static get observedAttributes(): string[];
|
|
16
|
+
private valueInternal;
|
|
17
|
+
private lastOptionsJson;
|
|
18
|
+
private rootEl;
|
|
19
|
+
private errorEl;
|
|
20
|
+
get label(): string;
|
|
21
|
+
set label(value: string);
|
|
22
|
+
get options(): PillCloudOption[];
|
|
23
|
+
set options(value: PillCloudOption[]);
|
|
24
|
+
get value(): string[];
|
|
25
|
+
set value(nextValue: string[]);
|
|
26
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
27
|
+
protected getFormValue(): FormValue;
|
|
28
|
+
protected restoreFormValue(value: FormValue): void;
|
|
29
|
+
private toggle;
|
|
30
|
+
protected renderTemplate(): void;
|
|
31
|
+
protected setupListeners(): void;
|
|
32
|
+
protected update(): void;
|
|
33
|
+
}
|
|
34
|
+
export declare const defineBoxPillCloudElement: (tagName?: string) => typeof BoxPillCloudElement;
|
|
35
|
+
export {};
|