viewkitjs 0.32.0 → 0.34.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/CHANGELOG.md +98 -0
- package/fields/dist/index.d.ts +1 -1
- package/fields/dist/index.js +1 -1
- package/fields/dist/query/evaluate.d.ts +7 -0
- package/fields/dist/query/exact-number.d.ts +8 -2
- package/fields/dist/query/exact-number.js +14 -1
- package/fields/dist/query/sort.js +13 -10
- package/fields/dist/registry.js +5 -1
- package/fields/dist/types.d.ts +4 -1
- package/fields/dist/zod.d.ts +5 -0
- package/fields/dist/zod.js +10 -1
- package/fields/docs/guides/contact-values.md +12 -0
- package/fields/docs/guides/field-types.md +1 -1
- package/fields/docs/guides/queries.md +3 -1
- package/fields/docs/reference/fields.md +1 -0
- package/package.json +1 -1
- package/postgres/dist/check.js +4 -1
- package/postgres/dist/definitions/formula-forms.js +3 -1
- package/postgres/dist/definitions/money.js +2 -1
- package/postgres/dist/page.js +6 -3
- package/postgres/dist/rules.d.ts +15 -1
- package/postgres/dist/rules.js +16 -0
- package/postgres/dist/sort.js +7 -2
- package/postgres/docs/guides/definitions.md +1 -1
- package/postgres/docs/guides/field-map.md +1 -1
- package/postgres/docs/reference/definitions.md +1 -1
- package/postgres/docs/reference/postgres.md +1 -1
- package/views/dist/atoms/ToolbarButton.d.ts +1 -1
- package/views/dist/atoms/ToolbarButton.js +4 -3
- package/views/dist/atoms/frame-parts.d.ts +6 -0
- package/views/dist/atoms/frame-parts.js +15 -0
- package/views/dist/atoms/types.d.ts +16 -7
- package/views/dist/cells/cell-title.d.ts +3 -1
- package/views/dist/cells/cell-title.js +2 -2
- package/views/dist/cells/cell-values.js +2 -2
- package/views/dist/contract.d.ts +46 -11
- package/views/dist/contract.js +157 -0
- package/views/dist/controls/alert/alert.js +2 -1
- package/views/dist/controls/alert-dialog/alert-dialog.js +3 -2
- package/views/dist/controls/bulk-bar/bulk-bar.js +25 -22
- package/views/dist/controls/button/map-button.js +2 -0
- package/views/dist/controls/checkbox/checkbox.d.ts +3 -2
- package/views/dist/controls/checkbox/checkbox.js +2 -2
- package/views/dist/controls/compound-editor/compound-editor.d.ts +1 -1
- package/views/dist/controls/compound-editor/name-parts.js +4 -4
- package/views/dist/controls/compound-editor/place-parts.js +19 -19
- package/views/dist/controls/compound-editor/range-parts.js +14 -14
- package/views/dist/controls/compound-editor/row.d.ts +3 -1
- package/views/dist/controls/compound-editor/row.js +2 -2
- package/views/dist/controls/controls.d.ts +4 -0
- package/views/dist/controls/controls.js +4 -0
- package/views/dist/controls/customize/customize.js +43 -39
- package/views/dist/controls/customize/map-customize-body.d.ts +2 -0
- package/views/dist/controls/customize/map-customize-body.js +7 -2
- package/views/dist/controls/date-editor/date-days.js +2 -2
- package/views/dist/controls/date-editor/date-editor.d.ts +3 -0
- package/views/dist/controls/date-editor/date-editor.js +27 -21
- package/views/dist/controls/date-editor/date-parts.js +6 -6
- package/views/dist/controls/date-editor/map-calendar.js +3 -1
- package/views/dist/controls/date-editor/map-date-body.d.ts +1 -1
- package/views/dist/controls/date-editor/map-date-body.js +7 -3
- package/views/dist/controls/date-editor.css +2 -2
- package/views/dist/controls/field/field.d.ts +3 -0
- package/views/dist/controls/field/field.js +6 -6
- package/views/dist/controls/filter-editor/block.d.ts +2 -2
- package/views/dist/controls/filter-editor/block.js +5 -5
- package/views/dist/controls/filter-editor/filter-editor.js +31 -33
- package/views/dist/controls/filter-editor/how.d.ts +3 -1
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +3 -0
- package/views/dist/controls/filter-editor/map-filter-body.js +11 -4
- package/views/dist/controls/filter-editor/map-rules.js +1 -1
- package/views/dist/controls/filter-editor/parts.d.ts +3 -1
- package/views/dist/controls/filter-editor/parts.js +8 -6
- package/views/dist/controls/group-editor/group-editor.js +17 -14
- package/views/dist/controls/group-editor/map-group-body.d.ts +1 -0
- package/views/dist/controls/group-editor/map-group-body.js +5 -1
- package/views/dist/controls/index.d.ts +2 -0
- package/views/dist/controls/index.js +1 -0
- package/views/dist/controls/input/input.js +4 -3
- package/views/dist/controls/input/map-input.js +2 -0
- package/views/dist/controls/internal/editor-parts.js +1 -1
- package/views/dist/controls/internal/head-button.d.ts +9 -0
- package/views/dist/controls/internal/head-button.js +13 -0
- package/views/dist/controls/internal/map-panel-controls.d.ts +8 -0
- package/views/dist/controls/internal/map-panel-controls.js +20 -0
- package/views/dist/controls/internal/panel-controls.d.ts +58 -0
- package/views/dist/controls/internal/panel-controls.js +240 -0
- package/views/dist/controls/internal/part-slot.d.ts +12 -0
- package/views/dist/controls/internal/part-slot.js +5 -0
- package/views/dist/controls/links-editor/links-editor.d.ts +1 -1
- package/views/dist/controls/links-editor/links-editor.js +27 -27
- package/views/dist/controls/menu/map-menu.d.ts +2 -2
- package/views/dist/controls/menu/map-menu.js +15 -12
- package/views/dist/controls/menu/menu.d.ts +3 -0
- package/views/dist/controls/menu/menu.js +5 -5
- package/views/dist/controls/menu-list/menu-list.d.ts +14 -4
- package/views/dist/controls/menu-list/menu-list.js +23 -22
- package/views/dist/controls/modal/modal.js +5 -3
- package/views/dist/controls/notice/notice.d.ts +3 -1
- package/views/dist/controls/notice/notice.js +2 -2
- package/views/dist/controls/number-editor/map-number-body.js +5 -1
- package/views/dist/controls/number-editor/number-editor.d.ts +1 -1
- package/views/dist/controls/number-editor/number-editor.js +16 -16
- package/views/dist/controls/number-field/number-field.js +5 -3
- package/views/dist/controls/pane/map-pane.d.ts +3 -0
- package/views/dist/controls/pane/map-pane.js +5 -0
- package/views/dist/controls/pane/pane.d.ts +4 -2
- package/views/dist/controls/pane/pane.js +4 -4
- package/views/dist/controls/picker/map-fields-body.js +25 -1
- package/views/dist/controls/picker/picker.d.ts +2 -0
- package/views/dist/controls/picker/picker.js +37 -36
- package/views/dist/controls/picker/rows.d.ts +4 -0
- package/views/dist/controls/picker.css +10 -1
- package/views/dist/controls/popover/map-popover.d.ts +1 -1
- package/views/dist/controls/popover/map-popover.js +4 -2
- package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +2 -1
- package/views/dist/controls/quick-filters/map-quick-filters-body.js +7 -3
- package/views/dist/controls/quick-filters/quick-filters.js +8 -6
- package/views/dist/controls/radio/radio.d.ts +3 -0
- package/views/dist/controls/radio/radio.js +4 -3
- package/views/dist/controls/select/map-select.d.ts +3 -0
- package/views/dist/controls/select/map-select.js +8 -0
- package/views/dist/controls/select/select.d.ts +3 -0
- package/views/dist/controls/select/select.js +3 -3
- package/views/dist/controls/setting-row/looks.js +5 -5
- package/views/dist/controls/setting-row/setting-row.d.ts +3 -1
- package/views/dist/controls/setting-row/setting-row.js +3 -1
- package/views/dist/controls/setting-row.css +3 -2
- package/views/dist/controls/sheet/bottom-sheet.d.ts +8 -2
- package/views/dist/controls/sheet/bottom-sheet.js +4 -4
- package/views/dist/controls/sheet/map-sheet.js +1 -1
- package/views/dist/controls/sort-editor/map-sort-body.d.ts +1 -0
- package/views/dist/controls/sort-editor/map-sort-body.js +8 -4
- package/views/dist/controls/sort-editor/sort-editor.js +24 -26
- package/views/dist/controls/sort-editor.css +5 -0
- package/views/dist/controls/text-editor/map-text-body.js +5 -1
- package/views/dist/controls/text-editor/text-editor.d.ts +1 -1
- package/views/dist/controls/text-editor/text-editor.js +11 -10
- package/views/dist/controls/toolbar/toolbar.d.ts +4 -2
- package/views/dist/controls/toolbar/toolbar.js +2 -2
- package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +3 -3
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +7 -6
- package/views/dist/controls/values-editor/values-editor.d.ts +1 -1
- package/views/dist/controls/values-editor/values-editor.js +22 -22
- package/views/dist/controls/views-list/map-view-menu.d.ts +3 -2
- package/views/dist/controls/views-list/map-view-menu.js +7 -3
- package/views/dist/controls/views-list/map-views-list-body.d.ts +2 -1
- package/views/dist/controls/views-list/map-views-list-body.js +6 -5
- package/views/dist/controls/views-list/view-menu.js +9 -10
- package/views/dist/controls/views-list/views-list.js +6 -6
- package/views/dist/editors/EditorPanel.js +4 -4
- package/views/dist/field-row/FieldRow.js +13 -0
- package/views/dist/fields/money.d.ts +5 -2
- package/views/dist/fields/money.js +14 -2
- package/views/dist/grid/chrome/GridTable.js +4 -1
- package/views/dist/grid/chrome/cell-clipboard.d.ts +4 -2
- package/views/dist/grid/chrome/cell-clipboard.js +2 -2
- package/views/dist/grid/chrome/cells.js +3 -1
- package/views/dist/grid/chrome/grid-row-menu-items.js +1 -1
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -1
- package/views/dist/grid/chrome/useGridKeyboard.js +29 -6
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +9 -2
- package/views/dist/grid/core/clipboard-model.d.ts +3 -1
- package/views/dist/grid/core/clipboard-model.js +9 -8
- package/views/dist/grid/core/editing-controller.d.ts +3 -0
- package/views/dist/grid/core/editing-controller.js +6 -0
- package/views/dist/grid/core/edits-sink.d.ts +19 -0
- package/views/dist/grid/core/edits-sink.js +2 -0
- package/views/dist/grid/core/spreadsheet-operations.js +1 -1
- package/views/dist/grid/core/useGridEditing.d.ts +5 -0
- package/views/dist/grid/core/useGridEditing.js +6 -0
- package/views/dist/list/answer.d.ts +40 -0
- package/views/dist/list/answer.js +43 -0
- package/views/dist/list/bulk-bar.d.ts +7 -0
- package/views/dist/list/bulk-bar.js +10 -0
- package/views/dist/list/columns.d.ts +24 -0
- package/views/dist/list/columns.js +27 -0
- package/views/dist/list/edits.d.ts +19 -0
- package/views/dist/list/edits.js +56 -0
- package/views/dist/list/grid.d.ts +11 -0
- package/views/dist/list/grid.js +76 -0
- package/views/dist/list/index.d.ts +14 -1
- package/views/dist/list/index.js +4 -1
- package/views/dist/list/link.d.ts +8 -0
- package/views/dist/list/link.js +78 -0
- package/views/dist/list/list.d.ts +74 -0
- package/views/dist/list/list.js +18 -0
- package/views/dist/list/parts.js +11 -3
- package/views/dist/list/root-base.d.ts +46 -0
- package/views/dist/list/root-base.js +137 -0
- package/views/dist/list/root.d.ts +35 -34
- package/views/dist/list/root.js +153 -113
- package/views/dist/list/source-answers.d.ts +39 -0
- package/views/dist/list/source-answers.js +225 -0
- package/views/dist/list/store.d.ts +37 -5
- package/views/dist/list/store.js +31 -0
- package/views/dist/list/toolbar.d.ts +3 -2
- package/views/dist/list/toolbar.js +23 -5
- package/views/dist/list/views-axis.js +4 -2
- package/views/dist/list/views.d.ts +7 -2
- package/views/dist/list/views.js +16 -5
- package/views/dist/model/column-capabilities.d.ts +13 -0
- package/views/dist/model/column-capabilities.js +23 -2
- package/views/dist/model/column-schema.d.ts +11 -1
- package/views/dist/model/view-rules.js +1 -0
- package/views/dist/panels/model.d.ts +2 -0
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +21 -2
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +2 -2
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +12 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +20 -6
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +4 -3
- package/views/dist/panels/react/toolbar/ToolbarAsideFilter.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +4 -4
- package/views/dist/panels/react/toolbar/ToolbarButton.js +4 -1
- package/views/dist/panels/react/toolbar/ToolbarFilter.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +4 -3
- package/views/dist/panels/react/toolbar/ToolbarFilterSheet.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +5 -4
- package/views/dist/panels/react/toolbar/ToolbarNew.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSort.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +8 -5
- package/views/dist/panels/react/toolbar/context.d.ts +31 -1
- package/views/dist/panels/react/toolbar/context.js +4 -0
- package/views/dist/panels/react/toolbar/pane-host.d.ts +6 -0
- package/views/dist/panels/react/toolbar/pane-host.js +17 -0
- package/views/dist/panels/react/toolbar/panel-part.d.ts +4 -1
- package/views/dist/panels/react/toolbar/panel-part.js +7 -4
- package/views/dist/panels/react.d.ts +1 -1
- package/views/dist/panels/settings/filter-groups.js +6 -1
- package/views/dist/provider/ViewsProvider.d.ts +7 -2
- package/views/dist/provider/ViewsProvider.js +18 -1
- package/views/dist/provider/components.d.ts +90 -2
- package/views/dist/provider/components.js +1 -1
- package/views/dist/provider/context.d.ts +4 -1
- package/views/dist/provider/own-control.d.ts +4 -0
- package/views/dist/provider/own-control.js +7 -0
- package/views/dist/provider/select-items.d.ts +3 -0
- package/views/dist/provider/select-items.js +6 -0
- package/views/dist/react.d.ts +4 -2
- package/views/dist/react.js +2 -0
- package/views/dist/styles.css +107 -80
- package/views/dist/styles.unlayered.css +107 -80
- package/views/docs/contract.md +310 -7
- package/views/docs/controls/alert-dialog.md +4 -0
- package/views/docs/controls/alert.md +4 -0
- package/views/docs/controls/bulk-bar.md +4 -0
- package/views/docs/controls/compound-editor.md +4 -0
- package/views/docs/controls/customize.md +8 -0
- package/views/docs/controls/date-editor.md +6 -0
- package/views/docs/controls/field.md +4 -0
- package/views/docs/controls/filter-editor.md +8 -0
- package/views/docs/controls/group-editor.md +8 -0
- package/views/docs/controls/input.md +4 -0
- package/views/docs/controls/links-editor.md +4 -0
- package/views/docs/controls/menu-list.md +8 -0
- package/views/docs/controls/menu.md +6 -0
- package/views/docs/controls/modal.md +4 -0
- package/views/docs/controls/notice.md +4 -0
- package/views/docs/controls/number-editor.md +6 -0
- package/views/docs/controls/pane.md +4 -0
- package/views/docs/controls/picker.md +8 -0
- package/views/docs/controls/quick-filters.md +8 -0
- package/views/docs/controls/radio.md +4 -0
- package/views/docs/controls/select.md +8 -0
- package/views/docs/controls/sheet.md +4 -0
- package/views/docs/controls/sort-editor.md +8 -0
- package/views/docs/controls/text-editor.md +6 -0
- package/views/docs/controls/toolbar.md +4 -0
- package/views/docs/controls/values-editor.md +4 -0
- package/views/docs/controls/views-list.md +8 -0
- package/views/docs/guides/the-grid.md +2 -2
- package/views/docs/guides/the-provider.md +19 -2
- package/views/docs/reference/controls.md +11 -7
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +1 -1
- package/views/docs/reference/list.md +143 -11
- package/views/docs/reference/looks.md +1 -1
- package/views/docs/reference/panels-react.md +6 -5
- package/views/docs/reference/react.md +19 -12
- package/views/docs/reference/views.md +11 -5
- package/views/docs/reshaping.md +17 -1
- package/views/skills/views/SKILL.md +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import { Button } from "../button/button.js";
|
|
5
4
|
import { glyph } from "../internal/editor-parts.js";
|
|
6
5
|
import { Icon } from "../internal/icons.js";
|
|
7
6
|
import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
|
|
8
|
-
import {
|
|
7
|
+
import { InputGroup, InputGroupAddon } from "../input/input.js";
|
|
8
|
+
import { usePanelControls } from "../internal/panel-controls.js";
|
|
9
9
|
import { MENU_LIST_CARD_FRAME } from "../menu-list/looks.js";
|
|
10
10
|
import { MenuList, MenuListPanelRows } from "../menu-list/menu-list.js";
|
|
11
11
|
import { Notice } from "../notice/notice.js";
|
|
@@ -42,6 +42,7 @@ export const layoutMark = (id) => (LAYOUT_MARKS[id] ? glyph([LAYOUT_MARKS[id]])
|
|
|
42
42
|
export function useCustomize(props) {
|
|
43
43
|
const { view, onViewChange, layouts, filter, sort, group, changed = false, onReset, onSave, pending = false, stale = false, exportCount, onCopyLink, onExport, toggles, layoutSettings, columnsReset, onLineChange, columnsFoot, fields = [], foldFields = false, onClose, onScreenChange } = props;
|
|
44
44
|
const w = customizeWords(props.words);
|
|
45
|
+
const { Button, Input } = usePanelControls();
|
|
45
46
|
const host = React.useContext(PhoneHost), small = usePhone(), phone = (props.form ?? (host || small ? "phone" : "computer")) === "phone";
|
|
46
47
|
const inPane = React.useContext(InPane);
|
|
47
48
|
const [place, worn] = useCustomizeWorn();
|
|
@@ -117,21 +118,22 @@ export function useCustomize(props) {
|
|
|
117
118
|
h.land();
|
|
118
119
|
} holds.current = []; }, []);
|
|
119
120
|
const layout = layouts.find((l) => l.id === view.layout) ?? layouts[0];
|
|
120
|
-
const
|
|
121
|
+
const part = (slot, key) => ({ slot: { slot, ...(key !== undefined ? { key } : {}) } });
|
|
122
|
+
const section = (label, icon, s, key) => s ? [{ kind: "actions", icon, label, detail: s.says, inForce: s.inForce, entries: [], ...part("vk-customize-section", key) }] : [];
|
|
121
123
|
const toggleRows = (ts) => ts.flatMap((t) => [
|
|
122
|
-
{ kind: "check", label: t.label, checked: t.value, onCheckedChange: (on) => t.onChange(on), ...(t.icon != null && { icon: t.icon }) },
|
|
123
|
-
...(t.reset ? [{ icon: null, label: w.toggleReset(t.label), onSelect: t.reset }] : []),
|
|
124
|
+
{ kind: "check", label: t.label, checked: t.value, onCheckedChange: (on) => t.onChange(on), ...(t.icon != null && { icon: t.icon }), ...part("vk-customize-toggle", t.key) },
|
|
125
|
+
...(t.reset ? [{ icon: null, label: w.toggleReset(t.label), onSelect: t.reset, ...part("vk-customize-toggle-reset", t.key) }] : []),
|
|
124
126
|
]);
|
|
125
127
|
const sectionsOfToggles = (ts) => [...new Set(ts.flatMap((t) => (t.section ? [t.section] : [])))];
|
|
126
128
|
const checks = toggles
|
|
127
129
|
? [...toggleRows(toggles.filter((t) => !t.section)),
|
|
128
130
|
...sectionsOfToggles(toggles).map((s) => ({ kind: "group", heading: s, entries: toggleRows(toggles.filter((t) => t.section === s)) }))]
|
|
129
|
-
: [{ kind: "check", label: w.showCounts, checked: view.counts, onCheckedChange: (c) => change({ ...latest.view, counts: c }) }];
|
|
131
|
+
: [{ kind: "check", label: w.showCounts, checked: view.counts, onCheckedChange: (c) => change({ ...latest.view, counts: c }), ...part("vk-customize-toggle", "counts") }];
|
|
130
132
|
const fieldRows = new Map();
|
|
131
133
|
const fieldRow = (f) => {
|
|
132
134
|
const entry = f.disabled != null
|
|
133
|
-
? { icon: f.icon ?? null, label: f.label, disabled: f.disabled }
|
|
134
|
-
: { kind: "actions", icon: f.icon ?? null, label: f.label, detail: f.says, inForce: f.inForce, entries: [] };
|
|
135
|
+
? { icon: f.icon ?? null, label: f.label, disabled: f.disabled, ...part("vk-customize-field", f.key) }
|
|
136
|
+
: { kind: "actions", icon: f.icon ?? null, label: f.label, detail: f.says, inForce: f.inForce, entries: [], ...part("vk-customize-field", f.key) };
|
|
135
137
|
if (f.disabled == null)
|
|
136
138
|
fieldRows.set(entry, f.key);
|
|
137
139
|
return entry;
|
|
@@ -146,10 +148,10 @@ export function useCustomize(props) {
|
|
|
146
148
|
const inForceFields = filterFields.filter((f) => f.inForce).length;
|
|
147
149
|
const foldedFilter = folded ? { says: inForceFields ? String(inForceFields) : w.none, inForce: inForceFields > 0 } : undefined;
|
|
148
150
|
const sections = [
|
|
149
|
-
...(hasLayout ? [{ kind: "actions", icon: layout?.mark, label: w.layout, detail: layout?.name, entries: [] }] : []),
|
|
150
|
-
...(hasColumns ? [{ kind: "actions", icon: COLUMNS, label: w.columns, detail: columnsSay(view.columns, w), entries: [] }] : []),
|
|
151
|
+
...(hasLayout ? [{ kind: "actions", icon: layout?.mark, label: w.layout, detail: layout?.name, entries: [], ...part("vk-customize-section", "layout") }] : []),
|
|
152
|
+
...(hasColumns ? [{ kind: "actions", icon: COLUMNS, label: w.columns, detail: columnsSay(view.columns, w), entries: [], ...part("vk-customize-section", "columns") }] : []),
|
|
151
153
|
...(folded ? [] : fieldEntries(filterFields, true)),
|
|
152
|
-
...section(w.filter, _jsx(Icon, { name: "filter" }), filter ?? foldedFilter), ...section(w.sort, _jsx(Icon, { name: "sort" }), sort), ...section(w.group, GROUP, group),
|
|
154
|
+
...section(w.filter, _jsx(Icon, { name: "filter" }), filter ?? foldedFilter, "filter"), ...section(w.sort, _jsx(Icon, { name: "sort" }), sort, "sort"), ...section(w.group, GROUP, group, "group"),
|
|
153
155
|
...(folded ? [] : fieldEntries(afterFields)),
|
|
154
156
|
...(checks.length ? [{ kind: "separator" }, ...checks] : []),
|
|
155
157
|
];
|
|
@@ -195,10 +197,10 @@ export function useCustomize(props) {
|
|
|
195
197
|
} if ("label" in e && SCREEN_OF[e.label])
|
|
196
198
|
go(SCREEN_OF[e.label]); };
|
|
197
199
|
const footer = [
|
|
198
|
-
...(onCopyLink ? [{ icon: _jsx(Icon, { name: "link" }), label: w.copyLink, onSelect: onCopyLink }] : []),
|
|
199
|
-
...(onExport ? [{ icon: _jsx(Icon, { name: "export" }), label: w.export, ...(exportCount != null ? { count: exportCount } : {}), onSelect: onExport }] : []),
|
|
200
|
+
...(onCopyLink ? [{ icon: _jsx(Icon, { name: "link" }), label: w.copyLink, onSelect: onCopyLink, ...part("vk-customize-action", "copy-link") }] : []),
|
|
201
|
+
...(onExport ? [{ icon: _jsx(Icon, { name: "export" }), label: w.export, ...(exportCount != null ? { count: exportCount } : {}), onSelect: onExport, ...part("vk-customize-action", "export") }] : []),
|
|
200
202
|
];
|
|
201
|
-
const words = (size) => (_jsxs(_Fragment, { children: [stale && _jsx(Notice, { className: "o-customize-stale", children: w.stale }), _jsxs("div", { className: "o-customize-words", children: [_jsx(Button, { kind: "link", size: size, onClick: onReset, disabled: pending, children: w.reset }), onSave && _jsx(Button, { kind: "link", size: size, onClick: onSave, disabled: pending, children: w.save })] })] }));
|
|
203
|
+
const words = (size) => (_jsxs(_Fragment, { children: [stale && _jsx(Notice, { className: "o-customize-stale", "data-slot": "vk-customize-stale", children: w.stale }), _jsxs("div", { className: "o-customize-words", "data-slot": "vk-customize-changes", children: [_jsx(Button, { kind: "link", size: size, "data-slot": "vk-customize-action", "data-key": "reset", onClick: onReset, disabled: pending, children: w.reset }), onSave && _jsx(Button, { kind: "link", size: size, "data-slot": "vk-customize-action", "data-key": "save", onClick: onSave, disabled: pending, children: w.save })] })] }));
|
|
202
204
|
const col = screen === "columns" && column ? view.columns.find((c) => c.id === column && columnOpens(c)) : undefined;
|
|
203
205
|
React.useLayoutEffect(() => { if (column && !col) {
|
|
204
206
|
setColumn(null);
|
|
@@ -215,30 +217,31 @@ export function useCustomize(props) {
|
|
|
215
217
|
? _jsx(MenuList, { label: label, entries: rows, onOpen: choiceOpened, words: w.rows })
|
|
216
218
|
: _jsx(MenuListPanelRows, { label: label, entries: rows, ticks: "switch", onOpen: choiceOpened, words: w.rows }));
|
|
217
219
|
const choiceRow = (c) => {
|
|
218
|
-
const entry = { kind: "choices", icon: null, label: c.label, value: c.value, choices: c.options.map((o) => ({ value: o.value, label: o.label })),
|
|
219
|
-
detail: c.options.find((o) => o.value === c.value)?.label };
|
|
220
|
+
const entry = { kind: "choices", icon: null, label: c.label, value: c.value, choices: c.options.map((o) => ({ value: o.value, label: o.label, ...part("vk-customize-option", o.value) })),
|
|
221
|
+
detail: c.options.find((o) => o.value === c.value)?.label, ...part("vk-customize-choice", c.key) };
|
|
220
222
|
choiceRows.set(entry, c);
|
|
221
223
|
return entry;
|
|
222
224
|
};
|
|
223
225
|
const choice = allChoices.find((c) => c.key === choosing);
|
|
224
226
|
const backFromChoice = () => { setBack(true); setFocusTo(choice?.label ?? null); setChoosing(null); };
|
|
225
227
|
const choiceLevel = choice && (() => {
|
|
226
|
-
const rows = [{ kind: "pick", value: choice.value, choices: choice.options.map((o) => ({ value: o.value, label: o.label })),
|
|
228
|
+
const rows = [{ kind: "pick", value: choice.value, choices: choice.options.map((o) => ({ value: o.value, label: o.label, ...part("vk-customize-option", o.value) })),
|
|
227
229
|
onChoose: (v) => { if (v !== choice.value)
|
|
228
230
|
choice.onChange(v); backFromChoice(); } }];
|
|
229
231
|
return phone ? _jsx(MenuList, { label: choice.label, entries: rows, words: w.rows }) : _jsx(MenuListPanelRows, { label: choice.label, entries: rows, words: w.rows });
|
|
230
232
|
})();
|
|
231
|
-
const heading = (label, act) => (_jsxs("div", { className: "o-customize-heading", children: [_jsx("p", { className: "o-list-heading o-customize-heading-words", children: label }), act?.map((a) => _jsx(Button, { kind: "link", size: "line", onClick: a.onPress, children: a.label }, a.label))] }));
|
|
233
|
+
const heading = (label, key, act) => (_jsxs("div", { className: "o-customize-heading", "data-slot": "vk-customize-heading", "data-key": key, children: [_jsx("p", { className: "o-list-heading o-customize-heading-words", children: label }), act?.map((a) => _jsx(Button, { kind: "link", size: "line", "data-slot": "vk-customize-columns-action", "data-key": a.key, onClick: a.onPress, children: a.label }, a.label))] }));
|
|
234
|
+
const headingWords = (label, key) => _jsx("p", { className: "o-list-heading o-customize-heading-words", "data-slot": "vk-customize-heading", "data-key": key, children: label });
|
|
232
235
|
const ownSettings = (settings, name, lead = [], own) => {
|
|
233
236
|
const bare = settings.toggles.filter((t) => !t.section), sectioned = sectionsOfToggles(settings.toggles);
|
|
234
237
|
const first = [...lead, ...settings.choices.map(choiceRow), ...toggleRows(bare)];
|
|
235
|
-
const you = settings.personal, yours = you ? [...you.choices.map(choiceRow), ...toggleRows(you.toggles), ...(you.onReset ? [{ icon: null, label: w.personalReset, onSelect: you.onReset }] : [])] : [];
|
|
236
|
-
return _jsxs(_Fragment, { children: [first.length > 0 && _jsxs(_Fragment, { children: [!own &&
|
|
238
|
+
const you = settings.personal, yours = you ? [...you.choices.map(choiceRow), ...toggleRows(you.toggles), ...(you.onReset ? [{ icon: null, label: w.personalReset, onSelect: you.onReset, ...part("vk-customize-toggle-reset", "personal") }] : [])] : [];
|
|
239
|
+
return _jsxs(_Fragment, { children: [first.length > 0 && _jsxs(_Fragment, { children: [!own && headingWords(name, own === undefined ? layout?.id ?? name : name), rowsList(own?.list ?? w.layoutSettings(name), first)] }), sectioned.map((s) => _jsxs(React.Fragment, { children: [headingWords(s, s), rowsList(s, toggleRows(settings.toggles.filter((t) => t.section === s)))] }, s)), you && yours.length > 0 && _jsxs(_Fragment, { children: [headingWords(you.label, "you"), rowsList(you.label, yours)] })] });
|
|
237
240
|
};
|
|
238
241
|
const layoutScreen = (_jsxs(_Fragment, { children: [_jsx(RadioGroup, { tiles: true, "aria-label": w.layout, value: view.layout, onValueChange: (v) => { if (typeof v === "string")
|
|
239
|
-
change({ ...latest.view, layout: v }); }, children: layouts.map((l) => _jsx(Radio, { value: l.id, mark: l.mark, label: l.name, disabled: l.later }, l.id)) }), layoutSettings ? ownSettings(layoutSettings, layout?.name ?? w.layout) : layout?.id === "table" && _jsxs(_Fragment, { children: [
|
|
240
|
-
{ kind: "check", label: w.freeze, checked: view.freeze, onCheckedChange: (c) => change({ ...latest.view, freeze: c }) },
|
|
241
|
-
{ kind: "check", label: w.wrap, checked: view.wrap, onCheckedChange: (c) => change({ ...latest.view, wrap: c }) },
|
|
242
|
+
change({ ...latest.view, layout: v }); }, children: layouts.map((l) => _jsx(Radio, { value: l.id, mark: l.mark, label: l.name, disabled: l.later, "data-slot": "vk-customize-layout", "data-key": l.id }, l.id)) }), layoutSettings ? ownSettings(layoutSettings, layout?.name ?? w.layout) : layout?.id === "table" && _jsxs(_Fragment, { children: [headingWords(layout.name, layout.id), rowsList(w.layoutSettings(layout.name), [
|
|
243
|
+
{ kind: "check", label: w.freeze, checked: view.freeze, onCheckedChange: (c) => change({ ...latest.view, freeze: c }), ...part("vk-customize-toggle", "freeze") },
|
|
244
|
+
{ kind: "check", label: w.wrap, checked: view.wrap, onCheckedChange: (c) => change({ ...latest.view, wrap: c }), ...part("vk-customize-toggle", "wrap") },
|
|
242
245
|
])] })] }));
|
|
243
246
|
const searching = find.trim() !== "", eyes = worn.columns === "eye";
|
|
244
247
|
const found = findColumns(view.columns, find);
|
|
@@ -251,7 +254,7 @@ export function useCustomize(props) {
|
|
|
251
254
|
const block = (shown) => {
|
|
252
255
|
const grips = new Set(gripped(found, shown).map((c) => c.id));
|
|
253
256
|
return found.filter((c) => c.shown === shown).map((c) => {
|
|
254
|
-
const entry = { kind: "check", label: c.label, icon: c.mark, checked: held[c.id] ?? c.shown, grip: grips.has(c.id),
|
|
257
|
+
const entry = { kind: "check", label: c.label, icon: c.mark, checked: held[c.id] ?? c.shown, grip: grips.has(c.id), ...part("vk-customize-column", c.id),
|
|
255
258
|
disabled: c.locked ? w.alwaysShown : undefined, onCheckedChange: (on) => press([c.id], on),
|
|
256
259
|
...(columnOpens(c) && { opens: w.columnSettings(c.label) }),
|
|
257
260
|
...(c.line && { toggle: { icon: lineMark, label: c.line.on ? w.newLineOn(c.label) : w.newLineStart(c.label), on: c.line.on, onPress: () => onLineChange?.(c.id),
|
|
@@ -273,26 +276,26 @@ export function useCustomize(props) {
|
|
|
273
276
|
const canHide = view.columns.some((c) => c.shown && !c.locked), canShow = view.columns.some((c) => !c.shown);
|
|
274
277
|
const shownHere = found.some((c) => c.shown), hiddenHere = found.some((c) => !c.shown);
|
|
275
278
|
const typed = (e) => setFind(e.target.value);
|
|
276
|
-
const columnsBox = (_jsxs(InputGroup, { size: phone ? "lg" : "sm", chrome: "soft", children: [_jsx(InputGroupAddon, { children: _jsx(Icon, { name: "search" }) }), _jsx(Input, { value: find, onChange: typed, placeholder: phone ? w.findColumn : w.searchColumns, "aria-label": phone ? w.findColumn : w.searchColumns })] }));
|
|
279
|
+
const columnsBox = (_jsxs(InputGroup, { size: phone ? "lg" : "sm", chrome: "soft", "data-slot": "vk-customize-search", children: [_jsx(InputGroupAddon, { children: _jsx(Icon, { name: "search" }) }), _jsx(Input, { value: find, onChange: typed, placeholder: phone ? w.findColumn : w.searchColumns, "aria-label": phone ? w.findColumn : w.searchColumns })] }));
|
|
277
280
|
const columnsSearch = phone ? columnsBox : _jsx("div", { className: "o-customize-search", children: columnsBox });
|
|
278
281
|
const shownActs = [
|
|
279
|
-
...(!searching && canHide ? [{ label: w.hideAll, onPress: () => press(latest.view.columns.filter((c) => c.shown && !c.locked).map((c) => c.id), false) }] : []),
|
|
280
|
-
...(!searching && columnsReset ? [{ label: w.columnsReset, onPress: columnsReset }] : []),
|
|
282
|
+
...(!searching && canHide ? [{ key: "hide-all", label: w.hideAll, onPress: () => press(latest.view.columns.filter((c) => c.shown && !c.locked).map((c) => c.id), false) }] : []),
|
|
283
|
+
...(!searching && columnsReset ? [{ key: "reset", label: w.columnsReset, onPress: columnsReset }] : []),
|
|
281
284
|
];
|
|
282
|
-
const columnsScreen = (_jsxs(_Fragment, { children: [phone && columnsSearch, shownHere && _jsxs(_Fragment, { children: [heading(w.shownHeading, shownActs), rowsOf(w.shownHeading, true)] }), hiddenHere && _jsxs(_Fragment, { children: [heading(w.hiddenHeading, !searching && canShow ? [{ label: w.showAll, onPress: () => press(latest.view.columns.filter((c) => !c.shown).map((c) => c.id), true) }] : undefined), rowsOf(w.hiddenHeading, false)] }), !found.length && _jsx("p", { className: "o-customize-none", children: w.noColumn(find.trim()) }), columnsFoot != null && _jsx("div", { className: "o-customize-foot-rows", children: columnsFoot })] }));
|
|
285
|
+
const columnsScreen = (_jsxs(_Fragment, { children: [phone && columnsSearch, shownHere && _jsxs(_Fragment, { children: [heading(w.shownHeading, "shown", shownActs), rowsOf(w.shownHeading, true)] }), hiddenHere && _jsxs(_Fragment, { children: [heading(w.hiddenHeading, "hidden", !searching && canShow ? [{ key: "show-all", label: w.showAll, onPress: () => press(latest.view.columns.filter((c) => !c.shown).map((c) => c.id), true) }] : undefined), rowsOf(w.hiddenHeading, false)] }), !found.length && _jsx("p", { className: "o-customize-none", "data-slot": "vk-customize-none", "data-key": "columns", children: w.noColumn(find.trim()) }), columnsFoot != null && _jsx("div", { className: "o-customize-foot-rows", "data-slot": "vk-customize-columns-foot", children: columnsFoot })] }));
|
|
283
286
|
const backFromColumn = () => { setBack(true); setFocusTo(col?.label ?? null); setColumn(null); setChoosing(null); };
|
|
284
|
-
const columnLevel = col && (_jsxs(_Fragment, { children: [ownSettings(col.settings ?? { choices: [], toggles: [] }, col.label, col.locked ? [] : [{ kind: "check", label: w.columnShown, checked: held[col.id] ?? col.shown, onCheckedChange: (on) => press([col.id], on) }], { list: w.columnSettings(col.label) }), col.rows != null && _jsxs("div", { className: "o-customize-rows", children: [(!col.locked || columnOpensBySettings(col)) && _jsx("div", { role: "separator", className: "o-list-sep" }), col.rows] })] }));
|
|
287
|
+
const columnLevel = col && (_jsxs(_Fragment, { children: [ownSettings(col.settings ?? { choices: [], toggles: [] }, col.label, col.locked ? [] : [{ kind: "check", label: w.columnShown, checked: held[col.id] ?? col.shown, onCheckedChange: (on) => press([col.id], on), ...part("vk-customize-toggle", "shown") }], { list: w.columnSettings(col.label) }), col.rows != null && _jsxs("div", { className: "o-customize-rows", "data-slot": "vk-customize-rows", "data-key": col.id, children: [(!col.locked || columnOpensBySettings(col)) && _jsx("div", { role: "separator", className: "o-list-sep" }), col.rows] })] }));
|
|
285
288
|
const rowsOfField = (label, rows) => (phone
|
|
286
289
|
? _jsx(MenuList, { label: label, entries: rows, words: w.rows }) : _jsx(MenuListPanelRows, { label: label, entries: rows, ticks: "box", words: w.rows }));
|
|
287
290
|
const fieldScreen = field && (() => {
|
|
288
291
|
const o = field.opens;
|
|
289
292
|
if ("pick" in o)
|
|
290
|
-
return o.pick.choices.length === 0 ? _jsx("p", { className: "o-customize-none", children: w.nothingToPick })
|
|
291
|
-
: rowsOfField(field.label, [{ kind: "pick", value: o.pick.value, choices: o.pick.choices, onChoose: (v) => { if (v !== o.pick.value)
|
|
293
|
+
return o.pick.choices.length === 0 ? _jsx("p", { className: "o-customize-none", "data-slot": "vk-customize-none", "data-key": "choices", children: w.nothingToPick })
|
|
294
|
+
: rowsOfField(field.label, [{ kind: "pick", value: o.pick.value, choices: o.pick.choices.map((c) => ({ ...c, ...part("vk-customize-option", c.value) })), onChoose: (v) => { if (v !== o.pick.value)
|
|
292
295
|
o.pick.onChoose(v); backFromField(); } }]);
|
|
293
296
|
if ("check" in o)
|
|
294
|
-
return o.check.choices.length === 0 ? _jsx("p", { className: "o-customize-none", children: w.nothingToPick })
|
|
295
|
-
: rowsOfField(field.label, o.check.choices.map((c) => ({ kind: "check", label: c.label, ...(c.mark != null && { icon: c.mark }), checked: o.check.values.includes(c.value),
|
|
297
|
+
return o.check.choices.length === 0 ? _jsx("p", { className: "o-customize-none", "data-slot": "vk-customize-none", "data-key": "choices", children: w.nothingToPick })
|
|
298
|
+
: rowsOfField(field.label, o.check.choices.map((c) => ({ kind: "check", label: c.label, ...(c.mark != null && { icon: c.mark }), ...part("vk-customize-option", c.value), checked: o.check.values.includes(c.value),
|
|
296
299
|
onCheckedChange: (on) => o.check.onChange(on ? [...o.check.values, c.value] : o.check.values.filter((v) => v !== c.value)) })));
|
|
297
300
|
return typeof o.body === "function" ? o.body(backFromField) : o.body;
|
|
298
301
|
})();
|
|
@@ -312,18 +315,19 @@ export function useCustomize(props) {
|
|
|
312
315
|
const titled = !named;
|
|
313
316
|
const step = choice ? (col ? `columns:${col.id}:${choice.key}` : `layout:${choice.key}`) : col ? `columns:${col.id}` : field ? `field:${field.key}` : screen;
|
|
314
317
|
if (phone) {
|
|
315
|
-
const body = (_jsx("div", { ref: placeRoot, className: "o-customize", "data-kit": "customize", "data-customize-form": form, "data-customize-screen": screen, ...phoneMark(!!host || small), ...MENU_LIST_CARD_FRAME, children: _jsx(SheetStep, { step: step, back: back, children: _jsx("div", { className: "o-customize-step", children: content }) }) }));
|
|
316
|
-
const foot = screen === "list" && (changed || footer.length) ? (_jsxs("div", { className: "o-customize-foot", ...MENU_LIST_CARD_FRAME, children: [changed && words("44"), footer.length > 0 && _jsx(MenuList, { label: w.share, entries: footer, words: w.rows })] })) : undefined;
|
|
318
|
+
const body = (_jsx("div", { ref: placeRoot, className: "o-customize", "data-slot": "vk-customize", "data-kit": "customize", "data-customize-form": form, "data-customize-screen": screen, ...phoneMark(!!host || small), ...MENU_LIST_CARD_FRAME, children: _jsx(SheetStep, { step: step, back: back, children: _jsx("div", { className: "o-customize-step", children: content }) }) }));
|
|
319
|
+
const foot = screen === "list" && (changed || footer.length) ? (_jsxs("div", { className: "o-customize-foot", "data-slot": "vk-customize-foot", ...MENU_LIST_CARD_FRAME, children: [changed && words("44"), footer.length > 0 && _jsx(MenuList, { label: w.share, entries: footer, words: w.rows })] })) : undefined;
|
|
317
320
|
return { body, title: name, head: screen === "list" ? { close: true } : { onBack: backTo, close: titled }, foot, level };
|
|
318
321
|
}
|
|
319
322
|
const title = (words) => (inPane ? _jsx(PaneTitle, { children: words }) : _jsx("h2", { className: "o-pane-title", children: words }));
|
|
320
|
-
const xButton = (extra) => _jsx(Button, { kind: "quiet", shape: "icon", size: "sm", "aria-label": w.close, icon: _jsx(Icon, { name: "x" }), ...extra });
|
|
323
|
+
const xButton = (extra) => _jsx(Button, { kind: "quiet", shape: "icon", size: "sm", "data-slot": "vk-customize-close", "aria-label": w.close, icon: _jsx(Icon, { name: "x" }), ...extra });
|
|
321
324
|
const close = inPane ? _jsx(PaneClose, { render: xButton() }) : onClose ? xButton({ onClick: onClose }) : null;
|
|
322
|
-
const head = screen !== "list" ? (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-screen", children: [_jsx(Button, { ref: backButton, kind: "quiet", shape: "icon", size: "sm", "aria-label": w.back, icon: _jsx(Icon, { name: "left" }), onClick: backTo }), _jsx("span", { className: "o-customize-title", children: title(name) }), titled && close] })) : titled ? (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-title", children: [_jsx("span", { className: "o-customize-title", children: title(w.title) }), close] })) : (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-name", children: [hasLayout && _jsx(Button, { kind: "outline", shape: "icon", size: "sm", "aria-label": w.layoutButton(layout?.name ?? ""), icon: layout?.mark, onClick: () => go("layout") }), _jsx(ViewName, { name: view.name, label: w.viewName, onRename: (n) => change({ ...latest.view, name: n }) })] }));
|
|
323
|
-
const parts = (_jsxs(_Fragment, { children: [head, screen === "columns" && !col && columnsSearch, _jsx(PaneBody, { children: _jsx("div", { ref: placeRoot, className: "o-customize", "data-kit": "customize", "data-customize-form": form, "data-customize-screen": screen, ...phoneMark(!!host || small), ...MENU_LIST_CARD_FRAME, children: _jsx(React.Fragment, { children: content }, step) }) }), screen === "list" && changed && words("xs"), footer.length > 0 && _jsx(PaneFoot, { children: _jsx(MenuListPanelRows, { label: w.share, entries: footer, words: w.rows }) })] }));
|
|
325
|
+
const head = screen !== "list" ? (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-screen", "data-slot": "vk-customize-head", children: [_jsx(Button, { ref: backButton, kind: "quiet", shape: "icon", size: "sm", "data-slot": "vk-customize-back", "aria-label": w.back, icon: _jsx(Icon, { name: "left" }), onClick: backTo }), _jsx("span", { className: "o-customize-title", "data-slot": "vk-customize-title", children: title(name) }), titled && close] })) : titled ? (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-title", "data-slot": "vk-customize-head", children: [_jsx("span", { className: "o-customize-title", "data-slot": "vk-customize-title", children: title(w.title) }), close] })) : (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-name", "data-slot": "vk-customize-head", children: [hasLayout && _jsx(Button, { kind: "outline", shape: "icon", size: "sm", "data-slot": "vk-customize-layout-button", "aria-label": w.layoutButton(layout?.name ?? ""), icon: layout?.mark, onClick: () => go("layout") }), _jsx(ViewName, { name: view.name, label: w.viewName, onRename: (n) => change({ ...latest.view, name: n }) })] }));
|
|
326
|
+
const parts = (_jsxs(_Fragment, { children: [head, screen === "columns" && !col && columnsSearch, _jsx(PaneBody, { children: _jsx("div", { ref: placeRoot, className: "o-customize", "data-slot": "vk-customize", "data-kit": "customize", "data-customize-form": form, "data-customize-screen": screen, ...phoneMark(!!host || small), ...MENU_LIST_CARD_FRAME, children: _jsx(React.Fragment, { children: content }, step) }) }), screen === "list" && changed && words("xs"), footer.length > 0 && _jsx(PaneFoot, { "data-slot": "vk-customize-foot", children: _jsx(MenuListPanelRows, { label: w.share, entries: footer, words: w.rows }) })] }));
|
|
324
327
|
return { body: inPane ? parts : _jsx("div", { className: "o-customize-frame", children: parts }), title: name, head: {}, level };
|
|
325
328
|
}
|
|
326
329
|
function ViewName({ name, label, onRename }) {
|
|
330
|
+
const { Input } = usePanelControls();
|
|
327
331
|
const [draft, setDraft] = React.useState(name);
|
|
328
332
|
React.useEffect(() => setDraft(name), [name]);
|
|
329
333
|
const keep = () => { const n = draft.trim(); if (!n)
|
|
@@ -332,7 +336,7 @@ function ViewName({ name, label, onRename }) {
|
|
|
332
336
|
onRename(n);
|
|
333
337
|
else
|
|
334
338
|
setDraft(name); };
|
|
335
|
-
return (_jsx("span", { className: "o-customize-name", children: _jsx(Input, { size: "sm", "aria-label": label, value: draft, onChange: (e) => setDraft(e.target.value), onBlur: keep, onKeyDown: (e) => {
|
|
339
|
+
return (_jsx("span", { className: "o-customize-name", children: _jsx(Input, { size: "sm", "data-slot": "vk-customize-name", "aria-label": label, value: draft, onChange: (e) => setDraft(e.target.value), onBlur: keep, onKeyDown: (e) => {
|
|
336
340
|
if (e.key === "Enter") {
|
|
337
341
|
e.preventDefault();
|
|
338
342
|
keep();
|
|
@@ -12,4 +12,6 @@ export declare function customizeWordsOf(say: ViewsMessageResolver): CustomizeWo
|
|
|
12
12
|
* refused one writes nothing) and its columns that differs. Columns, one or several shown or hidden (Hide all, Show all) or moved,
|
|
13
13
|
* through ViewKit's own, in one change. */
|
|
14
14
|
export declare function customizeWriteOf(p: ViewsCustomizeBodyProps, own: CustomizeBodyOwn, now: CustomizeView, next: CustomizeView): (() => void) | null;
|
|
15
|
+
/** ViewKit's Customize, drawing the app's controls where the provider's `panelControls` names them (VK-1013, VK-1014): its own,
|
|
16
|
+
* and its sort's, filter's and group's. */
|
|
15
17
|
export declare function MapCustomizeBody(props: ViewsCustomizeBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -12,11 +12,12 @@ import { groupLabel } from "../group-editor/rules.js";
|
|
|
12
12
|
import { glyph, X } from "../internal/editor-parts.js";
|
|
13
13
|
import { useToldStep } from "../internal/told-step.js";
|
|
14
14
|
import { HeaderBar } from "../phone-header/header-bar.js";
|
|
15
|
-
import {
|
|
15
|
+
import { PanelHeadButton } from "../internal/head-button.js";
|
|
16
16
|
import { SheetPartsFrom } from "../sheet/sheet-parts.js";
|
|
17
17
|
import { sortEditorPropsOf, sortEditorWordsOf } from "../sort-editor/map-sort-body.js";
|
|
18
18
|
import { sortLabel } from "../sort-editor/rules.js";
|
|
19
19
|
import { useSortEditor } from "../sort-editor/sort-editor.js";
|
|
20
|
+
import { PanelControlsFromViews } from "../internal/map-panel-controls.js";
|
|
20
21
|
import { layoutMark, useCustomize } from "./customize.js";
|
|
21
22
|
import { DateRangeBody, useTimeRange } from "./map-ranges.js";
|
|
22
23
|
const BACK = ["M5 12l14 0", "M5 12l6 6", "M5 12l6 -6"];
|
|
@@ -113,6 +114,9 @@ const NO_GROUP = { label: "", dimensions: [], group: { value: "none" }, manualOr
|
|
|
113
114
|
const stay = () => undefined;
|
|
114
115
|
const levelOf = (parts) => parts.title !== undefined && parts.head.onBack ? { name: parts.title, back: parts.head.onBack } : null;
|
|
115
116
|
export function MapCustomizeBody(props) {
|
|
117
|
+
return _jsx(PanelControlsFromViews, { children: _jsx(CustomizeBodyInner, { ...props }) });
|
|
118
|
+
}
|
|
119
|
+
function CustomizeBodyInner(props) {
|
|
116
120
|
const { name, onRename, exportCount, onCopyLink, onExport, ...p } = props;
|
|
117
121
|
const views = React.useContext(ViewsContext);
|
|
118
122
|
const say = views?.messages ?? resolveViewsMessage;
|
|
@@ -191,5 +195,6 @@ export function MapCustomizeBody(props) {
|
|
|
191
195
|
if (!phone || setParts)
|
|
192
196
|
return _jsx(_Fragment, { children: parts.body });
|
|
193
197
|
const { onBack, close } = parts.head;
|
|
194
|
-
return (_jsxs(_Fragment, { children: [_jsx(HeaderBar, { className: "o-sheet-row o-customize-own-head", title: parts.title, left: onBack ? _jsx(
|
|
198
|
+
return (_jsxs(_Fragment, { children: [_jsx(HeaderBar, { className: "o-sheet-row o-customize-own-head", title: parts.title, left: onBack ? _jsx(PanelHeadButton, { "data-slot": "vk-editor-back", "aria-label": w.back, className: "o-sheet-back", icon: glyph(BACK), onClick: onBack })
|
|
199
|
+
: close ? _jsx(PanelHeadButton, { "data-slot": "vk-editor-close", "aria-label": w.close, icon: glyph(X), onClick: p.onDone }) : _jsx("span", {}), right: close && onBack ? _jsx(PanelHeadButton, { "data-slot": "vk-editor-close", "aria-label": w.close, icon: glyph(X), onClick: p.onDone }) : _jsx("span", {}) }), parts.body, parts.foot] }));
|
|
195
200
|
}
|
|
@@ -16,9 +16,9 @@ export function DateDays({ year, month, keyDay, picked, today, names, weekdays,
|
|
|
16
16
|
};
|
|
17
17
|
React.useEffect(() => { if (moved.current) {
|
|
18
18
|
moved.current = false;
|
|
19
|
-
grid.current?.querySelector("[data-
|
|
19
|
+
grid.current?.querySelector("[data-stop]")?.focus({ preventScroll: true });
|
|
20
20
|
} }, [keyDay]);
|
|
21
21
|
const cells = monthGrid(year, month);
|
|
22
|
-
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "o-date-editor-weekdays", "aria-hidden": "true", children: weekdays.map((d, i) => _jsx("span", { children: d }, i)) }), _jsx("div", { ref: grid, role: "grid", "aria-label": `${names.months[month]} ${year}`, className: big ? "o-date-editor-days o-date-editor-days-phone" : "o-date-editor-days", onKeyDown: step, children: [0, 1, 2, 3, 4, 5].map((r) => (_jsx("div", { role: "row", className: "o-date-editor-week", children: cells.slice(r * 7, r * 7 + 7).map((day, i) => (_jsx("div", { role: "gridcell", "aria-selected": day && day === picked ? true : undefined, className: "o-date-editor-cell", children: day && _jsx("button", { type: "button", "aria-label": lineText(day, names), className: "o-date-editor-day", tabIndex: day === keyDay ? 0 : -1, disabled: off?.(day) || undefined, "data-today": day === today ? "" : undefined, "data-
|
|
22
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "o-date-editor-weekdays", "data-slot": "vk-date-weekdays", "aria-hidden": "true", children: weekdays.map((d, i) => _jsx("span", { children: d }, i)) }), _jsx("div", { ref: grid, role: "grid", "aria-label": `${names.months[month]} ${year}`, className: big ? "o-date-editor-days o-date-editor-days-phone" : "o-date-editor-days", "data-slot": "vk-date-days", onKeyDown: step, children: [0, 1, 2, 3, 4, 5].map((r) => (_jsx("div", { role: "row", className: "o-date-editor-week", children: cells.slice(r * 7, r * 7 + 7).map((day, i) => (_jsx("div", { role: "gridcell", "aria-selected": day && day === picked ? true : undefined, className: "o-date-editor-cell", children: day && _jsx("button", { type: "button", "aria-label": lineText(day, names), className: "o-date-editor-day", "data-slot": "vk-date-day", tabIndex: day === keyDay ? 0 : -1, disabled: off?.(day) || undefined, "data-today": day === today ? "" : undefined, "data-stop": day === keyDay ? "" : undefined, "data-picked": day === picked ? "" : undefined, "data-reads": reads && day === reads ? "" : undefined, onKeyDown: (e) => { if (e.key !== "Enter")
|
|
23
23
|
return; e.preventDefault(); (onEnter ?? onPick)(day); }, onClick: () => onPick(day), children: Number(day.slice(8)) }) }, i))) }, r))) })] }));
|
|
24
24
|
}
|
|
@@ -46,6 +46,9 @@ export interface DateEditorProps {
|
|
|
46
46
|
words?: Partial<DateEditorWords>;
|
|
47
47
|
/** The language its month and weekday names are written in (BCP 47); English unless said. */
|
|
48
48
|
language?: string;
|
|
49
|
+
/** The conventions' locale (BCP 47), handed to an app's Calendar as the filter's calendar is handed it (VK-1021); its
|
|
50
|
+
* language unless said. */
|
|
51
|
+
locale?: string;
|
|
49
52
|
}
|
|
50
53
|
export interface DateEditorParts {
|
|
51
54
|
body: React.ReactNode;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { cx } from "../../internal/cx.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { InputGroup, InputGroupAddon } from "../input/input.js";
|
|
6
|
+
import { usePanelControls } from "../internal/panel-controls.js";
|
|
7
7
|
import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
|
|
8
8
|
import { scrollInList } from "../internal/scroll.js";
|
|
9
9
|
import { MenuListRow } from "../menu-list/menu-list.js";
|
|
@@ -73,6 +73,7 @@ const STANDS_PRESSED = { pressed: "hovered" };
|
|
|
73
73
|
const wornAttrs = (w) => ({ "data-date-line": w.line, "data-date-time": w.time, "data-date-days": w.days, "data-date-year": w.year, "data-date-picks": w.picks, "data-date-calendar": w.calendar });
|
|
74
74
|
const wheelOf = (opens) => (opens === "years" || opens === "months" ? "date" : opens === "time" ? "time" : "none");
|
|
75
75
|
export function useDateEditor(props) {
|
|
76
|
+
const { Button, Input, Calendar } = usePanelControls();
|
|
76
77
|
const [wornRef, worn] = useDateEditorWorn(props.worn);
|
|
77
78
|
const w = dateWords(props.words), names = dateNames(props.language);
|
|
78
79
|
const root = React.useRef(null);
|
|
@@ -186,27 +187,30 @@ export function useDateEditor(props) {
|
|
|
186
187
|
const [sy, sm] = parts(shownKey);
|
|
187
188
|
const dayGrid = (big, weekdays) => (_jsx(DateDays, { year: sy, month: sm, keyDay: shownKey, picked: date, today: today, names: names, weekdays: weekdays, big: big, off: off, reads: reading && "date" in reading ? reading.date : null, onPick: pick, onKeyMove: setKey, onEnter: (day) => { pick(day); if (phone || time)
|
|
188
189
|
keep(day, clock); } }));
|
|
190
|
+
const calendar = Calendar && (_jsx(Calendar, { "data-slot": "vk-calendar", value: date, month: `${sy}-${String(sm + 1).padStart(2, "0")}`, locale: props.locale ?? props.language ?? "en", onMonthChange: (m) => setKey(`${m}-01`), onChange: (day) => { const to = day ?? date; if (to)
|
|
191
|
+
pick(to); } }));
|
|
189
192
|
const row = phone ? worn.calendar === "plain" : worn.picks === "row";
|
|
190
|
-
const quick = (_jsx("div", { className: "o-date-editor-picks", children: picks.map((p) => (_jsx(Button, { kind: "quiet", size: phone ? "lg" : row ? "2xs" : "sm", className: "o-date-editor-pick", look: phone ? (row ? PICK_PLAIN : PICK_CARDS) : row ? PICK_ROW : PICK_TWO, icon: glyph(row ? ROW_PICKS[p] : PICKS[p].icon), onClick: () => pick(p === "none" ? null : quickPick(p, today)), children: w[PICK_WORD[p]] }, p))) }));
|
|
193
|
+
const quick = (_jsx("div", { className: "o-date-editor-picks", "data-slot": "vk-date-picks", children: picks.map((p) => (_jsx(Button, { kind: "quiet", size: phone ? "lg" : row ? "2xs" : "sm", className: "o-date-editor-pick", "data-slot": "vk-date-pick", "data-key": p, look: phone ? (row ? PICK_PLAIN : PICK_CARDS) : row ? PICK_ROW : PICK_TWO, icon: glyph(row ? ROW_PICKS[p] : PICKS[p].icon), onClick: () => pick(p === "none" ? null : quickPick(p, today)), children: w[PICK_WORD[p]] }, p))) }));
|
|
191
194
|
if (phone) {
|
|
192
195
|
const months = names.months.map((name, i) => ({ value: String(i), label: name }));
|
|
193
196
|
const years = Array.from({ length: 41 }, (_, i) => String(sy - 20 + i)).map((v) => ({ value: v, label: v }));
|
|
194
197
|
const hours = Array.from({ length: 24 }, (_, i) => String(i).padStart(2, "0")).map((v) => ({ value: v, label: v }));
|
|
195
198
|
const mins = ["00", "15", "30", "45"].map((v) => ({ value: v, label: v }));
|
|
196
199
|
const [hh, mm] = (clock ?? "09:00").split(":");
|
|
197
|
-
const head = { left: _jsx(SheetButton, { "aria-label": w.close, icon: glyph(X), onClick: leave }), right: _jsx(SheetButton, { kind: "primary", "aria-label": w.save, icon: glyph(TICK), onClick: () => { if (take())
|
|
200
|
+
const head = { left: _jsx(SheetButton, { "data-slot": "vk-editor-close", "aria-label": w.close, icon: glyph(X), onClick: leave }), right: _jsx(SheetButton, { "data-slot": "vk-editor-save", kind: "primary", "aria-label": w.save, icon: glyph(TICK), onClick: () => { if (take())
|
|
198
201
|
keep(dayOfLine(), clock); } }) };
|
|
199
|
-
const wheels = wheel === "date" ? (_jsxs("div", { className: "o-date-editor-wheels", children: [_jsx(Wheel, { label: w.month, items: months, value: String(sm), onChange: (v) => setKey(addMonths(shownKey, Number(v) - sm)) }, "month"), _jsx(Wheel, { label: w.year, items: years, value: String(sy), onChange: (v) => setKey(addMonths(shownKey, (Number(v) - sy) * 12)) }, "year")] })) : wheel === "time" ? (_jsxs("div", { className: "o-date-editor-wheels", children: [_jsx(Wheel, { label: w.hour, items: hours, value: hh, onChange: (v) => setTime(`${v}:${mm}`) }, "hour"), _jsx(Wheel, { label: w.minute, items: mins, value: mm, onChange: (v) => setTime(`${hh}:${v}`) }, "minute")] })) : null;
|
|
202
|
+
const wheels = wheel === "date" ? (_jsxs("div", { className: "o-date-editor-wheels", "data-slot": "vk-date-wheels", children: [_jsx(Wheel, { name: "month", label: w.month, items: months, value: String(sm), onChange: (v) => setKey(addMonths(shownKey, Number(v) - sm)) }, "month"), _jsx(Wheel, { name: "year", label: w.year, items: years, value: String(sy), onChange: (v) => setKey(addMonths(shownKey, (Number(v) - sy) * 12)) }, "year")] })) : wheel === "time" ? (_jsxs("div", { className: "o-date-editor-wheels", "data-slot": "vk-date-wheels", children: [_jsx(Wheel, { name: "hour", label: w.hour, items: hours, value: hh, onChange: (v) => setTime(`${v}:${mm}`) }, "hour"), _jsx(Wheel, { name: "minute", label: w.minute, items: mins, value: mm, onChange: (v) => setTime(`${hh}:${v}`) }, "minute")] })) : null;
|
|
200
203
|
if (worn.calendar === "plain") {
|
|
201
204
|
const toggle = (w) => { if (w === "time" && !clock)
|
|
202
205
|
setTime("09:00"); setWheel(wheel === w ? "none" : w); };
|
|
203
|
-
const plain = (_jsxs("div", { ref: placeRoot, className: "o-date-editor", "data-kit": "date-editor", "data-date-form": "phone", ...phoneMark(!!host || small), ...wornAttrs(worn), children: [_jsxs(InputGroup, { size: "lg", className: "o-date-editor-line", "data-bad": error ? "" : undefined, children: [_jsx(Input, { ref: line, className: "o-date-editor-input", "aria-label": label, placeholder: `${w.type}…`, autofill: false, spellCheck: false, "aria-invalid": error ? true : undefined, value: typed ?? "", enterKeyHint: "done", onChange: (e) => { setTyped(e.target.value); setError(null); handTyped(e.target.value); }, onKeyDown: (e) => { if (e.key !== "Enter" || e.nativeEvent.isComposing)
|
|
206
|
+
const plain = (_jsxs("div", { ref: placeRoot, className: "o-date-editor", "data-slot": "vk-date", "data-kit": "date-editor", "data-date-form": "phone", ...phoneMark(!!host || small), ...wornAttrs(worn), children: [_jsxs(InputGroup, { size: "lg", className: "o-date-editor-line", "data-slot": "vk-date-line", "data-bad": error ? "" : undefined, children: [_jsx(Input, { ref: line, className: "o-date-editor-input", "aria-label": label, placeholder: `${w.type}…`, autofill: false, spellCheck: false, "aria-invalid": error ? true : undefined, value: typed ?? "", enterKeyHint: "done", onChange: (e) => { setTyped(e.target.value); setError(null); handTyped(e.target.value); }, onKeyDown: (e) => { if (e.key !== "Enter" || e.nativeEvent.isComposing)
|
|
204
207
|
return; e.preventDefault(); if (take())
|
|
205
|
-
keep(dayOfLine(), clock); } }), reading && "date" in reading && _jsx(InputGroupAddon, { side: "end", children: _jsx("span", { className: "o-date-editor-reads", children: lineText(reading.date, names) }) })] }), error && _jsx("p", { className: "o-date-editor-error", role: "alert", children: error }), _jsxs("div", { className: "o-date-editor-head", children: [_jsx(Button, { kind: "quiet", shape: "icon", size: "lg", "aria-label": w.lastMonth, icon: glyph(LEFT), onClick: () => setKey(addMonths(shownKey, -1)) }), _jsx(Button, { kind: "quiet", shape: "icon", size: "lg", "aria-label": w.nextMonth, icon: glyph(RIGHT), onClick: () => setKey(addMonths(shownKey, 1)) }), _jsx(Button, { kind: "quiet", size: "lg", className: "o-date-editor-heading", look: PLAIN_HEADING, "aria-expanded": wheel === "date", onClick: () => toggle("date"), children: names.months[sm] }), _jsx(Button, { kind: "quiet", size: "lg", className: "o-date-editor-year", look: PLAIN_YEAR, "aria-expanded": wheel === "date", onClick: () => toggle("date"), children: String(sy) })] }), wheels ?? _jsx(_Fragment, { children: dayGrid(true, names.week) }), time && _jsx(DateParts, { form: "phone", words: w, onEnter: () => { if (take())
|
|
206
|
-
keep(dayOfLine(), clock); }, date: date, clock: clock, today: today, wheel: wheel, onWheel:
|
|
208
|
+
keep(dayOfLine(), clock); } }), reading && "date" in reading && _jsx(InputGroupAddon, { side: "end", children: _jsx("span", { className: "o-date-editor-reads", "data-slot": "vk-date-reads", children: lineText(reading.date, names) }) })] }), error && _jsx("p", { className: "o-date-editor-error", "data-slot": "vk-date-error", role: "alert", children: error }), !calendar && _jsxs("div", { className: "o-date-editor-head", "data-slot": "vk-date-head", children: [_jsx(Button, { kind: "quiet", shape: "icon", size: "lg", "data-slot": "vk-date-prev", "aria-label": w.lastMonth, icon: glyph(LEFT), onClick: () => setKey(addMonths(shownKey, -1)) }), _jsx(Button, { kind: "quiet", shape: "icon", size: "lg", "data-slot": "vk-date-next", "aria-label": w.nextMonth, icon: glyph(RIGHT), onClick: () => setKey(addMonths(shownKey, 1)) }), _jsx(Button, { kind: "quiet", size: "lg", className: "o-date-editor-heading", "data-slot": "vk-date-month", look: PLAIN_HEADING, "aria-expanded": wheel === "date", onClick: () => toggle("date"), children: names.months[sm] }), _jsx(Button, { kind: "quiet", size: "lg", className: "o-date-editor-year", "data-slot": "vk-date-year", look: PLAIN_YEAR, "aria-expanded": wheel === "date", onClick: () => toggle("date"), children: String(sy) })] }), calendar ? (wheel === "time" ? wheels : calendar) : wheels ?? _jsx(_Fragment, { children: dayGrid(true, names.week) }), time && _jsx(DateParts, { form: "phone", words: w, onEnter: () => { if (take())
|
|
209
|
+
keep(dayOfLine(), clock); }, date: date, clock: clock, today: today, wheel: wheel, onWheel: calendar ? (which) => { if (which === "time")
|
|
210
|
+
toggle(which); } : toggle, onDate: (d) => { setDate(d); setKey(d); hand(d, clock); }, onClock: setTime }), quick] }));
|
|
207
211
|
return { body: plain, head: shell ? {} : head };
|
|
208
212
|
}
|
|
209
|
-
const body = (_jsxs("div", { ref: placeRoot, className: "o-date-editor", "data-kit": "date-editor", "data-date-form": "phone", ...phoneMark(!!host || small), ...wornAttrs(worn), children: [
|
|
213
|
+
const body = (_jsxs("div", { ref: placeRoot, className: "o-date-editor", "data-slot": "vk-date", "data-kit": "date-editor", "data-date-form": "phone", ...phoneMark(!!host || small), ...wornAttrs(worn), children: [_jsx("div", { className: "o-date-editor-card", "data-slot": "vk-date-card", "data-key": "date", children: calendar || _jsxs(_Fragment, { children: [_jsxs("div", { className: "o-date-editor-card-head", "data-slot": "vk-date-head", children: [_jsx(Button, { kind: "quiet", size: "lg", className: "o-date-editor-heading", "data-slot": "vk-date-month", look: CARD_HEADING, "aria-expanded": wheel === "date", iconEnd: glyph(wheel === "date" ? DOWN : RIGHT), onClick: () => setWheel(wheel === "date" ? "none" : "date"), children: `${names.months[sm]} ${sy}` }), wheel !== "date" && _jsxs("span", { className: "o-date-editor-arrows", children: [_jsx(Button, { kind: "quiet", shape: "icon", size: "lg", "data-slot": "vk-date-prev", "aria-label": w.lastMonth, icon: glyph(LEFT), onClick: () => setKey(addMonths(shownKey, -1)) }), _jsx(Button, { kind: "quiet", shape: "icon", size: "lg", "data-slot": "vk-date-next", "aria-label": w.nextMonth, icon: glyph(RIGHT), onClick: () => setKey(addMonths(shownKey, 1)) })] })] }), wheel === "date" ? (_jsxs("div", { className: "o-date-editor-wheels", "data-slot": "vk-date-wheels", children: [_jsx(Wheel, { name: "month", label: w.month, items: months, value: String(sm), onChange: (v) => setKey(addMonths(shownKey, Number(v) - sm)) }, "month"), _jsx(Wheel, { name: "year", label: w.year, items: years, value: String(sy), onChange: (v) => setKey(addMonths(shownKey, (Number(v) - sy) * 12)) }, "year")] })) : (_jsx(_Fragment, { children: dayGrid(true, names.weekUpper) }))] }) }), time && (_jsx("div", { className: "o-date-editor-card", "data-slot": "vk-date-card", "data-key": "time", children: wheel === "time" ? (_jsxs("div", { className: "o-date-editor-wheels", "data-slot": "vk-date-wheels", children: [_jsx(Wheel, { name: "hour", label: w.hour, items: hours, value: hh, onChange: (v) => setTime(`${v}:${mm}`) }, "hour"), _jsx(Wheel, { name: "minute", label: w.minute, items: mins, value: mm, onChange: (v) => setTime(`${hh}:${v}`) }, "minute")] })) : (_jsx(MenuListRow, { "data-slot": "vk-date-time", label: w.time, value: clock ?? w.addTime, onSelect: () => { if (!clock)
|
|
210
214
|
setTime("09:00"); setWheel("time"); } })) })), quick] }));
|
|
211
215
|
return { body, head: shell ? {} : head };
|
|
212
216
|
}
|
|
@@ -239,17 +243,19 @@ export function useDateEditor(props) {
|
|
|
239
243
|
el.focus({ preventScroll: true });
|
|
240
244
|
el.select();
|
|
241
245
|
} };
|
|
242
|
-
const timeButton = _jsx(Button, { kind: "quiet", size: lineBox ? "2xs" : "xs", className: "o-date-editor-time", look: TIME, "aria-pressed": view === "time", "data-empty": clock ? undefined : "", icon: glyph(CLOCK), onClick: () => setView(view === "time" ? "days" : "time"), children: clock ?? w.addTime });
|
|
243
|
-
const boxLine = (_jsxs(InputGroup, { size: "sm", className: "o-date-editor-line", "data-bad": error ? "" : undefined, children: [_jsx(Input, { ref: lineRef, className: "o-date-editor-input", "aria-label": label, placeholder: `${w.type}…`, autofill: false, spellCheck: false, "aria-invalid": error ? true : undefined, value: typed ?? "", onChange: (e) => { setTyped(e.target.value); setError(null); handTyped(e.target.value); }, onKeyDown: (e) => { if (blank(typed) && (e.key === "Backspace" || e.key === "Delete")) {
|
|
246
|
+
const timeButton = _jsx(Button, { kind: "quiet", size: lineBox ? "2xs" : "xs", className: "o-date-editor-time", "data-slot": "vk-date-time", look: TIME, "aria-pressed": view === "time", "data-empty": clock ? undefined : "", icon: glyph(CLOCK), onClick: () => setView(view === "time" ? "days" : "time"), children: clock ?? w.addTime });
|
|
247
|
+
const boxLine = (_jsxs(InputGroup, { size: "sm", className: "o-date-editor-line", "data-slot": "vk-date-line", "data-bad": error ? "" : undefined, children: [_jsx(Input, { ref: lineRef, className: "o-date-editor-input", "aria-label": label, placeholder: `${w.type}…`, autofill: false, spellCheck: false, "aria-invalid": error ? true : undefined, value: typed ?? "", onChange: (e) => { setTyped(e.target.value); setError(null); handTyped(e.target.value); }, onKeyDown: (e) => { if (blank(typed) && (e.key === "Backspace" || e.key === "Delete")) {
|
|
244
248
|
e.preventDefault();
|
|
245
249
|
return;
|
|
246
|
-
} lineKeys(e); } }), reading && "date" in reading && _jsx(InputGroupAddon, { side: "end", children: _jsx("span", { className: "o-date-editor-reads", children: lineText(reading.date, names) }) }), time && !inParts && _jsx(InputGroupAddon, { side: "end", flush: true, children: timeButton })] }));
|
|
250
|
+
} lineKeys(e); } }), reading && "date" in reading && _jsx(InputGroupAddon, { side: "end", children: _jsx("span", { className: "o-date-editor-reads", "data-slot": "vk-date-reads", children: lineText(reading.date, names) }) }), time && !inParts && _jsx(InputGroupAddon, { side: "end", flush: true, children: timeButton })] }));
|
|
251
|
+
const shownView = calendar && (view === "months" || view === "years") ? "days" : view;
|
|
252
|
+
const daysShown = shownView === "days" || (inParts && shownView === "time");
|
|
247
253
|
const refocus = (sel) => requestAnimationFrame(() => root.current?.querySelector(sel)?.focus({ preventScroll: true }));
|
|
248
|
-
const body = (_jsxs("div", { ref: rootRef, className: "o-date-editor", "data-kit": "date-editor", "data-date-form": "computer", ...phoneMark(!!host || small), ...wornAttrs(worn), onBlur: onBlur, onFocus: () => { settled.current = false; }, onKeyDown: shell ? undefined : (e) => { if (e.key === "Escape") {
|
|
254
|
+
const body = (_jsxs("div", { ref: rootRef, className: "o-date-editor", "data-slot": "vk-date", "data-kit": "date-editor", "data-date-form": "computer", ...phoneMark(!!host || small), ...wornAttrs(worn), onBlur: onBlur, onFocus: () => { settled.current = false; }, onKeyDown: shell ? undefined : (e) => { if (e.key === "Escape") {
|
|
249
255
|
e.preventDefault();
|
|
250
256
|
e.stopPropagation();
|
|
251
257
|
escape();
|
|
252
|
-
} }, children: [lineBox ? boxLine : _jsxs("div", { className: "o-date-editor-line o-popup-line", "data-bad": error ? "" : undefined, children: [glyph(CAL), _jsx(Input, { chrome: "bare", ref: (el) => { line.current = el; first(el); }, className: "o-date-editor-input", "aria-label": label, placeholder: w.type, autofill: false, spellCheck: false, "aria-invalid": error ? true : undefined, value: typed ?? (date ? lineText(date, names) : ""), onChange: (e) => { setTyped(e.target.value); setError(null); handTyped(e.target.value); }, onBeforeInput: (e) => { if (typed == null) {
|
|
258
|
+
} }, children: [lineBox ? boxLine : _jsxs("div", { className: "o-date-editor-line o-popup-line", "data-slot": "vk-date-line", "data-bad": error ? "" : undefined, children: [glyph(CAL), _jsx(Input, { chrome: "bare", ref: (el) => { line.current = el; first(el); }, className: "o-date-editor-input", "aria-label": label, placeholder: w.type, autofill: false, spellCheck: false, "aria-invalid": error ? true : undefined, value: typed ?? (date ? lineText(date, names) : ""), onChange: (e) => { setTyped(e.target.value); setError(null); handTyped(e.target.value); }, onBeforeInput: (e) => { if (typed == null) {
|
|
253
259
|
e.preventDefault();
|
|
254
260
|
const d = e.nativeEvent.data ?? "";
|
|
255
261
|
setTyped(d);
|
|
@@ -260,8 +266,8 @@ export function useDateEditor(props) {
|
|
|
260
266
|
setTyped("");
|
|
261
267
|
handTyped("");
|
|
262
268
|
return;
|
|
263
|
-
} lineKeys(e); } }), reading && "date" in reading && _jsx("span", { className: "o-date-editor-reads", children: lineText(reading.date, names) }), time && !inParts && _jsxs(_Fragment, { children: [_jsx("span", { className: "o-date-editor-bar", "aria-hidden": "true" }), timeButton] })] }), error && _jsx("p", { className: "o-date-editor-error", role: "alert", children: error }), _jsxs("div", { className: "o-date-editor-head", children: [_jsx(Button, { kind: "quiet", shape: "icon", size: arrows, "aria-label": w.lastMonth, icon: glyph(LEFT), onClick: () => moveMonth(-1) }), _jsx(Button, { kind: "quiet", shape: "icon", size: arrows, "aria-label": w.nextMonth, icon: glyph(RIGHT), onClick: () => moveMonth(1) }), _jsx(Button, { kind: "quiet", size: "xs", className: "o-date-editor-month", look: STANDS_PRESSED, "aria-pressed": view === "months", onClick: () => setView(view === "months" ? "days" : "months"), children: names.months[sm] }), _jsx("span", { className: "o-date-editor-space" }), worn.year === "typed" && view === "years"
|
|
264
|
-
? _jsx(Input, { ref: yearRef, size: "xs", numeric: true, className: "o-date-editor-year-box", "aria-label": w.year, inputMode: "numeric", maxLength: 4, autofill: false, value: yearText ?? String(sy), onChange: (e) => { const t = e.target.value.replace(/\D/g, "").slice(0, 4), yr = yearTyped(t); setYearText(t); if (yr)
|
|
269
|
+
} lineKeys(e); } }), reading && "date" in reading && _jsx("span", { className: "o-date-editor-reads", "data-slot": "vk-date-reads", children: lineText(reading.date, names) }), time && !inParts && _jsxs(_Fragment, { children: [_jsx("span", { className: "o-date-editor-bar", "aria-hidden": "true" }), timeButton] })] }), error && _jsx("p", { className: "o-date-editor-error", "data-slot": "vk-date-error", role: "alert", children: error }), calendar && daysShown ? calendar : _jsxs("div", { className: "o-date-editor-head", "data-slot": "vk-date-head", children: [_jsx(Button, { kind: "quiet", shape: "icon", size: arrows, "data-slot": "vk-date-prev", "aria-label": w.lastMonth, icon: glyph(LEFT), onClick: () => moveMonth(-1) }), _jsx(Button, { kind: "quiet", shape: "icon", size: arrows, "data-slot": "vk-date-next", "aria-label": w.nextMonth, icon: glyph(RIGHT), onClick: () => moveMonth(1) }), !calendar && _jsx(Button, { kind: "quiet", size: "xs", className: "o-date-editor-month", "data-slot": "vk-date-month", look: STANDS_PRESSED, "aria-pressed": view === "months", onClick: () => setView(view === "months" ? "days" : "months"), children: names.months[sm] }), _jsx("span", { className: "o-date-editor-space" }), calendar ? null : worn.year === "typed" && view === "years"
|
|
270
|
+
? _jsx(Input, { ref: yearRef, size: "xs", numeric: true, className: "o-date-editor-year-box", "data-slot": "vk-date-year", "aria-label": w.year, inputMode: "numeric", maxLength: 4, autofill: false, value: yearText ?? String(sy), onChange: (e) => { const t = e.target.value.replace(/\D/g, "").slice(0, 4), yr = yearTyped(t); setYearText(t); if (yr)
|
|
265
271
|
setKey(addMonths(shownKey, (yr - sy) * 12)); }, onKeyDown: (e) => { if (e.key === "Enter") {
|
|
266
272
|
e.preventDefault();
|
|
267
273
|
leaveYear();
|
|
@@ -269,15 +275,15 @@ export function useDateEditor(props) {
|
|
|
269
275
|
setView("months");
|
|
270
276
|
refocus(".o-date-editor-choice[data-picked]");
|
|
271
277
|
} } })
|
|
272
|
-
: _jsx(Button, { kind: "quiet", size: "xs", className: "o-date-editor-year", look: STANDS_PRESSED, "aria-pressed": view === "years", onMouseDown: worn.year === "typed" ? hold : undefined, onClick: () => { if (view !== "years") {
|
|
278
|
+
: _jsx(Button, { kind: "quiet", size: "xs", className: "o-date-editor-year", "data-slot": "vk-date-year", look: STANDS_PRESSED, "aria-pressed": view === "years", onMouseDown: worn.year === "typed" ? hold : undefined, onClick: () => { if (view !== "years") {
|
|
273
279
|
setYearText(null);
|
|
274
280
|
yearFocus.current = worn.year === "typed";
|
|
275
|
-
} setView(view === "years" ? "days" : "years"); }, children: String(sy) })] }),
|
|
281
|
+
} setView(view === "years" ? "days" : "years"); }, children: String(sy) })] }), !calendar && daysShown && _jsx(_Fragment, { children: dayGrid(false, names.week) }), shownView === "months" && (_jsx("div", { className: "o-date-editor-choices", "data-slot": "vk-date-choices", "data-key": "months", role: "group", "aria-label": w.months, children: names.monthsShort.map((name, i) => _jsx("button", { type: "button", className: "o-date-editor-choice", "data-slot": "vk-date-choice", "data-key": String(i), onMouseDown: hold, "data-picked": i === sm ? "" : undefined, onClick: () => { setKey(addMonths(shownKey, i - sm)); setView("days"); refocus(".o-date-editor-day[data-stop]"); }, children: name }, i)) })), shownView === "years" && (_jsx("div", { className: "o-date-editor-choices", "data-slot": "vk-date-choices", "data-key": "years", role: "group", "aria-label": w.years, children: Array.from({ length: 12 }, (_, i) => sy - 5 + i).map((yr) => (_jsx("button", { type: "button", className: "o-date-editor-choice", "data-slot": "vk-date-choice", "data-key": String(yr), onMouseDown: hold, "data-picked": yr === sy ? "" : undefined, "data-today": yr === parts(today)[0] ? "" : undefined, onClick: () => { leaveYear(); setYearText(null); setKey(addMonths(shownKey, (yr - sy) * 12)); setView("months"); refocus(".o-date-editor-choice[data-picked]"); }, children: yr }, yr))) })), view === "time" && !inParts && (_jsx("div", { className: "o-date-editor-quarters", "data-slot": "vk-date-quarters", role: "group", "aria-label": w.time, children: QUARTERS.map((q) => _jsx("button", { type: "button", className: "o-date-editor-quarter", "data-slot": "vk-date-quarter", "data-key": q, onMouseDown: hold, "data-picked": q === clock ? "" : undefined, ref: q === (clock ?? "09:00") ? (el) => { if (el)
|
|
276
282
|
scrollInList(el, { block: "center" }); } : undefined, onClick: () => { setTime(q); setView("days"); refocus(".o-date-editor-time"); }, children: q }, q)) })), inParts && _jsx(DateParts, { form: "computer", words: w, onEnter: () => { if (take())
|
|
277
|
-
keep(dayOfLine(), clock); }, date: date, clock: clock, today: today, shownTyping: props.opens === "time", onDate: (d) => { setDate(d); setKey(d); setTyped(null); setError(null); hand(d, clock); }, onClock: setTime }), worn.picks === "two" && _jsx("div", { className: "o-date-editor-sep" }), quick] }));
|
|
283
|
+
keep(dayOfLine(), clock); }, date: date, clock: clock, today: today, shownTyping: props.opens === "time", onDate: (d) => { setDate(d); setKey(d); setTyped(null); setError(null); hand(d, clock); }, onClock: setTime }), worn.picks === "two" && _jsx("div", { className: "o-date-editor-sep", "data-slot": "vk-date-sep" }), quick] }));
|
|
278
284
|
return { body, head: {} };
|
|
279
285
|
}
|
|
280
|
-
function Wheel({ label, items, value, onChange }) {
|
|
286
|
+
function Wheel({ name, label, items, value, onChange }) {
|
|
281
287
|
const col = React.useRef(null), timer = React.useRef(0);
|
|
282
288
|
const at = Math.max(0, items.findIndex((i) => i.value === value));
|
|
283
289
|
React.useLayoutEffect(() => { const el = col.current; if (el)
|
|
@@ -293,7 +299,7 @@ function Wheel({ label, items, value, onChange }) {
|
|
|
293
299
|
onChange(items[i].value);
|
|
294
300
|
}, 120);
|
|
295
301
|
};
|
|
296
|
-
return (_jsx("div", { ref: col, className: "o-date-editor-wheel", role: "listbox", "aria-label": label, tabIndex: 0, onScroll: settle, children: items.map((it) => _jsx("div", { role: "option", "aria-selected": it.value === value, className: cx("o-date-editor-wheel-row", it.value === value && "o-date-editor-wheel-on"), onClick: (e) => { scrollInList(e.currentTarget, { block: "center", behavior: "smooth" }); onChange(it.value); }, children: it.label }, it.value)) }));
|
|
302
|
+
return (_jsx("div", { ref: col, className: "o-date-editor-wheel", "data-slot": "vk-date-wheel", "data-key": name, role: "listbox", "aria-label": label, tabIndex: 0, onScroll: settle, children: items.map((it) => _jsx("div", { role: "option", "data-slot": "vk-date-wheel-row", "data-key": it.value, "aria-selected": it.value === value, className: cx("o-date-editor-wheel-row", it.value === value && "o-date-editor-wheel-on"), onClick: (e) => { scrollInList(e.currentTarget, { block: "center", behavior: "smooth" }); onChange(it.value); }, children: it.label }, it.value)) }));
|
|
297
303
|
}
|
|
298
304
|
export function DateEditor(props) {
|
|
299
305
|
return _jsx(_Fragment, { children: useDateEditor(props).body });
|
|
@@ -87,15 +87,15 @@ export function DateParts({ date, clock, today, form, onDate, onClock, shownTypi
|
|
|
87
87
|
const slash = (c) => _jsx("span", { className: "o-date-editor-slash", "aria-hidden": "true", children: c });
|
|
88
88
|
const joined = (list, c, each) => list.flatMap((s, i) => (i ? [_jsx(React.Fragment, { children: slash(c) }, `${s}-sep`), _jsx(React.Fragment, { children: each(s) }, s)] : [_jsx(React.Fragment, { children: each(s) }, s)]));
|
|
89
89
|
if (form === "phone") {
|
|
90
|
-
const shown = (s) => _jsx("span", { className: "o-date-editor-seg", "data-waiting": segs[s] == null ? "" : undefined, children: segmentText(s, segs[s]) });
|
|
91
|
-
const box = (which, list, c) => (_jsx(Select, { opens: "dialog", size: "lg", arrow: "none", "aria-label": which === "date" ? w.date : w.time, className: "o-date-editor-part", shown: _jsx("span", { className: "o-date-editor-shown", children: joined(list, c, shown) }), open: wheel === which, onOpenChange: (o) => { if (o !== (wheel === which))
|
|
90
|
+
const shown = (s) => _jsx("span", { className: "o-date-editor-seg", "data-slot": "vk-date-segment", "data-key": s, "data-waiting": segs[s] == null ? "" : undefined, children: segmentText(s, segs[s]) });
|
|
91
|
+
const box = (which, list, c) => (_jsx(Select, { opens: "dialog", size: "lg", arrow: "none", "aria-label": which === "date" ? w.date : w.time, className: "o-date-editor-part", "data-slot": "vk-date-part", "data-key": which, shown: _jsx("span", { className: "o-date-editor-shown", children: joined(list, c, shown) }), open: wheel === which, onOpenChange: (o) => { if (o !== (wheel === which))
|
|
92
92
|
onWheel?.(which); } }));
|
|
93
|
-
return _jsxs("div", { className: "o-date-editor-parts", children: [box("date", DATE, "/"), box("time", TIME, ":")] });
|
|
93
|
+
return _jsxs("div", { className: "o-date-editor-parts", "data-slot": "vk-date-parts", children: [box("date", DATE, "/"), box("time", TIME, ":")] });
|
|
94
94
|
}
|
|
95
95
|
const seg = (s) => {
|
|
96
96
|
const [min, max] = segmentRange(s, segs), v = segs[s];
|
|
97
|
-
return (_jsx(InputGroupSegment, { "data-seg": s, className: "o-date-editor-seg", "aria-label": NAMES[s], "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": v ?? undefined, "aria-valuetext": segmentText(s, v), on: on === s || (shownTyping && s === "hour"), "data-waiting": v == null && !(shownTyped.seg === s && shownTyped.text) ? "" : undefined, onKeyDown: keys(s), onFocus: () => setOn(s), onBlur: () => { setOn(null); setTyped({ seg: null, text: "" }); }, children: shownTyped.seg === s && shownTyped.text && v == null ? shownTyped.text : segmentText(s, v) }));
|
|
97
|
+
return (_jsx(InputGroupSegment, { "data-seg": s, "data-slot": "vk-date-segment", "data-key": s, className: "o-date-editor-seg", "aria-label": NAMES[s], "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": v ?? undefined, "aria-valuetext": segmentText(s, v), on: on === s || (shownTyping && s === "hour"), "data-waiting": v == null && !(shownTyped.seg === s && shownTyped.text) ? "" : undefined, onKeyDown: keys(s), onFocus: () => setOn(s), onBlur: () => { setOn(null); setTyped({ seg: null, text: "" }); }, children: shownTyped.seg === s && shownTyped.text && v == null ? shownTyped.text : segmentText(s, v) }));
|
|
98
98
|
};
|
|
99
|
-
const box = (which, list, c) => (_jsx(InputGroup, { size: "sm", className: "o-date-editor-part", "aria-label": which === "Date" ? w.date : w.time, "data-force": shownTyping && which === "Time" ? "focus" : undefined, children: joined(list, c, seg) }));
|
|
100
|
-
return _jsxs("div", { ref: own, className: "o-date-editor-parts", children: [box("Date", DATE, "/"), box("Time", TIME, ":")] });
|
|
99
|
+
const box = (which, list, c) => (_jsx(InputGroup, { size: "sm", className: "o-date-editor-part", "data-slot": "vk-date-part", "data-key": which.toLowerCase(), "aria-label": which === "Date" ? w.date : w.time, "data-force": shownTyping && which === "Time" ? "focus" : undefined, children: joined(list, c, seg) }));
|
|
100
|
+
return _jsxs("div", { ref: own, className: "o-date-editor-parts", "data-slot": "vk-date-parts", children: [box("Date", DATE, "/"), box("Time", TIME, ":")] });
|
|
101
101
|
}
|
|
@@ -4,6 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import { cx } from "../../internal/cx.js";
|
|
5
5
|
import { useViews } from "../../provider/context.js";
|
|
6
6
|
import { useMoment } from "../../provider/moment.js";
|
|
7
|
+
import { markOwnControl } from "../../provider/own-control.js";
|
|
7
8
|
import { Button } from "../button/button.js";
|
|
8
9
|
import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
|
|
9
10
|
import { addMonths, dateNames, parts, todayOf } from "./calendar.js";
|
|
@@ -36,5 +37,6 @@ export function MapCalendar({ value, onChange, min, max, month, onMonthChange, c
|
|
|
36
37
|
const off = (day) => (min != null && day < min) || (max != null && day > max);
|
|
37
38
|
const [y, m] = parts(key);
|
|
38
39
|
const arrows = phone ? "lg" : worn.days === "outlined" ? "2xs" : "xs";
|
|
39
|
-
return (_jsxs("div", { ref: wornRef, className: cx("o-date-editor o-date-calendar", className), "data-kit": "date-editor", "data-date-form": phone ? "phone" : "computer", ...phoneMark(phone), "data-date-days": worn.days, "data-date-year": worn.year, "data-date-calendar": worn.calendar, children: [_jsxs("div", { className: "o-date-editor-head", children: [_jsx(Button, { kind: "quiet", shape: "icon", size: arrows, "aria-label": w.lastMonth, icon: glyph(LEFT), onClick: () => moveTo(addMonths(key, -1)) }), _jsx(Button, { kind: "quiet", shape: "icon", size: arrows, "aria-label": w.nextMonth, icon: glyph(RIGHT), onClick: () => moveTo(addMonths(key, 1)) }), _jsx("span", { className: "o-date-editor-caption", children: names.months[m] }), _jsx("span", { className: "o-date-editor-space" }), _jsx("span", { className: "o-date-editor-caption o-date-editor-year", children: String(y) })] }), _jsx(DateDays, { year: y, month: m, keyDay: key, picked: value, today: today, names: names, weekdays: phone && worn.calendar === "cards" ? names.weekUpper : names.week, big: phone, off: off, onPick: onChange, onKeyMove: moveTo })] }));
|
|
40
|
+
return (_jsxs("div", { ref: wornRef, className: cx("o-date-editor o-date-calendar", className), "data-slot": "vk-calendar", "data-kit": "date-editor", "data-date-form": phone ? "phone" : "computer", ...phoneMark(phone), "data-date-days": worn.days, "data-date-year": worn.year, "data-date-calendar": worn.calendar, children: [_jsxs("div", { className: "o-date-editor-head", "data-slot": "vk-date-head", children: [_jsx(Button, { kind: "quiet", shape: "icon", size: arrows, "data-slot": "vk-date-prev", "aria-label": w.lastMonth, icon: glyph(LEFT), onClick: () => moveTo(addMonths(key, -1)) }), _jsx(Button, { kind: "quiet", shape: "icon", size: arrows, "data-slot": "vk-date-next", "aria-label": w.nextMonth, icon: glyph(RIGHT), onClick: () => moveTo(addMonths(key, 1)) }), _jsx("span", { className: "o-date-editor-caption", "data-slot": "vk-date-month", children: names.months[m] }), _jsx("span", { className: "o-date-editor-space" }), _jsx("span", { className: "o-date-editor-caption o-date-editor-year", "data-slot": "vk-date-year", children: String(y) })] }), _jsx(DateDays, { year: y, month: m, keyDay: key, picked: value, today: today, names: names, weekdays: phone && worn.calendar === "cards" ? names.weekUpper : names.week, big: phone, off: off, onPick: onChange, onKeyMove: moveTo })] }));
|
|
40
41
|
}
|
|
42
|
+
markOwnControl(MapCalendar);
|
|
@@ -6,6 +6,6 @@ import type { DateEditorWords } from "./words.js";
|
|
|
6
6
|
* panel holds the phone's ✕ and ✓. */
|
|
7
7
|
export declare function dateEditorWordsOf(messages: FieldMessageResolver): Partial<DateEditorWords>;
|
|
8
8
|
/** ViewKit's date body's props as the Date editor's, held as a shell that keeps the draft. */
|
|
9
|
-
export declare function dateEditorPropsOf(props: ViewsDateBodyProps, words: Partial<DateEditorWords>, language: string): DateEditorProps;
|
|
9
|
+
export declare function dateEditorPropsOf(props: ViewsDateBodyProps, words: Partial<DateEditorWords>, language: string, locale?: string): DateEditorProps;
|
|
10
10
|
/** ViewKit's date body, drawn as the Date editor in the app's words and language. */
|
|
11
11
|
export declare function MapDateBody(props: ViewsDateBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { useViews } from "../../provider/context.js";
|
|
5
5
|
import { DateEditor } from "./date-editor.js";
|
|
6
|
+
import { PanelControlsFromViews } from "../internal/map-panel-controls.js";
|
|
6
7
|
export function dateEditorWordsOf(messages) {
|
|
7
8
|
const say = (key) => messages({ key });
|
|
8
9
|
return {
|
|
@@ -28,11 +29,14 @@ export function dateEditorWordsOf(messages) {
|
|
|
28
29
|
noSuchDay: (month, day) => messages({ key: "date.no-such-day", values: { month, day } }),
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
|
-
export function dateEditorPropsOf(props, words, language) {
|
|
32
|
-
return { ...props, draft: "shell", words, language };
|
|
32
|
+
export function dateEditorPropsOf(props, words, language, locale) {
|
|
33
|
+
return { ...props, draft: "shell", words, language, ...(locale ? { locale } : {}) };
|
|
33
34
|
}
|
|
34
35
|
export function MapDateBody(props) {
|
|
36
|
+
return _jsx(PanelControlsFromViews, { children: _jsx(DateBodyInner, { ...props }) });
|
|
37
|
+
}
|
|
38
|
+
function DateBodyInner(props) {
|
|
35
39
|
const { conventions } = useViews();
|
|
36
40
|
const words = React.useMemo(() => dateEditorWordsOf(conventions.messages), [conventions.messages]);
|
|
37
|
-
return _jsx(DateEditor, { ...dateEditorPropsOf(props, words, conventions.language) });
|
|
41
|
+
return _jsx(DateEditor, { ...dateEditorPropsOf(props, words, conventions.language, conventions.locale) });
|
|
38
42
|
}
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
}
|
|
48
48
|
@media (hover: hover) { .o-date-editor-day:hover:not(:disabled) { background-color: var(--vk-overlay-hovered); } }
|
|
49
49
|
.o-date-editor-day[data-today] { color: var(--vk-fg-accent); font-weight: var(--vk-font-weight-semibold); }
|
|
50
|
-
.o-date-editor-day[data-
|
|
50
|
+
.o-date-editor-day[data-stop]:focus-visible { outline: none; box-shadow: inset 0 0 0 calc(var(--vk-border-width) * 1.5) var(--vk-border-brand); }
|
|
51
51
|
.o-date-editor-day[data-picked] { background-color: var(--vk-brand); color: var(--vk-fg-on-brand); font-weight: var(--vk-font-weight-semibold); box-shadow: none; }
|
|
52
52
|
.o-date-editor-day:disabled { color: var(--vk-fg-disabled); cursor: not-allowed; }
|
|
53
53
|
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
}
|
|
104
104
|
.o-date-editor[data-date-form="computer"][data-date-days="outlined"] .o-date-editor-day[data-picked],
|
|
105
105
|
.o-date-editor[data-date-form="computer"][data-date-days="outlined"] .o-date-editor-choice[data-picked] { background-color: var(--vk-brand); font-weight: var(--vk-font-weight-medium); box-shadow: none; }
|
|
106
|
-
.o-date-editor[data-date-form="computer"][data-date-days="outlined"] .o-date-editor-day[data-
|
|
106
|
+
.o-date-editor[data-date-form="computer"][data-date-days="outlined"] .o-date-editor-day[data-stop]:focus-visible { box-shadow: inset 0 0 0 var(--vk-focus-width) var(--vk-border-brand); }
|
|
107
107
|
.o-date-editor[data-date-form="computer"][data-date-days="outlined"] .o-date-editor-choice[data-today] { font-weight: var(--vk-font-weight-normal); }
|
|
108
108
|
|
|
109
109
|
/* The year, typed into: the year in the text's colour; while its twelve stand, a box to type it in. */
|