viewkitjs 0.33.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.
Files changed (107) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/package.json +1 -1
  3. package/views/dist/contract.d.ts +20 -10
  4. package/views/dist/contract.js +37 -3
  5. package/views/dist/controls/alert/alert.js +2 -1
  6. package/views/dist/controls/alert-dialog/alert-dialog.js +3 -2
  7. package/views/dist/controls/bulk-bar/bulk-bar.js +25 -22
  8. package/views/dist/controls/controls.d.ts +2 -0
  9. package/views/dist/controls/controls.js +2 -0
  10. package/views/dist/controls/customize/customize.js +8 -6
  11. package/views/dist/controls/customize/map-customize-body.d.ts +2 -2
  12. package/views/dist/controls/customize/map-customize-body.js +3 -2
  13. package/views/dist/controls/date-editor/date-editor.d.ts +3 -0
  14. package/views/dist/controls/date-editor/date-editor.js +13 -7
  15. package/views/dist/controls/date-editor/map-calendar.js +2 -0
  16. package/views/dist/controls/date-editor/map-date-body.d.ts +1 -1
  17. package/views/dist/controls/date-editor/map-date-body.js +7 -3
  18. package/views/dist/controls/filter-editor/map-filter-body.d.ts +2 -0
  19. package/views/dist/controls/filter-editor/map-filter-body.js +7 -4
  20. package/views/dist/controls/filter-editor/parts.d.ts +3 -1
  21. package/views/dist/controls/filter-editor/parts.js +7 -6
  22. package/views/dist/controls/group-editor/group-editor.js +2 -1
  23. package/views/dist/controls/group-editor/map-group-body.d.ts +1 -0
  24. package/views/dist/controls/group-editor/map-group-body.js +5 -1
  25. package/views/dist/controls/input/input.js +2 -1
  26. package/views/dist/controls/internal/head-button.d.ts +9 -0
  27. package/views/dist/controls/internal/head-button.js +13 -0
  28. package/views/dist/controls/internal/panel-controls.d.ts +13 -5
  29. package/views/dist/controls/internal/panel-controls.js +53 -10
  30. package/views/dist/controls/menu/menu.d.ts +2 -1
  31. package/views/dist/controls/menu/menu.js +2 -2
  32. package/views/dist/controls/modal/modal.js +5 -3
  33. package/views/dist/controls/number-editor/map-number-body.js +5 -1
  34. package/views/dist/controls/number-editor/number-editor.js +6 -6
  35. package/views/dist/controls/pane/map-pane.d.ts +3 -0
  36. package/views/dist/controls/pane/map-pane.js +5 -0
  37. package/views/dist/controls/picker/map-fields-body.js +25 -1
  38. package/views/dist/controls/picker.css +10 -1
  39. package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +2 -1
  40. package/views/dist/controls/quick-filters/map-quick-filters-body.js +7 -3
  41. package/views/dist/controls/quick-filters/quick-filters.js +5 -3
  42. package/views/dist/controls/setting-row/looks.js +5 -5
  43. package/views/dist/controls/setting-row/setting-row.d.ts +3 -1
  44. package/views/dist/controls/setting-row/setting-row.js +3 -1
  45. package/views/dist/controls/setting-row.css +3 -2
  46. package/views/dist/controls/sheet/bottom-sheet.d.ts +3 -1
  47. package/views/dist/controls/sheet/bottom-sheet.js +2 -2
  48. package/views/dist/controls/sort-editor/map-sort-body.js +4 -4
  49. package/views/dist/controls/text-editor/map-text-body.js +5 -1
  50. package/views/dist/controls/text-editor/text-editor.js +5 -4
  51. package/views/dist/controls/toolbar/toolbar.d.ts +4 -2
  52. package/views/dist/controls/toolbar/toolbar.js +2 -2
  53. package/views/dist/controls/views-list/map-view-menu.d.ts +3 -2
  54. package/views/dist/controls/views-list/map-view-menu.js +6 -2
  55. package/views/dist/controls/views-list/map-views-list-body.d.ts +2 -1
  56. package/views/dist/controls/views-list/map-views-list-body.js +6 -5
  57. package/views/dist/controls/views-list/view-menu.js +3 -4
  58. package/views/dist/controls/views-list/views-list.js +2 -2
  59. package/views/dist/editors/EditorPanel.js +3 -3
  60. package/views/dist/list/list.d.ts +6 -2
  61. package/views/dist/list/list.js +6 -2
  62. package/views/dist/list/parts.js +3 -2
  63. package/views/dist/list/toolbar.js +9 -3
  64. package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +13 -0
  65. package/views/dist/panels/react/toolbar/Toolbar.d.ts +4 -0
  66. package/views/dist/panels/react/toolbar/Toolbar.js +8 -3
  67. package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +3 -2
  68. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +3 -2
  69. package/views/dist/panels/react/toolbar/ToolbarFilters.js +3 -2
  70. package/views/dist/panels/react/toolbar/ToolbarSortPill.js +3 -2
  71. package/views/dist/panels/react/toolbar/context.d.ts +21 -0
  72. package/views/dist/panels/react/toolbar/context.js +4 -0
  73. package/views/dist/panels/react/toolbar/pane-host.d.ts +6 -0
  74. package/views/dist/panels/react/toolbar/pane-host.js +17 -0
  75. package/views/dist/panels/react/toolbar/panel-part.js +3 -2
  76. package/views/dist/panels/react.d.ts +1 -1
  77. package/views/dist/provider/ViewsProvider.d.ts +4 -3
  78. package/views/dist/provider/components.d.ts +34 -5
  79. package/views/dist/provider/components.js +1 -1
  80. package/views/dist/react.d.ts +1 -1
  81. package/views/dist/styles.css +97 -78
  82. package/views/dist/styles.unlayered.css +97 -78
  83. package/views/docs/contract.md +62 -6
  84. package/views/docs/controls/alert-dialog.md +4 -0
  85. package/views/docs/controls/alert.md +4 -0
  86. package/views/docs/controls/bulk-bar.md +4 -0
  87. package/views/docs/controls/customize.md +3 -1
  88. package/views/docs/controls/date-editor.md +2 -0
  89. package/views/docs/controls/filter-editor.md +1 -1
  90. package/views/docs/controls/group-editor.md +2 -0
  91. package/views/docs/controls/menu.md +3 -1
  92. package/views/docs/controls/modal.md +4 -0
  93. package/views/docs/controls/number-editor.md +2 -0
  94. package/views/docs/controls/quick-filters.md +3 -1
  95. package/views/docs/controls/sheet.md +1 -1
  96. package/views/docs/controls/text-editor.md +2 -0
  97. package/views/docs/controls/toolbar.md +4 -0
  98. package/views/docs/controls/views-list.md +2 -0
  99. package/views/docs/guides/the-provider.md +4 -4
  100. package/views/docs/reference/controls.md +5 -3
  101. package/views/docs/reference/list.md +5 -3
  102. package/views/docs/reference/looks.md +1 -1
  103. package/views/docs/reference/panels-react.md +6 -5
  104. package/views/docs/reference/react.md +7 -6
  105. package/views/docs/reference/views.md +4 -2
  106. package/views/docs/reshaping.md +16 -5
  107. package/views/skills/views/SKILL.md +1 -1
