@nxgt/material-core 0.14.0 → 0.15.0-next-20261013091433

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +274 -4
  3. package/dist/chunks/index-54gkyr43.js +23 -0
  4. package/dist/chunks/index-54gkyr43.js.map +10 -0
  5. package/dist/chunks/index-zpm2cke7.js +50 -0
  6. package/dist/chunks/index-zpm2cke7.js.map +10 -0
  7. package/dist/data-grid/aggregates.d.ts +16 -0
  8. package/dist/data-grid/aggregates.d.ts.map +1 -0
  9. package/dist/data-grid/announce.d.ts +41 -0
  10. package/dist/data-grid/announce.d.ts.map +1 -0
  11. package/dist/data-grid/change-ops.d.ts +29 -0
  12. package/dist/data-grid/change-ops.d.ts.map +1 -0
  13. package/dist/data-grid/change-select.d.ts +25 -0
  14. package/dist/data-grid/change-select.d.ts.map +1 -0
  15. package/dist/data-grid/change-types.d.ts +72 -0
  16. package/dist/data-grid/change-types.d.ts.map +1 -0
  17. package/dist/data-grid/changes.d.ts +46 -0
  18. package/dist/data-grid/changes.d.ts.map +1 -0
  19. package/dist/data-grid/conflict-text.d.ts +20 -0
  20. package/dist/data-grid/conflict-text.d.ts.map +1 -0
  21. package/dist/data-grid/date-cell.d.ts +53 -0
  22. package/dist/data-grid/date-cell.d.ts.map +1 -0
  23. package/dist/data-grid/discard.d.ts +15 -0
  24. package/dist/data-grid/discard.d.ts.map +1 -0
  25. package/dist/data-grid/edit-messages.d.ts +6 -0
  26. package/dist/data-grid/edit-messages.d.ts.map +1 -0
  27. package/dist/data-grid/edit-session.d.ts +107 -0
  28. package/dist/data-grid/edit-session.d.ts.map +1 -0
  29. package/dist/data-grid/exports-announce.d.ts +7 -0
  30. package/dist/data-grid/exports-announce.d.ts.map +1 -0
  31. package/dist/data-grid/exports-clipboard.d.ts +7 -0
  32. package/dist/data-grid/exports-clipboard.d.ts.map +1 -0
  33. package/dist/data-grid/exports-editing.d.ts +14 -0
  34. package/dist/data-grid/exports-editing.d.ts.map +1 -0
  35. package/dist/data-grid/exports-model.d.ts +10 -0
  36. package/dist/data-grid/exports-model.d.ts.map +1 -0
  37. package/dist/data-grid/exports-navigation.d.ts +8 -0
  38. package/dist/data-grid/exports-navigation.d.ts.map +1 -0
  39. package/dist/data-grid/exports-rows.d.ts +7 -0
  40. package/dist/data-grid/exports-rows.d.ts.map +1 -0
  41. package/dist/data-grid/exports-saving.d.ts +16 -0
  42. package/dist/data-grid/exports-saving.d.ts.map +1 -0
  43. package/dist/data-grid/history.d.ts +46 -0
  44. package/dist/data-grid/history.d.ts.map +1 -0
  45. package/dist/data-grid/index.d.ts +16 -0
  46. package/dist/data-grid/index.d.ts.map +1 -0
  47. package/dist/data-grid/index.js +1831 -0
  48. package/dist/data-grid/index.js.map +40 -0
  49. package/dist/data-grid/key-types.d.ts +82 -0
  50. package/dist/data-grid/key-types.d.ts.map +1 -0
  51. package/dist/data-grid/keys.d.ts +16 -0
  52. package/dist/data-grid/keys.d.ts.map +1 -0
  53. package/dist/data-grid/model.d.ts +52 -0
  54. package/dist/data-grid/model.d.ts.map +1 -0
  55. package/dist/data-grid/msg.d.ts +22 -0
  56. package/dist/data-grid/msg.d.ts.map +1 -0
  57. package/dist/data-grid/navigation.d.ts +33 -0
  58. package/dist/data-grid/navigation.d.ts.map +1 -0
  59. package/dist/data-grid/number-codes.d.ts +62 -0
  60. package/dist/data-grid/number-codes.d.ts.map +1 -0
  61. package/dist/data-grid/number-messages.d.ts +21 -0
  62. package/dist/data-grid/number-messages.d.ts.map +1 -0
  63. package/dist/data-grid/paste-plan.d.ts +43 -0
  64. package/dist/data-grid/paste-plan.d.ts.map +1 -0
  65. package/dist/data-grid/range.d.ts +52 -0
  66. package/dist/data-grid/range.d.ts.map +1 -0
  67. package/dist/data-grid/rebase.d.ts +10 -0
  68. package/dist/data-grid/rebase.d.ts.map +1 -0
  69. package/dist/data-grid/same-value.d.ts +7 -0
  70. package/dist/data-grid/same-value.d.ts.map +1 -0
  71. package/dist/data-grid/save-answer.d.ts +26 -0
  72. package/dist/data-grid/save-answer.d.ts.map +1 -0
  73. package/dist/data-grid/save-failure.d.ts +32 -0
  74. package/dist/data-grid/save-failure.d.ts.map +1 -0
  75. package/dist/data-grid/save-queue.d.ts +79 -0
  76. package/dist/data-grid/save-queue.d.ts.map +1 -0
  77. package/dist/data-grid/save-versions.d.ts +11 -0
  78. package/dist/data-grid/save-versions.d.ts.map +1 -0
  79. package/dist/data-grid/select-options.d.ts +34 -0
  80. package/dist/data-grid/select-options.d.ts.map +1 -0
  81. package/dist/data-grid/sort-snapshot.d.ts +22 -0
  82. package/dist/data-grid/sort-snapshot.d.ts.map +1 -0
  83. package/dist/data-grid/standard-schema.d.ts +38 -0
  84. package/dist/data-grid/standard-schema.d.ts.map +1 -0
  85. package/dist/data-grid/tsv.d.ts +29 -0
  86. package/dist/data-grid/tsv.d.ts.map +1 -0
  87. package/dist/data-grid/types.d.ts +89 -0
  88. package/dist/data-grid/types.d.ts.map +1 -0
  89. package/dist/data-grid/validate.d.ts +66 -0
  90. package/dist/data-grid/validate.d.ts.map +1 -0
  91. package/dist/data-grid/version.d.ts +22 -0
  92. package/dist/data-grid/version.d.ts.map +1 -0
  93. package/dist/lib/escape-forward.d.ts +6 -0
  94. package/dist/lib/escape-forward.d.ts.map +1 -1
  95. package/dist/lib/escape-forward.js +9 -1
  96. package/dist/lib/escape-forward.js.map +3 -3
  97. package/dist/lib/parse-number.d.ts +27 -0
  98. package/dist/lib/parse-number.d.ts.map +1 -0
  99. package/dist/lib/parse-number.js +15 -0
  100. package/dist/lib/parse-number.js.map +9 -0
  101. package/dist/lib/text-match.js +7 -21
  102. package/dist/lib/text-match.js.map +3 -4
  103. package/docs/roadmap.md +10 -1
  104. package/package.json +15 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @nxgt/material-core
