@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,362 @@
|
|
|
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-metadata-filter-builder";
|
|
5
|
+
const escapeHtml = (value) => value
|
|
6
|
+
.replaceAll("&", "&")
|
|
7
|
+
.replaceAll("<", "<")
|
|
8
|
+
.replaceAll(">", ">")
|
|
9
|
+
.replaceAll('"', """)
|
|
10
|
+
.replaceAll("'", "'");
|
|
11
|
+
const DEFAULT_OPERATORS = [
|
|
12
|
+
{ label: "is", value: "is" },
|
|
13
|
+
{ label: "is not", value: "is-not" },
|
|
14
|
+
{ label: "contains", value: "contains" },
|
|
15
|
+
];
|
|
16
|
+
const builderStyles = `
|
|
17
|
+
:host {
|
|
18
|
+
display: block;
|
|
19
|
+
color: inherit;
|
|
20
|
+
font: inherit;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[part="builder"] {
|
|
24
|
+
display: grid;
|
|
25
|
+
gap: ${boePanel.gap};
|
|
26
|
+
padding: ${boePanel.padding};
|
|
27
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 82%, transparent);
|
|
28
|
+
border-radius: ${boePanel.radius};
|
|
29
|
+
background: ${boePanel.background};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[part="label"] {
|
|
33
|
+
font-size: 0.8rem;
|
|
34
|
+
font-weight: 700;
|
|
35
|
+
letter-spacing: 0.08em;
|
|
36
|
+
text-transform: uppercase;
|
|
37
|
+
color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
[part="rules"] {
|
|
41
|
+
display: grid;
|
|
42
|
+
gap: ${boePanel.gap};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[part="rule"] {
|
|
46
|
+
display: grid;
|
|
47
|
+
grid-template-columns: minmax(10rem, 1fr) minmax(8rem, 0.8fr) minmax(12rem, 1.2fr) auto;
|
|
48
|
+
gap: ${boePanel.gap};
|
|
49
|
+
align-items: center;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
[part="select"],
|
|
53
|
+
[part="input"] {
|
|
54
|
+
width: 100%;
|
|
55
|
+
min-width: 0;
|
|
56
|
+
padding: 0.45rem 0.7rem;
|
|
57
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 64%, transparent);
|
|
58
|
+
border-radius: ${boeRadius.control};
|
|
59
|
+
background: var(--boe-token-surface-surface, #ffffff);
|
|
60
|
+
color: inherit;
|
|
61
|
+
font: inherit;
|
|
62
|
+
box-sizing: border-box;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
[part="add"],
|
|
66
|
+
[part="remove"] {
|
|
67
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 64%, transparent);
|
|
68
|
+
border-radius: 999px;
|
|
69
|
+
padding: 0.4rem 0.7rem;
|
|
70
|
+
background: var(--boe-token-surface-surface, #ffffff);
|
|
71
|
+
color: inherit;
|
|
72
|
+
font: inherit;
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
[part="empty"] {
|
|
77
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
78
|
+
line-height: 1.5;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
${boeNeutralInteractiveStyles('[part="select"]')}
|
|
82
|
+
${boeNeutralInteractiveStyles('[part="input"]')}
|
|
83
|
+
${boeNeutralInteractiveStyles('[part="add"]')}
|
|
84
|
+
${boeNeutralInteractiveStyles('[part="remove"]')}
|
|
85
|
+
|
|
86
|
+
[part="add"],
|
|
87
|
+
[part="add"]:hover:not(:disabled) {
|
|
88
|
+
width: fit-content;
|
|
89
|
+
border-color: rgba(0, 97, 213, 0.28);
|
|
90
|
+
background: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 12%, var(--boe-token-surface-surface, #ffffff) 88%);
|
|
91
|
+
color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@media (max-width: 860px) {
|
|
95
|
+
[part="rule"] {
|
|
96
|
+
grid-template-columns: 1fr;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
100
|
+
export class BoxMetadataFilterBuilderElement extends BaseElement {
|
|
101
|
+
static get observedAttributes() {
|
|
102
|
+
return ["fields", "label", "rules"];
|
|
103
|
+
}
|
|
104
|
+
rulesInternal = [];
|
|
105
|
+
syncingFromUi = false;
|
|
106
|
+
labelEl;
|
|
107
|
+
rulesEl;
|
|
108
|
+
structureSignature = "";
|
|
109
|
+
get fields() {
|
|
110
|
+
return this.parseJsonAttribute("fields", []);
|
|
111
|
+
}
|
|
112
|
+
set fields(value) {
|
|
113
|
+
this.setAttribute("fields", JSON.stringify(value));
|
|
114
|
+
}
|
|
115
|
+
get label() {
|
|
116
|
+
return this.getAttribute("label") ?? "Metadata Filters";
|
|
117
|
+
}
|
|
118
|
+
set label(value) {
|
|
119
|
+
this.setAttribute("label", value);
|
|
120
|
+
}
|
|
121
|
+
get rules() {
|
|
122
|
+
return [...this.rulesInternal];
|
|
123
|
+
}
|
|
124
|
+
set rules(value) {
|
|
125
|
+
this.rulesInternal = [...value];
|
|
126
|
+
this.setAttribute("rules", JSON.stringify(value));
|
|
127
|
+
if (this.isRendered) {
|
|
128
|
+
this.update();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
connectedCallback() {
|
|
132
|
+
this.syncRulesFromAttributes();
|
|
133
|
+
super.connectedCallback();
|
|
134
|
+
}
|
|
135
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
136
|
+
if (name === "rules" && !this.syncingFromUi) {
|
|
137
|
+
this.syncRulesFromAttributes();
|
|
138
|
+
}
|
|
139
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
140
|
+
}
|
|
141
|
+
parseJsonAttribute(name, fallback) {
|
|
142
|
+
const raw = this.getAttribute(name);
|
|
143
|
+
if (!raw) {
|
|
144
|
+
return fallback;
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
return JSON.parse(raw);
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
return fallback;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
syncRulesFromAttributes() {
|
|
154
|
+
this.rulesInternal = this.parseJsonAttribute("rules", []);
|
|
155
|
+
}
|
|
156
|
+
emitValueChanged() {
|
|
157
|
+
this.dispatchEvent(new CustomEvent("value-changed", {
|
|
158
|
+
bubbles: true,
|
|
159
|
+
composed: true,
|
|
160
|
+
detail: { value: [...this.rulesInternal] },
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
writeRulesAttribute() {
|
|
164
|
+
this.syncingFromUi = true;
|
|
165
|
+
this.setAttribute("rules", JSON.stringify(this.rulesInternal));
|
|
166
|
+
this.syncingFromUi = false;
|
|
167
|
+
}
|
|
168
|
+
updateRule(index, patch) {
|
|
169
|
+
this.rulesInternal = this.rulesInternal.map((rule, ruleIndex) => ruleIndex === index
|
|
170
|
+
? {
|
|
171
|
+
...rule,
|
|
172
|
+
...patch,
|
|
173
|
+
}
|
|
174
|
+
: rule);
|
|
175
|
+
this.writeRulesAttribute();
|
|
176
|
+
this.emitValueChanged();
|
|
177
|
+
// Structure-only changes go through add/remove. Field/operator/value edits are
|
|
178
|
+
// patched in place by update() so the focused control is not remounted.
|
|
179
|
+
}
|
|
180
|
+
addRule() {
|
|
181
|
+
const defaultField = this.fields[0]?.id ?? "";
|
|
182
|
+
this.rulesInternal = [
|
|
183
|
+
...this.rulesInternal,
|
|
184
|
+
{
|
|
185
|
+
field: defaultField,
|
|
186
|
+
operator: DEFAULT_OPERATORS[0].value,
|
|
187
|
+
value: "",
|
|
188
|
+
},
|
|
189
|
+
];
|
|
190
|
+
this.writeRulesAttribute();
|
|
191
|
+
this.dispatchEvent(new CustomEvent("rule-added", { bubbles: true, composed: true, detail: { count: this.rulesInternal.length } }));
|
|
192
|
+
this.emitValueChanged();
|
|
193
|
+
this.update();
|
|
194
|
+
}
|
|
195
|
+
removeRule(index) {
|
|
196
|
+
const removedRule = this.rulesInternal[index];
|
|
197
|
+
this.rulesInternal = this.rulesInternal.filter((_, ruleIndex) => ruleIndex !== index);
|
|
198
|
+
this.writeRulesAttribute();
|
|
199
|
+
this.dispatchEvent(new CustomEvent("rule-removed", {
|
|
200
|
+
bubbles: true,
|
|
201
|
+
composed: true,
|
|
202
|
+
detail: { index, rule: removedRule },
|
|
203
|
+
}));
|
|
204
|
+
this.emitValueChanged();
|
|
205
|
+
this.update();
|
|
206
|
+
}
|
|
207
|
+
renderFieldOptions(selectedValue) {
|
|
208
|
+
return this.fields
|
|
209
|
+
.map(field => `
|
|
210
|
+
<option value="${escapeHtml(field.id)}" ${field.id === selectedValue ? "selected" : ""}>
|
|
211
|
+
${escapeHtml(field.label)}
|
|
212
|
+
</option>
|
|
213
|
+
`)
|
|
214
|
+
.join("");
|
|
215
|
+
}
|
|
216
|
+
renderOperatorOptions(selectedValue) {
|
|
217
|
+
return DEFAULT_OPERATORS
|
|
218
|
+
.map(operator => `
|
|
219
|
+
<option value="${escapeHtml(operator.value)}" ${operator.value === selectedValue ? "selected" : ""}>
|
|
220
|
+
${escapeHtml(operator.label)}
|
|
221
|
+
</option>
|
|
222
|
+
`)
|
|
223
|
+
.join("");
|
|
224
|
+
}
|
|
225
|
+
renderRulesMarkup() {
|
|
226
|
+
if (!this.rulesInternal.length) {
|
|
227
|
+
return `<div part="empty">No metadata rules yet.</div>`;
|
|
228
|
+
}
|
|
229
|
+
return this.rulesInternal
|
|
230
|
+
.map((rule, index) => `
|
|
231
|
+
<div part="rule" data-rule-index="${index}">
|
|
232
|
+
<select part="select" data-rule-index="${index}" data-control="field">
|
|
233
|
+
${this.renderFieldOptions(rule.field)}
|
|
234
|
+
</select>
|
|
235
|
+
<select part="select" data-rule-index="${index}" data-control="operator">
|
|
236
|
+
${this.renderOperatorOptions(rule.operator)}
|
|
237
|
+
</select>
|
|
238
|
+
<input
|
|
239
|
+
type="text"
|
|
240
|
+
part="input"
|
|
241
|
+
data-rule-index="${index}"
|
|
242
|
+
value="${escapeHtml(rule.value)}"
|
|
243
|
+
placeholder="Enter metadata value"
|
|
244
|
+
/>
|
|
245
|
+
<button type="button" part="remove" data-rule-index="${index}">Remove</button>
|
|
246
|
+
</div>
|
|
247
|
+
`)
|
|
248
|
+
.join("");
|
|
249
|
+
}
|
|
250
|
+
structureKey() {
|
|
251
|
+
// Field/operator values are patched in place so select changes keep focus.
|
|
252
|
+
// Only add/remove (and fields catalog changes) are structural rebuilds.
|
|
253
|
+
return JSON.stringify({
|
|
254
|
+
fields: this.fields,
|
|
255
|
+
count: this.rulesInternal.length,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
patchRuleControls(index, active) {
|
|
259
|
+
const rule = this.rulesInternal[index];
|
|
260
|
+
if (!rule) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const fieldSelect = this.rulesEl.querySelector(`[data-control="field"][data-rule-index="${index}"]`);
|
|
264
|
+
const operatorSelect = this.rulesEl.querySelector(`[data-control="operator"][data-rule-index="${index}"]`);
|
|
265
|
+
// Set values in place — never rebuild option lists here (fields catalog changes
|
|
266
|
+
// already trigger a structural rebuild via structureKey).
|
|
267
|
+
if (fieldSelect && fieldSelect !== active && fieldSelect.value !== rule.field) {
|
|
268
|
+
fieldSelect.value = rule.field;
|
|
269
|
+
}
|
|
270
|
+
if (operatorSelect && operatorSelect !== active && operatorSelect.value !== rule.operator) {
|
|
271
|
+
operatorSelect.value = rule.operator;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
renderTemplate() {
|
|
275
|
+
if (!this.shadowRoot) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
this.shadowRoot.innerHTML = `
|
|
279
|
+
<style>${builderStyles}</style>
|
|
280
|
+
<section part="builder">
|
|
281
|
+
<div part="label"></div>
|
|
282
|
+
<div part="rules"></div>
|
|
283
|
+
<button type="button" part="add">Add rule</button>
|
|
284
|
+
</section>
|
|
285
|
+
`;
|
|
286
|
+
this.labelEl = this.shadowRoot.querySelector('[part="label"]');
|
|
287
|
+
this.rulesEl = this.shadowRoot.querySelector('[part="rules"]');
|
|
288
|
+
}
|
|
289
|
+
setupListeners() {
|
|
290
|
+
this.shadowRoot?.querySelector('[part="add"]')?.addEventListener("click", () => {
|
|
291
|
+
this.addRule();
|
|
292
|
+
});
|
|
293
|
+
this.rulesEl.addEventListener("change", event => {
|
|
294
|
+
const target = event.target;
|
|
295
|
+
if (target.getAttribute("part") !== "select") {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
const index = Number.parseInt(target.dataset.ruleIndex ?? "-1", 10);
|
|
299
|
+
const control = target.dataset.control;
|
|
300
|
+
if (index < 0) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (control === "field") {
|
|
304
|
+
this.updateRule(index, { field: target.value });
|
|
305
|
+
}
|
|
306
|
+
else if (control === "operator") {
|
|
307
|
+
this.updateRule(index, { operator: target.value });
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
this.rulesEl.addEventListener("input", event => {
|
|
311
|
+
const target = event.target;
|
|
312
|
+
if (target.getAttribute("part") !== "input") {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const index = Number.parseInt(target.dataset.ruleIndex ?? "-1", 10);
|
|
316
|
+
if (index < 0) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
this.updateRule(index, { value: target.value });
|
|
320
|
+
});
|
|
321
|
+
this.rulesEl.addEventListener("click", event => {
|
|
322
|
+
const button = event.target.closest('[part="remove"]');
|
|
323
|
+
if (!button || !this.rulesEl.contains(button)) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const index = Number.parseInt(button.dataset.ruleIndex ?? "-1", 10);
|
|
327
|
+
if (index < 0) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
this.removeRule(index);
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
update() {
|
|
334
|
+
if (!this.labelEl || !this.rulesEl) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
this.labelEl.textContent = this.label;
|
|
338
|
+
const nextSignature = this.structureKey();
|
|
339
|
+
if (nextSignature === this.structureSignature && this.rulesEl.childElementCount > 0) {
|
|
340
|
+
// Structure unchanged: patch unfocused controls only (external rules setter).
|
|
341
|
+
const active = this.shadowRoot?.activeElement;
|
|
342
|
+
this.rulesInternal.forEach((rule, index) => {
|
|
343
|
+
const input = this.rulesEl.querySelector(`[part="input"][data-rule-index="${index}"]`);
|
|
344
|
+
if (input && input !== active) {
|
|
345
|
+
input.value = rule.value;
|
|
346
|
+
}
|
|
347
|
+
this.patchRuleControls(index, active);
|
|
348
|
+
});
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
this.structureSignature = nextSignature;
|
|
352
|
+
this.rulesEl.innerHTML = this.renderRulesMarkup();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
export const defineBoxMetadataFilterBuilderElement = (tagName = DEFAULT_TAG_NAME) => {
|
|
356
|
+
const existingElement = customElements.get(tagName);
|
|
357
|
+
if (existingElement) {
|
|
358
|
+
return existingElement;
|
|
359
|
+
}
|
|
360
|
+
customElements.define(tagName, BoxMetadataFilterBuilderElement);
|
|
361
|
+
return BoxMetadataFilterBuilderElement;
|
|
362
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
type MetadataInspectorField = {
|
|
3
|
+
description?: string;
|
|
4
|
+
label: string;
|
|
5
|
+
tone?: string;
|
|
6
|
+
value: string;
|
|
7
|
+
};
|
|
8
|
+
type MetadataInspectorSection = {
|
|
9
|
+
fields: MetadataInspectorField[];
|
|
10
|
+
title: string;
|
|
11
|
+
};
|
|
12
|
+
export declare class BoxMetadataInspectorElement extends BaseElement {
|
|
13
|
+
static get observedAttributes(): string[];
|
|
14
|
+
get eyebrow(): string;
|
|
15
|
+
set eyebrow(value: string);
|
|
16
|
+
get message(): string;
|
|
17
|
+
set message(value: string);
|
|
18
|
+
get sections(): MetadataInspectorSection[];
|
|
19
|
+
set sections(value: MetadataInspectorSection[]);
|
|
20
|
+
get heading(): string;
|
|
21
|
+
set heading(value: string);
|
|
22
|
+
connectedCallback(): void;
|
|
23
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
24
|
+
private parseJsonAttribute;
|
|
25
|
+
private emitFieldSelected;
|
|
26
|
+
private renderSections;
|
|
27
|
+
protected renderTemplate(): void;
|
|
28
|
+
protected update(): void;
|
|
29
|
+
}
|
|
30
|
+
export declare const defineBoxMetadataInspectorElement: (tagName?: string) => typeof BoxMetadataInspectorElement;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
import { boeNeutralInteractiveStyles } from "../../foundations/tokens/index.js";
|
|
3
|
+
import { boePanel } from "../../foundations/geometry/index.js";
|
|
4
|
+
const DEFAULT_TAG_NAME = "box-metadata-inspector";
|
|
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
|
+
}
|
|
17
|
+
|
|
18
|
+
[part="inspector"] {
|
|
19
|
+
display: grid;
|
|
20
|
+
gap: ${boePanel.gap};
|
|
21
|
+
padding: ${boePanel.padding};
|
|
22
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 82%, transparent);
|
|
23
|
+
border-radius: ${boePanel.radius};
|
|
24
|
+
background: ${boePanel.background};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
[part="header"] {
|
|
28
|
+
display: grid;
|
|
29
|
+
gap: 0.45rem;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[part="eyebrow"] {
|
|
33
|
+
font-size: 0.8rem;
|
|
34
|
+
font-weight: 700;
|
|
35
|
+
letter-spacing: 0.08em;
|
|
36
|
+
text-transform: uppercase;
|
|
37
|
+
color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
[part="title"] {
|
|
41
|
+
font-size: 1.1rem;
|
|
42
|
+
font-weight: 700;
|
|
43
|
+
line-height: 1.15;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[part="message"] {
|
|
47
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
48
|
+
line-height: 1.55;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[part="section"] {
|
|
52
|
+
display: grid;
|
|
53
|
+
gap: ${boePanel.gap};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
[part="section-title"] {
|
|
57
|
+
font-size: 0.8rem;
|
|
58
|
+
font-weight: 700;
|
|
59
|
+
letter-spacing: 0.08em;
|
|
60
|
+
text-transform: uppercase;
|
|
61
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
[part="section-fields"] {
|
|
65
|
+
display: grid;
|
|
66
|
+
gap: ${boePanel.gap};
|
|
67
|
+
margin: 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
[part="field"] {
|
|
71
|
+
display: grid;
|
|
72
|
+
gap: 0.4rem;
|
|
73
|
+
width: 100%;
|
|
74
|
+
text-align: left;
|
|
75
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 56%, transparent);
|
|
76
|
+
border-radius: ${boePanel.radius};
|
|
77
|
+
padding: 0.55rem 0.65rem;
|
|
78
|
+
background: var(--boe-token-surface-surface, #ffffff);
|
|
79
|
+
color: inherit;
|
|
80
|
+
font: inherit;
|
|
81
|
+
cursor: pointer;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
${boeNeutralInteractiveStyles('[part="field"]')}
|
|
85
|
+
|
|
86
|
+
[part="field-header"] {
|
|
87
|
+
display: flex;
|
|
88
|
+
gap: ${boePanel.gap};
|
|
89
|
+
align-items: start;
|
|
90
|
+
justify-content: space-between;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[part="field-label"] {
|
|
94
|
+
margin: 0;
|
|
95
|
+
font-size: 0.84rem;
|
|
96
|
+
font-weight: 700;
|
|
97
|
+
letter-spacing: 0.06em;
|
|
98
|
+
text-transform: uppercase;
|
|
99
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
[part="field-value"] {
|
|
103
|
+
margin: 0;
|
|
104
|
+
font-weight: 600;
|
|
105
|
+
color: var(--boe-token-text-text, #1f1e1b);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
[part="field-value"][data-tone="accent"] {
|
|
109
|
+
color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
[part="field-value"][data-tone="success"] {
|
|
113
|
+
color: color-mix(in srgb, var(--boe-token-surface-status-surface-success, #26c281) 70%, var(--boe-token-text-text, #222222));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
[part="field-description"] {
|
|
117
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
118
|
+
line-height: 1.5;
|
|
119
|
+
}
|
|
120
|
+
`;
|
|
121
|
+
export class BoxMetadataInspectorElement extends BaseElement {
|
|
122
|
+
static get observedAttributes() {
|
|
123
|
+
return ["eyebrow", "heading", "message", "sections"];
|
|
124
|
+
}
|
|
125
|
+
get eyebrow() {
|
|
126
|
+
return this.getAttribute("eyebrow") ?? "";
|
|
127
|
+
}
|
|
128
|
+
set eyebrow(value) {
|
|
129
|
+
this.setAttribute("eyebrow", value);
|
|
130
|
+
}
|
|
131
|
+
get message() {
|
|
132
|
+
return this.getAttribute("message") ?? "";
|
|
133
|
+
}
|
|
134
|
+
set message(value) {
|
|
135
|
+
this.setAttribute("message", value);
|
|
136
|
+
}
|
|
137
|
+
get sections() {
|
|
138
|
+
return this.parseJsonAttribute("sections", []);
|
|
139
|
+
}
|
|
140
|
+
set sections(value) {
|
|
141
|
+
this.setAttribute("sections", JSON.stringify(value));
|
|
142
|
+
}
|
|
143
|
+
get heading() {
|
|
144
|
+
return this.getAttribute("heading") ?? "Metadata Inspector";
|
|
145
|
+
}
|
|
146
|
+
set heading(value) {
|
|
147
|
+
this.setAttribute("heading", value);
|
|
148
|
+
}
|
|
149
|
+
connectedCallback() {
|
|
150
|
+
super.connectedCallback();
|
|
151
|
+
}
|
|
152
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
153
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
154
|
+
}
|
|
155
|
+
parseJsonAttribute(name, fallback) {
|
|
156
|
+
const raw = this.getAttribute(name);
|
|
157
|
+
if (!raw) {
|
|
158
|
+
return fallback;
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
return JSON.parse(raw);
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
return fallback;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
emitFieldSelected(label, value, section) {
|
|
168
|
+
this.dispatchEvent(new CustomEvent("field-selected", {
|
|
169
|
+
bubbles: true,
|
|
170
|
+
composed: true,
|
|
171
|
+
detail: { label, section, value },
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
renderSections() {
|
|
175
|
+
return this.sections
|
|
176
|
+
.map(section => `
|
|
177
|
+
<section part="section">
|
|
178
|
+
<div part="section-title">${escapeHtml(section.title)}</div>
|
|
179
|
+
<dl part="section-fields">
|
|
180
|
+
${section.fields
|
|
181
|
+
.map(field => `
|
|
182
|
+
<button
|
|
183
|
+
type="button"
|
|
184
|
+
part="field"
|
|
185
|
+
data-field-label="${escapeHtml(field.label)}"
|
|
186
|
+
data-field-value="${escapeHtml(field.value)}"
|
|
187
|
+
data-field-section="${escapeHtml(section.title)}"
|
|
188
|
+
>
|
|
189
|
+
<div part="field-header">
|
|
190
|
+
<dt part="field-label">${escapeHtml(field.label)}</dt>
|
|
191
|
+
<dd part="field-value" data-tone="${escapeHtml(field.tone ?? "neutral")}">${escapeHtml(field.value)}</dd>
|
|
192
|
+
</div>
|
|
193
|
+
${field.description ? `<div part="field-description">${escapeHtml(field.description)}</div>` : ""}
|
|
194
|
+
</button>
|
|
195
|
+
`)
|
|
196
|
+
.join("")}
|
|
197
|
+
</dl>
|
|
198
|
+
</section>
|
|
199
|
+
`)
|
|
200
|
+
.join("");
|
|
201
|
+
}
|
|
202
|
+
renderTemplate() {
|
|
203
|
+
if (!this.shadowRoot) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
this.shadowRoot.innerHTML = `
|
|
207
|
+
<style>${elementStyles}</style>
|
|
208
|
+
<div part="content-host"></div>
|
|
209
|
+
`;
|
|
210
|
+
}
|
|
211
|
+
update() {
|
|
212
|
+
if (!this.shadowRoot) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const eyebrowMarkup = this.eyebrow ? `<div part="eyebrow">${escapeHtml(this.eyebrow)}</div>` : "";
|
|
216
|
+
const messageMarkup = this.message ? `<div part="message">${escapeHtml(this.message)}</div>` : "";
|
|
217
|
+
const host = this.shadowRoot.querySelector('[part="content-host"]');
|
|
218
|
+
if (!host) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
host.innerHTML = `
|
|
222
|
+
<section part="inspector">
|
|
223
|
+
<header part="header">
|
|
224
|
+
${eyebrowMarkup}
|
|
225
|
+
<h2 part="title">${escapeHtml(this.heading)}</h2>
|
|
226
|
+
${messageMarkup}
|
|
227
|
+
</header>
|
|
228
|
+
${this.renderSections()}
|
|
229
|
+
</section>
|
|
230
|
+
`;
|
|
231
|
+
this.shadowRoot.querySelectorAll('[part="field"]').forEach(field => {
|
|
232
|
+
field.addEventListener("click", () => {
|
|
233
|
+
this.emitFieldSelected(field.dataset.fieldLabel ?? "", field.dataset.fieldValue ?? "", field.dataset.fieldSection ?? "");
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
export const defineBoxMetadataInspectorElement = (tagName = DEFAULT_TAG_NAME) => {
|
|
239
|
+
const existingElement = customElements.get(tagName);
|
|
240
|
+
if (existingElement) {
|
|
241
|
+
return existingElement;
|
|
242
|
+
}
|
|
243
|
+
customElements.define(tagName, BoxMetadataInspectorElement);
|
|
244
|
+
return BoxMetadataInspectorElement;
|
|
245
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { JsonSchema } from "../../core/json-schema.js";
|
|
2
|
+
export declare const metadataFieldDefinitionSchema: JsonSchema;
|
|
3
|
+
export declare const metadataTemplateDefinitionSchema: JsonSchema;
|
|
4
|
+
export declare const metadataInstanceSchema: JsonSchema;
|
|
5
|
+
export declare const metadataPageSchema: JsonSchema;
|