@@ -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 { Button } from "../button/button.js";
6
- import { Input, InputGroup, InputGroupAddon } from "../input/input.js";
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,6 +187,8 @@ 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
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) {
@@ -202,11 +205,12 @@ export function useDateEditor(props) {
202
205
  setTime("09:00"); setWheel(wheel === w ? "none" : w); };
203
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", "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 }), _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) })] }), 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: toggle, onDate: (d) => { setDate(d); setKey(d); hand(d, clock); }, onClock: setTime }), quick] }));
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-slot": "vk-date", "data-kit": "date-editor", "data-date-form": "phone", ...phoneMark(!!host || small), ...wornAttrs(worn), children: [_jsxs("div", { className: "o-date-editor-card", "data-slot": "vk-date-card", "data-key": "date", 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)
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
  }
@@ -244,6 +248,8 @@ export function useDateEditor(props) {
244
248
  e.preventDefault();
245
249
  return;
246
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
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();
@@ -260,7 +266,7 @@ 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", "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 }), _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) }), _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" }), worn.year === "typed" && view === "years"
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"
264
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();
@@ -272,7 +278,7 @@ export function useDateEditor(props) {
272
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) })] }), (view === "days" || (inParts && view === "time")) && _jsx(_Fragment, { children: dayGrid(false, names.week) }), view === "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)) })), view === "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)
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
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: {} };
@@ -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";
@@ -38,3 +39,4 @@ export function MapCalendar({ value, onChange, min, max, month, onMonthChange, c
38
39
  const arrows = phone ? "lg" : worn.days === "outlined" ? "2xs" : "xs";
39
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
  }
@@ -30,5 +30,7 @@ export declare function partOf(rule: ViewKitRule, field: ViewsFilterPartBodyProp
30
30
  } | null;
31
31
  /** The kit filter's one rule as ViewKit's, naming the field and part the rule handed did; null where it holds none. */
32
32
  export declare function ruleBack(next: KitGroup, rule: ViewKitRule, kit: KitFields): ViewKitRule | null;
33
+ /** ViewKit's body for one part of a filter on the filter bar, its typed value the app's Input where the provider's `panelControls`
34
+ * names it (VK-1014). */
33
35
  export declare function MapFilterPartBody(props: ViewsFilterPartBodyProps): import("react/jsx-runtime").JSX.Element;
34
36
  export {};
@@ -8,11 +8,11 @@ import { useToldStep } from "../internal/told-step.js";
8
8
  import { HeaderBar } from "../phone-header/header-bar.js";
9
9
  import { pickerItemsOf, pickerWordsOf } from "../picker/map-picker.js";
10
10
  import { Picker } from "../picker/picker.js";
11
- import { SheetButton } from "../sheet/bottom-sheet.js";
12
11
  import { useFilterEditor } from "./filter-editor.js";
13
12
  import { kitFieldsOf, kitFilterOf, rulesFor, viewKitFilterOf, writeRules, CHOICE, RELATION_WAY } from "./map-rules.js";
14
13
  import { FilterPartBody } from "./parts.js";
15
14
  import { changeRule, fieldOf, isOwnWay, rulesOf } from "./rules.js";
15
+ import { PanelHeadButton } from "../internal/head-button.js";
16
16
  import { PanelControlsFromViews } from "../internal/map-panel-controls.js";
17
17
  const BACK = ["M5 12l14 0", "M5 12l6 6", "M5 12l6 -6"];
18
18
  export function filterWordsOf(say) {
@@ -152,10 +152,10 @@ function FilterBodyInner(props) {
152
152
  const { actions } = props;
153
153
  if (!actions)
154
154
  return _jsx(_Fragment, { children: parts.body });
155
- const done = actions.done && _jsx(SheetButton, { "data-slot": "vk-editor-save", kind: "primary", "aria-label": actions.done.label, icon: glyph(TICK), onClick: actions.done.onPress });
155
+ const done = actions.done && _jsx(PanelHeadButton, { "data-slot": "vk-editor-save", kind: "primary", "aria-label": actions.done.label, icon: glyph(TICK), onClick: actions.done.onPress });
156
156
  return (_jsxs(_Fragment, { children: [parts.title !== undefined
157
- ? _jsx(BodyHead, { title: parts.title, left: _jsx(SheetButton, { "data-slot": "vk-editor-back", "aria-label": words.back, className: "o-sheet-back", icon: glyph(BACK), onClick: parts.head.onBack }), right: done || _jsx("span", {}) })
158
- : _jsx(BodyHead, { title: props.label, left: _jsx(SheetButton, { "data-slot": "vk-editor-close", "aria-label": actions.close.label, icon: glyph(X), onClick: actions.close.onPress }), right: done || _jsx("span", {}) }), parts.body] }));
157
+ ? _jsx(BodyHead, { title: parts.title, left: _jsx(PanelHeadButton, { "data-slot": "vk-editor-back", "aria-label": words.back, className: "o-sheet-back", icon: glyph(BACK), onClick: parts.head.onBack }), right: done || _jsx("span", {}) })
158
+ : _jsx(BodyHead, { title: props.label, left: _jsx(PanelHeadButton, { "data-slot": "vk-editor-close", "aria-label": actions.close.label, icon: glyph(X), onClick: actions.close.onPress }), right: done || _jsx("span", {}) }), parts.body] }));
159
159
  }
