viewkitjs 0.38.0 → 0.40.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 +134 -0
- package/MIGRATION.md +32 -0
- package/fields/dist/derived.d.ts +7 -0
- package/fields/dist/derived.js +4 -0
- package/fields/dist/index.d.ts +1 -1
- package/fields/dist/index.js +1 -1
- package/fields/dist/messages.d.ts +5 -1
- package/fields/dist/messages.js +3 -0
- package/fields/dist/query/evaluate.d.ts +7 -1
- package/fields/dist/query/evaluate.js +8 -5
- package/fields/dist/query/figure-kinds.d.ts +2 -2
- package/fields/dist/query/figure-kinds.js +3 -0
- package/fields/dist/query/figures.d.ts +5 -3
- package/fields/dist/query/figures.js +13 -0
- package/fields/dist/query/filter.d.ts +7 -0
- package/fields/dist/query/filter.js +7 -1
- package/fields/dist/query/kit.d.ts +3 -2
- package/fields/dist/query/kit.js +1 -1
- package/fields/dist/query/layer.d.ts +6 -0
- package/fields/dist/query/layer.js +3 -0
- package/fields/dist/query/number.d.ts +3 -2
- package/fields/dist/query/number.js +5 -3
- package/fields/dist/query/read-rule.d.ts +1 -1
- package/fields/dist/query/read-rule.js +3 -0
- package/fields/docs/guides/queries.md +28 -24
- package/fields/docs/reference/fields.md +1 -0
- package/fields/docs/reference/query.md +9 -7
- package/package.json +2 -4
- package/postgres/dist/check.js +3 -1
- package/postgres/dist/definitions/storage.d.ts +3 -1
- package/postgres/dist/definitions/storage.js +3 -1
- package/postgres/dist/definitions/stored.js +13 -2
- package/postgres/dist/map.d.ts +5 -1
- package/postgres/dist/map.js +4 -0
- package/postgres/dist/records.js +6 -1
- package/postgres/docs/guides/definitions.md +1 -1
- package/postgres/docs/guides/field-map.md +3 -3
- package/postgres/docs/reference/postgres.md +1 -1
- package/views/dist/atoms/HeaderChrome.d.ts +7 -0
- package/views/dist/atoms/HeaderChrome.js +15 -0
- package/views/dist/atoms/ToolbarButton.d.ts +1 -1
- package/views/dist/atoms/ToolbarButton.js +2 -2
- package/views/dist/atoms/defaults.js +4 -0
- package/views/dist/atoms/types.d.ts +39 -2
- package/views/dist/contract.d.ts +38 -9
- package/views/dist/contract.js +64 -6
- package/views/dist/controls/avatar.css +1 -1
- package/views/dist/controls/customize/map-customize-body.js +1 -1
- package/views/dist/controls/field/field.d.ts +2 -14
- package/views/dist/controls/field/field.js +4 -9
- package/views/dist/controls/field/looks.d.ts +1 -1
- package/views/dist/controls/field/looks.js +7 -3
- package/views/dist/controls/field/tokens.d.ts +4 -0
- package/views/dist/controls/field/tokens.js +1 -0
- package/views/dist/controls/field.css +33 -0
- package/views/dist/controls/filter-editor/block.d.ts +3 -1
- package/views/dist/controls/filter-editor/block.js +4 -3
- package/views/dist/controls/filter-editor/filter-editor.d.ts +15 -2
- package/views/dist/controls/filter-editor/filter-editor.js +49 -16
- package/views/dist/controls/filter-editor/how.d.ts +11 -1
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +4 -2
- package/views/dist/controls/filter-editor/map-filter-body.js +21 -11
- package/views/dist/controls/filter-editor/map-rules.d.ts +6 -4
- package/views/dist/controls/filter-editor/map-rules.js +7 -4
- package/views/dist/controls/filter-editor/parts.d.ts +14 -1
- package/views/dist/controls/filter-editor/parts.js +14 -0
- package/views/dist/controls/filter-editor.css +4 -1
- package/views/dist/controls/index.d.ts +0 -3
- package/views/dist/controls/index.js +0 -3
- package/views/dist/controls/input.css +1 -1
- package/views/dist/controls/internal/menu-items.d.ts +2 -0
- package/views/dist/controls/internal/menu-items.js +1 -1
- package/views/dist/controls/internal/part-slot.d.ts +1 -1
- package/views/dist/controls/internal/part-slot.js +1 -1
- package/views/dist/controls/internal/row-actions.d.ts +33 -0
- package/views/dist/controls/internal/row-actions.js +28 -0
- package/views/dist/controls/menu/map-menu.js +1 -1
- package/views/dist/controls/menu-list.css +1 -1
- package/views/dist/controls/picker/looks.d.ts +1 -1
- package/views/dist/controls/picker.css +2 -2
- package/views/dist/controls/popover/map-popover.d.ts +1 -1
- package/views/dist/controls/popover/map-popover.js +2 -2
- package/views/dist/controls/press.css +0 -1
- package/views/dist/controls/radio/radio.d.ts +1 -1
- package/views/dist/controls/radio/radio.js +1 -16
- package/views/dist/controls/sheet/bottom-sheet.d.ts +2 -2
- package/views/dist/controls/sheet/bottom-sheet.js +31 -24
- package/views/dist/controls/sheet/map-sheet.js +9 -6
- package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
- package/views/dist/controls/sort-editor/sort-editor.d.ts +5 -1
- package/views/dist/controls/sort-editor/sort-editor.js +41 -13
- package/views/dist/controls/text-editor.css +22 -0
- package/views/dist/controls/tokens.js +0 -6
- package/views/dist/controls/toolbar/toolbar.js +2 -2
- package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +1 -1
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +2 -2
- package/views/dist/editors/EditorPanel.js +1 -1
- package/views/dist/field-row/FieldRow.js +38 -16
- package/views/dist/field-row/editors/RowChipsEditor.js +3 -1
- package/views/dist/field-row/editors/RowDateEditor.js +3 -1
- package/views/dist/field-row/editors/RowNameEditor.js +3 -1
- package/views/dist/field-row/editors/RowPlaceEditor.js +4 -2
- package/views/dist/field-row/editors/RowRangeEditor.js +3 -1
- package/views/dist/field-row/editors/RowRelationEditor.js +5 -2
- package/views/dist/field-row/editors/RowSelectEditor.js +3 -1
- package/views/dist/field-row/editors/RowTextEditor.d.ts +7 -1
- package/views/dist/field-row/editors/RowTextEditor.js +28 -4
- package/views/dist/field-row/editors/RowValueListEditor.js +4 -4
- package/views/dist/field-row/editors/row-place.d.ts +33 -0
- package/views/dist/field-row/editors/row-place.js +141 -0
- package/views/dist/field-row/field-row-button.d.ts +9 -6
- package/views/dist/field-row/field-row-button.js +3 -3
- package/views/dist/field-row/row-target.d.ts +4 -1
- package/views/dist/field-row/row-target.js +1 -1
- package/views/dist/filters/duration-bound.d.ts +7 -0
- package/views/dist/filters/duration-bound.js +9 -0
- package/views/dist/filters/filter-model.d.ts +4 -0
- package/views/dist/filters/number-refused.d.ts +8 -0
- package/views/dist/filters/number-refused.js +4 -0
- package/views/dist/grid/chrome/GridAggregateMenu.d.ts +12 -11
- package/views/dist/grid/chrome/GridAggregateMenu.js +4 -3
- package/views/dist/grid/chrome/GridFooter.d.ts +12 -4
- package/views/dist/grid/chrome/GridFooter.js +11 -9
- package/views/dist/grid/chrome/GridHeader.js +4 -3
- package/views/dist/grid/chrome/GridResizeHandle.d.ts +7 -3
- package/views/dist/grid/chrome/GridResizeHandle.js +2 -3
- package/views/dist/grid/chrome/GridTable.js +1 -1
- package/views/dist/grid/chrome/GridTableSurface.js +1 -1
- package/views/dist/grid/chrome/grid-body-place.d.ts +2 -4
- package/views/dist/grid/chrome/grid-body-place.js +4 -5
- package/views/dist/grid/chrome/grid-figure-value.js +10 -4
- package/views/dist/grid/chrome/grid-table-props.d.ts +15 -4
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +12 -2
- package/views/dist/grid/core/clipboard-model.js +42 -8
- package/views/dist/grid/core/commit-model.d.ts +3 -0
- package/views/dist/grid/core/editing-controller.d.ts +29 -1
- package/views/dist/grid/core/editing-controller.js +142 -12
- package/views/dist/grid/core/pending-reconciliation.d.ts +14 -0
- package/views/dist/grid/core/pending-reconciliation.js +20 -8
- package/views/dist/grid/core/save-path.d.ts +4 -2
- package/views/dist/grid/core/save-path.js +1 -1
- package/views/dist/grid/core/spreadsheet-operations.js +43 -5
- package/views/dist/grid/core/useGridEditing.d.ts +5 -1
- package/views/dist/grid/core/useGridEditing.js +4 -4
- package/views/dist/grid/core/written-alongside.d.ts +16 -0
- package/views/dist/grid/core/written-alongside.js +30 -0
- package/views/dist/grid/grid.css +8 -4
- package/views/dist/grid/index.d.ts +1 -1
- package/views/dist/grid/looks.d.ts +2 -2
- package/views/dist/internal/before-paint.d.ts +5 -0
- package/views/dist/internal/before-paint.js +17 -0
- package/views/dist/internal/field-rows.d.ts +0 -8
- package/views/dist/internal/field-rows.js +1 -3
- package/views/dist/internal/over-cell.d.ts +8 -0
- package/views/dist/internal/over-cell.js +5 -0
- package/views/dist/list/bar-keys.d.ts +8 -0
- package/views/dist/list/bar-keys.js +3 -0
- package/views/dist/list/bar-parts.d.ts +27 -0
- package/views/dist/list/bar-parts.js +38 -0
- package/views/dist/list/buttons/clear-save.d.ts +7 -0
- package/views/dist/list/buttons/clear-save.js +19 -0
- package/views/dist/list/buttons/customize.d.ts +28 -0
- package/views/dist/list/buttons/customize.js +31 -0
- package/views/dist/list/buttons/filter.d.ts +32 -0
- package/views/dist/list/buttons/filter.js +60 -0
- package/views/dist/list/buttons/new.d.ts +18 -0
- package/views/dist/list/buttons/new.js +21 -0
- package/views/dist/list/buttons/quick.d.ts +15 -0
- package/views/dist/list/buttons/quick.js +24 -0
- package/views/dist/list/buttons/search.d.ts +18 -0
- package/views/dist/list/buttons/search.js +17 -0
- package/views/dist/list/buttons/shared.d.ts +97 -0
- package/views/dist/list/buttons/shared.js +137 -0
- package/views/dist/list/buttons/sort-filter.d.ts +6 -0
- package/views/dist/list/buttons/sort-filter.js +16 -0
- package/views/dist/list/buttons/sort.d.ts +17 -0
- package/views/dist/list/buttons/sort.js +34 -0
- package/views/dist/list/buttons/views.d.ts +21 -0
- package/views/dist/list/buttons/views.js +38 -0
- package/views/dist/list/editor-menus.d.ts +13 -0
- package/views/dist/list/editor-menus.js +13 -0
- package/views/dist/list/edits.d.ts +3 -1
- package/views/dist/list/index.d.ts +41 -0
- package/views/dist/list/index.js +19 -0
- package/views/dist/list/layer.d.ts +13 -3
- package/views/dist/list/layer.js +13 -3
- package/views/dist/list/line.d.ts +58 -0
- package/views/dist/list/line.js +229 -0
- package/views/dist/list/list.d.ts +7 -1
- package/views/dist/list/list.js +2 -2
- package/views/dist/list/pane-box.d.ts +6 -0
- package/views/dist/list/pane-box.js +15 -0
- package/views/dist/list/panels/customize.d.ts +8 -0
- package/views/dist/list/panels/customize.js +23 -0
- package/views/dist/list/panels/filter-bar.d.ts +12 -0
- package/views/dist/list/panels/filter-bar.js +73 -0
- package/views/dist/list/panels/filter.d.ts +8 -0
- package/views/dist/list/panels/filter.js +23 -0
- package/views/dist/list/panels/quick.d.ts +7 -0
- package/views/dist/list/panels/quick.js +16 -0
- package/views/dist/list/panels/shared.d.ts +26 -0
- package/views/dist/list/panels/shared.js +36 -0
- package/views/dist/list/panels/sort.d.ts +8 -0
- package/views/dist/list/panels/sort.js +19 -0
- package/views/dist/list/panels/views.d.ts +13 -0
- package/views/dist/list/panels/views.js +27 -0
- package/views/dist/list/ready.d.ts +35 -0
- package/views/dist/list/ready.js +7 -0
- package/views/dist/list/root-base.d.ts +19 -1
- package/views/dist/list/root-base.js +13 -3
- package/views/dist/list/root.d.ts +1 -1
- package/views/dist/list/root.js +2 -2
- package/views/dist/list/store.d.ts +29 -0
- package/views/dist/list/store.js +48 -2
- package/views/dist/list/toolbar-model.d.ts +99 -0
- package/views/dist/list/toolbar-model.js +195 -0
- package/views/dist/list/toolbar.js +142 -329
- package/views/dist/list/views-axis.js +15 -4
- package/views/dist/list/views.d.ts +1 -1
- package/views/dist/list/views.js +4 -1
- package/views/dist/looks/index.d.ts +0 -1
- package/views/dist/looks/index.js +0 -1
- package/views/dist/looks/looks.d.ts +1 -1
- package/views/dist/looks/pieces.js +0 -2
- package/views/dist/model/aggregates.d.ts +18 -8
- package/views/dist/model/aggregates.js +16 -22
- package/views/dist/model/column-filters.js +10 -3
- package/views/dist/model/view-rules.js +1 -0
- package/views/dist/panels/filter/NumberFilterBody.js +6 -8
- package/views/dist/panels/labels.js +7 -2
- package/views/dist/panels/model.d.ts +3 -0
- package/views/dist/panels/react/filter/FilterEditor.d.ts +3 -1
- package/views/dist/panels/react/filter/FilterEditor.js +2 -2
- package/views/dist/panels/react/filter/filter-body.d.ts +3 -1
- package/views/dist/panels/react/filter/filter-body.js +7 -3
- package/views/dist/panels/react/sort/SortEditor.d.ts +3 -1
- package/views/dist/panels/react/sort/SortEditor.js +4 -4
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +80 -3
- package/views/dist/panels/react/toolbar/Toolbar.js +85 -52
- package/views/dist/panels/react/toolbar/ToolbarBarSorts.d.ts +9 -0
- package/views/dist/panels/react/toolbar/ToolbarBarSorts.js +84 -0
- package/views/dist/panels/react/toolbar/ToolbarButton.d.ts +1 -1
- package/views/dist/panels/react/toolbar/ToolbarButton.js +5 -3
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +4 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +30 -0
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +6 -1
- package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +5 -0
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +6 -4
- package/views/dist/panels/react/toolbar/ToolbarViews.d.ts +7 -1
- package/views/dist/panels/react/toolbar/ToolbarViews.js +4 -4
- package/views/dist/panels/react/toolbar/context.d.ts +4 -0
- package/views/dist/panels/react/toolbar/context.js +1 -0
- package/views/dist/panels/react/toolbar/sheet-host.d.ts +3 -0
- package/views/dist/panels/react/toolbar/sheet-host.js +6 -0
- package/views/dist/panels/react/toolbar/use-give-way.d.ts +6 -0
- package/views/dist/panels/react/toolbar/use-give-way.js +10 -3
- package/views/dist/panels/react/views-row/ViewPicker.d.ts +8 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +12 -7
- package/views/dist/panels/settings/filter-groups.js +12 -0
- package/views/dist/panels/settings/input.d.ts +11 -0
- package/views/dist/panels/settings/layout.js +26 -0
- package/views/dist/panels/settings/person.d.ts +15 -0
- package/views/dist/panels/settings/person.js +6 -0
- package/views/dist/panels/toolbar/page-resets.js +14 -3
- package/views/dist/provider/components.d.ts +47 -4
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +116 -257
- package/views/dist/styles.unlayered.css +116 -257
- package/views/docs/contract.md +28 -18
- package/views/docs/controls/field.md +2 -1
- package/views/docs/controls/filter-editor.md +1 -1
- package/views/docs/controls/menu.md +1 -1
- package/views/docs/controls/sort-editor.md +1 -1
- package/views/docs/guides/atoms.md +1 -0
- package/views/docs/guides/looks.md +1 -1
- package/views/docs/guides/the-grid.md +6 -4
- package/views/docs/guides/toolbar-parts.md +337 -0
- package/views/docs/index.md +4 -0
- package/views/docs/reference/controls.md +6 -44
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +8 -7
- package/views/docs/reference/list.md +184 -11
- package/views/docs/reference/looks.md +13 -16
- package/views/docs/reference/panels-react.md +7 -7
- package/views/docs/reference/panels.md +1 -1
- package/views/docs/reference/react.md +14 -11
- package/views/docs/reference/views.md +9 -7
- package/views/skills/views/SKILL.md +2 -1
- package/views/dist/controls/setting-row/looks.d.ts +0 -10
- package/views/dist/controls/setting-row/looks.js +0 -22
- package/views/dist/controls/setting-row/setting-row.d.ts +0 -102
- package/views/dist/controls/setting-row/setting-row.js +0 -135
- package/views/dist/controls/setting-row/tokens.d.ts +0 -156
- package/views/dist/controls/setting-row/tokens.js +0 -41
- package/views/dist/controls/setting-row.css +0 -216
- package/views/dist/controls/switch-row/switch-row.d.ts +0 -1
- package/views/dist/controls/switch-row/switch-row.js +0 -1
- package/views/dist/controls/switch-row/tokens.d.ts +0 -39
- package/views/dist/controls/switch-row/tokens.js +0 -12
- package/views/dist/controls/switch-row.css +0 -35
- package/views/dist/controls/tag-field/tag-field.d.ts +0 -24
- package/views/dist/controls/tag-field/tag-field.js +0 -25
- package/views/dist/controls/tag-field/tokens.d.ts +0 -23
- package/views/dist/controls/tag-field/tokens.js +0 -8
- package/views/dist/controls/tag-field.css +0 -32
- package/views/docs/controls/setting-row.md +0 -44
- package/views/docs/controls/switch-row.md +0 -15
- package/views/docs/controls/tag-field.md +0 -11
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ListColumn } from "../../model/column-schema.js";
|
|
2
|
+
import { type GridEditCell } from "./editing-model.js";
|
|
2
3
|
/**
|
|
3
4
|
* Reconciling the optimistic overlay with what the server actually holds.
|
|
4
5
|
*
|
|
@@ -51,3 +52,16 @@ export declare function findSupersededCells<Row>(rows: readonly Row[], columns:
|
|
|
51
52
|
column: ListColumn<Row>;
|
|
52
53
|
serverValue: unknown;
|
|
53
54
|
}[];
|
|
55
|
+
/**
|
|
56
|
+
* Does the server hold a value that is neither ours nor the one ours replaced: somebody else's? The one question both
|
|
57
|
+
* the warning after a save (`findSupersededCells`) and an undo before it writes (`changedSinceEdit`) ask. Ours is
|
|
58
|
+
* matched by structure where the save said what it kept, loosely otherwise; a date column's two spellings of one value
|
|
59
|
+
* are one value.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isThirdValue<Row>(col: ListColumn<Row>, server: unknown, ours: unknown, baseline: unknown): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Has someone written this cell since the person's edit, as the rows the grid holds show it? A third value:
|
|
64
|
+
* neither side of the edit as its overlay draws them (`gridRestoreShown`), a figure's side read as the number the row
|
|
65
|
+
* holds (an editor's `{ value, unit }`, a clear's `""`). No column, no read or no row: nothing to compare, so no.
|
|
66
|
+
*/
|
|
67
|
+
export declare function changedSinceEdit<Row>(col: ListColumn<Row> | undefined, row: Row | undefined, cell: GridEditCell<Row>): boolean;
|
|
@@ -2,6 +2,8 @@ import { gridCellKey } from "./commit-model.js";
|
|
|
2
2
|
import { sameListValue } from "viewkitjs/fields";
|
|
3
3
|
import { isEmptyValue, isGridKeptValue, looselyEqualValue, sameCalendarDay, sameInstantMinute, sameKeptValue, } from "./value-equality.js";
|
|
4
4
|
import { fieldTypeOf } from "../../model/field-type-of.js";
|
|
5
|
+
import { gridRestoreShown } from "./editing-model.js";
|
|
6
|
+
import { gridFigureOf } from "./clipboard-model.js";
|
|
5
7
|
const sameInstantIn = (col, a, b) => {
|
|
6
8
|
const type = col == null ? undefined : fieldTypeOf(col);
|
|
7
9
|
return type === "datetime" ? sameInstantMinute(a, b) : type === "date" && sameCalendarDay(a, b);
|
|
@@ -46,15 +48,25 @@ export function findSupersededCells(rows, columns, getRowId, pendingByRow, hasIn
|
|
|
46
48
|
if (hasInflight(rowId, columnId))
|
|
47
49
|
continue;
|
|
48
50
|
const serverValue = read(row);
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
continue;
|
|
53
|
-
const baseline = baselineOf(rowId, columnId);
|
|
54
|
-
if (looselyEqualValue(serverValue, baseline) || sameInstantIn(col, serverValue, baseline))
|
|
55
|
-
continue;
|
|
56
|
-
taken.push({ rowId, columnId, column: col, serverValue });
|
|
51
|
+
if (isThirdValue(col, serverValue, value, baselineOf(rowId, columnId))) {
|
|
52
|
+
taken.push({ rowId, columnId, column: col, serverValue });
|
|
53
|
+
}
|
|
57
54
|
}
|
|
58
55
|
}
|
|
59
56
|
return taken;
|
|
60
57
|
}
|
|
58
|
+
export function isThirdValue(col, server, ours, baseline) {
|
|
59
|
+
if (isGridKeptValue(ours) ? sameKeptValue(server, ours) : looselyEqualValue(server, ours))
|
|
60
|
+
return false;
|
|
61
|
+
if (sameInstantIn(col, server, ours))
|
|
62
|
+
return false;
|
|
63
|
+
return !(looselyEqualValue(server, baseline) || sameInstantIn(col, server, baseline));
|
|
64
|
+
}
|
|
65
|
+
export function changedSinceEdit(col, row, cell) {
|
|
66
|
+
const read = col?.editAccessor ?? col?.accessor;
|
|
67
|
+
if (!col || !read || row === undefined)
|
|
68
|
+
return false;
|
|
69
|
+
const type = fieldTypeOf(col);
|
|
70
|
+
const asRead = type === "number" || type === "percent" || type === "currency" ? gridFigureOf : (value) => value;
|
|
71
|
+
return isThirdValue(col, read(row), asRead(gridRestoreShown(cell, "next")), asRead(gridRestoreShown(cell, "prev")));
|
|
72
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GridCellCommitFn, GridCellsCommitFn, GridCommitContext, ListSave } from "./commit-model.js";
|
|
1
|
+
import type { GridCellCommitFn, GridCellValuesFn, GridCellsCommitFn, GridCommitContext, ListSave } from "./commit-model.js";
|
|
2
2
|
export type GridSaveOptions<Row> = {
|
|
3
3
|
/** The record's id, which `save` is sent as `id`. */
|
|
4
4
|
getRowId: (row: Row) => string;
|
|
@@ -9,7 +9,8 @@ export type GridSaveOptions<Row> = {
|
|
|
9
9
|
read?: (row: Row, columnId: string) => unknown;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
* The grid's two commit functions over one save
|
|
12
|
+
* The grid's two commit functions over one save, and the `values` it sends them with (`cellValues`, for `GridTable` to
|
|
13
|
+
* show every column a cell's save writes as it is sent): every write (an edit, a paste, a fill, an undo, a redo) is one call
|
|
13
14
|
* per record, its cells' values merged, and a record has one call in flight at a time, the next waiting for it to
|
|
14
15
|
* settle. When the page goes, every change still waiting is sent at once, marked `closing`, and leaves its record's
|
|
15
16
|
* queue: its own answer settles it; a call already out is not sent again. A cell whose `getRowId` or `values` throws
|
|
@@ -21,4 +22,5 @@ export type GridSaveOptions<Row> = {
|
|
|
21
22
|
export declare function gridSave<Row>(save: ListSave<Row>, options: GridSaveOptions<Row>): {
|
|
22
23
|
onCellCommit: GridCellCommitFn<Row>;
|
|
23
24
|
onCellsCommit: GridCellsCommitFn<Row>;
|
|
25
|
+
cellValues: GridCellValuesFn<Row>;
|
|
24
26
|
};
|
|
@@ -118,5 +118,5 @@ export function gridSave(save, options) {
|
|
|
118
118
|
const [outcome] = await onCellsCommit([{ row, columnId, value, ...(context ? { context } : {}) }]);
|
|
119
119
|
return outcome;
|
|
120
120
|
};
|
|
121
|
-
return { onCellCommit, onCellsCommit };
|
|
121
|
+
return { onCellCommit, onCellsCommit, cellValues: values };
|
|
122
122
|
}
|
|
@@ -22,6 +22,41 @@ function rowWrites(model, row) {
|
|
|
22
22
|
function rowRefusal(model) {
|
|
23
23
|
return (model.messages ?? resolveViewsMessage)({ key: "views.grid.cell-read-only" });
|
|
24
24
|
}
|
|
25
|
+
function samePlannedValue(a, b) {
|
|
26
|
+
if (a === b)
|
|
27
|
+
return true;
|
|
28
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
29
|
+
return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, index) => samePlannedValue(item, b[index]));
|
|
30
|
+
}
|
|
31
|
+
if (a === null || b === null || typeof a !== "object" || typeof b !== "object")
|
|
32
|
+
return false;
|
|
33
|
+
const keys = Object.keys(a);
|
|
34
|
+
return (keys.length === Object.keys(b).length &&
|
|
35
|
+
keys.every((key) => samePlannedValue(a[key], b[key])));
|
|
36
|
+
}
|
|
37
|
+
function foldRecordEdits(edits, refusals, messages) {
|
|
38
|
+
const byCell = new Map();
|
|
39
|
+
for (const edit of edits) {
|
|
40
|
+
const key = JSON.stringify([edit.rowId, edit.columnId]);
|
|
41
|
+
const cell = byCell.get(key);
|
|
42
|
+
if (cell)
|
|
43
|
+
cell.push(edit);
|
|
44
|
+
else
|
|
45
|
+
byCell.set(key, [edit]);
|
|
46
|
+
}
|
|
47
|
+
const kept = new Set();
|
|
48
|
+
let refused = 0;
|
|
49
|
+
for (const cell of byCell.values()) {
|
|
50
|
+
if (cell.every((edit) => samePlannedValue(edit.next, cell[0].next))) {
|
|
51
|
+
kept.add(cell[0]);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
for (let i = 0; i < cell.length; i++)
|
|
55
|
+
addRefusal(refusals, messages({ key: "views.grid.paste-two-values" }));
|
|
56
|
+
refused += cell.length;
|
|
57
|
+
}
|
|
58
|
+
return { edits: edits.filter((edit) => kept.has(edit)), refused };
|
|
59
|
+
}
|
|
25
60
|
export function buildGridCopyMatrix(model, rect) {
|
|
26
61
|
const matrix = [];
|
|
27
62
|
for (let r = rect.r1; r <= rect.r2; r++) {
|
|
@@ -99,7 +134,7 @@ export function planGridClear(model, rect) {
|
|
|
99
134
|
}
|
|
100
135
|
}
|
|
101
136
|
return {
|
|
102
|
-
edits,
|
|
137
|
+
edits: foldRecordEdits(edits, refusals, model.messages ?? resolveViewsMessage).edits,
|
|
103
138
|
refusals,
|
|
104
139
|
required: [...required].sort((a, b) => a - b).map((c) => columnLabel(model.visibleColumns[c])),
|
|
105
140
|
};
|
|
@@ -180,17 +215,19 @@ export function planGridPaste(model, matrix, anchor, activeRect, selectValuesByC
|
|
|
180
215
|
maxR = Math.max(maxR, r);
|
|
181
216
|
maxC = Math.max(maxC, c);
|
|
182
217
|
}
|
|
218
|
+
const folded = foldRecordEdits(edits, refusals, model.messages ?? resolveViewsMessage);
|
|
219
|
+
skipped += folded.refused;
|
|
183
220
|
const anchorRowId = model.visibleRowIds[anchor.rowIdx];
|
|
184
221
|
const anchorColumn = model.visibleColumns[anchor.colIdx];
|
|
185
222
|
const headRowId = model.visibleRowIds[maxR];
|
|
186
223
|
const headColumn = model.visibleColumns[maxC];
|
|
187
|
-
const selection = !single && edits.length > 0 && anchorRowId && anchorColumn && headRowId && headColumn
|
|
224
|
+
const selection = !single && folded.edits.length > 0 && anchorRowId && anchorColumn && headRowId && headColumn
|
|
188
225
|
? {
|
|
189
226
|
anchor: { rowId: anchorRowId, columnId: anchorColumn.id },
|
|
190
227
|
head: { rowId: headRowId, columnId: headColumn.id },
|
|
191
228
|
}
|
|
192
229
|
: null;
|
|
193
|
-
return { edits, skipped, refusals, targetCount: targets.length, selection };
|
|
230
|
+
return { edits: folded.edits, skipped, refusals, targetCount: targets.length, selection };
|
|
194
231
|
}
|
|
195
232
|
export function extendGridFillPreview(ranges, targetRowId, visibleRowIds, visibleColIds) {
|
|
196
233
|
if (!targetRowId || ranges.length === 0)
|
|
@@ -295,10 +332,11 @@ export function planGridFill(model, ranges, focused, targetRowId) {
|
|
|
295
332
|
});
|
|
296
333
|
}
|
|
297
334
|
}
|
|
335
|
+
const folded = foldRecordEdits(edits, refusals, model.messages ?? resolveViewsMessage);
|
|
298
336
|
return {
|
|
299
|
-
edits,
|
|
337
|
+
edits: folded.edits,
|
|
300
338
|
selectionHead: { rowId: targetRowId, columnId: active.head.columnId },
|
|
301
|
-
skipped,
|
|
339
|
+
skipped: skipped + folded.refused,
|
|
302
340
|
refusals,
|
|
303
341
|
targetCount: targetIndices.length * (rect.c2 - rect.c1 + 1),
|
|
304
342
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { GridCellCommitFn, GridCellsCommitFn, GridCommitRefusal } from "./commit-model.js";
|
|
2
2
|
import { type GridCellPos } from "./coordinates.js";
|
|
3
|
+
import { type GridEditingCallbacks } from "./editing-controller.js";
|
|
3
4
|
import { type GridEditCell, type GridSettlementByRow } from "./editing-model.js";
|
|
4
5
|
import type { GridWriteStateByRow } from "./write-states.js";
|
|
5
6
|
/** Whether a commit lays an overlay over its cell: `true` draws the value sent, `"figure"` the number a figure's
|
|
@@ -79,4 +80,7 @@ export declare function useGridEditing<Row>(onCellCommit?: GridCellCommitFn<Row>
|
|
|
79
80
|
/** Told once per write the app refused (`GridEditingCallbacks.onRefused`). */
|
|
80
81
|
onRefused?: (refusal: GridCommitRefusal) => void,
|
|
81
82
|
/** Which columns' sent values are kept for a part edit to build on (`GridEditingCallbacks.keepsSent`). */
|
|
82
|
-
keepsSent?: (columnId: string) => boolean
|
|
83
|
+
keepsSent?: (columnId: string) => boolean,
|
|
84
|
+
/** The other columns a save writes, and an undo's check for a value someone wrote since
|
|
85
|
+
* (`GridEditingCallbacks.alongside`, `changedSince`, `onChangedSince`). */
|
|
86
|
+
more?: Pick<GridEditingCallbacks<Row>, "alongside" | "changedSince" | "onChangedSince">): GridEditingApi<Row>;
|
|
@@ -5,22 +5,22 @@ import { forgetGridEdited, isLastEditedGrid } from "./undo-owner.js";
|
|
|
5
5
|
import { sameListValue } from "viewkitjs/fields";
|
|
6
6
|
import { prepareGridCommitCells, } from "./editing-model.js";
|
|
7
7
|
import { gridFigureOf } from "./clipboard-model.js";
|
|
8
|
-
export function useGridEditing(onCellCommit, onCellsCommit, onRefused, keepsSent) {
|
|
8
|
+
export function useGridEditing(onCellCommit, onCellsCommit, onRefused, keepsSent, more) {
|
|
9
9
|
const [focused, setFocused] = useState(null);
|
|
10
10
|
const [editing, setEditing] = useState(null);
|
|
11
11
|
const [pendingByRow, setPendingByRow] = useState(() => new Map());
|
|
12
12
|
const [settlementByRow, setSettlementByRow] = useState(() => new Map());
|
|
13
13
|
const [writeStateByRow, setWriteStateByRow] = useState(() => new Map());
|
|
14
|
-
const [controller] = useState(() => new GridEditingController({ onCellCommit, onCellsCommit, onRefused, keepsSent }, (pending, settlement) => {
|
|
14
|
+
const [controller] = useState(() => new GridEditingController({ onCellCommit, onCellsCommit, onRefused, keepsSent, ...more }, (pending, settlement) => {
|
|
15
15
|
setPendingByRow(pending);
|
|
16
16
|
setSettlementByRow(settlement);
|
|
17
17
|
}, setWriteStateByRow));
|
|
18
18
|
useEffect(() => () => forgetGridEdited(controller), [controller]);
|
|
19
19
|
const isLastEdited = useCallback(() => isLastEditedGrid(controller), [controller]);
|
|
20
20
|
useEffect(() => {
|
|
21
|
-
const callbacks = { onCellCommit, onCellsCommit, onRefused, keepsSent };
|
|
21
|
+
const callbacks = { onCellCommit, onCellsCommit, onRefused, keepsSent, ...more };
|
|
22
22
|
controller.setCallbacks(callbacks);
|
|
23
|
-
}, [controller, onCellCommit, onCellsCommit, onRefused, keepsSent]);
|
|
23
|
+
}, [controller, onCellCommit, onCellsCommit, onRefused, keepsSent, more]);
|
|
24
24
|
const focusCell = useCallback((rowId, columnId) => {
|
|
25
25
|
setFocused({ rowId, columnId });
|
|
26
26
|
setEditing(null);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ListColumn } from "../../model/column-schema.js";
|
|
2
|
+
import type { GridCellValuesFn, GridCommitContext } from "./commit-model.js";
|
|
3
|
+
/** What a cell's change writes into the other columns of its row: each one it changes, with what it reads after the
|
|
4
|
+
* change (`value`) and before it (`baseline`). */
|
|
5
|
+
export type GridAlongside<Row> = (row: Row, columnId: string, value: unknown, context: GridCommitContext) => {
|
|
6
|
+
columnId: string;
|
|
7
|
+
value: unknown;
|
|
8
|
+
baseline: unknown;
|
|
9
|
+
}[];
|
|
10
|
+
/** The columns a cell's values write beside its own, read by each column's `editAccessor`, else its `accessor`: each
|
|
11
|
+
* whose field key the values hold, and each whose read they change. A column the values write may read on the row what
|
|
12
|
+
* they write while the grid draws another value over it (an earlier save's, the rows not yet read again): the grid
|
|
13
|
+
* compares with what it draws (`GridEditingController`). A part column draws from its whole and is never named; a
|
|
14
|
+
* `cellValues` that throws names nothing (the save refuses the cell itself), and a read that throws leaves its column
|
|
15
|
+
* out. Undefined with no `cellValues`. */
|
|
16
|
+
export declare function gridWrittenAlongside<Row>(columns: readonly ListColumn<Row>[], cellValues: GridCellValuesFn<Row> | undefined): GridAlongside<Row> | undefined;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { sameListValue } from "viewkitjs/fields";
|
|
2
|
+
import { fieldKeyOf } from "../../model/view-rules.js";
|
|
3
|
+
export function gridWrittenAlongside(columns, cellValues) {
|
|
4
|
+
if (!cellValues)
|
|
5
|
+
return undefined;
|
|
6
|
+
return (row, columnId, value, context) => {
|
|
7
|
+
let values;
|
|
8
|
+
try {
|
|
9
|
+
values = cellValues(row, columnId, value, context);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const written = { ...row, ...values };
|
|
15
|
+
return columns.flatMap((col) => {
|
|
16
|
+
const read = col.editAccessor ?? col.accessor;
|
|
17
|
+
if (col.id === columnId || col.partOf || !read)
|
|
18
|
+
return [];
|
|
19
|
+
try {
|
|
20
|
+
const after = read(written);
|
|
21
|
+
const before = read(row);
|
|
22
|
+
const named = Object.hasOwn(values, fieldKeyOf(col)) || !sameListValue(after, before);
|
|
23
|
+
return named ? [{ columnId: col.id, value: after, baseline: before }] : [];
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
}
|
package/views/dist/grid/grid.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* THE GRID'S LOOK, by its options (GRID_LOOKS, grid/looks.ts): each rule under the option it draws, worn on a frame round the
|
|
2
2
|
grid as `data-grid-<option>="<value>"` (lookAttrs), and each option's default drawn with no frame too
|
|
3
|
-
(`:not([data-grid-<option>] *)`), so an app that wears no picks gets the default look,
|
|
3
|
+
(`:not([data-grid-<option>] *)`), so an app that wears no picks gets the default look, ViewKit's own. First drawn in the Showcase's ViewKit
|
|
4
4
|
add-on, after the table's canvas (UI Kit · sketch · table: Attio's look and the portal's). It reaches the grid only through
|
|
5
5
|
the contract: its named parts (data-slot), its states, the frame's options and the `data-kit` mark of ViewKit's own
|
|
6
6
|
controls, never a class it happens to use; and it reads only the contract's names (grid-tokens.ts, VK_GRID_TOKENS, beside
|
|
@@ -197,20 +197,24 @@
|
|
|
197
197
|
margin-inline-start: calc(var(--vk-spacing) * -1);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
/* Figures, Value first (Attio's): the footer's value, then its word in lower case, "13 count",
|
|
201
|
-
"+ Add calculation"
|
|
202
|
-
(vk-grid-figure-*). Word first is the grid's own: the word in capitals
|
|
200
|
+
/* Figures, Value first (Attio's): the footer's value, then its word in lower case, "13 count", both at the rows' size, and
|
|
201
|
+
an empty cell's offer "+ Add calculation" at the rows' size, regular, in the subtlest words, its words the app's message
|
|
202
|
+
(views.grid.figure-pick), its "+" drawn here (vk-grid-figure-*). Word first is the grid's own: the word in 10px capitals
|
|
203
|
+
before the value, "ADD CALCULATION". */
|
|
203
204
|
[data-grid-figures="value"] [data-slot="vk-grid-figure-value"] {
|
|
204
205
|
order: -1;
|
|
205
206
|
color: var(--vk-fg);
|
|
206
207
|
font-weight: var(--vk-font-weight-medium);
|
|
207
208
|
}
|
|
208
209
|
[data-grid-figures="value"] [data-slot="vk-grid-figure-label"] {
|
|
210
|
+
font-size: var(--vk-text);
|
|
209
211
|
text-transform: lowercase;
|
|
210
212
|
letter-spacing: normal;
|
|
211
213
|
color: var(--vk-fg-subtlest);
|
|
212
214
|
}
|
|
213
215
|
[data-grid-figures="value"] [data-slot="vk-grid-figure-pick"] {
|
|
216
|
+
font-size: var(--vk-text);
|
|
217
|
+
color: var(--vk-fg-subtlest);
|
|
214
218
|
text-transform: none;
|
|
215
219
|
letter-spacing: normal;
|
|
216
220
|
}
|
|
@@ -16,7 +16,7 @@ export type { GridGroupSortOption } from "./chrome/GridGroupMenu.js";
|
|
|
16
16
|
export type { GridGroupMenuPart } from "./chrome/grid-group-menu-parts.js";
|
|
17
17
|
export type { GridRowOpenedFrom } from "./core/row-opened-from.js";
|
|
18
18
|
export type { GridCellAt, GridCellPick, GridDeclaredFigure, GridDrawnFigure, GridGroupFigure, GridMenus, GridPages, GroupCountNoun, } from "./chrome/grid-table-props.js";
|
|
19
|
-
export type { GridCellCommitFn, GridCellsCommitFn, GridCommitContext, GridCommitOutcome, ListChange, ListSave, } from "./core/commit-model.js";
|
|
19
|
+
export type { GridCellCommitFn, GridCellValuesFn, GridCellsCommitFn, GridCommitContext, GridCommitOutcome, ListChange, ListSave, } from "./core/commit-model.js";
|
|
20
20
|
export { gridSave, type GridSaveOptions } from "./core/save-path.js";
|
|
21
21
|
export { deriveGridRelationValues, deriveGridSelectValues } from "./core/column-values.js";
|
|
22
22
|
export { cellCopyText, cellEditBaseline } from "./core/clipboard-model.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { GridGroupMenuPart } from "./chrome/grid-group-menu-parts.js";
|
|
2
2
|
import { type LookPicks, type PieceLooks } from "../looks/looks.js";
|
|
3
3
|
export type GridLookOptionId = "header" | "lines" | "columns" | "density" | "phone" | "name" | "edge" | "boxes" | "icon" | "picked" | "cell" | "corners" | "hover" | "highlight" | "frame" | "groups" | "names" | "phones" | "typed" | "figures" | "offer" | "width" | "more" | "wait" | "foot" | "add" | "picking";
|
|
4
|
-
/** The grid's options and its two looks, attio and portal. Nothing picked wears each option's default,
|
|
5
|
-
* (
|
|
4
|
+
/** The grid's options and its two looks, attio and portal. Nothing picked wears each option's default, ViewKit's own grid look
|
|
5
|
+
* (frozen on 5 Dec 2026), which differs from Attio's
|
|
6
6
|
* in ten options: its column lines all, its pinned edge a line, its checkboxes always, picked rows tinted and lined, round
|
|
7
7
|
* cell corners, a strong hover frame, groups under their own titles, names and phones as the grid draws them, its figures
|
|
8
8
|
* word first. */
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Whether a view transition is active on the page (`:active-view-transition`), being prepared or running. False where the
|
|
2
|
+
* browser doesn't know the selector, or there is no page. */
|
|
3
|
+
export declare function moving(): boolean;
|
|
4
|
+
/** `update` rendered before the paint (`flushSync`), or as a plain update while the page is moving. */
|
|
5
|
+
export declare function beforePaint(update: () => void): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { flushSync } from "react-dom";
|
|
2
|
+
export function moving() {
|
|
3
|
+
if (typeof document === "undefined")
|
|
4
|
+
return false;
|
|
5
|
+
try {
|
|
6
|
+
return document.documentElement.matches(":active-view-transition");
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function beforePaint(update) {
|
|
13
|
+
if (moving())
|
|
14
|
+
update();
|
|
15
|
+
else
|
|
16
|
+
flushSync(update);
|
|
17
|
+
}
|
|
@@ -9,14 +9,6 @@ export interface FieldRowsCard {
|
|
|
9
9
|
slot(id: string): HTMLElement | null;
|
|
10
10
|
}
|
|
11
11
|
export declare const FieldRowsCardContext: React.Context<FieldRowsCard | null>;
|
|
12
|
-
/** True inside a computer's SettingRows whose Fields option is At the end (VK-985): a Field placed in it is one of its rows, its
|
|
13
|
-
* control at the row's end. */
|
|
14
|
-
export declare const SettingRowField: React.Context<boolean>;
|
|
15
|
-
/** What stands at the end of such a Field row, and the row's name when its label is words: a RadioGroup there draws as a Select
|
|
16
|
-
* of its Radios, named by it. */
|
|
17
|
-
export declare const AtSettingRowEnd: React.Context<{
|
|
18
|
-
name?: string;
|
|
19
|
-
} | null>;
|
|
20
12
|
/** True inside a Field drawn as a row of Field rows: its Input or InputGroup stands typed in place, with no box. */
|
|
21
13
|
export declare const InFieldRow: React.Context<boolean>;
|
|
22
14
|
/** A place of its own: what it holds stands as it does anywhere else, no row of a Field rows card around it, whatever holds it.
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
export const FieldRowsCardContext = React.createContext(null);
|
|
3
|
-
export const SettingRowField = React.createContext(false);
|
|
4
|
-
export const AtSettingRowEnd = React.createContext(null);
|
|
5
3
|
export const InFieldRow = React.createContext(false);
|
|
6
4
|
export function OutOfFieldRows({ children }) {
|
|
7
|
-
return React.createElement(FieldRowsCardContext.Provider, { value: null }, React.createElement(InFieldRow.Provider, { value: false },
|
|
5
|
+
return React.createElement(FieldRowsCardContext.Provider, { value: null }, React.createElement(InFieldRow.Provider, { value: false }, children));
|
|
8
6
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The offsets a popover anchored to a box opens at over it. */
|
|
2
|
+
export type OverOffsets = {
|
|
3
|
+
sideOffset: number;
|
|
4
|
+
alignOffset: number;
|
|
5
|
+
};
|
|
6
|
+
/** Over the element's box, one spacing step up and one step left of it: minus its height and a step, minus a step. A step is
|
|
7
|
+
* 0 where no stylesheet declares one. */
|
|
8
|
+
export declare function overCellOffsets(el: HTMLElement): OverOffsets;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** What a placed filter bar places under the root besides `bar` (not on the door): its own, so the ready toolbar leaves it the filters. */
|
|
2
|
+
export declare const FILTER_BAR_KEY = "list-filter-bar";
|
|
3
|
+
/** What a placed filter bar standing by its button places too (not on the door), so a button's `opens="bar"` asks it open (VK-1092), and a rule
|
|
4
|
+
* held while it is hidden opens it (VK-1106). */
|
|
5
|
+
export declare const FILTER_BAR_BUTTON_KEY = "list-filter-bar-button";
|
|
6
|
+
/** What a placed filter bar standing always by the app's word places too (not on the door), so Customize's Filter bar row
|
|
7
|
+
* reads it while the person picked none. */
|
|
8
|
+
export declare const FILTER_BAR_ALWAYS_KEY = "list-filter-bar-always";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { ToolbarPanelHost } from "../panels/react/toolbar/panel-part.js";
|
|
3
|
+
import type { ToolbarPanelState } from "../panels/react/toolbar/panel-state.js";
|
|
4
|
+
import type { ListPart } from "./parts.js";
|
|
5
|
+
import type { ToolbarModel } from "./toolbar-model.js";
|
|
6
|
+
export { FILTER_BAR_BUTTON_KEY, FILTER_BAR_KEY } from "./bar-keys.js";
|
|
7
|
+
/** What the filter bar's pieces are built from: the model's, the bar's two panel states, and how it stands. */
|
|
8
|
+
export type FilterBarInput<Row> = Pick<ToolbarModel<Row>, "panels" | "differs" | "held" | "setHeld" | "savedFilter"> & {
|
|
9
|
+
/** It stands always (`bar: "always"`, `shows="always"`): every filter, its empty Filter, the sort standing undiffering. */
|
|
10
|
+
always: boolean;
|
|
11
|
+
/** The sort as the pill (`no`, today's) or its rules edited in place (`yes`; without `panels.sorts`, as `no`). */
|
|
12
|
+
sorts: "no" | "yes";
|
|
13
|
+
sortState: ToolbarPanelState;
|
|
14
|
+
filterState: ToolbarPanelState;
|
|
15
|
+
hosts?: {
|
|
16
|
+
sort?: ToolbarPanelHost;
|
|
17
|
+
filter?: ToolbarPanelHost;
|
|
18
|
+
};
|
|
19
|
+
/** Draws `yes`'s rules (`ToolbarBarSorts`), handed by the placed bar so the ready toolbar never loads it. */
|
|
20
|
+
barSorts?: (sorts: NonNullable<ToolbarModel<Row>["panels"]["sorts"]>, state: ToolbarPanelState) => ReactNode;
|
|
21
|
+
};
|
|
22
|
+
/** The filter bar's pieces as line parts, and whether they hold something (`filled`): a filter standing beyond the saved
|
|
23
|
+
* view's own or a rule held, or its sort part drawn. */
|
|
24
|
+
export declare function filterBarParts<Row>(input: FilterBarInput<Row>): {
|
|
25
|
+
parts: ListPart[];
|
|
26
|
+
holds: boolean;
|
|
27
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { heldStands } from "../panels/react/filter/editor-ctx.js";
|
|
4
|
+
import { ToolbarSeparator } from "../panels/react/toolbar/Toolbar.js";
|
|
5
|
+
import { ToolbarFilters, foldableFilters } from "../panels/react/toolbar/ToolbarFilters.js";
|
|
6
|
+
import { ToolbarSort } from "../panels/react/toolbar/ToolbarSort.js";
|
|
7
|
+
import { ToolbarSortPill } from "../panels/react/toolbar/ToolbarSortPill.js";
|
|
8
|
+
export { FILTER_BAR_BUTTON_KEY, FILTER_BAR_KEY } from "./bar-keys.js";
|
|
9
|
+
export function filterBarParts(input) {
|
|
10
|
+
const { panels, differs, held, setHeld, savedFilter, always, sortState, filterState, hosts } = input;
|
|
11
|
+
const tree = panels.filterTree;
|
|
12
|
+
const filtered = tree ? foldableFilters(tree.tree, null, savedFilter) > 0 || !!heldStands(held, tree.tree) : false;
|
|
13
|
+
const rules = input.sorts === "yes" && panels.sorts && input.barSorts ? panels.sorts : null;
|
|
14
|
+
const sort = rules
|
|
15
|
+
? rules.options.length > 0 && (always || rules.rules.length > 0)
|
|
16
|
+
? input.barSorts(rules, sortState)
|
|
17
|
+
: null
|
|
18
|
+
: (always || !!differs?.sort) && (panels.sorts ?? panels.sort).options.length > 0
|
|
19
|
+
? panels.sorts
|
|
20
|
+
? (_jsx(ToolbarSortPill, { sorts: panels.sorts, open: sortState.open, onOpenChange: sortState.onOpenChange, host: hosts?.sort, addAfter: false }))
|
|
21
|
+
: _jsx(ToolbarSort, { bar: true, sort: panels.sort, open: sortState.open, onOpenChange: sortState.onOpenChange, host: hosts?.sort })
|
|
22
|
+
: null;
|
|
23
|
+
const parts = [
|
|
24
|
+
...(sort ? [{ key: "sort-pill", line: 2, node: sort }] : []),
|
|
25
|
+
...(sort && (filtered || always) ? [{ key: "sep", line: 2, role: "separator", node: _jsx(ToolbarSeparator, {}) }] : []),
|
|
26
|
+
...(tree
|
|
27
|
+
? [
|
|
28
|
+
{
|
|
29
|
+
key: "filters",
|
|
30
|
+
line: 2,
|
|
31
|
+
filters: foldableFilters(tree.tree, held, always ? undefined : savedFilter),
|
|
32
|
+
node: (_jsx(ToolbarFilters, { filterTree: tree, open: filterState.open, onOpenChange: filterState.onOpenChange, held: held, onHeldChange: setHeld, host: hosts?.filter, emptyPlace: always, ...(!always && savedFilter && { saved: savedFilter }) })),
|
|
33
|
+
},
|
|
34
|
+
]
|
|
35
|
+
: []),
|
|
36
|
+
];
|
|
37
|
+
return { parts, holds: filtered || !!sort };
|
|
38
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type ListClearSaveProps = Record<string, never>;
|
|
3
|
+
export declare function ListClearSave(_props: ListClearSaveProps): ReactNode;
|
|
4
|
+
/** Clear and Save in a line (not on the door, VK-1105): as the ready bar's, never folding. */
|
|
5
|
+
export declare const SAVE_ITEM: {
|
|
6
|
+
readonly key: "save";
|
|
7
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { ToolbarSave } from "../../panels/react/toolbar/ToolbarSave.js";
|
|
5
|
+
import { useToolbarModel } from "../toolbar-model.js";
|
|
6
|
+
import { LineItem } from "../line.js";
|
|
7
|
+
import { ReadyPiece, useReadyParts } from "../ready.js";
|
|
8
|
+
import { usePartPhone } from "./shared.js";
|
|
9
|
+
export function ListClearSave(_props) {
|
|
10
|
+
const phone = usePartPhone();
|
|
11
|
+
const ready = useReadyParts();
|
|
12
|
+
const { view, layered, clearable, resetAll } = useToolbarModel({ phone, fromRoot: true });
|
|
13
|
+
const piece = useContext(ReadyPiece);
|
|
14
|
+
const only = piece === "clear" || piece === "save" ? piece : undefined;
|
|
15
|
+
if (phone && !ready)
|
|
16
|
+
return null;
|
|
17
|
+
return (_jsx(LineItem, { item: SAVE_ITEM, children: _jsx(ToolbarSave, { view: view, layered: layered, onClear: clearable ? resetAll : undefined, ...(only && { only }) }) }));
|
|
18
|
+
}
|
|
19
|
+
export const SAVE_ITEM = { key: "save" };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { PanelFieldEditor } from "../../panels/react/field-editor.js";
|
|
3
|
+
import type { ViewsCustomizeItems } from "../../provider/components.js";
|
|
4
|
+
import { type ListOpens, type ListWords } from "./shared.js";
|
|
5
|
+
export type ListCustomizeProps = {
|
|
6
|
+
/** Where its panel opens. Default `popover`. */
|
|
7
|
+
opens?: ListOpens;
|
|
8
|
+
words?: ListWords;
|
|
9
|
+
/** The view's name in Customize's head, renamed in place where `onRenameView` is handed too. */
|
|
10
|
+
viewName?: string;
|
|
11
|
+
onRenameView?: (name: string) => void;
|
|
12
|
+
/** Copy link to view, in Customize's foot, where handed. */
|
|
13
|
+
onCopyLink?: () => void;
|
|
14
|
+
/** Export CSV, in Customize's foot, where handed, with what it takes in words (`exportCount`, "12 deals"). */
|
|
15
|
+
onExport?: () => void;
|
|
16
|
+
exportCount?: string;
|
|
17
|
+
fieldEditor?: PanelFieldEditor | null;
|
|
18
|
+
/** Customize's rows as data (as the ready toolbar's `menus.customize`): handed its list's, Layout's and Columns' default rows, it
|
|
19
|
+
* hands back the rows drawn. */
|
|
20
|
+
menu?: ViewsCustomizeItems;
|
|
21
|
+
};
|
|
22
|
+
export declare function ListCustomize({ opens, words, viewName, onRenameView, onCopyLink, onExport, exportCount, fieldEditor, menu }: ListCustomizeProps): ReactNode;
|
|
23
|
+
/** Customize in a line (not on the door, VK-1105): its word, then into ⋯. */
|
|
24
|
+
export declare const CUSTOMIZE_ITEM: {
|
|
25
|
+
readonly key: "options";
|
|
26
|
+
readonly shed: true;
|
|
27
|
+
readonly fold: true;
|
|
28
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { ToolbarOptions } from "../../panels/react/toolbar/ToolbarOptions.js";
|
|
4
|
+
import { useViews } from "../../provider/context.js";
|
|
5
|
+
import { LineItem, useLineMore } from "../line.js";
|
|
6
|
+
import { useReadyParts } from "../ready.js";
|
|
7
|
+
import { PartFrame, PlacedButton, PressButton, menuPress, usePartPanel, usePlacedPanel } from "./shared.js";
|
|
8
|
+
export function ListCustomize({ opens, words, viewName, onRenameView, onCopyLink, onExport, exportCount, fieldEditor, menu }) {
|
|
9
|
+
const { icons, messages } = useViews();
|
|
10
|
+
const panel = usePartPanel("ListCustomize", "customize", opens);
|
|
11
|
+
const placed = usePlacedPanel("customize");
|
|
12
|
+
const more = useLineMore();
|
|
13
|
+
const ready = useReadyParts();
|
|
14
|
+
const { fielded, state, host, press } = panel;
|
|
15
|
+
const { inputs, view, layered, clearable, resetAll, resets } = panel.model;
|
|
16
|
+
if (!fielded)
|
|
17
|
+
return null;
|
|
18
|
+
const Glyph = icons.options;
|
|
19
|
+
const item = {
|
|
20
|
+
...CUSTOMIZE_ITEM,
|
|
21
|
+
menu: { label: messages({ key: "views.panels.toolbar-options" }), icon: _jsx(Glyph, { className: "h-4 w-4" }), onSelect: menuPress(placed, press, more, state) },
|
|
22
|
+
};
|
|
23
|
+
const line = (node) => _jsx(LineItem, { item: item, children: node });
|
|
24
|
+
if (placed.placed)
|
|
25
|
+
return line(_jsx(PartFrame, { panel: panel, words: words, children: _jsx(PlacedButton, { part: "options", icon: _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: messages({ key: "views.panels.toolbar-options" }), panel: placed }) }));
|
|
26
|
+
if (press)
|
|
27
|
+
return line(_jsx(PartFrame, { panel: panel, words: words, children: _jsx(PressButton, { part: "options", icon: _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: messages({ key: "views.panels.toolbar-options" }), onPress: press }) }));
|
|
28
|
+
const foot = ready?.customizeFoot ?? "parts";
|
|
29
|
+
return line(_jsx(PartFrame, { panel: panel, words: words, children: _jsx(ToolbarOptions, { ...inputs, view: view, ...(layered && { layered }), viewFoot: foot === "none" ? "none" : foot === "own" || view ? undefined : "kit", footClear: foot === "parts" && clearable ? resetAll : undefined, resets: resets, customizeItems: menu, fieldEditor: fieldEditor, onClear: resetAll, open: state.open, onOpenChange: state.onOpenChange, page: state.page, onPageChange: state.onPageChange, host: host, ...(viewName !== undefined && { viewName }), ...(onRenameView && { onRenameView }), ...(onCopyLink && { onCopyLink }), ...(onExport && { onExport }), ...(exportCount !== undefined && { exportCount }) }) }));
|
|
30
|
+
}
|
|
31
|
+
export const CUSTOMIZE_ITEM = { key: "options", shed: true, fold: true };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type Pending } from "../../panels/react/filter/editor-ctx.js";
|
|
3
|
+
import type { FilterTree } from "viewkitjs/fields/query";
|
|
4
|
+
import { type ReadyParts } from "../ready.js";
|
|
5
|
+
import { type ListOpens, type ListWords } from "./shared.js";
|
|
6
|
+
export type ListFilterProps = {
|
|
7
|
+
/** Where its panel opens; `bar`: a picked field's filter stands on the filter bar, where one is placed. Default `popover`. */
|
|
8
|
+
opens?: ListOpens | "bar";
|
|
9
|
+
/** What it opens with no filter set: the fields (`fields`, the default), or the filter editor saying so (`editor`). Means
|
|
10
|
+
* nothing with `opens="bar"` (the fields every time), on a phone, or without and/or groups (`filterGroups` false). */
|
|
11
|
+
empty?: "fields" | "editor";
|
|
12
|
+
words?: ListWords;
|
|
13
|
+
};
|
|
14
|
+
export declare function ListFilter({ opens, empty, words }: ListFilterProps): ReactNode;
|
|
15
|
+
/** Filter in a line (not on the door, VK-1105): its word, then into ⋯; its key by `filterItemKey`. */
|
|
16
|
+
export declare const FILTER_ITEM: {
|
|
17
|
+
readonly shed: true;
|
|
18
|
+
readonly fold: true;
|
|
19
|
+
};
|
|
20
|
+
/** Filter's key in a line (not on the door, VK-1106): the bar form's filters `filters`; plain Filter `filter`; else, a placed
|
|
21
|
+
* Filter's, `filter-add` with and/or groups on a computer, `filter` otherwise. */
|
|
22
|
+
export declare function filterItemKey(ready: ReadyParts["filter"] | undefined, tree: boolean, phone: boolean): "filter-add" | "filter" | "filters";
|
|
23
|
+
/** The bar form's filters in a line (not on the door, VK-1106): each filter folding into "+N filters"; while none stands or is
|
|
24
|
+
* held, Filter, whose words may turn to its icon and which may fold into ⋯. */
|
|
25
|
+
export declare function barFiltersItem(tree: FilterTree, held: Pending | null): {
|
|
26
|
+
shed?: true;
|
|
27
|
+
fold?: true;
|
|
28
|
+
filters?: number;
|
|
29
|
+
};
|
|
30
|
+
/** The and/or filters' pill (not on the door, VK-1106): each advanced filter's pill, opening the filter editor, in the ready
|
|
31
|
+
* toolbar after its Filter until the bar takes them; nothing without the groups. */
|
|
32
|
+
export declare function ListAdvancedFilters(): ReactNode;
|