@viewkitjs/views 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +571 -0
- package/README.md +5 -3
- package/dist/atoms/LoadMore.js +11 -1
- package/dist/atoms/RowMenu.js +5 -2
- package/dist/cells/cell-format.d.ts +3 -3
- package/dist/cells/cell-title.d.ts +1 -2
- package/dist/cells/cell-title.js +2 -2
- package/dist/cells/cell-values.js +6 -3
- package/dist/contract.d.ts +50 -9
- package/dist/contract.js +33 -5
- package/dist/display/converted.d.ts +19 -0
- package/dist/display/converted.js +12 -0
- package/dist/display/index.d.ts +1 -0
- package/dist/display/index.js +1 -0
- package/dist/display/link-click.d.ts +11 -0
- package/dist/display/link-click.js +3 -0
- package/dist/display/link.js +7 -3
- package/dist/display/multi-value.d.ts +1 -1
- package/dist/display/multi-value.js +1 -1
- package/dist/display/options.d.ts +7 -1
- package/dist/display/phone.js +3 -1
- package/dist/editors/ChipsEditor.d.ts +9 -4
- package/dist/editors/ChipsEditor.js +6 -2
- package/dist/editors/DateEditor.d.ts +21 -6
- package/dist/editors/DateEditor.js +118 -30
- package/dist/editors/EditorPanel.d.ts +61 -0
- package/dist/editors/EditorPanel.js +54 -0
- package/dist/editors/LocationEditor.d.ts +3 -0
- package/dist/editors/LocationEditor.js +14 -6
- package/dist/editors/NameEditor.d.ts +3 -0
- package/dist/editors/NameEditor.js +11 -7
- package/dist/editors/NumberEditor.d.ts +3 -0
- package/dist/editors/NumberEditor.js +6 -6
- package/dist/editors/RangeEditor.d.ts +16 -1
- package/dist/editors/RangeEditor.js +21 -5
- package/dist/editors/RelationEditor.d.ts +13 -28
- package/dist/editors/RelationEditor.js +17 -40
- package/dist/editors/RelationSetEditor.d.ts +53 -0
- package/dist/editors/RelationSetEditor.js +112 -0
- package/dist/editors/SelectEditor.d.ts +21 -3
- package/dist/editors/SelectEditor.js +55 -9
- package/dist/editors/TextEditor.d.ts +51 -0
- package/dist/editors/TextEditor.js +81 -0
- package/dist/editors/ValueListEditor.d.ts +3 -0
- package/dist/editors/ValueListEditor.js +4 -2
- package/dist/editors/edit-cores.d.ts +12 -9
- package/dist/editors/edit-cores.js +7 -6
- package/dist/editors/edit-session.d.ts +21 -11
- package/dist/editors/edit-session.js +19 -5
- package/dist/editors/keep-inside.d.ts +12 -0
- package/dist/editors/keep-inside.js +20 -0
- package/dist/editors/open-value.d.ts +21 -0
- package/dist/editors/open-value.js +36 -0
- package/dist/editors/open-values.d.ts +4 -0
- package/dist/editors/open-values.js +7 -0
- package/dist/editors/relation-kinds.d.ts +7 -0
- package/dist/editors/relation-kinds.js +21 -0
- package/dist/editors/relation-panel.d.ts +69 -0
- package/dist/editors/relation-panel.js +40 -0
- package/dist/field-row/FieldNoteLine.d.ts +14 -0
- package/dist/field-row/FieldNoteLine.js +14 -0
- package/dist/field-row/FieldRow.d.ts +73 -0
- package/dist/field-row/FieldRow.js +157 -0
- package/dist/field-row/FieldRowLane.d.ts +19 -0
- package/dist/field-row/FieldRowLane.js +11 -0
- package/dist/field-row/editors/RowChipsEditor.d.ts +11 -0
- package/dist/field-row/editors/RowChipsEditor.js +25 -0
- package/dist/field-row/editors/RowDateEditor.d.ts +16 -0
- package/dist/field-row/editors/RowDateEditor.js +18 -0
- package/dist/field-row/editors/RowEditor.d.ts +39 -0
- package/dist/field-row/editors/RowEditor.js +64 -0
- package/dist/field-row/editors/RowNameEditor.d.ts +4 -0
- package/dist/field-row/editors/RowNameEditor.js +15 -0
- package/dist/field-row/editors/RowNumberEditor.d.ts +12 -0
- package/dist/field-row/editors/RowNumberEditor.js +18 -0
- package/dist/field-row/editors/RowPlaceEditor.d.ts +8 -0
- package/dist/field-row/editors/RowPlaceEditor.js +18 -0
- package/dist/field-row/editors/RowRangeEditor.d.ts +4 -0
- package/dist/field-row/editors/RowRangeEditor.js +15 -0
- package/dist/field-row/editors/RowRelationEditor.d.ts +20 -0
- package/dist/field-row/editors/RowRelationEditor.js +77 -0
- package/dist/field-row/editors/RowSelectEditor.d.ts +13 -0
- package/dist/field-row/editors/RowSelectEditor.js +23 -0
- package/dist/field-row/editors/RowTextEditor.d.ts +15 -0
- package/dist/field-row/editors/RowTextEditor.js +16 -0
- package/dist/field-row/editors/RowValueListEditor.d.ts +4 -0
- package/dist/field-row/editors/RowValueListEditor.js +21 -0
- package/dist/field-row/editors/host.d.ts +59 -0
- package/dist/field-row/editors/host.js +1 -0
- package/dist/field-row/editors/row-session.d.ts +49 -0
- package/dist/field-row/editors/row-session.js +49 -0
- package/dist/field-row/index.d.ts +5 -0
- package/dist/field-row/index.js +5 -0
- package/dist/field-row/row-target.d.ts +20 -0
- package/dist/field-row/row-target.js +3 -0
- package/dist/field-row/useFieldWrite.d.ts +45 -0
- package/dist/field-row/useFieldWrite.js +190 -0
- package/dist/field-row/useRowSettlement.d.ts +33 -0
- package/dist/field-row/useRowSettlement.js +23 -0
- package/dist/fields/binding.d.ts +6 -1
- package/dist/fields/binding.js +13 -6
- package/dist/fields/edit-core-types.d.ts +9 -9
- package/dist/fields/edit-core-types.js +6 -6
- package/dist/fields/money.d.ts +5 -0
- package/dist/fields/money.js +10 -0
- package/dist/fields/number-edit.d.ts +6 -0
- package/dist/fields/number-edit.js +4 -0
- package/dist/fields/prepare-write.js +6 -1
- package/dist/fields/relation-source-types.d.ts +12 -0
- package/dist/fields/write-target.d.ts +50 -0
- package/dist/fields/write-target.js +10 -0
- package/dist/grid/chrome/GridAddColumn.js +1 -1
- package/dist/grid/chrome/GridAggregateMenu.d.ts +1 -1
- package/dist/grid/chrome/GridAggregateMenu.js +8 -6
- package/dist/grid/chrome/GridCellEditors.d.ts +7 -0
- package/dist/grid/chrome/GridCellEditors.js +87 -16
- package/dist/grid/chrome/GridCellOutline.d.ts +22 -43
- package/dist/grid/chrome/GridCellOutline.js +2 -7
- package/dist/grid/chrome/GridChipsEditor.d.ts +16 -6
- package/dist/grid/chrome/GridChipsEditor.js +21 -26
- package/dist/grid/chrome/GridColumnMenu.d.ts +1 -1
- package/dist/grid/chrome/GridColumnMenu.js +7 -3
- package/dist/grid/chrome/GridDateEditor.d.ts +23 -11
- package/dist/grid/chrome/GridDateEditor.js +13 -25
- package/dist/grid/chrome/GridFooter.d.ts +12 -2
- package/dist/grid/chrome/GridFooter.js +10 -6
- package/dist/grid/chrome/GridGroupMenu.js +20 -13
- package/dist/grid/chrome/GridHeader.d.ts +9 -4
- package/dist/grid/chrome/GridHeader.js +15 -10
- package/dist/grid/chrome/GridLongTextEditor.d.ts +28 -9
- package/dist/grid/chrome/GridLongTextEditor.js +16 -74
- package/dist/grid/chrome/GridNameEditor.d.ts +11 -6
- package/dist/grid/chrome/GridNameEditor.js +12 -27
- package/dist/grid/chrome/GridNumberEditor.d.ts +20 -6
- package/dist/grid/chrome/GridNumberEditor.js +46 -20
- package/dist/grid/chrome/GridPlaceEditor.d.ts +26 -0
- package/dist/grid/chrome/GridPlaceEditor.js +22 -0
- package/dist/grid/chrome/GridRangeEditor.d.ts +15 -5
- package/dist/grid/chrome/GridRangeEditor.js +16 -20
- package/dist/grid/chrome/GridRelationEditor.d.ts +38 -14
- package/dist/grid/chrome/GridRelationEditor.js +86 -24
- package/dist/grid/chrome/GridRow.d.ts +7 -1
- package/dist/grid/chrome/GridRow.js +57 -14
- package/dist/grid/chrome/GridRowActions.js +1 -1
- package/dist/grid/chrome/GridRowCells.js +18 -23
- package/dist/grid/chrome/GridSelectEditor.d.ts +19 -4
- package/dist/grid/chrome/GridSelectEditor.js +21 -27
- package/dist/grid/chrome/GridStructure.d.ts +9 -10
- package/dist/grid/chrome/GridStructure.js +10 -14
- package/dist/grid/chrome/GridTable.js +97 -30
- package/dist/grid/chrome/GridTableSurface.d.ts +39 -2
- package/dist/grid/chrome/GridTableSurface.js +12 -3
- package/dist/grid/chrome/GridTextEditor.d.ts +35 -1
- package/dist/grid/chrome/GridTextEditor.js +35 -37
- package/dist/grid/chrome/GridValueListEditor.d.ts +15 -3
- package/dist/grid/chrome/GridValueListEditor.js +10 -27
- package/dist/grid/chrome/cell-cut-off.d.ts +11 -0
- package/dist/grid/chrome/cell-cut-off.js +20 -0
- package/dist/grid/chrome/cells.js +1 -2
- package/dist/grid/chrome/checks.d.ts +2 -5
- package/dist/grid/chrome/checks.js +15 -5
- package/dist/grid/chrome/editors.d.ts +1 -1
- package/dist/grid/chrome/editors.js +1 -1
- package/dist/grid/chrome/grid-cell-classes.d.ts +2 -8
- package/dist/grid/chrome/grid-cell-classes.js +10 -8
- package/dist/grid/chrome/grid-cell-link.d.ts +13 -0
- package/dist/grid/chrome/grid-cell-link.js +9 -0
- package/dist/grid/chrome/grid-edit-session.d.ts +63 -0
- package/dist/grid/chrome/grid-edit-session.js +118 -0
- package/dist/grid/chrome/grid-hover.d.ts +60 -0
- package/dist/grid/chrome/grid-hover.js +81 -0
- package/dist/grid/chrome/grid-menu-focus.d.ts +43 -0
- package/dist/grid/chrome/grid-menu-focus.js +93 -0
- package/dist/grid/chrome/grid-row-menu-key.d.ts +15 -0
- package/dist/grid/chrome/grid-row-menu-key.js +36 -0
- package/dist/grid/chrome/grid-row-props.d.ts +16 -4
- package/dist/grid/chrome/grid-row-window.d.ts +61 -0
- package/dist/grid/chrome/grid-row-window.js +212 -0
- package/dist/grid/chrome/grid-scroll-owner.d.ts +38 -0
- package/dist/grid/chrome/grid-scroll-owner.js +75 -0
- package/dist/grid/chrome/grid-styles.d.ts +4 -1
- package/dist/grid/chrome/grid-styles.js +1 -0
- package/dist/grid/chrome/grid-table-props.d.ts +2 -3
- package/dist/grid/chrome/useGridFocus.d.ts +45 -0
- package/dist/grid/chrome/useGridFocus.js +122 -0
- package/dist/grid/chrome/useGridKeyboard.d.ts +21 -4
- package/dist/grid/chrome/useGridKeyboard.js +214 -38
- package/dist/grid/chrome/useGridRangeActions.d.ts +3 -1
- package/dist/grid/chrome/useGridRangeActions.js +17 -10
- package/dist/grid/chrome/useGridRangeGestures.js +68 -21
- package/dist/grid/chrome/useGridRowContextMenu.d.ts +4 -2
- package/dist/grid/chrome/useGridRowContextMenu.js +28 -2
- package/dist/grid/chrome/useGridScaleStyles.d.ts +3 -1
- package/dist/grid/chrome/useGridScaleStyles.js +6 -7
- package/dist/grid/chrome/useGridScrollArea.d.ts +21 -0
- package/dist/grid/chrome/useGridScrollArea.js +65 -0
- package/dist/grid/chrome/useGridTableInteractionModel.d.ts +28 -5
- package/dist/grid/chrome/useGridTableInteractionModel.js +66 -14
- package/dist/grid/chrome/useHeaderDragReorder.d.ts +2 -2
- package/dist/grid/core/clipboard-model.d.ts +2 -0
- package/dist/grid/core/clipboard-model.js +1 -1
- package/dist/grid/core/commit-model.d.ts +7 -0
- package/dist/grid/core/edge-scroll.d.ts +21 -0
- package/dist/grid/core/edge-scroll.js +23 -0
- package/dist/grid/core/editing-controller.d.ts +2 -1
- package/dist/grid/core/editing-controller.js +35 -9
- package/dist/grid/core/editing-model.d.ts +9 -0
- package/dist/grid/core/editing-model.js +12 -0
- package/dist/grid/core/flat-rows.d.ts +35 -0
- package/dist/grid/core/flat-rows.js +20 -0
- package/dist/grid/core/grid-aria.d.ts +27 -0
- package/dist/grid/core/grid-aria.js +39 -0
- package/dist/grid/core/grid-focus.d.ts +54 -0
- package/dist/grid/core/grid-focus.js +148 -0
- package/dist/grid/core/nav.d.ts +2 -2
- package/dist/grid/core/pending-reconciliation.d.ts +3 -0
- package/dist/grid/core/pending-reconciliation.js +5 -3
- package/dist/grid/core/row-window.d.ts +40 -0
- package/dist/grid/core/row-window.js +43 -0
- package/dist/grid/core/spreadsheet-operations.d.ts +17 -1
- package/dist/grid/core/spreadsheet-operations.js +33 -6
- package/dist/grid/core/useGridEditing.d.ts +3 -0
- package/dist/grid/core/useGridEditing.js +6 -3
- package/dist/grid/core/value-equality.d.ts +23 -1
- package/dist/grid/core/value-equality.js +46 -0
- package/dist/grid/useGridTablePrefs.d.ts +0 -1
- package/dist/grid/useGridTablePrefs.js +1 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/viewport.d.ts +0 -2
- package/dist/internal/viewport.js +0 -14
- package/dist/model/column-capabilities.d.ts +2 -1
- package/dist/model/column-capabilities.js +28 -8
- package/dist/model/column-from.js +3 -0
- package/dist/model/column-inspect.d.ts +10 -2
- package/dist/model/column-inspect.js +9 -0
- package/dist/model/column-schema.d.ts +6 -1
- package/dist/model/column-types.d.ts +3 -1
- package/dist/model/column-types.js +1 -1
- package/dist/model/preferences.d.ts +0 -4
- package/dist/model/preferences.js +0 -1
- package/dist/model/prefs-buckets.d.ts +0 -1
- package/dist/model/prefs-buckets.js +0 -3
- package/dist/model/render-count.d.ts +6 -0
- package/dist/model/render-count.js +11 -0
- package/dist/provider/ViewsProvider.d.ts +5 -1
- package/dist/provider/ViewsProvider.js +9 -3
- package/dist/provider/components.d.ts +19 -1
- package/dist/provider/components.js +4 -2
- package/dist/provider/context.d.ts +5 -2
- package/dist/provider/desktop.d.ts +9 -0
- package/dist/provider/desktop.js +22 -0
- package/dist/provider/plain-input.d.ts +8 -0
- package/dist/provider/plain-input.js +5 -0
- package/dist/react.d.ts +2 -1
- package/dist/react.js +1 -0
- package/dist/selection/SelectCheckbox.d.ts +3 -1
- package/dist/selection/SelectCheckbox.js +2 -2
- package/dist/selection/useCheckDragSelect.js +6 -5
- package/docs/contract.md +93 -35
- package/docs/guides/atoms.md +1 -1
- package/docs/guides/cells.md +2 -2
- package/docs/guides/columns.md +3 -2
- package/docs/guides/display.md +1 -0
- package/docs/guides/editors.md +71 -13
- package/docs/guides/the-grid.md +32 -13
- package/docs/guides/the-provider.md +3 -1
- package/docs/index.md +3 -1
- package/docs/install.md +1 -1
- package/docs/reference/cells.md +1 -1
- package/docs/reference/display.md +3 -1
- package/docs/reference/editors-chips.md +2 -2
- package/docs/reference/editors-date.md +3 -3
- package/docs/reference/editors-location.md +1 -1
- package/docs/reference/editors-number.md +1 -1
- package/docs/reference/editors-open-values.md +1 -0
- package/docs/reference/editors-panel.md +12 -0
- package/docs/reference/editors-range.md +1 -1
- package/docs/reference/editors-relation.md +6 -3
- package/docs/reference/editors-select.md +3 -2
- package/docs/reference/editors-session.md +4 -2
- package/docs/reference/editors-text.md +9 -0
- package/docs/reference/editors-value-list.md +1 -1
- package/docs/reference/editors.md +2 -2
- package/docs/reference/field-row.md +16 -0
- package/docs/reference/grid.md +3 -3
- package/docs/reference/react.md +8 -5
- package/docs/reference/views.md +36 -15
- package/package.json +23 -4
- package/skills/views/SKILL.md +4 -4
- package/dist/grid/chrome/useGridScrollSync.d.ts +0 -38
- package/dist/grid/chrome/useGridScrollSync.js +0 -176
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ Guides:
|
|
|
69
69
|
- [The grid](./docs/guides/the-grid.md): grouping, sorting, writes, preferences, figures and the editing rules.
|
|
70
70
|
- [The rendering contract](./docs/contract.md): every public name and what each door holds; [reshaping a view](./docs/reshaping.md): the cheapest change first.
|
|
71
71
|
|
|
72
|
-
References, one per door, each naming every export: [`@viewkitjs/views`](./docs/reference/views.md), [`/react`](./docs/reference/react.md), [`/display`](./docs/reference/display.md), [`/editors`](./docs/reference/editors.md), [`/editors/select`](./docs/reference/editors-select.md), [`/editors/relation`](./docs/reference/editors-relation.md), [`/editors/number`](./docs/reference/editors-number.md), [`/editors/range`](./docs/reference/editors-range.md), [`/editors/name`](./docs/reference/editors-name.md), [`/editors/location`](./docs/reference/editors-location.md), [`/editors/value-list`](./docs/reference/editors-value-list.md), [`/editors/date`](./docs/reference/editors-date.md), [`/editors/chips`](./docs/reference/editors-chips.md), [`/editors/session`](./docs/reference/editors-session.md), [`/editors/open-values`](./docs/reference/editors-open-values.md), [`/cells`](./docs/reference/cells.md), [`/selection`](./docs/reference/selection.md), [`/grid`](./docs/reference/grid.md).
|
|
72
|
+
References, one per door, each naming every export: [`@viewkitjs/views`](./docs/reference/views.md), [`/react`](./docs/reference/react.md), [`/display`](./docs/reference/display.md), [`/editors`](./docs/reference/editors.md), [`/editors/select`](./docs/reference/editors-select.md), [`/editors/text`](./docs/reference/editors-text.md), [`/editors/relation`](./docs/reference/editors-relation.md), [`/editors/number`](./docs/reference/editors-number.md), [`/editors/range`](./docs/reference/editors-range.md), [`/editors/name`](./docs/reference/editors-name.md), [`/editors/location`](./docs/reference/editors-location.md), [`/editors/value-list`](./docs/reference/editors-value-list.md), [`/editors/date`](./docs/reference/editors-date.md), [`/editors/chips`](./docs/reference/editors-chips.md), [`/editors/session`](./docs/reference/editors-session.md), [`/editors/panel`](./docs/reference/editors-panel.md), [`/editors/open-values`](./docs/reference/editors-open-values.md), [`/field-row`](./docs/reference/field-row.md), [`/cells`](./docs/reference/cells.md), [`/selection`](./docs/reference/selection.md), [`/grid`](./docs/reference/grid.md).
|
|
73
73
|
|
|
74
74
|
## Doors
|
|
75
75
|
|
|
@@ -79,13 +79,15 @@ References, one per door, each naming every export: [`@viewkitjs/views`](./docs/
|
|
|
79
79
|
| `@viewkitjs/views/react` | `ViewsProvider`, `useViews`, the default atoms, and the types an adapter implements |
|
|
80
80
|
| `@viewkitjs/views/display` | the field display: one renderer per storage type, the string formatters, the viewer |
|
|
81
81
|
| `@viewkitjs/views/editors` | the edit registry: which editor each type opens |
|
|
82
|
-
| `@viewkitjs/views/editors/<name>` | one editor each: `select`, `relation`, `number`, `range`, `name`, `location`, `value-list`, `date`, `chips` |
|
|
82
|
+
| `@viewkitjs/views/editors/<name>` | one editor each: `select`, `text`, `relation`, `number`, `range`, `name`, `location`, `value-list`, `date`, `chips` |
|
|
83
83
|
| `@viewkitjs/views/editors/session`, `/editors/open-values` | the anchored edit session every host shares, and an open field's values carried to its editors |
|
|
84
|
+
| `@viewkitjs/views/editors/panel` | an editor opened as your popover on the desktop and your sheet on the phone |
|
|
85
|
+
| `@viewkitjs/views/field-row` | a record's field row: its label, its value and its editor in place, with the write path that admits, queues and settles each edit |
|
|
84
86
|
| `@viewkitjs/views/cells` | a column's typed cell, and its column-shaped string formatters |
|
|
85
87
|
| `@viewkitjs/views/selection` | a list's selection: the model, the hook, the row checkbox, drag-select and the row-click rules |
|
|
86
88
|
| `@viewkitjs/views/grid` | the grid: the table, its props, its preferences, and the helpers a host shares with it |
|
|
87
89
|
|
|
88
|
-
|
|
90
|
+
Twenty-one doors; there are no other subpaths.
|
|
89
91
|
|
|
90
92
|
## For coding agents
|
|
91
93
|
|
package/dist/atoms/LoadMore.js
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
4
|
import { useViews } from "../provider/context.js";
|
|
5
|
+
const SCROLLS_Y = new Set(["auto", "scroll", "overlay"]);
|
|
6
|
+
function nearestScrollArea(element) {
|
|
7
|
+
for (let el = element.parentElement; el; el = el.parentElement) {
|
|
8
|
+
if (el === document.body || el === document.documentElement)
|
|
9
|
+
break;
|
|
10
|
+
if (SCROLLS_Y.has(getComputedStyle(el).overflowY) && el.scrollHeight > el.clientHeight)
|
|
11
|
+
return el;
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
5
15
|
export function DefaultLoadMore({ onReveal, label }) {
|
|
6
16
|
const { Loading } = useViews().atoms;
|
|
7
17
|
const ref = useRef(null);
|
|
@@ -17,7 +27,7 @@ export function DefaultLoadMore({ onReveal, label }) {
|
|
|
17
27
|
for (const entry of entries)
|
|
18
28
|
if (entry.isIntersecting)
|
|
19
29
|
onRevealRef.current();
|
|
20
|
-
}, { rootMargin: "600px 0px" });
|
|
30
|
+
}, { root: nearestScrollArea(element), rootMargin: "600px 0px" });
|
|
21
31
|
observer.observe(element);
|
|
22
32
|
return () => observer.disconnect();
|
|
23
33
|
}, []);
|
package/dist/atoms/RowMenu.js
CHANGED
|
@@ -90,14 +90,17 @@ export function DefaultRowMenu({ children, rowId, items, openHref, onDelete, del
|
|
|
90
90
|
setPoint(null);
|
|
91
91
|
return (_jsxs("div", { ref: wrapper, "data-slot": "vk-row-menu", onPointerDownCapture: (event) => {
|
|
92
92
|
lastPress.current = event.pointerType;
|
|
93
|
+
}, onKeyDownCapture: () => {
|
|
94
|
+
lastPress.current = undefined;
|
|
93
95
|
}, onContextMenu: (event) => {
|
|
94
96
|
const fromMore = event.target.closest?.('[data-slot="vk-grid-row-more"]');
|
|
95
|
-
const
|
|
97
|
+
const pressed = lastPress.current;
|
|
98
|
+
const touched = pressed === "touch";
|
|
96
99
|
lastPress.current = undefined;
|
|
97
100
|
if (touched && !fromMore)
|
|
98
101
|
return;
|
|
99
102
|
event.preventDefault();
|
|
100
|
-
openedAt.current = performance.now();
|
|
103
|
+
openedAt.current = pressed === undefined ? -Infinity : performance.now();
|
|
101
104
|
setPoint({ x: event.clientX, y: event.clientY });
|
|
102
105
|
}, onPointerUpCapture: (event) => {
|
|
103
106
|
if (!point || !inGrace())
|
|
@@ -36,9 +36,6 @@ export type GridCellOptions = {
|
|
|
36
36
|
withTime?: boolean;
|
|
37
37
|
/** Percent columns: the workspace's display — wins over `format.percentDisplay`. */
|
|
38
38
|
percentDisplay?: PercentDisplay;
|
|
39
|
-
/** Per-user "Wrap columns" toggle: text-bearing cells wrap instead of
|
|
40
|
-
* truncating. See `cellTextClass` in the display. */
|
|
41
|
-
wrap?: boolean;
|
|
42
39
|
/** Optimistic pending value (Tier 3) — wins over `accessor(row)` when defined.
|
|
43
40
|
* Only typed cells honor it; custom `render` columns show confirmed data. */
|
|
44
41
|
valueOverride?: unknown;
|
|
@@ -105,6 +102,9 @@ export type GridCellOptions = {
|
|
|
105
102
|
* controls inside the slot's own button would be invalid markup.
|
|
106
103
|
*/
|
|
107
104
|
slotOwnsClick?: boolean;
|
|
105
|
+
/** A host whose plain click on a value is its own (the grid selects the cell): links stay links but let the
|
|
106
|
+
* click through, and the host follows one only on a ⌘- or Ctrl-click (`DisplayOptions.hostOwnsPlainClick`). */
|
|
107
|
+
hostOwnsPlainClick?: boolean;
|
|
108
108
|
};
|
|
109
109
|
/**
|
|
110
110
|
* Fold the code a money cell is drawn in into the render options, so the
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import type { GridCellOptions } from "./cell-format.js";
|
|
3
2
|
import type { ListColumn } from "../model/column-schema.js";
|
|
4
3
|
/**
|
|
5
4
|
* THE TITLE CELL — the one typed cell the list owns, not a field.
|
|
@@ -14,4 +13,4 @@ import type { ListColumn } from "../model/column-schema.js";
|
|
|
14
13
|
* generic indicator lane for this type: the adornment has to sit inside the
|
|
15
14
|
* cell's own layout rules about where the click target ends.
|
|
16
15
|
*/
|
|
17
|
-
export declare function renderTitleCell<Row>(col: ListColumn<Row>, row: Row, content: ReactNode
|
|
16
|
+
export declare function renderTitleCell<Row>(col: ListColumn<Row>, row: Row, content: ReactNode): ReactNode;
|
package/dist/cells/cell-title.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { cellTextClass } from "../display/text-class.js";
|
|
4
4
|
import { cx } from "../internal/cx.js";
|
|
5
|
-
export function renderTitleCell(col, row, content
|
|
5
|
+
export function renderTitleCell(col, row, content) {
|
|
6
6
|
const indicator = col.indicator?.(row);
|
|
7
|
-
return (_jsxs("span", { className: "flex min-w-0 flex-1 items-center gap-2", children: [_jsx("span", { "data-cell-open": true, className: cx("min-w-0 cursor-pointer font-medium text-(color:--vk-fg)", cellTextClass(
|
|
7
|
+
return (_jsxs("span", { className: "flex min-w-0 flex-1 items-center gap-2", children: [_jsx("span", { "data-cell-open": true, className: cx("min-w-0 cursor-pointer font-medium text-(color:--vk-fg)", cellTextClass()), children: content }), indicator] }));
|
|
8
8
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { valueTypeOf } from "@viewkitjs/fields";
|
|
4
|
+
import { ConvertedFigure } from "../display/converted.js";
|
|
4
5
|
import { renderFieldValue } from "../display/display-cores.js";
|
|
6
|
+
import { convertedFromOf } from "../fields/money.js";
|
|
5
7
|
import { columnLabel } from "../model/column-capabilities.js";
|
|
6
8
|
import { prettifyOptionValue } from "../model/column-state.js";
|
|
7
9
|
import { useViews } from "../provider/context.js";
|
|
@@ -19,13 +21,14 @@ export function renderTypedCellValue(col, row, opts) {
|
|
|
19
21
|
if (!col.type)
|
|
20
22
|
return null;
|
|
21
23
|
if (col.type === "title")
|
|
22
|
-
return renderTitleCell(col, row, identityContent(col, row, value, opts)
|
|
24
|
+
return renderTitleCell(col, row, identityContent(col, row, value, opts));
|
|
23
25
|
const field = col.field ?? legacyFieldFromColumn(col);
|
|
24
26
|
const cell = renderFieldValue(field, value, displayOptionsFor(col, row, opts));
|
|
25
27
|
if (col.command && opts?.commandItems?.length) {
|
|
26
28
|
return _jsx(CommandCell, { col: col, cell: cell, items: opts.commandItems });
|
|
27
29
|
}
|
|
28
|
-
|
|
30
|
+
const from = cell == null ? null : convertedFromOf(col, row);
|
|
31
|
+
return from ? _jsx(ConvertedFigure, { from: from, children: cell }) : cell;
|
|
29
32
|
}
|
|
30
33
|
const TITLE_THROUGH_CORE = new Set(["number", "percent", "currency", "date", "datetime", "name"]);
|
|
31
34
|
function identityContent(col, row, value, opts) {
|
|
@@ -74,7 +77,6 @@ function displayOptionsFor(col, row, opts) {
|
|
|
74
77
|
nameFallback: col.nameFallback?.(row) ?? undefined,
|
|
75
78
|
withTime: opts?.withTime,
|
|
76
79
|
percentDisplay: opts?.percentDisplay,
|
|
77
|
-
wrap: opts?.wrap,
|
|
78
80
|
booleanIcon: col.format?.icon,
|
|
79
81
|
marker: col.marker,
|
|
80
82
|
markerReason: opts?.markerReason,
|
|
@@ -82,6 +84,7 @@ function displayOptionsFor(col, row, opts) {
|
|
|
82
84
|
onToggle: opts?.onToggle,
|
|
83
85
|
entityIcon: opts?.entityIcon,
|
|
84
86
|
slotOwnsClick: opts?.slotOwnsClick,
|
|
87
|
+
hostOwnsPlainClick: opts?.hostOwnsPlainClick,
|
|
85
88
|
relationWrap: listRelationWrap(opts),
|
|
86
89
|
};
|
|
87
90
|
}
|
package/dist/contract.d.ts
CHANGED
|
@@ -10,14 +10,14 @@ export declare const VK_PREFIX: "vk";
|
|
|
10
10
|
/** The parts of the grid, as `data-slot` values. `data-slot` is one attribute shared by
|
|
11
11
|
* every component copy in an app, so each value carries the prefix. Board's arrive with
|
|
12
12
|
* the board. */
|
|
13
|
-
export declare const GRID_SLOTS: readonly ["vk-grid", "vk-grid-header", "vk-grid-header-cell", "vk-grid-row", "vk-grid-cell", "vk-grid-group", "vk-grid-group-header", "vk-grid-footer", "vk-grid-footer-cell", "vk-grid-rail", "vk-grid-tail", "vk-grid-row-more", "vk-grid-editor", "vk-grid-outline", "vk-grid-resize-handle", "vk-grid-column-menu", "vk-grid-flyout", "vk-grid-group-menu", "vk-grid-aggregate-menu"];
|
|
13
|
+
export declare const GRID_SLOTS: readonly ["vk-grid", "vk-grid-scroll", "vk-grid-head", "vk-grid-header", "vk-grid-header-cell", "vk-grid-row", "vk-grid-rows", "vk-grid-gap", "vk-grid-cell", "vk-grid-group", "vk-grid-group-head", "vk-grid-group-header", "vk-grid-footer", "vk-grid-footer-cell", "vk-grid-rail", "vk-grid-tail", "vk-grid-row-more", "vk-grid-editor", "vk-grid-outline", "vk-grid-resize-handle", "vk-grid-column-menu", "vk-grid-flyout", "vk-grid-group-menu", "vk-grid-aggregate-menu"];
|
|
14
14
|
export type GridSlot = (typeof GRID_SLOTS)[number];
|
|
15
15
|
/** The flags the rendering styles, as `data-*` attributes present when true. */
|
|
16
16
|
export declare const GRID_STATES: readonly ["focused", "selected", "editing", "in-range", "range-edge", "pending", "invalid", "dragging", "empty", "frozen", "scrolled", "parked"];
|
|
17
17
|
export type GridState = (typeof GRID_STATES)[number];
|
|
18
18
|
/** The CSS variables the package owns: geometry and density. Its colours are `VK_COLOURS`, which the app declares.
|
|
19
19
|
* The last three are `densityStyle`'s, written on the root of a rows view an app draws itself. */
|
|
20
|
-
export declare const VK_TOKENS: readonly ["--vk-scale", "--vk-row-h", "--vk-head-h", "--vk-footer-h", "--vk-label-h", "--vk-line-h", "--vk-
|
|
20
|
+
export declare const VK_TOKENS: readonly ["--vk-scale", "--vk-row-h", "--vk-head-h", "--vk-footer-h", "--vk-label-h", "--vk-line-h", "--vk-px", "--vk-tail-pl", "--vk-rail-w", "--vk-rail-gap", "--vk-tail-w", "--vk-indent", "--vk-frozen-w", "--vk-scroll-mt", "--vk-glyph", "--vk-head-glyph", "--vk-text", "--vk-text-xs", "--vk-text-10", "--vk-head-text", "--vk-scrolled", "--vk-parked", "--vk-frozen-on", "--vk-row-py", "--vk-head-mb", "--vk-row-gap"];
|
|
21
21
|
export type VkToken = (typeof VK_TOKENS)[number];
|
|
22
22
|
/** The colours the rendering paints, each a CSS variable the APP declares — the package
|
|
23
23
|
* sets none, and names no variable of the app's own. An app maps each onto its tokens once
|
|
@@ -32,15 +32,18 @@ export declare const VK_OPTIONAL_COLOURS: readonly ["--vk-success", "--vk-warnin
|
|
|
32
32
|
export type VkOptionalColour = (typeof VK_OPTIONAL_COLOURS)[number];
|
|
33
33
|
/** Layout the APP may declare, read with a built-in fallback. `--vk-gutter` is the side padding the
|
|
34
34
|
* page gives its content: the grid's rows run edge to edge and line their content up with it.
|
|
35
|
-
* Undeclared, it reads `0px` — a grid flush with its container. `--vk-
|
|
36
|
-
*
|
|
37
|
-
* grid's
|
|
38
|
-
|
|
35
|
+
* Undeclared, it reads `0px` — a grid flush with its container. `--vk-scroll-inset-bottom` is how
|
|
36
|
+
* much of the grid's foot the app covers with something it floats there (a phone's bottom bar):
|
|
37
|
+
* the grid's scroll area runs underneath it and its last row scrolls clear of it. Undeclared, it
|
|
38
|
+
* reads `0px`. The grid's headers pin inside its own scroll area, so nothing the app pins outside
|
|
39
|
+
* it concerns the grid. */
|
|
40
|
+
export declare const VK_OPTIONAL_LAYOUT: readonly ["--vk-gutter", "--vk-scroll-inset-bottom"];
|
|
39
41
|
export type VkOptionalLayout = (typeof VK_OPTIONAL_LAYOUT)[number];
|
|
40
42
|
/** The grid's own machinery, set and read by the grid alone: prefixed because they share the
|
|
41
43
|
* global namespace, and not public. An app neither sets nor reads them, and they may change in
|
|
42
|
-
* any release. `--vk-drag-shift` is a header cell's offset while its column is dragged
|
|
43
|
-
|
|
44
|
+
* any release. `--vk-drag-shift` is a header cell's offset while its column is dragged;
|
|
45
|
+
* `--vk-cols` is the columns' template, set on the scroll area and read by every row. */
|
|
46
|
+
export declare const VK_INTERNAL: readonly ["--vk-drag-shift", "--vk-cols"];
|
|
44
47
|
export type VkInternal = (typeof VK_INTERNAL)[number];
|
|
45
48
|
/** Internal families: a prefix, one variable per key after it. `--vk-col-w-<id>` is one
|
|
46
49
|
* column's resolved width, set on the grid's root for every visible column. */
|
|
@@ -48,12 +51,19 @@ export declare const VK_INTERNAL_FAMILIES: readonly ["--vk-col-w-"];
|
|
|
48
51
|
/** The primitives an app hands in through the provider. */
|
|
49
52
|
export declare const COMPONENT_NAMES: readonly ["Button", "Popover", "Tooltip", "Checkbox", "Menu", "Command", "Calendar", "Collapse", "Sheet", "AppIcon", "Markdown"];
|
|
50
53
|
export type ComponentName = (typeof COMPONENT_NAMES)[number];
|
|
54
|
+
/** The primitives an app may hand in, each with a plain default the provider fills: apart from
|
|
55
|
+
* `COMPONENT_NAMES`, which lists the ones it must. */
|
|
56
|
+
export declare const OPTIONAL_COMPONENT_NAMES: readonly ["Input"];
|
|
57
|
+
export type OptionalComponentName = (typeof OPTIONAL_COMPONENT_NAMES)[number];
|
|
51
58
|
/** 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). Each ships as a default; an app swaps any of them through the provider's `atoms`. */
|
|
52
59
|
export declare const ATOM_NAMES: readonly ["Row", "RowContent", "TickBox", "StatusBadge", "StatusMarker", "Tag", "List", "CommandMenu", "RelationLink", "Loading", "LoadMore", "PlatformMark", "RowMenu"];
|
|
53
60
|
export type AtomName = (typeof ATOM_NAMES)[number];
|
|
54
61
|
/** The default atoms' `data-slot` values: prefixed, like the grid's. */
|
|
55
62
|
export declare const ATOM_SLOTS: readonly ["vk-row", "vk-row-content", "vk-tick", "vk-status", "vk-marker", "vk-tag", "vk-list", "vk-command-menu", "vk-relation-link", "vk-loading", "vk-load-more", "vk-platform", "vk-row-menu"];
|
|
56
63
|
export type AtomSlot = (typeof ATOM_SLOTS)[number];
|
|
64
|
+
/** The editor panel's `data-slot` values: prefixed, like the grid's. */
|
|
65
|
+
export declare const EDITOR_SLOTS: readonly ["vk-editor-panel", "vk-editor-bar", "vk-editor-refusal", "vk-text-editor"];
|
|
66
|
+
export type EditorSlot = (typeof EDITOR_SLOTS)[number];
|
|
57
67
|
/** The default atoms' states. `chosen`, `disabled`, `muted`, `checked` and `open` are
|
|
58
68
|
* flags present when true; `status` carries the slot's name. */
|
|
59
69
|
export declare const ATOM_STATES: readonly ["chosen", "disabled", "muted", "checked", "open", "status", "platform"];
|
|
@@ -108,6 +118,25 @@ export type ViewsMessage = {
|
|
|
108
118
|
values: {
|
|
109
119
|
value: string;
|
|
110
120
|
};
|
|
121
|
+
} | {
|
|
122
|
+
key: "views.editors.discard";
|
|
123
|
+
} | {
|
|
124
|
+
key: "views.editors.save";
|
|
125
|
+
} | {
|
|
126
|
+
key: "views.editors.open-email";
|
|
127
|
+
values: {
|
|
128
|
+
value: string;
|
|
129
|
+
};
|
|
130
|
+
} | {
|
|
131
|
+
key: "views.editors.open-phone";
|
|
132
|
+
values: {
|
|
133
|
+
value: string;
|
|
134
|
+
};
|
|
135
|
+
} | {
|
|
136
|
+
key: "views.editors.open-link";
|
|
137
|
+
values: {
|
|
138
|
+
value: string;
|
|
139
|
+
};
|
|
111
140
|
} | {
|
|
112
141
|
key: "views.editors.place-country";
|
|
113
142
|
} | {
|
|
@@ -319,6 +348,11 @@ export type ViewsMessage = {
|
|
|
319
348
|
key: "views.grid.cell-read-only";
|
|
320
349
|
} | {
|
|
321
350
|
key: "views.grid.clear-none";
|
|
351
|
+
} | {
|
|
352
|
+
key: "views.grid.clear-required";
|
|
353
|
+
values: {
|
|
354
|
+
fields: string;
|
|
355
|
+
};
|
|
322
356
|
} | {
|
|
323
357
|
key: "views.grid.write-not-list";
|
|
324
358
|
} | {
|
|
@@ -443,6 +477,13 @@ export type ViewsMessage = {
|
|
|
443
477
|
};
|
|
444
478
|
} | {
|
|
445
479
|
key: "views.display.phone-as-typed";
|
|
480
|
+
} | {
|
|
481
|
+
key: "views.display.converted-from";
|
|
482
|
+
values: {
|
|
483
|
+
code: string;
|
|
484
|
+
};
|
|
485
|
+
} | {
|
|
486
|
+
key: "views.display.as-shown";
|
|
446
487
|
};
|
|
447
488
|
export type ViewsMessageKey = ViewsMessage["key"];
|
|
448
489
|
/** A place's word, as a message key: the region, city or postal-code word a country's format names
|
|
@@ -452,7 +493,7 @@ export type PlaceWordKey = Extract<ViewsMessageKey, `views.editors.place-${"regi
|
|
|
452
493
|
export declare function placeWordKey(kind: "region", word: RegionWord): PlaceWordKey;
|
|
453
494
|
export declare function placeWordKey(kind: "city", word: CityWord): PlaceWordKey;
|
|
454
495
|
export declare function placeWordKey(kind: "postal", word: PostalWord): PlaceWordKey;
|
|
455
|
-
export declare const VIEWS_MESSAGE_KEYS: readonly ["views.editors.tag-remove", "views.editors.marker-resolve", "views.editors.marker-no-reason", "views.editors.range-low", "views.editors.range-high", "views.editors.name-given", "views.editors.name-family", "views.editors.name-full", "views.editors.values-add", "views.editors.values-label", "views.editors.values-main", "views.editors.values-make-main", "views.editors.values-remove", "views.editors.place-country", "views.editors.place-country-search", "views.editors.place-change-country", "views.editors.place-region-search", "views.editors.place-line1", "views.editors.place-line2", "views.editors.place-region-area", "views.editors.place-region-county", "views.editors.place-region-department", "views.editors.place-region-district", "views.editors.place-region-do-si", "views.editors.place-region-emirate", "views.editors.place-region-island", "views.editors.place-region-oblast", "views.editors.place-region-parish", "views.editors.place-region-prefecture", "views.editors.place-region-province", "views.editors.place-region-state", "views.editors.place-city-city", "views.editors.place-city-district", "views.editors.place-city-post-town", "views.editors.place-city-suburb", "views.editors.place-postal-eircode", "views.editors.place-postal-pin", "views.editors.place-postal-postal", "views.editors.place-postal-zip", "views.editors.place-required", "views.editors.place-region", "views.menus.part-row", "views.menus.sort-asc", "views.menus.sort-desc", "views.menus.sort-clear", "views.menus.group-by", "views.menus.ungroup", "views.menus.move-left", "views.menus.move-right", "views.menus.hide-column", "views.menus.format", "views.menus.date-style", "views.menus.show-time", "views.menus.duration-style", "views.menus.decimals", "views.menus.automatic", "views.menus.currency", "views.menus.percent-display", "views.menus.percent-display-option", "views.menus.colour", "views.menus.colours-reset", "views.menus.group-options", "views.menus.group-sort", "views.menus.search", "views.menus.group-show", "views.menus.group-count", "views.menus.group-hide", "views.menus.add-column-search", "views.menus.add-column-no-match", "views.menus.add-column-all-shown", "views.menus.copy", "views.menus.cut", "views.menus.paste", "views.menus.clear", "views.menus.edit", "views.menus.row-open", "views.menus.row-select", "views.menus.row-delete", "views.menus.row-delete-confirm", "views.menus.row-delete-failed", "views.grid.figure", "views.grid.figure-pick", "views.grid.add-column", "views.grid.loading", "views.grid.select-row", "views.grid.select-group", "views.grid.select-all", "views.grid.row-menu", "views.grid.group-expand", "views.grid.group-collapse", "views.grid.change-value", "views.grid.value", "views.grid.edit-value", "views.grid.read-only", "views.grid.read-only-why", "views.grid.locked", "views.grid.not-clearable", "views.grid.computed", "views.grid.cell-read-only", "views.grid.clear-none", "views.grid.write-not-list", "views.grid.write-not-boolean", "views.grid.write-marker", "views.grid.write-not-email", "views.grid.write-not-url", "views.grid.write-not-link", "views.grid.write-not-linkable", "views.grid.paste-refused", "views.grid.paste-empty", "views.grid.paste-not-number", "views.grid.paste-not-duration", "views.grid.paste-not-date", "views.grid.paste-not-option", "views.grid.paste-ambiguous-option", "views.grid.paste-other-currency", "views.grid.paste-pick", "views.grid.paste-not-linkable", "views.grid.paste-not-range", "views.grid.paste-skipped", "views.grid.fill-skipped", "views.grid.changed-elsewhere", "views.grid.changed-elsewhere-cells", "views.grid.saved-value", "views.grid.saved-values", "views.grid.row-left", "views.display.just-now", "views.display.in", "views.display.today", "views.display.yesterday", "views.display.tomorrow", "views.display.month", "views.display.not-an-option", "views.display.needs-attention", "views.display.boolean", "views.display.show-all", "views.display.show-more", "views.display.show-less", "views.display.phone-extension", "views.display.phone-as-typed"];
|
|
496
|
+
export declare const VIEWS_MESSAGE_KEYS: readonly ["views.editors.tag-remove", "views.editors.marker-resolve", "views.editors.marker-no-reason", "views.editors.range-low", "views.editors.range-high", "views.editors.name-given", "views.editors.name-family", "views.editors.name-full", "views.editors.values-add", "views.editors.values-label", "views.editors.values-main", "views.editors.values-make-main", "views.editors.values-remove", "views.editors.discard", "views.editors.save", "views.editors.open-email", "views.editors.open-phone", "views.editors.open-link", "views.editors.place-country", "views.editors.place-country-search", "views.editors.place-change-country", "views.editors.place-region-search", "views.editors.place-line1", "views.editors.place-line2", "views.editors.place-region-area", "views.editors.place-region-county", "views.editors.place-region-department", "views.editors.place-region-district", "views.editors.place-region-do-si", "views.editors.place-region-emirate", "views.editors.place-region-island", "views.editors.place-region-oblast", "views.editors.place-region-parish", "views.editors.place-region-prefecture", "views.editors.place-region-province", "views.editors.place-region-state", "views.editors.place-city-city", "views.editors.place-city-district", "views.editors.place-city-post-town", "views.editors.place-city-suburb", "views.editors.place-postal-eircode", "views.editors.place-postal-pin", "views.editors.place-postal-postal", "views.editors.place-postal-zip", "views.editors.place-required", "views.editors.place-region", "views.menus.part-row", "views.menus.sort-asc", "views.menus.sort-desc", "views.menus.sort-clear", "views.menus.group-by", "views.menus.ungroup", "views.menus.move-left", "views.menus.move-right", "views.menus.hide-column", "views.menus.format", "views.menus.date-style", "views.menus.show-time", "views.menus.duration-style", "views.menus.decimals", "views.menus.automatic", "views.menus.currency", "views.menus.percent-display", "views.menus.percent-display-option", "views.menus.colour", "views.menus.colours-reset", "views.menus.group-options", "views.menus.group-sort", "views.menus.search", "views.menus.group-show", "views.menus.group-count", "views.menus.group-hide", "views.menus.add-column-search", "views.menus.add-column-no-match", "views.menus.add-column-all-shown", "views.menus.copy", "views.menus.cut", "views.menus.paste", "views.menus.clear", "views.menus.edit", "views.menus.row-open", "views.menus.row-select", "views.menus.row-delete", "views.menus.row-delete-confirm", "views.menus.row-delete-failed", "views.grid.figure", "views.grid.figure-pick", "views.grid.add-column", "views.grid.loading", "views.grid.select-row", "views.grid.select-group", "views.grid.select-all", "views.grid.row-menu", "views.grid.group-expand", "views.grid.group-collapse", "views.grid.change-value", "views.grid.value", "views.grid.edit-value", "views.grid.read-only", "views.grid.read-only-why", "views.grid.locked", "views.grid.not-clearable", "views.grid.computed", "views.grid.cell-read-only", "views.grid.clear-none", "views.grid.clear-required", "views.grid.write-not-list", "views.grid.write-not-boolean", "views.grid.write-marker", "views.grid.write-not-email", "views.grid.write-not-url", "views.grid.write-not-link", "views.grid.write-not-linkable", "views.grid.paste-refused", "views.grid.paste-empty", "views.grid.paste-not-number", "views.grid.paste-not-duration", "views.grid.paste-not-date", "views.grid.paste-not-option", "views.grid.paste-ambiguous-option", "views.grid.paste-other-currency", "views.grid.paste-pick", "views.grid.paste-not-linkable", "views.grid.paste-not-range", "views.grid.paste-skipped", "views.grid.fill-skipped", "views.grid.changed-elsewhere", "views.grid.changed-elsewhere-cells", "views.grid.saved-value", "views.grid.saved-values", "views.grid.row-left", "views.display.just-now", "views.display.in", "views.display.today", "views.display.yesterday", "views.display.tomorrow", "views.display.month", "views.display.not-an-option", "views.display.needs-attention", "views.display.boolean", "views.display.show-all", "views.display.show-more", "views.display.show-less", "views.display.phone-extension", "views.display.phone-as-typed", "views.display.converted-from", "views.display.as-shown"];
|
|
456
497
|
/** What an app hands in: its wording for every message. A resolver that words
|
|
457
498
|
* only some keys calls `resolveViewsMessage` for the rest; the provider does not. */
|
|
458
499
|
export type ViewsMessageResolver = (message: ViewsMessage) => string;
|
package/dist/contract.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
export const VK_PREFIX = "vk";
|
|
2
2
|
export const GRID_SLOTS = [
|
|
3
3
|
"vk-grid",
|
|
4
|
+
"vk-grid-scroll",
|
|
5
|
+
"vk-grid-head",
|
|
4
6
|
"vk-grid-header",
|
|
5
7
|
"vk-grid-header-cell",
|
|
6
8
|
"vk-grid-row",
|
|
9
|
+
"vk-grid-rows",
|
|
10
|
+
"vk-grid-gap",
|
|
7
11
|
"vk-grid-cell",
|
|
8
12
|
"vk-grid-group",
|
|
13
|
+
"vk-grid-group-head",
|
|
9
14
|
"vk-grid-group-header",
|
|
10
15
|
"vk-grid-footer",
|
|
11
16
|
"vk-grid-footer-cell",
|
|
@@ -41,10 +46,7 @@ export const VK_TOKENS = [
|
|
|
41
46
|
"--vk-footer-h",
|
|
42
47
|
"--vk-label-h",
|
|
43
48
|
"--vk-line-h",
|
|
44
|
-
"--vk-chrome-h",
|
|
45
49
|
"--vk-px",
|
|
46
|
-
"--vk-cell-py",
|
|
47
|
-
"--vk-tail-py",
|
|
48
50
|
"--vk-tail-pl",
|
|
49
51
|
"--vk-rail-w",
|
|
50
52
|
"--vk-rail-gap",
|
|
@@ -99,8 +101,8 @@ export const VK_OPTIONAL_COLOURS = [
|
|
|
99
101
|
"--vk-label-pink",
|
|
100
102
|
"--vk-label-teal",
|
|
101
103
|
];
|
|
102
|
-
export const VK_OPTIONAL_LAYOUT = ["--vk-gutter", "--vk-
|
|
103
|
-
export const VK_INTERNAL = ["--vk-drag-shift"];
|
|
104
|
+
export const VK_OPTIONAL_LAYOUT = ["--vk-gutter", "--vk-scroll-inset-bottom"];
|
|
105
|
+
export const VK_INTERNAL = ["--vk-drag-shift", "--vk-cols"];
|
|
104
106
|
export const VK_INTERNAL_FAMILIES = ["--vk-col-w-"];
|
|
105
107
|
export const COMPONENT_NAMES = [
|
|
106
108
|
"Button",
|
|
@@ -115,6 +117,7 @@ export const COMPONENT_NAMES = [
|
|
|
115
117
|
"AppIcon",
|
|
116
118
|
"Markdown",
|
|
117
119
|
];
|
|
120
|
+
export const OPTIONAL_COMPONENT_NAMES = ["Input"];
|
|
118
121
|
export const ATOM_NAMES = ["Row", "RowContent", "TickBox", "StatusBadge", "StatusMarker", "Tag", "List", "CommandMenu", "RelationLink", "Loading", "LoadMore", "PlatformMark", "RowMenu"];
|
|
119
122
|
export const ATOM_SLOTS = [
|
|
120
123
|
"vk-row",
|
|
@@ -131,6 +134,7 @@ export const ATOM_SLOTS = [
|
|
|
131
134
|
"vk-platform",
|
|
132
135
|
"vk-row-menu",
|
|
133
136
|
];
|
|
137
|
+
export const EDITOR_SLOTS = ["vk-editor-panel", "vk-editor-bar", "vk-editor-refusal", "vk-text-editor"];
|
|
134
138
|
export const ATOM_STATES = ["chosen", "disabled", "muted", "checked", "open", "status", "platform"];
|
|
135
139
|
export const PORT_NAMES = ["toast", "haptics", "clipboard", "viewPrefs", "confirm"];
|
|
136
140
|
export const ICON_NAMES = [
|
|
@@ -219,6 +223,11 @@ export const VIEWS_MESSAGE_KEYS = [
|
|
|
219
223
|
"views.editors.values-main",
|
|
220
224
|
"views.editors.values-make-main",
|
|
221
225
|
"views.editors.values-remove",
|
|
226
|
+
"views.editors.discard",
|
|
227
|
+
"views.editors.save",
|
|
228
|
+
"views.editors.open-email",
|
|
229
|
+
"views.editors.open-phone",
|
|
230
|
+
"views.editors.open-link",
|
|
222
231
|
"views.editors.place-country",
|
|
223
232
|
"views.editors.place-country-search",
|
|
224
233
|
"views.editors.place-change-country",
|
|
@@ -306,6 +315,7 @@ export const VIEWS_MESSAGE_KEYS = [
|
|
|
306
315
|
"views.grid.computed",
|
|
307
316
|
"views.grid.cell-read-only",
|
|
308
317
|
"views.grid.clear-none",
|
|
318
|
+
"views.grid.clear-required",
|
|
309
319
|
"views.grid.write-not-list",
|
|
310
320
|
"views.grid.write-not-boolean",
|
|
311
321
|
"views.grid.write-marker",
|
|
@@ -345,6 +355,8 @@ export const VIEWS_MESSAGE_KEYS = [
|
|
|
345
355
|
"views.display.show-less",
|
|
346
356
|
"views.display.phone-extension",
|
|
347
357
|
"views.display.phone-as-typed",
|
|
358
|
+
"views.display.converted-from",
|
|
359
|
+
"views.display.as-shown",
|
|
348
360
|
];
|
|
349
361
|
const _everyKeyListed = true;
|
|
350
362
|
void _everyKeyListed;
|
|
@@ -425,6 +437,16 @@ export function resolveViewsMessage(message) {
|
|
|
425
437
|
return `Make ${message.values.value} the main one`;
|
|
426
438
|
case "views.editors.values-remove":
|
|
427
439
|
return `Remove ${message.values.value}`;
|
|
440
|
+
case "views.editors.discard":
|
|
441
|
+
return "Discard";
|
|
442
|
+
case "views.editors.save":
|
|
443
|
+
return "Save";
|
|
444
|
+
case "views.editors.open-email":
|
|
445
|
+
return `Email ${message.values.value}`;
|
|
446
|
+
case "views.editors.open-phone":
|
|
447
|
+
return `Call ${message.values.value}`;
|
|
448
|
+
case "views.editors.open-link":
|
|
449
|
+
return `Open ${message.values.value}`;
|
|
428
450
|
case "views.editors.place-country":
|
|
429
451
|
return "Country";
|
|
430
452
|
case "views.editors.place-country-search":
|
|
@@ -599,6 +621,8 @@ export function resolveViewsMessage(message) {
|
|
|
599
621
|
return "Cell is read-only";
|
|
600
622
|
case "views.grid.clear-none":
|
|
601
623
|
return "Nothing in this selection can be emptied — the fields are required";
|
|
624
|
+
case "views.grid.clear-required":
|
|
625
|
+
return `Not emptied: ${message.values.fields} can't be empty`;
|
|
602
626
|
case "views.grid.write-not-list":
|
|
603
627
|
return "Not a list of values";
|
|
604
628
|
case "views.grid.write-not-boolean":
|
|
@@ -678,5 +702,9 @@ export function resolveViewsMessage(message) {
|
|
|
678
702
|
return `ext. ${message.values.extension}`;
|
|
679
703
|
case "views.display.phone-as-typed":
|
|
680
704
|
return "Not yet in international form";
|
|
705
|
+
case "views.display.converted-from":
|
|
706
|
+
return `Converted from ${message.values.code}`;
|
|
707
|
+
case "views.display.as-shown":
|
|
708
|
+
return "as shown";
|
|
681
709
|
}
|
|
682
710
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A MONEY FIGURE SHOWN IN ANOTHER CURRENCY THAN ITS RECORD'S OWN. A surface reading a money column in a chosen
|
|
4
|
+
* currency draws the converted amount, while every editor opens on the amount the record stores, in the record's
|
|
5
|
+
* own currency. These two pieces are how the two read as one value, drawn the same way on every surface: the
|
|
6
|
+
* figure carries ≈ and a title naming the currency it came from, and the editor names the figure under the amount
|
|
7
|
+
* it opens on. `convertedFromOf` says when a column's figure is converted.
|
|
8
|
+
*/
|
|
9
|
+
/** The figure, marked: ≈ before it, and a title naming the currency it was converted from. */
|
|
10
|
+
export declare function ConvertedFigure({ from, children }: {
|
|
11
|
+
from: string;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}): ReactNode;
|
|
14
|
+
/** Under a money editor: the figure as the surface showed it, so the amount being edited and the one the person
|
|
15
|
+
* clicked read as one value. `figure` is the marked figure. */
|
|
16
|
+
export declare function ConversionLine({ figure, className }: {
|
|
17
|
+
figure: ReactNode;
|
|
18
|
+
className?: string;
|
|
19
|
+
}): ReactNode;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cx } from "../internal/cx.js";
|
|
4
|
+
import { useViews } from "../provider/context.js";
|
|
5
|
+
export function ConvertedFigure({ from, children }) {
|
|
6
|
+
const { messages } = useViews();
|
|
7
|
+
return (_jsxs("span", { "data-converted": "", title: messages({ key: "views.display.converted-from", values: { code: from } }), className: "inline-flex min-w-0 max-w-full items-baseline gap-1 whitespace-nowrap", children: [_jsx("span", { className: "text-(color:--vk-fg-subtle)", children: "\u2248" }), children] }));
|
|
8
|
+
}
|
|
9
|
+
export function ConversionLine({ figure, className }) {
|
|
10
|
+
const { messages } = useViews();
|
|
11
|
+
return (_jsxs("p", { "data-slot": "vk-conversion", className: cx("flex items-baseline gap-1 text-xs text-(color:--vk-fg-subtle)", className), children: [figure, _jsx("span", { children: messages({ key: "views.display.as-shown" }) })] }));
|
|
12
|
+
}
|
package/dist/display/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export { CellSuffix, DEFAULT_FIELD_PRESENTATION, formatDateValue, formatMoney, f
|
|
|
5
5
|
export { viewerFrom } from "./viewer.js";
|
|
6
6
|
export { cellTextClass } from "./text-class.js";
|
|
7
7
|
export { MultiValueCell } from "./multi-value.js";
|
|
8
|
+
export { ConversionLine, ConvertedFigure } from "./converted.js";
|
|
8
9
|
export { CHIP_BASE, CHIP_INTERACTIVE } from "../internal/chip.js";
|
package/dist/display/index.js
CHANGED
|
@@ -4,4 +4,5 @@ export { CellSuffix, DEFAULT_FIELD_PRESENTATION, formatDateValue, formatMoney, f
|
|
|
4
4
|
export { viewerFrom } from "./viewer.js";
|
|
5
5
|
export { cellTextClass } from "./text-class.js";
|
|
6
6
|
export { MultiValueCell } from "./multi-value.js";
|
|
7
|
+
export { ConversionLine, ConvertedFigure } from "./converted.js";
|
|
7
8
|
export { CHIP_BASE, CHIP_INTERACTIVE } from "../internal/chip.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DisplayOptions } from "./options.js";
|
|
2
|
+
/**
|
|
3
|
+
* A link whose plain click the host owns (`hostOwnsPlainClick`, the grid): marked as the cell's own, so the host
|
|
4
|
+
* tells it from a control, and not draggable, so a press on it is never the browser's link drag. Such a link carries no `data-no-nav`
|
|
5
|
+
* and stops no click: the click reaches the host, which follows the link only on a ⌘- or Ctrl-click. Null where the
|
|
6
|
+
* link owns its click, as by default.
|
|
7
|
+
*/
|
|
8
|
+
export declare function cellLinkProps(opts: DisplayOptions | undefined): {
|
|
9
|
+
"data-cell-link": "";
|
|
10
|
+
draggable: false;
|
|
11
|
+
} | null;
|
package/dist/display/link.js
CHANGED
|
@@ -4,6 +4,7 @@ import { useContext } from "react";
|
|
|
4
4
|
import { linkPlatform } from "@viewkitjs/fields";
|
|
5
5
|
import { cx } from "../internal/cx.js";
|
|
6
6
|
import { ViewsContext } from "../provider/context.js";
|
|
7
|
+
import { cellLinkProps } from "./link-click.js";
|
|
7
8
|
import { cellTextClass } from "./text-class.js";
|
|
8
9
|
import { renderValueList } from "./value-list.js";
|
|
9
10
|
import { webHref } from "./web-href.js";
|
|
@@ -19,7 +20,7 @@ function WebAddress({ address, opts }) {
|
|
|
19
20
|
const views = useContext(ViewsContext);
|
|
20
21
|
const label = address.replace(/^https?:\/\//, "");
|
|
21
22
|
const href = webHref(address);
|
|
22
|
-
const link = opts?.slotOwnsClick || href === null ? (_jsx("span", { className: cellTextClass(opts?.wrap), children: label })) : (_jsx("a", { href: href, target: "_blank", rel: "noopener noreferrer", "data-no-nav": true, className: cx(cellTextClass(opts?.wrap), "text-(color:--vk-fg-brand) hover:underline"), children: label }));
|
|
23
|
+
const link = opts?.slotOwnsClick || href === null ? (_jsx("span", { className: cellTextClass(opts?.wrap), children: label })) : (_jsx("a", { href: href, target: "_blank", rel: "noopener noreferrer", ...(cellLinkProps(opts) ?? { "data-no-nav": true }), className: cx(cellTextClass(opts?.wrap), "text-(color:--vk-fg-brand) hover:underline"), children: label }));
|
|
23
24
|
const platform = views && href !== null ? linkPlatform(address, views.conventions) : null;
|
|
24
25
|
if (!platform || !views)
|
|
25
26
|
return link;
|
|
@@ -34,7 +35,7 @@ function domainLink(domain, opts) {
|
|
|
34
35
|
const href = webHref(domain);
|
|
35
36
|
if (opts?.slotOwnsClick || href === null)
|
|
36
37
|
return _jsx("span", { className: cellTextClass(opts?.wrap), children: domain });
|
|
37
|
-
return (_jsx("a", { href: href, target: "_blank", rel: "noopener noreferrer", "data-no-nav": true, className: cx(cellTextClass(opts?.wrap), "text-(color:--vk-fg-brand) hover:underline"), children: domain }));
|
|
38
|
+
return (_jsx("a", { href: href, target: "_blank", rel: "noopener noreferrer", ...(cellLinkProps(opts) ?? { "data-no-nav": true }), className: cx(cellTextClass(opts?.wrap), "text-(color:--vk-fg-brand) hover:underline"), children: domain }));
|
|
38
39
|
}
|
|
39
40
|
export function renderEmail(_field, value, opts) {
|
|
40
41
|
if (Array.isArray(value))
|
|
@@ -46,5 +47,8 @@ export function renderEmail(_field, value, opts) {
|
|
|
46
47
|
function renderEmailAddress(address, opts) {
|
|
47
48
|
if (opts?.slotOwnsClick)
|
|
48
49
|
return _jsx("span", { children: address });
|
|
49
|
-
return (_jsx("a", { href: `mailto:${address}`,
|
|
50
|
+
return (_jsx("a", { href: `mailto:${address}`, ...(cellLinkProps(opts) ?? {
|
|
51
|
+
"data-no-nav": true,
|
|
52
|
+
onClick: (event) => event.stopPropagation(),
|
|
53
|
+
}), className: "text-(color:--vk-fg) underline decoration-dotted decoration-(color:--vk-fg-subtle)/40 decoration-1 underline-offset-[3px] transition-colors hover:decoration-(color:--vk-fg-subtle)/60", children: address }));
|
|
50
54
|
}
|
|
@@ -6,7 +6,7 @@ export declare function MultiValueCell({ items, details, wrap, title, slotOwnsCl
|
|
|
6
6
|
items: ReactNode[];
|
|
7
7
|
/** One word per value drawn beside it in the popover (a value's label), never in the cell. */
|
|
8
8
|
details?: (string | null)[];
|
|
9
|
-
/**
|
|
9
|
+
/** Whether the values may flow onto more rows. BINARY here, unlike `DisplayOptions.wrap`
|
|
10
10
|
* — a chip list either flows onto more rows or does not; there is no
|
|
11
11
|
* uncapped state to ask for, because the overflow is a count, not a clip. */
|
|
12
12
|
wrap?: boolean;
|
|
@@ -15,7 +15,7 @@ export function MultiValueCell({ items, details, wrap, title, slotOwnsClick, })
|
|
|
15
15
|
return null;
|
|
16
16
|
const shown = items.slice(0, wrap ? VISIBLE_WRAPPED : VISIBLE_FLAT);
|
|
17
17
|
const hidden = items.length - shown.length;
|
|
18
|
-
const content = (_jsxs("span", { ref: anchor, className: cx("flex min-w-0 items-center gap-1", wrap && "flex-wrap gap-y-0.5"), title: title, children: [shown.map((item, index) => (_jsx("span", { className: "flex min-w-0 items-center truncate", children: item }, index))), hidden > 0 &&
|
|
18
|
+
const content = (_jsxs("span", { ref: anchor, className: cx("flex min-w-0 items-center gap-1", wrap && "flex-wrap gap-y-0.5"), title: title, children: [shown.map((item, index) => (_jsx("span", { className: "flex min-w-0 items-center truncate *:min-w-0 *:truncate", children: typeof item === "string" || typeof item === "number" ? _jsx("span", { children: item }) : item }, index))), hidden > 0 &&
|
|
19
19
|
(slotOwnsClick ? (_jsxs("span", { className: "shrink-0 text-[10px] leading-[0.9rem] text-(color:--vk-fg-subtle)", children: ["+", hidden] })) : (_jsxs("button", { ref: trigger, type: "button", tabIndex: -1, "data-no-nav": true, "aria-label": messages({ key: "views.display.show-all", values: { count: items.length } }), "aria-haspopup": "dialog", "aria-expanded": open, onClick: (event) => {
|
|
20
20
|
event.stopPropagation();
|
|
21
21
|
setOpen((current) => !current);
|
|
@@ -114,7 +114,7 @@ export type DisplayOptions = {
|
|
|
114
114
|
/** percent: the workspace's display choice — wins over the field's `format.display`. */
|
|
115
115
|
percentDisplay?: PercentDisplay;
|
|
116
116
|
/**
|
|
117
|
-
* The
|
|
117
|
+
* The host's wrap: text-bearing values clamp to three lines instead of
|
|
118
118
|
* truncating. `"full"` is the third state — the whole value, newlines kept,
|
|
119
119
|
* no cap — which only a host with room asks for (`FieldRow`, for a
|
|
120
120
|
* `format.long` text field). See `cellTextClass`.
|
|
@@ -150,4 +150,10 @@ export type DisplayOptions = {
|
|
|
150
150
|
* shows its glyph with no toggle. Set once by the host, never per field.
|
|
151
151
|
*/
|
|
152
152
|
slotOwnsClick?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* A host whose plain click on a value is its own — the grid, where a click selects the cell. An email, a phone,
|
|
155
|
+
* a url and a domain still draw as links, marked `data-cell-link`, but no longer stop the click: it reaches the
|
|
156
|
+
* host, which follows the link only on a ⌘- or Ctrl-click. Set once by the host, never per field.
|
|
157
|
+
*/
|
|
158
|
+
hostOwnsPlainClick?: boolean;
|
|
153
159
|
};
|
package/dist/display/phone.js
CHANGED
|
@@ -4,6 +4,7 @@ import { phoneHref, phoneText, readPhone } from "@viewkitjs/fields/phone";
|
|
|
4
4
|
import { resolveViewsMessage } from "../contract.js";
|
|
5
5
|
import { cx } from "../internal/cx.js";
|
|
6
6
|
import { CHIP_INTERACTIVE } from "../internal/chip.js";
|
|
7
|
+
import { cellLinkProps } from "./link-click.js";
|
|
7
8
|
import { cellTextClass } from "./text-class.js";
|
|
8
9
|
import { useDisplayOptions } from "./use-display-options.js";
|
|
9
10
|
import { renderValueList } from "./value-list.js";
|
|
@@ -41,5 +42,6 @@ function phoneNode(value, opts) {
|
|
|
41
42
|
if (opts?.slotOwnsClick) {
|
|
42
43
|
return (_jsx("span", { className: cellTextClass(opts?.wrap), ...asTyped, children: text }));
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
+
const owned = cellLinkProps(opts);
|
|
46
|
+
return (_jsx("a", { href: phoneHref(value) ?? undefined, ...(owned ?? { "data-no-nav": true, onClick: (event) => event.stopPropagation() }), className: CHIP_INTERACTIVE, ...asTyped, children: _jsx("span", { className: cx("min-w-0", cellTextClass(opts?.wrap)), children: text }) }));
|
|
45
47
|
}
|