@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,27 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
export interface SegmentedControlOption {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class BoxSegmentedControlElement extends BaseElement {
|
|
8
|
+
static get observedAttributes(): string[];
|
|
9
|
+
private valueInternal;
|
|
10
|
+
private controlEl;
|
|
11
|
+
get disabled(): boolean;
|
|
12
|
+
set disabled(value: boolean);
|
|
13
|
+
get label(): string;
|
|
14
|
+
set label(value: string);
|
|
15
|
+
get layout(): "attached" | "separated";
|
|
16
|
+
set layout(value: "attached" | "separated");
|
|
17
|
+
get options(): SegmentedControlOption[];
|
|
18
|
+
set options(value: SegmentedControlOption[]);
|
|
19
|
+
get value(): string;
|
|
20
|
+
set value(nextValue: string);
|
|
21
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
22
|
+
private moveSelection;
|
|
23
|
+
private moveSelectionTo;
|
|
24
|
+
protected renderTemplate(): void;
|
|
25
|
+
protected update(): void;
|
|
26
|
+
}
|
|
27
|
+
export declare const defineBoxSegmentedControlElement: (tagName?: string) => typeof BoxSegmentedControlElement;
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
import { boeRadius } from "../../foundations/geometry/index.js";
|
|
3
|
+
import { boeMotionDuration, boeMotionEasing } from "../../foundations/motion/index.js";
|
|
4
|
+
const DEFAULT_TAG_NAME = "box-segmented-control";
|
|
5
|
+
const escapeHtml = (value) => value
|
|
6
|
+
.replaceAll("&", "&")
|
|
7
|
+
.replaceAll("<", "<")
|
|
8
|
+
.replaceAll(">", ">")
|
|
9
|
+
.replaceAll('"', """)
|
|
10
|
+
.replaceAll("'", "'");
|
|
11
|
+
const segmentedControlStyles = `
|
|
12
|
+
:host {
|
|
13
|
+
display: inline-block;
|
|
14
|
+
color: inherit;
|
|
15
|
+
font: inherit;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
[part="control"] {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
align-items: stretch;
|
|
21
|
+
gap: 0.25rem;
|
|
22
|
+
padding: 0.25rem;
|
|
23
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 84%, var(--boe-token-surface-surface, #ffffff) 16%);
|
|
24
|
+
border-radius: ${boeRadius.control};
|
|
25
|
+
background: var(--boe-token-surface-surface-secondary, #fbfbfb);
|
|
26
|
+
box-shadow: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
[part="control"][data-layout="attached"] {
|
|
30
|
+
gap: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[part="segment"] {
|
|
34
|
+
appearance: none;
|
|
35
|
+
font: inherit;
|
|
36
|
+
font-weight: 600;
|
|
37
|
+
line-height: 1.2;
|
|
38
|
+
padding: 0.45em 1em;
|
|
39
|
+
border: 1px solid transparent;
|
|
40
|
+
border-radius: ${boeRadius.control};
|
|
41
|
+
background: transparent;
|
|
42
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
transition:
|
|
45
|
+
background-color ${boeMotionDuration.interactive} ${boeMotionEasing.standard},
|
|
46
|
+
border-color ${boeMotionDuration.interactive} ${boeMotionEasing.standard},
|
|
47
|
+
color ${boeMotionDuration.interactive} ${boeMotionEasing.standard},
|
|
48
|
+
box-shadow ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[part="segment"]:hover:not(:disabled):not([data-selected="true"]) {
|
|
52
|
+
background: color-mix(in srgb, var(--boe-token-surface-surface-hover, #f4f4f4) 60%, var(--boe-token-surface-surface, #ffffff) 40%);
|
|
53
|
+
color: var(--boe-token-text-text, #222222);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
[part="segment"][data-selected="true"] {
|
|
57
|
+
background: var(--boe-token-surface-surface, #ffffff);
|
|
58
|
+
border-color: color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 70%, var(--boe-token-surface-surface, #ffffff) 30%);
|
|
59
|
+
color: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 84%, var(--boe-token-text-text, #222222) 16%);
|
|
60
|
+
box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
[part="segment"]:focus-visible {
|
|
64
|
+
outline: none;
|
|
65
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 18%, transparent);
|
|
66
|
+
z-index: 1;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
[part="segment"]:disabled {
|
|
70
|
+
cursor: not-allowed;
|
|
71
|
+
opacity: 0.55;
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
export class BoxSegmentedControlElement extends BaseElement {
|
|
75
|
+
static get observedAttributes() {
|
|
76
|
+
return ["disabled", "label", "layout", "options", "value"];
|
|
77
|
+
}
|
|
78
|
+
valueInternal = "";
|
|
79
|
+
controlEl;
|
|
80
|
+
get disabled() {
|
|
81
|
+
return this.hasAttribute("disabled");
|
|
82
|
+
}
|
|
83
|
+
set disabled(value) {
|
|
84
|
+
if (value) {
|
|
85
|
+
this.setAttribute("disabled", "");
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
this.removeAttribute("disabled");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
get label() {
|
|
92
|
+
return this.getAttribute("label") ?? "Segmented Control";
|
|
93
|
+
}
|
|
94
|
+
set label(value) {
|
|
95
|
+
this.setAttribute("label", value);
|
|
96
|
+
}
|
|
97
|
+
get layout() {
|
|
98
|
+
return this.getAttribute("layout") === "attached" ? "attached" : "separated";
|
|
99
|
+
}
|
|
100
|
+
set layout(value) {
|
|
101
|
+
this.setAttribute("layout", value);
|
|
102
|
+
}
|
|
103
|
+
get options() {
|
|
104
|
+
const raw = this.getAttribute("options");
|
|
105
|
+
if (!raw) {
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
const parsed = JSON.parse(raw);
|
|
110
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
set options(value) {
|
|
117
|
+
this.setAttribute("options", JSON.stringify(value));
|
|
118
|
+
}
|
|
119
|
+
get value() {
|
|
120
|
+
return this.valueInternal;
|
|
121
|
+
}
|
|
122
|
+
set value(nextValue) {
|
|
123
|
+
this.valueInternal = nextValue;
|
|
124
|
+
this.setAttribute("value", nextValue);
|
|
125
|
+
if (this.isRendered) {
|
|
126
|
+
this.update();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
130
|
+
if (name === "value") {
|
|
131
|
+
this.valueInternal = this.getAttribute("value") ?? "";
|
|
132
|
+
}
|
|
133
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
134
|
+
}
|
|
135
|
+
moveSelection(direction) {
|
|
136
|
+
const enabledOptions = this.options.filter(option => !option.disabled);
|
|
137
|
+
if (enabledOptions.length === 0) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const currentIndex = enabledOptions.findIndex(option => option.value === this.valueInternal);
|
|
141
|
+
const nextIndex = currentIndex < 0
|
|
142
|
+
? 0
|
|
143
|
+
: (currentIndex + direction + enabledOptions.length) % enabledOptions.length;
|
|
144
|
+
this.moveSelectionTo(nextIndex, enabledOptions);
|
|
145
|
+
}
|
|
146
|
+
moveSelectionTo(index, enabledOptions = this.options.filter(option => !option.disabled)) {
|
|
147
|
+
if (enabledOptions.length === 0) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const nextIndex = Math.max(0, Math.min(enabledOptions.length - 1, index));
|
|
151
|
+
const nextValue = enabledOptions[nextIndex]?.value ?? "";
|
|
152
|
+
const focusSegment = (value) => {
|
|
153
|
+
const nextButton = Array.from(this.controlEl?.querySelectorAll('[part="segment"]') ?? []).find(button => button.dataset.value === value);
|
|
154
|
+
nextButton?.focus();
|
|
155
|
+
};
|
|
156
|
+
if (!nextValue || nextValue === this.valueInternal) {
|
|
157
|
+
focusSegment(nextValue);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
this.valueInternal = nextValue;
|
|
161
|
+
this.setAttribute("value", nextValue);
|
|
162
|
+
this.dispatchEvent(new CustomEvent("value-changed", {
|
|
163
|
+
bubbles: true,
|
|
164
|
+
composed: true,
|
|
165
|
+
detail: { value: nextValue },
|
|
166
|
+
}));
|
|
167
|
+
this.update();
|
|
168
|
+
focusSegment(nextValue);
|
|
169
|
+
}
|
|
170
|
+
renderTemplate() {
|
|
171
|
+
if (!this.shadowRoot) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
this.shadowRoot.innerHTML = `
|
|
175
|
+
<style>${segmentedControlStyles}</style>
|
|
176
|
+
<div part="control" role="radiogroup"></div>
|
|
177
|
+
`;
|
|
178
|
+
this.controlEl = this.shadowRoot.querySelector('[part="control"]');
|
|
179
|
+
}
|
|
180
|
+
update() {
|
|
181
|
+
if (!this.controlEl) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const options = this.options;
|
|
185
|
+
const firstEnabledValue = options.find(option => !option.disabled)?.value ?? "";
|
|
186
|
+
const selectedValue = this.valueInternal || firstEnabledValue;
|
|
187
|
+
if (selectedValue !== this.valueInternal) {
|
|
188
|
+
this.valueInternal = selectedValue;
|
|
189
|
+
this.setAttribute("value", selectedValue);
|
|
190
|
+
}
|
|
191
|
+
this.controlEl.dataset.layout = this.layout;
|
|
192
|
+
this.controlEl.setAttribute("aria-label", this.label);
|
|
193
|
+
this.controlEl.setAttribute("aria-disabled", String(this.disabled));
|
|
194
|
+
// Rebuild segments (count may change)
|
|
195
|
+
this.controlEl.innerHTML = options
|
|
196
|
+
.map((option, index) => {
|
|
197
|
+
const position = options.length === 1
|
|
198
|
+
? "only"
|
|
199
|
+
: index === 0
|
|
200
|
+
? "first"
|
|
201
|
+
: index === options.length - 1
|
|
202
|
+
? "last"
|
|
203
|
+
: "middle";
|
|
204
|
+
return `
|
|
205
|
+
<button
|
|
206
|
+
type="button"
|
|
207
|
+
part="segment"
|
|
208
|
+
data-value="${escapeHtml(option.value)}"
|
|
209
|
+
data-layout="${this.layout}"
|
|
210
|
+
data-position="${position}"
|
|
211
|
+
data-selected="${String(option.value === selectedValue)}"
|
|
212
|
+
role="radio"
|
|
213
|
+
aria-checked="${String(option.value === selectedValue)}"
|
|
214
|
+
tabindex="${option.value === selectedValue ? "0" : "-1"}"
|
|
215
|
+
${this.disabled || option.disabled ? "disabled" : ""}
|
|
216
|
+
>
|
|
217
|
+
${escapeHtml(option.label)}
|
|
218
|
+
</button>
|
|
219
|
+
`;
|
|
220
|
+
})
|
|
221
|
+
.join("");
|
|
222
|
+
this.controlEl.querySelectorAll('[part="segment"]').forEach(button => {
|
|
223
|
+
button.addEventListener("click", () => {
|
|
224
|
+
const target = button;
|
|
225
|
+
if (target.disabled) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const nextValue = target.dataset.value ?? "";
|
|
229
|
+
if (!nextValue || nextValue === this.valueInternal) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
this.valueInternal = nextValue;
|
|
233
|
+
this.setAttribute("value", nextValue);
|
|
234
|
+
this.dispatchEvent(new CustomEvent("value-changed", {
|
|
235
|
+
bubbles: true,
|
|
236
|
+
composed: true,
|
|
237
|
+
detail: { value: nextValue },
|
|
238
|
+
}));
|
|
239
|
+
this.update();
|
|
240
|
+
});
|
|
241
|
+
button.addEventListener("keydown", event => {
|
|
242
|
+
const keyboardEvent = event;
|
|
243
|
+
if (keyboardEvent.key === "ArrowRight" || keyboardEvent.key === "ArrowDown") {
|
|
244
|
+
keyboardEvent.preventDefault();
|
|
245
|
+
this.moveSelection(1);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (keyboardEvent.key === "ArrowLeft" || keyboardEvent.key === "ArrowUp") {
|
|
249
|
+
keyboardEvent.preventDefault();
|
|
250
|
+
this.moveSelection(-1);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (keyboardEvent.key === "Home") {
|
|
254
|
+
keyboardEvent.preventDefault();
|
|
255
|
+
this.moveSelectionTo(0);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (keyboardEvent.key === "End") {
|
|
259
|
+
keyboardEvent.preventDefault();
|
|
260
|
+
this.moveSelectionTo(this.options.length - 1);
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
export const defineBoxSegmentedControlElement = (tagName = DEFAULT_TAG_NAME) => {
|
|
267
|
+
const existingElement = customElements.get(tagName);
|
|
268
|
+
if (existingElement) {
|
|
269
|
+
return existingElement;
|
|
270
|
+
}
|
|
271
|
+
customElements.define(tagName, BoxSegmentedControlElement);
|
|
272
|
+
return BoxSegmentedControlElement;
|
|
273
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
export declare class BoxCardElement extends BaseElement {
|
|
3
|
+
static get observedAttributes(): string[];
|
|
4
|
+
private eyebrowEl;
|
|
5
|
+
private titleEl;
|
|
6
|
+
get eyebrow(): string;
|
|
7
|
+
set eyebrow(value: string);
|
|
8
|
+
get heading(): string;
|
|
9
|
+
set heading(value: string);
|
|
10
|
+
protected renderTemplate(): void;
|
|
11
|
+
protected update(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare const defineBoxCardElement: (tagName?: string) => typeof BoxCardElement;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
import { boeRadius } from "../../foundations/geometry/index.js";
|
|
3
|
+
const DEFAULT_TAG_NAME = "box-card";
|
|
4
|
+
const cardStyles = `
|
|
5
|
+
:host {
|
|
6
|
+
display: block;
|
|
7
|
+
color: inherit;
|
|
8
|
+
font: inherit;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
[part="card"] {
|
|
12
|
+
display: grid;
|
|
13
|
+
gap: 0.55rem;
|
|
14
|
+
padding: 0.7rem;
|
|
15
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 82%, var(--boe-token-surface-surface, #ffffff) 18%);
|
|
16
|
+
border-radius: ${boeRadius.large};
|
|
17
|
+
background: var(--boe-token-surface-surface-secondary, #fbfbfb);
|
|
18
|
+
box-shadow:
|
|
19
|
+
0 14px 28px rgba(15, 23, 42, 0.04);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[part="header"] {
|
|
23
|
+
display: grid;
|
|
24
|
+
gap: 0.35rem;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
[part="eyebrow"] {
|
|
28
|
+
color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
29
|
+
font-size: 0.78rem;
|
|
30
|
+
font-weight: 700;
|
|
31
|
+
letter-spacing: 0.08em;
|
|
32
|
+
text-transform: uppercase;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
[part~="title"] {
|
|
36
|
+
margin: 0;
|
|
37
|
+
font: inherit;
|
|
38
|
+
font-size: 1.04rem;
|
|
39
|
+
font-weight: 700;
|
|
40
|
+
line-height: 1.25;
|
|
41
|
+
letter-spacing: -0.02em;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[part="body"] {
|
|
45
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
46
|
+
line-height: 1.55;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
[part="eyebrow"][hidden],
|
|
50
|
+
[part~="title"][hidden] {
|
|
51
|
+
display: none;
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
export class BoxCardElement extends BaseElement {
|
|
55
|
+
static get observedAttributes() {
|
|
56
|
+
return ["eyebrow", "heading"];
|
|
57
|
+
}
|
|
58
|
+
eyebrowEl;
|
|
59
|
+
titleEl;
|
|
60
|
+
get eyebrow() {
|
|
61
|
+
return this.getAttribute("eyebrow") ?? "";
|
|
62
|
+
}
|
|
63
|
+
set eyebrow(value) {
|
|
64
|
+
this.setAttribute("eyebrow", value);
|
|
65
|
+
}
|
|
66
|
+
get heading() {
|
|
67
|
+
return this.getAttribute("heading") ?? "";
|
|
68
|
+
}
|
|
69
|
+
set heading(value) {
|
|
70
|
+
this.setAttribute("heading", value);
|
|
71
|
+
}
|
|
72
|
+
renderTemplate() {
|
|
73
|
+
if (!this.shadowRoot) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
this.shadowRoot.innerHTML = `
|
|
77
|
+
<style>${cardStyles}</style>
|
|
78
|
+
<article part="card">
|
|
79
|
+
<header part="header">
|
|
80
|
+
<span part="eyebrow" hidden></span>
|
|
81
|
+
<h2 part="title heading" hidden></h2>
|
|
82
|
+
</header>
|
|
83
|
+
<div part="body">
|
|
84
|
+
<slot></slot>
|
|
85
|
+
</div>
|
|
86
|
+
</article>
|
|
87
|
+
`;
|
|
88
|
+
this.eyebrowEl = this.shadowRoot.querySelector('[part="eyebrow"]');
|
|
89
|
+
this.titleEl = this.shadowRoot.querySelector('[part~="title"]');
|
|
90
|
+
}
|
|
91
|
+
update() {
|
|
92
|
+
if (!this.eyebrowEl || !this.titleEl) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const eyebrow = this.eyebrow;
|
|
96
|
+
const heading = this.heading;
|
|
97
|
+
this.eyebrowEl.textContent = eyebrow;
|
|
98
|
+
this.eyebrowEl.hidden = !eyebrow;
|
|
99
|
+
this.titleEl.textContent = heading;
|
|
100
|
+
this.titleEl.hidden = !heading;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export const defineBoxCardElement = (tagName = DEFAULT_TAG_NAME) => {
|
|
104
|
+
const existingElement = customElements.get(tagName);
|
|
105
|
+
if (existingElement) {
|
|
106
|
+
return existingElement;
|
|
107
|
+
}
|
|
108
|
+
customElements.define(tagName, BoxCardElement);
|
|
109
|
+
return BoxCardElement;
|
|
110
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
type CarouselItem = {
|
|
3
|
+
eyebrow?: string;
|
|
4
|
+
title: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
imageSrc?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class BoxCarouselElement extends BaseElement {
|
|
9
|
+
static get observedAttributes(): string[];
|
|
10
|
+
private valueInternal;
|
|
11
|
+
private lastItemsJson;
|
|
12
|
+
private carouselEl;
|
|
13
|
+
private labelEl;
|
|
14
|
+
private stageEl;
|
|
15
|
+
private mediaEl;
|
|
16
|
+
private eyebrowEl;
|
|
17
|
+
private titleEl;
|
|
18
|
+
private descriptionEl;
|
|
19
|
+
private controlsEl;
|
|
20
|
+
private paginationEl;
|
|
21
|
+
private emptyEl;
|
|
22
|
+
private previousEl;
|
|
23
|
+
private nextEl;
|
|
24
|
+
get label(): string;
|
|
25
|
+
set label(value: string);
|
|
26
|
+
get items(): CarouselItem[];
|
|
27
|
+
set items(value: CarouselItem[]);
|
|
28
|
+
get value(): number;
|
|
29
|
+
set value(value: number);
|
|
30
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
31
|
+
private normalizeIndex;
|
|
32
|
+
private emitValueChanged;
|
|
33
|
+
private setIndex;
|
|
34
|
+
private changeBy;
|
|
35
|
+
protected renderTemplate(): void;
|
|
36
|
+
protected setupListeners(): void;
|
|
37
|
+
protected update(): void;
|
|
38
|
+
}
|
|
39
|
+
export declare const defineBoxCarouselElement: (tagName?: string) => typeof BoxCarouselElement;
|
|
40
|
+
export {};
|