viewkitjs 0.36.0 → 0.37.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 (151) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/package.json +1 -1
  3. package/views/dist/atoms/types.d.ts +32 -4
  4. package/views/dist/contract.d.ts +14 -8
  5. package/views/dist/contract.js +14 -1
  6. package/views/dist/controls/button/own-look-moved.d.ts +11 -0
  7. package/views/dist/controls/button/own-look-moved.js +3 -0
  8. package/views/dist/controls/date-editor/date-behaviour.d.ts +80 -0
  9. package/views/dist/controls/date-editor/date-behaviour.js +187 -0
  10. package/views/dist/controls/date-editor/date-editor.d.ts +3 -2
  11. package/views/dist/controls/date-editor/date-editor.js +29 -166
  12. package/views/dist/controls/field/field.d.ts +3 -2
  13. package/views/dist/controls/field/field.js +7 -2
  14. package/views/dist/controls/field/looks.d.ts +1 -1
  15. package/views/dist/controls/field/looks.js +5 -4
  16. package/views/dist/controls/field.css +4 -0
  17. package/views/dist/controls/filter-editor/filter-editor.js +2 -2
  18. package/views/dist/controls/filter-editor/parts.d.ts +2 -0
  19. package/views/dist/controls/filter-editor/parts.js +1 -1
  20. package/views/dist/controls/index.d.ts +3 -1
  21. package/views/dist/controls/index.js +3 -1
  22. package/views/dist/controls/inline-input.css +9 -0
  23. package/views/dist/controls/internal/phone.d.ts +1 -1
  24. package/views/dist/controls/internal/phone.js +3 -2
  25. package/views/dist/controls/list/tokens.d.ts +1 -1
  26. package/views/dist/controls/list/tokens.js +1 -1
  27. package/views/dist/controls/list.css +5 -2
  28. package/views/dist/controls/menu-list/menu-list.js +3 -2
  29. package/views/dist/controls/menu.css +4 -4
  30. package/views/dist/controls/pane.css +1 -1
  31. package/views/dist/controls/picker.css +5 -3
  32. package/views/dist/controls/popover/looks.d.ts +1 -1
  33. package/views/dist/controls/popover/looks.js +5 -0
  34. package/views/dist/controls/popover/tokens.d.ts +13 -1
  35. package/views/dist/controls/popover/tokens.js +4 -1
  36. package/views/dist/controls/popover.css +59 -8
  37. package/views/dist/controls/select/select.js +1 -1
  38. package/views/dist/controls/sort-editor.css +4 -2
  39. package/views/dist/controls/text-editor.css +6 -0
  40. package/views/dist/controls/toolbar/toolbar.d.ts +4 -2
  41. package/views/dist/controls/toolbar/toolbar.js +7 -2
  42. package/views/dist/controls/toolbar-button/atom-toolbar-button.js +1 -1
  43. package/views/dist/controls/toolbar.css +5 -0
  44. package/views/dist/controls/tooltip/tokens.d.ts +1 -1
  45. package/views/dist/controls/tooltip/tokens.js +1 -1
  46. package/views/dist/controls/tooltip.css +5 -3
  47. package/views/dist/controls/values-editor.css +20 -5
  48. package/views/dist/display/entity-chip.d.ts +7 -1
  49. package/views/dist/display/entity-chip.js +2 -1
  50. package/views/dist/field-row/FieldRow.js +12 -8
  51. package/views/dist/grid/chrome/GridCellEditors.d.ts +4 -1
  52. package/views/dist/grid/chrome/GridCellEditors.js +3 -2
  53. package/views/dist/grid/chrome/GridCellOutline.d.ts +3 -5
  54. package/views/dist/grid/chrome/GridCellOutline.js +3 -5
  55. package/views/dist/grid/chrome/GridChipsEditor.js +1 -1
  56. package/views/dist/grid/chrome/GridDateEditor.d.ts +1 -1
  57. package/views/dist/grid/chrome/GridDateEditor.js +1 -1
  58. package/views/dist/grid/chrome/GridLongTextEditor.d.ts +1 -1
  59. package/views/dist/grid/chrome/GridLongTextEditor.js +8 -5
  60. package/views/dist/grid/chrome/GridNameEditor.d.ts +1 -1
  61. package/views/dist/grid/chrome/GridNameEditor.js +1 -1
  62. package/views/dist/grid/chrome/GridNumberEditor.d.ts +1 -1
  63. package/views/dist/grid/chrome/GridNumberEditor.js +2 -2
  64. package/views/dist/grid/chrome/GridPlaceEditor.d.ts +1 -1
  65. package/views/dist/grid/chrome/GridPlaceEditor.js +1 -1
  66. package/views/dist/grid/chrome/GridRangeEditor.d.ts +2 -2
  67. package/views/dist/grid/chrome/GridRangeEditor.js +1 -1
  68. package/views/dist/grid/chrome/GridRelationEditor.js +2 -2
  69. package/views/dist/grid/chrome/GridRowCells.js +6 -5
  70. package/views/dist/grid/chrome/GridSelectEditor.js +1 -1
  71. package/views/dist/grid/chrome/GridTable.d.ts +2 -1
  72. package/views/dist/grid/chrome/GridTable.js +7 -2
  73. package/views/dist/grid/chrome/GridTextEditor.d.ts +1 -1
  74. package/views/dist/grid/chrome/GridTextEditor.js +2 -2
  75. package/views/dist/grid/chrome/GridValueListEditor.d.ts +1 -1
  76. package/views/dist/grid/chrome/GridValueListEditor.js +1 -1
  77. package/views/dist/grid/chrome/grid-body-place.d.ts +7 -2
  78. package/views/dist/grid/chrome/grid-body-place.js +8 -4
  79. package/views/dist/grid/chrome/grid-cell-classes.js +2 -2
  80. package/views/dist/grid/chrome/grid-edit-session.d.ts +4 -0
  81. package/views/dist/grid/chrome/grid-edit-session.js +10 -1
  82. package/views/dist/grid/chrome/grid-editor-layer.d.ts +10 -0
  83. package/views/dist/grid/chrome/grid-editor-layer.js +1 -0
  84. package/views/dist/grid/chrome/grid-fitted-box.d.ts +4 -4
  85. package/views/dist/grid/chrome/grid-fitted-box.js +1 -3
  86. package/views/dist/grid/chrome/grid-hover.d.ts +3 -3
  87. package/views/dist/grid/chrome/grid-hover.js +2 -3
  88. package/views/dist/grid/chrome/grid-row-props.d.ts +6 -2
  89. package/views/dist/grid/chrome/grid-styles.d.ts +1 -5
  90. package/views/dist/grid/chrome/grid-styles.js +0 -1
  91. package/views/dist/grid/chrome/useGridKeyboard.d.ts +0 -1
  92. package/views/dist/grid/chrome/useGridKeyboard.js +2 -10
  93. package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +3 -1
  94. package/views/dist/grid/chrome/useGridTableInteractionModel.js +24 -1
  95. package/views/dist/grid/core/useGridEditing.d.ts +3 -0
  96. package/views/dist/grid/core/useGridEditing.js +2 -0
  97. package/views/dist/grid/grid.css +4 -19
  98. package/views/dist/internal/screen-forms.d.ts +11 -0
  99. package/views/dist/internal/screen-forms.js +31 -0
  100. package/views/dist/list/list.js +2 -1
  101. package/views/dist/list/parts.d.ts +8 -2
  102. package/views/dist/list/parts.js +31 -7
  103. package/views/dist/list/toolbar.js +7 -3
  104. package/views/dist/looks/index.d.ts +1 -0
  105. package/views/dist/looks/index.js +1 -0
  106. package/views/dist/panels/react/popover.d.ts +3 -1
  107. package/views/dist/panels/react/popover.js +2 -2
  108. package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +6 -3
  109. package/views/dist/panels/react/toolbar/Toolbar.d.ts +12 -1
  110. package/views/dist/panels/react/toolbar/Toolbar.js +5 -1
  111. package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +1 -1
  112. package/views/dist/panels/react/toolbar/ToolbarButton.js +3 -2
  113. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +1 -3
  114. package/views/dist/panels/react/toolbar/ToolbarOptions.js +1 -1
  115. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +1 -1
  116. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
  117. package/views/dist/panels/react/toolbar/ToolbarSave.d.ts +3 -1
  118. package/views/dist/panels/react/toolbar/ToolbarSave.js +28 -20
  119. package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
  120. package/views/dist/panels/react/toolbar/context.d.ts +3 -2
  121. package/views/dist/panels/react/views-row/FoldingViewRow.js +24 -7
  122. package/views/dist/panels/react/views-row/ViewPicker.js +1 -1
  123. package/views/dist/panels/react/views-row/more-views.d.ts +2 -0
  124. package/views/dist/panels/react/views-row/more-views.js +3 -0
  125. package/views/dist/panels/react.d.ts +1 -1
  126. package/views/dist/panels/toolbar/model.d.ts +2 -2
  127. package/views/dist/provider/components.d.ts +6 -6
  128. package/views/dist/provider/desktop.d.ts +2 -1
  129. package/views/dist/provider/desktop.js +5 -2
  130. package/views/dist/styles.css +181 -80
  131. package/views/dist/styles.unlayered.css +181 -80
  132. package/views/docs/contract.md +68 -20
  133. package/views/docs/controls/list.md +2 -0
  134. package/views/docs/controls/menu.md +2 -0
  135. package/views/docs/controls/picker.md +2 -0
  136. package/views/docs/controls/popover.md +7 -0
  137. package/views/docs/controls/tooltip.md +2 -0
  138. package/views/docs/guides/atoms.md +11 -10
  139. package/views/docs/guides/the-grid.md +7 -5
  140. package/views/docs/guides/the-provider.md +2 -2
  141. package/views/docs/reference/controls.md +11 -6
  142. package/views/docs/reference/display.md +1 -1
  143. package/views/docs/reference/field-row.md +1 -1
  144. package/views/docs/reference/list.md +5 -6
  145. package/views/docs/reference/looks.md +4 -1
  146. package/views/docs/reference/panels-react.md +5 -4
  147. package/views/docs/reference/panels.md +1 -1
  148. package/views/docs/reference/react.md +6 -6
  149. package/views/docs/reference/views.md +2 -2
  150. package/views/docs/reshaping.md +2 -2
  151. package/views/skills/views/SKILL.md +1 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,55 @@ Until 0.19.0 ViewKit shipped as three packages; their changes are in [fields/CHA
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.37.0] — 2026-12-04
9
+
10
+ ### Added
11
+
12
+ - `viewkitjs/views/controls`: `useDateEditorBehaviour`, the Date editor's behaviour with no drawing (`DateEditorBehaviour`, `DateEditorBehaviourProps`, `DateEditorRootProps`, `DateEditorLineProps`). Draw your own date body or editor, with no calendar or with your own, and spread its `root` and `line` props: its keys, its save on close, its refusals and, inside ViewKit's date editor, the undo stay ViewKit's, and its fixes reach your piece with each release. ViewKit's own Date editor is drawn on it.
13
+ - `viewkitjs/views/controls`: `dateEditorWordsOf(messages)`, the Date editor's words in your conventions' messages, as ViewKit's own date body takes them, so your own date body speaks the same words.
14
+ - `viewkitjs/views/panels/react`: `ReadyToolbar` and `ListToolbar` take `moreViews` (`ToolbarMoreViews`, and so does `List`'s `toolbar` in `viewkitjs/views/list`): the views row's "+N" as you draw it, your class on ViewKit's own, or your whole button, handed the props your `ToolbarButton` would get (`part: "views-more"`, the count as its `children`, `open`, `ref` and its presses), opening the same folded views. Handed nothing, "+N" is ViewKit's own, as before.
15
+ - `viewkitjs/views`: a popup's motion is yours to declare. Six optional variables set how every popup ViewKit draws on a computer opens and closes (the Popover, and so the Picker and every field editor and panel in one; the Menu's and the Select's list; the Tooltip): `--vk-popup-open-duration`, `--vk-popup-close-duration`, `--vk-popup-open-ease`, `--vk-popup-close-ease`, `--vk-popup-nudge` (how far it moves in from; `0px` only fades) and `--vk-popup-scale` (what it grows from, `0.95` for 95%). They join `VK_OPTIONAL_LAYOUT`. Undeclared, every popup moves as before. Declared on `:root` they reach your own popups too, where their transitions read them.
16
+ - `viewkitjs/views/looks`: the Popover's options gain How it comes (`motion`: fade · nudge · scale · none), How far (`distance`: small · medium · large), Opens in (`open`: 100 · 150 · 200 · 300 ms), Closes in (`close`: 75 · 100 · 150 · 200 ms) and Ease (`ease`: out · sharp · smooth · spring). Worn on a frame, they set the popup motion variables there, so every popup inside it moves the same; each default is today's motion.
17
+ - `viewkitjs/views/controls`: the Popover's stylesheet also reads `--vk-ease-out-sharp`, `--vk-ease-in-out` and `--vk-ease-spring`, for the Ease picks.
18
+ - `viewkitjs/views/looks`: the Field's looks gain a computer option, `row-icon` (`on`, `off`). Set `data-field-row-icon="off"` on a section, or on any ancestor (`lookAttrs(FIELD_LOOKS, { "row-icon": "off" })`), and each field row in it draws label, value and lane with no type icon on a computer, the label at the row's start. Editing, the lock, Empty and "—" work as before. Every look keeps it `on`, so a frame that sets nothing draws as before.
19
+ - `viewkitjs/views/looks`: a Button's own look, `ButtonOwnLook`, `buttonOwnOptions` and `buttonOwnAttrs`, beside the Input's, so a script, a server or a Node test reads it without React.
20
+ - `viewkitjs/views/panels/react`: the ready toolbar's Clear and Save are two places in `toolbarParts`, `clear` and `save`, so you place each on its own line, side and order, or leave one out: Save on the row while Clear stays on the filter bar, say. Handed back side by side, Clear first, on one line and side, they draw as one item, exactly as before.
21
+ - `viewkitjs/views/panels/react`: a place's `words` takes `"word"`, its word alone with no icon (`ToolbarPartPlace`, and `ToolbarPlacement` in `viewkitjs/views/panels`). It reaches every button of the part that has a word (the search, the quick filters, Sort, Filter, Customize, New): your `ToolbarButton` is handed `icon: null` and the word as its `children`, and the part never turns to its icon as its line narrows, folding into ⋯ instead. A + and New's round + at a phone list's foot keep their glyph.
22
+ - `viewkitjs/views/panels/react`: `ToolbarSave` takes `only` (`"clear"` or `"save"`): that one button alone, with no box around it.
23
+ - `viewkitjs/views`: an app sizes the toolbar's panels, the field editors' popovers and the menus on a computer by one variable per kind, each optional: `--vk-panel-w` and `--vk-panel-max-h` (Customize, Sort, Filter, the filter bar's panels, quick filters, a views list), `--vk-editor-w` and `--vk-editor-max-h` (a field editor's popover), `--vk-menu-w` and `--vk-menu-max-h` (a column's, a group's or a row's menu). Declared on `:root`, every place of the kind takes it; declared on one panel's slot (`[data-slot="vk-toolbar-sort-panel"]`), that panel alone. A declared width is the width, never past the room on screen. Undeclared, each stands as before. They size ViewKit's own Popover and Menu and the panels' width classes; your own Popover is sized as you size it.
24
+ - `viewkitjs/views`: `--vk-list-rows` sets how many rows a computer's list (the Picker's, the Select's) stands before it scrolls, 8½ undeclared. It replaces the unlisted `--list-rows`, which is still read: switch to the new name.
25
+
26
+ ### Changed
27
+
28
+ - `viewkitjs/views`: server-rendered, the ready `List` stands inside a `display: contents` box (`data-vk-screen-forms`) for the page's life, and so do a toolbar and a grid you place yourself; what stands inside the `List` keeps its shape (`vk-list` > its toolbar); while the page comes alive the two forms' boxes carry `data-vk-twin` (`computer`, `phone`) and `data-vk-twin-line`, with a small inline `<style>` beside them. A rule of yours that reaches the list, or a toolbar or a grid you place, as a direct child (`.page > [data-slot="vk-list"]`, `> [data-slot="vk-toolbar"]`) reaches it through that box now. A page whose content security policy refuses inline styles still picks at the default line, `(min-width: 1024px)`, from `toolbar.css` (in the ready stylesheet); at a line of your own it shows both forms until the page comes alive. The list's server HTML is sent twice over, about twice its raw size; compressed, a few kilobytes more (a list of 30 rows: 13 → 22 KB gzip, 7 → 8 KB brotli). A form you tell (`Toolbar`'s `phone`, `ToolbarControl`'s `form`, a `PhoneHost` or `ComputerHost`) and a list the browser draws first are drawn once, as before.
29
+ - `viewkitjs/views`: a field row says its form in `data-form`: `computer`, `phone` or `rows` (a Field rows card's row on a phone); outside a card its two forms share one class list, each form's layout reading that attribute.
30
+ - `viewkitjs/views`: server-rendered, Field rows' card and a field row outside one stand inside a `display: contents` box (`data-vk-screen-forms`) for the page's life, as a list does. A rule of yours that reaches them as a direct child (`.details > .o-field-rows`), or draws lines between rows by their siblings (Tailwind's `divide-y` round server-rendered field rows), reaches the box now; the row's own line under every row but the last sees through it. `field.css` carries the default line's rule too, for a page whose content security policy refuses inline styles.
31
+ - `viewkitjs/views/grid`: a cell draws nothing of its own while its editor is open: no ring, no lift and no tint (the picked cell's Wash stands down too), so under a popover it stays as it was. A picker cell's ▾ no longer turns up while its picker is open.
32
+ - `viewkitjs/views/grid`: a cell stops wearing `data-editing` the moment its editor starts to close (Escape, a pick, Enter or a click away), not once the popover's exit is over. A cell that stays selected (Escape, a pick) has its ring back while the popover fades; a click away leaves no ring. No shadowed cell shows through a closing popover any more.
33
+ - `viewkitjs/views/grid`: Enter after typing, in any editor, writes and keeps the cell selected, as Escape and a pick do; it no longer moves down a row. Tab still writes and moves on.
34
+ - `viewkitjs/views/grid`: a click away from an open editor closes it and lets the cell go; before, the cell stayed selected. A pick your app holds (`cellPick`) stays.
35
+ - `viewkitjs/views/grid`: a cell typed in is the cell itself: ViewKit's Text and Number bodies stand in it with no edge, no ring, no ground and no lift, only the caret. A text grows from the cell as the text editor's "In the cell" look grows it, whatever the page's look, and where it runs past the cell it lies on the plain ground (`--vk-overlay`) so the values beside it don't show through. "Over the cell" still applies in a record's rows.
36
+ - `--vk-editing-shadow` is drawn by nothing now: an open editor lifts nothing. It stays in `VK_OPTIONAL_COLOURS`, so an app that declares it still typechecks.
37
+ - `viewkitjs/views`: a toolbar panel's popover (Customize, Sort, Filter) takes how long it opens and closes from the popup motion variables first, then `--vk-duration`, then 150ms as before; an app that declares neither sees no change.
38
+ - `viewkitjs/views/grid`: a grid editor that opens over its cell (the Picker, the Date, Parts, Values and Links bodies, a long text's panel) hands your `Popover` a `sideOffset` of minus the cell's height and one spacing step, and an `alignOffset` of minus one step: the panel stands a step above and a step left of the cell, covering the cell and its lines instead of lying on them and doubling them. A flipped panel stands a step below the cell's bottom. ViewKit's own Popover there is at least the cell's width and two steps, so it covers the cell's far line too; give yours the same.
39
+ - `viewkitjs/views/controls`: `ButtonOwnLook`, `buttonOwnOptions` and `buttonOwnAttrs` are deprecated here, read them from `viewkitjs/views/looks`; this door's copy is removed in a later breaking release. They are the same values, so an app that reads them from `/controls` still compiles and works.
40
+ - `viewkitjs/views/panels/react`: in `toolbarParts`, the key `save` now names Save alone, and Clear is `clear`. A function that moved `save` to move both moves Save alone now: move `clear` beside it.
41
+ - `viewkitjs/views/react`: the `RowContent`, `ChoiceRow` and `ToggleRow` atoms are deprecated, read by nothing, removed in a later breaking release. Nothing in ViewKit draws them, so handing one changes nothing on screen; an app that hands them still compiles and needn't change anything now. `ViewsChoiceRowProps` and `ViewsToggleRowProps` are deprecated with them.
42
+ - `viewkitjs/views/react`: the `Row` atom's `opens` and `open` are deprecated, read by nothing, removed in a later breaking release. ViewKit draws no flyout beside a menu any more, so nothing hands them; the default `Row` still reads them for a caller of your own.
43
+ - `viewkitjs/views/react`: the `CheckRow`, `RadioRow`, `DirectionButton`, `MenuRow` and `PanelSearch` atoms say where they are drawn: only inside ViewKit's own filter and sort bodies, the older panels a list keeps with `severalSorts: false` or `filterGroups: false`, and the value body a filter rule falls back to where your `FilterPartBody` or `FilterBody` doesn't draw its type. The atoms guide no longer calls them the rows the panels draw with.
44
+ - `viewkitjs/views/react`: the deprecated `Command` slot of the components map now goes in a later breaking release, not at a later minor.
45
+ - `viewkitjs/views/react`: `ViewsMenuItem.beside` says what a row that opens beside its menu opens on: a hover or →.
46
+
47
+ ### Fixed
48
+
49
+ - `viewkitjs/views`: a server-rendered list on a phone no longer paints the computer's toolbar and grid first and turns into the phone's once the page comes alive. The server draws the ready `List`, and a toolbar (the ready toolbar, `Toolbar`, `ToolbarControl`) or a grid (`GridTable`) you place yourself, in both forms, and CSS shows the one your `desktopQuery` picks; as the page comes alive the screen's form is the one kept, the very elements the person saw, and the other is dropped without ever running. So a tap on Sort just after the page appears opens Sort, never Search or nothing.
50
+ - `viewkitjs/views/panels/react`: the ready toolbar's Filter editor (the row's Filter, with filters standing) and an advanced filter's editor now hang in your `Popover` with `chrome="menu"`, as Sort's editor and every other toolbar panel do, so an app whose card and menu panel differ draws them on one surface. ViewKit's own look is unchanged.
51
+ - `viewkitjs/views/display`: a relation's and an actor's chip holds its mark in one slot the photo's size (16px), whatever stands in it: the photo, your `Avatar` atom's own mark, a host's icon, or ViewKit's 12px glyph, now centred in that slot. So in a column of chips, a person with a photo above an import or the system with a glyph, every name starts at the same place, in a table's cell, a field row and `renderFieldValue`; before, a glyph's name stood 4px further left than a photo's. A photo draws as before, and a chip stands no taller. The mark is now wrapped in a `<span>` before the name, so a stylesheet that reached the picture as the chip's direct child (`> img`) reaches it one level down.
52
+ - `viewkitjs/views`: a server-rendered record's field rows on a phone no longer paint the computer's form first (glyph, label and value on one line, or a Field rows card's computer rows) and turn into the phone's once the page comes alive. The server draws Field rows' card (`FieldRows`) whole in both forms, and a `FieldRow` outside a card in both forms, and CSS shows the one your `desktopQuery` picks; as the page comes alive the screen's form is the one kept, the very elements the person saw. A card inside a `PhoneHost` or a `ComputerHost`, and rows the browser draws first, are drawn once, as before.
53
+ - `viewkitjs/views/controls`: the filter editor's own number box on a whole-number column (the one the toolbar's Filter draws for a rule) now holds what is typed to a whole number once the box is left, as the filter part's box already did: 5.4 typed into a "less than" rule on such a column filters by 5, not 5.4.
54
+ - `viewkitjs/views/controls`: on a phone, a tick row whose mark is refused (a card's first field, a hidden field) says why under its name, as a refused tick does. A touch screen never shows the mark's tooltip. A row's own refusal still comes first.
55
+ - `viewkitjs/views/controls`: on a phone, the values sheet draws each value over its label, so a phone number takes the whole line between its grip and its call and delete buttons and reads whole at 375 wide. A value with no label stands alone in its row, as before. A computer's values editor is unchanged.
56
+
8
57
  ## [0.36.0] — 2026-12-04
9
58
 
10
59
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viewkitjs",
3
- "version": "0.36.0",
3
+ "version": "0.37.0",
4
4
  "description": "ViewKit — typed fields, the grid and its editors, and a list's SQL for record lists, in one package: viewkitjs/fields, viewkitjs/views and viewkitjs/postgres. By Sheaf.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -42,9 +42,12 @@ export type ViewsRowProps = ViewsRowContentProps & {
42
42
  disabled?: boolean;
43
43
  /** Default true. False draws a line that is read, not pressed. */
44
44
  interactive?: boolean;
45
- /** The row opens a flyout beside its menu, a dialog: `aria-haspopup="dialog"`, and `aria-expanded` from `open`. */
45
+ /** The row opens a flyout beside its menu, a dialog: `aria-haspopup="dialog"`, and `aria-expanded` from `open`.
46
+ * @deprecated Handed by nothing in ViewKit since its grid's flyouts went (VK-872); the default still reads it for an app's
47
+ * own caller. It goes in a later release that breaks something anyway. */
46
48
  opens?: boolean;
47
- /** The flyout this row opens is up now: `aria-expanded`, `data-open` and the pressed ground. */
49
+ /** The flyout this row opens is up now: `aria-expanded`, `data-open` and the pressed ground.
50
+ * @deprecated Handed by nothing in ViewKit, with `opens`; it goes in a later release that breaks something anyway. */
48
51
  open?: boolean;
49
52
  title?: string;
50
53
  /** A role for a row that is not a plain button (an option, a tab); `aria-selected` rides only with one. */
@@ -279,7 +282,9 @@ export type ViewsRowMenuProps = {
279
282
  * calls it; an atom of yours that doesn't leaves the row to the real pointer, as before. */
280
283
  onOpenChange?: (open: boolean) => void;
281
284
  };
282
- /** Picks one value: its label, a second line, a right-hand `meta` (a sample, a count), the check when chosen. */
285
+ /** Picks one value: its label, a second line, a right-hand `meta` (a sample, a count), the check when chosen.
286
+ * @deprecated The `ChoiceRow` atom's props; ViewKit draws no `ChoiceRow`. It goes in a later release that breaks something
287
+ * anyway. */
283
288
  export type ViewsChoiceRowProps = {
284
289
  selected?: boolean;
285
290
  label: ReactNode;
@@ -344,7 +349,9 @@ export type ViewsMenuRowProps = {
344
349
  onClick: () => void;
345
350
  };
346
351
  /** A boolean that flips in place, a painted switch where the chevron would be; `reset` draws the way back to
347
- * the reader's default on the row. */
352
+ * the reader's default on the row.
353
+ * @deprecated The `ToggleRow` atom's props; ViewKit draws no `ToggleRow`. It goes in a later release that breaks something
354
+ * anyway. */
348
355
  export type ViewsToggleRowProps = {
349
356
  icon?: ReactNode;
350
357
  label: string;
@@ -516,6 +523,8 @@ export type ViewsToolbarButtonPart = ViewsFramePart | "options" | "search" | "qu
516
523
  export type ViewsAtoms = {
517
524
  List: ComponentType<ViewsListProps>;
518
525
  Row: ComponentType<ViewsRowProps>;
526
+ /** @deprecated Drawn by nothing: the default `Row` draws its own inside. Handed, it changes nothing; it goes in a later
527
+ * release that breaks something anyway. */
519
528
  RowContent: ComponentType<ViewsRowContentProps>;
520
529
  TickBox: ComponentType<ViewsTickBoxProps>;
521
530
  Avatar: ComponentType<ViewsAvatarProps>;
@@ -531,12 +540,31 @@ export type ViewsAtoms = {
531
540
  LoadMore: ComponentType<ViewsLoadMoreProps>;
532
541
  PlatformMark: ComponentType<ViewsPlatformMarkProps>;
533
542
  RowMenu: ComponentType<ViewsRowMenuProps>;
543
+ /** @deprecated Drawn by nothing: Customize's and the editors' rows come to your bodies as data. Handed, it changes
544
+ * nothing; it goes in a later release that breaks something anyway. */
534
545
  ChoiceRow: ComponentType<ViewsChoiceRowProps>;
546
+ /** A tick row, drawn only inside ViewKit's own filter and sort bodies: the older panels (`severalSorts: false`,
547
+ * `filterGroups: false`) and the value body a filter rule falls back to where your `FilterPartBody` or `FilterBody`
548
+ * doesn't draw its type. */
535
549
  CheckRow: ComponentType<ViewsCheckRowProps>;
550
+ /** A one-of-a-set row, drawn only inside ViewKit's own filter and sort bodies: the older panels (`severalSorts: false`,
551
+ * `filterGroups: false`) and the value body a filter rule falls back to where your `FilterPartBody` or `FilterBody`
552
+ * doesn't draw its type. */
536
553
  RadioRow: ComponentType<ViewsRadioRowProps>;
554
+ /** A sort's direction arrow, drawn only inside ViewKit's own filter and sort bodies: the older panels (`severalSorts: false`,
555
+ * `filterGroups: false`) and the value body a filter rule falls back to where your `FilterPartBody` or `FilterBody`
556
+ * doesn't draw its type. */
537
557
  DirectionButton: ComponentType<ViewsDirectionButtonProps>;
558
+ /** A drill-in row, drawn only inside ViewKit's own filter and sort bodies: the older panels (`severalSorts: false`,
559
+ * `filterGroups: false`) and the value body a filter rule falls back to where your `FilterPartBody` or `FilterBody`
560
+ * doesn't draw its type. */
538
561
  MenuRow: ComponentType<ViewsMenuRowProps>;
562
+ /** @deprecated Drawn by nothing: Customize's and the editors' rows come to your bodies as data. Handed, it changes
563
+ * nothing; it goes in a later release that breaks something anyway. */
539
564
  ToggleRow: ComponentType<ViewsToggleRowProps>;
565
+ /** A panel's text box, drawn only inside ViewKit's own filter and sort bodies: the older panels (`severalSorts: false`,
566
+ * `filterGroups: false`) and the value body a filter rule falls back to where your `FilterPartBody` or `FilterBody`
567
+ * doesn't draw its type. */
540
568
  PanelSearch: ComponentType<ViewsPanelSearchProps>;
541
569
  SelectionSheet: ComponentType<ViewsSelectionSheetProps>;
542
570
  Pill: ComponentType<ViewsPillProps>;
@@ -34,10 +34,10 @@ export type VkColour = (typeof VK_COLOURS)[number];
34
34
  * `--vk-pressed` (the active view's pill and the picker's chip); undeclared, `--vk-neutral`.
35
35
  * `--vk-outline-hover` is the line of the cell under the pointer (undeclared, `--vk-border-bold`), `--vk-outline`
36
36
  * the picked cell's ring at rest (undeclared, `--vk-fg-subtle`) and `--vk-outline-active` that ring under the
37
- * pointer or while editing (undeclared, `--vk-border-brand`). `--vk-selection-edge` is a picked row's lines
37
+ * pointer (undeclared, `--vk-border-brand`). `--vk-selection-edge` is a picked row's lines
38
38
  * (undeclared, `--vk-brand`). `--vk-frozen-shadow` is the colour the pinned edge's shadow fades from (undeclared,
39
- * black at 15%, 60% in the dark). `--vk-editing-shadow` is the open editor's lift, a whole `box-shadow` value
40
- * (undeclared, Tailwind's `shadow-lg` in black at 20%, 50% in the dark).
39
+ * black at 15%, 60% in the dark). `--vk-editing-shadow`, once the open editor's lift, is drawn
40
+ * by nothing since 0.37.0 (an open editor lifts nothing); it stays listed so an app that declares it still typechecks.
41
41
  * The field row's line, `--vk-field-row-line` (undeclared, `--vk-border`), and its label's colour,
42
42
  * `--vk-field-row-label-fg` (undeclared, `--vk-fg-subtle`), are the app's to set round a record's rows (VK-953).
43
43
  * The status washes (`--vk-success-subtlest`, `--vk-warning-subtlest`, `--vk-info-subtlest`), the words on a
@@ -71,8 +71,12 @@ export type VkOptionalColour = (typeof VK_OPTIONAL_COLOURS)[number];
71
71
  * (VK-953): `--vk-field-row-label-w` its label column on a desktop (undeclared `calc(var(--spacing)*32)`, what `w-32` drew), `--vk-field-row-gap` the gap
72
72
  * between its glyph, label, value and lane (`calc(var(--spacing)*3)`), `--vk-field-row-h` its least height, its content standing in
73
73
  * the middle (`auto`), `--vk-field-row-py` its padding above and below (`calc(var(--spacing)*2.5)`) and `--vk-field-row-line-w` the
74
- * line under every row but the last (`1px`; `0px` draws none). */
75
- export declare const VK_OPTIONAL_LAYOUT: readonly ["--vk-field-row-label-w", "--vk-field-row-gap", "--vk-field-row-h", "--vk-field-row-py", "--vk-field-row-line-w", "--vk-toolbar-foot", "--vk-toolbar-line-py", "--vk-toolbar-line-gap", "--vk-toolbar-line-w", "--vk-gutter", "--vk-scroll-inset-bottom", "--vk-panel-padding", "--vk-scroll-row-inset", "--vk-scroll-row-end", "--vk-outline-radius", "--vk-group-gap", "--vk-duration", "--vk-caption-text", "--vk-caption-leading", "--vk-caps-tracking", "--vk-input-text", "--vk-panel-title-text", "--vk-sheet-text", "--vk-underline-offset", "--vk-underline-width", "--vk-thick-line", "--vk-selected-stroke", "--vk-frozen-shadow-width"];
74
+ * line under every row but the last (`1px`; `0px` draws none). A panel's, an editor's and a menu's size on a computer (VK-992):
75
+ * `--vk-panel-w` and `--vk-panel-max-h` a toolbar panel's, `--vk-editor-w` and `--vk-editor-max-h` a field editor's popover's,
76
+ * `--vk-menu-w` and `--vk-menu-max-h` a menu's, each place keeping its own undeclared; `--vk-list-rows` how many rows a
77
+ * computer's list stands before it scrolls (undeclared `8.5`, or `--list-rows`, its old name). ViewKit's own controls read
78
+ * these as well as their control tokens. */
79
+ export declare const VK_OPTIONAL_LAYOUT: readonly ["--vk-field-row-label-w", "--vk-field-row-gap", "--vk-field-row-h", "--vk-field-row-py", "--vk-field-row-line-w", "--vk-toolbar-foot", "--vk-toolbar-line-py", "--vk-toolbar-line-gap", "--vk-toolbar-line-w", "--vk-gutter", "--vk-scroll-inset-bottom", "--vk-panel-padding", "--vk-scroll-row-inset", "--vk-scroll-row-end", "--vk-outline-radius", "--vk-group-gap", "--vk-duration", "--vk-caption-text", "--vk-caption-leading", "--vk-caps-tracking", "--vk-input-text", "--vk-panel-title-text", "--vk-sheet-text", "--vk-underline-offset", "--vk-underline-width", "--vk-thick-line", "--vk-selected-stroke", "--vk-frozen-shadow-width", "--vk-panel-w", "--vk-panel-max-h", "--vk-editor-w", "--vk-editor-max-h", "--vk-menu-w", "--vk-menu-max-h", "--vk-list-rows", "--vk-popup-open-duration", "--vk-popup-close-duration", "--vk-popup-open-ease", "--vk-popup-close-ease", "--vk-popup-nudge", "--vk-popup-scale"];
76
80
  export type VkOptionalLayout = (typeof VK_OPTIONAL_LAYOUT)[number];
77
81
  /** The grid's own machinery, set and read by the grid alone: prefixed because they share the
78
82
  * global namespace, and not public. An app neither sets nor reads them, and they may change in
@@ -88,8 +92,10 @@ export type VkInternal = (typeof VK_INTERNAL)[number];
88
92
  export declare const VK_INTERNAL_FAMILIES: readonly ["--vk-col-w-"];
89
93
  /** The display's own marks, set and read by ViewKit alone: not public, like the grid's own variables. An app neither
90
94
  * sets, reads nor styles them, and they may change in any release. A cell fitting its values (`severalValues: "fit"`)
91
- * marks its box `vk-fit` and each value's box `vk-fit-value`, which its measure reads. */
92
- export declare const VK_INTERNAL_MARKS: readonly ["vk-fit", "vk-fit-value"];
95
+ * marks its box `vk-fit` and each value's box `vk-fit-value`, which its measure reads. Server-rendered, the box a list, a
96
+ * toolbar or a grid stands in is `vk-screen-forms`, and while the page comes alive each of its two forms' boxes `vk-twin`
97
+ * (`computer`, `phone`) with the line that shows it, `vk-twin-line`, which ViewKit's own rules read. */
98
+ export declare const VK_INTERNAL_MARKS: readonly ["vk-fit", "vk-fit-value", "vk-screen-forms", "vk-twin", "vk-twin-line"];
93
99
  export type VkInternalMark = (typeof VK_INTERNAL_MARKS)[number];
94
100
  /** THE CONTROLS' TOKENS: every name ViewKit's default controls (`viewkitjs/views/controls`) read, each with its kind and the
95
101
  * Outright token it stands for, gathered from each control's own list (`controls/<piece>/tokens.ts`). All optional: the
@@ -115,7 +121,7 @@ export type ComponentName = (typeof COMPONENT_NAMES)[number];
115
121
  * its view's `menu` rows; without `Pane`, a toolbar's `customizeIn: "pane"` opens Customize in the `Popover`. */
116
122
  export declare const OPTIONAL_COMPONENT_NAMES: readonly ["Input", "Select", "Command", "Calendar", "RowsWait", "GroupBody", "SearchField", "PortsHost", "SelectionBar", "ViewMenu", "Pane"];
117
123
  export type OptionalComponentName = (typeof OPTIONAL_COMPONENT_NAMES)[number];
118
- /** The pieces the rendering is built from, and the app's own pieces it cannot draw itself (a command cell's verb menu, the row's right-click menu, where a relation goes, a wait, how a list asks for more), and the rows the panels draw with. Each ships as a default; an app swaps any of them through the provider's `atoms`. */
124
+ /** The pieces the rendering is built from, and the app's own pieces it cannot draw itself (a command cell's verb menu, the row's right-click menu, where a relation goes, a wait, how a list asks for more), and the rows ViewKit's own filter and sort bodies draw with. Each ships as a default; an app swaps any of them through the provider's `atoms`. `RowContent`, `ChoiceRow` and `ToggleRow` are deprecated: nothing draws them, and they go in a later release that breaks something anyway. */
119
125
  export declare const ATOM_NAMES: readonly ["Row", "RowContent", "TickBox", "StatusBadge", "StatusMarker", "Tag", "List", "CommandMenu", "RelationLink", "RelationRoles", "RelationChip", "CellMore", "Loading", "LoadMore", "PlatformMark", "RowMenu", "SelectionSheet", "ChoiceRow", "CheckRow", "RadioRow", "DirectionButton", "MenuRow", "ToggleRow", "PanelSearch", "Pill", "RangeCalendar", "ToolbarButton", "Avatar"];
120
126
  export type AtomName = (typeof ATOM_NAMES)[number];
121
127
  /** The parts inside the default panels, by panel (VK-988): each its public `data-slot`, prefixed with the panel's own short name.
@@ -196,6 +196,19 @@ export const VK_OPTIONAL_LAYOUT = [
196
196
  "--vk-thick-line",
197
197
  "--vk-selected-stroke",
198
198
  "--vk-frozen-shadow-width",
199
+ "--vk-panel-w",
200
+ "--vk-panel-max-h",
201
+ "--vk-editor-w",
202
+ "--vk-editor-max-h",
203
+ "--vk-menu-w",
204
+ "--vk-menu-max-h",
205
+ "--vk-list-rows",
206
+ "--vk-popup-open-duration",
207
+ "--vk-popup-close-duration",
208
+ "--vk-popup-open-ease",
209
+ "--vk-popup-close-ease",
210
+ "--vk-popup-nudge",
211
+ "--vk-popup-scale",
199
212
  ];
200
213
  export const VK_INTERNAL = [
201
214
  "--vk-drag-shift",
@@ -205,7 +218,7 @@ export const VK_INTERNAL = [
205
218
  "--vk-foot-at",
206
219
  ];
207
220
  export const VK_INTERNAL_FAMILIES = ["--vk-col-w-"];
208
- export const VK_INTERNAL_MARKS = ["vk-fit", "vk-fit-value"];
221
+ export const VK_INTERNAL_MARKS = ["vk-fit", "vk-fit-value", "vk-screen-forms", "vk-twin", "vk-twin-line"];
209
222
  export { VK_CONTROL_PRIVATE_FAMILIES, VK_CONTROL_TOKENS, VK_CONTROL_TOKENS_BY_PIECE } from "./controls/tokens.js";
210
223
  export { GRID_TOKENS as VK_GRID_TOKENS } from "./grid-tokens.js";
211
224
  export const COMPONENT_NAMES = [
@@ -0,0 +1,11 @@
1
+ import { buttonOwnAttrs as ownAttrs, type ButtonOwnLook as OwnLook } from "./own-look.js";
2
+ /** @deprecated Read it from `viewkitjs/views/looks`; this door's copy goes in a later release that breaks something anyway. */
3
+ export declare const buttonOwnAttrs: typeof ownAttrs;
4
+ /** @deprecated Read it from `viewkitjs/views/looks`; this door's copy goes in a later release that breaks something anyway. */
5
+ export declare const buttonOwnOptions: {
6
+ id: keyof OwnLook;
7
+ attr: string;
8
+ values: string[];
9
+ }[];
10
+ /** @deprecated Read it from `viewkitjs/views/looks`; this door's copy goes in a later release that breaks something anyway. */
11
+ export type ButtonOwnLook = OwnLook;
@@ -0,0 +1,3 @@
1
+ import { buttonOwnAttrs as ownAttrs, buttonOwnOptions as ownOptions, } from "./own-look.js";
2
+ export const buttonOwnAttrs = ownAttrs;
3
+ export const buttonOwnOptions = ownOptions;
@@ -0,0 +1,80 @@
1
+ import * as React from "react";
2
+ import { type DateNames, type DatePick } from "./calendar.js";
3
+ import type { DateEditorProps } from "./date-editor.js";
4
+ import { type DateEditorWords } from "./words.js";
5
+ /** What the behaviour is handed: the Date editor's props that say how it behaves, and how its line reads. */
6
+ export type DateEditorBehaviourProps = Pick<DateEditorProps, "value" | "onValueChange" | "onDone" | "time" | "empty" | "days" | "picks" | "today" | "typed" | "autoFocus" | "form" | "draft" | "words" | "language"> & {
7
+ /** The line: `box` stands empty at rest, nothing typed in it nothing at all (the default; Attio's, and every phone's);
8
+ * `written` writes the day held out, the first key typed or a delete starting over in its place (Mihai's line). */
9
+ line?: "box" | "written";
10
+ };
11
+ /** The element that holds it: a press elsewhere keeps (own draft, computer), Escape keeps and closes (own draft,
12
+ * computer), and on a phone, taken off the page and back, it starts over on what it is handed then. */
13
+ export interface DateEditorRootProps {
14
+ ref: (el: HTMLElement | null) => void;
15
+ onBlur?: React.FocusEventHandler<HTMLElement>;
16
+ onFocus?: React.FocusEventHandler<HTMLElement>;
17
+ onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
18
+ }
19
+ /** The line a date is typed into: its text, its refusal, its keys (Enter keeps and closes; on a written line the first
20
+ * key starts over), and on a computer the focus as it opens, the caret after a seed. */
21
+ export interface DateEditorLineProps {
22
+ ref: (el: HTMLInputElement | null) => void;
23
+ value: string;
24
+ "aria-invalid"?: true;
25
+ onChange: React.ChangeEventHandler<HTMLInputElement>;
26
+ onKeyDown: React.KeyboardEventHandler<HTMLInputElement>;
27
+ onBeforeInput?: React.FormEventHandler<HTMLInputElement>;
28
+ }
29
+ export interface DateEditorBehaviour {
30
+ /** It behaves as a phone's: a day pressed never closes, and ✓ and ✕ are the closes. */
31
+ phone: boolean;
32
+ today: string;
33
+ /** What it holds: the day ("2026-11-12") and the time ("14:30"), each or null. */
34
+ date: string | null;
35
+ clock: string | null;
36
+ /** What is typed in the line, null when nothing is. */
37
+ typed: string | null;
38
+ /** The day the line reads as, while it reads as one. */
39
+ reads: string | null;
40
+ /** Why the line is refused, in its words, or null. */
41
+ error: string | null;
42
+ /** The day the keys stand on, the month shown being its month: the day the line reads while it reads. */
43
+ keyDay: string;
44
+ /** Its quick picks in order, each with its day from today (null for No date) and its word. */
45
+ picks: {
46
+ key: DatePick;
47
+ day: string | null;
48
+ word: string;
49
+ }[];
50
+ /** Its words, the English under those handed, and its month and weekday names. */
51
+ words: DateEditorWords;
52
+ names: DateNames;
53
+ /** A day the field can't take (`days`). */
54
+ off: (day: string) => boolean;
55
+ /** A day or a quick pick pressed (null: No date): on a computer a date keeps and closes, a date and time stays open;
56
+ * No date closes; on a phone nothing closes. */
57
+ pick: (day: string | null) => void;
58
+ /** Enter on a day: as `pick`, then on a phone or a date and time it keeps that day and closes. */
59
+ enterDay: (day: string) => void;
60
+ /** The keys' day moved (an arrow, a month or a year shown); nothing is picked. */
61
+ moveKey: (day: string) => void;
62
+ /** The month shown moved by n months. */
63
+ moveMonth: (n: number) => void;
64
+ /** The line's text set (null: nothing typed); a refusal shown clears; held, it is handed once it reads. */
65
+ type: (text: string | null) => void;
66
+ /** A day set in parts: held and handed, nothing closes. */
67
+ setDay: (day: string) => void;
68
+ /** The time set (null: none); handed with the day the line means. */
69
+ setTime: (time: string | null) => void;
70
+ /** ✓ or Enter: what is typed taken first, then kept and closed; a line that isn't a date stays open, refused. */
71
+ keep: () => void;
72
+ /** ✕: nothing kept, it starts over on what it was handed, and closes. */
73
+ leave: () => void;
74
+ root: DateEditorRootProps;
75
+ line: DateEditorLineProps;
76
+ }
77
+ /** The Date editor's behaviour, with no drawing: what an app's own date body or editor is drawn on. */
78
+ export declare function useDateEditorBehaviour(props: DateEditorBehaviourProps): DateEditorBehaviour;
79
+ /** The behaviour, and for ViewKit's own drawing what it puts back as it starts over (its views and wheels). */
80
+ export declare function useDateBehaviour(props: DateEditorBehaviourProps, startOver?: () => void): DateEditorBehaviour;
@@ -0,0 +1,187 @@
1
+ "use client";
2
+ import * as React from "react";
3
+ import { PhoneHost, usePhone } from "../internal/phone.js";
4
+ import { addMonths, dateNames, lineDay, lineText, quickPick, readDate, todayOf } from "./calendar.js";
5
+ import { dateWords } from "./words.js";
6
+ const PICK_WORD = { today: "today", tomorrow: "tomorrow", "next-week": "nextWeek", "in-a-week": "inAWeek", "next-monday": "nextMonday", none: "none" };
7
+ export function useDateEditorBehaviour(props) {
8
+ return useDateBehaviour(props);
9
+ }
10
+ export function useDateBehaviour(props, startOver) {
11
+ const { value, onValueChange, onDone, time = false, empty = false, days = "any", autoFocus = true } = props;
12
+ const w = dateWords(props.words), names = dateNames(props.language);
13
+ const host = React.useContext(PhoneHost), small = usePhone(), phone = (props.form ?? (host || small ? "phone" : "computer")) === "phone";
14
+ const phoneNow = React.useRef(phone);
15
+ React.useLayoutEffect(() => { phoneNow.current = phone; }, [phone]);
16
+ const today = props.today ?? todayOf();
17
+ const picks = props.picks ?? ["today", "tomorrow", "next-week", ...(empty ? ["none"] : [])];
18
+ const [date, setDate] = React.useState(value ? value.slice(0, 10) : null);
19
+ const [clock, setClock] = React.useState(value && value.length > 10 ? value.slice(11, 16) : null);
20
+ const [key, setKey] = React.useState(date ?? today);
21
+ const [typed, setTyped] = React.useState(props.typed ?? null);
22
+ const [error, setError] = React.useState(() => { const r = props.typed != null && props.typed.length > 1 ? readDate(props.typed, today, names, w) : null; return r && "error" in r ? r.error : null; });
23
+ const settled = React.useRef(false), line = React.useRef(null);
24
+ const off = (day) => (days === "from-today" && day < today) || (days === "until-today" && day > today);
25
+ const reading = typed != null ? readDate(typed, today, names, w) : null;
26
+ const written = props.line === "written";
27
+ const blank = (t) => t == null || (!written && !t.trim());
28
+ const clears = empty && written;
29
+ const valueOf = (d, t) => (d ? (time && t ? `${d}T${t}` : d) : null);
30
+ const shell = props.draft === "shell";
31
+ const handed = React.useRef(value);
32
+ const hand = (d, t) => {
33
+ if (!shell)
34
+ return;
35
+ const next = valueOf(d, t);
36
+ if (next === handed.current)
37
+ return;
38
+ handed.current = next;
39
+ onValueChange(next);
40
+ };
41
+ const dayOfLine = () => lineDay(typed, date, today, clears, names);
42
+ const handTyped = (text) => { if (shell)
43
+ hand(lineDay(text, date, today, clears, names), clock); };
44
+ const setTime = (t) => { setClock(t); hand(dayOfLine(), t); };
45
+ const settle = (d = date, t = clock) => {
46
+ settled.current = true;
47
+ if (shell) {
48
+ hand(d, t);
49
+ onDone?.();
50
+ return;
51
+ }
52
+ const next = valueOf(d, t);
53
+ if (next !== value)
54
+ onValueChange(next);
55
+ onDone?.();
56
+ };
57
+ const leave = () => { settled.current = true; reset(); onDone?.(); };
58
+ function reset() { const v = value; setDate(v ? v.slice(0, 10) : null); setClock(v && v.length > 10 ? v.slice(11, 16) : null); setKey(v ? v.slice(0, 10) : today); setTyped(null); setError(null); startOver?.(); }
59
+ const [placed, setPlaced] = React.useState(null), left = React.useRef(false);
60
+ const rootRef = React.useCallback((el) => {
61
+ if (!phoneNow.current)
62
+ return;
63
+ setPlaced(el);
64
+ if (!el) {
65
+ left.current = true;
66
+ settled.current = false;
67
+ }
68
+ }, []);
69
+ React.useLayoutEffect(() => {
70
+ if (!placed || !left.current || !phone)
71
+ return;
72
+ left.current = false;
73
+ reset();
74
+ }, [placed]);
75
+ const focusOnce = React.useRef(autoFocus);
76
+ const seeded = React.useRef(props.typed != null);
77
+ const lineRef = React.useCallback((el) => {
78
+ line.current = el;
79
+ if (!phoneNow.current && el && focusOnce.current) {
80
+ focusOnce.current = false;
81
+ requestAnimationFrame(() => {
82
+ const to = el.isConnected ? el : line.current;
83
+ to?.focus({ preventScroll: true });
84
+ if (seeded.current && to instanceof HTMLInputElement)
85
+ to.setSelectionRange(to.value.length, to.value.length);
86
+ });
87
+ }
88
+ }, []);
89
+ const pick = (day) => {
90
+ setDate(day);
91
+ setTyped(null);
92
+ setError(null);
93
+ hand(day, clock);
94
+ if (day)
95
+ setKey(day);
96
+ if (!phone && (!time || day === null))
97
+ settle(day, clock);
98
+ };
99
+ const take = () => {
100
+ if (typed == null)
101
+ return true;
102
+ if (!typed.trim()) {
103
+ setTyped(null);
104
+ if (clears) {
105
+ setDate(null);
106
+ hand(null, clock);
107
+ }
108
+ return true;
109
+ }
110
+ if (reading && "date" in reading) {
111
+ setDate(reading.date);
112
+ setKey(reading.date);
113
+ setTyped(null);
114
+ setError(null);
115
+ hand(reading.date, clock);
116
+ return true;
117
+ }
118
+ setError(reading && "error" in reading ? reading.error : null);
119
+ return false;
120
+ };
121
+ const keep = () => { if (take())
122
+ settle(dayOfLine(), clock); };
123
+ const type = (text) => { setTyped(text); setError(null); if (text != null)
124
+ handTyped(text); };
125
+ const reads = reading && "date" in reading ? reading.date : null;
126
+ const keyDay = reads ?? key;
127
+ const onBlur = (e) => {
128
+ if (shell || settled.current || (e.relatedTarget instanceof Node && e.currentTarget.contains(e.relatedTarget)))
129
+ return;
130
+ keep();
131
+ };
132
+ const onEscape = (e) => { if (e.key === "Escape") {
133
+ e.preventDefault();
134
+ e.stopPropagation();
135
+ settle(dayOfLine(), clock);
136
+ } };
137
+ const lineKeys = (e) => {
138
+ if (e.key !== "Enter" || e.nativeEvent.isComposing)
139
+ return;
140
+ e.preventDefault();
141
+ if (blank(typed)) {
142
+ setTyped(null);
143
+ settle();
144
+ return;
145
+ }
146
+ keep();
147
+ };
148
+ const lineKeyDown = written
149
+ ? (e) => { if (typed == null && (e.key === "Backspace" || e.key === "Delete")) {
150
+ e.preventDefault();
151
+ type("");
152
+ return;
153
+ } lineKeys(e); }
154
+ : phone
155
+ ? (e) => { if (e.key !== "Enter" || e.nativeEvent.isComposing)
156
+ return; e.preventDefault(); keep(); }
157
+ : (e) => { if (blank(typed) && (e.key === "Backspace" || e.key === "Delete")) {
158
+ e.preventDefault();
159
+ return;
160
+ } lineKeys(e); };
161
+ return {
162
+ phone, today, date, clock, typed, reads, error, keyDay,
163
+ picks: picks.map((p) => ({ key: p, day: p === "none" ? null : quickPick(p, today), word: w[PICK_WORD[p]] })),
164
+ words: w, names, off, pick,
165
+ enterDay: (day) => { pick(day); if (phone || time)
166
+ settle(day, clock); },
167
+ moveKey: setKey,
168
+ moveMonth: (n) => setKey(addMonths(keyDay, n)),
169
+ type,
170
+ setDay: (d) => { setDate(d); setKey(d); hand(d, clock); },
171
+ setTime, keep, leave,
172
+ root: phone
173
+ ? { ref: rootRef }
174
+ : { ref: rootRef, onBlur, onFocus: () => { settled.current = false; }, onKeyDown: shell ? undefined : onEscape },
175
+ line: {
176
+ ref: lineRef,
177
+ value: written ? (typed ?? (date ? lineText(date, names) : "")) : (typed ?? ""),
178
+ "aria-invalid": error ? true : undefined,
179
+ onChange: (e) => type(e.target.value),
180
+ onKeyDown: lineKeyDown,
181
+ onBeforeInput: written ? (e) => { if (typed == null) {
182
+ e.preventDefault();
183
+ type(e.nativeEvent.data ?? "");
184
+ } } : undefined,
185
+ },
186
+ };
187
+ }
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import { type SheetHeadProps } from "../sheet/bottom-sheet.js";
3
3
  import { type DatePick } from "./calendar.js";
4
4
  import { type DateEditorWorn } from "./looks.js";
5
- import { type DateEditorWords } from "./words.js";
5
+ import type { DateEditorWords } from "./words.js";
6
6
  export type { DatePick } from "./calendar.js";
7
7
  export interface DateEditorProps {
8
8
  /** The field's name: the Sheet's title, and the days' name to a screen reader. */
@@ -62,7 +62,8 @@ export declare const LEFT: string[], RIGHT: string[];
62
62
  /** The options worn round an element: a ref callback and what it wears, Attio's before it stands, read again as Tweaks
63
63
  * change them (a MutationObserver on the six data-date-editor-* attributes, as the Picker reads its own); `given` wins. */
64
64
  export declare function useDateEditorWorn(given?: Partial<DateEditorWorn>): [(el: Element | null) => void, DateEditorWorn];
65
- /** The Date editor's state and the parts a shell pours in. */
65
+ /** The Date editor's state and the parts a shell pours in: drawn on its behaviour (date-behaviour.ts), which an app's own
66
+ * piece may be drawn on too. */
66
67
  export declare function useDateEditor(props: DateEditorProps): DateEditorParts;
67
68
  /** The body alone, for a shell that holds only a body (the Popover). */
68
69
  export declare function DateEditor(props: DateEditorProps): import("react/jsx-runtime").JSX.Element;