viewkitjs 0.39.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 +65 -0
- package/MIGRATION.md +25 -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/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 +6 -4
- 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 +2 -2
- package/postgres/docs/reference/postgres.md +1 -1
- package/views/dist/contract.d.ts +20 -2
- package/views/dist/contract.js +27 -0
- 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/filter-editor/filter-editor.d.ts +2 -0
- package/views/dist/controls/filter-editor/filter-editor.js +5 -2
- package/views/dist/controls/filter-editor/how.d.ts +8 -0
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +4 -2
- package/views/dist/controls/filter-editor/map-filter-body.js +17 -8
- package/views/dist/controls/filter-editor/map-rules.d.ts +4 -3
- package/views/dist/controls/filter-editor/map-rules.js +5 -2
- 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/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/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/text-editor.css +5 -3
- package/views/dist/controls/tokens.js +0 -6
- package/views/dist/controls/toolbar/toolbar.js +2 -2
- package/views/dist/field-row/editors/RowTextEditor.js +4 -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/grid-table-props.d.ts +4 -1
- 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 +1 -1
- 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/list/bar-keys.d.ts +3 -0
- package/views/dist/list/bar-keys.js +1 -0
- package/views/dist/list/buttons/clear-save.js +6 -2
- package/views/dist/list/buttons/new.d.ts +1 -1
- package/views/dist/list/buttons/new.js +14 -2
- package/views/dist/list/buttons/shared.d.ts +7 -1
- package/views/dist/list/buttons/shared.js +8 -2
- package/views/dist/list/buttons/views.js +6 -4
- package/views/dist/list/edits.d.ts +3 -1
- package/views/dist/list/layer.d.ts +13 -3
- package/views/dist/list/layer.js +13 -3
- package/views/dist/list/line.d.ts +5 -2
- package/views/dist/list/line.js +11 -3
- package/views/dist/list/list.d.ts +7 -1
- package/views/dist/list/list.js +2 -2
- package/views/dist/list/panels/filter-bar.d.ts +1 -1
- package/views/dist/list/panels/filter-bar.js +9 -3
- package/views/dist/list/panels/shared.d.ts +3 -2
- package/views/dist/list/panels/shared.js +5 -2
- package/views/dist/list/root-base.d.ts +2 -1
- package/views/dist/list/root-base.js +5 -3
- package/views/dist/list/root.d.ts +1 -1
- package/views/dist/list/store.d.ts +10 -0
- package/views/dist/list/store.js +8 -1
- package/views/dist/list/toolbar-model.d.ts +4 -0
- package/views/dist/list/toolbar-model.js +19 -1
- package/views/dist/list/toolbar.js +2 -1
- 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/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/filter-body.js +5 -1
- package/views/dist/panels/react/toolbar/ToolbarBarSorts.js +28 -1
- 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/context.d.ts +4 -0
- package/views/dist/panels/react/toolbar/context.js +1 -0
- package/views/dist/panels/react/toolbar/use-give-way.js +2 -2
- package/views/dist/panels/settings/filter-groups.js +5 -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 +12 -3
- package/views/dist/styles.css +16 -260
- package/views/dist/styles.unlayered.css +16 -260
- package/views/docs/contract.md +9 -7
- package/views/docs/controls/field.md +1 -1
- package/views/docs/guides/looks.md +1 -1
- package/views/docs/guides/the-grid.md +4 -2
- package/views/docs/guides/toolbar-parts.md +337 -0
- package/views/docs/index.md +4 -0
- package/views/docs/reference/controls.md +3 -41
- package/views/docs/reference/grid.md +4 -3
- package/views/docs/reference/list.md +24 -13
- package/views/docs/reference/looks.md +12 -15
- package/views/docs/reference/panels.md +1 -1
- package/views/docs/reference/react.md +3 -3
- package/views/docs/reference/views.md +1 -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
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,71 @@ Until 0.19.0 ViewKit shipped as three packages; their changes are in [fields/CHA
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.40.0] — 2026-12-05
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `viewkitjs/views`: `menus.sortEditor` now reaches the filter bar's sort pills (`ListFilterBar sorts="yes"`): each pill's × is handed as `delete` with `{ menu: "row", field, index, place: "bar" }` (`ViewsSortEditorItemsContext` gains `place`), so a function that drops `delete` takes the × off the pill as it does in the editor, and an item of your own draws as one more part of the pill.
|
|
13
|
+
- `viewkitjs/views/list`: `personSettings` on `List` and `ListRoot`, `{ bar?: boolean; words?: boolean }`, each off by default: where you turn one on, a person picks it in their own Customize, kept in their layer and never in the shared view. `bar` adds Layout's **Filter bar** row (`choice:bar`: Once added or Always, on a computer), standing over the toolbar's `bar` and a placed `ListFilterBar`'s `shows` (a bar written `shows="button"` keeps its button, and the row is left out while one is placed). `words` adds Layout's **Button words** row (`choice:words`: Icon and word, Icon or Word, on a computer and a phone), standing over every toolbar button's own words under the root. Customize's Reset empties both with the rest of the person's layer. With neither turned on, nothing changes.
|
|
14
|
+
- `viewkitjs/fields/query`: `ListPersonalLayer.toolbar`, `{ bar?: "added" | "always"; words?: "both" | "icon" | "word" }`, and `listPersonalLayerSchema` takes it, refusing any other key or value in it.
|
|
15
|
+
- `viewkitjs/views/list`: the root's `panels.personBar` and `panels.personWords`, what `personSettings` turns on.
|
|
16
|
+
- Message keys: `views.panels.person-bar` ("Filter bar"), `views.panels.person-bar-added` ("Once added"), `views.panels.person-bar-always` ("Always"), `views.panels.person-words` ("Button words"), `views.panels.person-words-both` ("Icon and word"), `views.panels.person-words-icon` ("Icon"), `views.panels.person-words-word` ("Word").
|
|
17
|
+
- `viewkitjs/views`: a guide to the toolbar's parts, "The toolbar's parts" (`views/docs/guides/toolbar-parts.md`): every button and panel of a list's toolbar with its settings, default first; `ListLine`, `ListGap`, `ListSlot` and `ListFill`; what `personSettings` lets a person pick; how the ready toolbar's props (`sortFilter`, `bar`, `toolbarParts`, `customizeIn`, `hosts`, `menus`…) map onto the parts; and six layouts to copy: the default, filters in a side column, views in the app's sidebar, all in the page header, no popovers, and search in the app bar.
|
|
18
|
+
- `viewkitjs/views/grid`: the message `views.grid.paste-two-values`, "A record shown twice can't take two different values".
|
|
19
|
+
- `viewkitjs/fields/query`: `numberRuleLabel` takes the unit a duration rule is kept in as its fifth argument (the kit's, its fourth), and then writes each bound as the duration box writes it: `> 1m 30s`.
|
|
20
|
+
- `viewkitjs/views`: `ViewsFilterBodyField.duration`, `"ms"` or `"s"` on a number field kept as a duration, in that unit. An app's own `FilterBody` can read and write its box as a duration (`1m 30s`, a bare number in seconds) and keep the rule's bound in that unit. A body that ignores it draws as before.
|
|
21
|
+
- `viewkitjs/fields`: `isMixedCurrency(field)` says whether a money field keeps amounts in several currencies: its currency is each row's own (`code: { field }`) and no `convert` reads it in one.
|
|
22
|
+
- `viewkitjs/fields/query`: `refusesNumberRule(field, operator, oneCurrency?)` and `comparesNumber(operator)`. A number rule that compares (every number operator but Is empty and Is not empty) over money in several currencies is refused: one number can't compare 1000 RON with 1000 EUR.
|
|
23
|
+
- `viewkitjs/fields/query`: `ViewFieldReader.oneCurrency(key)`, for a reader that reads a money field in one currency for every row (it converted the amounts, or the list shows one currency): a number rule over that field compares again.
|
|
24
|
+
- `viewkitjs/fields`: the message key `filter.mixed-currency`, "Not applied: amounts in several currencies", a refused rule's summary and the note under its box.
|
|
25
|
+
- `viewkitjs/views`: `FilterConfigNumber.refused`, the words a number row shows when a rule that compares would be refused; `ViewsFilterBodyProps.ruleWords` hands them as `refused`, and `CONTROLS.FilterBody` draws them under the rule (`data-slot="vk-filter-refused"`).
|
|
26
|
+
- `viewkitjs/postgres`: several values kept as rows of their own may name each row's label, `several: { kept: "rows", …, label }` (a column or your expression, read as text), and the definitions' rows form takes `label` beside `main`: `{ rows: { kind, record, value, main, label } }`.
|
|
27
|
+
- `viewkitjs/views/grid`: `gridSave` also returns `cellValues`, the function that turns a cell's change into the values
|
|
28
|
+
saved, and `GridTable` takes it as `cellValues` (spreading what `gridSave` returns hands it over). Every column a
|
|
29
|
+
cell's save writes beside its own (an amount's direction or currency) now shows its new value as the save is sent,
|
|
30
|
+
and rolls back with the edit when the save is refused; an undo or a redo shows them back as it is pressed. `<List>`
|
|
31
|
+
does this for a binding that writes several fields. `GridCellValuesFn` types it.
|
|
32
|
+
- Message key `views.grid.changed-since`: "Changed by someone since".
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- `viewkitjs/views/list`: on a phone, the toolbar parts you place anywhere keep today's phone form: every placed button (`ListSort`, `ListFilter`, `ListCustomize`, `ListQuickFilters`, `ListViews`) opens its panel in your map's Sheet; `ListNew` is the round + at the list's foot; `ListClearSave` draws nothing, Clear and Save waiting in Customize's foot; a `ListLine` takes the phone's form; and a placed panel (`ListFilterPanel`, `ListSortPanel`, `ListCustomizePanel`, `ListQuickFiltersPanel`, `ListViewsPanel`) folds behind its button while one of the same stands under the root, opening as the button's sheet, and keeps standing where none does. Before, inside a `ListRoot` these opened popovers and stood as on a computer. `ListToolbar` and `List` on a phone are unchanged.
|
|
37
|
+
- `viewkitjs/views`: a function handed to `menus.sortEditor` that drops `delete` without checking `ctx.menu` now also takes the × off the filter bar's sort pills; one that adds a row without checking it adds a part to every pill. Check `ctx.menu` (and `place`).
|
|
38
|
+
- `viewkitjs/fields/query`: a person's layer may now hold `toolbar`. A reader on an older release refuses such a layer whole, as its schema is strict (a server checking a stored layer, the browser's views store), so the person's widths and folds would be dropped with it there: take this release everywhere a stored layer is read before turning `personSettings` on.
|
|
39
|
+
- An app that keeps the person's layer in its own storage, key by key, adds `toolbar` to the keys it keeps before turning `personSettings` on; otherwise a pick shows until the page reloads and is then gone.
|
|
40
|
+
- The tarball's unpacked size budget is raised from 11670 kB to 11690 kB for this guide: the package now measures about 11681 kB unpacked.
|
|
41
|
+
- `viewkitjs/views`: the default look is ViewKit's own, at the values it ships today: nothing an app draws moves, and the stylesheet's values are byte for byte what they were (two of its comments are reworded). From now on a visible change to the default look (a row's height, the focus ring, the selection's colours, any visible default) is released as breaking, a minor while 0.x, with the old and the new side by side under Changed. The looks' docs call each default ViewKit's own.
|
|
42
|
+
- The tarball's unpacked size budget is raised from 11690 kB to 11710 kB: the paste's label reading, the new refusal and their docs bring the package to about 11693 kB unpacked.
|
|
43
|
+
- A number rule that compares amounts in several currencies now filters nothing, everywhere: the in-memory evaluator, the grid's column rules and `viewkitjs/postgres`, which leaves it out as it leaves out a rule on a field it doesn't know, so a saved view that carries one still lists its rows. Where the rule is made and on the filter bar, the list says why. Its operators stay offered, and Is empty and Is not empty filter as before. A field kept in one currency (`code: { fixed }`), one that converts (`convert`), and a grid column read in a display currency filter as before. A reader of your own that converts amounts inside `read` adds `oneCurrency: (key) => key === "<field>"` to keep filtering them; a field map that converts in its own expression declares its money in one currency (`code: { fixed }`).
|
|
44
|
+
- The tarball's unpacked size budget is raised from 11690 kB to 11710 kB for the refusal of a number rule over amounts in several currencies and the summary of a duration rule, their docs and their release notes: the package now measures about 11698 kB unpacked.
|
|
45
|
+
- `viewkitjs/postgres`: several values kept as rows whose map names a `main` or a `label` read as the items every several-values cell takes, `{ value, label, main }`, the main one first and the rest by their key, so a list shows the same main email or phone, and the same labels, as the record. Before, they read as bare values in key order, whatever row was marked main. A map naming neither reads as before.
|
|
46
|
+
- The tarball's unpacked size budget is raised from 11710 kB to 11740 kB for the grid's save and undo changes and
|
|
47
|
+
their guide: the package now measures about 11725 kB unpacked.
|
|
48
|
+
- `viewkitjs/views/grid`: ⌘Z and ⇧⌘Z no longer overwrite a value someone else wrote since the person's edit. Where the
|
|
49
|
+
rows the grid holds show a value in the cell that is neither the edit nor what it replaced, the undo or redo leaves
|
|
50
|
+
that cell as the rows show it, sends no write for it and says so through the toast's `warning`; the edit's other
|
|
51
|
+
cells are undone as before, and the next ⌘Z reaches the edit before it. A cell whose own write is still out, or whose
|
|
52
|
+
rows haven't caught up with it, is undone as before.
|
|
53
|
+
|
|
54
|
+
### Fixed
|
|
55
|
+
|
|
56
|
+
- `viewkitjs/views`: a page holding the toolbar (the ready one or the controls' `Toolbar`) moves on React's view transitions. When the toolbar's line was resized, a menu in it closed or an attribute above it changed while a move was being prepared, its fit check flushed at once and React skipped the move, so the page swapped with a cut. While a view transition is active the toolbar now finds its fit with a plain update, once the move's commit is done; at any other time it still finds it before the paint.
|
|
57
|
+
- `viewkitjs/views/field-row`: on a computer, under the Field's Long (`row-long: line`), a long text's editor now takes the row box's own corners (`--vk-field-row-box-r` under the Field's Box, `--vk-radius-md` without it), so the row's pressed ground no longer shows past the popover's rounder top corners. Its words stand where they did. Under the Field's Box, the popover's mark reads `data-field-row-long-editor="box"`, so your own `Popover` can take the same corner.
|
|
58
|
+
- `viewkitjs/views/list`: a `ListLine` takes no room while none of its parts draws anything. A `ListLine kind="bar"` holding a `ListFilterBar`, a `ListGap` and `ListClearSave` no longer stands as an empty band under your row while nothing is filtered, sorted or changed; it stands as soon as a rule, a held rule, the sort pill or Clear and Save shows, as the ready toolbar's bar does. Your own node or text written in a line keeps it standing.
|
|
59
|
+
- `viewkitjs/views/grid`: a paste, a fill or a cut that reaches one record through two of its drawn copies (a grid grouped by a column of several values) and gives it two different values for one column writes nothing to that cell and says why, as `views.grid.paste-two-values`, counted with the paste's or the fill's other refusals. The same value reaching it twice is written once. Before, the value on the last copy was saved and the other lost.
|
|
60
|
+
- `viewkitjs/views`: a duration rule's summary, on the filter bar and in the Filter panel's rows, reads as its box writes it (`> 1m 30s`), no longer the stored milliseconds with an "s" after them (`> 90000 s`).
|
|
61
|
+
- `viewkitjs/views/controls`: the kit's filter editor (`CONTROLS.FilterBody`, in the Filter panel and Customize's Filter page) and the filter bar's value part (`CONTROLS.FilterPartBody`) read a duration rule's bound as a duration (`1m 30s`), no longer the stored milliseconds (`90,000`). A bound typed there, `90` or `1m 30s`, is kept as 90 seconds in the column's unit, no longer 90 milliseconds.
|
|
62
|
+
- `viewkitjs/views`: a Sheet opened over a sheet or dialog the app draws itself on Base UI (a Drawer or a Dialog) now knows it stands over it, as it does over another Sheet of ViewKit's: it dims the one below with `--vk-backdrop-stacked`, and a choice that finishes the job closes the app's one too. The app changes nothing. Over ViewKit's own Sheet, and alone, nothing changes.
|
|
63
|
+
- `viewkitjs/views/grid`: an option copied in the grid and pasted into another column lands by its label, never on an option there that only shares its key; a copied list of options lands its keys only where this column's options with those keys carry the copied labels. Copy and paste within one column stays exact.
|
|
64
|
+
- `viewkitjs/views/grid`: a list of labels pasted from outside into a column of options lands a label that holds a comma ("Sales, EMEA") whole where the column offers it: the text is read whole first, then by the column's labels, longest first, then split on commas. A column whose options name none of it still splits on commas.
|
|
65
|
+
|
|
66
|
+
### Removed
|
|
67
|
+
|
|
68
|
+
- `viewkitjs/views/controls`: breaking. The setting row, the switch row and the tag field are gone, since none of ViewKit's own pieces draws them: `SettingRow`, `SettingRows`, `SettingIcon`, `SettingChevron`, `SwitchRow`, `SwitchRows`, `TagField`, `useSettingRowWorn`, `useSettingRowsRow`, `settingRowWornOf`, `SETTING_ROW_ATTRS` and their types (`SettingRowProps`, `SettingRowsProps`, `SettingAction`, `SettingState`, `SwitchRowProps`, `TagFieldProps`). An app that drew them draws its own settings rows and tag field instead: before, `import { SettingRow, SettingRows } from "viewkitjs/views/controls"`; now, the app's own component in their place, built on ViewKit's `Switch`, `Select`, `Button`, `Field` and `Tag`, which stay.
|
|
69
|
+
- `viewkitjs/views/controls/setting-row.css`, `switch-row.css` and `tag-field.css` are gone, and the ready stylesheet no longer carries them or declares their `--vk-` names. An app's own rows bring their own stylesheet.
|
|
70
|
+
- `viewkitjs/views/looks`: `SETTING_ROW_LOOKS`, `SettingRowOptionId` and `SettingRowPicks` are gone with the setting row, and `LOOKS` no longer lists it.
|
|
71
|
+
- `viewkitjs/views/controls`: a `Field` no longer draws as a setting row inside a computer's `SettingRows`, and a `RadioGroup` no longer turns into a Select at such a row's end; both only ever did inside the setting row. Alone and in `FieldRows` they draw as before.
|
|
72
|
+
|
|
8
73
|
## [0.39.0] — 2026-12-05
|
|
9
74
|
|
|
10
75
|
### Added
|
package/MIGRATION.md
CHANGED
|
@@ -805,12 +805,36 @@ The panels: quick filters, set-aside rules, dragging:
|
|
|
805
805
|
| `views.panels.toolbar-bar` | Sort and filters |
|
|
806
806
|
| `views.panels.sort-filter` | Sort and filter |
|
|
807
807
|
|
|
808
|
+
The person's own toolbar rows in Customize's Layout, where the app turns them on (`personSettings`):
|
|
809
|
+
|
|
810
|
+
| Key | English |
|
|
811
|
+
| --- | --- |
|
|
812
|
+
| `views.panels.person-bar` | Filter bar |
|
|
813
|
+
| `views.panels.person-bar-added` | Once added |
|
|
814
|
+
| `views.panels.person-bar-always` | Always |
|
|
815
|
+
| `views.panels.person-words` | Button words |
|
|
816
|
+
| `views.panels.person-words-both` | Icon and word |
|
|
817
|
+
| `views.panels.person-words-icon` | Icon |
|
|
818
|
+
| `views.panels.person-words-word` | Word |
|
|
819
|
+
|
|
808
820
|
The grid's footer:
|
|
809
821
|
|
|
810
822
|
| Key | English |
|
|
811
823
|
| --- | --- |
|
|
812
824
|
| `views.grid.figure-word` | The word after a footer figure's value, by `{ kind }`: count, empty, filled, sum, average, min, max, unique, ratio |
|
|
813
825
|
|
|
826
|
+
A paste, a fill or a cut that gives one record, drawn under two groups, two different values for one column:
|
|
827
|
+
|
|
828
|
+
| Key | English |
|
|
829
|
+
| --- | --- |
|
|
830
|
+
| `views.grid.paste-two-values` | A record shown twice can't take two different values |
|
|
831
|
+
|
|
832
|
+
The grid's undo and redo, over a value someone wrote since the edit:
|
|
833
|
+
|
|
834
|
+
| Key | English |
|
|
835
|
+
| --- | --- |
|
|
836
|
+
| `views.grid.changed-since` | Changed by someone since |
|
|
837
|
+
|
|
814
838
|
The field row in a Field rows card, holding nothing:
|
|
815
839
|
|
|
816
840
|
| Key | English |
|
|
@@ -839,6 +863,7 @@ The field row in a Field rows card, holding nothing:
|
|
|
839
863
|
| `date.no-such-day` | {month} has no {day, as an ordinal}. Write a day and a month: 12/11 |
|
|
840
864
|
| `field.must-tick` | This box must be ticked |
|
|
841
865
|
| `field.label` | A field a lookup's or a rollup's note names, by `{ entity, field, label }`: its label |
|
|
866
|
+
| `filter.mixed-currency` | Not applied: amounts in several currencies |
|
|
842
867
|
|
|
843
868
|
### Check you're done with this part
|
|
844
869
|
|
package/fields/dist/derived.d.ts
CHANGED
|
@@ -46,6 +46,13 @@ export declare function lockReason(field: FieldDef, cv?: FieldConventions): stri
|
|
|
46
46
|
* narrowing `CurrencyCode` itself, so the shape is read in exactly one place.
|
|
47
47
|
*/
|
|
48
48
|
export declare function isPerCodeCurrency(field: FieldDef): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Does this money field keep amounts in several currencies? A currency
|
|
51
|
+
* whose code is each row's own (`code: { field }`) and that no `convert` reads
|
|
52
|
+
* in one: 1000 RON beside 1000 EUR, so one number can't compare them. Read off
|
|
53
|
+
* the presented def, like `isPerCodeCurrency`, and it never throws.
|
|
54
|
+
*/
|
|
55
|
+
export declare function isMixedCurrency(field: FieldDef): boolean;
|
|
49
56
|
/**
|
|
50
57
|
* A money field's conversion: the `convert` of a currency whose code
|
|
51
58
|
* is a sibling field, read off the presented def; null for anything else. Asked
|
package/fields/dist/derived.js
CHANGED
|
@@ -81,6 +81,10 @@ export function isPerCodeCurrency(field) {
|
|
|
81
81
|
const def = presentedDef(field);
|
|
82
82
|
return def.type === "currency" && !!def.code && "perCode" in def.code;
|
|
83
83
|
}
|
|
84
|
+
export function isMixedCurrency(field) {
|
|
85
|
+
const def = presentedDef(field);
|
|
86
|
+
return def.type === "currency" && !!def.code && "field" in def.code && !def.convert;
|
|
87
|
+
}
|
|
84
88
|
export function conversionOf(field) {
|
|
85
89
|
const def = presentedDef(field);
|
|
86
90
|
if (def.type !== "currency" || !def.code || !("field" in def.code))
|
package/fields/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export { cleanDomain, isCleanDomain } from "./domain.js";
|
|
|
22
22
|
export { isEmptyName, isNameValue, NAME_PARTS, namePart, nameText, sameName, tidyName, withNamePart, type NamePart, } from "./name.js";
|
|
23
23
|
export { bandTone } from "./bands.js";
|
|
24
24
|
export { checkFilterTree, listFieldsOf, checkIndex, defineIndex, drawsUnderName, entityDef, avatarKey, editedThroughField, renamedName, subtitleField, subtitleKeys, subtitleThrough, withLine, type EntityContribution, type EntityDef, type EntityIndex, } from "./entities.js";
|
|
25
|
-
export { conversionOf, derivedReason, isBreakdown, isDerived, isGroupedRollup, isLookup, isIntegerField, isPerCodeCurrency, lockReason, looksAhead, presentedDef, scalarOf, storesDecimalText, valueTypeOf, type DerivedDef, type ValueType, } from "./derived.js";
|
|
25
|
+
export { conversionOf, derivedReason, isBreakdown, isDerived, isGroupedRollup, isLookup, isIntegerField, isMixedCurrency, isPerCodeCurrency, lockReason, looksAhead, presentedDef, scalarOf, storesDecimalText, valueTypeOf, type DerivedDef, type ValueType, } from "./derived.js";
|
|
26
26
|
export { isOpenVocabulary, optionFor, optionValues, optionsOf, statusOptionOrder } from "./options.js";
|
|
27
27
|
export { sameListValue, sameStoredValue } from "./equality.js";
|
|
28
28
|
export { optimisticDisplay, sameFieldValue } from "./optimistic.js";
|
package/fields/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ export { cleanDomain, isCleanDomain } from "./domain.js";
|
|
|
19
19
|
export { isEmptyName, isNameValue, NAME_PARTS, namePart, nameText, sameName, tidyName, withNamePart, } from "./name.js";
|
|
20
20
|
export { bandTone } from "./bands.js";
|
|
21
21
|
export { checkFilterTree, listFieldsOf, checkIndex, defineIndex, drawsUnderName, entityDef, avatarKey, editedThroughField, renamedName, subtitleField, subtitleKeys, subtitleThrough, withLine, } from "./entities.js";
|
|
22
|
-
export { conversionOf, derivedReason, isBreakdown, isDerived, isGroupedRollup, isLookup, isIntegerField, isPerCodeCurrency, lockReason, looksAhead, presentedDef, scalarOf, storesDecimalText, valueTypeOf, } from "./derived.js";
|
|
22
|
+
export { conversionOf, derivedReason, isBreakdown, isDerived, isGroupedRollup, isLookup, isIntegerField, isMixedCurrency, isPerCodeCurrency, lockReason, looksAhead, presentedDef, scalarOf, storesDecimalText, valueTypeOf, } from "./derived.js";
|
|
23
23
|
export { isOpenVocabulary, optionFor, optionValues, optionsOf, statusOptionOrder } from "./options.js";
|
|
24
24
|
export { sameListValue, sameStoredValue } from "./equality.js";
|
|
25
25
|
export { optimisticDisplay, sameFieldValue } from "./optimistic.js";
|
|
@@ -350,6 +350,10 @@ export type FieldMessage = {
|
|
|
350
350
|
| {
|
|
351
351
|
key: "filter.any";
|
|
352
352
|
}
|
|
353
|
+
/** Why a number rule over amounts in several currencies filters nothing: its summary, and the note under its box. */
|
|
354
|
+
| {
|
|
355
|
+
key: "filter.mixed-currency";
|
|
356
|
+
}
|
|
353
357
|
/** A filter operator's name: "Contains", "Is before", "Greater than". */
|
|
354
358
|
| {
|
|
355
359
|
key: "filter.operator";
|
|
@@ -437,6 +441,6 @@ export type FieldMessage = {
|
|
|
437
441
|
export type FieldMessageKey = FieldMessage["key"];
|
|
438
442
|
export type FieldMessageResolver = (message: FieldMessage) => string;
|
|
439
443
|
/** Every key a host words, once: a host tests that its catalog holds each (`VIEWS_MESSAGE_KEYS` is the views part's). */
|
|
440
|
-
export declare const FIELD_MESSAGE_KEYS: readonly ["lock.system", "lock.provider", "lock.create", "lock.never", "derived.formula", "derived.lookup", "derived.count", "derived.rollup", "derived.exists", "derived.none", "field.label", "settlement.requested", "provider.name", "type.label", "setting.label", "setting.word", "field.cannot-empty", "field.must-tick", "field.cannot-edit", "field.cannot-save", "field.retry-save", "field.stored-value-required", "field.history-unavailable", "field.restore-refused", "field.already-saving", "field.unavailable", "field.derived", "editor.search", "editor.searching", "editor.search-failed", "editor.loading-more", "editor.nothing-matches", "editor.use-value", "relation.none", "relation.lead", "relation.make-lead", "date.placeholder", "date.label", "date.today", "date.tomorrow", "date.next-monday", "date.in-a-week", "date.clear", "time.placeholder", "time.label", "date.type", "date.none", "date.add-time", "date.last-month", "date.next-month", "date.day", "date.month", "date.year", "date.months", "date.years", "time.hour", "time.minute", "date.not-a-date", "date.no-such-day", "chips.add-placeholder", "chips.everything-picked", "chips.add", "validation.invalid", "validation.text", "validation.number", "validation.integer", "validation.date", "validation.datetime", "validation.boolean", "validation.option", "validation.options-list", "validation.values-list", "validation.relation", "validation.url", "validation.domain", "validation.email", "validation.email-list", "validation.unit", "validation.phone", "validation.phone-country", "validation.phone-short", "validation.phone-long", "validation.phone-whole", "validation.user", "validation.location", "validation.country-code", "validation.region-code", "validation.name", "validation.actor", "actor.type", "validation.range-order", "range.up-to", "range.and-up", "validation.pattern", "validation.tag-empty", "validation.max-length", "validation.min-length", "validation.min", "validation.max", "validation.greater-than", "validation.less-than", "validation.decimals", "validation.max-items", "validation.max-addresses", "validation.one-main", "validation.duplicate-value", "save.failed", "save.refresh-failed", "filter.any", "filter.operator", "filter.text-summary", "filter.date-summary", "filter.relative", "filter.relative-direction", "filter.relative-unit", "group.none", "group.relative", "group.due", "group.week-of", "time.never", "time.future", "time.ago", "platform.website"];
|
|
444
|
+
export declare const FIELD_MESSAGE_KEYS: readonly ["lock.system", "lock.provider", "lock.create", "lock.never", "derived.formula", "derived.lookup", "derived.count", "derived.rollup", "derived.exists", "derived.none", "field.label", "settlement.requested", "provider.name", "type.label", "setting.label", "setting.word", "field.cannot-empty", "field.must-tick", "field.cannot-edit", "field.cannot-save", "field.retry-save", "field.stored-value-required", "field.history-unavailable", "field.restore-refused", "field.already-saving", "field.unavailable", "field.derived", "editor.search", "editor.searching", "editor.search-failed", "editor.loading-more", "editor.nothing-matches", "editor.use-value", "relation.none", "relation.lead", "relation.make-lead", "date.placeholder", "date.label", "date.today", "date.tomorrow", "date.next-monday", "date.in-a-week", "date.clear", "time.placeholder", "time.label", "date.type", "date.none", "date.add-time", "date.last-month", "date.next-month", "date.day", "date.month", "date.year", "date.months", "date.years", "time.hour", "time.minute", "date.not-a-date", "date.no-such-day", "chips.add-placeholder", "chips.everything-picked", "chips.add", "validation.invalid", "validation.text", "validation.number", "validation.integer", "validation.date", "validation.datetime", "validation.boolean", "validation.option", "validation.options-list", "validation.values-list", "validation.relation", "validation.url", "validation.domain", "validation.email", "validation.email-list", "validation.unit", "validation.phone", "validation.phone-country", "validation.phone-short", "validation.phone-long", "validation.phone-whole", "validation.user", "validation.location", "validation.country-code", "validation.region-code", "validation.name", "validation.actor", "actor.type", "validation.range-order", "range.up-to", "range.and-up", "validation.pattern", "validation.tag-empty", "validation.max-length", "validation.min-length", "validation.min", "validation.max", "validation.greater-than", "validation.less-than", "validation.decimals", "validation.max-items", "validation.max-addresses", "validation.one-main", "validation.duplicate-value", "save.failed", "save.refresh-failed", "filter.any", "filter.mixed-currency", "filter.operator", "filter.text-summary", "filter.date-summary", "filter.relative", "filter.relative-direction", "filter.relative-unit", "group.none", "group.relative", "group.due", "group.week-of", "time.never", "time.future", "time.ago", "platform.website"];
|
|
441
445
|
/** Neutral English fallback for hosts that do not provide localization. */
|
|
442
446
|
export declare const resolveFieldMessage: FieldMessageResolver;
|
package/fields/dist/messages.js
CHANGED
|
@@ -108,6 +108,7 @@ export const FIELD_MESSAGE_KEYS = [
|
|
|
108
108
|
"save.failed",
|
|
109
109
|
"save.refresh-failed",
|
|
110
110
|
"filter.any",
|
|
111
|
+
"filter.mixed-currency",
|
|
111
112
|
"filter.operator",
|
|
112
113
|
"filter.text-summary",
|
|
113
114
|
"filter.date-summary",
|
|
@@ -511,6 +512,8 @@ export const resolveFieldMessage = (message) => {
|
|
|
511
512
|
return `${message.values.noun} saved, but refresh failed`;
|
|
512
513
|
case "filter.any":
|
|
513
514
|
return "Any";
|
|
515
|
+
case "filter.mixed-currency":
|
|
516
|
+
return "Not applied: amounts in several currencies";
|
|
514
517
|
case "filter.operator":
|
|
515
518
|
return OPERATOR_LABELS[message.values.operator] ?? message.values.operator;
|
|
516
519
|
case "filter.text-summary": {
|
|
@@ -43,6 +43,10 @@ export type ViewFieldReader<Row> = {
|
|
|
43
43
|
* so the order flips with the direction; `undefined` (or no hook) sorts by
|
|
44
44
|
* what `read` returns, clustered by code as `codeOf` says. */
|
|
45
45
|
sortAmountOf?: (row: Row, key: string) => number | null | undefined;
|
|
46
|
+
/** Whether this reader reads money field `key` in one currency for every row: it converted the amounts, or the list
|
|
47
|
+
* shows them in one currency. A number rule over a field whose currency is each row's own compares only then;
|
|
48
|
+
* otherwise it is refused and filters nothing (`refusesNumberRule`). Absent: each row's own currency. */
|
|
49
|
+
oneCurrency?: (key: string) => boolean;
|
|
46
50
|
/** The records a row's relation holds, each read as a record of its own (`recordReaderFor` over the far rows and
|
|
47
51
|
* their reader), so a rule across the relation ("any / none / every of its records where …") is answered in
|
|
48
52
|
* memory. Absent, or `undefined` for a row, the rule has no opinion and the row stays. */
|
|
@@ -57,7 +61,9 @@ export declare function countMatching<Row>(rows: readonly Row[], filter: FilterT
|
|
|
57
61
|
}): number;
|
|
58
62
|
/** `answersRelations`: the reader hands in related records (`ViewFieldReader.related`), so a rule across a relation
|
|
59
63
|
* the reader knows filters too; without them it has no opinion. */
|
|
60
|
-
export declare function hasActiveRules(filter: FilterTree, fieldOf: (key: string) => FieldDef | undefined, answersRelations?: boolean
|
|
64
|
+
export declare function hasActiveRules(filter: FilterTree, fieldOf: (key: string) => FieldDef | undefined, answersRelations?: boolean,
|
|
65
|
+
/** The reader's `oneCurrency`: a number rule over money it reads in one currency is whole. */
|
|
66
|
+
oneCurrency?: (key: string) => boolean): boolean;
|
|
61
67
|
export declare function evaluateView<Row>(rows: readonly Row[], query: ViewQuery, reader: ViewFieldReader<Row>, opts?: {
|
|
62
68
|
now?: Date;
|
|
63
69
|
rowId?: (row: Row) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isPerCodeCurrency, knownField, scalarOf, valueTypeOf } from "../derived.js";
|
|
2
2
|
import { ruleReaderOf } from "./read-rule.js";
|
|
3
|
-
import { isRelationRule, matchesTree, ruleIsActive, whereWaits, } from "./filter.js";
|
|
3
|
+
import { isRelationRule, matchesTree, refusesNumberRule, ruleIsActive, whereWaits, } from "./filter.js";
|
|
4
4
|
import { compareBy } from "./sort.js";
|
|
5
5
|
import { bucketRows } from "./buckets.js";
|
|
6
6
|
import { figuresOf } from "./figures.js";
|
|
@@ -26,19 +26,22 @@ export function countMatching(rows, filter, reader, opts = {}) {
|
|
|
26
26
|
n += 1;
|
|
27
27
|
return n;
|
|
28
28
|
}
|
|
29
|
-
export function hasActiveRules(filter, fieldOf, answersRelations = false) {
|
|
29
|
+
export function hasActiveRules(filter, fieldOf, answersRelations = false, oneCurrency) {
|
|
30
30
|
return filter.items.some((item) => {
|
|
31
31
|
if ("items" in item)
|
|
32
|
-
return hasActiveRules({ op: "and", items: item.items }, fieldOf, answersRelations);
|
|
32
|
+
return hasActiveRules({ op: "and", items: item.items }, fieldOf, answersRelations, oneCurrency);
|
|
33
33
|
if (isRelationRule(item))
|
|
34
34
|
return (answersRelations && !item.setAside && !whereWaits(item.where) && knownField(fieldOf(item.fieldKey))?.type === "relation");
|
|
35
35
|
const field = knownField(fieldOf(item.fieldKey));
|
|
36
|
-
return !!field &&
|
|
36
|
+
return (!!field &&
|
|
37
|
+
!isPerCodeCurrency(field) &&
|
|
38
|
+
!refusesNumberRule(field, item.operator, oneCurrency?.(item.fieldKey)) &&
|
|
39
|
+
ruleIsActive(valueTypeOf(field), item));
|
|
37
40
|
});
|
|
38
41
|
}
|
|
39
42
|
export function evaluateView(rows, query, reader, opts = {}) {
|
|
40
43
|
const filter = withHold(query.filter, query.hold, reader.fieldOf);
|
|
41
|
-
const filters = hasActiveRules(filter, reader.fieldOf, !!reader.related);
|
|
44
|
+
const filters = hasActiveRules(filter, reader.fieldOf, !!reader.related, reader.oneCurrency);
|
|
42
45
|
const search = hasSearch(query.search) ? query.search : null;
|
|
43
46
|
const filtered = filters || search
|
|
44
47
|
? rows.filter((row) => (!filters || matchesTree(filter, recordReaderFor(row, reader), opts)) &&
|
|
@@ -78,6 +78,13 @@ export declare function operatorsFor(type: FieldType, part?: string): readonly F
|
|
|
78
78
|
* compare shows nothing to filter on rather than an operator that would compare
|
|
79
79
|
* the wrong thing. */
|
|
80
80
|
export declare function operatorsForField(field: FieldDef, part?: string): readonly FilterOperator[];
|
|
81
|
+
/** Whether an operator compares a number: every number operator but Is empty and Is not empty. */
|
|
82
|
+
export declare function comparesNumber(operator: FilterOperator): boolean;
|
|
83
|
+
/** Whether a rule with `operator` on `field` is refused: it compares a number, and the field's amounts are in
|
|
84
|
+
* several currencies (`isMixedCurrency`), which one number can't compare. `oneCurrency`: the list reads the field in
|
|
85
|
+
* one currency (its amounts converted, or one currency shown for all), so the number compares again. A refused rule
|
|
86
|
+
* filters nothing anywhere, and the list says why (`filter.mixed-currency`); its operators stay offered. */
|
|
87
|
+
export declare function refusesNumberRule(field: FieldDef, operator: FilterOperator, oneCurrency?: boolean): boolean;
|
|
81
88
|
export declare function defaultOperator(type: FieldType, part?: string): FilterOperator;
|
|
82
89
|
export declare function isFilterGroup(node: FilterNode): node is FilterGroup;
|
|
83
90
|
export declare function isRelationRule(node: FilterNode): node is FilterRelationRule;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { DEFAULT_CONVENTIONS } from "../conventions.js";
|
|
3
|
-
import { isPerCodeCurrency, valueTypeOf } from "../derived.js";
|
|
3
|
+
import { isMixedCurrency, isPerCodeCurrency, valueTypeOf } from "../derived.js";
|
|
4
4
|
import { actorKey } from "../actor.js";
|
|
5
5
|
import { relationIdOf, relationKey } from "../relation.js";
|
|
6
6
|
import { phoneFilterOperand, phoneMatchText, readPhone } from "../phone.js";
|
|
@@ -141,6 +141,12 @@ export function operatorsForField(field, part) {
|
|
|
141
141
|
return [];
|
|
142
142
|
return operatorsFor(valueTypeOf(field), part);
|
|
143
143
|
}
|
|
144
|
+
export function comparesNumber(operator) {
|
|
145
|
+
return operator !== "is_empty" && operator !== "is_not_empty";
|
|
146
|
+
}
|
|
147
|
+
export function refusesNumberRule(field, operator, oneCurrency = false) {
|
|
148
|
+
return !oneCurrency && comparesNumber(operator) && isMixedCurrency(field);
|
|
149
|
+
}
|
|
144
150
|
export function defaultOperator(type, part) {
|
|
145
151
|
return operatorsFor(type, part)[0];
|
|
146
152
|
}
|
|
@@ -6,7 +6,7 @@ import type { FilterTree } from "./filter.js";
|
|
|
6
6
|
import { type ViewBucket } from "./buckets.js";
|
|
7
7
|
import type { GroupFigures } from "./figures.js";
|
|
8
8
|
import type { GroupSpec } from "./group.js";
|
|
9
|
-
import { type NumberFilterRule } from "./number.js";
|
|
9
|
+
import { type DurationUnit, type NumberFilterRule } from "./number.js";
|
|
10
10
|
import type { ListHold } from "./hold.js";
|
|
11
11
|
import { type ViewSearch } from "./search.js";
|
|
12
12
|
import { type SortSpec } from "./sort.js";
|
|
@@ -49,7 +49,8 @@ export type QueryKit = {
|
|
|
49
49
|
compareBy<Row>(sorts: readonly SortSpec[], reader: ViewFieldReader<Row>): (a: Row, b: Row) => number;
|
|
50
50
|
dateRuleLabel(rule: DateFilterRule | null | undefined): string;
|
|
51
51
|
textRuleLabel(rule: TextFilterRule | null | undefined): string;
|
|
52
|
-
|
|
52
|
+
/** `duration`: the unit a duration rule is kept in, its bounds then written as the duration box writes them. */
|
|
53
|
+
numberRuleLabel(rule: NumberFilterRule | null | undefined, decimals?: number, unit?: string, duration?: DurationUnit): string;
|
|
53
54
|
parseNumber(raw: string): number | null;
|
|
54
55
|
/** A new kit over `conventions.with(overrides)`. */
|
|
55
56
|
with(overrides: ConventionsInput): QueryKit;
|
package/fields/dist/query/kit.js
CHANGED
|
@@ -21,7 +21,7 @@ export function createQueryKit(conventions = DEFAULT_CONVENTIONS) {
|
|
|
21
21
|
compareBy: (sorts, reader) => compareBy(sorts, reader, cv),
|
|
22
22
|
dateRuleLabel: (rule) => dateRuleLabel(rule, cv),
|
|
23
23
|
textRuleLabel: (rule) => textRuleLabel(rule, cv),
|
|
24
|
-
numberRuleLabel: (rule, decimals, unit) => numberRuleLabel(rule, decimals, unit, cv),
|
|
24
|
+
numberRuleLabel: (rule, decimals, unit, duration) => numberRuleLabel(rule, decimals, unit, cv, duration),
|
|
25
25
|
parseNumber: (raw) => parseNumber(raw, cv),
|
|
26
26
|
with: (overrides) => createQueryKit(cv.with(overrides)),
|
|
27
27
|
};
|
|
@@ -10,6 +10,12 @@ export type ListPersonalLayer = {
|
|
|
10
10
|
phoneLayout?: ListLayout;
|
|
11
11
|
/** Their look over the view's; a key they left out is the view's. */
|
|
12
12
|
look?: ListLook;
|
|
13
|
+
/** Their toolbar, where the app lets them set it: when the filter bar stands (`added`, once something is added;
|
|
14
|
+
* `always`) and the buttons' words (`both`, icon and word; `icon`; `word`). Where its parts sit is the app's alone. */
|
|
15
|
+
toolbar?: {
|
|
16
|
+
bar?: "added" | "always";
|
|
17
|
+
words?: "both" | "icon" | "word";
|
|
18
|
+
};
|
|
13
19
|
};
|
|
14
20
|
/** The settings a person sees, with what they apply to that the settings don't hold. */
|
|
15
21
|
export type ListSettingsSeen = {
|
|
@@ -24,6 +24,9 @@ export const listPersonalLayerSchema = z.strictObject({
|
|
|
24
24
|
.optional(),
|
|
25
25
|
phoneLayout: z.enum(["table", "list", "board", "calendar"]).optional(),
|
|
26
26
|
look: listLookSchema.optional(),
|
|
27
|
+
toolbar: z
|
|
28
|
+
.strictObject({ bar: z.enum(["added", "always"]).optional(), words: z.enum(["both", "icon", "word"]).optional() })
|
|
29
|
+
.optional(),
|
|
27
30
|
});
|
|
28
31
|
function columnId(column) {
|
|
29
32
|
return column.part === undefined ? column.key : partKey(column.key, column.part);
|
|
@@ -69,8 +69,9 @@ export declare function durationUnitToMs(value: number, unit?: DurationUnit): nu
|
|
|
69
69
|
export declare function formatDurationInput(ms: number, cv?: FieldConventions): string;
|
|
70
70
|
/** Is the rule complete enough to filter? A half-typed range must not. */
|
|
71
71
|
export declare function isNumberRuleActive(rule: NumberFilterRule | null | undefined): boolean;
|
|
72
|
-
/** The row's right-hand summary: `> 100`, `100 – 500`, `Is empty`, `Any`.
|
|
73
|
-
|
|
72
|
+
/** The row's right-hand summary: `> 100`, `100 – 500`, `Is empty`, `Any`. `duration`: the unit a duration rule is kept
|
|
73
|
+
* in; each bound is then written as the duration box writes it (`> 1m 30s`), never the stored number. */
|
|
74
|
+
export declare function numberRuleLabel(rule: NumberFilterRule | null | undefined, decimals?: number, unit?: string, cv?: FieldConventions, duration?: DurationUnit): string;
|
|
74
75
|
/**
|
|
75
76
|
* The decimals a number rule's `eq` and `neq` round both sides to on `field`, as the grid works them out for the field's
|
|
76
77
|
* column: none for a whole number, percent, currency or range; else the decimals the field states (a rollup, a formula or
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_CONVENTIONS, conventionsOr } from "../conventions.js";
|
|
2
2
|
import { isIntegerField, presentedDef } from "../derived.js";
|
|
3
|
+
import { formatDurationMs } from "../format/time.js";
|
|
3
4
|
import { compareDecimalText, decimalTextOf, isDecimalText, parseNumber, roundDecimalText } from "../parse-number.js";
|
|
4
5
|
export { parseNumber } from "../parse-number.js";
|
|
5
6
|
export const NUMBER_FILTER_OPERATORS = [
|
|
@@ -94,12 +95,13 @@ function formatDot(value, decimals) {
|
|
|
94
95
|
return String(Math.round(value));
|
|
95
96
|
return value.toFixed(decimals).replace(/\.?0+$/, "") || "0";
|
|
96
97
|
}
|
|
97
|
-
export function numberRuleLabel(rule, decimals = 2, unit, cv = DEFAULT_CONVENTIONS) {
|
|
98
|
+
export function numberRuleLabel(rule, decimals = 2, unit, cv = DEFAULT_CONVENTIONS, duration) {
|
|
98
99
|
cv = conventionsOr(cv);
|
|
99
100
|
if (!isNumberRuleActive(rule))
|
|
100
101
|
return cv.messages({ key: "filter.any" });
|
|
101
102
|
const suffix = unit ? ` ${unit}` : "";
|
|
102
|
-
const
|
|
103
|
+
const bound = (v) => (duration ? formatDurationMs(durationUnitToMs(v, duration)) : format(v, decimals, cv));
|
|
104
|
+
const shown = (v) => (duration ? bound(v) : `${bound(v)}${suffix}`);
|
|
103
105
|
switch (rule.operator) {
|
|
104
106
|
case "eq":
|
|
105
107
|
return shown(rule.value);
|
|
@@ -114,7 +116,7 @@ export function numberRuleLabel(rule, decimals = 2, unit, cv = DEFAULT_CONVENTIO
|
|
|
114
116
|
case "lte":
|
|
115
117
|
return `≤ ${shown(rule.value)}`;
|
|
116
118
|
case "between":
|
|
117
|
-
return `${
|
|
119
|
+
return `${bound(rule.value)} – ${shown(rule.value2)}`;
|
|
118
120
|
case "is_empty":
|
|
119
121
|
case "is_not_empty":
|
|
120
122
|
return numberFilterOperatorLabel(rule.operator, cv);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { isPerCodeCurrency, knownField, scalarOf, storesDecimalText, valueTypeOf } from "../derived.js";
|
|
2
|
+
import { refusesNumberRule } from "./filter.js";
|
|
2
3
|
export function ruleReaderOf(row, reader) {
|
|
3
4
|
return (rule) => {
|
|
4
5
|
const field = knownField(reader.fieldOf(rule.fieldKey));
|
|
5
6
|
if (!field || isPerCodeCurrency(field))
|
|
6
7
|
return undefined;
|
|
8
|
+
if (refusesNumberRule(field, rule.operator, reader.oneCurrency?.(rule.fieldKey)))
|
|
9
|
+
return undefined;
|
|
7
10
|
return {
|
|
8
11
|
type: valueTypeOf(field),
|
|
9
12
|
value: scalarOf(field, reader.read(row, rule.fieldKey)),
|
|
@@ -186,7 +186,7 @@ A `FilterRule` is one field, one operator and one value. A `FilterGroup` combine
|
|
|
186
186
|
Every negative way (`is_not`, `neq`, `is_none_of`, `not_contains`) keeps a row whose value is empty, for every type: "Amount is not 0" and "Stage is not Won" both keep the row that has neither. `is_empty` asks for those rows alone.
|
|
187
187
|
|
|
188
188
|
```ts
|
|
189
|
-
const
|
|
189
|
+
const openOrUndated: FilterTree = {
|
|
190
190
|
op: "and",
|
|
191
191
|
items: [
|
|
192
192
|
{ fieldKey: "stage", operator: "is_none_of", value: ["lost"] },
|
|
@@ -194,13 +194,13 @@ const openOrBig: FilterTree = {
|
|
|
194
194
|
op: "or",
|
|
195
195
|
items: [
|
|
196
196
|
{ fieldKey: "currency", operator: "is_any_of", value: ["EUR"] },
|
|
197
|
-
{ fieldKey: "
|
|
197
|
+
{ fieldKey: "closeOn", operator: "is_empty", value: null },
|
|
198
198
|
],
|
|
199
199
|
},
|
|
200
200
|
],
|
|
201
201
|
};
|
|
202
|
-
// d1 is in euros, d4
|
|
203
|
-
assert.equal(countMatching(DEALS,
|
|
202
|
+
// d1 is in euros, d4 has no close date, d6 is in euros; d3 is lost.
|
|
203
|
+
assert.equal(countMatching(DEALS, openOrUndated, deals), 3);
|
|
204
204
|
```
|
|
205
205
|
|
|
206
206
|
`treeDepth` counts a tree's levels. A panel caps how deep a person can nest at `FILTER_TREE_MAX_UI_DEPTH`; the evaluator reads a tree of any depth.
|
|
@@ -208,7 +208,7 @@ assert.equal(countMatching(DEALS, openOrBig, deals), 3);
|
|
|
208
208
|
```ts
|
|
209
209
|
import { FILTER_TREE_MAX_UI_DEPTH, treeDepth } from "viewkitjs/fields/query";
|
|
210
210
|
|
|
211
|
-
assert.equal(treeDepth(
|
|
211
|
+
assert.equal(treeDepth(openOrUndated), 2);
|
|
212
212
|
assert.equal(FILTER_TREE_MAX_UI_DEPTH, 3);
|
|
213
213
|
```
|
|
214
214
|
|
|
@@ -235,7 +235,7 @@ const stillTyping: FilterTree = {
|
|
|
235
235
|
};
|
|
236
236
|
assert.equal(countMatching(DEALS, stillTyping, deals), DEALS.length);
|
|
237
237
|
assert.equal(hasActiveRules(stillTyping, deals.fieldOf), false);
|
|
238
|
-
assert.equal(hasActiveRules(
|
|
238
|
+
assert.equal(hasActiveRules(openOrUndated, deals.fieldOf), true);
|
|
239
239
|
```
|
|
240
240
|
|
|
241
241
|
A `FilterRelationRule` reads across a relation: any, none or every of the far records where its own tree holds. The far records are not among the rows in memory, so unless the reader hands them in the evaluator has no opinion on it and every row stays. A database adapter answers it.
|
|
@@ -347,7 +347,7 @@ The evaluator forgives: a rule it cannot read keeps the row. A saved view deserv
|
|
|
347
347
|
const DEAL = entityDef(DEAL_FIELDS);
|
|
348
348
|
const INDEX = defineIndex([DEAL, entityDef(COMPANY_FIELDS), entityDef(PERSON_FIELDS)]);
|
|
349
349
|
|
|
350
|
-
checkFilterTree(
|
|
350
|
+
checkFilterTree(openOrUndated, DEAL, INDEX, "deals view");
|
|
351
351
|
checkFilterTree(atBigCompanies, DEAL, INDEX, "deals view");
|
|
352
352
|
|
|
353
353
|
assert.throws(
|
|
@@ -392,19 +392,29 @@ assert.deepEqual(FILTER_OPERATORS.name, FILTER_OPERATORS.text);
|
|
|
392
392
|
|
|
393
393
|
A number rule compares the number the cell draws. Equality rounds both sides to the column's decimals, two unless the reader's `decimalsOf` says otherwise, so `= 100` finds an amount that reads `100.00` after a conversion. The decimals the grid rounds a field to are `ruleDecimalsOf(field)`'s; a reader of your own, or a server that translates rules, hands those. The comparisons need no rounding. `between` takes its two bounds in either order. Zero is a value: only an absent number is empty. `neq` keeps the rows with no number, as every "not" rule keeps an empty value.
|
|
394
394
|
|
|
395
|
+
A money field whose currency is each row's own (`code: { field }`) keeps 12000 EUR beside 5000 RON, and one number can't compare them: a rule that compares a number over it is refused (`refusesNumberRule`), filters nothing, and the list says why (`filter.mixed-currency`). Is empty and Is not empty compare no number and filter as ever. The deals' `value` is such a field, so read as kept it can't be narrowed by an amount. A reader that converts its amounts into one currency says so with `oneCurrency`, and the number compares again; so does a field that converts (`convert`), or one kept in one currency (`code: { fixed }`).
|
|
396
|
+
|
|
395
397
|
```ts
|
|
396
|
-
assert.deepEqual(kept(DEALS, deals, { fieldKey: "value", operator: "
|
|
397
|
-
|
|
398
|
+
assert.deepEqual(kept(DEALS, deals, { fieldKey: "value", operator: "gt", value: 500 }), ["d1", "d2", "d3", "d4", "d5", "d6"]);
|
|
399
|
+
assert.deepEqual(kept(DEALS, deals, { fieldKey: "value", operator: "is_empty", value: null }), ["d6"]);
|
|
400
|
+
|
|
401
|
+
const TO_EUR: Record<string, number> = { EUR: 1, RON: 0.2 };
|
|
402
|
+
const inEuros: ViewFieldReader<Deal> = {
|
|
403
|
+
...deals,
|
|
404
|
+
read: (row, key) =>
|
|
405
|
+
key === "value" && row.value !== null ? row.value * (TO_EUR[row.currency ?? ""] ?? 1) : deals.read(row, key),
|
|
406
|
+
codeOf: (_row, key) => (key === "value" ? "EUR" : undefined),
|
|
407
|
+
oneCurrency: (key) => key === "value",
|
|
408
|
+
};
|
|
409
|
+
assert.deepEqual(kept(DEALS, inEuros, { fieldKey: "value", operator: "eq", value: 100 }), ["d5"]);
|
|
410
|
+
const threeDecimals: ViewFieldReader<Deal> = { ...inEuros, decimalsOf: (key) => (key === "value" ? 3 : undefined) };
|
|
398
411
|
assert.equal(countMatching(DEALS, treeOf({ fieldKey: "value", operator: "eq", value: 100 }), threeDecimals), 0);
|
|
399
412
|
|
|
400
|
-
assert.deepEqual(kept(DEALS,
|
|
401
|
-
assert.deepEqual(kept(DEALS,
|
|
402
|
-
assert.
|
|
403
|
-
assert.ok(kept(DEALS, deals, { fieldKey: "value", operator: "neq", value: 100 }).includes("d6"));
|
|
413
|
+
assert.deepEqual(kept(DEALS, inEuros, { fieldKey: "value", operator: "between", value: [20000, 1000] }), ["d1", "d2", "d4"]);
|
|
414
|
+
assert.deepEqual(kept(DEALS, inEuros, { fieldKey: "value", operator: "lt", value: 1000 }), ["d3", "d5"]);
|
|
415
|
+
assert.ok(kept(DEALS, inEuros, { fieldKey: "value", operator: "neq", value: 100 }).includes("d6"));
|
|
404
416
|
```
|
|
405
417
|
|
|
406
|
-
A rule over a currency column compares the number alone: `lt 1000` above keeps 900 EUR and the 99.996 whose code nobody states alike. A reader that converts its amounts into one currency makes the number comparable, and says so through `codeOf` (see [A currency column of mixed codes](#a-currency-column-of-mixed-codes)).
|
|
407
|
-
|
|
408
418
|
## Date rules
|
|
409
419
|
|
|
410
420
|
A date rule compares calendar days, never instants. `is_relative` stores its intent, a direction and a unit, and resolves it against `now` each time, so "past week" still means the past week tomorrow. `this` is the calendar period around today, the week running Monday to Sunday. `past` and `next` reach one unit back or forward from today, both ends included. The other operators take day keys, `YYYY-MM-DD`; `is_between` takes a pair in either order, and filters nothing until both days are picked: an end left empty, `""` or null, leaves the rule unfinished and every row stays. `is_not` keeps every row but that day's, the rows with no date included, as every "not" rule keeps an empty value.
|
|
@@ -548,16 +558,10 @@ assert.deepEqual(sortedBy(DEALS, [{ fieldKey: "value", direction: "asc" }], deal
|
|
|
548
558
|
assert.deepEqual(sortedBy(DEALS, [{ fieldKey: "value", direction: "desc" }], deals), ["d1", "d3", "d4", "d2", "d5", "d6"]);
|
|
549
559
|
```
|
|
550
560
|
|
|
551
|
-
The library converts nothing. A reader that converts inside `read` knows the one currency its numbers came out in, and says so with `codeOf
|
|
561
|
+
The library converts nothing. A reader that converts inside `read` knows the one currency its numbers came out in, and says so with `codeOf` (and with `oneCurrency`, for its number rules); the column then sorts as the plain numbers it draws.
|
|
552
562
|
|
|
553
563
|
```ts
|
|
554
|
-
|
|
555
|
-
const inEuros: ViewFieldReader<Deal> = {
|
|
556
|
-
...deals,
|
|
557
|
-
read: (row, key) =>
|
|
558
|
-
key === "value" && row.value !== null ? row.value * (TO_EUR[row.currency ?? ""] ?? 1) : deals.read(row, key),
|
|
559
|
-
codeOf: (_row, key) => (key === "value" ? "EUR" : undefined),
|
|
560
|
-
};
|
|
564
|
+
// `inEuros`, from Number rules: every amount converted into euros.
|
|
561
565
|
assert.deepEqual(sortedBy(DEALS, [{ fieldKey: "value", direction: "asc" }], inEuros), ["d5", "d3", "d2", "d4", "d1", "d6"]);
|
|
562
566
|
```
|
|
563
567
|
|
|
@@ -847,7 +851,7 @@ assert.equal(kit.conventions.timeZone, "Europe/Bucharest");
|
|
|
847
851
|
assert.equal(kit.parseNumber("1.234,5"), 1234.5);
|
|
848
852
|
assert.equal(kit.textRuleLabel({ operator: "contains", query: "acme" }), 'contains "acme"');
|
|
849
853
|
assert.equal(kit.numberRuleLabel({ operator: "between", value: 100, value2: 500 }), "100 – 500");
|
|
850
|
-
assert.equal(kit.countMatching(DEALS,
|
|
854
|
+
assert.equal(kit.countMatching(DEALS, openOrUndated, deals), 3);
|
|
851
855
|
|
|
852
856
|
const romanian = kit.with({ locale: "ro" });
|
|
853
857
|
assert.equal(romanian.conventions.timeZone, "Europe/Bucharest");
|
|
@@ -137,6 +137,7 @@ Guide: [derived fields](../guides/derived-fields.md).
|
|
|
137
137
|
- `scalarOf` — the one value a field's value is sorted, filtered and totalled by: a breakdown's headline, and any other value itself.
|
|
138
138
|
- `valueTypeOf` — the type a consumer dispatches on: a rollup's or formula's result type, a lookup's far field's type (text while unresolved), or the field's own type.
|
|
139
139
|
- `presentedDef` — a derived field as the plain field its consumers can read: the result's shape under the field's own key and label, never editable, frozen. A rollup's or a formula's keeps its provenance; a lookup's takes the far field's shape without its provenance. It writes no sentence; `lockReason` on the original field does.
|
|
140
|
+
- `isMixedCurrency` — says whether a money field keeps amounts in several currencies: its currency is each row's own (`code: { field }`) and no `convert` reads it in one.
|
|
140
141
|
- `isPerCodeCurrency` — says whether a rollup's or formula's currency result is one amount per currency code rather than one number.
|
|
141
142
|
- `conversionOf` — a money field's conversion, when its currency code is a sibling field that declares one; null for anything else, and it never throws.
|
|
142
143
|
- `looksAhead` — says whether a date or instant field looks ahead, read off the presented definition so a lookup of one answers too; false for anything else.
|