@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,499 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
import { boeMotionDuration, boeMotionEasing } from "../../foundations/motion/index.js";
|
|
3
|
+
import { boeRadius } from "../../foundations/geometry/index.js";
|
|
4
|
+
const DEFAULT_TAG_NAME = "box-calendar";
|
|
5
|
+
const escapeHtml = (value) => value
|
|
6
|
+
.replaceAll("&", "&")
|
|
7
|
+
.replaceAll("<", "<")
|
|
8
|
+
.replaceAll(">", ">")
|
|
9
|
+
.replaceAll('"', """)
|
|
10
|
+
.replaceAll("'", "'");
|
|
11
|
+
const WEEKDAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
12
|
+
const MONTH_NAMES = [
|
|
13
|
+
"January", "February", "March", "April", "May", "June",
|
|
14
|
+
"July", "August", "September", "October", "November", "December",
|
|
15
|
+
];
|
|
16
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
17
|
+
const toISO = ({ y, m, d }) => `${y}-${pad(m)}-${pad(d)}`;
|
|
18
|
+
const parseISO = (value) => {
|
|
19
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
20
|
+
if (!match) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const y = Number(match[1]);
|
|
24
|
+
const m = Number(match[2]);
|
|
25
|
+
const d = Number(match[3]);
|
|
26
|
+
if (m < 1 || m > 12 || d < 1 || d > 31) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return { y, m, d };
|
|
30
|
+
};
|
|
31
|
+
const parseMonth = (value) => {
|
|
32
|
+
const match = /^(\d{4})-(\d{2})$/.exec(value);
|
|
33
|
+
if (!match) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const m = Number(match[2]);
|
|
37
|
+
if (m < 1 || m > 12) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return { y: Number(match[1]), m };
|
|
41
|
+
};
|
|
42
|
+
const daysInMonth = (y, m) => new Date(Date.UTC(y, m, 0)).getUTCDate();
|
|
43
|
+
const firstWeekday = (y, m) => new Date(Date.UTC(y, m - 1, 1)).getUTCDay();
|
|
44
|
+
/** Add `delta` days to a date, rolling across month/year boundaries. */
|
|
45
|
+
const addDays = ({ y, m, d }, delta) => {
|
|
46
|
+
const next = new Date(Date.UTC(y, m - 1, d + delta));
|
|
47
|
+
return { y: next.getUTCFullYear(), m: next.getUTCMonth() + 1, d: next.getUTCDate() };
|
|
48
|
+
};
|
|
49
|
+
const clampDay = (y, m, d) => Math.min(d, daysInMonth(y, m));
|
|
50
|
+
const calendarStyles = `
|
|
51
|
+
:host {
|
|
52
|
+
display: inline-block;
|
|
53
|
+
color: inherit;
|
|
54
|
+
font: inherit;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
[part="calendar"] {
|
|
58
|
+
display: grid;
|
|
59
|
+
gap: 0.55rem;
|
|
60
|
+
inline-size: 17.5rem;
|
|
61
|
+
max-inline-size: 100%;
|
|
62
|
+
padding: 0.7rem;
|
|
63
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 78%, var(--boe-token-surface-surface, #ffffff) 22%);
|
|
64
|
+
border-radius: ${boeRadius.large};
|
|
65
|
+
background: var(--boe-token-surface-surface, #ffffff);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
[part="header"] {
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
justify-content: space-between;
|
|
72
|
+
gap: 0.5rem;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
[part="title"] {
|
|
76
|
+
font-weight: 700;
|
|
77
|
+
font-size: 0.95rem;
|
|
78
|
+
color: var(--boe-token-text-text, #222222);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
[part~="nav"] {
|
|
82
|
+
appearance: none;
|
|
83
|
+
display: inline-flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
justify-content: center;
|
|
86
|
+
inline-size: 2rem;
|
|
87
|
+
block-size: 2rem;
|
|
88
|
+
padding: 0;
|
|
89
|
+
border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 78%, var(--boe-token-surface-surface, #ffffff) 22%);
|
|
90
|
+
border-radius: ${boeRadius.control};
|
|
91
|
+
background: var(--boe-token-surface-surface, #ffffff);
|
|
92
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
93
|
+
cursor: pointer;
|
|
94
|
+
transition: background ${boeMotionDuration.interactive} ${boeMotionEasing.standard}, border-color ${boeMotionDuration.interactive} ${boeMotionEasing.standard}, box-shadow ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
[part~="nav"] svg {
|
|
98
|
+
inline-size: 0.85rem;
|
|
99
|
+
block-size: 0.85rem;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
[part~="nav"]:hover {
|
|
103
|
+
border-color: var(--boe-token-stroke-stroke-hover, #bcbcbc);
|
|
104
|
+
background: var(--boe-token-surface-surface-hover, #f4f4f4);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
[part~="nav"]:focus-visible {
|
|
108
|
+
outline: none;
|
|
109
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 20%, transparent);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
[part="weekdays"],
|
|
113
|
+
[part="week"] {
|
|
114
|
+
display: grid;
|
|
115
|
+
grid-template-columns: repeat(7, 1fr);
|
|
116
|
+
gap: 0.15rem;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
[part="grid"] {
|
|
120
|
+
display: grid;
|
|
121
|
+
gap: 0.15rem;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
[part="weekday"] {
|
|
125
|
+
text-align: center;
|
|
126
|
+
font-size: 0.68rem;
|
|
127
|
+
font-weight: 700;
|
|
128
|
+
letter-spacing: 0.04em;
|
|
129
|
+
text-transform: uppercase;
|
|
130
|
+
color: var(--boe-token-text-text-secondary, #6f6f6f);
|
|
131
|
+
padding-block: 0.2rem;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
[part="day-blank"] {
|
|
135
|
+
block-size: 2.1rem;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
[part~="day"] {
|
|
139
|
+
appearance: none;
|
|
140
|
+
display: inline-flex;
|
|
141
|
+
align-items: center;
|
|
142
|
+
justify-content: center;
|
|
143
|
+
block-size: 2.1rem;
|
|
144
|
+
padding: 0;
|
|
145
|
+
border: 1px solid transparent;
|
|
146
|
+
border-radius: ${boeRadius.med};
|
|
147
|
+
background: transparent;
|
|
148
|
+
font: inherit;
|
|
149
|
+
font-size: 0.82rem;
|
|
150
|
+
color: var(--boe-token-text-text, #222222);
|
|
151
|
+
cursor: pointer;
|
|
152
|
+
transition: background ${boeMotionDuration.fast} ${boeMotionEasing.standard}, color ${boeMotionDuration.fast} ${boeMotionEasing.standard}, border-color ${boeMotionDuration.fast} ${boeMotionEasing.standard}, box-shadow ${boeMotionDuration.fast} ${boeMotionEasing.standard};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
[part~="day"]:hover:not(:disabled) {
|
|
156
|
+
background: var(--boe-token-surface-surface-hover, #f4f4f4);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
[part~="day"][data-today="true"] {
|
|
160
|
+
border-color: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 40%, transparent);
|
|
161
|
+
font-weight: 700;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
[part~="day"][data-selected="true"] {
|
|
165
|
+
background: var(--boe-token-surface-surface-brand, #0061d5);
|
|
166
|
+
border-color: var(--boe-token-surface-surface-brand, #0061d5);
|
|
167
|
+
color: var(--boe-token-text-text-on-brand, #ffffff);
|
|
168
|
+
font-weight: 700;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
[part~="day"][data-selected="true"]:hover:not(:disabled) {
|
|
172
|
+
background: var(--boe-token-surface-surface-brand-hover, #006ae9);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
[part~="day"]:focus-visible {
|
|
176
|
+
outline: none;
|
|
177
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 24%, transparent);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
[part~="day"]:disabled {
|
|
181
|
+
opacity: 0.4;
|
|
182
|
+
cursor: not-allowed;
|
|
183
|
+
}
|
|
184
|
+
`;
|
|
185
|
+
export class BoxCalendarElement extends BaseElement {
|
|
186
|
+
static get observedAttributes() {
|
|
187
|
+
return ["disabled", "max", "min", "month", "today", "value"];
|
|
188
|
+
}
|
|
189
|
+
/** The date the roving tabindex currently points at. */
|
|
190
|
+
activeDate = null;
|
|
191
|
+
titleEl;
|
|
192
|
+
gridEl;
|
|
193
|
+
weekdayCells = WEEKDAYS.map(label => `<span part="weekday" role="columnheader" aria-label="${escapeHtml(label)}">${label}</span>`).join("");
|
|
194
|
+
get value() {
|
|
195
|
+
return this.getAttribute("value") ?? "";
|
|
196
|
+
}
|
|
197
|
+
set value(next) {
|
|
198
|
+
this.setAttribute("value", next);
|
|
199
|
+
}
|
|
200
|
+
get month() {
|
|
201
|
+
return this.getAttribute("month") ?? "";
|
|
202
|
+
}
|
|
203
|
+
set month(next) {
|
|
204
|
+
this.setAttribute("month", next);
|
|
205
|
+
}
|
|
206
|
+
get min() {
|
|
207
|
+
return this.getAttribute("min") ?? "";
|
|
208
|
+
}
|
|
209
|
+
set min(next) {
|
|
210
|
+
this.setAttribute("min", next);
|
|
211
|
+
}
|
|
212
|
+
get max() {
|
|
213
|
+
return this.getAttribute("max") ?? "";
|
|
214
|
+
}
|
|
215
|
+
set max(next) {
|
|
216
|
+
this.setAttribute("max", next);
|
|
217
|
+
}
|
|
218
|
+
get disabled() {
|
|
219
|
+
return this.hasAttribute("disabled");
|
|
220
|
+
}
|
|
221
|
+
set disabled(next) {
|
|
222
|
+
this.toggleAttribute("disabled", next);
|
|
223
|
+
}
|
|
224
|
+
/** Optional ISO date used as "today" for highlighting / fallback month (pin for demos). */
|
|
225
|
+
get today() {
|
|
226
|
+
return this.getAttribute("today") ?? "";
|
|
227
|
+
}
|
|
228
|
+
set today(next) {
|
|
229
|
+
if (next) {
|
|
230
|
+
this.setAttribute("today", next);
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
this.removeAttribute("today");
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
237
|
+
this.activeDate = null;
|
|
238
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
239
|
+
}
|
|
240
|
+
resolveToday() {
|
|
241
|
+
const pinned = parseISO(this.today);
|
|
242
|
+
if (pinned) {
|
|
243
|
+
return pinned;
|
|
244
|
+
}
|
|
245
|
+
const now = new Date();
|
|
246
|
+
return { y: now.getFullYear(), m: now.getMonth() + 1, d: now.getDate() };
|
|
247
|
+
}
|
|
248
|
+
/** The year/month currently displayed: explicit `month`, else `value`'s month, else today. */
|
|
249
|
+
displayedMonth() {
|
|
250
|
+
const explicit = parseMonth(this.month);
|
|
251
|
+
if (explicit) {
|
|
252
|
+
return explicit;
|
|
253
|
+
}
|
|
254
|
+
const selected = parseISO(this.value);
|
|
255
|
+
if (selected) {
|
|
256
|
+
return { y: selected.y, m: selected.m };
|
|
257
|
+
}
|
|
258
|
+
const today = this.resolveToday();
|
|
259
|
+
return { y: today.y, m: today.m };
|
|
260
|
+
}
|
|
261
|
+
isOutOfRange(iso) {
|
|
262
|
+
if (this.min && iso < this.min) {
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
if (this.max && iso > this.max) {
|
|
266
|
+
return true;
|
|
267
|
+
}
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
goToMonth(y, m) {
|
|
271
|
+
const normalized = `${y}-${pad(m)}`;
|
|
272
|
+
this.activeDate = null;
|
|
273
|
+
this.setAttribute("month", normalized);
|
|
274
|
+
this.dispatchEvent(new CustomEvent("month-changed", {
|
|
275
|
+
bubbles: true,
|
|
276
|
+
composed: true,
|
|
277
|
+
detail: { month: normalized },
|
|
278
|
+
}));
|
|
279
|
+
}
|
|
280
|
+
shiftMonth(delta) {
|
|
281
|
+
const { y, m } = this.displayedMonth();
|
|
282
|
+
const next = new Date(Date.UTC(y, m - 1 + delta, 1));
|
|
283
|
+
this.goToMonth(next.getUTCFullYear(), next.getUTCMonth() + 1);
|
|
284
|
+
}
|
|
285
|
+
selectDate(date) {
|
|
286
|
+
const iso = toISO(date);
|
|
287
|
+
if (this.disabled || this.isOutOfRange(iso)) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
this.setAttribute("value", iso);
|
|
291
|
+
// Keep the grid on the month of the chosen day.
|
|
292
|
+
this.setAttribute("month", `${date.y}-${pad(date.m)}`);
|
|
293
|
+
// `setAttribute` nulls activeDate via attributeChangedCallback — restore after.
|
|
294
|
+
this.activeDate = date;
|
|
295
|
+
this.update();
|
|
296
|
+
this.focusActive();
|
|
297
|
+
this.dispatchEvent(new CustomEvent("value-changed", {
|
|
298
|
+
bubbles: true,
|
|
299
|
+
composed: true,
|
|
300
|
+
detail: { value: iso },
|
|
301
|
+
}));
|
|
302
|
+
}
|
|
303
|
+
/** Move roving focus by `delta` days, following into the neighbouring month if needed. */
|
|
304
|
+
moveActive(delta) {
|
|
305
|
+
const current = this.activeDate ?? this.resolveActiveDate();
|
|
306
|
+
const next = this.clampToEnabled(addDays(current, delta));
|
|
307
|
+
const display = this.displayedMonth();
|
|
308
|
+
// `setAttribute` synchronously runs attributeChangedCallback, which nulls out
|
|
309
|
+
// activeDate — so assign `next` *after* the month change or focus would be lost.
|
|
310
|
+
if (next.y !== display.y || next.m !== display.m) {
|
|
311
|
+
this.setAttribute("month", `${next.y}-${pad(next.m)}`);
|
|
312
|
+
}
|
|
313
|
+
this.activeDate = next;
|
|
314
|
+
this.update();
|
|
315
|
+
this.focusActive();
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Clamp a candidate roving date to the nearest in-range day so the tabbable cell
|
|
319
|
+
* (and arrow-key navigation) never lands on a disabled/out-of-range button, which
|
|
320
|
+
* would leave the grid unreachable via Tab. When the whole calendar is disabled
|
|
321
|
+
* there is nothing to focus, so the candidate is returned untouched.
|
|
322
|
+
*/
|
|
323
|
+
clampToEnabled(candidate) {
|
|
324
|
+
if (this.disabled || !this.isOutOfRange(toISO(candidate))) {
|
|
325
|
+
return candidate;
|
|
326
|
+
}
|
|
327
|
+
for (let step = 1; step <= 366; step += 1) {
|
|
328
|
+
const forward = addDays(candidate, step);
|
|
329
|
+
if (!this.isOutOfRange(toISO(forward))) {
|
|
330
|
+
return forward;
|
|
331
|
+
}
|
|
332
|
+
const backward = addDays(candidate, -step);
|
|
333
|
+
if (!this.isOutOfRange(toISO(backward))) {
|
|
334
|
+
return backward;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return candidate;
|
|
338
|
+
}
|
|
339
|
+
focusActive() {
|
|
340
|
+
if (!this.activeDate) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
const iso = toISO(this.activeDate);
|
|
344
|
+
const button = this.gridEl?.querySelector(`[data-date="${iso}"]`);
|
|
345
|
+
button?.focus();
|
|
346
|
+
}
|
|
347
|
+
/** The date the roving tabindex should default to for the displayed month. */
|
|
348
|
+
resolveActiveDate() {
|
|
349
|
+
if (this.activeDate) {
|
|
350
|
+
return this.activeDate;
|
|
351
|
+
}
|
|
352
|
+
const { y, m } = this.displayedMonth();
|
|
353
|
+
const selected = parseISO(this.value);
|
|
354
|
+
let candidate;
|
|
355
|
+
if (selected && selected.y === y && selected.m === m) {
|
|
356
|
+
candidate = selected;
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
const today = this.resolveToday();
|
|
360
|
+
candidate = today.y === y && today.m === m ? today : { y, m, d: 1 };
|
|
361
|
+
}
|
|
362
|
+
return this.clampToEnabled(candidate);
|
|
363
|
+
}
|
|
364
|
+
handleGridKeydown(event) {
|
|
365
|
+
const deltas = {
|
|
366
|
+
ArrowLeft: -1,
|
|
367
|
+
ArrowRight: 1,
|
|
368
|
+
ArrowUp: -7,
|
|
369
|
+
ArrowDown: 7,
|
|
370
|
+
};
|
|
371
|
+
if (event.key in deltas) {
|
|
372
|
+
event.preventDefault();
|
|
373
|
+
this.moveActive(deltas[event.key]);
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
if (event.key === "PageUp") {
|
|
377
|
+
event.preventDefault();
|
|
378
|
+
this.moveActive(-daysInMonth(this.displayedMonth().y, this.displayedMonth().m));
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
if (event.key === "PageDown") {
|
|
382
|
+
event.preventDefault();
|
|
383
|
+
const { y, m } = this.displayedMonth();
|
|
384
|
+
this.moveActive(daysInMonth(y, m));
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
if (event.key === "Home") {
|
|
388
|
+
event.preventDefault();
|
|
389
|
+
const active = this.activeDate ?? this.resolveActiveDate();
|
|
390
|
+
this.moveActive(1 - active.d);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
if (event.key === "End") {
|
|
394
|
+
event.preventDefault();
|
|
395
|
+
const active = this.activeDate ?? this.resolveActiveDate();
|
|
396
|
+
this.moveActive(daysInMonth(active.y, active.m) - active.d);
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
400
|
+
event.preventDefault();
|
|
401
|
+
const active = this.activeDate ?? this.resolveActiveDate();
|
|
402
|
+
this.selectDate(active);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
renderTemplate() {
|
|
406
|
+
if (!this.shadowRoot) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
this.shadowRoot.innerHTML = `
|
|
410
|
+
<style>${calendarStyles}</style>
|
|
411
|
+
<div part="calendar" role="group" aria-label="Calendar">
|
|
412
|
+
<div part="header">
|
|
413
|
+
<button type="button" part="nav nav-prev" aria-label="Previous month">
|
|
414
|
+
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path d="M10 3L5 8l5 5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
|
415
|
+
</button>
|
|
416
|
+
<span part="title" aria-live="polite"></span>
|
|
417
|
+
<button type="button" part="nav nav-next" aria-label="Next month">
|
|
418
|
+
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path d="M6 3l5 5-5 5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
|
419
|
+
</button>
|
|
420
|
+
</div>
|
|
421
|
+
<div part="grid" role="grid"></div>
|
|
422
|
+
</div>
|
|
423
|
+
`;
|
|
424
|
+
this.titleEl = this.shadowRoot.querySelector('[part="title"]');
|
|
425
|
+
this.gridEl = this.shadowRoot.querySelector('[part="grid"]');
|
|
426
|
+
}
|
|
427
|
+
setupListeners() {
|
|
428
|
+
this.shadowRoot?.querySelector('[part~="nav-prev"]')?.addEventListener("click", () => this.shiftMonth(-1));
|
|
429
|
+
this.shadowRoot?.querySelector('[part~="nav-next"]')?.addEventListener("click", () => this.shiftMonth(1));
|
|
430
|
+
this.gridEl.addEventListener("click", event => {
|
|
431
|
+
const button = event.target.closest('[part~="day"]');
|
|
432
|
+
if (!button || !this.gridEl.contains(button)) {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const date = parseISO(button.dataset.date ?? "");
|
|
436
|
+
if (date) {
|
|
437
|
+
this.selectDate(date);
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
this.gridEl.addEventListener("keydown", event => this.handleGridKeydown(event));
|
|
441
|
+
}
|
|
442
|
+
update() {
|
|
443
|
+
if (!this.titleEl || !this.gridEl) {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
const { y, m } = this.displayedMonth();
|
|
447
|
+
const selected = parseISO(this.value);
|
|
448
|
+
const active = this.resolveActiveDate();
|
|
449
|
+
const activeIso = toISO({ y, m, d: clampDay(y, m, active.d) });
|
|
450
|
+
const todayIso = toISO(this.resolveToday());
|
|
451
|
+
this.titleEl.textContent = `${MONTH_NAMES[m - 1]} ${y}`;
|
|
452
|
+
this.gridEl.setAttribute("aria-label", `${MONTH_NAMES[m - 1]} ${y}`);
|
|
453
|
+
const leading = firstWeekday(y, m);
|
|
454
|
+
const total = daysInMonth(y, m);
|
|
455
|
+
const cells = [];
|
|
456
|
+
for (let i = 0; i < leading; i += 1) {
|
|
457
|
+
cells.push(`<span part="day-blank" aria-hidden="true"></span>`);
|
|
458
|
+
}
|
|
459
|
+
for (let day = 1; day <= total; day += 1) {
|
|
460
|
+
const iso = toISO({ y, m, d: day });
|
|
461
|
+
const isSelected = selected ? toISO(selected) === iso : false;
|
|
462
|
+
const isToday = iso === todayIso;
|
|
463
|
+
const isActive = iso === activeIso;
|
|
464
|
+
const outOfRange = this.isOutOfRange(iso);
|
|
465
|
+
const disabled = this.disabled || outOfRange;
|
|
466
|
+
cells.push(`<button
|
|
467
|
+
type="button"
|
|
468
|
+
part="day${isSelected ? " day-selected" : ""}${isToday ? " day-today" : ""}"
|
|
469
|
+
role="gridcell"
|
|
470
|
+
data-date="${iso}"
|
|
471
|
+
data-selected="${isSelected ? "true" : "false"}"
|
|
472
|
+
data-today="${isToday ? "true" : "false"}"
|
|
473
|
+
tabindex="${isActive && !disabled ? "0" : "-1"}"
|
|
474
|
+
aria-selected="${isSelected ? "true" : "false"}"
|
|
475
|
+
aria-label="${escapeHtml(`${MONTH_NAMES[m - 1]} ${day}, ${y}`)}"
|
|
476
|
+
${disabled ? "disabled" : ""}
|
|
477
|
+
>${day}</button>`);
|
|
478
|
+
}
|
|
479
|
+
while (cells.length % 7 !== 0) {
|
|
480
|
+
cells.push(`<span part="day-blank" aria-hidden="true"></span>`);
|
|
481
|
+
}
|
|
482
|
+
const rows = [];
|
|
483
|
+
for (let i = 0; i < cells.length; i += 7) {
|
|
484
|
+
rows.push(`<div part="week" role="row">${cells.slice(i, i + 7).join("")}</div>`);
|
|
485
|
+
}
|
|
486
|
+
this.gridEl.innerHTML = `
|
|
487
|
+
<div part="weekdays" role="row">${this.weekdayCells}</div>
|
|
488
|
+
${rows.join("")}
|
|
489
|
+
`;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
export const defineBoxCalendarElement = (tagName = DEFAULT_TAG_NAME) => {
|
|
493
|
+
const existingElement = customElements.get(tagName);
|
|
494
|
+
if (existingElement) {
|
|
495
|
+
return existingElement;
|
|
496
|
+
}
|
|
497
|
+
customElements.define(tagName, BoxCalendarElement);
|
|
498
|
+
return BoxCalendarElement;
|
|
499
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseElement } from "../../core/index.js";
|
|
2
|
+
type CategoryOption = {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A single-select category picker rendered as a horizontal radiogroup of pills —
|
|
9
|
+
* a filter bar for switching one active category (distinct from the multi-select
|
|
10
|
+
* `box-pill-cloud`). Data arrives via `options`; the active value is exposed as
|
|
11
|
+
* `value` and announced with `value-changed`. Follows the radiogroup keyboard
|
|
12
|
+
* pattern: arrow keys move selection with roving `tabindex`.
|
|
13
|
+
*/
|
|
14
|
+
export declare class BoxCategorySelectorElement extends BaseElement {
|
|
15
|
+
static get observedAttributes(): string[];
|
|
16
|
+
private valueInternal;
|
|
17
|
+
private lastOptionsJson;
|
|
18
|
+
private hadFocus;
|
|
19
|
+
private rootEl;
|
|
20
|
+
get label(): string;
|
|
21
|
+
set label(value: string);
|
|
22
|
+
get options(): CategoryOption[];
|
|
23
|
+
set options(value: CategoryOption[]);
|
|
24
|
+
get value(): string;
|
|
25
|
+
set value(nextValue: string);
|
|
26
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
27
|
+
private selectableOptions;
|
|
28
|
+
private select;
|
|
29
|
+
private moveSelection;
|
|
30
|
+
protected renderTemplate(): void;
|
|
31
|
+
protected setupListeners(): void;
|
|
32
|
+
protected update(): void;
|
|
33
|
+
}
|
|
34
|
+
export declare const defineBoxCategorySelectorElement: (tagName?: string) => typeof BoxCategorySelectorElement;
|
|
35
|
+
export {};
|