@threadlabs/looma 0.50.2 → 0.51.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/components/shared/binding-inputs.js +5 -0
- package/components/shared/calendar-model.js +84 -0
- package/components/shared/date-input-segments.js +25 -0
- package/components/shared/date-navigation.js +35 -0
- package/components/shared/date-picker.js +38 -0
- package/components/shared/date-range.js +61 -0
- package/components/shared/date-time.js +273 -0
- package/components/shared/external-value.js +12 -0
- package/components/shared/form-reset.js +1 -1
- package/components/shared/icons.js +2 -0
- package/components/shared/initial-field-value.js +14 -0
- package/components/shared/input-segments.js +190 -0
- package/components/shared/prepared-module.js +19 -0
- package/components/ui-button/ui-button.html +31 -10
- package/components/ui-calendar/calendar-source.js +34 -0
- package/components/ui-calendar/ui-calendar.html +221 -0
- package/components/ui-calendar/ui-calendar.js +185 -0
- package/components/ui-cluster/ui-cluster.html +5 -2
- package/components/ui-date-field/ui-date-field.html +143 -0
- package/components/ui-date-field/ui-date-field.js +258 -0
- package/components/ui-date-picker/ui-date-picker.html +213 -0
- package/components/ui-date-picker/ui-date-picker.js +153 -0
- package/components/ui-date-range-picker/ui-date-range-picker.html +202 -0
- package/components/ui-date-range-picker/ui-date-range-picker.js +224 -0
- package/components/ui-file-input/files.js +15 -0
- package/components/ui-file-input/ui-file-input.html +79 -0
- package/components/ui-file-input/ui-file-input.js +108 -0
- package/components/ui-form-field/ui-form-field.js +2 -2
- package/components/ui-grid/ui-grid.html +68 -5
- package/components/ui-icon/ui-icon.html +8 -0
- package/components/ui-icon-button/ui-icon-button.html +22 -7
- package/components/ui-input/ui-input.html +10 -1
- package/components/ui-input/ui-input.js +11 -5
- package/components/ui-input-group/ui-input-group.html +2 -2
- package/components/ui-input-group/ui-input-group.js +6 -5
- package/components/ui-popover/ui-popover.html +2 -0
- package/components/ui-popover/ui-popover.js +5 -1
- package/components/ui-select/ui-select.html +8 -3
- package/components/ui-time-field/ui-time-field.html +62 -0
- package/components/ui-time-field/ui-time-field.js +21 -0
- package/components/ui-time-picker/time-options.js +25 -0
- package/components/ui-time-picker/ui-time-picker.html +160 -0
- package/components/ui-time-picker/ui-time-picker.js +132 -0
- package/dist/index.js +68 -61
- package/docs/README.md +2 -2
- package/docs/catalog.json +14225 -6225
- package/docs/documentation.css +1 -1
- package/docs/framework-examples.mjs +13 -2
- package/docs/site.mjs +1 -1
- package/editor/components.css +62 -29
- package/editor/icons.d.ts +2 -0
- package/editor/index.js +602 -141
- package/package.json +6 -4
- package/styles/ui-action-bar.css +1 -1
- package/styles/ui-affordance-scope.css +1 -1
- package/styles/ui-avatar-group.css +1 -1
- package/styles/ui-avatar.css +1 -1
- package/styles/ui-badge.css +1 -1
- package/styles/ui-breadcrumb-item.css +1 -1
- package/styles/ui-breadcrumbs.css +1 -1
- package/styles/ui-button.css +19 -7
- package/styles/ui-calendar.css +1 -0
- package/styles/ui-callout.css +1 -1
- package/styles/ui-card-group.css +1 -1
- package/styles/ui-card.css +1 -1
- package/styles/ui-checkbox.css +1 -1
- package/styles/ui-cluster.css +4 -1
- package/styles/ui-color-picker.css +1 -1
- package/styles/ui-combobox.css +1 -1
- package/styles/ui-compact-content.css +1 -1
- package/styles/ui-compact-editor.css +1 -1
- package/styles/ui-compact-mark.css +1 -1
- package/styles/ui-compact-node.css +1 -1
- package/styles/ui-container.css +1 -1
- package/styles/ui-context-menu.css +1 -1
- package/styles/ui-cover.css +1 -1
- package/styles/ui-curve-editor.css +1 -1
- package/styles/ui-cycle-button.css +1 -1
- package/styles/ui-date-field.css +1 -0
- package/styles/ui-date-picker.css +1 -0
- package/styles/ui-date-range-picker.css +1 -0
- package/styles/ui-description-item.css +1 -1
- package/styles/ui-description-list.css +1 -1
- package/styles/ui-dialog.css +1 -1
- package/styles/ui-disclosure.css +1 -1
- package/styles/ui-editable.css +1 -1
- package/styles/ui-editor-block-actions.css +1 -1
- package/styles/ui-editor-chip-editor.css +1 -1
- package/styles/ui-editor-code-language.css +1 -1
- package/styles/ui-editor-footnote-editor.css +1 -1
- package/styles/ui-editor-formatting-tools.css +1 -1
- package/styles/ui-editor-image-toolbar.css +1 -1
- package/styles/ui-editor-insert-table-grid.css +1 -1
- package/styles/ui-editor-link-card.css +1 -1
- package/styles/ui-editor-link-form.css +1 -1
- package/styles/ui-editor-mention-menu-item.css +1 -1
- package/styles/ui-editor-mention-menu.css +1 -1
- package/styles/ui-editor-slash-menu-group.css +1 -1
- package/styles/ui-editor-slash-menu-item.css +1 -1
- package/styles/ui-editor-slash-menu.css +1 -1
- package/styles/ui-editor-surface.css +1 -1
- package/styles/ui-editor-table-context-menu.css +1 -1
- package/styles/ui-editor-table-overlay.css +1 -1
- package/styles/ui-editor-table-toolbar.css +1 -1
- package/styles/ui-editor-toolbar.css +1 -1
- package/styles/ui-editor.css +1 -1
- package/styles/ui-file-input.css +1 -0
- package/styles/ui-floating-action-button.css +1 -1
- package/styles/ui-form-field.css +1 -1
- package/styles/ui-grid.css +38 -1
- package/styles/ui-icon-button.css +19 -5
- package/styles/ui-icon.css +5 -1
- package/styles/ui-image.css +1 -1
- package/styles/ui-input-group.css +3 -3
- package/styles/ui-input.css +1 -1
- package/styles/ui-light-editor.css +1 -1
- package/styles/ui-list-item.css +1 -1
- package/styles/ui-list.css +1 -1
- package/styles/ui-listbox.css +1 -1
- package/styles/ui-menu-group.css +1 -1
- package/styles/ui-menu-item.css +1 -1
- package/styles/ui-menu.css +1 -1
- package/styles/ui-meter.css +1 -1
- package/styles/ui-nav-item.css +1 -1
- package/styles/ui-number-input.css +1 -1
- package/styles/ui-page-header.css +1 -1
- package/styles/ui-pagination.css +1 -1
- package/styles/ui-popover.css +1 -1
- package/styles/ui-radio-group.css +1 -1
- package/styles/ui-radio.css +1 -1
- package/styles/ui-reel.css +1 -1
- package/styles/ui-scroll-area.css +1 -1
- package/styles/ui-search-result-row.css +1 -1
- package/styles/ui-search-shell.css +1 -1
- package/styles/ui-section.css +1 -1
- package/styles/ui-select.css +9 -4
- package/styles/ui-separator.css +1 -1
- package/styles/ui-sidebar.css +1 -1
- package/styles/ui-site-header.css +19 -19
- package/styles/ui-skeleton.css +1 -1
- package/styles/ui-slider.css +1 -1
- package/styles/ui-spinner.css +1 -1
- package/styles/ui-stack.css +1 -1
- package/styles/ui-status-message.css +1 -1
- package/styles/ui-swatch.css +1 -1
- package/styles/ui-switch.css +1 -1
- package/styles/ui-switcher.css +1 -1
- package/styles/ui-table.css +1 -1
- package/styles/ui-tabs.css +1 -1
- package/styles/ui-text.css +1 -1
- package/styles/ui-textarea.css +1 -1
- package/styles/ui-time-field.css +1 -0
- package/styles/ui-time-picker.css +1 -0
- package/styles/ui-toast-region.css +1 -1
- package/styles/ui-toast.css +1 -1
- package/styles/ui-tooltip.css +1 -1
- package/styles/ui-top-bar.css +1 -1
- package/styles/ui-tree-item.css +1 -1
- package/styles/ui-tree.css +1 -1
- package/tokens.css +4 -0
- package/vanilla/UiActionBar.d.ts +1 -1
- package/vanilla/UiActionBar.js +1 -1
- package/vanilla/UiAffordanceScope.d.ts +1 -1
- package/vanilla/UiAffordanceScope.js +1 -1
- package/vanilla/UiAvatar.d.ts +1 -1
- package/vanilla/UiAvatar.js +1 -1
- package/vanilla/UiAvatarGroup.d.ts +1 -1
- package/vanilla/UiAvatarGroup.js +1 -1
- package/vanilla/UiBadge.d.ts +1 -1
- package/vanilla/UiBadge.js +1 -1
- package/vanilla/UiBreadcrumbItem.d.ts +1 -1
- package/vanilla/UiBreadcrumbItem.js +1 -1
- package/vanilla/UiBreadcrumbs.d.ts +1 -1
- package/vanilla/UiBreadcrumbs.js +1 -1
- package/vanilla/UiButton.d.ts +2 -1
- package/vanilla/UiButton.js +128 -108
- package/vanilla/UiCalendar.d.ts +50 -0
- package/vanilla/UiCalendar.js +477 -0
- package/vanilla/UiCallout.d.ts +1 -1
- package/vanilla/UiCallout.js +1 -1
- package/vanilla/UiCard.d.ts +1 -1
- package/vanilla/UiCard.js +1 -1
- package/vanilla/UiCardGroup.d.ts +1 -1
- package/vanilla/UiCardGroup.js +1 -1
- package/vanilla/UiCheckbox.d.ts +1 -1
- package/vanilla/UiCheckbox.js +1 -1
- package/vanilla/UiCluster.d.ts +2 -2
- package/vanilla/UiCluster.js +2 -2
- package/vanilla/UiColorPicker.d.ts +1 -1
- package/vanilla/UiColorPicker.js +1 -1
- package/vanilla/UiCombobox.d.ts +1 -1
- package/vanilla/UiCombobox.js +1 -1
- package/vanilla/UiCompactContent.d.ts +1 -1
- package/vanilla/UiCompactContent.js +1 -1
- package/vanilla/UiCompactEditor.d.ts +1 -1
- package/vanilla/UiCompactEditor.js +1 -1
- package/vanilla/UiCompactMark.d.ts +1 -1
- package/vanilla/UiCompactMark.js +1 -1
- package/vanilla/UiCompactNode.d.ts +1 -1
- package/vanilla/UiCompactNode.js +1 -1
- package/vanilla/UiContainer.d.ts +1 -1
- package/vanilla/UiContainer.js +1 -1
- package/vanilla/UiContextMenu.d.ts +1 -1
- package/vanilla/UiContextMenu.js +1 -1
- package/vanilla/UiCover.d.ts +1 -1
- package/vanilla/UiCover.js +1 -1
- package/vanilla/UiCurveEditor.d.ts +1 -1
- package/vanilla/UiCurveEditor.js +1 -1
- package/vanilla/UiCycleButton.d.ts +1 -1
- package/vanilla/UiCycleButton.js +1 -1
- package/vanilla/UiDateField.d.ts +52 -0
- package/vanilla/UiDateField.js +208 -0
- package/vanilla/UiDatePicker.d.ts +63 -0
- package/vanilla/UiDatePicker.js +360 -0
- package/vanilla/UiDateRangePicker.d.ts +60 -0
- package/vanilla/UiDateRangePicker.js +418 -0
- package/vanilla/UiDescriptionItem.d.ts +1 -1
- package/vanilla/UiDescriptionItem.js +1 -1
- package/vanilla/UiDescriptionList.d.ts +1 -1
- package/vanilla/UiDescriptionList.js +1 -1
- package/vanilla/UiDialog.d.ts +1 -1
- package/vanilla/UiDialog.js +1 -1
- package/vanilla/UiDisclosure.d.ts +1 -1
- package/vanilla/UiDisclosure.js +1 -1
- package/vanilla/UiEditable.d.ts +1 -1
- package/vanilla/UiEditable.js +1 -1
- package/vanilla/UiEditor.d.ts +1 -1
- package/vanilla/UiEditor.js +1 -1
- package/vanilla/UiEditorBlockActions.d.ts +1 -1
- package/vanilla/UiEditorBlockActions.js +1 -1
- package/vanilla/UiEditorChipEditor.d.ts +1 -1
- package/vanilla/UiEditorChipEditor.js +1 -1
- package/vanilla/UiEditorCodeLanguage.d.ts +1 -1
- package/vanilla/UiEditorCodeLanguage.js +1 -1
- package/vanilla/UiEditorFootnoteEditor.d.ts +1 -1
- package/vanilla/UiEditorFootnoteEditor.js +1 -1
- package/vanilla/UiEditorFormattingTools.d.ts +1 -1
- package/vanilla/UiEditorFormattingTools.js +1 -1
- package/vanilla/UiEditorImageToolbar.d.ts +1 -1
- package/vanilla/UiEditorImageToolbar.js +1 -1
- package/vanilla/UiEditorInsertTableGrid.d.ts +1 -1
- package/vanilla/UiEditorInsertTableGrid.js +1 -1
- package/vanilla/UiEditorLinkCard.d.ts +1 -1
- package/vanilla/UiEditorLinkCard.js +1 -1
- package/vanilla/UiEditorLinkForm.d.ts +1 -1
- package/vanilla/UiEditorLinkForm.js +1 -1
- package/vanilla/UiEditorMentionMenu.d.ts +1 -1
- package/vanilla/UiEditorMentionMenu.js +1 -1
- package/vanilla/UiEditorMentionMenuItem.d.ts +1 -1
- package/vanilla/UiEditorMentionMenuItem.js +1 -1
- package/vanilla/UiEditorSlashMenu.d.ts +1 -1
- package/vanilla/UiEditorSlashMenu.js +1 -1
- package/vanilla/UiEditorSlashMenuGroup.d.ts +1 -1
- package/vanilla/UiEditorSlashMenuGroup.js +1 -1
- package/vanilla/UiEditorSlashMenuItem.d.ts +1 -1
- package/vanilla/UiEditorSlashMenuItem.js +1 -1
- package/vanilla/UiEditorSurface.d.ts +1 -1
- package/vanilla/UiEditorSurface.js +1 -1
- package/vanilla/UiEditorTableContextMenu.d.ts +1 -1
- package/vanilla/UiEditorTableContextMenu.js +1 -1
- package/vanilla/UiEditorTableOverlay.d.ts +1 -1
- package/vanilla/UiEditorTableOverlay.js +1 -1
- package/vanilla/UiEditorTableToolbar.d.ts +1 -1
- package/vanilla/UiEditorTableToolbar.js +1 -1
- package/vanilla/UiEditorToolbar.d.ts +1 -1
- package/vanilla/UiEditorToolbar.js +1 -1
- package/vanilla/UiFileInput.d.ts +36 -0
- package/vanilla/UiFileInput.js +209 -0
- package/vanilla/UiFloatingActionButton.d.ts +1 -1
- package/vanilla/UiFloatingActionButton.js +1 -1
- package/vanilla/UiFormField.d.ts +1 -1
- package/vanilla/UiFormField.js +1 -1
- package/vanilla/UiGrid.d.ts +7 -2
- package/vanilla/UiGrid.js +85 -19
- package/vanilla/UiIcon.d.ts +2 -1
- package/vanilla/UiIcon.js +10 -10
- package/vanilla/UiIconButton.d.ts +2 -2
- package/vanilla/UiIconButton.js +2 -2
- package/vanilla/UiImage.d.ts +1 -1
- package/vanilla/UiImage.js +1 -1
- package/vanilla/UiInput.d.ts +2 -1
- package/vanilla/UiInput.js +11 -11
- package/vanilla/UiInputGroup.d.ts +1 -1
- package/vanilla/UiInputGroup.js +1 -1
- package/vanilla/UiLightEditor.d.ts +1 -1
- package/vanilla/UiLightEditor.js +1 -1
- package/vanilla/UiList.d.ts +1 -1
- package/vanilla/UiList.js +1 -1
- package/vanilla/UiListItem.d.ts +1 -1
- package/vanilla/UiListItem.js +1 -1
- package/vanilla/UiListbox.d.ts +1 -1
- package/vanilla/UiListbox.js +1 -1
- package/vanilla/UiMenu.d.ts +1 -1
- package/vanilla/UiMenu.js +1 -1
- package/vanilla/UiMenuGroup.d.ts +1 -1
- package/vanilla/UiMenuGroup.js +1 -1
- package/vanilla/UiMenuItem.d.ts +1 -1
- package/vanilla/UiMenuItem.js +1 -1
- package/vanilla/UiMeter.d.ts +1 -1
- package/vanilla/UiMeter.js +1 -1
- package/vanilla/UiNavItem.d.ts +1 -1
- package/vanilla/UiNavItem.js +1 -1
- package/vanilla/UiNumberInput.d.ts +1 -1
- package/vanilla/UiNumberInput.js +1 -1
- package/vanilla/UiPageHeader.d.ts +1 -1
- package/vanilla/UiPageHeader.js +1 -1
- package/vanilla/UiPagination.d.ts +1 -1
- package/vanilla/UiPagination.js +1 -1
- package/vanilla/UiPopover.d.ts +2 -1
- package/vanilla/UiPopover.js +4 -4
- package/vanilla/UiRadio.d.ts +1 -1
- package/vanilla/UiRadio.js +1 -1
- package/vanilla/UiRadioGroup.d.ts +1 -1
- package/vanilla/UiRadioGroup.js +1 -1
- package/vanilla/UiReel.d.ts +1 -1
- package/vanilla/UiReel.js +1 -1
- package/vanilla/UiScrollArea.d.ts +1 -1
- package/vanilla/UiScrollArea.js +1 -1
- package/vanilla/UiSearchResultRow.d.ts +1 -1
- package/vanilla/UiSearchResultRow.js +1 -1
- package/vanilla/UiSearchShell.d.ts +1 -1
- package/vanilla/UiSearchShell.js +1 -1
- package/vanilla/UiSection.d.ts +1 -1
- package/vanilla/UiSection.js +1 -1
- package/vanilla/UiSelect.d.ts +1 -1
- package/vanilla/UiSelect.js +1 -1
- package/vanilla/UiSeparator.d.ts +1 -1
- package/vanilla/UiSeparator.js +1 -1
- package/vanilla/UiSidebar.d.ts +1 -1
- package/vanilla/UiSidebar.js +1 -1
- package/vanilla/UiSiteHeader.d.ts +1 -1
- package/vanilla/UiSiteHeader.js +1 -1
- package/vanilla/UiSkeleton.d.ts +1 -1
- package/vanilla/UiSkeleton.js +1 -1
- package/vanilla/UiSlider.d.ts +1 -1
- package/vanilla/UiSlider.js +1 -1
- package/vanilla/UiSpinner.d.ts +1 -1
- package/vanilla/UiSpinner.js +1 -1
- package/vanilla/UiStack.d.ts +1 -1
- package/vanilla/UiStack.js +1 -1
- package/vanilla/UiStatusMessage.d.ts +1 -1
- package/vanilla/UiStatusMessage.js +1 -1
- package/vanilla/UiSwatch.d.ts +1 -1
- package/vanilla/UiSwatch.js +1 -1
- package/vanilla/UiSwitch.d.ts +1 -1
- package/vanilla/UiSwitch.js +1 -1
- package/vanilla/UiSwitcher.d.ts +1 -1
- package/vanilla/UiSwitcher.js +1 -1
- package/vanilla/UiTable.d.ts +1 -1
- package/vanilla/UiTable.js +1 -1
- package/vanilla/UiTabs.d.ts +1 -1
- package/vanilla/UiTabs.js +1 -1
- package/vanilla/UiText.d.ts +1 -1
- package/vanilla/UiText.js +1 -1
- package/vanilla/UiTextarea.d.ts +1 -1
- package/vanilla/UiTextarea.js +1 -1
- package/vanilla/UiTimeField.d.ts +42 -0
- package/vanilla/UiTimeField.js +112 -0
- package/vanilla/UiTimePicker.d.ts +48 -0
- package/vanilla/UiTimePicker.js +372 -0
- package/vanilla/UiToast.d.ts +1 -1
- package/vanilla/UiToast.js +1 -1
- package/vanilla/UiToastRegion.d.ts +1 -1
- package/vanilla/UiToastRegion.js +1 -1
- package/vanilla/UiTooltip.d.ts +1 -1
- package/vanilla/UiTooltip.js +1 -1
- package/vanilla/UiTopBar.d.ts +1 -1
- package/vanilla/UiTopBar.js +1 -1
- package/vanilla/UiTree.d.ts +1 -1
- package/vanilla/UiTree.js +1 -1
- package/vanilla/UiTreeItem.d.ts +1 -1
- package/vanilla/UiTreeItem.js +1 -1
- package/vanilla/index.js +7 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/** Give one native text input editable blocks, literal navigation and continuous code entry. */
|
|
2
|
+
export function inputSegments(input, readSegments, readInitialValue) {
|
|
3
|
+
let connected = true;
|
|
4
|
+
let composing = false;
|
|
5
|
+
let internal = false;
|
|
6
|
+
let continued = -1;
|
|
7
|
+
let skipped = "";
|
|
8
|
+
let expectedValue = input.value;
|
|
9
|
+
let entering = false;
|
|
10
|
+
const undo = [];
|
|
11
|
+
const redo = [];
|
|
12
|
+
const configuration = () => {
|
|
13
|
+
if (input.value !== expectedValue) {
|
|
14
|
+
undo.length = 0; redo.length = 0; continued = -1; skipped = ""; expectedValue = input.value;
|
|
15
|
+
}
|
|
16
|
+
if (input.type !== "text" && input.type !== "tel" && input.type !== "search") return null;
|
|
17
|
+
const parts = readSegments() ?? [];
|
|
18
|
+
if (!parts.some(part => part.placeholder)) return null;
|
|
19
|
+
return parts.map(part => typeof part.literal === "string" ? { literal: part.literal } : {
|
|
20
|
+
length: [...part.placeholder].length,
|
|
21
|
+
accepts: new RegExp(`^(?:${part.pattern ?? "."})$`, "u"),
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const layout = (parts, text = input.value) => {
|
|
25
|
+
const blocks = [];
|
|
26
|
+
let offset = 0;
|
|
27
|
+
for (let index = 0; index < parts.length; index++) {
|
|
28
|
+
const part = parts[index];
|
|
29
|
+
if (part.literal !== undefined) {
|
|
30
|
+
if (offset < text.length) {
|
|
31
|
+
if (!text.startsWith(part.literal, offset)) return null;
|
|
32
|
+
offset += part.literal.length;
|
|
33
|
+
}
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const start = offset;
|
|
37
|
+
let value = "";
|
|
38
|
+
const nextLiteral = parts[index + 1]?.literal;
|
|
39
|
+
while (offset < text.length && [...value].length < part.length && !(nextLiteral && text.startsWith(nextLiteral, offset))) {
|
|
40
|
+
const character = String.fromCodePoint(text.codePointAt(offset));
|
|
41
|
+
if (!part.accepts.test(character)) break;
|
|
42
|
+
value += character; offset += character.length;
|
|
43
|
+
}
|
|
44
|
+
blocks.push({ ...part, value, start, end: offset, index });
|
|
45
|
+
}
|
|
46
|
+
return offset === text.length ? blocks : null;
|
|
47
|
+
};
|
|
48
|
+
const snapshot = () => ({ value: input.value, start: input.selectionStart, end: input.selectionEnd });
|
|
49
|
+
const select = block => input.setSelectionRange(block.start, block.end);
|
|
50
|
+
const announce = inputType => {
|
|
51
|
+
expectedValue = input.value;
|
|
52
|
+
internal = true;
|
|
53
|
+
input.dispatchEvent(new InputEvent("input", { bubbles: true, inputType }));
|
|
54
|
+
internal = false;
|
|
55
|
+
};
|
|
56
|
+
const entryText = (parts, blocks, active) => {
|
|
57
|
+
const lastFilled = blocks.findLastIndex(block => block.value);
|
|
58
|
+
const last = blocks[Math.max(active, lastFilled)].index;
|
|
59
|
+
let index = 0;
|
|
60
|
+
return parts.slice(0, last + 1).map(part => part.literal ?? blocks[index++].value).join("");
|
|
61
|
+
};
|
|
62
|
+
const render = (parts, blocks, active, inputType) => {
|
|
63
|
+
undo.push(snapshot()); redo.length = 0;
|
|
64
|
+
input.value = blocks.every(block => !block.value) && !inputType.startsWith("insert") ? "" : entryText(parts, blocks, active);
|
|
65
|
+
const next = layout(parts);
|
|
66
|
+
if (next?.[active]) select(next[active]);
|
|
67
|
+
announce(inputType);
|
|
68
|
+
};
|
|
69
|
+
const activeBlock = blocks => {
|
|
70
|
+
if (continued >= 0 && input.selectionStart === input.selectionEnd && blocks[continued]?.end === input.selectionStart) return continued;
|
|
71
|
+
const exact = blocks.findIndex(block => block.start === input.selectionStart);
|
|
72
|
+
if (exact >= 0) return exact;
|
|
73
|
+
const containing = blocks.findIndex(block => input.selectionStart < block.end);
|
|
74
|
+
return containing >= 0 ? containing : blocks.length - 1;
|
|
75
|
+
};
|
|
76
|
+
const focus = (force = false) => {
|
|
77
|
+
continued = -1; skipped = "";
|
|
78
|
+
if (input.disabled || input.readOnly || force !== true && input.value && input.selectionStart === 0 && input.selectionEnd === input.value.length) return;
|
|
79
|
+
const parts = configuration();
|
|
80
|
+
const blocks = parts && layout(parts);
|
|
81
|
+
if (blocks?.length) select(blocks[0]);
|
|
82
|
+
};
|
|
83
|
+
const down = () => { entering = input.ownerDocument.activeElement !== input; };
|
|
84
|
+
const reselect = () => focus(true);
|
|
85
|
+
const pointer = () => {
|
|
86
|
+
if (entering) { entering = false; if (input.selectionStart === input.selectionEnd) focus(true); return; }
|
|
87
|
+
const parts = configuration();
|
|
88
|
+
const blocks = parts && layout(parts);
|
|
89
|
+
if (!blocks || input.selectionStart !== input.selectionEnd) return;
|
|
90
|
+
continued = -1; skipped = "";
|
|
91
|
+
select(blocks[activeBlock(blocks)]);
|
|
92
|
+
};
|
|
93
|
+
const insert = (parts, blocks, data, inputType) => {
|
|
94
|
+
let active = activeBlock(blocks);
|
|
95
|
+
const block = blocks[active];
|
|
96
|
+
const nextLiteral = parts[block.index + 1]?.literal ?? "";
|
|
97
|
+
if (nextLiteral.includes(data) && data) {
|
|
98
|
+
if (skipped === data) { skipped = ""; return; }
|
|
99
|
+
continued = -1;
|
|
100
|
+
if (blocks[active + 1]) {
|
|
101
|
+
if (entryText(parts, blocks, active + 1) !== input.value) render(parts, blocks, active + 1, inputType);
|
|
102
|
+
else select(blocks[active + 1]);
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (skipped === data) { skipped = ""; return; }
|
|
107
|
+
if (!block.accepts.test(data)) return;
|
|
108
|
+
const all = input.selectionStart === 0 && input.selectionEnd === input.value.length && blocks.length > 1;
|
|
109
|
+
if (all) { blocks.forEach(part => { part.value = ""; }); active = 0; }
|
|
110
|
+
const target = blocks[active];
|
|
111
|
+
const replacing = continued !== active || input.selectionStart !== input.selectionEnd;
|
|
112
|
+
target.value = (replacing ? "" : target.value) + data;
|
|
113
|
+
if ([...target.value].length > target.length) return;
|
|
114
|
+
const complete = [...target.value].length === target.length;
|
|
115
|
+
const next = complete && blocks[active + 1] ? active + 1 : active;
|
|
116
|
+
render(parts, blocks, next, inputType);
|
|
117
|
+
const positions = layout(parts);
|
|
118
|
+
if (next === active && positions) input.setSelectionRange(positions[active].end, positions[active].end);
|
|
119
|
+
continued = next === active ? active : -1;
|
|
120
|
+
skipped = complete ? nextLiteral : "";
|
|
121
|
+
};
|
|
122
|
+
const before = event => {
|
|
123
|
+
if (composing || event.isComposing || input.disabled || input.readOnly) return;
|
|
124
|
+
const parts = configuration();
|
|
125
|
+
let blocks = parts && layout(parts);
|
|
126
|
+
if (!blocks) return;
|
|
127
|
+
if (event.inputType === "insertText" && event.data && [...event.data].length > 1) {
|
|
128
|
+
// Bulk native replacement (including dictation and automation) replaces the field;
|
|
129
|
+
// the owner retains parsing and validation of complete or incomplete pasted text.
|
|
130
|
+
event.preventDefault(); undo.push(snapshot()); redo.length = 0;
|
|
131
|
+
input.value = event.data; input.setSelectionRange(input.value.length, input.value.length);
|
|
132
|
+
announce(event.inputType); continued = -1; skipped = "";
|
|
133
|
+
} else if (event.inputType === "insertText" && event.data && [...event.data].length === 1) {
|
|
134
|
+
event.preventDefault(); insert(parts, blocks, event.data, event.inputType);
|
|
135
|
+
} else if (["deleteContentBackward", "deleteContentForward"].includes(event.inputType)) {
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
const all = input.selectionStart === 0 && input.selectionEnd === input.value.length;
|
|
138
|
+
let active = activeBlock(blocks);
|
|
139
|
+
if (all) blocks.forEach(block => { block.value = ""; });
|
|
140
|
+
else if (event.inputType === "deleteContentBackward") {
|
|
141
|
+
if (!blocks[active].value && active > 0) active--;
|
|
142
|
+
blocks[active].value = continued === active && input.selectionStart === input.selectionEnd ? [...blocks[active].value].slice(0, -1).join("") : "";
|
|
143
|
+
} else blocks[active].value = "";
|
|
144
|
+
render(parts, blocks, active, event.inputType);
|
|
145
|
+
continued = -1; skipped = "";
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const key = event => {
|
|
149
|
+
if (event.isComposing || input.disabled || input.readOnly) return;
|
|
150
|
+
const parts = configuration();
|
|
151
|
+
const blocks = parts && layout(parts);
|
|
152
|
+
if (!blocks) return;
|
|
153
|
+
const modifier = event.ctrlKey || event.metaKey;
|
|
154
|
+
if (modifier && ["z", "y"].includes(event.key.toLowerCase())) {
|
|
155
|
+
const forward = event.key.toLowerCase() === "y" || event.shiftKey;
|
|
156
|
+
const from = forward ? redo : undo, to = forward ? undo : redo;
|
|
157
|
+
if (!from.length) return;
|
|
158
|
+
event.preventDefault(); to.push(snapshot());
|
|
159
|
+
const previous = from.pop(); input.value = previous.value; input.setSelectionRange(previous.start, previous.end);
|
|
160
|
+
continued = -1; skipped = ""; announce(forward ? "historyRedo" : "historyUndo");
|
|
161
|
+
} else if (!modifier && !event.altKey && !event.shiftKey && ["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) {
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
const active = activeBlock(blocks);
|
|
164
|
+
const next = event.key === "Home" ? 0 : event.key === "End" ? blocks.length - 1 : Math.max(0, Math.min(blocks.length - 1, active + (event.key === "ArrowLeft" ? -1 : 1)));
|
|
165
|
+
select(blocks[next]); continued = -1; skipped = "";
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const paste = event => {
|
|
169
|
+
const parts = configuration();
|
|
170
|
+
const blocks = parts && layout(parts);
|
|
171
|
+
const text = event.clipboardData?.getData("text");
|
|
172
|
+
// Adjacent code blocks consume a paste from the active position, like continued typing.
|
|
173
|
+
if (!blocks || !text || parts.some(part => part.literal) || input.disabled || input.readOnly) return;
|
|
174
|
+
if (input.selectionStart === 0 && input.selectionEnd === input.value.length) return;
|
|
175
|
+
if ([...text].some(character => !blocks[0].accepts.test(character))) return;
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
const active = activeBlock(blocks);
|
|
178
|
+
let characters = [...text];
|
|
179
|
+
for (let index = active; index < blocks.length && characters.length; index++) blocks[index].value = characters.splice(0, blocks[index].length).join("");
|
|
180
|
+
render(parts, blocks, Math.min(blocks.length - 1, active + [...text].length), "insertFromPaste");
|
|
181
|
+
continued = -1; skipped = "";
|
|
182
|
+
};
|
|
183
|
+
const native = () => { if (!internal) { undo.length = 0; redo.length = 0; continued = -1; skipped = ""; expectedValue = input.value; } };
|
|
184
|
+
const start = () => { composing = true; };
|
|
185
|
+
const end = () => { composing = false; native(); };
|
|
186
|
+
const events = { focus, "select-first-segment": reselect, pointerdown: down, click: pointer, beforeinput: before, keydown: key, paste, input: native, compositionstart: start, compositionend: end };
|
|
187
|
+
for (const [name, listener] of Object.entries(events)) input.addEventListener(name, listener);
|
|
188
|
+
queueMicrotask(() => { if (connected && input.ownerDocument.activeElement === input && input.value === String(readInitialValue() ?? input.defaultValue)) focus(); });
|
|
189
|
+
return () => { connected = false; for (const [name, listener] of Object.entries(events)) input.removeEventListener(name, listener); };
|
|
190
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { bindModule } from "@nextwebwg/html-next/bindings";
|
|
2
|
+
|
|
3
|
+
/** Retain host-aware providers and a checked transfer revision across preparation and connection. */
|
|
4
|
+
export function preparedModule(create) {
|
|
5
|
+
const bindings = new WeakMap();
|
|
6
|
+
const instance = (host, source) => {
|
|
7
|
+
let binding = bindings.get(host.props);
|
|
8
|
+
if (!binding) {
|
|
9
|
+
binding = bindModule(create(host), { browser: { source } });
|
|
10
|
+
bindings.set(host.props, binding);
|
|
11
|
+
}
|
|
12
|
+
return binding;
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
connect(host, context) { return instance(host).connect(host, context); },
|
|
16
|
+
prepare(host, options) { return instance(host).prepare(host, options); },
|
|
17
|
+
adopt(host, options) { return instance(host, options.snapshot.source).adopt(host, options); },
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
></computed>
|
|
13
13
|
<prop name="variant" type="keyword" values="outline, solid, danger, ghost, link, card, field" default="outline"
|
|
14
14
|
>Emphasis: how loudly the button asks. solid fills with its tone, outline draws its tone at the edge over a wash of it, ghost carries only text until it is
|
|
15
|
-
hovered, and link is an inline text action that reads as a link. danger is solid in the danger tone, kept for the call sites that name it.
|
|
16
|
-
same tone on a full-width action with an icon slot, wrapping content, and a centered action slot. field opens a custom value picker: it
|
|
17
|
-
quiet outline, neutral text and slightly raised surface, independently of action tone.</prop>
|
|
15
|
+
hovered or selected, and link is an inline text action that reads as a link. danger is solid in the danger tone, kept for the call sites that name it.
|
|
16
|
+
card uses the same tone on a full-width action with an icon slot, wrapping content, and a centered action slot. field opens a custom value picker: it
|
|
17
|
+
shares Select's quiet outline, neutral text and slightly raised surface, independently of action tone.</prop>
|
|
18
18
|
<prop name="size" type="keyword" values="xs, sm, md, lg" default="md"
|
|
19
19
|
>Height, padding, and type size. xs is 1.5rem with the smallest text, for a control inside a line of small text; sm is the small control height (2rem by
|
|
20
20
|
default) with tighter padding and smaller text, md is the standard control height (2.5rem), and lg is taller (3rem) with roomier padding. Visible sizes
|
|
@@ -24,14 +24,19 @@
|
|
|
24
24
|
keep their normal layout.</prop>
|
|
25
25
|
<prop name="shape" type="keyword" values="rounded, pill" default="rounded"
|
|
26
26
|
>rounded uses the theme's action radius; pill rounds the ends fully, for a compact choice such as a status or a person.</prop>
|
|
27
|
+
<prop name="selected" type="boolean" default="false"
|
|
28
|
+
>Keeps a ghost choice highlighted with the shared selection surface and text colors, matching selected menu choices independently of its action tone.
|
|
29
|
+
Composite controls own the appropriate selection semantics, such as aria-selected on a grid cell; this visual state does not make the button a
|
|
30
|
+
toggle.</prop>
|
|
27
31
|
<prop name="tone" type="keyword" values="accent, accent-secondary, accent-tertiary, neutral, danger, success, warning, info" default="neutral"
|
|
28
32
|
>Which colour the button speaks in. It applies to every variant, so an outline, a ghost, and a solid in the same tone are the same action at three volumes:
|
|
29
33
|
tone="danger" variant="outline" is a destructive secondary action. neutral is the quiet one, for a button that should not claim a colour. The field
|
|
30
34
|
variant always uses neutral field colors. Supporting brand families use accent-secondary and accent-tertiary; their usable colors derive from the theme,
|
|
31
35
|
and unset families follow the primary accent.</prop>
|
|
32
36
|
<prop name="disabled" type="boolean" default="false"
|
|
33
|
-
>Makes the button unavailable: it cannot be pressed, uses
|
|
34
|
-
|
|
37
|
+
>Makes the button unavailable: it cannot be pressed, uses muted neutral colors, and loses its raised look. An unselected disabled ghost keeps its
|
|
38
|
+
transparent surface; a selected ghost retains a muted selection wash. A disabled link (with href) drops its href and states aria-disabled="true" instead,
|
|
39
|
+
because a link has no native disabled state.</prop>
|
|
35
40
|
<prop name="loading" type="boolean" default="false"
|
|
36
41
|
>Keeps the action focusable and its label visible while work is in progress. It shows a decorative spinner, states aria-disabled and aria-busy, and prevents
|
|
37
42
|
activation or form submission until cleared.</prop>
|
|
@@ -54,6 +59,7 @@
|
|
|
54
59
|
<a
|
|
55
60
|
from:data-appearance="$appearance"
|
|
56
61
|
from:data-tone="$colorTone"
|
|
62
|
+
from:data-selected="$selected"
|
|
57
63
|
$when="$appearance = 'card' and $href != null"
|
|
58
64
|
from:href="{ true: null, false: $href }[concat($disabled or $loading or $pending)]"
|
|
59
65
|
from:target="$target"
|
|
@@ -71,6 +77,7 @@
|
|
|
71
77
|
<button
|
|
72
78
|
from:data-appearance="$appearance"
|
|
73
79
|
from:data-tone="$colorTone"
|
|
80
|
+
from:data-selected="$selected"
|
|
74
81
|
$when="$appearance = 'card'"
|
|
75
82
|
from:type="$type"
|
|
76
83
|
from:disabled="$disabled"
|
|
@@ -86,6 +93,7 @@
|
|
|
86
93
|
<a
|
|
87
94
|
from:data-appearance="$appearance"
|
|
88
95
|
from:data-tone="$colorTone"
|
|
96
|
+
from:data-selected="$selected"
|
|
89
97
|
$when="$href != null"
|
|
90
98
|
from:href="{ true: null, false: $href }[concat($disabled or $loading or $pending)]"
|
|
91
99
|
from:target="$target"
|
|
@@ -101,6 +109,7 @@
|
|
|
101
109
|
<button
|
|
102
110
|
from:data-appearance="$appearance"
|
|
103
111
|
from:data-tone="$colorTone"
|
|
112
|
+
from:data-selected="$selected"
|
|
104
113
|
$else
|
|
105
114
|
from:type="$type"
|
|
106
115
|
from:disabled="$disabled"
|
|
@@ -250,8 +259,8 @@
|
|
|
250
259
|
}
|
|
251
260
|
|
|
252
261
|
:host([size="xs"]) {
|
|
253
|
-
--_button-square-size:
|
|
254
|
-
min-block-size:
|
|
262
|
+
--_button-square-size: var(--ui-control-size-xs);
|
|
263
|
+
min-block-size: var(--ui-control-size-xs);
|
|
255
264
|
padding: calc(var(--ui-space-0-5) * 1.5) calc(var(--ui-space-1) * 1.25) !important;
|
|
256
265
|
font-size: var(--ui-font-size-xs);
|
|
257
266
|
}
|
|
@@ -589,8 +598,16 @@
|
|
|
589
598
|
box-shadow: inset 0 0 0 1px oklch(from var(--_tone) l c h / 10%), inset 0 1px 2px oklch(from var(--_tone) l c h / 8%);
|
|
590
599
|
}
|
|
591
600
|
|
|
601
|
+
:host[data-appearance="ghost"][data-selected]:not(:disabled, [aria-disabled="true"]) {
|
|
602
|
+
background-color: var(--ui-button-ghost-active-surface, var(--ui-selection-surface));
|
|
603
|
+
color: var(--ui-button-ghost-text, var(--ui-selection-text));
|
|
604
|
+
border-color: transparent;
|
|
605
|
+
box-shadow: inset 0 0 0 1px var(--ui-selection-border);
|
|
606
|
+
}
|
|
607
|
+
|
|
592
608
|
/* A soft halo that transitions in with the other box-shadow changes, layered on the raised shadow. */
|
|
593
|
-
:host:focus-visible
|
|
609
|
+
:host:focus-visible,
|
|
610
|
+
:host[data-appearance="ghost"][data-selected]:focus-visible {
|
|
594
611
|
outline: none;
|
|
595
612
|
box-shadow:
|
|
596
613
|
var(--ui-button-shadow, var(--ui-action-shadow, var(--_ui-action-shadow))),
|
|
@@ -630,12 +647,16 @@
|
|
|
630
647
|
box-shadow: var(--ui-focus-halo);
|
|
631
648
|
}
|
|
632
649
|
|
|
633
|
-
/*
|
|
650
|
+
/* Disabled ghost actions keep the quiet variant's transparent surface and muted text. */
|
|
634
651
|
:host[data-appearance="ghost"]:is(:disabled, [aria-disabled="true"]:not([aria-busy="true"])) {
|
|
635
|
-
background-color:
|
|
652
|
+
background-color: transparent;
|
|
636
653
|
border-color: transparent;
|
|
637
654
|
}
|
|
638
655
|
|
|
656
|
+
:host[data-appearance="ghost"][data-selected]:is(:disabled, [aria-disabled="true"]:not([aria-busy="true"])) {
|
|
657
|
+
background-color: var(--ui-disabled-surface);
|
|
658
|
+
}
|
|
659
|
+
|
|
639
660
|
/* The size states outrank :host, so sm is named too, or a small button would stay small. */
|
|
640
661
|
|
|
641
662
|
/* Under touch, a link-style button's press lands within the control minimum: an invisible hit
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { calendarModel } from "../shared/calendar-model.js";
|
|
2
|
+
import { Temporal } from "../shared/date-time.js";
|
|
3
|
+
import { readOptionalInput } from "../shared/binding-inputs.js";
|
|
4
|
+
|
|
5
|
+
const chunk = values => Array.from({ length: Math.ceil(values.length / 3) }, (_, index) => values.slice(index * 3, index * 3 + 3));
|
|
6
|
+
|
|
7
|
+
/** Pure selected-input producer, shared by server preparation and browser updates. */
|
|
8
|
+
export function createCalendarBindings(inputs) {
|
|
9
|
+
return {
|
|
10
|
+
model: {
|
|
11
|
+
// Retain the rendered date cells while synchronous projections refresh,
|
|
12
|
+
// so range previews do not remove the currently focused keyboard target.
|
|
13
|
+
keepPrevious: true,
|
|
14
|
+
input(props, { state }) {
|
|
15
|
+
return {
|
|
16
|
+
month: state.visibleMonth || state.current.slice(0, 7) || props.today.slice(0, 7),
|
|
17
|
+
value: state.current, focusedDate: state.focusedDate, yearPageStart: state.yearPageStart || undefined,
|
|
18
|
+
locale: props.locale, today: props.today, start: props.start, end: props.end,
|
|
19
|
+
weekStartsOn: readOptionalInput(inputs, props, "weekStartsOn"), min: props.min, max: props.max,
|
|
20
|
+
allowedDates: readOptionalInput(inputs, props, "allowedDates"), allowedRanges: readOptionalInput(inputs, props, "allowedRanges"),
|
|
21
|
+
disabledDates: props.disabledDates, disabledRanges: props.disabledRanges, disabledWeekdays: props.disabledWeekdays,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
load(input) {
|
|
25
|
+
const model = calendarModel({ ...input, month: input.month || Temporal.Now.plainDateISO("UTC").toString().slice(0, 7) });
|
|
26
|
+
for (const choices of [model.months, model.years]) {
|
|
27
|
+
const focus = choices.find(item => item.current && !item.disabled) ?? choices.find(item => !item.disabled);
|
|
28
|
+
for (const item of choices) item.tabIndex = item === focus ? 0 : -1;
|
|
29
|
+
}
|
|
30
|
+
return { ...model, monthRows: chunk(model.months), yearRows: chunk(model.years) };
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
<link rel="component" href="../ui-stack/ui-stack.html">
|
|
2
|
+
<link rel="component" href="../ui-cluster/ui-cluster.html">
|
|
3
|
+
<link rel="component" href="../ui-grid/ui-grid.html">
|
|
4
|
+
<link rel="component" href="../ui-button/ui-button.html">
|
|
5
|
+
<link rel="component" href="../ui-icon-button/ui-icon-button.html">
|
|
6
|
+
<link rel="component" href="../ui-icon/ui-icon.html">
|
|
7
|
+
<link rel="component" href="../ui-text/ui-text.html">
|
|
8
|
+
<link rel="component" href="../ui-input/ui-input.html">
|
|
9
|
+
<template component="ui-calendar" module="./ui-calendar.js">
|
|
10
|
+
<defs>
|
|
11
|
+
<prop name="value" type="string" default=""
|
|
12
|
+
>Initial selected YYYY-MM-DD civil date, replaced on an external change. Selection events always export just the date, without a time or timezone.
|
|
13
|
+
Navigation does not select.</prop>
|
|
14
|
+
<prop name="month" type="string" default=""
|
|
15
|
+
>Initial visible YYYY-MM, replaced on an external change. Omission follows value, today, then the current UTC month.</prop>
|
|
16
|
+
<prop name="locale" type="string" default="en-US">Intl Gregorian labels, digits and default week order.</prop>
|
|
17
|
+
<prop name="today" type="string" default="">Optional explicit YYYY-MM-DD date to mark as today; omission adds no today marker.</prop>
|
|
18
|
+
<prop name="weekStartsOn" type="integer" min="1" max="7"
|
|
19
|
+
>Week order override using ISO weekdays: Sunday 7, Saturday 6, or Monday 1. Omission follows the locale's week information, with Sunday as the fallback when
|
|
20
|
+
unavailable.</prop>
|
|
21
|
+
<prop name="min" type="string" default="">Inclusive earliest selectable YYYY-MM-DD date.</prop>
|
|
22
|
+
<prop name="max" type="string" default="">Inclusive latest selectable YYYY-MM-DD date.</prop>
|
|
23
|
+
<prop name="allowedDates" type="list(string)">Allow-listed dates; omission is unrestricted, an explicit empty list allows none.</prop>
|
|
24
|
+
<prop name="allowedRanges" type="list(object({ start: string, end: string }))">Inclusive allowed intervals, unioned with allowed-dates.</prop>
|
|
25
|
+
<prop name="disabledDates" type="list(string)" default="[]">Unavailable dates, subtracted after bounds and allowed rules.</prop>
|
|
26
|
+
<prop name="disabledRanges" type="list(object({ start: string, end: string }))" default="[]"
|
|
27
|
+
>Inclusive unavailable intervals with YYYY-MM-DD start and end dates, subtracted after bounds and allowed rules.</prop>
|
|
28
|
+
<prop name="disabledWeekdays" type="list(integer)" default="[]">Unavailable ISO weekdays: Monday 1 through Sunday 7.</prop>
|
|
29
|
+
<prop name="start" type="string" default="">Optional range highlight's inclusive YYYY-MM-DD start.</prop>
|
|
30
|
+
<prop name="end" type="string" default="">Optional range highlight's inclusive YYYY-MM-DD end. The caller owns range coordination.</prop>
|
|
31
|
+
<prop name="label" type="string" default="Calendar">Accessible name of the calendar group.</prop>
|
|
32
|
+
<prop name="previousLabel" type="string" default="Previous">Accessible name of the previous month, year or year-page action.</prop>
|
|
33
|
+
<prop name="nextLabel" type="string" default="Next">Accessible name of the next month, year or year-page action.</prop>
|
|
34
|
+
<prop name="monthLabel" type="string" default="Choose month">Accessible name of the month view toggle.</prop>
|
|
35
|
+
<prop name="yearLabel" type="string" default="Choose year">Accessible name of the year view toggle and direct year input.</prop>
|
|
36
|
+
<prop name="emptyLabel" type="string" default="No available dates this month.">Message when the displayed month has no selectable date.</prop>
|
|
37
|
+
<prop name="yearErrorLabel" type="string" default="Enter a year from 1 to 9999.">Direct year entry error.</prop>
|
|
38
|
+
<prop name="disabled" type="boolean" default="false">Prevents selection and navigation.</prop>
|
|
39
|
+
<prop name="readonly" type="boolean" default="false">Allows navigation while preventing selection.</prop>
|
|
40
|
+
<prop
|
|
41
|
+
name="model"
|
|
42
|
+
type="object({ rangeBands: list(object({ start: integer, end: integer })), month: string, title: string, monthLabel: string, yearLabel: string, weekStartsOn: integer, weekendColumns: list(integer), weekdays: list(object({ day: integer, label: string, fullLabel: string })), rows: list(list(object({ value: string, day: integer, outside: boolean, label: string, disabled: boolean, selected: boolean, today: boolean, rangeStart: boolean, rangeEnd: boolean, inRange: boolean, tabIndex: integer }))), focusDate: string, empty: boolean, previousMonth: string, nextMonth: string, months: list(object({ value: string, label: string, fullLabel: string, current: boolean, outsideBounds: boolean, disabled: boolean, tabIndex: integer })), years: list(object({ value: integer, label: string, current: boolean, outsideBounds: boolean, disabled: boolean, tabIndex: integer })), yearPageStart: integer, yearPageLabel: string, monthRows: list(list(object({ value: string, label: string, fullLabel: string, current: boolean, outsideBounds: boolean, disabled: boolean, tabIndex: integer }))), yearRows: list(list(object({ value: integer, label: string, current: boolean, outsideBounds: boolean, disabled: boolean, tabIndex: integer }))) })"
|
|
43
|
+
>Calendar data supplied by the component module's server-safe producer. Hosts prepare this input before SSR; caller-supplied fixtures override
|
|
44
|
+
production.</prop>
|
|
45
|
+
<state name="current" type="string" from="$value"></state>
|
|
46
|
+
<state name="visibleMonth" type="string" from="$month"></state>
|
|
47
|
+
<state name="focusedDate" type="string" value=""></state>
|
|
48
|
+
<state name="yearPageStart" type="integer" value="0"></state>
|
|
49
|
+
<state name="mode" type="string" value="days"></state>
|
|
50
|
+
<state name="viewHeight" type="number"></state>
|
|
51
|
+
<state name="yearError" type="string" value=""></state>
|
|
52
|
+
<event name="input" type="object"><prop name="value" type="string" required></prop><prop
|
|
53
|
+
name="trigger"
|
|
54
|
+
type="keyword"
|
|
55
|
+
values="keyboard, pointer, programmatic"
|
|
56
|
+
required
|
|
57
|
+
></prop></event>
|
|
58
|
+
<event name="change" type="object"><prop name="value" type="string" required></prop><prop
|
|
59
|
+
name="trigger"
|
|
60
|
+
type="keyword"
|
|
61
|
+
values="keyboard, pointer, programmatic"
|
|
62
|
+
required
|
|
63
|
+
></prop></event>
|
|
64
|
+
<event name="select" type="object"><prop name="value" type="string" required></prop><prop
|
|
65
|
+
name="trigger"
|
|
66
|
+
type="keyword"
|
|
67
|
+
values="keyboard, pointer, programmatic"
|
|
68
|
+
required
|
|
69
|
+
></prop></event>
|
|
70
|
+
<event name="month-change" type="object"><prop name="month" type="string" required></prop><prop
|
|
71
|
+
name="trigger"
|
|
72
|
+
type="keyword"
|
|
73
|
+
values="keyboard, pointer, programmatic"
|
|
74
|
+
required
|
|
75
|
+
></prop></event>
|
|
76
|
+
</defs>
|
|
77
|
+
<section role="group" from:aria-label="$label">
|
|
78
|
+
<ui-stack gap="s">
|
|
79
|
+
<ui-cluster justify="between" gap="xs" padding="s" wrap="nowrap">
|
|
80
|
+
<ui-icon-button
|
|
81
|
+
data-calendar-previous
|
|
82
|
+
size="sm"
|
|
83
|
+
variant="ghost"
|
|
84
|
+
from:label="$previousLabel"
|
|
85
|
+
from:disabled="$disabled or ($mode = 'days' and $model.previousMonth = '') or ($mode = 'months' and $model.month < '0002-01') or ($mode = 'years' and $model.yearPageStart = 1)"
|
|
86
|
+
><ui-icon name="chevron-left" directional></ui-icon></ui-icon-button>
|
|
87
|
+
<ui-cluster fixed gap="xs" wrap="nowrap" aria-live="polite" aria-atomic="true">
|
|
88
|
+
<ui-button
|
|
89
|
+
data-calendar-month-toggle
|
|
90
|
+
size="sm"
|
|
91
|
+
variant="ghost"
|
|
92
|
+
from:aria-label="concat($monthLabel, ': ', $model.monthLabel)"
|
|
93
|
+
from:aria-expanded="$mode = 'months'"
|
|
94
|
+
from:selected="$mode = 'months'"
|
|
95
|
+
from:disabled="$disabled"
|
|
96
|
+
><ui-text as="span">{$model.monthLabel}</ui-text><ui-icon name="chevron-down"></ui-icon></ui-button>
|
|
97
|
+
<ui-button
|
|
98
|
+
data-calendar-year-toggle
|
|
99
|
+
size="sm"
|
|
100
|
+
variant="ghost"
|
|
101
|
+
from:aria-label="concat($yearLabel, ': ', $model.yearLabel)"
|
|
102
|
+
from:aria-expanded="$mode = 'years'"
|
|
103
|
+
from:selected="$mode = 'years'"
|
|
104
|
+
from:disabled="$disabled"
|
|
105
|
+
>{$model.yearLabel}<ui-icon name="chevron-down"></ui-icon></ui-button>
|
|
106
|
+
</ui-cluster>
|
|
107
|
+
<ui-icon-button
|
|
108
|
+
data-calendar-next
|
|
109
|
+
size="sm"
|
|
110
|
+
variant="ghost"
|
|
111
|
+
from:label="$nextLabel"
|
|
112
|
+
from:disabled="$disabled or ($mode = 'days' and $model.nextMonth = '') or ($mode = 'months' and $model.month > '9998-12') or ($mode = 'years' and $model.yearPageStart >= 9997)"
|
|
113
|
+
><ui-icon name="chevron-right" directional></ui-icon></ui-icon-button>
|
|
114
|
+
</ui-cluster>
|
|
115
|
+
<ui-stack data-calendar-viewport gap="none" from:height="{ true: null, false: $viewHeight }[concat($mode = 'days')]">
|
|
116
|
+
<ui-stack
|
|
117
|
+
data-calendar-days
|
|
118
|
+
gap="none"
|
|
119
|
+
role="grid"
|
|
120
|
+
from:tabindex="{ true: 0, false: null }[concat($model.empty)]"
|
|
121
|
+
from:aria-label="$model.title"
|
|
122
|
+
from:aria-readonly="$readonly"
|
|
123
|
+
from:aria-multiselectable="$start != '' or $end != ''"
|
|
124
|
+
from:hidden="$mode != 'days'"
|
|
125
|
+
>
|
|
126
|
+
<ui-grid fixed columns="7" gap="none" role="row" shaded-columns="[1,2,3,4,5,6,7]" shade-tone="accent">
|
|
127
|
+
<template $each="weekday of $model.weekdays" $key="$weekday.day"><ui-cluster
|
|
128
|
+
justify="center"
|
|
129
|
+
padding="s"
|
|
130
|
+
wrap="nowrap"
|
|
131
|
+
role="columnheader"
|
|
132
|
+
from:aria-label="$weekday.fullLabel"
|
|
133
|
+
><ui-text variant="caption" weight="semibold" tone="secondary">{$weekday.label}</ui-text></ui-cluster></template>
|
|
134
|
+
</ui-grid>
|
|
135
|
+
<template $each="row, index of $model.rows" $key="$row[0].value">
|
|
136
|
+
<ui-grid
|
|
137
|
+
fixed
|
|
138
|
+
columns="7"
|
|
139
|
+
gap="none"
|
|
140
|
+
role="row"
|
|
141
|
+
from:shaded-columns="$model.weekendColumns"
|
|
142
|
+
from:selection-start="$model.rangeBands[$index].start"
|
|
143
|
+
from:selection-end="$model.rangeBands[$index].end"
|
|
144
|
+
>
|
|
145
|
+
<template $each="day of $row" $key="$day.value">
|
|
146
|
+
<ui-cluster
|
|
147
|
+
justify="center"
|
|
148
|
+
padding="xs"
|
|
149
|
+
wrap="nowrap"
|
|
150
|
+
role="gridcell"
|
|
151
|
+
from:aria-selected="$day.selected or $day.inRange or $day.rangeStart or $day.rangeEnd"
|
|
152
|
+
from:aria-disabled="$day.disabled or $disabled = true"
|
|
153
|
+
>
|
|
154
|
+
<ui-button
|
|
155
|
+
from:data-calendar-day="$day.value"
|
|
156
|
+
size="sm"
|
|
157
|
+
square
|
|
158
|
+
shape="pill"
|
|
159
|
+
variant="ghost"
|
|
160
|
+
from:selected="($day.selected and $start = '' and $end = '') or $day.rangeStart or $day.rangeEnd"
|
|
161
|
+
from:disabled="$disabled or $day.disabled"
|
|
162
|
+
from:tabindex="$day.tabIndex"
|
|
163
|
+
from:aria-label="$day.label"
|
|
164
|
+
from:aria-current="{ true: 'date', false: null }[concat($day.today)]"
|
|
165
|
+
><ui-text
|
|
166
|
+
as="span"
|
|
167
|
+
variant="label"
|
|
168
|
+
from:weight="{ true: 'semibold', false: { true: 'normal', false: 'inherit' }[concat($day.outside)] }[concat($day.today)]"
|
|
169
|
+
from:tone="{ true: 'muted', false: 'default' }[concat($day.outside and not $day.inRange and not $day.selected)]"
|
|
170
|
+
>{format($day.day, 'number', {}, $locale)}</ui-text></ui-button>
|
|
171
|
+
</ui-cluster>
|
|
172
|
+
</template>
|
|
173
|
+
</ui-grid>
|
|
174
|
+
</template>
|
|
175
|
+
</ui-stack>
|
|
176
|
+
<ui-text variant="caption" align="center" from:hidden="not $model.empty or $mode != 'days'">{$emptyLabel}</ui-text>
|
|
177
|
+
<ui-stack data-calendar-months fill justify="center" gap="m" role="grid" from:aria-label="$monthLabel" from:hidden="$mode != 'months'">
|
|
178
|
+
<template $each="row of $model.monthRows" $key="$row[0].value"><ui-grid fixed columns="3" gap="xs" role="row">
|
|
179
|
+
<template $each="choice of $row" $key="$choice.value"><span role="gridcell" from:aria-selected="$choice.current"><ui-button
|
|
180
|
+
from:data-calendar-month="$choice.value"
|
|
181
|
+
from:aria-label="$choice.fullLabel"
|
|
182
|
+
from:title="$choice.fullLabel"
|
|
183
|
+
size="sm"
|
|
184
|
+
stretch
|
|
185
|
+
variant="ghost"
|
|
186
|
+
shape="pill"
|
|
187
|
+
from:selected="$choice.current"
|
|
188
|
+
from:disabled="$disabled or $choice.disabled"
|
|
189
|
+
from:tabindex="$choice.tabIndex"
|
|
190
|
+
><ui-text as="span" wrap="anywhere" align="center">{$choice.label}</ui-text></ui-button></span></template>
|
|
191
|
+
</ui-grid></template>
|
|
192
|
+
</ui-stack>
|
|
193
|
+
<ui-stack data-calendar-years fill justify="center" gap="s" from:hidden="$mode != 'years'">
|
|
194
|
+
<ui-input
|
|
195
|
+
data-calendar-year-input
|
|
196
|
+
size="sm"
|
|
197
|
+
inputmode="numeric"
|
|
198
|
+
from:aria-label="$yearLabel"
|
|
199
|
+
from:disabled="$disabled"
|
|
200
|
+
from:invalid="$yearError != ''"
|
|
201
|
+
></ui-input>
|
|
202
|
+
<ui-text variant="caption" tone="danger" role="alert" from:hidden="$yearError = ''">{$yearError}</ui-text>
|
|
203
|
+
<ui-stack gap="m" role="grid" from:aria-label="$yearLabel">
|
|
204
|
+
<template $each="row of $model.yearRows" $key="$row[0].value"><ui-grid fixed columns="3" gap="xs" role="row">
|
|
205
|
+
<template $each="year of $row" $key="$year.value"><span role="gridcell" from:aria-selected="$year.current"><ui-button
|
|
206
|
+
from:data-calendar-year="$year.value"
|
|
207
|
+
size="sm"
|
|
208
|
+
stretch
|
|
209
|
+
variant="ghost"
|
|
210
|
+
shape="pill"
|
|
211
|
+
from:selected="$year.current"
|
|
212
|
+
from:disabled="$disabled or $year.disabled"
|
|
213
|
+
from:tabindex="$year.tabIndex"
|
|
214
|
+
>{$year.label}</ui-button></span></template>
|
|
215
|
+
</ui-grid></template>
|
|
216
|
+
</ui-stack>
|
|
217
|
+
</ui-stack>
|
|
218
|
+
</ui-stack>
|
|
219
|
+
</ui-stack>
|
|
220
|
+
</section>
|
|
221
|
+
</template>
|