160
160
  export function partOf(rule, field, choices) {
161
161
  const kit = kitFieldsOf([field], choices), [f] = kit.fields, { filter } = kitFilterOf({ op: "and", items: [rule] }, kit);
@@ -170,6 +170,9 @@ export function ruleBack(next, rule, kit) {
170
170
  return { ...only, fieldKey: rule.fieldKey, ...(rule.part !== undefined ? { part: rule.part } : {}) };
171
171
  }
172
172
  export function MapFilterPartBody(props) {
173
+ return _jsx(PanelControlsFromViews, { children: _jsx(FilterPartBodyInner, { ...props }) });
174
+ }
175
+ function FilterPartBodyInner(props) {
173
176
  const views = React.useContext(ViewsContext);
174
177
  const say = views?.messages ?? resolveViewsMessage;
175
178
  const words = React.useMemo(() => filterWordsOf(say), [say]);
@@ -36,11 +36,13 @@ export declare function valuePlaceholder(field: FilterField, w?: FilterEditorWor
36
36
  /** The body a Popover holds under the part of a filter pressed: the fields, its type's ways, or its value in its type's own. */
37
37
  export declare function FilterPartBody({ part, rule: ruleId, label, fields, filter, onFilterChange, onDone, own, form, words: given }: FilterPartProps): import("react/jsx-runtime").JSX.Element | null;
38
38
  /** A range's From and To: two Number fields, an en dash between, each named by its end; either may be left empty. */
39
- export declare function PairValue({ name, value, onValue, size, onKeyDown, words: given }: {
39
+ export declare function PairValue({ name, value, onValue, size, onKeyDown, words: given, slot }: {
40
40
  name: string;
41
41
  value: [number | null, number | null];
42
42
  onValue: (v: [number | null, number | null]) => void;
43
43
  size?: "sm" | "lg";
44
44
  onKeyDown?: (e: React.KeyboardEvent) => void;
45
45
  words?: Partial<FilterEditorWords>;
46
+ /** Its public name, on the pair: the filter bar's popover hands `vk-filter-part-pair` (VK-1003). */
47
+ slot?: string;
46
48
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { DateEditor } from "../date-editor/date-editor.js";
4
- import { Input } from "../input/input.js";
4
+ import { usePanelControls } from "../internal/panel-controls.js";
5
5
  import { NumberField } from "../number-field/number-field.js";
6
6
  import { Picker } from "../picker/picker.js";
7
7
  import { itemLabel } from "../picker/rows.js";
@@ -52,7 +52,7 @@ export function FilterPartBody({ part, rule: ruleId, label, fields, filter, onFi
52
52
  return _jsx(Picker, { label: name, items: field.choices, multiple: several, value: value, form: form, onDone: onDone, ...words, onValueChange: (v) => set({ value: several ? (Array.isArray(v) ? v : []) : typeof v === "string" ? v : null }) });
53
53
  }
54
54
  if (takes === "two")
55
- return _jsx(PairValue, { name: name, value: isPair(r.value) ? r.value : [null, null], onValue: (v) => set({ value: v }), words: w, onKeyDown: (e) => { if (e.key === "Enter") {
55
+ return _jsx(PairValue, { name: name, value: isPair(r.value) ? r.value : [null, null], onValue: (v) => set({ value: v }), words: w, slot: "vk-filter-part-pair", onKeyDown: (e) => { if (e.key === "Enter") {
56
56
  e.preventDefault();
57
57
  onDone();
58
58
  } } });
@@ -60,9 +60,9 @@ export function FilterPartBody({ part, rule: ruleId, label, fields, filter, onFi
60
60
  return _jsx(DateEditor, { label: name, value: typeof r.value === "string" ? r.value : null, onValueChange: (v) => set({ value: v }), onDone: onDone, form: form });
61
61
  return _jsx(TypedValue, { rule: r, field: field, name: name, set: set, onDone: onDone, w: w });
62
62
  }
63
- export function PairValue({ name, value, onValue, size, onKeyDown, words: given }) {
63
+ export function PairValue({ name, value, onValue, size, onKeyDown, words: given, slot }) {
64
64
  const w = filterWords(given), [from, to] = value;
65
- return (_jsxs("div", { className: "o-filter-editor-pair", children: [_jsx(NumberField, { size: size, steppers: false, "aria-label": w.fromOf(name), placeholder: w.from, value: from, onValueChange: (v) => onValue([v ?? null, to]), onKeyDown: onKeyDown }), _jsx("span", { className: "o-filter-editor-dash", "aria-hidden": "true", children: "\u2013" }), _jsx(NumberField, { size: size, steppers: false, "aria-label": w.toOf(name), placeholder: w.to, value: to, onValueChange: (v) => onValue([from, v ?? null]), onKeyDown: onKeyDown })] }));
65
+ return (_jsxs("div", { className: "o-filter-editor-pair", ...(slot ? { "data-slot": slot } : {}), children: [_jsx(NumberField, { size: size, steppers: false, "aria-label": w.fromOf(name), placeholder: w.from, value: from, onValueChange: (v) => onValue([v ?? null, to]), onKeyDown: onKeyDown }), _jsx("span", { className: "o-filter-editor-dash", "aria-hidden": "true", children: "\u2013" }), _jsx(NumberField, { size: size, steppers: false, "aria-label": w.toOf(name), placeholder: w.to, value: to, onValueChange: (v) => onValue([from, v ?? null]), onKeyDown: onKeyDown })] }));
66
66
  }
67
67
  const WHOLE = { maximumFractionDigits: 0 };
68
68
  function TypedValue({ rule: r, field, name, set, onDone, w }) {
@@ -70,7 +70,8 @@ function TypedValue({ rule: r, field, name, set, onDone, w }) {
70
70
  e.preventDefault();
71
71
  onDone();
72
72
  } };
73
+ const { Input } = usePanelControls();
73
74
  return field.type === "number" || field.type === "range"
74
- ? _jsx(NumberField, { "aria-label": name, placeholder: valuePlaceholder(field, w), value: typeof r.value === "number" ? r.value : null, format: field.integer ? WHOLE : undefined, onValueChange: (v) => set({ value: v ?? null }), onKeyDown: enter })
75
- : _jsx(Input, { "aria-label": name, placeholder: valuePlaceholder(field, w), value: typeof r.value === "string" ? r.value : "", onChange: (e) => set({ value: e.target.value }), onKeyDown: enter });
75
+ ? _jsx(NumberField, { "data-slot": "vk-filter-part-value", "aria-label": name, placeholder: valuePlaceholder(field, w), value: typeof r.value === "number" ? r.value : null, format: field.integer ? WHOLE : undefined, onValueChange: (v) => set({ value: v ?? null }), onKeyDown: enter })
76
+ : _jsx(Input, { "data-slot": "vk-filter-part-value", "aria-label": name, placeholder: valuePlaceholder(field, w), value: typeof r.value === "string" ? r.value : "", onChange: (e) => set({ value: e.target.value }), onKeyDown: enter });
76
77
  }
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
- import { Button } from "../button/button.js";
4
+ import { usePanelControls } from "../internal/panel-controls.js";
5
5
  import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
6
6
  import { useStepReturn } from "../internal/step-return.js";
7
7
  import { MENU_LIST_CARD_FRAME } from "../menu-list/looks.js";
@@ -18,6 +18,7 @@ function FieldsOnPhone(props) {
18
18
  }
19
19
  export function useGroupEditor(props) {
20
20
  const { label, fields, ownOrders = {}, group, values, onGroupChange, opens, orders = {}, manualOrder = true, steps = {} } = props;
21
+ const { Button } = usePanelControls();
21
22
  const w = groupWords(props.words), search = props.search ?? w.search;
22
23
  const NAMES = { field: w.groupBy, order: w.order, direction: w.direction, step: w.dateStep };
23
24
  const LEVEL_OF = Object.fromEntries(Object.entries(NAMES).map(([k, v]) => [v, k]));
@@ -16,4 +16,5 @@ export declare function kitGroupValuesOf(group: ViewsGroupValue, noValue: string
16
16
  export declare function viewKitGroupOf(next: ListGroup | null, now: ViewsGroupValue, dated?: boolean): ViewsGroupValue;
17
17
  /** ViewKit's group body's props as the group editor's. */
18
18
  export declare function groupEditorPropsOf(p: ViewsGroupBodyProps, words: GroupEditorWords): GroupEditorProps;
19
+ /** ViewKit's group editor, drawing the app's controls where the provider's `panelControls` names them (VK-1014). */
19
20
  export declare function MapGroupBody(props: ViewsGroupBodyProps): import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,9 @@
1
1
  "use client";
2
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { resolveViewsMessage } from "../../contract.js";
5
5
  import { ViewsContext } from "../../provider/context.js";
6
+ import { PanelControlsFromViews } from "../internal/map-panel-controls.js";
6
7
  import { useToldStep } from "../internal/told-step.js";
7
8
  import { pickerWordsOf } from "../picker/map-picker.js";
8
9
  import { useGroupEditor } from "./group-editor.js";
@@ -97,6 +98,9 @@ export function groupEditorPropsOf(p, words) {
97
98
  };
98
99
  }
99
100
  export function MapGroupBody(props) {
101
+ return _jsx(PanelControlsFromViews, { children: _jsx(GroupBodyInner, { ...props }) });
102
+ }
103
+ function GroupBodyInner(props) {
100
104
  const views = React.useContext(ViewsContext);
101
105
  const messages = views?.messages ?? resolveViewsMessage;
102
106
  const words = React.useMemo(() => groupEditorWordsOf(messages), [messages]);
@@ -17,7 +17,8 @@ export function pressGroup(e) {
17
17
  const on = e.target;
18
18
  if (on.closest(".o-input-segment"))
19
19
  return;
20
- const control = e.currentTarget.querySelector(":scope > .o-input-control") ?? e.currentTarget.querySelector(".o-input-segment");
20
+ const control = e.currentTarget.querySelector(":scope > .o-input-control") ?? e.currentTarget.querySelector(".o-input-segment")
21
+ ?? e.currentTarget.querySelector("input:not([type='hidden']):not([type='checkbox']):not([type='radio'])");
21
22
  if (e.defaultPrevented || !control || on.closest("a, input, textarea, select"))
22
23
  return;
23
24
  if (on.closest("button, [role='button']")) {
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ import { SheetButton } from "../sheet/bottom-sheet.js";
3
+ /** SheetButton's props, and what ViewKit draws in their place when the Button isn't the app's (SheetButton by default). */
4
+ export type PanelHeadButtonProps = React.ComponentProps<typeof SheetButton> & {
5
+ own?: React.ReactNode;
6
+ };
7
+ /** A panel head's ✕, ‹ or ✓: ViewKit's own (`own`, else SheetButton's glass and plain pair), or, where the context holds the app's
8
+ * Button, that Button alone, quiet (primary for a ✓), an icon when it has no words, the part's name on it. */
9
+ export declare function PanelHeadButton({ own, ...props }: PanelHeadButtonProps): React.ReactElement;
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { SheetButton } from "../sheet/bottom-sheet.js";
5
+ import { PanelControlsContext, usePanelControls } from "./panel-controls.js";
6
+ export function PanelHeadButton({ own, ...props }) {
7
+ const app = React.useContext(PanelControlsContext).Button;
8
+ const { Button } = usePanelControls();
9
+ if (!app)
10
+ return _jsx(_Fragment, { children: own ?? _jsx(SheetButton, { ...props }) });
11
+ const { kind, children, ...rest } = props;
12
+ return _jsx(Button, { ...rest, kind: kind ?? "quiet", shape: children == null ? "icon" : undefined, children: children });
13
+ }
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import type { ViewsButtonProps, ViewsInputProps, ViewsMenuItem, ViewsMenuProps, ViewsPopoverProps, ViewsSelectProps } from "../../provider/components.js";
2
+ import type { ViewsButtonProps, ViewsCalendarProps, ViewsInputProps, ViewsMenuItem, ViewsMenuProps, ViewsPopoverProps, ViewsSelectProps } from "../../provider/components.js";
3
3
  import { type ButtonProps } from "../button/button.js";
4
4
  import { type InputProps } from "../input/input.js";
5
5
  import { type MenuProps } from "../menu/menu.js";
@@ -13,6 +13,8 @@ export type AppPanelControls = {
13
13
  Menu?: React.ComponentType<ViewsMenuProps>;
14
14
  Popover?: React.ComponentType<ViewsPopoverProps>;
15
15
  Input?: React.ComponentType<ViewsInputProps>;
16
+ /** The date editor's month (VK-1021). */
17
+ Calendar?: React.ComponentType<ViewsCalendarProps>;
16
18
  };
17
19
  /** No app control: what a panel drawn alone reads. */
18
20
  export declare const NO_APP_CONTROLS: AppPanelControls;
@@ -24,13 +26,17 @@ type ButtonLike = ButtonProps & {
24
26
  type InputLike = InputProps & {
25
27
  ref?: React.Ref<HTMLInputElement>;
26
28
  };
27
- /** The five controls a panel draws, each taking ViewKit's own props. */
29
+ /** The controls a panel or a field editor draws, each taking ViewKit's own props; and the app's Calendar, or none. */
28
30
  export type PanelControls = {
29
31
  Button: React.ComponentType<ButtonLike>;
30
32
  Select: React.ComponentType<SelectProps>;
31
33
  Menu: React.ComponentType<MenuProps>;
32
34
  Popover: React.ComponentType<PopoverProps>;
33
35
  Input: React.ComponentType<InputLike>;
36
+ /** A box group's button (InputGroupButton): ViewKit's, or the app's Button handed it as a quiet one (VK-1021). */
37
+ GroupButton: React.ComponentType<ButtonLike>;
38
+ /** The app's Calendar, or null: the date editor then draws its own month (VK-1021). */
39
+ Calendar: React.ComponentType<ViewsCalendarProps> | null;
34
40
  };
35
41
  /** The controls a panel draws: the app's where the context holds them, else ViewKit's own, the same components. */
36
42
  export declare function usePanelControls(): PanelControls;
@@ -43,8 +49,10 @@ export declare function selectPropsOf(p: SelectListProps): ViewsSelectProps;
43
49
  /** A menu's rows as the map's: an action, a tick, a pick's choices (under its heading when it has one), a line before the next row.
44
50
  * Each row keeps its public name and which one it is. A kind the map has no word for is left out, with a warning. */
45
51
  export declare function menuItemsOf(entries: MenuEntry[], label: string): ViewsMenuItem[];
46
- /** ViewKit's Popover props as the map's: open, where, what closes it, its name; a trigger of its own stays ViewKit's. */
52
+ /** ViewKit's Popover props as the map's: open, where, what closes it, its name, its popup's marks and click (an editor's inner
53
+ * Escape rides those marks, VK-1021); a trigger of its own stays ViewKit's. A `finalFocus` ref is honoured by AppPopover itself. */
47
54
  export declare function popoverPropsOf(p: PopoverProps): ViewsPopoverProps;
48
- /** ViewKit's Input props as the map's: a value typed handed as its change, in the app's field frame; never ViewKit's own look. */
49
- export declare function inputPropsOf(p: InputLike): ViewsInputProps;
55
+ /** ViewKit's Input props as the map's: a value typed handed as its change, in the app's field frame, or bare where a ViewKit box
56
+ * frames it (a box group) or the part says so (VK-1021); never ViewKit's own look. */
57
+ export declare function inputPropsOf(p: InputLike, bare?: boolean): ViewsInputProps;
50
58
  export {};
@@ -2,13 +2,17 @@
2
2
  import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { Button } from "../button/button.js";
5
- import { Input } from "../input/input.js";
5
+ import { useAutofill } from "../input/autofill.js";
6
+ import { Input, InputGroupButton, InputGroupContext } from "../input/input.js";
6
7
  import { Menu } from "../menu/menu.js";
7
8
  import { Popover } from "../popover/popover.js";
8
9
  import { Select } from "../select/select.js";
9
10
  export const NO_APP_CONTROLS = Object.freeze({});
10
11
  export const PanelControlsContext = React.createContext(NO_APP_CONTROLS);
11
- const OWN = { Button: Button, Select, Menu, Popover, Input: Input };
12
+ const OWN = {
13
+ Button: Button, Select, Menu, Popover, Input: Input,
14
+ GroupButton: InputGroupButton, Calendar: null,
15
+ };
12
16
  export function usePanelControls() {
13
17
  const app = React.useContext(PanelControlsContext);
14
18
  return React.useMemo(() => (app === NO_APP_CONTROLS ? OWN : {
@@ -17,6 +21,8 @@ export function usePanelControls() {
17
21
  Menu: app.Menu || app.Button ? OpenedMenu : Menu,
18
22
  Popover: app.Popover ? AppPopover : Popover,
19
23
  Input: app.Input ? AppInput : OWN.Input,
24
+ GroupButton: app.Button ? AppGroupButton : OWN.GroupButton,
25
+ Calendar: app.Calendar ?? null,
20
26
  }), [app]);
21
27
  }
22
28
  const VARIANT = {
@@ -44,6 +50,9 @@ function AppButton(p) {
44
50
  return _jsx(Button, { ...p });
45
51
  return _jsx(Own, { ...buttonPropsOf(p) });
46
52
  }
53
+ function AppGroupButton(p) {
54
+ return _jsx(AppButton, { kind: "quiet", size: "sm", ...p });
55
+ }
47
56
  const selectItemsOf = (items) => items.map(({ value, label, line, group, disabled, mark, level }) => ({
48
57
  value, label, ...(mark != null ? { icon: mark } : {}), ...(line != null ? { line } : {}), ...(group != null ? { group } : {}),
49
58
  ...(disabled ? { disabled } : {}), ...(level ? { level: selectItemsOf(level) } : {}),
@@ -158,10 +167,12 @@ function AnchoredAppMenu(p) {
158
167
  }
159
168
  export function popoverPropsOf(p) {
160
169
  const extra = p;
161
- const unsaid = ["popupData", "onPopupClick", "finalFocus", "defaultOpen"].filter((k) => extra[k] != null);
170
+ const unsaid = ["defaultOpen"].filter((k) => extra[k] != null);
171
+ if (typeof p.finalFocus === "boolean")
172
+ unsaid.push("finalFocus");
162
173
  if (unsaid.length)
163
174
  warnUnsaid("Popover", unsaid, named(p) ?? "");
164
- const { open, onOpenChange, anchor, side, align, sideOffset, alignOffset, initialFocus, onOutsidePress, onEscape, className, style, children } = p;
175
+ const { open, onOpenChange, anchor, side, align, sideOffset, alignOffset, initialFocus, onOutsidePress, onEscape, className, style, children, popupData, onPopupClick } = p;
165
176
  const label = p["aria-label"];
166
177
  return {
167
178
  open: !!open, onOpenChange: (o, d) => onOpenChange?.(o, { reason: (d?.reason ?? "none") }),
@@ -169,20 +180,51 @@ export function popoverPropsOf(p) {
169
180
  ...(side ? { side } : {}), ...(align ? { align } : {}), ...(sideOffset != null ? { sideOffset } : {}), ...(alignOffset != null ? { alignOffset } : {}),
170
181
  ...(initialFocus !== undefined ? { initialFocus: typeof initialFocus === "boolean" ? initialFocus : true } : {}),
171
182
  ...(onOutsidePress ? { onOutsidePress } : {}), ...(onEscape ? { onEscape } : {}), ...(className ? { className } : {}), ...(style ? { style } : {}),
172
- ...(label != null ? { label } : {}),
183
+ ...(label != null ? { label } : {}), ...(popupData ? { panelData: popupData } : {}), ...(onPopupClick ? { onPanelClick: onPopupClick } : {}),
173
184
  };
174
185
  }
175
186
  function AppPopover(p) {
176
187
  const Own = React.useContext(PanelControlsContext).Popover;
188
+ const open = !!p.open, was = React.useRef(open), why = React.useRef(null);
189
+ const back = Own && !p.trigger && p.finalFocus && typeof p.finalFocus !== "boolean" ? p.finalFocus : null;
190
+ React.useLayoutEffect(() => {
191
+ const shut = was.current && !open, reason = why.current;
192
+ was.current = open;
193
+ why.current = null;
194
+ if (!shut || !back || reason === "outside-press" || reason === "focus-out")
195
+ return;
196
+ const give = () => back.current?.focus({ preventScroll: true });
197
+ if (reason) {
198
+ give();
199
+ return;
200
+ }
201
+ const from = document.activeElement;
202
+ let frame = 0, tries = 0;
203
+ const look = () => {
204
+ const now = document.activeElement;
205
+ if (!now || now === document.body || !now.isConnected) {
206
+ give();
207
+ return;
208
+ }
209
+ if (now !== from || tries++ >= 120)
210
+ return;
211
+ frame = requestAnimationFrame(look);
212
+ };
213
+ look();
214
+ return () => cancelAnimationFrame(frame);
215
+ }, [open, back]);
177
216
  if (!Own || p.trigger)
178
217
  return _jsx(Popover, { ...p });
179
- return _jsx(Own, { ...popoverPropsOf(p) });
218
+ const handed = popoverPropsOf(p);
219
+ const onOutsidePress = (e) => { const kept = p.onOutsidePress?.(e); if (kept !== false)
220
+ why.current = "outside-press"; return kept; };
221
+ return _jsx(Own, { ...handed, onOutsidePress: onOutsidePress, onOpenChange: (o, d) => { why.current = o ? null : d?.reason ?? why.current; handed.onOpenChange(o, d); } });
180
222
  }
181
- export function inputPropsOf(p) {
223
+ export function inputPropsOf(p, bare = false) {
182
224
  const { size: _size, chrome: _chrome, look: _look, numeric: _numeric, multiline: _multiline, grow: _grow, maxLines: _maxLines, minLines: _minLines, lines: _lines, autofill: _autofill, fills: _fills, saving: _saving, saved: _saved, combobox: _combobox, onValueChange, onChange, ...rest } = p;
183
225
  return {
184
226
  ...rest,
185
- chrome: "field",
227
+ chrome: bare ? "bare" : "field",
186
228
  onChange: (e) => {
187
229
  onChange?.(e);
188
230
  onValueChange?.(e.target.value, { event: e.nativeEvent });
@@ -191,7 +233,8 @@ export function inputPropsOf(p) {
191
233
  }
192
234
  function AppInput(p) {
193
235
  const Own = React.useContext(PanelControlsContext).Input;
194
- if (!Own)
236
+ const grouped = React.useContext(InputGroupContext) != null, fill = useAutofill();
237
+ if (!Own || p.multiline || p.combobox)
195
238
  return _jsx(Input, { ...p });
196
- return _jsx(Own, { ...inputPropsOf(p) });
239
+ return _jsx(Own, { ...fill(p.autofill !== false), ...inputPropsOf(p, p.chrome === "bare" || grouped) });
197
240
  }
@@ -17,7 +17,8 @@ export interface MenuProps {
17
17
  words?: MenuWords;
18
18
  /** What the menu is for, to screen readers ("Acme Robotics — service portal redesign"). */
19
19
  label: string;
20
- /** Its public name where a panel names it (VK-988: `vk-view-menu`), on its popup on a computer. */
20
+ /** Its public name where a part names it (VK-988: `vk-view-menu`; VK-1023: the bulk bar's `vk-bulk-menu`), on its popup on a
21
+ * computer and on its Sheet on a phone. */
21
22
  "data-slot"?: string;
22
23
  /** What opens it: the ⋯ button by default (MenuDots), named "Actions for <label>". */
23
24
  trigger?: React.ReactElement;
@@ -63,7 +63,7 @@ function LevelSheet({ index, at }) {
63
63
  at.shut(index); }, onOpenChangeComplete: (o) => { if (!o)
64
64
  at.gone(index); }, label: entry.label, form: entry.kind === "choices" ? "full" : at.form, container: at.container, standing: at.standing, children: [entry.kind === "choices" ? _jsx(LevelPicker, { entry: entry }) : _jsx(LevelActions, { entry: entry, index: index, at: at }), index + 1 < at.levels.length && _jsx(LevelSheet, { index: index + 1, at: at })] }));
65
65
  }
66
- function MenuSheet({ entries, label, trigger, anchor, open, defaultOpen, onOpenChange, defaultLevel, allRows, frame, words: said = NO_WORDS }) {
66
+ function MenuSheet({ entries, label, trigger, anchor, open, defaultOpen, onOpenChange, defaultLevel, allRows, frame, words: said = NO_WORDS, "data-slot": slot }) {
67
67
  const { ref, host } = usePickHost(), screen = React.useContext(PhoneHost), [mark, setMark] = React.useState(null);
68
68
  const first = () => { const l = levelOf(entries, defaultLevel); return l ? [{ entry: l, open: true }] : []; };
69
69
  const rows = useMenuListRows(mark), words = rows === "words", closeRow = useMenuListOption(mark, "close") === "shown" && !words;
@@ -78,7 +78,7 @@ function MenuSheet({ entries, label, trigger, anchor, open, defaultOpen, onOpenC
78
78
  const rowsList = _jsx(MenuList, { label: label, ...(words ? { entries: shutting } : tilesOf(shutting, allRows)), onOpen: at.openFrom(-1), onClose: closeRow ? () => set(false, "close-press") : undefined, closeWord: said.close });
79
79
  const list = frame ? _jsx("div", { ...frame, style: { display: "contents" }, children: rowsList }) : rowsList;
80
80
  return (_jsxs(_Fragment, { children: [_jsx("span", { ref: (el) => { ref.current = el; setMark(el); }, hidden: true, ...frame }), opener && React.cloneElement(opener, mergeProps({ "aria-haspopup": "dialog", "aria-expanded": shown, onClick: () => set(!shown, "trigger-press") }, opener.props)), _jsx(MenuWordsContext.Provider, { value: said, children: _jsxs(Sheet, { open: shown, onOpenChange: (o, d) => set(o, d.reason), onOpenChangeComplete: (o) => { if (!o)
81
- setLevels(first()); }, label: label, form: at.form, container: at.container, standing: at.standing, children: [_jsx(SheetBody, { children: list }), levels.length > 0 && _jsx(LevelSheet, { index: 0, at: at })] }, at.form) })] }));
81
+ setLevels(first()); }, label: label, form: at.form, container: at.container, standing: at.standing, "data-slot": slot, children: [_jsx(SheetBody, { children: list }), levels.length > 0 && _jsx(LevelSheet, { index: 0, at: at })] }, at.form) })] }));
82
82
  }
83
83
  export function Menu(props) {
84
84
  return useSheetMenus() && !props.popup ? _jsx(MenuSheet, { ...props }) : _jsx(MenuPopup, { ...props });
@@ -2,14 +2,15 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import * as React from "react";
3
3
  import { Dialog as BaseDialog } from "@base-ui/react/dialog";
4
4
  import { AlertDialog } from "../alert-dialog/alert-dialog.js";
5
- import { Button } from "../button/button.js";
5
+ import { PanelHeadButton } from "../internal/head-button.js";
6
6
  import { useKeptFocus } from "../internal/keep-focus.js";
7
+ import { usePanelControls } from "../internal/panel-controls.js";
7
8
  import { PhoneHost, usePhone } from "../internal/phone.js";
8
9
  import { OutOfFieldRows } from "../../internal/field-rows.js";
9
10
  import { usePopupHost } from "../internal/popup-host.js";
10
11
  import { Notice } from "../notice/notice.js";
11
12
  import { Scrollbar } from "../scrollbar/scrollbar.js";
12
- import { Sheet, SheetBody, SheetButton, SheetHead } from "../sheet/bottom-sheet.js";
13
+ import { Sheet, SheetBody, SheetHead } from "../sheet/bottom-sheet.js";
13
14
  const glyph = (paths) => _jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: paths.map((d) => _jsx("path", { d: d }, d)) });
14
15
  const X = ["M18 6l-12 12", "M6 6l12 12"], CHECK = ["M5 12l5 5l10 -10"], NEXT = ["M9 6l6 6l-6 6"];
15
16
  const EXPAND = ["M16 4l4 0l0 4", "M14 10l6 -6", "M8 20l-4 0l0 -4", "M4 20l6 -6"];
@@ -24,6 +25,7 @@ export const MODAL_WORDS = {
24
25
  };
25
26
  export function Modal({ open, onOpenChange, title, mark, path, onOpenAsPage, size = "md", foot = "both", action, cancel = "Cancel", footStart, dirty, state, failed, container, standing, children, words }) {
26
27
  const said = { ...MODAL_WORDS, ...words };
28
+ const { Button } = usePanelControls();
27
29
  const ref = React.useRef(null), host = usePopupHost(ref), body = React.useRef(null);
28
30
  const small = usePhone(), screen = React.useContext(PhoneHost), phone = small || !!screen;
29
31
  const [own, setOwn] = React.useState("rest"), [why, setWhy] = React.useState(null), [asking, setAsking] = React.useState(false);
@@ -60,7 +62,7 @@ export function Modal({ open, onOpenChange, title, mark, path, onOpenAsPage, siz
60
62
  onOpenChange(false); }, title: said.discardTitle, line: said.discardLine, action: said.discard, kind: "danger", cancel: said.keepEditing, container: where, standing: standing }));
61
63
  if (phone)
62
64
  return (_jsxs(_Fragment, { children: [_jsx("span", { ref: ref, hidden: true }), _jsxs(Sheet, { open: open, onOpenChange: (o) => { if (!o)
63
- leave(); }, label: title, form: "full", container: where, standing: standing, children: [_jsx(SheetHead, { title: title, left: _jsx(SheetButton, { "aria-label": cancel, icon: glyph(X), onClick: leave, disabled: saving }), right: foot !== "none" && action ? _jsx(SheetButton, { kind: "primary", "aria-label": action.label, icon: glyph(CHECK), onClick: act, disabled: saving || action.disabled }) : _jsx("span", {}) }), _jsxs(SheetBody, { children: [notice, children] }), guard] })] }));
65
+ leave(); }, label: title, form: "full", container: where, standing: standing, children: [_jsx(SheetHead, { title: title, left: _jsx(PanelHeadButton, { "aria-label": cancel, icon: glyph(X), onClick: leave, disabled: saving }), right: foot !== "none" && action ? _jsx(PanelHeadButton, { kind: "primary", "aria-label": action.label, icon: glyph(CHECK), onClick: act, disabled: saving || action.disabled }) : _jsx("span", {}) }), _jsxs(SheetBody, { children: [notice, children] }), guard] })] }));
64
66
  return (_jsxs(_Fragment, { children: [_jsx("span", { ref: ref, hidden: true }), _jsx(BaseDialog.Root, { open: open, onOpenChange: (o) => { if (!o)
65
67
  leave(); }, ...(standing ? { modal: false, disablePointerDismissal: true } : {}), children: _jsxs(BaseDialog.Portal, { container: where, children: [_jsx(BaseDialog.Backdrop, { className: "o-modal-backdrop", "data-over-popup": over }), _jsx(BaseDialog.Viewport, { className: "o-modal-viewport", "data-over-popup": over, children: _jsxs(BaseDialog.Popup, { ref: setPopup, className: "o-modal", "data-kit": "modal", "data-width": size, "aria-busy": saving || undefined, initialFocus: standing ? false : () => body.current?.querySelector("input:not([type=hidden]), textarea, [role='combobox'], .o-select-field") ?? true, children: [_jsxs("div", { className: "o-modal-cut o-smooth", children: [_jsxs("header", { className: "o-modal-head", children: [mark != null && _jsx("span", { className: "o-modal-mark", "aria-hidden": "true", children: mark }), path && _jsxs("span", { className: "o-modal-path", children: [_jsxs("span", { className: "o-modal-chip", children: [path.icon, _jsx("span", { className: "o-modal-chip-word", children: path.label })] }), glyph(NEXT)] }), _jsx(BaseDialog.Title, { className: "o-modal-title", children: title }), _jsxs("span", { className: "o-modal-tools", children: [onOpenAsPage && _jsx(Button, { kind: "quiet", shape: "icon", size: "xs", "aria-label": said.openAsPage, icon: glyph(EXPAND), onClick: onOpenAsPage }), _jsx(Button, { kind: "quiet", shape: "icon", size: "xs", "aria-label": said.close, icon: glyph(X), disabled: saving, onClick: leave })] })] }), _jsx("div", { ref: body, className: "o-modal-body", children: _jsxs(OutOfFieldRows, { children: [notice, children] }) }), _jsx(Scrollbar, { drawn: true }), foot !== "none" && (_jsxs("footer", { className: "o-modal-foot", children: [footStart != null && _jsx("span", { className: "o-modal-start", children: footStart }), _jsxs("span", { className: "o-modal-end", children: [foot === "both" && _jsx(Button, { className: "o-modal-cancel", disabled: saving, onClick: leave, children: cancel }), action && _jsx(Button, { kind: action.kind ?? "primary", loading: saving, disabled: action.disabled, onClick: act, children: action.label })] })] }))] }), guard] }) })] }) })] }));
66
68
  }