@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,299 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
import { boeRadius } from "../../foundations/geometry/index.js";
|
|
3
|
+
import { boeFocusVisibleStyles, boeNeutralInteractiveStyles, } from "../../foundations/tokens/index.js";
|
|
4
|
+
const DEFAULT_TAG_NAME = "box-nudge";
|
|
5
|
+
const nudgeStyles = `
|
|
6
|
+
:host {
|
|
7
|
+
display: block;
|
|
8
|
+
color: inherit;
|
|
9
|
+
font: inherit;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
[part="nudge"] {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: flex-start;
|
|
15
|
+
gap: 0.55rem;
|
|
16
|
+
padding: 0.55rem 0.7rem;
|
|
17
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 24%, var(--boe-token-surface-surface, #ffffff));
|
|
18
|
+
border-radius: ${boeRadius.large};
|
|
19
|
+
background: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 7%, var(--boe-token-surface-surface, #ffffff));
|
|
20
|
+
color: var(--boe-token-text-text, #222222);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[part="icon"] {
|
|
24
|
+
flex: none;
|
|
25
|
+
display: grid;
|
|
26
|
+
place-items: center;
|
|
27
|
+
inline-size: 1.5rem;
|
|
28
|
+
block-size: 1.5rem;
|
|
29
|
+
color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[part="icon"] svg {
|
|
33
|
+
inline-size: 1.15rem;
|
|
34
|
+
block-size: 1.15rem;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
[part="content"] {
|
|
38
|
+
display: grid;
|
|
39
|
+
gap: 0.15rem;
|
|
40
|
+
flex: 1 1 auto;
|
|
41
|
+
line-height: 1.4;
|
|
42
|
+
font-size: 0.88rem;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[part~="title"] {
|
|
46
|
+
font-weight: 700;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
[part~="title"][hidden] {
|
|
50
|
+
display: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[part="message"] {
|
|
54
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
[part="message"][hidden] {
|
|
58
|
+
display: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[part="action"] {
|
|
62
|
+
appearance: none;
|
|
63
|
+
justify-self: start;
|
|
64
|
+
margin-top: 0.2rem;
|
|
65
|
+
padding: 0;
|
|
66
|
+
border: 0;
|
|
67
|
+
background: none;
|
|
68
|
+
color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
69
|
+
font: inherit;
|
|
70
|
+
font-size: 0.85rem;
|
|
71
|
+
font-weight: 700;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
text-decoration: underline;
|
|
74
|
+
text-underline-offset: 2px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
[part="action"]:hover:not(:disabled) {
|
|
78
|
+
color: var(--boe-token-surface-surface-brand-hover, #006ae9);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
[part="action"]:active:not(:disabled) {
|
|
82
|
+
color: var(--boe-token-surface-surface-brand-pressed, #004eac);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
${boeFocusVisibleStyles('[part="action"]')}
|
|
86
|
+
|
|
87
|
+
[part="action"]:disabled {
|
|
88
|
+
cursor: not-allowed;
|
|
89
|
+
opacity: 0.55;
|
|
90
|
+
box-shadow: none;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[part="dismiss"] {
|
|
94
|
+
appearance: none;
|
|
95
|
+
flex: none;
|
|
96
|
+
inline-size: 1.4rem;
|
|
97
|
+
block-size: 1.4rem;
|
|
98
|
+
padding: 0;
|
|
99
|
+
border: 0;
|
|
100
|
+
border-radius: 999px;
|
|
101
|
+
background: transparent;
|
|
102
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
[part="dismiss"] svg {
|
|
107
|
+
inline-size: 0.8rem;
|
|
108
|
+
block-size: 0.8rem;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
${boeNeutralInteractiveStyles('[part="dismiss"]')}
|
|
112
|
+
`;
|
|
113
|
+
/**
|
|
114
|
+
* A compact inline nudge — a lightweight hint or promotion pointing at a nearby
|
|
115
|
+
* feature, smaller than `box-alert`. It carries an optional primary action
|
|
116
|
+
* (emits `action`) and can be dismissed (emits `dismiss` and hides). Announced
|
|
117
|
+
* politely via `role="status"`; the host decides what the action does.
|
|
118
|
+
*/
|
|
119
|
+
export class BoxNudgeElement extends BaseElement {
|
|
120
|
+
static get observedAttributes() {
|
|
121
|
+
return ["action-label", "heading", "message", "open"];
|
|
122
|
+
}
|
|
123
|
+
openValue = true;
|
|
124
|
+
hostEl;
|
|
125
|
+
headingEl = null;
|
|
126
|
+
messageEl = null;
|
|
127
|
+
actionEl = null;
|
|
128
|
+
get open() {
|
|
129
|
+
return this.openValue;
|
|
130
|
+
}
|
|
131
|
+
set open(value) {
|
|
132
|
+
const nextValue = Boolean(value);
|
|
133
|
+
if (this.openValue === nextValue) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
this.openValue = nextValue;
|
|
137
|
+
if (nextValue) {
|
|
138
|
+
this.setAttribute("open", "");
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
this.removeAttribute("open");
|
|
142
|
+
}
|
|
143
|
+
if (this.isRendered) {
|
|
144
|
+
this.update();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
get heading() {
|
|
148
|
+
return this.getAttribute("heading") ?? "";
|
|
149
|
+
}
|
|
150
|
+
set heading(value) {
|
|
151
|
+
this.setAttribute("heading", value);
|
|
152
|
+
}
|
|
153
|
+
get message() {
|
|
154
|
+
return this.getAttribute("message") ?? "";
|
|
155
|
+
}
|
|
156
|
+
set message(value) {
|
|
157
|
+
this.setAttribute("message", value);
|
|
158
|
+
}
|
|
159
|
+
get actionLabel() {
|
|
160
|
+
return this.getAttribute("action-label") ?? "";
|
|
161
|
+
}
|
|
162
|
+
set actionLabel(value) {
|
|
163
|
+
this.setAttribute("action-label", value);
|
|
164
|
+
}
|
|
165
|
+
connectedCallback() {
|
|
166
|
+
// Open by default; dismiss() (via the `open` property) manages the closed state.
|
|
167
|
+
this.openValue = true;
|
|
168
|
+
super.connectedCallback();
|
|
169
|
+
}
|
|
170
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
171
|
+
if (name === "open") {
|
|
172
|
+
this.openValue = this.hasAttribute("open");
|
|
173
|
+
}
|
|
174
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
175
|
+
}
|
|
176
|
+
dismiss() {
|
|
177
|
+
if (!this.openValue) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
this.open = false;
|
|
181
|
+
this.dispatchEvent(new CustomEvent("dismiss", { bubbles: true, composed: true }));
|
|
182
|
+
}
|
|
183
|
+
renderTemplate() {
|
|
184
|
+
if (!this.shadowRoot) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
this.shadowRoot.innerHTML = `
|
|
188
|
+
<style>${nudgeStyles}</style>
|
|
189
|
+
<div part="host"></div>
|
|
190
|
+
`;
|
|
191
|
+
this.hostEl = this.shadowRoot.querySelector('[part="host"]');
|
|
192
|
+
}
|
|
193
|
+
setupListeners() {
|
|
194
|
+
this.hostEl.addEventListener("click", event => {
|
|
195
|
+
const target = event.target;
|
|
196
|
+
if (target.closest('[part="dismiss"]')) {
|
|
197
|
+
this.dismiss();
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (target.closest('[part="action"]')) {
|
|
201
|
+
this.dispatchEvent(new CustomEvent("action", {
|
|
202
|
+
bubbles: true,
|
|
203
|
+
composed: true,
|
|
204
|
+
detail: { label: this.actionLabel },
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
ensureOpenStructure() {
|
|
210
|
+
if (this.hostEl.querySelector('[part="nudge"]')) {
|
|
211
|
+
this.headingEl = this.hostEl.querySelector('[part~="title"]');
|
|
212
|
+
this.messageEl = this.hostEl.querySelector('[part="message"]');
|
|
213
|
+
this.actionEl = this.hostEl.querySelector('[part="action"]');
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
this.hostEl.innerHTML = `
|
|
217
|
+
<div part="nudge" role="status" aria-live="polite">
|
|
218
|
+
<span part="icon" aria-hidden="true">
|
|
219
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
|
220
|
+
<path d="M9 18h6"/>
|
|
221
|
+
<path d="M10 22h4"/>
|
|
222
|
+
<path d="M12 2a7 7 0 0 0-4 12.7c.6.5 1 1.3 1 2.1v.2h6v-.2c0-.8.4-1.6 1-2.1A7 7 0 0 0 12 2Z"/>
|
|
223
|
+
</svg>
|
|
224
|
+
</span>
|
|
225
|
+
<div part="content">
|
|
226
|
+
<h2 part="heading title" hidden></h2>
|
|
227
|
+
<span part="message" hidden></span>
|
|
228
|
+
</div>
|
|
229
|
+
<button type="button" part="dismiss" aria-label="Dismiss">
|
|
230
|
+
<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>
|
|
231
|
+
</button>
|
|
232
|
+
</div>
|
|
233
|
+
`;
|
|
234
|
+
this.headingEl = this.hostEl.querySelector('[part~="title"]');
|
|
235
|
+
this.messageEl = this.hostEl.querySelector('[part="message"]');
|
|
236
|
+
this.actionEl = null;
|
|
237
|
+
}
|
|
238
|
+
syncActionButton() {
|
|
239
|
+
const content = this.hostEl.querySelector('[part="content"]');
|
|
240
|
+
if (!content) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (this.actionLabel) {
|
|
244
|
+
if (!this.actionEl) {
|
|
245
|
+
const button = document.createElement("button");
|
|
246
|
+
button.type = "button";
|
|
247
|
+
button.setAttribute("part", "action");
|
|
248
|
+
content.append(button);
|
|
249
|
+
this.actionEl = button;
|
|
250
|
+
}
|
|
251
|
+
this.actionEl.textContent = this.actionLabel;
|
|
252
|
+
}
|
|
253
|
+
else if (this.actionEl) {
|
|
254
|
+
this.actionEl.remove();
|
|
255
|
+
this.actionEl = null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
update() {
|
|
259
|
+
if (!this.hostEl) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (!this.openValue) {
|
|
263
|
+
this.hostEl.innerHTML = "";
|
|
264
|
+
this.headingEl = null;
|
|
265
|
+
this.messageEl = null;
|
|
266
|
+
this.actionEl = null;
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
this.ensureOpenStructure();
|
|
270
|
+
if (!this.headingEl || !this.messageEl) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (this.heading) {
|
|
274
|
+
this.headingEl.hidden = false;
|
|
275
|
+
this.headingEl.textContent = this.heading;
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
this.headingEl.hidden = true;
|
|
279
|
+
this.headingEl.textContent = "";
|
|
280
|
+
}
|
|
281
|
+
if (this.message) {
|
|
282
|
+
this.messageEl.hidden = false;
|
|
283
|
+
this.messageEl.textContent = this.message;
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
this.messageEl.hidden = true;
|
|
287
|
+
this.messageEl.textContent = "";
|
|
288
|
+
}
|
|
289
|
+
this.syncActionButton();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
export const defineBoxNudgeElement = (tagName = DEFAULT_TAG_NAME) => {
|
|
293
|
+
const existingElement = customElements.get(tagName);
|
|
294
|
+
if (existingElement) {
|
|
295
|
+
return existingElement;
|
|
296
|
+
}
|
|
297
|
+
customElements.define(tagName, BoxNudgeElement);
|
|
298
|
+
return BoxNudgeElement;
|
|
299
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
export declare class BoxProgressBarElement extends BaseElement {
|
|
3
|
+
static get observedAttributes(): string[];
|
|
4
|
+
private progressEl;
|
|
5
|
+
private labelEl;
|
|
6
|
+
private valueEl;
|
|
7
|
+
private trackEl;
|
|
8
|
+
private indicatorEl;
|
|
9
|
+
get label(): string;
|
|
10
|
+
set label(value: string);
|
|
11
|
+
get max(): number;
|
|
12
|
+
set max(value: number);
|
|
13
|
+
get value(): number;
|
|
14
|
+
set value(value: number);
|
|
15
|
+
protected renderTemplate(): void;
|
|
16
|
+
protected update(): void;
|
|
17
|
+
}
|
|
18
|
+
export declare const defineBoxProgressBarElement: (tagName?: string) => typeof BoxProgressBarElement;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
import { boeMotionDuration, boeMotionEasing } from "../../foundations/motion/index.js";
|
|
3
|
+
const DEFAULT_TAG_NAME = "box-progress-bar";
|
|
4
|
+
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
5
|
+
const progressBarStyles = `
|
|
6
|
+
:host {
|
|
7
|
+
display: block;
|
|
8
|
+
color: inherit;
|
|
9
|
+
font: inherit;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
[part="progress"] {
|
|
13
|
+
display: grid;
|
|
14
|
+
gap: 0.45rem;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[part="meta"] {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: baseline;
|
|
20
|
+
justify-content: space-between;
|
|
21
|
+
gap: 0.65rem;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
[part="label"] {
|
|
25
|
+
font-size: 0.8rem;
|
|
26
|
+
font-weight: 700;
|
|
27
|
+
letter-spacing: 0.08em;
|
|
28
|
+
text-transform: uppercase;
|
|
29
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[part="value"] {
|
|
33
|
+
font-size: 0.86rem;
|
|
34
|
+
font-weight: 700;
|
|
35
|
+
font-variant-numeric: tabular-nums;
|
|
36
|
+
color: var(--boe-token-text-text, #222222);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
[part="track"] {
|
|
40
|
+
display: block;
|
|
41
|
+
height: 0.5rem;
|
|
42
|
+
border-radius: 999px;
|
|
43
|
+
background: color-mix(in srgb, var(--boe-token-surface-surface-secondary, #fbfbfb) 55%, var(--boe-token-stroke-stroke, #e8e8e8) 45%);
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[part="indicator"] {
|
|
48
|
+
display: block;
|
|
49
|
+
height: 100%;
|
|
50
|
+
border-radius: 999px;
|
|
51
|
+
background: var(--boe-token-surface-surface-brand, #0061d5);
|
|
52
|
+
transition: width ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
export class BoxProgressBarElement extends BaseElement {
|
|
56
|
+
static get observedAttributes() {
|
|
57
|
+
return ["label", "max", "value"];
|
|
58
|
+
}
|
|
59
|
+
progressEl;
|
|
60
|
+
labelEl;
|
|
61
|
+
valueEl;
|
|
62
|
+
trackEl;
|
|
63
|
+
indicatorEl;
|
|
64
|
+
get label() {
|
|
65
|
+
return this.getAttribute("label") ?? "Progress";
|
|
66
|
+
}
|
|
67
|
+
set label(value) {
|
|
68
|
+
this.setAttribute("label", value);
|
|
69
|
+
}
|
|
70
|
+
get max() {
|
|
71
|
+
return Number(this.getAttribute("max") ?? "100");
|
|
72
|
+
}
|
|
73
|
+
set max(value) {
|
|
74
|
+
this.setAttribute("max", String(value));
|
|
75
|
+
}
|
|
76
|
+
get value() {
|
|
77
|
+
return Number(this.getAttribute("value") ?? "0");
|
|
78
|
+
}
|
|
79
|
+
set value(value) {
|
|
80
|
+
this.setAttribute("value", String(value));
|
|
81
|
+
}
|
|
82
|
+
renderTemplate() {
|
|
83
|
+
if (!this.shadowRoot) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this.shadowRoot.innerHTML = `
|
|
87
|
+
<style>${progressBarStyles}</style>
|
|
88
|
+
<div part="progress" role="group">
|
|
89
|
+
<div part="meta">
|
|
90
|
+
<span part="label"></span>
|
|
91
|
+
<span part="value"></span>
|
|
92
|
+
</div>
|
|
93
|
+
<div part="track" role="progressbar" aria-valuemin="0">
|
|
94
|
+
<span part="indicator"></span>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
`;
|
|
98
|
+
this.progressEl = this.shadowRoot.querySelector('[part="progress"]');
|
|
99
|
+
this.labelEl = this.shadowRoot.querySelector('[part="label"]');
|
|
100
|
+
this.valueEl = this.shadowRoot.querySelector('[part="value"]');
|
|
101
|
+
this.trackEl = this.shadowRoot.querySelector('[part="track"]');
|
|
102
|
+
this.indicatorEl = this.shadowRoot.querySelector('[part="indicator"]');
|
|
103
|
+
}
|
|
104
|
+
update() {
|
|
105
|
+
if (!this.progressEl) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const max = Math.max(1, this.max);
|
|
109
|
+
const value = clamp(this.value, 0, max);
|
|
110
|
+
const percentage = Math.round((value / max) * 100);
|
|
111
|
+
this.progressEl.setAttribute("aria-label", `${this.label} progress`);
|
|
112
|
+
this.labelEl.textContent = this.label;
|
|
113
|
+
this.valueEl.textContent = `${percentage}%`;
|
|
114
|
+
this.trackEl.setAttribute("aria-label", this.label);
|
|
115
|
+
this.trackEl.setAttribute("aria-valuemax", String(max));
|
|
116
|
+
this.trackEl.setAttribute("aria-valuenow", String(value));
|
|
117
|
+
this.trackEl.setAttribute("aria-valuetext", `${percentage}%`);
|
|
118
|
+
this.indicatorEl.style.width = `${percentage}%`;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export const defineBoxProgressBarElement = (tagName = DEFAULT_TAG_NAME) => {
|
|
122
|
+
const existingElement = customElements.get(tagName);
|
|
123
|
+
if (existingElement) {
|
|
124
|
+
return existingElement;
|
|
125
|
+
}
|
|
126
|
+
customElements.define(tagName, BoxProgressBarElement);
|
|
127
|
+
return BoxProgressBarElement;
|
|
128
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
export declare class BoxProgressRingElement extends BaseElement {
|
|
3
|
+
static get observedAttributes(): string[];
|
|
4
|
+
private ringEl;
|
|
5
|
+
private svgEl;
|
|
6
|
+
private trackCircle;
|
|
7
|
+
private indicatorCircle;
|
|
8
|
+
private valueEl;
|
|
9
|
+
private labelEl;
|
|
10
|
+
get label(): string;
|
|
11
|
+
set label(value: string);
|
|
12
|
+
get max(): number;
|
|
13
|
+
set max(value: number);
|
|
14
|
+
get size(): number;
|
|
15
|
+
set size(value: number);
|
|
16
|
+
get value(): number;
|
|
17
|
+
set value(value: number);
|
|
18
|
+
protected renderTemplate(): void;
|
|
19
|
+
protected update(): void;
|
|
20
|
+
}
|
|
21
|
+
export declare const defineBoxProgressRingElement: (tagName?: string) => typeof BoxProgressRingElement;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
import { boeMotionDuration, boeMotionEasing } from "../../foundations/motion/index.js";
|
|
3
|
+
const DEFAULT_TAG_NAME = "box-progress-ring";
|
|
4
|
+
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
5
|
+
const progressRingStyles = `
|
|
6
|
+
:host {
|
|
7
|
+
display: inline-block;
|
|
8
|
+
color: inherit;
|
|
9
|
+
font: inherit;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
[part="ring"] {
|
|
13
|
+
display: inline-grid;
|
|
14
|
+
place-items: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[part="svg"] {
|
|
18
|
+
grid-area: 1 / 1;
|
|
19
|
+
transform: rotate(-90deg);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
circle[part="track"] {
|
|
23
|
+
stroke: color-mix(in srgb, var(--boe-token-surface-surface-secondary, #fbfbfb) 55%, var(--boe-token-stroke-stroke, #e8e8e8) 45%);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
circle[part="indicator"] {
|
|
27
|
+
stroke: var(--boe-token-surface-surface-brand, #0061d5);
|
|
28
|
+
stroke-linecap: round;
|
|
29
|
+
transition: stroke-dashoffset ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[part="meta"] {
|
|
33
|
+
grid-area: 1 / 1;
|
|
34
|
+
display: grid;
|
|
35
|
+
justify-items: center;
|
|
36
|
+
gap: 0.1rem;
|
|
37
|
+
text-align: center;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
[part="value"] {
|
|
41
|
+
font-weight: 700;
|
|
42
|
+
line-height: 1;
|
|
43
|
+
letter-spacing: -0.02em;
|
|
44
|
+
font-variant-numeric: tabular-nums;
|
|
45
|
+
color: var(--boe-token-text-text, #222222);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[part="label"] {
|
|
49
|
+
font-size: 0.68rem;
|
|
50
|
+
font-weight: 700;
|
|
51
|
+
letter-spacing: 0.08em;
|
|
52
|
+
text-transform: uppercase;
|
|
53
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
export class BoxProgressRingElement extends BaseElement {
|
|
57
|
+
static get observedAttributes() {
|
|
58
|
+
return ["label", "max", "size", "value"];
|
|
59
|
+
}
|
|
60
|
+
ringEl;
|
|
61
|
+
svgEl;
|
|
62
|
+
trackCircle;
|
|
63
|
+
indicatorCircle;
|
|
64
|
+
valueEl;
|
|
65
|
+
labelEl;
|
|
66
|
+
get label() {
|
|
67
|
+
return this.getAttribute("label") ?? "Progress";
|
|
68
|
+
}
|
|
69
|
+
set label(value) {
|
|
70
|
+
this.setAttribute("label", value);
|
|
71
|
+
}
|
|
72
|
+
get max() {
|
|
73
|
+
return Number(this.getAttribute("max") ?? "100");
|
|
74
|
+
}
|
|
75
|
+
set max(value) {
|
|
76
|
+
this.setAttribute("max", String(value));
|
|
77
|
+
}
|
|
78
|
+
get size() {
|
|
79
|
+
return Number(this.getAttribute("size") ?? "88");
|
|
80
|
+
}
|
|
81
|
+
set size(value) {
|
|
82
|
+
this.setAttribute("size", String(value));
|
|
83
|
+
}
|
|
84
|
+
get value() {
|
|
85
|
+
return Number(this.getAttribute("value") ?? "0");
|
|
86
|
+
}
|
|
87
|
+
set value(value) {
|
|
88
|
+
this.setAttribute("value", String(value));
|
|
89
|
+
}
|
|
90
|
+
renderTemplate() {
|
|
91
|
+
if (!this.shadowRoot) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
this.shadowRoot.innerHTML = `
|
|
95
|
+
<style>${progressRingStyles}</style>
|
|
96
|
+
<div part="ring" role="group">
|
|
97
|
+
<svg part="svg" role="progressbar" aria-valuemin="0">
|
|
98
|
+
<circle part="track" fill="none"></circle>
|
|
99
|
+
<circle part="indicator" fill="none"></circle>
|
|
100
|
+
</svg>
|
|
101
|
+
<div part="meta">
|
|
102
|
+
<span part="value"></span>
|
|
103
|
+
<span part="label"></span>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
`;
|
|
107
|
+
this.ringEl = this.shadowRoot.querySelector('[part="ring"]');
|
|
108
|
+
this.svgEl = this.shadowRoot.querySelector('[part="svg"]');
|
|
109
|
+
this.trackCircle = this.shadowRoot.querySelector('circle[part="track"]');
|
|
110
|
+
this.indicatorCircle = this.shadowRoot.querySelector('circle[part="indicator"]');
|
|
111
|
+
this.valueEl = this.shadowRoot.querySelector('[part="value"]');
|
|
112
|
+
this.labelEl = this.shadowRoot.querySelector('[part="label"]');
|
|
113
|
+
}
|
|
114
|
+
update() {
|
|
115
|
+
if (!this.ringEl) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const max = Math.max(1, this.max);
|
|
119
|
+
const value = clamp(this.value, 0, max);
|
|
120
|
+
const percentage = Math.round((value / max) * 100);
|
|
121
|
+
const size = Math.max(48, this.size);
|
|
122
|
+
const strokeWidth = Math.max(6, Math.round(size * 0.09));
|
|
123
|
+
const radius = (size - strokeWidth) / 2;
|
|
124
|
+
const circumference = 2 * Math.PI * radius;
|
|
125
|
+
const dashOffset = circumference - (percentage / 100) * circumference;
|
|
126
|
+
const center = String(size / 2);
|
|
127
|
+
this.ringEl.setAttribute("aria-label", `${this.label} progress`);
|
|
128
|
+
this.svgEl.setAttribute("viewBox", `0 0 ${size} ${size}`);
|
|
129
|
+
this.svgEl.style.width = `${size}px`;
|
|
130
|
+
this.svgEl.style.height = `${size}px`;
|
|
131
|
+
this.svgEl.setAttribute("aria-label", this.label);
|
|
132
|
+
this.svgEl.setAttribute("aria-valuemax", String(max));
|
|
133
|
+
this.svgEl.setAttribute("aria-valuenow", String(value));
|
|
134
|
+
this.svgEl.setAttribute("aria-valuetext", `${percentage}%`);
|
|
135
|
+
for (const circle of [this.trackCircle, this.indicatorCircle]) {
|
|
136
|
+
circle.setAttribute("cx", center);
|
|
137
|
+
circle.setAttribute("cy", center);
|
|
138
|
+
circle.setAttribute("r", String(radius));
|
|
139
|
+
circle.setAttribute("stroke-width", String(strokeWidth));
|
|
140
|
+
}
|
|
141
|
+
this.indicatorCircle.setAttribute("stroke-dasharray", String(circumference));
|
|
142
|
+
this.indicatorCircle.setAttribute("stroke-dashoffset", String(dashOffset));
|
|
143
|
+
this.valueEl.style.fontSize = `${Math.max(0.8, size / 88)}rem`;
|
|
144
|
+
this.valueEl.textContent = `${percentage}%`;
|
|
145
|
+
this.labelEl.textContent = this.label;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
export const defineBoxProgressRingElement = (tagName = DEFAULT_TAG_NAME) => {
|
|
149
|
+
const existingElement = customElements.get(tagName);
|
|
150
|
+
if (existingElement) {
|
|
151
|
+
return existingElement;
|
|
152
|
+
}
|
|
153
|
+
customElements.define(tagName, BoxProgressRingElement);
|
|
154
|
+
return BoxProgressRingElement;
|
|
155
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
type BoxProgressStep = {
|
|
3
|
+
description?: string;
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class BoxProgressStepsElement extends BaseElement {
|
|
8
|
+
static get observedAttributes(): string[];
|
|
9
|
+
private valueInternal;
|
|
10
|
+
private stepsEl;
|
|
11
|
+
private itemsSignature;
|
|
12
|
+
get label(): string;
|
|
13
|
+
set label(value: string);
|
|
14
|
+
get items(): BoxProgressStep[];
|
|
15
|
+
set items(value: BoxProgressStep[]);
|
|
16
|
+
get value(): string;
|
|
17
|
+
set value(nextValue: string);
|
|
18
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
19
|
+
protected renderTemplate(): void;
|
|
20
|
+
protected setupListeners(): void;
|
|
21
|
+
private selectValue;
|
|
22
|
+
protected update(): void;
|
|
23
|
+
}
|
|
24
|
+
export declare const defineBoxProgressStepsElement: (tagName?: string) => typeof BoxProgressStepsElement;
|
|
25
|
+
export {};
|