@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,646 @@
|
|
|
1
|
+
import { UnifiedShareController } from "./unified-share-controller.js";
|
|
2
|
+
import { BaseElement } from "../../core/index.js";
|
|
3
|
+
import { boePanel, boeRadius } from "../../foundations/geometry/index.js";
|
|
4
|
+
import { boeBrandInteractiveStyles, boeNeutralInteractiveStyles, } from "../../foundations/tokens/index.js";
|
|
5
|
+
const DEFAULT_TAG_NAME = "box-unified-share-modal";
|
|
6
|
+
const escapeHtml = (value) => value
|
|
7
|
+
.replaceAll("&", "&")
|
|
8
|
+
.replaceAll("<", "<")
|
|
9
|
+
.replaceAll(">", ">")
|
|
10
|
+
.replaceAll('"', """)
|
|
11
|
+
.replaceAll("'", "'");
|
|
12
|
+
const ACCESS_OPTIONS = [
|
|
13
|
+
{ value: "collaborators", label: "Invited people only", description: "Only people with access can open this link." },
|
|
14
|
+
{ value: "company", label: "People in your company", description: "Anyone in your company with the link." },
|
|
15
|
+
{ value: "open", label: "Anyone with the link", description: "Anyone on the internet with the link." },
|
|
16
|
+
];
|
|
17
|
+
const accessLabel = (access) => ACCESS_OPTIONS.find(option => option.value === access)?.label ?? "Invited people only";
|
|
18
|
+
const elementStyles = `
|
|
19
|
+
:host { display: contents; color: inherit; font: inherit; }
|
|
20
|
+
|
|
21
|
+
[part="backdrop"] {
|
|
22
|
+
position: fixed;
|
|
23
|
+
inset: 0;
|
|
24
|
+
display: grid;
|
|
25
|
+
place-items: center;
|
|
26
|
+
padding: 0.75rem;
|
|
27
|
+
background: rgba(15, 23, 42, 0.45);
|
|
28
|
+
z-index: 1000;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[part="dialog"] {
|
|
32
|
+
inline-size: min(32rem, 100%);
|
|
33
|
+
max-block-size: calc(100vh - 2rem);
|
|
34
|
+
overflow: auto;
|
|
35
|
+
display: grid;
|
|
36
|
+
gap: ${boePanel.gap};
|
|
37
|
+
padding: 0.75rem;
|
|
38
|
+
border-radius: ${boeRadius.field};
|
|
39
|
+
background: var(--boe-token-surface-surface, #ffffff);
|
|
40
|
+
color: var(--boe-token-text-text, #222222);
|
|
41
|
+
box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[part="header"] {
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: flex-start;
|
|
47
|
+
justify-content: space-between;
|
|
48
|
+
gap: ${boePanel.gap};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[part="title"] { margin: 0; font-size: 1.1rem; font-weight: 700; }
|
|
52
|
+
|
|
53
|
+
[part="close"] {
|
|
54
|
+
appearance: none;
|
|
55
|
+
inline-size: 1.9rem;
|
|
56
|
+
block-size: 1.9rem;
|
|
57
|
+
display: inline-grid;
|
|
58
|
+
place-items: center;
|
|
59
|
+
padding: 0;
|
|
60
|
+
border: 0;
|
|
61
|
+
border-radius: 999px;
|
|
62
|
+
background: transparent;
|
|
63
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[part="close"] svg { inline-size: 0.85rem; block-size: 0.85rem; }
|
|
68
|
+
|
|
69
|
+
[part="tablist"] {
|
|
70
|
+
display: inline-flex;
|
|
71
|
+
gap: 0.25rem;
|
|
72
|
+
padding: 0.25rem;
|
|
73
|
+
border-radius: 999px;
|
|
74
|
+
background: color-mix(in srgb, var(--boe-token-surface-surface-secondary, #fbfbfb) 70%, var(--boe-token-surface-surface, #ffffff) 30%);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
[part^="tab-"] {
|
|
78
|
+
appearance: none;
|
|
79
|
+
border: 0;
|
|
80
|
+
border-radius: 999px;
|
|
81
|
+
padding: 0.35rem 0.75rem;
|
|
82
|
+
font: inherit;
|
|
83
|
+
font-weight: 600;
|
|
84
|
+
background: transparent;
|
|
85
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
86
|
+
cursor: pointer;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
[part^="tab-"][aria-selected="true"] {
|
|
90
|
+
background: var(--boe-token-surface-surface, #ffffff);
|
|
91
|
+
color: var(--boe-token-text-text, #222222);
|
|
92
|
+
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
[part="body"] { display: grid; gap: ${boePanel.gap}; min-block-size: 6rem; }
|
|
96
|
+
|
|
97
|
+
[part="label"] {
|
|
98
|
+
font-size: 0.78rem;
|
|
99
|
+
font-weight: 700;
|
|
100
|
+
letter-spacing: 0.06em;
|
|
101
|
+
text-transform: uppercase;
|
|
102
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
[part="link-row"] { display: flex; gap: 0.5rem; }
|
|
106
|
+
|
|
107
|
+
[part="link-url"] {
|
|
108
|
+
flex: 1 1 auto;
|
|
109
|
+
min-inline-size: 0;
|
|
110
|
+
box-sizing: border-box;
|
|
111
|
+
padding: 0.55rem 0.65rem;
|
|
112
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 82%, transparent);
|
|
113
|
+
border-radius: ${boeRadius.control};
|
|
114
|
+
background: var(--boe-token-surface-surface-secondary, #fbfbfb);
|
|
115
|
+
font: inherit;
|
|
116
|
+
color: inherit;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
[part="copy"] {
|
|
120
|
+
appearance: none;
|
|
121
|
+
border-radius: ${boeRadius.control};
|
|
122
|
+
border: 1px solid transparent;
|
|
123
|
+
background: var(--boe-token-surface-surface-brand, #0061d5);
|
|
124
|
+
color: var(--boe-token-text-text-on-brand, #ffffff);
|
|
125
|
+
font: inherit;
|
|
126
|
+
font-weight: 600;
|
|
127
|
+
padding: 0.4rem 0.7rem;
|
|
128
|
+
cursor: pointer;
|
|
129
|
+
white-space: nowrap;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
[part="access"] {
|
|
133
|
+
inline-size: 100%;
|
|
134
|
+
box-sizing: border-box;
|
|
135
|
+
padding: 0.55rem 0.65rem;
|
|
136
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 82%, transparent);
|
|
137
|
+
border-radius: ${boeRadius.control};
|
|
138
|
+
background: var(--boe-token-surface-surface, #ffffff);
|
|
139
|
+
font: inherit;
|
|
140
|
+
color: inherit;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
[part="access-hint"] {
|
|
144
|
+
margin: 0;
|
|
145
|
+
font-size: 0.82rem;
|
|
146
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
[part="field"] { display: grid; gap: 0.35rem; }
|
|
150
|
+
|
|
151
|
+
[part="roster"] { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
|
|
152
|
+
|
|
153
|
+
[part="collaborator"] {
|
|
154
|
+
display: flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
gap: 0.6rem;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
[part="avatar"] {
|
|
160
|
+
flex: 0 0 auto;
|
|
161
|
+
inline-size: 2rem;
|
|
162
|
+
block-size: 2rem;
|
|
163
|
+
display: inline-grid;
|
|
164
|
+
place-items: center;
|
|
165
|
+
border-radius: 999px;
|
|
166
|
+
background: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 16%, var(--boe-token-surface-surface, #ffffff) 84%);
|
|
167
|
+
color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
168
|
+
font-size: 0.72rem;
|
|
169
|
+
font-weight: 700;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
[part="collaborator-name"] { font-weight: 600; }
|
|
173
|
+
|
|
174
|
+
[part="collaborator-meta"] {
|
|
175
|
+
font-size: 0.8rem;
|
|
176
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
[part="collaborator-role"] {
|
|
180
|
+
margin-inline-start: auto;
|
|
181
|
+
font-size: 0.8rem;
|
|
182
|
+
font-weight: 600;
|
|
183
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
184
|
+
text-transform: capitalize;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
[part="invite"] {
|
|
188
|
+
appearance: none;
|
|
189
|
+
justify-self: start;
|
|
190
|
+
border-radius: 999px;
|
|
191
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 40%, transparent);
|
|
192
|
+
background: transparent;
|
|
193
|
+
color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
194
|
+
font: inherit;
|
|
195
|
+
font-weight: 600;
|
|
196
|
+
padding: 0.4rem 0.7rem;
|
|
197
|
+
cursor: pointer;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
[part="status"] {
|
|
201
|
+
margin: 0;
|
|
202
|
+
font-size: 0.9rem;
|
|
203
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
[part="error"] {
|
|
207
|
+
margin: 0;
|
|
208
|
+
color: var(--boe-token-text-text-danger, #b3261e);
|
|
209
|
+
font-size: 0.85rem;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
[part="error"][hidden] { display: none; }
|
|
213
|
+
|
|
214
|
+
[part="actions"] {
|
|
215
|
+
display: flex;
|
|
216
|
+
justify-content: flex-end;
|
|
217
|
+
gap: 0.5rem;
|
|
218
|
+
margin-block-start: 0.25rem;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
[part="done"] {
|
|
222
|
+
appearance: none;
|
|
223
|
+
border-radius: 999px;
|
|
224
|
+
border: 1px solid transparent;
|
|
225
|
+
background: var(--boe-token-surface-surface-brand, #0061d5);
|
|
226
|
+
color: var(--boe-token-text-text-on-brand, #ffffff);
|
|
227
|
+
font: inherit;
|
|
228
|
+
font-weight: 600;
|
|
229
|
+
padding: 0.4rem 0.7rem;
|
|
230
|
+
cursor: pointer;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
${boeNeutralInteractiveStyles('[part^="tab-"]')}
|
|
234
|
+
${boeNeutralInteractiveStyles('[part="close"]')}
|
|
235
|
+
${boeNeutralInteractiveStyles('[part="invite"]')}
|
|
236
|
+
${boeNeutralInteractiveStyles('[part="access"]')}
|
|
237
|
+
${boeNeutralInteractiveStyles('[part="link-url"]')}
|
|
238
|
+
${boeBrandInteractiveStyles('[part="copy"]')}
|
|
239
|
+
${boeBrandInteractiveStyles('[part="done"]')}
|
|
240
|
+
|
|
241
|
+
[part^="tab-"][aria-selected="true"],
|
|
242
|
+
[part^="tab-"][aria-selected="true"]:hover:not(:disabled) {
|
|
243
|
+
background: var(--boe-token-surface-surface, #ffffff);
|
|
244
|
+
color: var(--boe-token-text-text, #222222);
|
|
245
|
+
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
`;
|
|
249
|
+
const initials = (name) => {
|
|
250
|
+
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
251
|
+
if (parts.length === 0) {
|
|
252
|
+
return "?";
|
|
253
|
+
}
|
|
254
|
+
const first = parts[0]?.charAt(0) ?? "";
|
|
255
|
+
const last = parts.length > 1 ? parts[parts.length - 1]?.charAt(0) ?? "" : "";
|
|
256
|
+
return (first + last).toUpperCase() || "?";
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* The unified share surface: a modal that loads an item's shared link and
|
|
260
|
+
* collaborators through a `ShareDataSource` (via a `UnifiedShareController` it
|
|
261
|
+
* owns), then presents them across a "Shared link" tab (copyable URL + access
|
|
262
|
+
* level) and a "People" tab (collaborator roster + an invite affordance). Emits
|
|
263
|
+
* `invite` when the user asks to add people (host delegates to the invite modal),
|
|
264
|
+
* `linkcopied` after a successful copy, and `close` on dismissal. Structure is
|
|
265
|
+
* built once per open so the tab controls keep focus while the body re-renders.
|
|
266
|
+
*/
|
|
267
|
+
export class BoxUnifiedShareModalElement extends BaseElement {
|
|
268
|
+
static get observedAttributes() {
|
|
269
|
+
return ["heading", "item-id", "item-type", "open"];
|
|
270
|
+
}
|
|
271
|
+
controller = null;
|
|
272
|
+
controllerUnsubscribe = null;
|
|
273
|
+
dataSourceValue = null;
|
|
274
|
+
// Structural signature of the currently-rendered body; null after a shell
|
|
275
|
+
// (re)build so the next updateDynamic renders fresh. See updateDynamic().
|
|
276
|
+
bodySignature = null;
|
|
277
|
+
get open() {
|
|
278
|
+
return this.hasAttribute("open");
|
|
279
|
+
}
|
|
280
|
+
set open(value) {
|
|
281
|
+
this.toggleAttribute("open", value);
|
|
282
|
+
}
|
|
283
|
+
get itemId() {
|
|
284
|
+
return this.getAttribute("item-id") ?? "";
|
|
285
|
+
}
|
|
286
|
+
set itemId(value) {
|
|
287
|
+
this.setAttribute("item-id", value);
|
|
288
|
+
}
|
|
289
|
+
get itemType() {
|
|
290
|
+
return this.getAttribute("item-type") === "folder" ? "folder" : "file";
|
|
291
|
+
}
|
|
292
|
+
set itemType(value) {
|
|
293
|
+
this.setAttribute("item-type", value);
|
|
294
|
+
}
|
|
295
|
+
get heading() {
|
|
296
|
+
return this.getAttribute("heading") ?? "Share";
|
|
297
|
+
}
|
|
298
|
+
set heading(value) {
|
|
299
|
+
this.setAttribute("heading", value);
|
|
300
|
+
}
|
|
301
|
+
get dataSource() {
|
|
302
|
+
return this.dataSourceValue;
|
|
303
|
+
}
|
|
304
|
+
set dataSource(value) {
|
|
305
|
+
this.dataSourceValue = value;
|
|
306
|
+
this.ensureController(true);
|
|
307
|
+
this.refresh();
|
|
308
|
+
}
|
|
309
|
+
connectedCallback() {
|
|
310
|
+
super.connectedCallback();
|
|
311
|
+
this.ensureController(false);
|
|
312
|
+
this.refresh();
|
|
313
|
+
}
|
|
314
|
+
disconnectedCallback() {
|
|
315
|
+
this.teardownController();
|
|
316
|
+
}
|
|
317
|
+
attributeChangedCallback(name, previous, next) {
|
|
318
|
+
if (previous === next) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
if (name === "item-id" || name === "item-type") {
|
|
322
|
+
this.ensureController(true);
|
|
323
|
+
}
|
|
324
|
+
if (name === "open" && this.open) {
|
|
325
|
+
// Kick off a fresh load whenever the modal is (re)opened.
|
|
326
|
+
void this.controller?.load();
|
|
327
|
+
}
|
|
328
|
+
this.refresh();
|
|
329
|
+
}
|
|
330
|
+
ensureController(recreate) {
|
|
331
|
+
if (recreate) {
|
|
332
|
+
this.teardownController();
|
|
333
|
+
}
|
|
334
|
+
if (this.controller || !this.dataSourceValue || !this.itemId) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
this.controller = new UnifiedShareController({
|
|
338
|
+
itemId: this.itemId,
|
|
339
|
+
itemType: this.itemType,
|
|
340
|
+
dataSource: this.dataSourceValue,
|
|
341
|
+
});
|
|
342
|
+
this.controllerUnsubscribe = this.controller.subscribe("stateChanged", () => this.updateDynamic());
|
|
343
|
+
if (this.open) {
|
|
344
|
+
void this.controller.load();
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
teardownController() {
|
|
348
|
+
this.controllerUnsubscribe?.();
|
|
349
|
+
this.controllerUnsubscribe = null;
|
|
350
|
+
this.controller?.destroy();
|
|
351
|
+
this.controller = null;
|
|
352
|
+
}
|
|
353
|
+
refresh() {
|
|
354
|
+
if (this.isRendered) {
|
|
355
|
+
this.update();
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
renderTemplate() {
|
|
359
|
+
if (!this.shadowRoot) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
// Styles and open content are owned by update()/buildStructure so closed
|
|
363
|
+
// state can clear the dialog without dropping the BaseElement lifecycle.
|
|
364
|
+
this.shadowRoot.innerHTML = "";
|
|
365
|
+
}
|
|
366
|
+
update() {
|
|
367
|
+
if (!this.shadowRoot) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
if (!this.open) {
|
|
371
|
+
this.shadowRoot.innerHTML = "";
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
const built = this.shadowRoot.querySelector('[part="dialog"]');
|
|
375
|
+
if (!built) {
|
|
376
|
+
this.bodySignature = null;
|
|
377
|
+
this.buildStructure();
|
|
378
|
+
this.shadowRoot.querySelector('[part="tab-link"]')?.focus();
|
|
379
|
+
}
|
|
380
|
+
this.updateDynamic();
|
|
381
|
+
}
|
|
382
|
+
buildStructure() {
|
|
383
|
+
if (!this.shadowRoot) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
this.shadowRoot.innerHTML = `
|
|
387
|
+
<style>${elementStyles}</style>
|
|
388
|
+
<div part="backdrop">
|
|
389
|
+
<section part="dialog" role="dialog" aria-modal="true" aria-labelledby="unified-share-title">
|
|
390
|
+
<div part="header">
|
|
391
|
+
<h2 part="title" id="unified-share-title">${escapeHtml(this.heading)}</h2>
|
|
392
|
+
<button type="button" part="close" aria-label="Close">
|
|
393
|
+
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path d="M4 4l8 8M12 4l-8 8" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>
|
|
394
|
+
</button>
|
|
395
|
+
</div>
|
|
396
|
+
<div part="tablist" role="tablist" aria-label="Share options">
|
|
397
|
+
<button type="button" part="tab-link" role="tab" id="unified-share-tab-link" aria-controls="unified-share-body" aria-selected="true">Shared link</button>
|
|
398
|
+
<button type="button" part="tab-people" role="tab" id="unified-share-tab-people" aria-controls="unified-share-body" aria-selected="false">People</button>
|
|
399
|
+
</div>
|
|
400
|
+
<div part="body" id="unified-share-body" role="tabpanel" tabindex="0"></div>
|
|
401
|
+
<div part="actions">
|
|
402
|
+
<button type="button" part="done">Done</button>
|
|
403
|
+
</div>
|
|
404
|
+
</section>
|
|
405
|
+
</div>
|
|
406
|
+
`;
|
|
407
|
+
this.attachListeners();
|
|
408
|
+
}
|
|
409
|
+
attachListeners() {
|
|
410
|
+
if (!this.shadowRoot) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
this.shadowRoot.querySelector('[part="tab-link"]')?.addEventListener("click", () => {
|
|
414
|
+
this.controller?.setActiveTab("link");
|
|
415
|
+
});
|
|
416
|
+
this.shadowRoot.querySelector('[part="tab-people"]')?.addEventListener("click", () => {
|
|
417
|
+
this.controller?.setActiveTab("people");
|
|
418
|
+
});
|
|
419
|
+
this.shadowRoot.querySelector('[part="tablist"]')?.addEventListener("keydown", event => {
|
|
420
|
+
const keyboardEvent = event;
|
|
421
|
+
if (keyboardEvent.key !== "ArrowLeft" && keyboardEvent.key !== "ArrowRight") {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
keyboardEvent.preventDefault();
|
|
425
|
+
const next = keyboardEvent.key === "ArrowRight" ? "people" : "link";
|
|
426
|
+
this.controller?.setActiveTab(next);
|
|
427
|
+
const target = next === "people" ? '[part="tab-people"]' : '[part="tab-link"]';
|
|
428
|
+
this.shadowRoot?.querySelector(target)?.focus();
|
|
429
|
+
});
|
|
430
|
+
this.shadowRoot.querySelector('[part="close"]')?.addEventListener("click", () => this.close());
|
|
431
|
+
this.shadowRoot.querySelector('[part="done"]')?.addEventListener("click", () => this.close());
|
|
432
|
+
this.shadowRoot.querySelector('[part="backdrop"]')?.addEventListener("click", event => {
|
|
433
|
+
if (event.target === event.currentTarget) {
|
|
434
|
+
this.close();
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
// Dialog-level keyboard contract: Escape dismisses, and Tab is trapped so
|
|
438
|
+
// focus cannot leave the modal while aria-modal is set.
|
|
439
|
+
this.shadowRoot.querySelector('[part="dialog"]')?.addEventListener("keydown", event => {
|
|
440
|
+
const keyboardEvent = event;
|
|
441
|
+
if (keyboardEvent.key === "Escape") {
|
|
442
|
+
keyboardEvent.stopPropagation();
|
|
443
|
+
this.close();
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
if (keyboardEvent.key === "Tab") {
|
|
447
|
+
this.trapFocus(keyboardEvent);
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
/** Keep Tab / Shift+Tab focus cycling inside the dialog's tabbable controls. */
|
|
452
|
+
trapFocus(event) {
|
|
453
|
+
const dialog = this.shadowRoot?.querySelector('[part="dialog"]');
|
|
454
|
+
if (!dialog) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
const focusables = Array.from(dialog.querySelectorAll('button, select, input, [tabindex]')).filter(element => !element.hasAttribute("disabled") && element.tabIndex !== -1);
|
|
458
|
+
if (focusables.length === 0) {
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
const first = focusables[0];
|
|
462
|
+
const last = focusables[focusables.length - 1];
|
|
463
|
+
const active = this.shadowRoot?.activeElement;
|
|
464
|
+
if (event.shiftKey && active === first) {
|
|
465
|
+
event.preventDefault();
|
|
466
|
+
last.focus();
|
|
467
|
+
}
|
|
468
|
+
else if (!event.shiftKey && active === last) {
|
|
469
|
+
event.preventDefault();
|
|
470
|
+
first.focus();
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
close() {
|
|
474
|
+
this.dispatchEvent(new CustomEvent("close", { bubbles: true, composed: true }));
|
|
475
|
+
this.open = false;
|
|
476
|
+
}
|
|
477
|
+
async copyLink(url) {
|
|
478
|
+
// No clipboard API (insecure context / unsupported / test env) is not a
|
|
479
|
+
// rejection — bail before claiming a success the host would toast.
|
|
480
|
+
if (!navigator.clipboard) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
try {
|
|
484
|
+
await navigator.clipboard.writeText(url);
|
|
485
|
+
}
|
|
486
|
+
catch {
|
|
487
|
+
// Clipboard access can be denied — don't claim success the host would toast.
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
this.dispatchEvent(new CustomEvent("linkcopied", { bubbles: true, composed: true, detail: { url } }));
|
|
491
|
+
}
|
|
492
|
+
updateDynamic() {
|
|
493
|
+
if (!this.shadowRoot || !this.open) {
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
// Keep the observed `heading` attribute reflected after the shell is built.
|
|
497
|
+
const title = this.shadowRoot.querySelector('[part="title"]');
|
|
498
|
+
if (title) {
|
|
499
|
+
title.textContent = this.heading;
|
|
500
|
+
}
|
|
501
|
+
const state = this.controller?.getState();
|
|
502
|
+
const body = this.shadowRoot.querySelector('[part="body"]');
|
|
503
|
+
const tabLink = this.shadowRoot.querySelector('[part="tab-link"]');
|
|
504
|
+
const tabPeople = this.shadowRoot.querySelector('[part="tab-people"]');
|
|
505
|
+
if (!body || !tabLink || !tabPeople) {
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
const activeTab = state?.activeTab ?? "link";
|
|
509
|
+
tabLink.setAttribute("aria-selected", String(activeTab === "link"));
|
|
510
|
+
tabPeople.setAttribute("aria-selected", String(activeTab === "people"));
|
|
511
|
+
tabLink.tabIndex = activeTab === "link" ? 0 : -1;
|
|
512
|
+
tabPeople.tabIndex = activeTab === "people" ? 0 : -1;
|
|
513
|
+
body.setAttribute("aria-labelledby", activeTab === "people" ? "unified-share-tab-people" : "unified-share-tab-link");
|
|
514
|
+
const phase = !state || state.status === "loading" || state.status === "idle"
|
|
515
|
+
? "loading"
|
|
516
|
+
: state.status === "error"
|
|
517
|
+
? "error"
|
|
518
|
+
: "ready";
|
|
519
|
+
const hasLink = Boolean(state?.sharedLink?.url);
|
|
520
|
+
// Only rebuild the body when its structure actually changes (phase / tab /
|
|
521
|
+
// whether a link exists). Within a phase, patch dynamic values in place so a
|
|
522
|
+
// focused control — e.g. the access <select> toggling disabled during
|
|
523
|
+
// setAccess — is never destroyed and focus stays inside the dialog.
|
|
524
|
+
const signature = `${phase}|${activeTab}|${hasLink}`;
|
|
525
|
+
if (signature !== this.bodySignature) {
|
|
526
|
+
this.bodySignature = signature;
|
|
527
|
+
if (phase === "loading") {
|
|
528
|
+
body.innerHTML = `<p part="status">Loading share settings…</p>`;
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
if (phase === "error") {
|
|
532
|
+
body.innerHTML = `<p part="error">${escapeHtml(state?.error ?? "Something went wrong.")}</p>`;
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
body.innerHTML = activeTab === "link" ? this.renderLinkTab(state) : this.renderPeopleTab(state);
|
|
536
|
+
this.attachBodyListeners();
|
|
537
|
+
}
|
|
538
|
+
if (phase === "ready" && state && activeTab === "link") {
|
|
539
|
+
this.patchLinkTab(state);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
/** In-place refresh of the link tab's dynamic values (no DOM teardown). */
|
|
543
|
+
patchLinkTab(state) {
|
|
544
|
+
if (!this.shadowRoot) {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
const access = state.sharedLink?.access ?? "collaborators";
|
|
548
|
+
const select = this.shadowRoot.querySelector('[part="access"]');
|
|
549
|
+
if (select) {
|
|
550
|
+
// aria-busy (not disabled) so an actively-focused select is never blurred
|
|
551
|
+
// mid-update; the controller's in-flight guard ignores overlapping changes.
|
|
552
|
+
select.setAttribute("aria-busy", state.updatingLink ? "true" : "false");
|
|
553
|
+
if (select.value !== access) {
|
|
554
|
+
select.value = access;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
const hint = this.shadowRoot.querySelector('[part="access-hint"]');
|
|
558
|
+
if (hint) {
|
|
559
|
+
hint.textContent = ACCESS_OPTIONS.find(option => option.value === access)?.description ?? "";
|
|
560
|
+
}
|
|
561
|
+
const url = this.shadowRoot.querySelector('[part="link-url"]');
|
|
562
|
+
if (url && state.sharedLink?.url && url.value !== state.sharedLink.url) {
|
|
563
|
+
url.value = state.sharedLink.url;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
renderLinkTab(state) {
|
|
567
|
+
const url = state.sharedLink?.url ?? "";
|
|
568
|
+
const access = state.sharedLink?.access ?? "collaborators";
|
|
569
|
+
const options = ACCESS_OPTIONS.map(option => `<option value="${option.value}"${option.value === access ? " selected" : ""}>${escapeHtml(option.label)}</option>`).join("");
|
|
570
|
+
const description = ACCESS_OPTIONS.find(option => option.value === access)?.description ?? "";
|
|
571
|
+
const linkSection = url
|
|
572
|
+
? `
|
|
573
|
+
<div part="field">
|
|
574
|
+
<span part="label">Shared link</span>
|
|
575
|
+
<div part="link-row">
|
|
576
|
+
<input part="link-url" type="text" readonly value="${escapeHtml(url)}" aria-label="Shared link URL" />
|
|
577
|
+
<button type="button" part="copy">Copy</button>
|
|
578
|
+
</div>
|
|
579
|
+
</div>`
|
|
580
|
+
: `<p part="status">No shared link yet. Choose who can access this item to create one.</p>`;
|
|
581
|
+
return `
|
|
582
|
+
${linkSection}
|
|
583
|
+
<div part="field">
|
|
584
|
+
<label part="label" for="unified-share-access">Who has access</label>
|
|
585
|
+
<select part="access" id="unified-share-access" aria-busy="${state.updatingLink ? "true" : "false"}">${options}</select>
|
|
586
|
+
<p part="access-hint">${escapeHtml(description)}</p>
|
|
587
|
+
</div>
|
|
588
|
+
`;
|
|
589
|
+
}
|
|
590
|
+
renderPeopleTab(state) {
|
|
591
|
+
const roster = state.collaborators.length
|
|
592
|
+
? `<ul part="roster">${state.collaborators.map(collaborator => this.renderCollaborator(collaborator)).join("")}</ul>`
|
|
593
|
+
: `<p part="status">No people have been added yet.</p>`;
|
|
594
|
+
return `
|
|
595
|
+
${roster}
|
|
596
|
+
<button type="button" part="invite">Invite people</button>
|
|
597
|
+
`;
|
|
598
|
+
}
|
|
599
|
+
renderCollaborator(collaborator) {
|
|
600
|
+
const name = collaborator.name.trim() || "Unknown";
|
|
601
|
+
const meta = collaborator.status ? escapeHtml(collaborator.status) : escapeHtml(collaborator.type);
|
|
602
|
+
return `
|
|
603
|
+
<li part="collaborator">
|
|
604
|
+
<span part="avatar" role="img" aria-label="${escapeHtml(name)}">${escapeHtml(initials(name))}</span>
|
|
605
|
+
<span>
|
|
606
|
+
<span part="collaborator-name">${escapeHtml(name)}</span><br />
|
|
607
|
+
<span part="collaborator-meta">${meta}</span>
|
|
608
|
+
</span>
|
|
609
|
+
<span part="collaborator-role">${escapeHtml(collaborator.role)}</span>
|
|
610
|
+
</li>
|
|
611
|
+
`;
|
|
612
|
+
}
|
|
613
|
+
// Attached once per body rebuild; each handler reads live controller state at
|
|
614
|
+
// event time so it stays correct across in-place patches (no rebuild).
|
|
615
|
+
attachBodyListeners() {
|
|
616
|
+
if (!this.shadowRoot) {
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
const copy = this.shadowRoot.querySelector('[part="copy"]');
|
|
620
|
+
copy?.addEventListener("click", () => {
|
|
621
|
+
void this.copyLink(this.controller?.getState().sharedLink?.url ?? "");
|
|
622
|
+
});
|
|
623
|
+
const access = this.shadowRoot.querySelector('[part="access"]');
|
|
624
|
+
access?.addEventListener("change", event => {
|
|
625
|
+
const value = event.currentTarget.value;
|
|
626
|
+
void this.controller?.setAccess(value);
|
|
627
|
+
});
|
|
628
|
+
const invite = this.shadowRoot.querySelector('[part="invite"]');
|
|
629
|
+
invite?.addEventListener("click", () => {
|
|
630
|
+
const current = this.controller?.getState();
|
|
631
|
+
this.dispatchEvent(new CustomEvent("invite", {
|
|
632
|
+
bubbles: true,
|
|
633
|
+
composed: true,
|
|
634
|
+
detail: { itemId: this.itemId, itemType: this.itemType, access: accessLabel(current?.sharedLink?.access) },
|
|
635
|
+
}));
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
export const defineBoxUnifiedShareModalElement = (tagName = DEFAULT_TAG_NAME) => {
|
|
640
|
+
const existingElement = customElements.get(tagName);
|
|
641
|
+
if (existingElement) {
|
|
642
|
+
return existingElement;
|
|
643
|
+
}
|
|
644
|
+
customElements.define(tagName, BoxUnifiedShareModalElement);
|
|
645
|
+
return BoxUnifiedShareModalElement;
|
|
646
|
+
};
|