@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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type GridClipboardCell, type GridPasteSource } from "./clipboard-model.js";
|
|
2
|
+
import { type ListSettingsConfig } from "../../model/column-capabilities.js";
|
|
2
3
|
import { type ViewsMessageResolver } from "../../contract.js";
|
|
3
4
|
import type { FieldConventions } from "@viewkitjs/fields";
|
|
4
5
|
import type { ListColumn } from "../../model/column-schema.js";
|
|
@@ -42,6 +43,9 @@ export type GridSpreadsheetModel<Row> = {
|
|
|
42
43
|
conventions: FieldConventions;
|
|
43
44
|
/** The app's words (the provider's): a refused paste says why in them. */
|
|
44
45
|
messages?: ViewsMessageResolver;
|
|
46
|
+
/** The list's settings (the grid's `listConfig`): a column they lock takes no write from a
|
|
47
|
+
* clear, a paste or a fill, and is refused in the sentence an edit of one cell says. */
|
|
48
|
+
listConfig?: ListSettingsConfig;
|
|
45
49
|
};
|
|
46
50
|
type GridPlannedEdit<Row> = GridEditCell<Row> & {
|
|
47
51
|
row: Row;
|
|
@@ -52,8 +56,20 @@ export type GridRefusal = {
|
|
|
52
56
|
count: number;
|
|
53
57
|
};
|
|
54
58
|
export declare function buildGridCopyMatrix<Row>(model: GridSpreadsheetModel<Row>, rect: GridCellRect): GridClipboardCell[][];
|
|
59
|
+
/** Does the rect hold a column that may be emptied, by its declaration? The list's locks are
|
|
60
|
+
* not asked here: a rect of only locked columns plans a clear, and the plan says the lock,
|
|
61
|
+
* rather than "the fields are required". */
|
|
55
62
|
export declare function gridRectHasClearable<Row>(columns: readonly ListColumn<Row>[], rect: GridCellRect): boolean;
|
|
56
|
-
|
|
63
|
+
type GridClearPlan<Row> = {
|
|
64
|
+
edits: GridPlannedEdit<Row>[];
|
|
65
|
+
/** The cells the list's locks refused, one entry per locked column. A column that can't be
|
|
66
|
+
* written or emptied by its declaration is passed over without a word, as it always was. */
|
|
67
|
+
refusals: GridRefusal[];
|
|
68
|
+
/** The fields the clear left as they were because they can't be empty: each writable, unlocked column of the
|
|
69
|
+
* selection that isn't clearable and holds a value in at least one of its rows, by label, in column order. */
|
|
70
|
+
required: string[];
|
|
71
|
+
};
|
|
72
|
+
export declare function planGridClear<Row>(model: GridSpreadsheetModel<Row>, rect: GridCellRect): GridClearPlan<Row>;
|
|
57
73
|
type GridPastePlan<Row> = {
|
|
58
74
|
edits: GridPlannedEdit<Row>[];
|
|
59
75
|
skipped: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cellClearPrev, cellCopyText, cellEditBaseline, cellPrevPayload, coercePaste, gridPasteOverlay, pasteUnit, rowHoldsCurrency, } from "./clipboard-model.js";
|
|
2
|
-
import { gridBooleanMode,
|
|
2
|
+
import { gridBooleanMode, columnEffectiveWritable, columnLabel, columnWritable, gridColumnLocked, gridEditRefusal, } from "../../model/column-capabilities.js";
|
|
3
3
|
import { resolveViewsMessage } from "../../contract.js";
|
|
4
4
|
import { gridRectIsMulti, resolveCellRect, } from "./coordinates.js";
|
|
5
5
|
import { resolveActiveRangeRect } from "./range-model.js";
|
|
@@ -11,6 +11,11 @@ function addRefusal(refusals, reason) {
|
|
|
11
11
|
else
|
|
12
12
|
refusals.push({ reason, count: 1 });
|
|
13
13
|
}
|
|
14
|
+
function cellRefusal(model, col) {
|
|
15
|
+
const messages = model.messages ?? resolveViewsMessage;
|
|
16
|
+
return ((col && gridEditRefusal(col, model.listConfig, model.conventions, messages)) ||
|
|
17
|
+
messages({ key: "views.grid.cell-read-only" }));
|
|
18
|
+
}
|
|
14
19
|
export function buildGridCopyMatrix(model, rect) {
|
|
15
20
|
const matrix = [];
|
|
16
21
|
for (let r = rect.r1; r <= rect.r2; r++) {
|
|
@@ -43,8 +48,13 @@ export function gridRectHasClearable(columns, rect) {
|
|
|
43
48
|
}
|
|
44
49
|
return false;
|
|
45
50
|
}
|
|
51
|
+
function holdsNothing(value) {
|
|
52
|
+
return value == null || value === "" || (Array.isArray(value) && value.length === 0);
|
|
53
|
+
}
|
|
46
54
|
export function planGridClear(model, rect) {
|
|
47
55
|
const edits = [];
|
|
56
|
+
const refusals = [];
|
|
57
|
+
const required = new Set();
|
|
48
58
|
for (let r = rect.r1; r <= rect.r2; r++) {
|
|
49
59
|
const entry = model.rowByKey.get(model.visibleRowIds[r]);
|
|
50
60
|
if (entry == null)
|
|
@@ -54,8 +64,16 @@ export function planGridClear(model, rect) {
|
|
|
54
64
|
const col = model.visibleColumns[c];
|
|
55
65
|
if (!col || !columnWritable(col))
|
|
56
66
|
continue;
|
|
57
|
-
if (!col.clearable && !gridBooleanMode(col))
|
|
67
|
+
if (!col.clearable && !gridBooleanMode(col)) {
|
|
68
|
+
const held = cellEditBaseline(col, row, model.pendingByRow.get(rowId));
|
|
69
|
+
if (!gridColumnLocked(col, model.listConfig) && !holdsNothing(held))
|
|
70
|
+
required.add(c);
|
|
58
71
|
continue;
|
|
72
|
+
}
|
|
73
|
+
if (gridColumnLocked(col, model.listConfig)) {
|
|
74
|
+
addRefusal(refusals, cellRefusal(model, col));
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
59
77
|
edits.push({
|
|
60
78
|
row,
|
|
61
79
|
rowId,
|
|
@@ -67,7 +85,11 @@ export function planGridClear(model, rect) {
|
|
|
67
85
|
});
|
|
68
86
|
}
|
|
69
87
|
}
|
|
70
|
-
return
|
|
88
|
+
return {
|
|
89
|
+
edits,
|
|
90
|
+
refusals,
|
|
91
|
+
required: [...required].sort((a, b) => a - b).map((c) => columnLabel(model.visibleColumns[c])),
|
|
92
|
+
};
|
|
71
93
|
}
|
|
72
94
|
export function planGridPaste(model, matrix, anchor, activeRect, selectValuesByColumn) {
|
|
73
95
|
const empty = {
|
|
@@ -109,10 +131,9 @@ export function planGridPaste(model, matrix, anchor, activeRect, selectValuesByC
|
|
|
109
131
|
const row = entry?.row;
|
|
110
132
|
const rowId = entry?.rowId;
|
|
111
133
|
const col = model.visibleColumns[c];
|
|
112
|
-
if (row == null || !col || !
|
|
134
|
+
if (row == null || !col || !columnEffectiveWritable(col, model.listConfig)) {
|
|
113
135
|
skipped++;
|
|
114
|
-
|
|
115
|
-
addRefusal(refusals, (col && columnEditRefusal(col, model.conventions, messages)) || messages({ key: "views.grid.cell-read-only" }));
|
|
136
|
+
addRefusal(refusals, cellRefusal(model, col));
|
|
116
137
|
continue;
|
|
117
138
|
}
|
|
118
139
|
const coerced = coercePaste(col, source, {
|
|
@@ -121,6 +142,7 @@ export function planGridPaste(model, matrix, anchor, activeRect, selectValuesByC
|
|
|
121
142
|
currentUnit: col.editUnit?.value(row),
|
|
122
143
|
holdsCurrency: rowHoldsCurrency(col, row),
|
|
123
144
|
values: selectValuesByColumn[col.id],
|
|
145
|
+
region: col.region?.(row),
|
|
124
146
|
});
|
|
125
147
|
if (!coerced.ok) {
|
|
126
148
|
skipped++;
|
|
@@ -211,6 +233,11 @@ export function planGridFill(model, ranges, focused, targetRowId) {
|
|
|
211
233
|
const col = model.visibleColumns[c];
|
|
212
234
|
if (!col || !columnWritable(col))
|
|
213
235
|
continue;
|
|
236
|
+
if (gridColumnLocked(col, model.listConfig)) {
|
|
237
|
+
skipped++;
|
|
238
|
+
addRefusal(refusals, cellRefusal(model, col));
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
214
241
|
const sourceBaseline = cellEditBaseline(col, sourceRow, model.pendingByRow.get(sourceRowId));
|
|
215
242
|
const empty = sourceBaseline == null || sourceBaseline === "";
|
|
216
243
|
if (empty && !col.clearable && !gridBooleanMode(col))
|
|
@@ -13,6 +13,9 @@ type GridEditingApi<Row> = {
|
|
|
13
13
|
clearFocus: () => void;
|
|
14
14
|
startEdit: (rowId: string, columnId: string) => void;
|
|
15
15
|
cancelEdit: (rowId?: string, columnId?: string) => void;
|
|
16
|
+
/** Close the editor open on this cell, by its RECORD id as a commit carries it, and write nothing:
|
|
17
|
+
* the chrome refused the commit. An editor open on another cell stays open. */
|
|
18
|
+
closeEdit: (rowId: string, columnId: string) => void;
|
|
16
19
|
commitEdit: (row: Row, rowId: string, columnId: string, prev: unknown, next: unknown, opts?: {
|
|
17
20
|
overlay?: boolean;
|
|
18
21
|
}) => void;
|
|
@@ -33,11 +33,14 @@ export function useGridEditing(onCellCommit, onCellsCommit) {
|
|
|
33
33
|
? current
|
|
34
34
|
: null);
|
|
35
35
|
}, []);
|
|
36
|
-
const
|
|
36
|
+
const closeEdit = useCallback((rowId, columnId) => {
|
|
37
37
|
setEditing((current) => current != null &&
|
|
38
38
|
(gridRowIdFromKey(current.rowId) !== rowId || current.columnId !== columnId)
|
|
39
39
|
? current
|
|
40
40
|
: null);
|
|
41
|
+
}, []);
|
|
42
|
+
const commitEdit = useCallback((row, rowId, columnId, prev, next, opts) => {
|
|
43
|
+
closeEdit(rowId, columnId);
|
|
41
44
|
if (sameListValue(next, prev) || !onCellCommit)
|
|
42
45
|
return;
|
|
43
46
|
controller.commit([
|
|
@@ -53,11 +56,10 @@ export function useGridEditing(onCellCommit, onCellsCommit) {
|
|
|
53
56
|
},
|
|
54
57
|
},
|
|
55
58
|
]);
|
|
56
|
-
}, [controller, onCellCommit]);
|
|
59
|
+
}, [controller, onCellCommit, closeEdit]);
|
|
57
60
|
const commitBatch = useCallback((edits) => controller.commit(prepareGridCommitCells(edits)), [controller]);
|
|
58
61
|
const applyHistory = useCallback((kind, resolveRow, onApply) => {
|
|
59
62
|
const reveal = (pos) => {
|
|
60
|
-
setFocused(pos);
|
|
61
63
|
setEditing(null);
|
|
62
64
|
onApply?.(pos);
|
|
63
65
|
};
|
|
@@ -79,6 +81,7 @@ export function useGridEditing(onCellCommit, onCellsCommit) {
|
|
|
79
81
|
clearFocus,
|
|
80
82
|
startEdit,
|
|
81
83
|
cancelEdit,
|
|
84
|
+
closeEdit,
|
|
82
85
|
commitEdit,
|
|
83
86
|
commitBatch,
|
|
84
87
|
undo,
|
|
@@ -19,9 +19,20 @@
|
|
|
19
19
|
* is forgiving, so a server that stores a list in its own order has not
|
|
20
20
|
* overruled you and nobody is warned. That is a question about a reply, not
|
|
21
21
|
* about a field, so it stays here.
|
|
22
|
+
*
|
|
23
|
+
* A third, `sameKeptValue` at the end, reads only a value a save handed back as
|
|
24
|
+
* what it kept, by structure, so an answer that never says what it kept keeps
|
|
25
|
+
* the two rules above unchanged.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Nothing, however it is spelled: `null`, `undefined`, a blank text, an empty list. An emptied cell
|
|
29
|
+
* sends `""` and an app stores nothing as `null`, the rule `@viewkitjs/fields` reads a stored value
|
|
30
|
+
* by. A zero and a false are values.
|
|
22
31
|
*/
|
|
32
|
+
export declare function isEmptyValue(value: unknown): boolean;
|
|
23
33
|
/**
|
|
24
|
-
* The RESHAPING CHECK:
|
|
34
|
+
* The RESHAPING CHECK: one empty value for every spelling of nothing, a
|
|
35
|
+
* multiset for two arrays, the scalar rule otherwise.
|
|
25
36
|
*
|
|
26
37
|
* Order-insensitive on purpose. What comes back is the server's own storage
|
|
27
38
|
* order, and treating that as a third party's edit would put a warning on the
|
|
@@ -30,3 +41,14 @@
|
|
|
30
41
|
* `["a","a"]` and `["a","b"]` stay different.
|
|
31
42
|
*/
|
|
32
43
|
export declare function looselyEqualValue(a: unknown, b: unknown): boolean;
|
|
44
|
+
/** Note a value a save said it kept. A primitive needs no note: the rules above already read it. */
|
|
45
|
+
export declare function markGridKeptValue(value: unknown): void;
|
|
46
|
+
/** Is this overlay value one a save said it kept? */
|
|
47
|
+
export declare function isGridKeptValue(value: unknown): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* WHAT A SAVE KEPT, AGAINST WHAT THE ROWS NOW READ. The kept value is the server's own, but a fresh
|
|
50
|
+
* read hands back a new object holding it, so two plain objects are one when their keys and values
|
|
51
|
+
* are, and two lists when their items are, in any order (the format rule's own tolerance). Everything
|
|
52
|
+
* else goes by `looselyEqualValue`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function sameKeptValue(a: unknown, b: unknown): boolean;
|
|
@@ -15,7 +15,18 @@ function looselyEqualScalar(a, b) {
|
|
|
15
15
|
const rightNumber = Number(right);
|
|
16
16
|
return !Number.isNaN(leftNumber) && !Number.isNaN(rightNumber) && leftNumber === rightNumber;
|
|
17
17
|
}
|
|
18
|
+
export function isEmptyValue(value) {
|
|
19
|
+
if (value == null)
|
|
20
|
+
return true;
|
|
21
|
+
if (typeof value === "string")
|
|
22
|
+
return value.trim() === "";
|
|
23
|
+
return Array.isArray(value) && value.length === 0;
|
|
24
|
+
}
|
|
18
25
|
export function looselyEqualValue(a, b) {
|
|
26
|
+
const emptyA = isEmptyValue(a);
|
|
27
|
+
const emptyB = isEmptyValue(b);
|
|
28
|
+
if (emptyA || emptyB)
|
|
29
|
+
return emptyA && emptyB;
|
|
19
30
|
if (Array.isArray(a) || Array.isArray(b)) {
|
|
20
31
|
if (!Array.isArray(a) || !Array.isArray(b))
|
|
21
32
|
return false;
|
|
@@ -32,3 +43,38 @@ export function looselyEqualValue(a, b) {
|
|
|
32
43
|
}
|
|
33
44
|
return looselyEqualScalar(a, b);
|
|
34
45
|
}
|
|
46
|
+
const keptValues = new WeakSet();
|
|
47
|
+
export function markGridKeptValue(value) {
|
|
48
|
+
if (typeof value === "object" && value !== null)
|
|
49
|
+
keptValues.add(value);
|
|
50
|
+
}
|
|
51
|
+
export function isGridKeptValue(value) {
|
|
52
|
+
return typeof value === "object" && value !== null && keptValues.has(value);
|
|
53
|
+
}
|
|
54
|
+
const isPlainObject = (value) => typeof value === "object" &&
|
|
55
|
+
value !== null &&
|
|
56
|
+
!Array.isArray(value) &&
|
|
57
|
+
(Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
58
|
+
export function sameKeptValue(a, b) {
|
|
59
|
+
if (looselyEqualValue(a, b))
|
|
60
|
+
return true;
|
|
61
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
62
|
+
if (a.length !== b.length)
|
|
63
|
+
return false;
|
|
64
|
+
const unmatched = [...b];
|
|
65
|
+
for (const item of a) {
|
|
66
|
+
const index = unmatched.findIndex((candidate) => sameKeptValue(item, candidate));
|
|
67
|
+
if (index === -1)
|
|
68
|
+
return false;
|
|
69
|
+
unmatched.splice(index, 1);
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
if (!isPlainObject(a) || !isPlainObject(b))
|
|
74
|
+
return false;
|
|
75
|
+
const keysOf = (value) => Object.keys(value).filter((key) => value[key] !== undefined);
|
|
76
|
+
const keys = keysOf(a);
|
|
77
|
+
if (keys.length !== keysOf(b).length)
|
|
78
|
+
return false;
|
|
79
|
+
return keys.every((key) => Object.hasOwn(b, key) && sameKeptValue(a[key], b[key]));
|
|
80
|
+
}
|
|
@@ -21,7 +21,6 @@ export declare function useGridTablePrefs<Row>({ prefs, setPrefs, columns, viewB
|
|
|
21
21
|
verticalBorders: boolean;
|
|
22
22
|
showRowIcon: boolean;
|
|
23
23
|
freezeIdentity: boolean;
|
|
24
|
-
wrapCells: boolean;
|
|
25
24
|
alwaysCheckboxes: boolean;
|
|
26
25
|
scale: number;
|
|
27
26
|
optionColors: import("../model/column-schema.js").ListOptionColorOverrides;
|
|
@@ -6,7 +6,7 @@ import { normalizeGroupSummary, setAggregate, setDateStyle, setCurrency, setDeci
|
|
|
6
6
|
import { moneyReadingOf } from "../fields/money.js";
|
|
7
7
|
import { isMoneyReading, MONEY_READING_OPTIONS } from "../fields/currency.js";
|
|
8
8
|
export function useGridTablePrefs({ prefs, setPrefs, columns, viewBacked = false, }) {
|
|
9
|
-
const { gridVerticalBorders, gridRowIcon, gridFreezeIdentity,
|
|
9
|
+
const { gridVerticalBorders, gridRowIcon, gridFreezeIdentity, gridAlwaysCheckboxes, gridOptionColors, gridDateStyles, gridDurationStyles, gridShowTime, gridPercentDisplays, gridDecimals, gridCurrencies, gridAggregates, gridColumns, gridScale, groupSummary, } = prefs;
|
|
10
10
|
const onOptionColorChange = useCallback((key, value, color) => {
|
|
11
11
|
setPrefs({ gridOptionColors: setOptionColor(gridOptionColors, key, value, color) });
|
|
12
12
|
}, [gridOptionColors, setPrefs]);
|
|
@@ -48,7 +48,6 @@ export function useGridTablePrefs({ prefs, setPrefs, columns, viewBacked = false
|
|
|
48
48
|
verticalBorders: gridVerticalBorders,
|
|
49
49
|
showRowIcon: gridRowIcon,
|
|
50
50
|
freezeIdentity: gridFreezeIdentity,
|
|
51
|
-
wrapCells: gridWrapCells,
|
|
52
51
|
alwaysCheckboxes: gridAlwaysCheckboxes,
|
|
53
52
|
scale: GRID_SCALE_MULTIPLIER[gridScale],
|
|
54
53
|
optionColors: gridOptionColors,
|
|
@@ -74,7 +73,6 @@ export function useGridTablePrefs({ prefs, setPrefs, columns, viewBacked = false
|
|
|
74
73
|
gridVerticalBorders,
|
|
75
74
|
gridRowIcon,
|
|
76
75
|
gridFreezeIdentity,
|
|
77
|
-
gridWrapCells,
|
|
78
76
|
gridAlwaysCheckboxes,
|
|
79
77
|
gridScale,
|
|
80
78
|
gridOptionColors,
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export * from "./fields/money.js";
|
|
|
21
21
|
export * from "./fields/currency.js";
|
|
22
22
|
export * from "./fields/denomination.js";
|
|
23
23
|
export * from "./fields/prepare-write.js";
|
|
24
|
+
export * from "./fields/write-target.js";
|
|
24
25
|
export * from "./fields/edit-core-types.js";
|
|
25
26
|
export * from "./fields/number-edit.js";
|
|
26
27
|
export * from "./fields/format-knobs.js";
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ export * from "./fields/money.js";
|
|
|
21
21
|
export * from "./fields/currency.js";
|
|
22
22
|
export * from "./fields/denomination.js";
|
|
23
23
|
export * from "./fields/prepare-write.js";
|
|
24
|
+
export * from "./fields/write-target.js";
|
|
24
25
|
export * from "./fields/edit-core-types.js";
|
|
25
26
|
export * from "./fields/number-edit.js";
|
|
26
27
|
export * from "./fields/format-knobs.js";
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** True below 768px wide, from the first effect on; false during a server render. */
|
|
2
|
-
export declare function useIsMobile(): boolean;
|
|
3
1
|
/** True when the primary input can hover (a mouse, a trackpad); true during a server render, so
|
|
4
2
|
* the hover-capable rendering is what the server sends. */
|
|
5
3
|
export declare function useHasHover(): boolean;
|
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
|
-
const MOBILE_BREAKPOINT = 768;
|
|
4
|
-
export function useIsMobile() {
|
|
5
|
-
const [isMobile, setIsMobile] = useState(undefined);
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
8
|
-
const onChange = () => {
|
|
9
|
-
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
10
|
-
};
|
|
11
|
-
mql.addEventListener("change", onChange);
|
|
12
|
-
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
13
|
-
return () => mql.removeEventListener("change", onChange);
|
|
14
|
-
}, []);
|
|
15
|
-
return !!isMobile;
|
|
16
|
-
}
|
|
17
3
|
export function useHasHover() {
|
|
18
4
|
const [hasHover, setHasHover] = useState(true);
|
|
19
5
|
useEffect(() => {
|
|
@@ -154,7 +154,8 @@ export declare function gridNormalizeWrite<Row>(col: ListColumn<Row>, next: unkn
|
|
|
154
154
|
/** `region`: the record's country, where a phone typed without its country code is read. A host whose rows carry
|
|
155
155
|
* a country passes the row's here; absent, the conventions' region reads it. `messages`: the app's words for a
|
|
156
156
|
* refusal, the package's English when absent. `stored`: the cell's value before this edit, as stored; a value
|
|
157
|
-
* fields keeps by `stored` (a phone, a url) that comes back as it is here is kept, never read again
|
|
157
|
+
* fields keeps by `stored` (a phone, a url) that comes back as it is here is kept, never read again, and a value
|
|
158
|
+
* a closed multiselect already holds passes though no option names it. */
|
|
158
159
|
options?: {
|
|
159
160
|
region?: string | null;
|
|
160
161
|
messages?: ViewsMessageResolver;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { acceptFieldCommit, isMultipleType, lockReason, valueTypeOf } from "@viewkitjs/fields";
|
|
1
|
+
import { acceptFieldCommit, isMultipleType, lockReason, relationIdOf, valueTypeOf, } from "@viewkitjs/fields";
|
|
2
2
|
import { resolveViewsMessage } from "../contract.js";
|
|
3
3
|
import { prettifyOptionValue, resolveColumnOrder } from "./column-state.js";
|
|
4
4
|
import { typeRule } from "./column-types.js";
|
|
@@ -10,6 +10,8 @@ export function gridEditorKind(col) {
|
|
|
10
10
|
return col.field && col.type && isMultipleType(col.type) ? "values" : null;
|
|
11
11
|
if (col.type === "title" && col.field && valueTypeOf(col.field) === "name")
|
|
12
12
|
return "name";
|
|
13
|
+
if (col.type === "location")
|
|
14
|
+
return col.field && valueTypeOf(col.field) === "location" ? "place" : null;
|
|
13
15
|
return typeRule(col.type)?.editor ?? null;
|
|
14
16
|
}
|
|
15
17
|
export function gridColumnHasEditor(col) {
|
|
@@ -112,7 +114,9 @@ export function columnClearRefusal(col, messages = resolveViewsMessage) {
|
|
|
112
114
|
export function columnEditRefusal(col, conventions, messages = resolveViewsMessage) {
|
|
113
115
|
return (col.reasons?.editable ??
|
|
114
116
|
(col.field ? lockReason(col.field, conventions) : undefined) ??
|
|
115
|
-
(col.custom
|
|
117
|
+
(col.custom
|
|
118
|
+
? messages({ key: "views.grid.computed", values: { from: col.custom.from } })
|
|
119
|
+
: undefined));
|
|
116
120
|
}
|
|
117
121
|
export function gridEditRefusal(col, config, conventions, messages = resolveViewsMessage) {
|
|
118
122
|
if (gridColumnLocked(col, config))
|
|
@@ -186,15 +190,31 @@ function coerceWrite(col, next, messages) {
|
|
|
186
190
|
return { ok: true, value: trimmed };
|
|
187
191
|
}
|
|
188
192
|
case "relation": {
|
|
193
|
+
const many = col.field?.type === "relation" && col.field.cardinality === "many";
|
|
189
194
|
if (isCleared(next))
|
|
190
|
-
return { ok: true, value: null };
|
|
191
|
-
if (typeof next !== "string")
|
|
192
|
-
return { ok: false, reason: messages({ key: "views.grid.write-not-link" }) };
|
|
195
|
+
return { ok: true, value: many ? [] : null };
|
|
193
196
|
const known = col.relation?.options;
|
|
194
|
-
|
|
195
|
-
|
|
197
|
+
const judge = (item) => {
|
|
198
|
+
const id = typeof item === "string" || col.field ? relationIdOf(item) : null;
|
|
199
|
+
if (id === null)
|
|
200
|
+
return messages({ key: "views.grid.write-not-link" });
|
|
201
|
+
if (known && !known.some((option) => option.id === id)) {
|
|
202
|
+
return messages({ key: "views.grid.write-not-linkable" });
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
};
|
|
206
|
+
if (many) {
|
|
207
|
+
if (!Array.isArray(next))
|
|
208
|
+
return { ok: false, reason: messages({ key: "views.grid.write-not-link" }) };
|
|
209
|
+
for (const item of next) {
|
|
210
|
+
const reason = judge(item);
|
|
211
|
+
if (reason)
|
|
212
|
+
return { ok: false, reason };
|
|
213
|
+
}
|
|
214
|
+
return { ok: true, value: next };
|
|
196
215
|
}
|
|
197
|
-
|
|
216
|
+
const reason = judge(next);
|
|
217
|
+
return reason ? { ok: false, reason } : { ok: true, value: next };
|
|
198
218
|
}
|
|
199
219
|
case "list": {
|
|
200
220
|
if (isCleared(next))
|
|
@@ -146,12 +146,15 @@ export function columnFrom(binding, presentation) {
|
|
|
146
146
|
entity: shown.type === "user" ? "user" : relationKinds(shown)[0],
|
|
147
147
|
...(source ? { source } : {}),
|
|
148
148
|
...(source?.kind === "static" ? { options: source.items } : {}),
|
|
149
|
+
...(binding.create ? { create: binding.create } : {}),
|
|
149
150
|
};
|
|
150
151
|
}
|
|
151
152
|
if (isMultipleType(shown.type) && "multiple" in shown && shown.multiple)
|
|
152
153
|
column.multiple = true;
|
|
153
154
|
if (binding.labels === false)
|
|
154
155
|
column.labels = false;
|
|
156
|
+
if (binding.region)
|
|
157
|
+
column.region = binding.region;
|
|
155
158
|
if (shown.type === "multiselect")
|
|
156
159
|
column.chips = { normalize: normalizerFor(shown) };
|
|
157
160
|
if (column.money)
|
|
@@ -7,8 +7,9 @@ import type { ListColumn } from "./column-schema.js";
|
|
|
7
7
|
* editor, can it be written, in what shape). This file answers the one read
|
|
8
8
|
* question the mount gestures (click-on-focused, double-click, Enter) ask
|
|
9
9
|
* beside them: a long text you cannot edit is still worth reading in full, and
|
|
10
|
-
* the anchored panel is the one reading surface the grid has.
|
|
11
|
-
* text qualifies
|
|
10
|
+
* the anchored panel is the one reading surface the grid has. A long text
|
|
11
|
+
* always qualifies; a plain text or a text name qualifies when its cell cuts
|
|
12
|
+
* it off, which only the cell can measure at the gesture.
|
|
12
13
|
*/
|
|
13
14
|
/** A text column whose value is a paragraph, not a phrase — the field said so
|
|
14
15
|
* with `format.long`. It edits (and reads) in the anchored long-text panel
|
|
@@ -16,3 +17,10 @@ import type { ListColumn } from "./column-schema.js";
|
|
|
16
17
|
export declare function isLongTextColumn<Row>(col: ListColumn<Row>): boolean;
|
|
17
18
|
/** Whether a cell opens a PANEL to be READ, whatever its write state. */
|
|
18
19
|
export declare function gridColumnInspectable<Row>(col: ListColumn<Row>): boolean;
|
|
20
|
+
/** A text that opens WHOLE in the panel when the cell cuts it off: plain text, and a name that is
|
|
21
|
+
* text (not a person's name, which edits in its own boxes). Links, emails, phones and domains keep
|
|
22
|
+
* their one-line box. Whether it IS cut off is the cell's to measure (`gridCellCutOff`). */
|
|
23
|
+
export declare function isWholeTextColumn<Row>(col: ListColumn<Row>): boolean;
|
|
24
|
+
/** Whether an open text cell is drawn in the panel over the cell rather than in the cell: a
|
|
25
|
+
* paragraph always, a line when it opened `whole` (cut off when it was opened). */
|
|
26
|
+
export declare function gridTextOpensBox<Row>(col: ListColumn<Row>, whole: boolean): boolean;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
import { valueTypeOf } from "@viewkitjs/fields";
|
|
1
2
|
export function isLongTextColumn(col) {
|
|
2
3
|
return (col.type === "text" && !!col.format?.long) || col.type === "rich_text";
|
|
3
4
|
}
|
|
4
5
|
export function gridColumnInspectable(col) {
|
|
5
6
|
return isLongTextColumn(col);
|
|
6
7
|
}
|
|
8
|
+
export function isWholeTextColumn(col) {
|
|
9
|
+
if (col.type === "text")
|
|
10
|
+
return !col.format?.long;
|
|
11
|
+
return col.type === "title" && !(col.field && valueTypeOf(col.field) === "name");
|
|
12
|
+
}
|
|
13
|
+
export function gridTextOpensBox(col, whole) {
|
|
14
|
+
return isLongTextColumn(col) || (whole && isWholeTextColumn(col));
|
|
15
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MouseEvent as ReactMouseEvent, ReactNode } from "react";
|
|
2
2
|
import type { FieldBinding } from "../fields/binding.js";
|
|
3
3
|
import type { MoneyDeclaration } from "../fields/money.js";
|
|
4
|
-
import type { RelationSource } from "../fields/relation-source-types.js";
|
|
4
|
+
import type { RelationCellCreate, RelationSource } from "../fields/relation-source-types.js";
|
|
5
5
|
import type { MoneyReading } from "../fields/currency.js";
|
|
6
6
|
import type { CategoryColor } from "@viewkitjs/fields/design/category-colors";
|
|
7
7
|
import type { StageMark } from "@viewkitjs/fields/design/stage-marks";
|
|
@@ -159,6 +159,9 @@ export type ListColumn<Row> = {
|
|
|
159
159
|
value: (row: Row) => string;
|
|
160
160
|
options?: string[];
|
|
161
161
|
};
|
|
162
|
+
/** The record's country, where a phone typed without its country code is read: the grid's editors and every
|
|
163
|
+
* write gate read it off the row. Absent, the conventions' region reads it. A binding's `region` carries here. */
|
|
164
|
+
region?: (row: Row) => string | null | undefined;
|
|
162
165
|
type?: ListColumnType;
|
|
163
166
|
/**
|
|
164
167
|
* `relation` columns only — the candidates the picker offers, and the default
|
|
@@ -174,6 +177,8 @@ export type ListColumn<Row> = {
|
|
|
174
177
|
options?: ListRelationValue[];
|
|
175
178
|
/** Kind for values that don't carry their own — the monomorphic case. */
|
|
176
179
|
entity?: string;
|
|
180
|
+
/** The app's create row, offered under the candidates (`FieldBinding.create`). */
|
|
181
|
+
create?: RelationCellCreate;
|
|
177
182
|
};
|
|
178
183
|
/**
|
|
179
184
|
* This cell holds SEVERAL values, not one (an array). Declared rather than
|
|
@@ -29,7 +29,9 @@ import type { ListColumn, ListColumnType, ListRelationValue } from "./column-sch
|
|
|
29
29
|
/** Which editor a writable column mounts when clicked, Entered or typed into. */
|
|
30
30
|
export type GridEditorId = "text" | "select" | "number" | "date" | "relation" | "chips" | "range" | "name"
|
|
31
31
|
/** Several values of one kind (`multiple` email, phone, url or domain), each with its label and a main one. */
|
|
32
|
-
| "values"
|
|
32
|
+
| "values"
|
|
33
|
+
/** A place: the country first, then that country's own parts (`LocationEditor`). */
|
|
34
|
+
| "place";
|
|
33
35
|
/** Which editor this type opens in the Filter drill-in. `none` lists the
|
|
34
36
|
* column and opens nothing — a structured value with no rule to write. */
|
|
35
37
|
export type ListFilterEditor = "options" | "text" | "number" | "date" | "boolean" | "range" | "none";
|
|
@@ -14,7 +14,7 @@ export const GRID_TYPE_RULES = {
|
|
|
14
14
|
relation: { editor: "relation", filter: "options", paste: "relation", value: "relation" },
|
|
15
15
|
user: { editor: "relation", filter: "options", paste: "relation", value: "relation" },
|
|
16
16
|
phone: { editor: "text", filter: "text", paste: "text", value: "any" },
|
|
17
|
-
location: { editor:
|
|
17
|
+
location: { editor: "place", filter: "none", paste: "none", value: "any" },
|
|
18
18
|
name: { editor: "name", filter: "text", paste: "text", value: "any" },
|
|
19
19
|
actor: { editor: null, filter: "options", paste: "none", value: "any" },
|
|
20
20
|
rich_text: { editor: "text", filter: "text", paste: "text", value: "any" },
|
|
@@ -56,10 +56,6 @@ export type ListViewPrefs = {
|
|
|
56
56
|
/** Pin the identity columns (everything through the title) to the left edge
|
|
57
57
|
* while the rest of the table scrolls under them. */
|
|
58
58
|
gridFreezeIdentity: boolean;
|
|
59
|
-
/** Cells wrap to at most 3 lines instead of truncating to one, and rows grow
|
|
60
|
-
* to fit their tallest cell. Off by default: one line per row is what makes
|
|
61
|
-
* a grid scannable, and wrapping is the deliberate trade against it. */
|
|
62
|
-
gridWrapCells: boolean;
|
|
63
59
|
/** Keep every row's checkbox on screen instead of revealing it on hover.
|
|
64
60
|
* Off by default: the rail is chrome, and a permanent column of empty boxes
|
|
65
61
|
* is a cost every row pays for a gesture used occasionally. On for anyone
|
|
@@ -11,7 +11,6 @@ export const LIST_LAYOUT_DEFAULTS = {
|
|
|
11
11
|
verticalBorders: false,
|
|
12
12
|
rowIcon: true,
|
|
13
13
|
freezeIdentity: false,
|
|
14
|
-
wrapCells: false,
|
|
15
14
|
alwaysCheckboxes: false,
|
|
16
15
|
};
|
|
17
16
|
export function verticalBordersDefault(defaults) {
|
|
@@ -29,7 +28,6 @@ export function readViewLayout(bucket, viewId, defaults) {
|
|
|
29
28
|
verticalBorders: stored?.verticalBorders ?? verticalBordersDefault(defaults),
|
|
30
29
|
rowIcon: stored?.rowIcon ?? LIST_LAYOUT_DEFAULTS.rowIcon,
|
|
31
30
|
freezeIdentity: stored?.freezeIdentity ?? LIST_LAYOUT_DEFAULTS.freezeIdentity,
|
|
32
|
-
wrapCells: stored?.wrapCells ?? LIST_LAYOUT_DEFAULTS.wrapCells,
|
|
33
31
|
alwaysCheckboxes: stored?.alwaysCheckboxes ?? LIST_LAYOUT_DEFAULTS.alwaysCheckboxes,
|
|
34
32
|
...(stored?.dateColumnId ? { dateColumnId: stored.dateColumnId } : {}),
|
|
35
33
|
...(stored?.boardFieldId ? { boardFieldId: stored.boardFieldId } : {}),
|
|
@@ -61,7 +59,6 @@ export function hoistLegacyPrefs(legacy) {
|
|
|
61
59
|
verticalBorders: pick(legacy, "gridVerticalBorders"),
|
|
62
60
|
rowIcon: pick(legacy, "gridRowIcon"),
|
|
63
61
|
freezeIdentity: pick(legacy, "gridFreezeIdentity"),
|
|
64
|
-
wrapCells: pick(legacy, "gridWrapCells"),
|
|
65
62
|
alwaysCheckboxes: pick(legacy, "gridAlwaysCheckboxes"),
|
|
66
63
|
}),
|
|
67
64
|
list: {},
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
export declare function countRowRender(): void;
|
|
2
|
+
/**
|
|
3
|
+
* Counts row renders whatever `localStorage.perf` says, from zero, until the
|
|
4
|
+
* returned stop runs. For tests only: the package doesn't export it, and the
|
|
5
|
+
* browser's log never calls it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function countRowRendersInTest(): () => void;
|
|
2
8
|
export declare function takeRowRenders(): number;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
let on = null;
|
|
2
|
+
let forced = 0;
|
|
2
3
|
let rendered = 0;
|
|
3
4
|
function counting() {
|
|
5
|
+
if (forced > 0)
|
|
6
|
+
return true;
|
|
4
7
|
if (typeof window === "undefined")
|
|
5
8
|
return false;
|
|
6
9
|
if (on === null) {
|
|
@@ -17,6 +20,14 @@ export function countRowRender() {
|
|
|
17
20
|
if (counting())
|
|
18
21
|
rendered += 1;
|
|
19
22
|
}
|
|
23
|
+
export function countRowRendersInTest() {
|
|
24
|
+
forced += 1;
|
|
25
|
+
rendered = 0;
|
|
26
|
+
return () => {
|
|
27
|
+
forced -= 1;
|
|
28
|
+
rendered = 0;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
20
31
|
export function takeRowRenders() {
|
|
21
32
|
const count = rendered;
|
|
22
33
|
rendered = 0;
|
|
@@ -21,6 +21,10 @@ export type ViewsProviderProps = {
|
|
|
21
21
|
* app's. It is called where a value is drawn, so the app's provider imports none of the
|
|
22
22
|
* display. Absent, the package's defaults in the conventions' locale. */
|
|
23
23
|
presentation?: (defaults: FieldPresentation) => FieldPresentation;
|
|
24
|
+
/** The media query that means a desktop, so an editor opens as a popover there and as a sheet
|
|
25
|
+
* elsewhere. Hand in the one your own shell switches on. Default `DEFAULT_DESKTOP_QUERY`,
|
|
26
|
+
* `(min-width: 1024px)`. */
|
|
27
|
+
desktopQuery?: string;
|
|
24
28
|
children: ReactNode;
|
|
25
29
|
};
|
|
26
|
-
export declare function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages, presentation, }: ViewsProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages, presentation, desktopQuery, }: ViewsProviderProps): import("react/jsx-runtime").JSX.Element;
|