2
2
 
3
+ ## 0.15.0-next-20261013091433
4
+
5
+ ### Minor Changes
6
+
7
+ - [#693](https://github.com/softistx/nxgt-material/pull/693) [`075693d`](https://github.com/softistx/nxgt-material/commit/075693dda8355458d3a2795277bfba0de14a773b) Thanks [@SteveGT96](https://github.com/SteveGT96)! - `@nxgt/material-core/data-grid`: the pure half of the coming editable `DataGrid` — its model (rows and columns by position and key, what each cell allows, the version each cell was read from, per cell with the row's as the fallback), navigation and keyboard commands (arrows over the header, body and footer rows, Home/End and Ctrl/Cmd+Left/Right, Ctrl/Cmd+Up/Down to a column's ends, Ctrl/Cmd+Home/End, PageUp/PageDown, Tab and Enter skipping cells that cannot be edited, RTL), the selected range, the edit session, validation (a column's parse, then `validate`, then any Standard Schema; the server's refusals by entry index), a number column with codes (`numberCodes`: "abs" or "disp" in any language, `,` or `.` as the decimal separator, bounds and decimals, an empty text clearing the cell) and the live region's message descriptors.
8
+
9
+ `@nxgt/material-core/parse-number`: `parseNumberInput`, `clampNumber` and `stepNumber` move here from `@nxgt/material`'s `NumberField`, plus `decimalsTyped`; they read a number as `NumberField` does, directional marks skipped and `−` as a minus.
10
+
11
+ - [#699](https://github.com/softistx/nxgt-material/pull/699) [`b13f08a`](https://github.com/softistx/nxgt-material/commit/b13f08a5c1a92f362ecd4e1f365173b5a8eb88f6) Thanks [@SteveGT96](https://github.com/SteveGT96)! - `@nxgt/material-core/data-grid`: the rest of the coming editable `DataGrid`'s pure half — the changes per cell (`editCell`, each change keeping the value and the version it was read at, per cell with the row's as the fallback; `rebase` after a refetch, a moved version and value turning a pending edit into a conflict while a cell whose value is still its base adopts the new version; a saved value, and "Keep theirs", kept as an overlay until the app's rows hold it, a refetch still read at the version a save or a conflict replaced changing nothing; `resolveConflict` with "theirs" or "mine"; a conflict outliving any edit until it is resolved; `expireSaved`; `changeCounts` and `blocking`), the save queue (`startCall`, `applyAnswer`, `applyFailure`, `applyAbort`, `retry`: one call in flight at a time; per cell up to 200 entries a call, per row once the row is left, or in one batch on `save()` with no limit, blocked while a cell is in error or in conflict; an answer is all or nothing, `versions[i]` updating entry `i`'s cells (and, with `versionScope: 'row'`, the row's other changes) and a refusal flagging its cells as errors or conflicts; paused after 3 failures in a row, an abort counting none), undo and redo (`record`, `undo`, `redo`: 100 steps, an undo is a new edit, cells changed since are skipped and counted), tab-separated copy and paste as Excel and Google Sheets write it, a cell with a quote and no line break read raw (`parseTsv`, `serializeTsv`), the all-or-nothing paste plan (`planPaste`: past the grid, locked, read-only, computed, not parsed and invalid cells listed as problems), the totals' aggregates (`aggregate`: sum, mean, min, max, count, or the app's own, over numbers only; a count of nothing is 0), the sort order kept while editing (`reconcileOrder`) and the conflict panel's two values, a cleared one reading "Cleared" (`conflictValues`).
12
+
13
+ - [#769](https://github.com/softistx/nxgt-material/pull/769) [`8e4cdfa`](https://github.com/softistx/nxgt-material/commit/8e4cdfae4d67d6563f916e35112cadac8d54e2ce) Thanks [@SteveGT96](https://github.com/SteveGT96)! - `@nxgt/material-core/escape-forward`: a control marked `data-keeps-escape` keeps Escape from the Dialog, Sheet, Drawer, AlertDialog or Popover around it (in both libraries), as a field whose list is open does; `isKeptEscape(event)` tells such an Escape from one the page prevented.
14
+
3
15
  ## 0.14.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -10,8 +10,8 @@ the date range presets, a debounce, accent-insensitive text matching and a race-
10
10
  rule, a field's first reachable control (`/focus-control`) and its `aria-describedby`
11
11
  (`/described-by`), where the focus goes in a repeatable row group
12
12
  (`/repeatable-group`), the page behind a modal layer made inert
13
- (`/inert-others`), Escape pressed while an overlay closes or in a field whose
14
- list is open (`/escape-forward`), the Toaster's guard against a tap's emulated hover
13
+ (`/inert-others`), Escape pressed while an overlay closes, in a field whose
14
+ list is open or in a control marked `data-keeps-escape` (`/escape-forward`), the Toaster's guard against a tap's emulated hover
15
15
  (`/touch-hover`), the focus a toast's action hands back (`/toast-focus`), a
16
16
  table row's activation, the zod error map's issue messages
17
17
  (`/zod-issue-messages`), a zod error map that words an issue by its code
@@ -30,7 +30,8 @@ re-export what they always exported, at the same subpaths:
30
30
  from here, and so do their `PdfReader`, `CurrencyField`, form fields (their
31
31
  focus, blur, `aria-describedby` and zod messages), file list and upload
32
32
  field (`formatFileSize`), modal layers (the inert page behind, Escape while
33
- closing, Escape in a field whose list is open), `Toaster`, `DataTable` rows, `@nxgt/material/next` and
33
+ closing, Escape in a field whose list is open or in a control marked
34
+ `data-keeps-escape`), `Toaster`, `DataTable` rows, `@nxgt/material/next` and
34
35
  `@nxgt/material-vue/nuxt`. Import it directly when you want the model or a
35
36
  formatter without a UI library, or one of these helpers in a component of
36
37
  your own.
@@ -92,7 +93,7 @@ can reach. No other subpath imports a `node:` built-in.
92
93
  | `/field-blur-layers` | `layerOf`, `openerOf`, `FieldLayers` — whose overlay a layer of the page is, for a field's blur |
93
94
  | `/focus-control` | `firstControl`, `focusHandle`, `FocusHandle` — the first control of a field a user can reach, and a stand-in element that focuses it for a form library |
94
95
  | `/repeatable-group` | `focusAfterRemove`, `focusAfterMove`, `focusRowTarget`, `rowMoveTarget`, `canAddRow`, `canRemoveRow`, `RowFocusTarget`, `RowMoveDirection`, `RowAnnouncement`, `ROW_SLOT`, `ROW_FIELDS_SLOT`, `ADD_ATTRIBUTE` — where the focus goes after a row of a `RepeatableGroup` is added, removed or moved, and what its live region says |
95
- | `/escape-forward` | `forwardEscape`, `keepListEscape` — Escape pressed while an overlay closes, pressed again for the overlay below once it has gone; Escape pressed in a field whose list is open, kept from closing the overlay around it |
96
+ | `/escape-forward` | `forwardEscape`, `keepListEscape`, `isKeptEscape` — Escape pressed while an overlay closes, pressed again for the overlay below once it has gone; Escape pressed in a field whose list is open, or in a control marked `data-keeps-escape`, kept from closing the overlay around it, and told from an Escape the page prevented |
96
97
  | `/described-by` | `describedBy` — an `aria-describedby` value from the caller's ids and a field's help and error ids |
97
98
  | `/inert-others` | `inertOthers`, `INERT_MARKER` — the rest of the page `inert` behind a modal layer, live regions kept, nested layers counted |
98
99
  | `/backgrounds` | `buildBackgroundScene`, `buildGrain`, `assertSafeScene`, `svgIdPrefix`, `observeBackgroundActivity`, `mulberry32`, `valueNoise2`, `scatter`, `motifShape`, `place`, `BACKGROUND_PRESETS`, `SHIPPED_BACKGROUND_PRESETS`, `resolveShippedPreset`, `BACKGROUND_TONES`, `MOTIF_SHAPES`, `MOTIF_DEFAULTS` and the types `BackgroundPreset`, `ShippedBackgroundPreset`, `BackgroundTone`, `BackgroundIntensity`, `MotifOptions`, `SceneNode`, `PresetInfo` — the engine behind the libraries' background presets: a seeded generator, scattering, motif shapes, a plain SVG scene format with its safety check, ids for `url(#…)`, and the observer that pauses an animation |
@@ -120,6 +121,8 @@ can reach. No other subpath imports a `node:` built-in.
120
121
  | `/states` | `EMPTY_STATE_KINDS`, `ERROR_STATE_KINDS`, `resolveEmptyStateKind`, `isErrorKind`, `stateCopy`, `STATE_ACTION_KEYS`, `describeError`, `STATE_ILLUSTRATIONS`, `STATE_ACCENT`, `STATE_ICON` and the types `EmptyStateKind`, `ErrorStateKind`, `StateKind`, `LegacyEmptyStateVariant`, `StateFamily`, `StateCopy`, `ErrorDetail`, `StateIllustration`, `IllustrationShape`, `IllustrationTone`, `StateAccent`, `StateIconName` — the kinds, copy keys, error details and illustrations behind `EmptyState` and `ErrorState` |
121
122
  | `/vite` | `nxgtMaterial()`, `pdfkitStandardFonts()`, `cspAssetsInlineLimit`, `CSP_NONCE_PLACEHOLDER`, `ZOD_JITLESS_SCRIPT` and the types `NxgtMaterialOptions`, `NxgtMaterialCspOptions`, `NxgtMaterialLibrary` — see below |
122
123
  | `/pdfkit-fonts` | **Node only.** `pdfkitStandardFontDirs`, `pdfkitStandardFontFiles`, `PDFKIT_STANDARD_FONTS`, the types `PdfkitStandardFont` and `PdfkitFontsWarn` — where the app's pdfkit keeps its standard fonts, for a server tracer |
124
+ | `/data-grid` | **Headless**, for the editable `DataGrid` coming in `@nxgt/material`; nothing renders yet. The model (`buildGridModel`, `cellAccess`, `cellVersion` and `isNewCellVersion`), navigation (`navigate`, `gridCommandFor`), the range (`extend`, `selectAll`, `rangeCells`, …), the edit session (`editReducer`), validation (`validateCell`, `serverErrors`, `refusalsByCell`, Standard Schema), `numberCodes`, the changes per cell (`NO_CHANGES`, `editCell`, `rebase`, `resolveConflict`, `expireSaved`, `changeCounts`, `blocking`), the save queue (`IDLE_QUEUE`, `nextCall`, `startCall`, `applyAnswer`, `applyFailure`, `applyAbort`, `retry`), undo and redo (`EMPTY_HISTORY`, `record`, `undo`, `redo`), copy and paste (`parseTsv`, `serializeTsv`, `planPaste`), the totals (`aggregate`), the kept sort order (`snapshotOrder`, `reconcileOrder`, `sortingChanged`), the conflict panel's text (`conflictValues`, `conflictSummary`, `clearedText`) and the live region's descriptors (`savedMessage`, `cellStateText`, …), with the types `GridModel`, `GridColumnSpec`, `GridRowSpec`, `GridMsg`, `GridPos`, `GridRange`, `GridVersion`, `GridCode`, `GridChanges`, `GridSaveQueue`, `GridCall`, `GridSaveAnswer`, `GridHistory`, `GridStep`, `GridPasteInput`, `GridPastePlan`, `GridPasteProblem`, `GridAggregate` and `GridSort`. A cell's version is `0` or `undefined` when it does not exist yet on the server. See below |
125
+ | `/parse-number` | `parseNumberInput`, `decimalsTyped`, `clampNumber`, `stepNumber` — a typed number read with `,` or `.` as its decimal separator, its typed decimals, and the clamp and step behind `NumberField` |
123
126
 
124
127
  ## Usage
125
128
 
@@ -1079,6 +1082,30 @@ list sits in a `[data-slot="combobox-content"]` popup (a command palette's
1079
1082
  input is not), or when it carries `data-list-open="true"` (the Vue
1080
1083
  `Autocomplete`'s textbox).
1081
1084
 
1085
+ A control that handles Escape itself (a grid's cell editor, whose Escape
1086
+ cancels the edit; a grid cell whose Escape collapses a selected range)
1087
+ carries `data-keeps-escape`, or sits inside an element that does (a grid's
1088
+ paste-problems panel, whose Escape closes it): `keepListEscape` keeps its
1089
+ Escape from the overlay around it too. Its own handler then sees `defaultPrevented` true,
1090
+ for an Escape that is still its own: `isKeptEscape(event)` is `true` for an
1091
+ Escape `keepListEscape` kept (and only for one), so the handler can tell it
1092
+ from an Escape something else prevented.
1093
+
1094
+ ```tsx
1095
+ import { isKeptEscape } from '@nxgt/material-core/escape-forward';
1096
+
1097
+ declare function cancelEdit(): void;
1098
+
1099
+ <input
1100
+ data-keeps-escape=""
1101
+ onKeyDown={(event) => {
1102
+ const native = event.nativeEvent;
1103
+ if (event.defaultPrevented && !isKeptEscape(native)) return;
1104
+ if (event.key === 'Escape') cancelEdit(); // the dialog stays open
1105
+ }}
1106
+ />;
1107
+ ```
1108
+
1082
1109
  ```ts
1083
1110
  import { forwardEscape, keepListEscape } from '@nxgt/material-core/escape-forward';
1084
1111
 
@@ -1382,6 +1409,249 @@ You rarely call it yourself: `withNxgtPrint` (`@nxgt/material/next`) turns
1382
1409
  the directories into `outputFileTracingIncludes` globs, and the Nuxt module
1383
1410
  of `@nxgt/material-vue` adds the files to `nitro.externals.traceInclude`.
1384
1411
 
1412
+ ### An editable grid's pure half: `/data-grid`
1413
+
1414
+ The logic behind the editable `DataGrid` that is coming to `@nxgt/material`,
1415
+ with nothing rendered yet: where a cell is, which cell a key moves to, what a
1416
+ typed text parses to, and the messages to announce. It never reads the DOM, so
1417
+ it also runs in a test or on a server. Positions are `{ row, col }`; the header
1418
+ row is `-1` and the footer rows follow the body.
1419
+
1420
+ ```ts
1421
+ import {
1422
+ buildGridModel,
1423
+ cellVersion,
1424
+ gridCommandFor,
1425
+ gridPlatform,
1426
+ isGridPos,
1427
+ navigate,
1428
+ numberCodes,
1429
+ validateCell,
1430
+ type GridPos,
1431
+ } from '@nxgt/material-core/data-grid';
1432
+
1433
+ type Row = { id: string; outOf: number; version?: number };
1434
+
1435
+ const model = buildGridModel({
1436
+ columns: [
1437
+ { id: 'name', label: 'Name', frozen: true },
1438
+ { id: 'maths', label: 'Maths', editor: 'number' },
1439
+ ],
1440
+ rows: [{ id: 'ada' }, { id: 'alan' }],
1441
+ });
1442
+
1443
+ // A key press is a command, and a command takes the active cell somewhere.
1444
+ const key = { key: 'ArrowDown', shiftKey: false, ctrlKey: false, metaKey: false, altKey: false };
1445
+ const command = gridCommandFor(key, 'nav', gridPlatform(navigator.platform));
1446
+ // { type: 'move', cmd: 'down' }
1447
+
1448
+ let active: GridPos = { row: 0, col: 1 };
1449
+ if (command?.type === 'move') {
1450
+ const next = navigate(active, command.cmd, {
1451
+ model,
1452
+ pageSize: 10,
1453
+ dir: 'ltr',
1454
+ skipReadOnly: true,
1455
+ });
1456
+ if (isGridPos(next)) active = next; // else 'exit-forward' / 'exit-back': leave the grid
1457
+ }
1458
+
1459
+ // A number column that also takes codes, in any language, with `,` or `.`.
1460
+ const grades = numberCodes<Row>({
1461
+ min: 0,
1462
+ max: (row) => row.outOf,
1463
+ decimals: 2,
1464
+ codes: [{ value: 'ABS', labels: { en: 'abs', fr: 'abs' }, aliases: { fr: ['absent'] } }],
1465
+ });
1466
+ const row: Row = { id: 'ada', outOf: 20 };
1467
+
1468
+ grades.parse('abs', { lang: 'fr', row }); // { value: 'ABS' }
1469
+ grades.parse('12,5', { lang: 'fr', row }); // { value: 12.5 }
1470
+ grades.parse('25', { lang: 'en', row }); // { error: GridMsg } — "Enter a number from 0 to 20"
1471
+
1472
+ // Parse, then the column's check, then a Standard Schema: the first error wins.
1473
+ const result = validateCell({
1474
+ text: '12,5',
1475
+ row,
1476
+ parse: (text) => grades.parse(text, { lang: 'fr', row }),
1477
+ });
1478
+ // { ok: true, value: 12.5 } or { ok: false, error: GridMsg }
1479
+
1480
+ // The version the server gave a cell: per cell, else the row's.
1481
+ cellVersion(row, 'maths', { getRowVersion: (r) => r.version });
1482
+ ```
1483
+
1484
+ - **Messages are descriptors.** Every error and announcement is a `GridMsg`
1485
+ (`{ key: 'material.data-grid.…', fallback, values? }`): the library
1486
+ translates `key`, and `gridFallbackText(message)` gives the English text.
1487
+ - **Versions are passed through unchanged.** `cellVersion` answers
1488
+ `getCellVersion` when it is given, else `getRowVersion`, else `undefined`;
1489
+ `isNewCellVersion` is true for `0` and `undefined`, a cell that does not
1490
+ exist yet on the server.
1491
+ - **Numbers are never rounded or clamped.** Too many decimals or a value out
1492
+ of bounds is an error. Spaces are stripped (`"1 234"` is 1234), but a
1493
+ second separator is refused: `"1,234"` is 1.234 and `"1,234.5"` an error.
1494
+ `parse` needs the row; with a bound that is a function of the row and no
1495
+ row, it refuses the number rather than let it through unchecked.
1496
+ - **A cleared cell skips the schema.** `null` still runs `validate`, but not
1497
+ the Standard Schema, so a `z.number()` does not refuse a clear; refuse an
1498
+ empty cell in `validate` (or with `numberCodes({ emptyClears: false })`).
1499
+ Without `parse`, the value is the text: a column whose value is not a
1500
+ string must give one.
1501
+ - **Tab in an editor always moves on.** `tabBehavior: 'exit'` makes Tab leave
1502
+ the grid from a cell, but a commit's Tab (`commitNext` / `commitPrev`)
1503
+ still walks the cells. `gridCommandFor` returns `{ type: 'swallow' }` for
1504
+ the browser's back and forward (Alt+Arrow, Cmd+[ and Cmd+]): call
1505
+ `preventDefault` and do nothing.
1506
+
1507
+ #### Saving changes: the queue
1508
+
1509
+ Each edited cell is a change that keeps the value and the version it was read
1510
+ at. The queue picks what the next call sends, one call at a time; the answer
1511
+ is all or nothing.
1512
+
1513
+ ```ts
1514
+ import {
1515
+ applyAbort,
1516
+ applyAnswer,
1517
+ applyFailure,
1518
+ cellVersion,
1519
+ editCell,
1520
+ expireSaved,
1521
+ gridCellKey,
1522
+ type GridCall,
1523
+ type GridSaveAnswer,
1524
+ IDLE_QUEUE,
1525
+ NO_CHANGES,
1526
+ startCall,
1527
+ } from '@nxgt/material-core/data-grid';
1528
+
1529
+ type Row = { id: string; maths: number | null; version: number };
1530
+ const row: Row = { id: 'ada', maths: 12, version: 3 };
1531
+ // The app's save: one call, answered as a whole.
1532
+ declare function onSave(entries: GridCall['entries'], signal: AbortSignal): Promise<GridSaveAnswer>;
1533
+
1534
+ let changes = NO_CHANGES;
1535
+ let queue = IDLE_QUEUE;
1536
+
1537
+ // An edit: going back to the value read drops it again.
1538
+ changes = editCell(changes, {
1539
+ key: gridCellKey(row.id, 'maths'),
1540
+ base: row.maths,
1541
+ baseVersion: cellVersion(row, 'maths', { getRowVersion: (r) => r.version }),
1542
+ value: 14,
1543
+ });
1544
+
1545
+ // Cell mode sends everything dirty (200 entries a call at most); row mode the
1546
+ // rows left; batch mode only on save(), with no limit, and not while a cell is
1547
+ // in error or in conflict.
1548
+ const started = startCall(changes, queue, { mode: 'cell' });
1549
+ if (started) {
1550
+ ({ changes, queue } = started); // its cells are 'saving'
1551
+ const { call } = started;
1552
+ const controller = new AbortController();
1553
+ try {
1554
+ const answer = await onSave(call.entries, controller.signal);
1555
+ // Versions per row (no getCellVersion): the row's other changes move too.
1556
+ ({ changes, queue } = applyAnswer(changes, queue, call.id, answer, Date.now(), { versionScope: 'row' }));
1557
+ } catch {
1558
+ ({ changes, queue } = controller.signal.aborted
1559
+ ? applyAbort(changes, queue, call.id) // no failure counted
1560
+ : applyFailure(changes, queue, call.id)); // paused after 3: retry(queue)
1561
+ }
1562
+ }
1563
+ changes = expireSaved(changes, Date.now()); // 1.5s later: the "saved" mark goes
1564
+ ```
1565
+
1566
+ - **`versions[i]` is entry `i`'s.** It becomes the cell's new `baseVersion`
1567
+ (every changed cell of the row, in row mode; with `versionScope: 'row'`,
1568
+ the row's other changes still on the old version too). Without one, the
1569
+ version the cell was read at stays, and the next `rebase` adopts the
1570
+ row's: a cell whose value is still its base never conflicts.
1571
+ - **A refusal saves nothing.** `{ ok: false, refused }` names entries by index:
1572
+ an `error` flags its cell, a `conflict` opens one (`resolveConflict(changes,
1573
+ key, 'theirs' | 'mine')`), and every other cell goes back to dirty, to be
1574
+ sent again. A cell edited during the call stays dirty either way. A
1575
+ refusal naming no cell sent is counted in `outcome.unmatched`.
1576
+ - **A saved value stays until the rows hold it.** It is kept as an overlay
1577
+ (status `'clean'` once the mark expires), as "Keep theirs" is, so the cell
1578
+ never flashes back to stale data. The version a save or a conflict
1579
+ replaced is kept as `staleVersion`: a refetch that still reads at it is
1580
+ older than the grid and changes nothing, and `rebase` drops the overlay
1581
+ once the refetched rows hold the value.
1582
+ - **A refetch is a `rebase`.** It compares cell versions when `getCellVersion`
1583
+ is given, else the row's; a pending edit whose version and value moved
1584
+ becomes a conflict, and a conflict outlives any edit until it is resolved.
1585
+
1586
+ ```ts
1587
+ import {
1588
+ aggregate,
1589
+ buildGridModel,
1590
+ conflictValues,
1591
+ EMPTY_HISTORY,
1592
+ type GridCellKey,
1593
+ type GridNumberCodeValue,
1594
+ NO_CHANGES,
1595
+ numberCodes,
1596
+ parseTsv,
1597
+ planPaste,
1598
+ splitCellKey,
1599
+ undo,
1600
+ } from '@nxgt/material-core/data-grid';
1601
+
1602
+ const changes = NO_CHANGES; // the grid's changes
1603
+ const rows = new Map([['ada', { maths: 12 as GridNumberCodeValue }]]);
1604
+ const model = buildGridModel({
1605
+ columns: [{ id: 'maths', label: 'Maths', editor: 'number' }],
1606
+ rows: [{ id: 'ada' }],
1607
+ });
1608
+ const grades = numberCodes({ min: 0, max: 20, decimals: 2 });
1609
+ const [lang, locale] = ['fr', 'fr-FR'];
1610
+ const valueInRows = (key: GridCellKey) => {
1611
+ const { rowId } = splitCellKey(key);
1612
+ return rows.get(rowId)?.maths;
1613
+ };
1614
+
1615
+ // Undo is a new edit: send each of `undone.edits` through editCell; `skipped` cells changed since.
1616
+ const undone = undo(EMPTY_HISTORY, (key) => changes[key]?.value ?? valueInRows(key)); // null: nothing to undo
1617
+
1618
+ // A paste is all or nothing, at the matrix's own size: { ok: true, edits, range } or { ok: false, problems }.
1619
+ const plan = planPaste({
1620
+ matrix: parseTsv('14\r\n'),
1621
+ anchor: { row: 0, col: 0 },
1622
+ model,
1623
+ parse: (text) => grades.parse(text, { lang, row: undefined }),
1624
+ });
1625
+
1626
+ // Totals over numbers only: codes and empty cells are skipped.
1627
+ aggregate('mean', [12, 'ABS', null, 14]); // 13; aggregate('count', []) is 0
1628
+
1629
+ // The conflict panel's two values, formatted with the column's own format; a cleared one is "Cleared".
1630
+ conflictValues({
1631
+ theirs: null,
1632
+ yours: 12.5,
1633
+ format: (value) => grades.format(value as GridNumberCodeValue, { lang, locale }),
1634
+ }); // { theirs: Cleared, yours: "12,5" }
1635
+ ```
1636
+
1637
+ ### A typed number: `/parse-number`
1638
+
1639
+ A number typed with `,` or `.` as its decimal separator, the decimals it was
1640
+ typed with, and the clamp and step behind `NumberField` and the data grid's
1641
+ number editor.
1642
+
1643
+ ```ts
1644
+ import { clampNumber, decimalsTyped, parseNumberInput, stepNumber } from '@nxgt/material-core/parse-number';
1645
+
1646
+ parseNumberInput('12,5'); // 12.5
1647
+ parseNumberInput('1 234,5'); // 1234.5: the last of `,` and `.` is the decimal separator
1648
+ parseNumberInput('-'); // null: empty or incomplete
1649
+ decimalsTyped('12,50'); // 2: a trailing zero is what the user typed
1650
+ clampNumber(15, 0, 10); // 10: `min` and `max` are each optional
1651
+ stepNumber(1.1, 1, 0.1); // 1.2: no float drift
1652
+ stepNumber(null, -1, 1, 0); // 0: empty starts at 0, then is clamped
1653
+ ```
1654
+
1385
1655
  ## Traps
1386
1656
 
1387
1657
  | Symptom | Fix |
@@ -0,0 +1,23 @@
1
+ // src/lib/text-match.ts
2
+ var DIACRITICS = /[̀-ͯ]/g;
3
+ function foldText2(text, locale) {
4
+ return lowercase(text, locale).normalize("NFD").replace(DIACRITICS, "");
5
+ }
6
+ function lowercase(text, locale) {
7
+ try {
8
+ return text.toLocaleLowerCase(locale);
9
+ } catch {
10
+ return text.toLocaleLowerCase();
11
+ }
12
+ }
13
+ function matchesText2(text, query, locale) {
14
+ const needle = foldText2(query.trim(), locale);
15
+ if (!needle)
16
+ return true;
17
+ return foldText2(text, locale).includes(needle);
18
+ }
19
+
20
+ export { foldText2, matchesText2 };
21
+
22
+ //# debugId=021CEAFE8087CA9864756E2164756E21
23
+ //# sourceMappingURL=index-54gkyr43.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lib/text-match.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * Accent- and case-insensitive text matching, for a list filtered as the user\n * types: `'e'` finds \"École\", `'ecole'` finds \"ÉCOLE\".\n */\n\n/** Combining diacritical marks, which `normalize('NFD')` splits from their letter. */\nconst DIACRITICS = /[̀-ͯ]/g;\n\n/**\n * `text` lowercased for `locale` (the runtime's when omitted), then without\n * its diacritics: `foldText('Élève')` is `'eleve'`. Lowercasing comes first,\n * so a Turkish `'İ'` (`'tr'`) folds to `'i'` rather than keeping a dot.\n */\nexport function foldText(text: string, locale?: string): string {\n\treturn lowercase(text, locale).normalize('NFD').replace(DIACRITICS, '');\n}\n\nfunction lowercase(text: string, locale?: string): string {\n\ttry {\n\t\treturn text.toLocaleLowerCase(locale);\n\t} catch {\n\t\t// An invalid language tag: the runtime's own rules, never a throw.\n\t\treturn text.toLocaleLowerCase();\n\t}\n}\n\n/**\n * Whether `query` occurs in `text`, ignoring case and accents. A query of\n * spaces only matches everything, as an empty one does.\n */\nexport function matchesText(\n\ttext: string,\n\tquery: string,\n\tlocale?: string,\n): boolean {\n\tconst needle = foldText(query.trim(), locale);\n\tif (!needle) return true;\n\treturn foldText(text, locale).includes(needle);\n}\n"
6
+ ],
7
+ "mappings": ";AAMA,IAAM,aAAa;AAOZ,SAAS,SAAQ,CAAC,MAAc,QAAyB;AAAA,EAC/D,OAAO,UAAU,MAAM,MAAM,EAAE,UAAU,KAAK,EAAE,QAAQ,YAAY,EAAE;AAAA;AAGvE,SAAS,SAAS,CAAC,MAAc,QAAyB;AAAA,EACzD,IAAI;AAAA,IACH,OAAO,KAAK,kBAAkB,MAAM;AAAA,IACnC,MAAM;AAAA,IAEP,OAAO,KAAK,kBAAkB;AAAA;AAAA;AAQzB,SAAS,YAAW,CAC1B,MACA,OACA,QACU;AAAA,EACV,MAAM,SAAS,UAAS,MAAM,KAAK,GAAG,MAAM;AAAA,EAC5C,IAAI,CAAC;AAAA,IAAQ,OAAO;AAAA,EACpB,OAAO,UAAS,MAAM,MAAM,EAAE,SAAS,MAAM;AAAA;",
8
+ "debugId": "021CEAFE8087CA9864756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,50 @@
1
+ // src/lib/parse-number.ts
2
+ var IGNORED = /[\s\u200e\u200f\u061c]/g;
3
+ function clean(raw) {
4
+ return raw.trim().replace(IGNORED, "").replace(/\u2212/g, "-");
5
+ }
6
+ function parseNumberInput2(raw) {
7
+ const cleaned = clean(raw);
8
+ if (!cleaned || cleaned === "-" || cleaned === "+" || cleaned === "." || cleaned === ",") {
9
+ return null;
10
+ }
11
+ const lastComma = cleaned.lastIndexOf(",");
12
+ const lastDot = cleaned.lastIndexOf(".");
13
+ const normalized = lastComma > lastDot ? cleaned.replace(/\./g, "").replace(",", ".") : cleaned.replace(/,/g, "");
14
+ const value = Number(normalized);
15
+ return Number.isFinite(value) ? value : null;
16
+ }
17
+ function decimalsTyped2(raw) {
18
+ const cleaned = clean(raw);
19
+ const separator = Math.max(cleaned.lastIndexOf(","), cleaned.lastIndexOf("."));
20
+ if (separator === -1)
21
+ return 0;
22
+ return /^\d*/.exec(cleaned.slice(separator + 1))?.[0].length ?? 0;
23
+ }
24
+ function clampNumber2(value, min, max) {
25
+ let next = value;
26
+ if (min != null)
27
+ next = Math.max(min, next);
28
+ if (max != null)
29
+ next = Math.min(max, next);
30
+ return next;
31
+ }
32
+ function decimalPlaces(value) {
33
+ if (!Number.isFinite(value))
34
+ return 0;
35
+ const text = String(value);
36
+ const index = text.indexOf(".");
37
+ if (index === -1 || text.includes("e") || text.includes("E"))
38
+ return 0;
39
+ return text.length - index - 1;
40
+ }
41
+ function stepNumber2(value, direction, step = 1, min, max) {
42
+ const places = Math.max(decimalPlaces(step), decimalPlaces(value ?? 0));
43
+ const next = Number(((value ?? 0) + direction * step).toFixed(places));
44
+ return clampNumber2(next, min, max);
45
+ }
46
+
47
+ export { parseNumberInput2, decimalsTyped2, clampNumber2, stepNumber2 };
48
+
49
+ //# debugId=90F9821DC4F6087964756E2164756E21
50
+ //# sourceMappingURL=index-zpm2cke7.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lib/parse-number.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * The number a user typed, read with either decimal separator: `'12,5'` and\n * `'12.5'` are both 12.5. Behind `NumberField` and the data grid's number\n * editor (`numberCodes`).\n */\n\n/**\n * What a user or a locale puts in a number besides its digits: spaces (`\\s`\n * covers the no-break ones) and the directional marks around an Arabic minus.\n */\nconst IGNORED = /[\\s\\u200e\\u200f\\u061c]/g;\n\n/** `raw` without its spaces and marks, a Unicode minus (`−`) read as `-`. */\nfunction clean(raw: string) {\n\treturn raw\n\t\t.trim()\n\t\t.replace(IGNORED, '')\n\t\t.replace(/\\u2212/g, '-');\n}\n\n/**\n * `raw` as a number, or `null` when it is empty or incomplete (`'-'`, `','`).\n * The last of `,` and `.` is the decimal separator and the other one groups\n * (`'1 234,5'` and `'1,234.5'` are 1234.5); a lone `,` is a decimal comma.\n * Directional marks are skipped and `−` is a minus, so what `Intl` writes\n * for an Arabic locale reads back.\n */\nexport function parseNumberInput(raw: string): number | null {\n\tconst cleaned = clean(raw);\n\tif (\n\t\t!cleaned ||\n\t\tcleaned === '-' ||\n\t\tcleaned === '+' ||\n\t\tcleaned === '.' ||\n\t\tcleaned === ','\n\t) {\n\t\treturn null;\n\t}\n\tconst lastComma = cleaned.lastIndexOf(',');\n\tconst lastDot = cleaned.lastIndexOf('.');\n\tconst normalized =\n\t\tlastComma > lastDot\n\t\t\t? cleaned.replace(/\\./g, '').replace(',', '.')\n\t\t\t: cleaned.replace(/,/g, '');\n\tconst value = Number(normalized);\n\treturn Number.isFinite(value) ? value : null;\n}\n\n/**\n * How many decimals `raw` was typed with, read as `parseNumberInput` reads\n * it: the digits after the last `,` or `.` — `'12,50'` is 2, `'12'` and\n * `'12.'` are 0. A trailing zero counts: it is what the user typed.\n */\nexport function decimalsTyped(raw: string): number {\n\tconst cleaned = clean(raw);\n\tconst separator = Math.max(\n\t\tcleaned.lastIndexOf(','),\n\t\tcleaned.lastIndexOf('.'),\n\t);\n\tif (separator === -1) return 0;\n\treturn /^\\d*/.exec(cleaned.slice(separator + 1))?.[0].length ?? 0;\n}\n\n/** `value` kept within `min` and `max`, either of which may be absent. */\nexport function clampNumber(value: number, min?: number, max?: number) {\n\tlet next = value;\n\tif (min != null) next = Math.max(min, next);\n\tif (max != null) next = Math.min(max, next);\n\treturn next;\n}\n\nfunction decimalPlaces(value: number) {\n\tif (!Number.isFinite(value)) return 0;\n\tconst text = String(value);\n\tconst index = text.indexOf('.');\n\tif (index === -1 || text.includes('e') || text.includes('E')) return 0;\n\treturn text.length - index - 1;\n}\n\n/**\n * `value` one `step` up or down, rounded to the decimals of the step or the\n * value (no float drift: 1.1 + 0.1 is 1.2), then clamped. Empty starts at 0.\n */\nexport function stepNumber(\n\tvalue: number | null,\n\tdirection: 1 | -1,\n\tstep = 1,\n\tmin?: number,\n\tmax?: number,\n) {\n\tconst places = Math.max(decimalPlaces(step), decimalPlaces(value ?? 0));\n\tconst next = Number(((value ?? 0) + direction * step).toFixed(places));\n\treturn clampNumber(next, min, max);\n}\n"
6
+ ],
7
+ "mappings": ";AAUA,IAAM,UAAU;AAGhB,SAAS,KAAK,CAAC,KAAa;AAAA,EAC3B,OAAO,IACL,KAAK,EACL,QAAQ,SAAS,EAAE,EACnB,QAAQ,WAAW,GAAG;AAAA;AAUlB,SAAS,iBAAgB,CAAC,KAA4B;AAAA,EAC5D,MAAM,UAAU,MAAM,GAAG;AAAA,EACzB,IACC,CAAC,WACD,YAAY,OACZ,YAAY,OACZ,YAAY,OACZ,YAAY,KACX;AAAA,IACD,OAAO;AAAA,EACR;AAAA,EACA,MAAM,YAAY,QAAQ,YAAY,GAAG;AAAA,EACzC,MAAM,UAAU,QAAQ,YAAY,GAAG;AAAA,EACvC,MAAM,aACL,YAAY,UACT,QAAQ,QAAQ,OAAO,EAAE,EAAE,QAAQ,KAAK,GAAG,IAC3C,QAAQ,QAAQ,MAAM,EAAE;AAAA,EAC5B,MAAM,QAAQ,OAAO,UAAU;AAAA,EAC/B,OAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;AAAA;AAQlC,SAAS,cAAa,CAAC,KAAqB;AAAA,EAClD,MAAM,UAAU,MAAM,GAAG;AAAA,EACzB,MAAM,YAAY,KAAK,IACtB,QAAQ,YAAY,GAAG,GACvB,QAAQ,YAAY,GAAG,CACxB;AAAA,EACA,IAAI,cAAc;AAAA,IAAI,OAAO;AAAA,EAC7B,OAAO,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC,CAAC,IAAI,GAAG,UAAU;AAAA;AAI1D,SAAS,YAAW,CAAC,OAAe,KAAc,KAAc;AAAA,EACtE,IAAI,OAAO;AAAA,EACX,IAAI,OAAO;AAAA,IAAM,OAAO,KAAK,IAAI,KAAK,IAAI;AAAA,EAC1C,IAAI,OAAO;AAAA,IAAM,OAAO,KAAK,IAAI,KAAK,IAAI;AAAA,EAC1C,OAAO;AAAA;AAGR,SAAS,aAAa,CAAC,OAAe;AAAA,EACrC,IAAI,CAAC,OAAO,SAAS,KAAK;AAAA,IAAG,OAAO;AAAA,EACpC,MAAM,OAAO,OAAO,KAAK;AAAA,EACzB,MAAM,QAAQ,KAAK,QAAQ,GAAG;AAAA,EAC9B,IAAI,UAAU,MAAM,KAAK,SAAS,GAAG,KAAK,KAAK,SAAS,GAAG;AAAA,IAAG,OAAO;AAAA,EACrE,OAAO,KAAK,SAAS,QAAQ;AAAA;AAOvB,SAAS,WAAU,CACzB,OACA,WACA,OAAO,GACP,KACA,KACC;AAAA,EACD,MAAM,SAAS,KAAK,IAAI,cAAc,IAAI,GAAG,cAAc,SAAS,CAAC,CAAC;AAAA,EACtE,MAAM,OAAO,SAAS,SAAS,KAAK,YAAY,MAAM,QAAQ,MAAM,CAAC;AAAA,EACrE,OAAO,aAAY,MAAM,KAAK,GAAG;AAAA;",
8
+ "debugId": "90F9821DC4F6087964756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * A totals row's built-in aggregates over a column's values. Only numbers
3
+ * count: codes ("abs"), empty cells and anything else are skipped, so the
4
+ * mean of 12, "abs" and 14 is 13. With no number, `count` is 0 and the
5
+ * others are `null` (the cell shows nothing); an app's own aggregate is
6
+ * not called.
7
+ */
8
+ export type GridAggregateName = 'sum' | 'mean' | 'min' | 'max' | 'count';
9
+ /** An app's own aggregate, over the column's numbers (never empty). */
10
+ export type GridAggregateFn = (values: number[]) => number | null;
11
+ export type GridAggregate = GridAggregateName | GridAggregateFn;
12
+ /** The finite numbers among `values`. */
13
+ export declare function numericValues(values: readonly unknown[]): number[];
14
+ /** `kind` over the numbers among `values`; with none, 0 for `count` and `null` otherwise. */
15
+ export declare function aggregate(kind: GridAggregate, values: readonly unknown[]): number | null;
16
+ //# sourceMappingURL=aggregates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregates.d.ts","sourceRoot":"","sources":["../../src/data-grid/aggregates.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,CAAC;AAEzE,uEAAuE;AACvE,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,MAAM,GAAG,IAAI,CAAC;AAElE,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAEhE,yCAAyC;AACzC,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,EAAE,CAKlE;AAWD,6FAA6F;AAC7F,wBAAgB,SAAS,CACxB,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,SAAS,OAAO,EAAE,GACxB,MAAM,GAAG,IAAI,CAIf"}
@@ -0,0 +1,41 @@
1
+ import type { GridCellStatus, GridMsg } from './types';
2
+ /** How long saved announcements merge, in ms. */
3
+ export declare const SAVED_MERGE_MS = 1000;
4
+ /** "3 changes saved". */
5
+ export declare function savedMessage(count: number): GridMsg;
6
+ /** The saved count to announce: added to the last one when it was under a second ago. */
7
+ export type SavedTally = {
8
+ count: number;
9
+ at: number;
10
+ };
11
+ export declare function mergeSaved(last: SavedTally | null, count: number, now: number): SavedTally;
12
+ /** A save that failed (the network): it is retried, or paused after 3 failures. */
13
+ export declare function saveFailedMessage(paused?: boolean): GridMsg;
14
+ /** "2 changes refused. F8: next problem": the server said no to them. */
15
+ export declare function refusedMessage(count: number): GridMsg;
16
+ /** "1 conflict: changed by someone else. F8: next problem". */
17
+ export declare function conflictMessage(count: number): GridMsg;
18
+ /** "Not cleared: 1 cell changed meanwhile": a Delete whose check answered too late. */
19
+ export declare function clearDroppedMessage(count: number): GridMsg;
20
+ /** "6 cells pasted". */
21
+ export declare function pasteAppliedMessage(count: number): GridMsg;
22
+ /** "Nothing pasted: 2 problems". */
23
+ export declare function pasteRefusedMessage(count: number): GridMsg;
24
+ /** "Undone: 3 cells", or "Undone: 2 cells, 1 skipped" when some had moved on. */
25
+ export declare function undoneMessage(count: number, skipped?: number): GridMsg;
26
+ /** "Redone: 3 cells". */
27
+ export declare function redoneMessage(count: number): GridMsg;
28
+ /** "Not saved", "Saving", "Saved", "Error", "Conflict". */
29
+ export declare function cellStateText(status: GridCellStatus): GridMsg;
30
+ /** "Locked", or "Locked: Grades are final" with the app's reason. */
31
+ export declare function lockedText(reason?: string): GridMsg;
32
+ /** "Read-only", or "Read-only: Left the course". */
33
+ export declare function readOnlyText(reason?: string): GridMsg;
34
+ /** "Calculated": a computed column's cell. */
35
+ export declare function computedText(): GridMsg;
36
+ /**
37
+ * The grid's description: how to move, edit and leave it ("Cmd" on macOS).
38
+ * With `tabBehavior: 'exit'`, Tab leaves the grid at once.
39
+ */
40
+ export declare function exitHintText(platform?: 'mac' | 'other', tabBehavior?: 'cells' | 'exit'): GridMsg;
41
+ //# sourceMappingURL=announce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"announce.d.ts","sourceRoot":"","sources":["../../src/data-grid/announce.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvD,iDAAiD;AACjD,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC,yBAAyB;AACzB,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAMnD;AAED,yFAAyF;AACzF,MAAM,MAAM,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,wBAAgB,UAAU,CACzB,IAAI,EAAE,UAAU,GAAG,IAAI,EACvB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACT,UAAU,CAKZ;AAED,mFAAmF;AACnF,wBAAgB,iBAAiB,CAAC,MAAM,UAAQ,GAAG,OAAO,CAUzD;AAKD,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAMrD;AAED,+DAA+D;AAC/D,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAUtD;AAED,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAU1D;AAED,wBAAwB;AACxB,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAM1D;AAED,oCAAoC;AACpC,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAU1D;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,SAAI,GAAG,OAAO,CAYjE;AAED,yBAAyB;AACzB,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAMpD;AAUD,2DAA2D;AAC3D,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAE7D;AAED,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAMnD;AAED,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAUrD;AAED,8CAA8C;AAC9C,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC3B,QAAQ,GAAE,KAAK,GAAG,OAAiB,EACnC,WAAW,GAAE,OAAO,GAAG,MAAgB,GACrC,OAAO,CAaT"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The changes' small immutable operations, shared by `changes.ts`,
3
+ * `rebase.ts` and the save answers.
4
+ */
5
+ import type { GridChange, GridChanges } from './change-types';
6
+ import type { GridCellKey, GridVersion } from './types';
7
+ /** `change` without the fields named. */
8
+ export declare function omit<K extends keyof GridChange>(change: GridChange, ...keys: K[]): GridChange;
9
+ export declare function withEntry(changes: GridChanges, change: GridChange): GridChanges;
10
+ export declare function without(changes: GridChanges, key: GridCellKey): GridChanges;
11
+ /**
12
+ * The overlay a cell keeps once nothing is left to send: it shows `value`,
13
+ * the server's, until the app's rows hold it.
14
+ */
15
+ export declare function cleanOverlay(change: GridChange, value: unknown, version: GridChange['baseVersion']): GridChange;
16
+ /** Whether `change` keeps a version a save or a conflict replaced. */
17
+ export declare function hasStaleVersion(change: GridChange): boolean;
18
+ /**
19
+ * Whether a refetch read at `version` is older than what `change` knows.
20
+ * `0` and `undefined` (a cell that does not exist yet) are the same read
21
+ * here: an app may report a missing cell either way.
22
+ */
23
+ export declare function isStaleRead(change: GridChange, version: GridVersion | undefined): boolean;
24
+ /**
25
+ * `change` moved to `version`, the one it had kept as `staleVersion`; the
26
+ * same change when the version did not move.
27
+ */
28
+ export declare function moveVersion(change: GridChange, version: GridVersion | undefined): GridChange;
29
+ //# sourceMappingURL=change-ops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-ops.d.ts","sourceRoot":"","sources":["../../src/data-grid/change-ops.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGxD,yCAAyC;AACzC,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,UAAU,EAC9C,MAAM,EAAE,UAAU,EAClB,GAAG,IAAI,EAAE,CAAC,EAAE,GACV,UAAU,CAIZ;AAED,wBAAgB,SAAS,CACxB,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,UAAU,GAChB,WAAW,CAEb;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAAG,WAAW,CAK3E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,UAAU,CAAC,aAAa,CAAC,GAChC,UAAU,CASZ;AAED,sEAAsE;AACtE,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAE3D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAC1B,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAOT;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAC1B,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,WAAW,GAAG,SAAS,GAC9B,UAAU,CAGZ"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * What the changes add up to: the counts a status bar and a save button
3
+ * show, and the entries in the order they were edited.
4
+ */
5
+ import type { GridChange, GridChanges } from './change-types';
6
+ /** The entries, oldest edit first. */
7
+ export declare function changeList(changes: GridChanges): GridChange[];
8
+ export type GridChangeCounts = {
9
+ /** Not saved yet, and valid: `dirty` and `saving`. */
10
+ dirty: number;
11
+ saving: number;
12
+ errors: number;
13
+ conflicts: number;
14
+ };
15
+ /** Every count in one pass (`onChangesChange`); a `clean` overlay counts for nothing. */
16
+ export declare function changeCounts(changes: GridChanges): GridChangeCounts;
17
+ /** Cells not saved yet (`dirty` or `saving`). */
18
+ export declare function dirtyCount(changes: GridChanges): number;
19
+ export declare function errorCount(changes: GridChanges): number;
20
+ export declare function conflictCount(changes: GridChanges): number;
21
+ /** Whether a cell in error or in conflict blocks a batch save. */
22
+ export declare function blocking(changes: GridChanges): boolean;
23
+ /** Whether anything is left to save or resolve (a saved cell or an overlay is not). */
24
+ export declare function hasPendingChanges(changes: GridChanges): boolean;
25
+ //# sourceMappingURL=change-select.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-select.d.ts","sourceRoot":"","sources":["../../src/data-grid/change-select.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE9D,sCAAsC;AACtC,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,EAAE,CAE7D;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC9B,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,yFAAyF;AACzF,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,gBAAgB,CASnE;AAED,iDAAiD;AACjD,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAEvD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAEvD;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAE1D;AAED,kEAAkE;AAClE,wBAAgB,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAGtD;AAED,uFAAuF;AACvF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAI/D"}