@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,745 @@
|
|
|
1
|
+
import { ContentExplorerController } from "./controller.js";
|
|
2
|
+
import { resolveExplorerItemGesture, shouldActivateOnClick, shouldToggleOnEnter, } from "./types.js";
|
|
3
|
+
import { formatItemMetaLine } from "./adapters/item-summary.js";
|
|
4
|
+
import { defineBoxSearchResultsHeaderElement, } from "../search/search-results-header.js";
|
|
5
|
+
import { BaseElement } from "../../core/index.js";
|
|
6
|
+
import { boeMotionDuration, boeMotionEasing } from "../../foundations/motion/index.js";
|
|
7
|
+
import { boePanel, boeRadius } from "../../foundations/geometry/index.js";
|
|
8
|
+
const DEFAULT_TAG_NAME = "box-content-explorer";
|
|
9
|
+
const toKebabCase = (value) => value.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);
|
|
10
|
+
const escapeHtml = (value) => value
|
|
11
|
+
.replaceAll("&", "&")
|
|
12
|
+
.replaceAll("<", "<")
|
|
13
|
+
.replaceAll(">", ">")
|
|
14
|
+
.replaceAll('"', """)
|
|
15
|
+
.replaceAll("'", "'");
|
|
16
|
+
const toAttributeString = (attributes) => Object.entries(attributes)
|
|
17
|
+
.map(([name, value]) => `${name}="${escapeHtml(value)}"`)
|
|
18
|
+
.join(" ");
|
|
19
|
+
const readPositiveNumber = (value) => {
|
|
20
|
+
if (!value) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
const parsed = Number.parseInt(value, 10);
|
|
24
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
|
|
25
|
+
};
|
|
26
|
+
const elementStyles = `
|
|
27
|
+
:host {
|
|
28
|
+
display: block;
|
|
29
|
+
color: inherit;
|
|
30
|
+
font: inherit;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
section {
|
|
34
|
+
display: grid;
|
|
35
|
+
gap: ${boePanel.gap};
|
|
36
|
+
padding: ${boePanel.padding};
|
|
37
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 82%, transparent);
|
|
38
|
+
border-radius: ${boePanel.radius};
|
|
39
|
+
background: var(--boe-token-surface-surface, #ffffff);
|
|
40
|
+
transition: opacity ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
section[aria-busy="true"] {
|
|
44
|
+
opacity: 0.65;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[part="folder"] {
|
|
48
|
+
display: grid;
|
|
49
|
+
gap: 0.35rem;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
[part="folder"] h2 {
|
|
53
|
+
margin: 0;
|
|
54
|
+
font-size: 1.1rem;
|
|
55
|
+
font-weight: 700;
|
|
56
|
+
line-height: 1.2;
|
|
57
|
+
color: var(--boe-token-text-text, #222222);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
[part="folder"] p {
|
|
61
|
+
margin: 0;
|
|
62
|
+
font-size: 0.8rem;
|
|
63
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
[part="breadcrumbs"] {
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-wrap: wrap;
|
|
69
|
+
align-items: center;
|
|
70
|
+
gap: 0.2rem;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
[part="breadcrumb"] {
|
|
74
|
+
appearance: none;
|
|
75
|
+
font: inherit;
|
|
76
|
+
font-size: 0.875rem;
|
|
77
|
+
padding: 0.25rem 0.55rem;
|
|
78
|
+
border: none;
|
|
79
|
+
border-radius: ${boeRadius.med};
|
|
80
|
+
background: transparent;
|
|
81
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
transition: background ${boeMotionDuration.interactive} ${boeMotionEasing.standard}, color ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
[part="breadcrumb"]:hover {
|
|
87
|
+
background: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 8%, transparent);
|
|
88
|
+
color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
[part="breadcrumb"]:focus-visible {
|
|
92
|
+
outline: none;
|
|
93
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 18%, transparent);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
[part="breadcrumb-separator"] {
|
|
97
|
+
color: color-mix(in srgb, var(--boe-token-text-text-secondary, #6f6f6f) 55%, transparent);
|
|
98
|
+
font-size: 0.875rem;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
[part="status"] {
|
|
102
|
+
margin: 0;
|
|
103
|
+
font-size: 0.8rem;
|
|
104
|
+
font-weight: 700;
|
|
105
|
+
letter-spacing: 0.08em;
|
|
106
|
+
text-transform: uppercase;
|
|
107
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
[part="error"] {
|
|
111
|
+
margin: 0;
|
|
112
|
+
padding: 0.55rem 0.7rem;
|
|
113
|
+
border-radius: ${boeRadius.large};
|
|
114
|
+
font-size: 0.9rem;
|
|
115
|
+
background: color-mix(in srgb, var(--boe-token-surface-status-surface-error, #ed3757) 10%, var(--boe-token-surface-surface, #ffffff));
|
|
116
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-surface-status-surface-error, #ed3757) 34%, transparent);
|
|
117
|
+
color: color-mix(in srgb, var(--boe-token-surface-status-surface-error, #ed3757) 72%, black 28%);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
[part="refresh"],
|
|
121
|
+
[part="load-more"],
|
|
122
|
+
[part="item-action"] {
|
|
123
|
+
appearance: none;
|
|
124
|
+
font: inherit;
|
|
125
|
+
font-size: 0.875rem;
|
|
126
|
+
font-weight: 600;
|
|
127
|
+
padding: 0.4rem 0.7rem;
|
|
128
|
+
border-radius: ${boeRadius.control};
|
|
129
|
+
border: 1px solid var(--boe-token-stroke-stroke, #e8e8e8);
|
|
130
|
+
background: var(--boe-token-surface-surface, #ffffff);
|
|
131
|
+
color: var(--boe-token-text-text, #222222);
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
transition: background ${boeMotionDuration.interactive} ${boeMotionEasing.standard}, border-color ${boeMotionDuration.interactive} ${boeMotionEasing.standard}, box-shadow ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
[part="refresh"] {
|
|
137
|
+
justify-self: start;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
[part="refresh"]:hover:not(:disabled),
|
|
141
|
+
[part="load-more"]:hover,
|
|
142
|
+
[part="item-action"]:hover {
|
|
143
|
+
background: var(--boe-token-surface-surface-hover, #f4f4f4);
|
|
144
|
+
border-color: var(--boe-token-stroke-stroke-hover, #bcbcbc);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
[part="refresh"]:focus-visible,
|
|
148
|
+
[part="load-more"]:focus-visible,
|
|
149
|
+
[part="item-action"]:focus-visible {
|
|
150
|
+
outline: none;
|
|
151
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 18%, transparent);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
[part="refresh"]:disabled {
|
|
155
|
+
cursor: not-allowed;
|
|
156
|
+
opacity: 0.55;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
[part="items"] {
|
|
160
|
+
list-style: none;
|
|
161
|
+
margin: 0;
|
|
162
|
+
padding: 0;
|
|
163
|
+
display: grid;
|
|
164
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 62%, transparent);
|
|
165
|
+
border-radius: ${boePanel.radius};
|
|
166
|
+
overflow: hidden;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
[part="items"] > li {
|
|
170
|
+
display: flex;
|
|
171
|
+
align-items: center;
|
|
172
|
+
justify-content: space-between;
|
|
173
|
+
gap: ${boePanel.gap};
|
|
174
|
+
padding: 0.15rem 0.45rem;
|
|
175
|
+
background: var(--boe-token-surface-surface, #ffffff);
|
|
176
|
+
transition: background ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
[part="items"] > li + li {
|
|
180
|
+
border-top: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 46%, transparent);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
[part="items"] > li:hover {
|
|
184
|
+
background: var(--boe-token-surface-surface-hover, #f4f4f4);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
[part="items"] > li:has([part="item"][aria-selected="true"]) {
|
|
188
|
+
background: var(--boe-token-surface-item-surface-selected, #f2f7fd);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
[part="item"] {
|
|
192
|
+
appearance: none;
|
|
193
|
+
font: inherit;
|
|
194
|
+
font-size: 0.95rem;
|
|
195
|
+
flex: 1;
|
|
196
|
+
display: grid;
|
|
197
|
+
gap: 0.15rem;
|
|
198
|
+
text-align: left;
|
|
199
|
+
padding: 0.45rem 0.45rem;
|
|
200
|
+
border: none;
|
|
201
|
+
border-radius: ${boeRadius.med};
|
|
202
|
+
background: transparent;
|
|
203
|
+
color: var(--boe-token-text-text, #222222);
|
|
204
|
+
cursor: pointer;
|
|
205
|
+
transition: color ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
[part="item-name"] {
|
|
209
|
+
overflow: hidden;
|
|
210
|
+
text-overflow: ellipsis;
|
|
211
|
+
white-space: nowrap;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
[part="item-meta"] {
|
|
215
|
+
overflow: hidden;
|
|
216
|
+
text-overflow: ellipsis;
|
|
217
|
+
white-space: nowrap;
|
|
218
|
+
font-size: 0.78rem;
|
|
219
|
+
font-weight: 400;
|
|
220
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
[part="item"]:hover {
|
|
224
|
+
color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
[part="item"]:focus-visible {
|
|
228
|
+
outline: none;
|
|
229
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 18%, transparent);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
[part="item"][aria-selected="true"] {
|
|
233
|
+
font-weight: 600;
|
|
234
|
+
color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
[part="item-actions"] {
|
|
238
|
+
display: flex;
|
|
239
|
+
gap: 0.4rem;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
[part="item-action"] {
|
|
243
|
+
font-size: 0.8rem;
|
|
244
|
+
padding: 0.35rem 0.7rem;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
[part="load-more-region"] {
|
|
248
|
+
display: flex;
|
|
249
|
+
justify-content: center;
|
|
250
|
+
}
|
|
251
|
+
`;
|
|
252
|
+
export class BoxContentExplorerElement extends BaseElement {
|
|
253
|
+
static get observedAttributes() {
|
|
254
|
+
return ["item-gesture", "language", "page-size", "root-folder-id", "search-query", "selection-mode", "token"];
|
|
255
|
+
}
|
|
256
|
+
controller = null;
|
|
257
|
+
pendingStart = false;
|
|
258
|
+
focusItemId = null;
|
|
259
|
+
unsubscribeFns = [];
|
|
260
|
+
transportValue = null;
|
|
261
|
+
itemActionsValue = [];
|
|
262
|
+
templatesValue = {};
|
|
263
|
+
get language() {
|
|
264
|
+
return this.getAttribute("language");
|
|
265
|
+
}
|
|
266
|
+
set language(value) {
|
|
267
|
+
this.updateStringAttribute("language", value);
|
|
268
|
+
}
|
|
269
|
+
get pageSize() {
|
|
270
|
+
return readPositiveNumber(this.getAttribute("page-size"));
|
|
271
|
+
}
|
|
272
|
+
get selectionMode() {
|
|
273
|
+
const value = this.getAttribute("selection-mode");
|
|
274
|
+
return value === "single" || value === "multiple" ? value : null;
|
|
275
|
+
}
|
|
276
|
+
set selectionMode(value) {
|
|
277
|
+
this.updateStringAttribute("selection-mode", value);
|
|
278
|
+
}
|
|
279
|
+
get itemGesture() {
|
|
280
|
+
return resolveExplorerItemGesture(this.getAttribute("item-gesture"));
|
|
281
|
+
}
|
|
282
|
+
set itemGesture(value) {
|
|
283
|
+
this.setAttribute("item-gesture", value);
|
|
284
|
+
}
|
|
285
|
+
set pageSize(value) {
|
|
286
|
+
if (typeof value === "number" && value > 0) {
|
|
287
|
+
this.setAttribute("page-size", String(value));
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
this.removeAttribute("page-size");
|
|
291
|
+
}
|
|
292
|
+
get rootFolderId() {
|
|
293
|
+
return this.getAttribute("root-folder-id");
|
|
294
|
+
}
|
|
295
|
+
set rootFolderId(value) {
|
|
296
|
+
this.updateStringAttribute("root-folder-id", value);
|
|
297
|
+
}
|
|
298
|
+
get token() {
|
|
299
|
+
return this.getAttribute("token");
|
|
300
|
+
}
|
|
301
|
+
set token(value) {
|
|
302
|
+
this.updateStringAttribute("token", value);
|
|
303
|
+
}
|
|
304
|
+
get transport() {
|
|
305
|
+
return this.transportValue;
|
|
306
|
+
}
|
|
307
|
+
set transport(value) {
|
|
308
|
+
this.transportValue = value;
|
|
309
|
+
this.scheduleStart();
|
|
310
|
+
}
|
|
311
|
+
get itemActions() {
|
|
312
|
+
return this.itemActionsValue;
|
|
313
|
+
}
|
|
314
|
+
set itemActions(value) {
|
|
315
|
+
this.itemActionsValue = value;
|
|
316
|
+
this.scheduleStart();
|
|
317
|
+
}
|
|
318
|
+
get templates() {
|
|
319
|
+
return this.templatesValue;
|
|
320
|
+
}
|
|
321
|
+
set templates(value) {
|
|
322
|
+
this.templatesValue = value;
|
|
323
|
+
if (this.isRendered) {
|
|
324
|
+
this.update();
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
get state() {
|
|
328
|
+
return this.controller?.getState() ?? null;
|
|
329
|
+
}
|
|
330
|
+
get searchQuery() {
|
|
331
|
+
return this.getAttribute("search-query");
|
|
332
|
+
}
|
|
333
|
+
set searchQuery(value) {
|
|
334
|
+
this.updateStringAttribute("search-query", value);
|
|
335
|
+
}
|
|
336
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
337
|
+
// Presentation-only attrs must not tear down the session.
|
|
338
|
+
if (name !== "item-gesture" && name !== "search-query") {
|
|
339
|
+
this.scheduleStart();
|
|
340
|
+
}
|
|
341
|
+
if (name === "search-query" && this.controller && oldValue !== newValue) {
|
|
342
|
+
const query = newValue?.trim() ?? "";
|
|
343
|
+
const current = this.controller.getState().view.searchQuery?.trim() ?? "";
|
|
344
|
+
const inFolder = this.controller.getState().view.mode === "folder";
|
|
345
|
+
if (query !== current && !(query === "" && inFolder)) {
|
|
346
|
+
void (query ? this.controller.search(query) : this.controller.clearSearch());
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
350
|
+
}
|
|
351
|
+
connectedCallback() {
|
|
352
|
+
super.connectedCallback();
|
|
353
|
+
this.scheduleStart();
|
|
354
|
+
}
|
|
355
|
+
disconnectedCallback() {
|
|
356
|
+
this.teardownController();
|
|
357
|
+
}
|
|
358
|
+
async loadNextPage() {
|
|
359
|
+
await this.controller?.loadNextPage();
|
|
360
|
+
}
|
|
361
|
+
async refresh() {
|
|
362
|
+
await this.controller?.refresh();
|
|
363
|
+
}
|
|
364
|
+
async activateItem(itemId) {
|
|
365
|
+
await this.controller?.activateItem(itemId);
|
|
366
|
+
}
|
|
367
|
+
async navigateTo(folderId) {
|
|
368
|
+
await this.controller?.navigateTo(folderId);
|
|
369
|
+
}
|
|
370
|
+
async search(query) {
|
|
371
|
+
await this.controller?.search(query);
|
|
372
|
+
}
|
|
373
|
+
async clearSearch() {
|
|
374
|
+
await this.controller?.clearSearch();
|
|
375
|
+
}
|
|
376
|
+
select(itemIds) {
|
|
377
|
+
this.controller?.select(itemIds);
|
|
378
|
+
}
|
|
379
|
+
toggleSelection(itemId) {
|
|
380
|
+
this.controller?.toggleSelection(itemId);
|
|
381
|
+
}
|
|
382
|
+
clearSelection() {
|
|
383
|
+
this.controller?.clearSelection();
|
|
384
|
+
}
|
|
385
|
+
invokeItemAction(itemId, actionId) {
|
|
386
|
+
this.controller?.invokeItemAction(itemId, actionId);
|
|
387
|
+
}
|
|
388
|
+
updateStringAttribute(name, value) {
|
|
389
|
+
if (value === null || value === "") {
|
|
390
|
+
this.removeAttribute(name);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
this.setAttribute(name, value);
|
|
394
|
+
}
|
|
395
|
+
scheduleStart() {
|
|
396
|
+
if (this.pendingStart) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
this.pendingStart = true;
|
|
400
|
+
queueMicrotask(() => {
|
|
401
|
+
this.pendingStart = false;
|
|
402
|
+
void this.startController();
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
async startController() {
|
|
406
|
+
if (!this.isConnected) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
const config = this.readConfig();
|
|
410
|
+
if (!config) {
|
|
411
|
+
this.teardownController();
|
|
412
|
+
if (this.isRendered) {
|
|
413
|
+
this.update();
|
|
414
|
+
}
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
const initialSearchQuery = this.searchQuery?.trim() ?? "";
|
|
418
|
+
this.teardownController();
|
|
419
|
+
const controller = new ContentExplorerController(config);
|
|
420
|
+
this.controller = controller;
|
|
421
|
+
this.subscribeToController(controller);
|
|
422
|
+
if (this.isRendered) {
|
|
423
|
+
this.update();
|
|
424
|
+
}
|
|
425
|
+
await controller.connect();
|
|
426
|
+
if (this.controller === controller && initialSearchQuery) {
|
|
427
|
+
await controller.search(initialSearchQuery);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
readConfig() {
|
|
431
|
+
if (!this.transportValue || !this.rootFolderId || !this.token) {
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
434
|
+
return {
|
|
435
|
+
language: this.language ?? undefined,
|
|
436
|
+
pageSize: this.pageSize,
|
|
437
|
+
rootFolderId: this.rootFolderId,
|
|
438
|
+
selectionMode: this.selectionMode ?? undefined,
|
|
439
|
+
token: this.token,
|
|
440
|
+
itemActions: this.itemActionsValue,
|
|
441
|
+
transport: this.transportValue,
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
subscribeToController(controller) {
|
|
445
|
+
const eventNames = [
|
|
446
|
+
"breadcrumbsChanged",
|
|
447
|
+
"connected",
|
|
448
|
+
"disconnected",
|
|
449
|
+
"folderChanged",
|
|
450
|
+
"folderLoaded",
|
|
451
|
+
"itemActivated",
|
|
452
|
+
"itemActionInvoked",
|
|
453
|
+
"itemsChanged",
|
|
454
|
+
"loadFailed",
|
|
455
|
+
"loadSucceeded",
|
|
456
|
+
"loadingChanged",
|
|
457
|
+
"paginationChanged",
|
|
458
|
+
"searchSucceeded",
|
|
459
|
+
"selectionChanged",
|
|
460
|
+
"viewChanged",
|
|
461
|
+
];
|
|
462
|
+
this.unsubscribeFns = eventNames.map(eventName => controller.subscribe(eventName, payload => {
|
|
463
|
+
if (eventName === "viewChanged" || eventName === "searchSucceeded" || eventName === "loadSucceeded") {
|
|
464
|
+
const query = controller.getState().view.searchQuery;
|
|
465
|
+
if (query) {
|
|
466
|
+
this.setAttribute("search-query", query);
|
|
467
|
+
}
|
|
468
|
+
else if (this.hasAttribute("search-query")) {
|
|
469
|
+
this.removeAttribute("search-query");
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
this.dispatchEvent(new CustomEvent(toKebabCase(String(eventName)), {
|
|
473
|
+
bubbles: true,
|
|
474
|
+
composed: true,
|
|
475
|
+
detail: payload,
|
|
476
|
+
}));
|
|
477
|
+
if (this.isRendered) {
|
|
478
|
+
this.update();
|
|
479
|
+
}
|
|
480
|
+
}));
|
|
481
|
+
}
|
|
482
|
+
teardownController() {
|
|
483
|
+
for (const unsubscribe of this.unsubscribeFns) {
|
|
484
|
+
unsubscribe();
|
|
485
|
+
}
|
|
486
|
+
this.unsubscribeFns = [];
|
|
487
|
+
this.controller?.destroy();
|
|
488
|
+
this.controller = null;
|
|
489
|
+
}
|
|
490
|
+
getFocusableItemIds() {
|
|
491
|
+
return this.controller?.getState().items.map(item => item.id) ?? [];
|
|
492
|
+
}
|
|
493
|
+
renderTemplate() {
|
|
494
|
+
if (!this.shadowRoot) {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
this.shadowRoot.innerHTML = `
|
|
498
|
+
<style>${elementStyles}</style>
|
|
499
|
+
<div part="content-host"></div>
|
|
500
|
+
`;
|
|
501
|
+
}
|
|
502
|
+
update() {
|
|
503
|
+
if (!this.shadowRoot) {
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
const state = this.controller?.getState();
|
|
507
|
+
const breadcrumbMarkup = state?.breadcrumbs.length
|
|
508
|
+
? `<nav part="breadcrumbs" aria-label="Breadcrumbs">${state.breadcrumbs
|
|
509
|
+
.map(crumb => {
|
|
510
|
+
const buttonAttributes = toAttributeString({
|
|
511
|
+
"aria-label": `Open ${crumb.name}`,
|
|
512
|
+
"data-folder-id": crumb.id,
|
|
513
|
+
part: "breadcrumb",
|
|
514
|
+
type: "button",
|
|
515
|
+
});
|
|
516
|
+
return this.templatesValue.renderBreadcrumb
|
|
517
|
+
? this.templatesValue.renderBreadcrumb({
|
|
518
|
+
buttonAttributes,
|
|
519
|
+
element: this,
|
|
520
|
+
id: crumb.id,
|
|
521
|
+
name: crumb.name,
|
|
522
|
+
state,
|
|
523
|
+
})
|
|
524
|
+
: `<button ${buttonAttributes}>${escapeHtml(crumb.name)}</button>`;
|
|
525
|
+
})
|
|
526
|
+
.join('<span part="breadcrumb-separator">/</span>')}</nav>`
|
|
527
|
+
: "";
|
|
528
|
+
const isSearch = state?.view.mode === "search";
|
|
529
|
+
const searchResultCount = state?.pagination.totalCount ?? state?.items.length ?? 0;
|
|
530
|
+
const searchScope = state?.currentFolder?.name ?? "";
|
|
531
|
+
const folderMarkup = isSearch
|
|
532
|
+
? `<header part="folder" data-view="search">
|
|
533
|
+
${breadcrumbMarkup}
|
|
534
|
+
<box-search-results-header
|
|
535
|
+
part="search-results-header"
|
|
536
|
+
label="Search results"
|
|
537
|
+
query="${escapeHtml(state.view.searchQuery ?? "")}"
|
|
538
|
+
result-count="${escapeHtml(String(searchResultCount))}"
|
|
539
|
+
scope="${escapeHtml(searchScope)}"
|
|
540
|
+
actions='[{"id":"clear-search","label":"Clear search"}]'
|
|
541
|
+
></box-search-results-header>
|
|
542
|
+
</header>`
|
|
543
|
+
: state?.currentFolder
|
|
544
|
+
? this.templatesValue.renderFolder
|
|
545
|
+
? this.templatesValue.renderFolder({
|
|
546
|
+
breadcrumbsMarkup: breadcrumbMarkup,
|
|
547
|
+
element: this,
|
|
548
|
+
state,
|
|
549
|
+
})
|
|
550
|
+
: `<header part="folder">${breadcrumbMarkup}<h2>${escapeHtml(state.currentFolder.name)}</h2><p>${escapeHtml(state.currentFolder.id)}</p></header>`
|
|
551
|
+
: `<header part="folder"><h2>No folder loaded</h2></header>`;
|
|
552
|
+
const itemsMarkup = state?.items.length
|
|
553
|
+
? state.items
|
|
554
|
+
.map(item => {
|
|
555
|
+
const isSelected = state.selectedItemIds.includes(item.id);
|
|
556
|
+
const focusTarget = this.focusItemId ?? state.items[0]?.id ?? "";
|
|
557
|
+
const meta = formatItemMetaLine(item);
|
|
558
|
+
const actions = (state.availableActionsByItemId[item.id] ?? [])
|
|
559
|
+
.map(action => {
|
|
560
|
+
const buttonAttributes = toAttributeString({
|
|
561
|
+
"aria-label": `${action.label} ${item.name}`,
|
|
562
|
+
"data-action-id": action.id,
|
|
563
|
+
"data-item-id": item.id,
|
|
564
|
+
part: "item-action",
|
|
565
|
+
type: "button",
|
|
566
|
+
});
|
|
567
|
+
return this.templatesValue.renderItemAction
|
|
568
|
+
? this.templatesValue.renderItemAction({
|
|
569
|
+
action,
|
|
570
|
+
buttonAttributes,
|
|
571
|
+
element: this,
|
|
572
|
+
item,
|
|
573
|
+
state,
|
|
574
|
+
})
|
|
575
|
+
: `<button ${buttonAttributes}>${escapeHtml(action.label)}</button>`;
|
|
576
|
+
})
|
|
577
|
+
.join("");
|
|
578
|
+
const itemButtonAttributes = toAttributeString({
|
|
579
|
+
"aria-label": item.name,
|
|
580
|
+
"aria-selected": isSelected ? "true" : "false",
|
|
581
|
+
"data-item-id": item.id,
|
|
582
|
+
part: "item",
|
|
583
|
+
role: "option",
|
|
584
|
+
tabindex: item.id === focusTarget ? "0" : "-1",
|
|
585
|
+
type: "button",
|
|
586
|
+
});
|
|
587
|
+
return this.templatesValue.renderItem
|
|
588
|
+
? this.templatesValue.renderItem({
|
|
589
|
+
element: this,
|
|
590
|
+
isSelected,
|
|
591
|
+
item,
|
|
592
|
+
itemActionsMarkup: actions ? `<div part="item-actions">${actions}</div>` : "",
|
|
593
|
+
itemButtonAttributes,
|
|
594
|
+
state,
|
|
595
|
+
})
|
|
596
|
+
: `<li data-item-id="${item.id}" role="presentation">
|
|
597
|
+
<button ${itemButtonAttributes}><span part="item-name">${escapeHtml(item.name)}</span>${meta ? `<span part="item-meta">${escapeHtml(meta)}</span>` : ""}</button>
|
|
598
|
+
${actions ? `<div part="item-actions">${actions}</div>` : ""}
|
|
599
|
+
</li>`;
|
|
600
|
+
})
|
|
601
|
+
.join("")
|
|
602
|
+
: `<li role="presentation">No items loaded</li>`;
|
|
603
|
+
const loadMoreMarkup = state?.pagination.hasMoreItems && !state.loading
|
|
604
|
+
? `<button type="button" part="load-more">Load more</button>`
|
|
605
|
+
: "";
|
|
606
|
+
const refreshDisabled = state?.loading ? "disabled" : "";
|
|
607
|
+
const errorMarkup = state?.error ? `<p part="error">${escapeHtml(state.error.message)}</p>` : "";
|
|
608
|
+
const statusText = state
|
|
609
|
+
? state.loading
|
|
610
|
+
? "loading"
|
|
611
|
+
: "ready"
|
|
612
|
+
: "idle";
|
|
613
|
+
const host = this.shadowRoot.querySelector('[part="content-host"]');
|
|
614
|
+
if (!host) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
host.innerHTML = `
|
|
618
|
+
<section aria-busy="${state?.loading ? "true" : "false"}">
|
|
619
|
+
${folderMarkup}
|
|
620
|
+
<p part="status" data-status="${statusText}" role="status" aria-live="polite">${statusText}</p>
|
|
621
|
+
${errorMarkup}
|
|
622
|
+
<button type="button" part="refresh" aria-label="Refresh items" ${refreshDisabled}>Refresh</button>
|
|
623
|
+
<ul part="items" role="listbox" aria-label="Explorer items">${itemsMarkup}</ul>
|
|
624
|
+
${loadMoreMarkup ? `<div part="load-more-region">${loadMoreMarkup}</div>` : ""}
|
|
625
|
+
</section>
|
|
626
|
+
`;
|
|
627
|
+
this.shadowRoot.querySelector('[part="refresh"]')?.addEventListener("click", () => {
|
|
628
|
+
void this.refresh();
|
|
629
|
+
});
|
|
630
|
+
const searchHeader = this.shadowRoot.querySelector('[part="search-results-header"]');
|
|
631
|
+
searchHeader?.addEventListener("action", event => {
|
|
632
|
+
const actionId = event.detail?.action;
|
|
633
|
+
if (actionId === "clear-search") {
|
|
634
|
+
void this.clearSearch();
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
this.shadowRoot.querySelector('[part="load-more"]')?.addEventListener("click", () => {
|
|
638
|
+
void this.loadNextPage();
|
|
639
|
+
});
|
|
640
|
+
this.shadowRoot.querySelectorAll('[part="breadcrumb"]').forEach(node => {
|
|
641
|
+
node.addEventListener("click", event => {
|
|
642
|
+
const folderId = event.currentTarget.getAttribute("data-folder-id");
|
|
643
|
+
if (folderId) {
|
|
644
|
+
void this.navigateTo(folderId);
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
});
|
|
648
|
+
this.shadowRoot.querySelectorAll('[part="item"]').forEach(node => {
|
|
649
|
+
node.addEventListener("click", event => {
|
|
650
|
+
if (event.detail > 1) {
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
const itemId = event.currentTarget.getAttribute("data-item-id");
|
|
654
|
+
if (itemId) {
|
|
655
|
+
this.focusItemId = itemId;
|
|
656
|
+
this.toggleSelection(itemId);
|
|
657
|
+
if (shouldActivateOnClick(this.itemGesture)) {
|
|
658
|
+
void this.activateItem(itemId);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
node.addEventListener("dblclick", event => {
|
|
663
|
+
const itemId = event.currentTarget.getAttribute("data-item-id");
|
|
664
|
+
if (itemId) {
|
|
665
|
+
this.focusItemId = itemId;
|
|
666
|
+
void this.activateItem(itemId);
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
node.addEventListener("keydown", event => {
|
|
670
|
+
const keyboardEvent = event;
|
|
671
|
+
const itemId = event.currentTarget.getAttribute("data-item-id") ?? "";
|
|
672
|
+
const itemIds = this.getFocusableItemIds();
|
|
673
|
+
const currentIndex = itemIds.indexOf(itemId);
|
|
674
|
+
let nextIndex = currentIndex;
|
|
675
|
+
if (keyboardEvent.key === "ArrowDown") {
|
|
676
|
+
nextIndex = Math.min(itemIds.length - 1, currentIndex + 1);
|
|
677
|
+
}
|
|
678
|
+
else if (keyboardEvent.key === "ArrowUp") {
|
|
679
|
+
nextIndex = Math.max(0, currentIndex - 1);
|
|
680
|
+
}
|
|
681
|
+
else if (keyboardEvent.key === "Home") {
|
|
682
|
+
nextIndex = 0;
|
|
683
|
+
}
|
|
684
|
+
else if (keyboardEvent.key === "End") {
|
|
685
|
+
nextIndex = itemIds.length - 1;
|
|
686
|
+
}
|
|
687
|
+
else if (keyboardEvent.key === " ") {
|
|
688
|
+
keyboardEvent.preventDefault();
|
|
689
|
+
this.focusItemId = itemId;
|
|
690
|
+
this.toggleSelection(itemId);
|
|
691
|
+
if (shouldActivateOnClick(this.itemGesture)) {
|
|
692
|
+
void this.activateItem(itemId);
|
|
693
|
+
}
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
else if (keyboardEvent.key === "Enter") {
|
|
697
|
+
keyboardEvent.preventDefault();
|
|
698
|
+
this.focusItemId = itemId;
|
|
699
|
+
if (shouldToggleOnEnter(this.itemGesture)) {
|
|
700
|
+
this.toggleSelection(itemId);
|
|
701
|
+
}
|
|
702
|
+
void this.activateItem(itemId);
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
else {
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
keyboardEvent.preventDefault();
|
|
709
|
+
const nextItemId = itemIds[nextIndex];
|
|
710
|
+
if (nextItemId) {
|
|
711
|
+
this.focusItemId = nextItemId;
|
|
712
|
+
if (this.isRendered) {
|
|
713
|
+
this.update();
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
});
|
|
718
|
+
this.shadowRoot.querySelectorAll('[part="item-action"]').forEach(node => {
|
|
719
|
+
node.addEventListener("click", event => {
|
|
720
|
+
event.stopPropagation();
|
|
721
|
+
const currentTarget = event.currentTarget;
|
|
722
|
+
const itemId = currentTarget.getAttribute("data-item-id");
|
|
723
|
+
const actionId = currentTarget.getAttribute("data-action-id");
|
|
724
|
+
if (itemId && actionId) {
|
|
725
|
+
this.invokeItemAction(itemId, actionId);
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
});
|
|
729
|
+
if (this.focusItemId) {
|
|
730
|
+
queueMicrotask(() => {
|
|
731
|
+
const target = Array.from(this.shadowRoot?.querySelectorAll('[part="item"]') ?? []).find(node => node.dataset.itemId === this.focusItemId);
|
|
732
|
+
target?.focus();
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
export const defineBoxContentExplorerElement = (tagName = DEFAULT_TAG_NAME) => {
|
|
738
|
+
defineBoxSearchResultsHeaderElement();
|
|
739
|
+
const existingElement = customElements.get(tagName);
|
|
740
|
+
if (existingElement) {
|
|
741
|
+
return existingElement;
|
|
742
|
+
}
|
|
743
|
+
customElements.define(tagName, BoxContentExplorerElement);
|
|
744
|
+
return BoxContentExplorerElement;
|
|
745
|
+
};
|