@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,379 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
import { boeNeutralInteractiveStyles } from "../../foundations/tokens/index.js";
|
|
3
|
+
import { boePanel, boeRadius } from "../../foundations/geometry/index.js";
|
|
4
|
+
const DEFAULT_TAG_NAME = "box-filter-bar";
|
|
5
|
+
const escapeHtml = (value) => value
|
|
6
|
+
.replaceAll("&", "&")
|
|
7
|
+
.replaceAll("<", "<")
|
|
8
|
+
.replaceAll(">", ">")
|
|
9
|
+
.replaceAll('"', """)
|
|
10
|
+
.replaceAll("'", "'");
|
|
11
|
+
const elementStyles = `
|
|
12
|
+
:host {
|
|
13
|
+
display: block;
|
|
14
|
+
color: inherit;
|
|
15
|
+
font: inherit;
|
|
16
|
+
--_obp-surface: var(--boe-token-surface-surface, #ffffff);
|
|
17
|
+
--_obp-surface-muted: var(--boe-token-surface-surface-secondary, #fbfbfb);
|
|
18
|
+
--_obp-border: color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 82%, transparent);
|
|
19
|
+
--_obp-border-subtle: color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 64%, transparent);
|
|
20
|
+
--_obp-text-muted: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
21
|
+
--_obp-brand: var(--boe-token-surface-surface-brand, #0061d5);
|
|
22
|
+
--_obp-brand-soft: color-mix(in srgb, var(--_obp-brand) 12%, var(--boe-token-surface-surface, #ffffff) 88%);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[part="bar"] {
|
|
26
|
+
display: grid;
|
|
27
|
+
gap: ${boePanel.gap};
|
|
28
|
+
padding: ${boePanel.padding};
|
|
29
|
+
border: 1px solid var(--_obp-border);
|
|
30
|
+
border-radius: ${boePanel.radius};
|
|
31
|
+
background: var(--_obp-surface-muted);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
[part="label"] {
|
|
35
|
+
font-size: 0.9rem;
|
|
36
|
+
font-weight: 700;
|
|
37
|
+
letter-spacing: 0.08em;
|
|
38
|
+
text-transform: uppercase;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[part="controls"] {
|
|
42
|
+
display: grid;
|
|
43
|
+
grid-template-columns: minmax(14rem, 1.4fr) repeat(2, minmax(10rem, 0.8fr));
|
|
44
|
+
gap: ${boePanel.gap};
|
|
45
|
+
align-items: center;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[part="field"],
|
|
49
|
+
[part="select-field"] {
|
|
50
|
+
display: grid;
|
|
51
|
+
gap: 0.35rem;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
[part="field-label"] {
|
|
55
|
+
font-size: 0.82rem;
|
|
56
|
+
font-weight: 700;
|
|
57
|
+
letter-spacing: 0.06em;
|
|
58
|
+
text-transform: uppercase;
|
|
59
|
+
color: var(--_obp-text-muted);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
[part="input"],
|
|
63
|
+
[part="select"] {
|
|
64
|
+
width: 100%;
|
|
65
|
+
min-width: 0;
|
|
66
|
+
padding: 0.45rem 0.7rem;
|
|
67
|
+
border: 1px solid var(--_obp-border-subtle);
|
|
68
|
+
border-radius: ${boeRadius.control};
|
|
69
|
+
background: var(--_obp-surface);
|
|
70
|
+
color: inherit;
|
|
71
|
+
font: inherit;
|
|
72
|
+
box-sizing: border-box;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
[part="filters"] {
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-wrap: wrap;
|
|
78
|
+
gap: 0.65rem;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
[part="filter-chip"] {
|
|
82
|
+
border: 1px solid var(--_obp-border-subtle);
|
|
83
|
+
border-radius: 999px;
|
|
84
|
+
padding: 0.4rem 0.7rem;
|
|
85
|
+
background: var(--_obp-surface);
|
|
86
|
+
color: inherit;
|
|
87
|
+
font: inherit;
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
${boeNeutralInteractiveStyles('[part="input"]')}
|
|
92
|
+
${boeNeutralInteractiveStyles('[part="select"]')}
|
|
93
|
+
${boeNeutralInteractiveStyles('[part="filter-chip"]')}
|
|
94
|
+
|
|
95
|
+
[part="filter-chip"][data-selected="true"],
|
|
96
|
+
[part="filter-chip"][data-selected="true"]:hover:not(:disabled),
|
|
97
|
+
[part="filter-chip"][data-selected="true"]:active:not(:disabled) {
|
|
98
|
+
border-color: color-mix(in srgb, var(--_obp-brand) 34%, transparent);
|
|
99
|
+
background: var(--_obp-brand-soft);
|
|
100
|
+
color: var(--_obp-brand);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@media (max-width: 900px) {
|
|
104
|
+
[part="controls"] {
|
|
105
|
+
grid-template-columns: 1fr;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
`;
|
|
109
|
+
export class BoxFilterBarElement extends BaseElement {
|
|
110
|
+
static get observedAttributes() {
|
|
111
|
+
return ["filter-options", "filters", "label", "query", "sort-options", "sort-value", "view-options", "view-value"];
|
|
112
|
+
}
|
|
113
|
+
queryInternal = "";
|
|
114
|
+
sortValueInternal = "";
|
|
115
|
+
viewValueInternal = "";
|
|
116
|
+
filtersInternal = [];
|
|
117
|
+
labelEl;
|
|
118
|
+
barEl;
|
|
119
|
+
inputEl;
|
|
120
|
+
sortEl;
|
|
121
|
+
viewEl;
|
|
122
|
+
filtersEl;
|
|
123
|
+
optionsSignature = "";
|
|
124
|
+
get label() {
|
|
125
|
+
return this.getAttribute("label") ?? "Filter Bar";
|
|
126
|
+
}
|
|
127
|
+
set label(value) {
|
|
128
|
+
this.setAttribute("label", value);
|
|
129
|
+
}
|
|
130
|
+
get query() {
|
|
131
|
+
return this.queryInternal;
|
|
132
|
+
}
|
|
133
|
+
set query(value) {
|
|
134
|
+
this.queryInternal = value;
|
|
135
|
+
this.setAttribute("query", value);
|
|
136
|
+
}
|
|
137
|
+
get sortValue() {
|
|
138
|
+
return this.sortValueInternal;
|
|
139
|
+
}
|
|
140
|
+
set sortValue(value) {
|
|
141
|
+
this.sortValueInternal = value;
|
|
142
|
+
this.setAttribute("sort-value", value);
|
|
143
|
+
}
|
|
144
|
+
get viewValue() {
|
|
145
|
+
return this.viewValueInternal;
|
|
146
|
+
}
|
|
147
|
+
set viewValue(value) {
|
|
148
|
+
this.viewValueInternal = value;
|
|
149
|
+
this.setAttribute("view-value", value);
|
|
150
|
+
}
|
|
151
|
+
get filters() {
|
|
152
|
+
return this.filtersInternal;
|
|
153
|
+
}
|
|
154
|
+
set filters(value) {
|
|
155
|
+
this.filtersInternal = value;
|
|
156
|
+
this.setAttribute("filters", JSON.stringify(value));
|
|
157
|
+
}
|
|
158
|
+
get filterOptions() {
|
|
159
|
+
return this.parseOptionsAttribute("filter-options");
|
|
160
|
+
}
|
|
161
|
+
set filterOptions(value) {
|
|
162
|
+
this.setAttribute("filter-options", JSON.stringify(value));
|
|
163
|
+
}
|
|
164
|
+
get sortOptions() {
|
|
165
|
+
return this.parseOptionsAttribute("sort-options");
|
|
166
|
+
}
|
|
167
|
+
set sortOptions(value) {
|
|
168
|
+
this.setAttribute("sort-options", JSON.stringify(value));
|
|
169
|
+
}
|
|
170
|
+
get viewOptions() {
|
|
171
|
+
return this.parseOptionsAttribute("view-options");
|
|
172
|
+
}
|
|
173
|
+
set viewOptions(value) {
|
|
174
|
+
this.setAttribute("view-options", JSON.stringify(value));
|
|
175
|
+
}
|
|
176
|
+
connectedCallback() {
|
|
177
|
+
this.syncInternalStateFromAttributes();
|
|
178
|
+
super.connectedCallback();
|
|
179
|
+
}
|
|
180
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
181
|
+
this.syncInternalStateFromAttributes();
|
|
182
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
183
|
+
}
|
|
184
|
+
syncInternalStateFromAttributes() {
|
|
185
|
+
this.queryInternal = this.getAttribute("query") ?? "";
|
|
186
|
+
this.sortValueInternal = this.getAttribute("sort-value") ?? "";
|
|
187
|
+
this.viewValueInternal = this.getAttribute("view-value") ?? "";
|
|
188
|
+
const rawFilters = this.getAttribute("filters");
|
|
189
|
+
if (!rawFilters) {
|
|
190
|
+
this.filtersInternal = [];
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
const parsed = JSON.parse(rawFilters);
|
|
195
|
+
this.filtersInternal = Array.isArray(parsed) ? parsed : [];
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
this.filtersInternal = [];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
parseOptionsAttribute(name) {
|
|
202
|
+
const raw = this.getAttribute(name);
|
|
203
|
+
if (!raw) {
|
|
204
|
+
return [];
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
const parsed = JSON.parse(raw);
|
|
208
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return [];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
getState() {
|
|
215
|
+
return {
|
|
216
|
+
query: this.query,
|
|
217
|
+
sort: this.sortValue,
|
|
218
|
+
view: this.viewValue,
|
|
219
|
+
filters: this.filters,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
emitValueChanged() {
|
|
223
|
+
this.dispatchEvent(new CustomEvent("value-changed", {
|
|
224
|
+
bubbles: true,
|
|
225
|
+
composed: true,
|
|
226
|
+
detail: { value: this.getState() },
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
229
|
+
renderOptionList(options, selectedValue) {
|
|
230
|
+
return options
|
|
231
|
+
.map(option => `
|
|
232
|
+
<option value="${escapeHtml(option.value)}" ${selectedValue === option.value ? "selected" : ""}>
|
|
233
|
+
${escapeHtml(option.label)}
|
|
234
|
+
</option>
|
|
235
|
+
`)
|
|
236
|
+
.join("");
|
|
237
|
+
}
|
|
238
|
+
optionsKey() {
|
|
239
|
+
return JSON.stringify({
|
|
240
|
+
filterOptions: this.filterOptions,
|
|
241
|
+
sortOptions: this.sortOptions,
|
|
242
|
+
viewOptions: this.viewOptions,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
rebuildOptionControls() {
|
|
246
|
+
this.sortEl.innerHTML = this.renderOptionList(this.sortOptions, this.sortValue);
|
|
247
|
+
this.viewEl.innerHTML = this.renderOptionList(this.viewOptions, this.viewValue);
|
|
248
|
+
this.filtersEl.innerHTML = this.filterOptions
|
|
249
|
+
.map(option => {
|
|
250
|
+
const selected = this.filters.includes(option.value);
|
|
251
|
+
return `
|
|
252
|
+
<button
|
|
253
|
+
type="button"
|
|
254
|
+
part="filter-chip"
|
|
255
|
+
data-value="${escapeHtml(option.value)}"
|
|
256
|
+
aria-pressed="${String(selected)}"
|
|
257
|
+
data-selected="${String(selected)}"
|
|
258
|
+
>
|
|
259
|
+
${escapeHtml(option.label)}
|
|
260
|
+
</button>
|
|
261
|
+
`;
|
|
262
|
+
})
|
|
263
|
+
.join("");
|
|
264
|
+
}
|
|
265
|
+
patchChips() {
|
|
266
|
+
this.filtersEl.querySelectorAll('[part="filter-chip"]').forEach(button => {
|
|
267
|
+
const chip = button;
|
|
268
|
+
const selected = this.filters.includes(chip.dataset.value ?? "");
|
|
269
|
+
chip.setAttribute("aria-pressed", String(selected));
|
|
270
|
+
chip.dataset.selected = String(selected);
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
renderTemplate() {
|
|
274
|
+
if (!this.shadowRoot) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
this.shadowRoot.innerHTML = `
|
|
278
|
+
<style>${elementStyles}</style>
|
|
279
|
+
<section part="bar" aria-label="">
|
|
280
|
+
<div part="label"></div>
|
|
281
|
+
<div part="controls">
|
|
282
|
+
<label part="field">
|
|
283
|
+
<span part="field-label">Search</span>
|
|
284
|
+
<input type="search" part="input" placeholder="Search items" />
|
|
285
|
+
</label>
|
|
286
|
+
<label part="select-field">
|
|
287
|
+
<span part="field-label">Sort</span>
|
|
288
|
+
<select part="select" data-control="sort"></select>
|
|
289
|
+
</label>
|
|
290
|
+
<label part="select-field">
|
|
291
|
+
<span part="field-label">View</span>
|
|
292
|
+
<select part="select" data-control="view"></select>
|
|
293
|
+
</label>
|
|
294
|
+
</div>
|
|
295
|
+
<div part="filters"></div>
|
|
296
|
+
</section>
|
|
297
|
+
`;
|
|
298
|
+
this.barEl = this.shadowRoot.querySelector('[part="bar"]');
|
|
299
|
+
this.labelEl = this.shadowRoot.querySelector('[part="label"]');
|
|
300
|
+
this.inputEl = this.shadowRoot.querySelector('[part="input"]');
|
|
301
|
+
this.sortEl = this.shadowRoot.querySelector('[data-control="sort"]');
|
|
302
|
+
this.viewEl = this.shadowRoot.querySelector('[data-control="view"]');
|
|
303
|
+
this.filtersEl = this.shadowRoot.querySelector('[part="filters"]');
|
|
304
|
+
}
|
|
305
|
+
setupListeners() {
|
|
306
|
+
this.inputEl.addEventListener("input", event => {
|
|
307
|
+
this.queryInternal = event.currentTarget.value;
|
|
308
|
+
this.emitValueChanged();
|
|
309
|
+
});
|
|
310
|
+
this.inputEl.addEventListener("change", () => {
|
|
311
|
+
this.setAttribute("query", this.queryInternal);
|
|
312
|
+
this.dispatchEvent(new CustomEvent("search", {
|
|
313
|
+
bubbles: true,
|
|
314
|
+
composed: true,
|
|
315
|
+
detail: { value: this.getState() },
|
|
316
|
+
}));
|
|
317
|
+
});
|
|
318
|
+
this.sortEl.addEventListener("change", event => {
|
|
319
|
+
const element = event.currentTarget;
|
|
320
|
+
this.sortValueInternal = element.value;
|
|
321
|
+
this.setAttribute("sort-value", element.value);
|
|
322
|
+
this.emitValueChanged();
|
|
323
|
+
});
|
|
324
|
+
this.viewEl.addEventListener("change", event => {
|
|
325
|
+
const element = event.currentTarget;
|
|
326
|
+
this.viewValueInternal = element.value;
|
|
327
|
+
this.setAttribute("view-value", element.value);
|
|
328
|
+
this.emitValueChanged();
|
|
329
|
+
});
|
|
330
|
+
this.filtersEl.addEventListener("click", event => {
|
|
331
|
+
const button = event.target.closest('[part="filter-chip"]');
|
|
332
|
+
if (!button || !this.filtersEl.contains(button)) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const value = button.dataset.value ?? "";
|
|
336
|
+
if (!value) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
const nextFilters = this.filters.includes(value)
|
|
340
|
+
? this.filters.filter(entry => entry !== value)
|
|
341
|
+
: [...this.filters, value];
|
|
342
|
+
this.filtersInternal = nextFilters;
|
|
343
|
+
this.setAttribute("filters", JSON.stringify(nextFilters));
|
|
344
|
+
this.emitValueChanged();
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
update() {
|
|
348
|
+
if (!this.labelEl || !this.inputEl) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
this.labelEl.textContent = this.label;
|
|
352
|
+
this.barEl.setAttribute("aria-label", this.label);
|
|
353
|
+
const active = this.shadowRoot?.activeElement;
|
|
354
|
+
if (active !== this.inputEl) {
|
|
355
|
+
this.inputEl.value = this.query;
|
|
356
|
+
}
|
|
357
|
+
if (active !== this.sortEl) {
|
|
358
|
+
this.sortEl.value = this.sortValue;
|
|
359
|
+
}
|
|
360
|
+
if (active !== this.viewEl) {
|
|
361
|
+
this.viewEl.value = this.viewValue;
|
|
362
|
+
}
|
|
363
|
+
const nextOptions = this.optionsKey();
|
|
364
|
+
if (nextOptions !== this.optionsSignature) {
|
|
365
|
+
this.optionsSignature = nextOptions;
|
|
366
|
+
this.rebuildOptionControls();
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
this.patchChips();
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
export const defineBoxFilterBarElement = (tagName = DEFAULT_TAG_NAME) => {
|
|
373
|
+
const existingElement = customElements.get(tagName);
|
|
374
|
+
if (existingElement) {
|
|
375
|
+
return existingElement;
|
|
376
|
+
}
|
|
377
|
+
customElements.define(tagName, BoxFilterBarElement);
|
|
378
|
+
return BoxFilterBarElement;
|
|
379
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
type SavedView = {
|
|
3
|
+
description?: string;
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
resultCount?: number;
|
|
7
|
+
};
|
|
8
|
+
export declare class BoxSavedViewPickerElement extends BaseElement {
|
|
9
|
+
static get observedAttributes(): string[];
|
|
10
|
+
private valueInternal;
|
|
11
|
+
get label(): string;
|
|
12
|
+
set label(value: string);
|
|
13
|
+
get value(): string;
|
|
14
|
+
set value(value: string);
|
|
15
|
+
get views(): SavedView[];
|
|
16
|
+
set views(value: SavedView[]);
|
|
17
|
+
connectedCallback(): void;
|
|
18
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
19
|
+
private parseJsonAttribute;
|
|
20
|
+
private emitValueChanged;
|
|
21
|
+
protected renderTemplate(): void;
|
|
22
|
+
protected update(): void;
|
|
23
|
+
}
|
|
24
|
+
export declare const defineBoxSavedViewPickerElement: (tagName?: string) => typeof BoxSavedViewPickerElement;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
import { applyRovingTabindex, handleRovingKeydown } from "../../foundations/a11y/index.js";
|
|
3
|
+
import { boeNeutralInteractiveStyles } from "../../foundations/tokens/index.js";
|
|
4
|
+
import { boePanel, boeRadius } from "../../foundations/geometry/index.js";
|
|
5
|
+
const DEFAULT_TAG_NAME = "box-saved-view-picker";
|
|
6
|
+
const escapeHtml = (value) => value
|
|
7
|
+
.replaceAll("&", "&")
|
|
8
|
+
.replaceAll("<", "<")
|
|
9
|
+
.replaceAll(">", ">")
|
|
10
|
+
.replaceAll('"', """)
|
|
11
|
+
.replaceAll("'", "'");
|
|
12
|
+
const elementStyles = `
|
|
13
|
+
:host {
|
|
14
|
+
display: block;
|
|
15
|
+
color: inherit;
|
|
16
|
+
font: inherit;
|
|
17
|
+
--_obp-surface: var(--boe-token-surface-surface, #ffffff);
|
|
18
|
+
--_obp-surface-muted: var(--boe-token-surface-surface-secondary, #fbfbfb);
|
|
19
|
+
--_obp-border: color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 82%, transparent);
|
|
20
|
+
--_obp-border-subtle: color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 58%, transparent);
|
|
21
|
+
--_obp-text-muted: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
22
|
+
--_obp-brand: var(--boe-token-surface-surface-brand, #0061d5);
|
|
23
|
+
--_obp-brand-soft: color-mix(in srgb, var(--_obp-brand) 12%, var(--boe-token-surface-surface, #ffffff) 88%);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
[part="picker"] {
|
|
27
|
+
display: grid;
|
|
28
|
+
gap: ${boePanel.gap};
|
|
29
|
+
padding: ${boePanel.padding};
|
|
30
|
+
border: 1px solid var(--_obp-border);
|
|
31
|
+
border-radius: ${boePanel.radius};
|
|
32
|
+
background: var(--_obp-surface-muted);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
[part="label"] {
|
|
36
|
+
font-size: 0.8rem;
|
|
37
|
+
font-weight: 700;
|
|
38
|
+
letter-spacing: 0.08em;
|
|
39
|
+
text-transform: uppercase;
|
|
40
|
+
color: var(--_obp-brand);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
[part="views"] {
|
|
44
|
+
display: grid;
|
|
45
|
+
gap: ${boePanel.gap};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[part="view"] {
|
|
49
|
+
display: grid;
|
|
50
|
+
gap: 0.3rem;
|
|
51
|
+
width: 100%;
|
|
52
|
+
text-align: left;
|
|
53
|
+
border: 1px solid var(--_obp-border-subtle);
|
|
54
|
+
border-radius: ${boeRadius.med};
|
|
55
|
+
padding: 0.55rem 0.7rem;
|
|
56
|
+
background: var(--_obp-surface);
|
|
57
|
+
color: inherit;
|
|
58
|
+
font: inherit;
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
${boeNeutralInteractiveStyles('[part="view"]')}
|
|
63
|
+
|
|
64
|
+
[part="view"][data-selected="true"],
|
|
65
|
+
[part="view"][data-selected="true"]:hover:not(:disabled) {
|
|
66
|
+
border-color: color-mix(in srgb, var(--_obp-brand) 34%, transparent);
|
|
67
|
+
background: var(--_obp-brand-soft);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
[part="view-label"] {
|
|
71
|
+
font-weight: 700;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
[part="view-description"] {
|
|
75
|
+
color: var(--_obp-text-muted);
|
|
76
|
+
line-height: 1.45;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
[part="view-count"] {
|
|
80
|
+
color: var(--_obp-text-muted);
|
|
81
|
+
font-size: 0.88rem;
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
export class BoxSavedViewPickerElement extends BaseElement {
|
|
85
|
+
static get observedAttributes() {
|
|
86
|
+
return ["label", "value", "views"];
|
|
87
|
+
}
|
|
88
|
+
valueInternal = "";
|
|
89
|
+
get label() {
|
|
90
|
+
return this.getAttribute("label") ?? "Saved Views";
|
|
91
|
+
}
|
|
92
|
+
set label(value) {
|
|
93
|
+
this.setAttribute("label", value);
|
|
94
|
+
}
|
|
95
|
+
get value() {
|
|
96
|
+
return this.valueInternal;
|
|
97
|
+
}
|
|
98
|
+
set value(value) {
|
|
99
|
+
this.valueInternal = value;
|
|
100
|
+
this.setAttribute("value", value);
|
|
101
|
+
if (this.isRendered) {
|
|
102
|
+
this.update();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
get views() {
|
|
106
|
+
return this.parseJsonAttribute("views", []);
|
|
107
|
+
}
|
|
108
|
+
set views(value) {
|
|
109
|
+
this.setAttribute("views", JSON.stringify(value));
|
|
110
|
+
}
|
|
111
|
+
connectedCallback() {
|
|
112
|
+
this.valueInternal = this.getAttribute("value") ?? "";
|
|
113
|
+
super.connectedCallback();
|
|
114
|
+
}
|
|
115
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
116
|
+
if (name === "value") {
|
|
117
|
+
this.valueInternal = this.getAttribute("value") ?? "";
|
|
118
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
119
|
+
}
|
|
120
|
+
if (this.isRendered) {
|
|
121
|
+
this.update();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
parseJsonAttribute(name, fallback) {
|
|
125
|
+
const raw = this.getAttribute(name);
|
|
126
|
+
if (!raw) {
|
|
127
|
+
return fallback;
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
return JSON.parse(raw);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
return fallback;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
emitValueChanged() {
|
|
137
|
+
this.dispatchEvent(new CustomEvent("value-changed", {
|
|
138
|
+
bubbles: true,
|
|
139
|
+
composed: true,
|
|
140
|
+
detail: { value: this.valueInternal },
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
renderTemplate() {
|
|
144
|
+
if (!this.shadowRoot) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
this.shadowRoot.innerHTML = `
|
|
148
|
+
<style>${elementStyles}</style>
|
|
149
|
+
<div part="content-host"></div>
|
|
150
|
+
`;
|
|
151
|
+
}
|
|
152
|
+
update() {
|
|
153
|
+
if (!this.shadowRoot) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const host = this.shadowRoot.querySelector('[part="content-host"]');
|
|
157
|
+
if (!host) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
host.innerHTML = `
|
|
161
|
+
<section part="picker" role="radiogroup" aria-label="${escapeHtml(this.label)}">
|
|
162
|
+
<div part="label">${escapeHtml(this.label)}</div>
|
|
163
|
+
<div part="views">
|
|
164
|
+
${this.views
|
|
165
|
+
.map(view => `
|
|
166
|
+
<button
|
|
167
|
+
type="button"
|
|
168
|
+
part="view"
|
|
169
|
+
role="radio"
|
|
170
|
+
aria-checked="${String(this.value === view.id)}"
|
|
171
|
+
data-view-id="${escapeHtml(view.id)}"
|
|
172
|
+
data-selected="${String(this.value === view.id)}"
|
|
173
|
+
>
|
|
174
|
+
<div part="view-label">${escapeHtml(view.label)}</div>
|
|
175
|
+
${view.description ? `<div part="view-description">${escapeHtml(view.description)}</div>` : ""}
|
|
176
|
+
${typeof view.resultCount === "number" ? `<div part="view-count">${escapeHtml(`${view.resultCount} results`)}</div>` : ""}
|
|
177
|
+
</button>
|
|
178
|
+
`)
|
|
179
|
+
.join("")}
|
|
180
|
+
</div>
|
|
181
|
+
</section>
|
|
182
|
+
`;
|
|
183
|
+
const views = Array.from(this.shadowRoot.querySelectorAll('[part="view"]'));
|
|
184
|
+
const selectedIndex = Math.max(0, views.findIndex(button => button.getAttribute("data-view-id") === this.valueInternal));
|
|
185
|
+
applyRovingTabindex(views, selectedIndex);
|
|
186
|
+
const focusView = (viewId) => {
|
|
187
|
+
queueMicrotask(() => {
|
|
188
|
+
const match = Array.from(this.shadowRoot?.querySelectorAll('[part="view"]') ?? []).find(button => button.getAttribute("data-view-id") === viewId);
|
|
189
|
+
match?.focus();
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
const selectView = (nextValue, restoreFocus = false) => {
|
|
193
|
+
if (!nextValue || nextValue === this.valueInternal) {
|
|
194
|
+
if (restoreFocus) {
|
|
195
|
+
focusView(nextValue);
|
|
196
|
+
}
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
this.valueInternal = nextValue;
|
|
200
|
+
this.setAttribute("value", nextValue);
|
|
201
|
+
this.emitValueChanged();
|
|
202
|
+
// `update()` rebuilds the view buttons; restore focus onto the new node.
|
|
203
|
+
if (restoreFocus) {
|
|
204
|
+
focusView(nextValue);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
views.forEach(button => {
|
|
208
|
+
button.addEventListener("click", () => {
|
|
209
|
+
selectView(button.getAttribute("data-view-id") ?? "");
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
this.shadowRoot.querySelector('[part="views"]')?.addEventListener("keydown", event => {
|
|
213
|
+
const keyboardEvent = event;
|
|
214
|
+
// APG radiogroup: Arrow/Home/End move focus and select the newly focused view.
|
|
215
|
+
if (handleRovingKeydown(keyboardEvent, views, { orientation: "both" })) {
|
|
216
|
+
const focused = views.find(button => button.tabIndex === 0);
|
|
217
|
+
selectView(focused?.getAttribute("data-view-id") ?? "", true);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (keyboardEvent.key !== "Enter" && keyboardEvent.key !== " ") {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const button = keyboardEvent.target.closest('[part="view"]');
|
|
224
|
+
if (!button) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
keyboardEvent.preventDefault();
|
|
228
|
+
selectView(button.getAttribute("data-view-id") ?? "", true);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
export const defineBoxSavedViewPickerElement = (tagName = DEFAULT_TAG_NAME) => {
|
|
233
|
+
const existingElement = customElements.get(tagName);
|
|
234
|
+
if (existingElement) {
|
|
235
|
+
return existingElement;
|
|
236
|
+
}
|
|
237
|
+
customElements.define(tagName, BoxSavedViewPickerElement);
|
|
238
|
+
return BoxSavedViewPickerElement;
|
|
239
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
type SearchHeaderAction = {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
tone?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class BoxSearchResultsHeaderElement extends BaseElement {
|
|
8
|
+
static get observedAttributes(): string[];
|
|
9
|
+
get actions(): SearchHeaderAction[];
|
|
10
|
+
set actions(value: SearchHeaderAction[]);
|
|
11
|
+
get filters(): string[];
|
|
12
|
+
set filters(value: string[]);
|
|
13
|
+
get label(): string;
|
|
14
|
+
set label(value: string);
|
|
15
|
+
get query(): string;
|
|
16
|
+
set query(value: string);
|
|
17
|
+
get resultCount(): number;
|
|
18
|
+
set resultCount(value: number);
|
|
19
|
+
get scope(): string;
|
|
20
|
+
set scope(value: string);
|
|
21
|
+
get sortLabel(): string;
|
|
22
|
+
set sortLabel(value: string);
|
|
23
|
+
get viewLabel(): string;
|
|
24
|
+
set viewLabel(value: string);
|
|
25
|
+
connectedCallback(): void;
|
|
26
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
27
|
+
private parseJsonAttribute;
|
|
28
|
+
private emitAction;
|
|
29
|
+
private emitFilterRemoved;
|
|
30
|
+
protected renderTemplate(): void;
|
|
31
|
+
protected update(): void;
|
|
32
|
+
}
|
|
33
|
+
export declare const defineBoxSearchResultsHeaderElement: (tagName?: string) => typeof BoxSearchResultsHeaderElement;
|
|
34
|
+
export {};
|