viewkitjs 0.22.0 → 0.24.0-pr-755-9d44fcd
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 +27 -0
- package/fields/dist/creatable.d.ts +9 -5
- package/fields/dist/creatable.js +8 -1
- package/fields/dist/messages.d.ts +19 -1
- package/fields/dist/messages.js +75 -0
- package/fields/dist/registry.js +4 -7
- package/fields/dist/types.d.ts +4 -2
- package/fields/dist/zod.d.ts +58 -0
- package/fields/dist/zod.js +430 -2
- package/fields/docs/guides/checking-definitions.md +6 -1
- package/fields/docs/guides/field-types.md +5 -1
- package/fields/docs/reference/definitions.md +1 -2
- package/fields/docs/reference/types.md +2 -1
- package/fields/skills/viewkit/SKILL.md +2 -2
- package/package.json +2 -4
- package/views/dist/contract.d.ts +6 -289
- package/views/dist/contract.js +1 -96
- package/views/dist/controls/atoms.d.ts +8 -0
- package/views/dist/controls/atoms.js +8 -0
- package/views/dist/controls/button/tokens.d.ts +351 -0
- package/views/dist/controls/button/tokens.js +90 -0
- package/views/dist/controls/checkbox/checkbox.d.ts +28 -0
- package/views/dist/controls/checkbox/checkbox.js +15 -0
- package/views/dist/controls/checkbox/looks.d.ts +3 -0
- package/views/dist/controls/checkbox/looks.js +8 -0
- package/views/dist/controls/checkbox/map-checkbox.d.ts +2 -0
- package/views/dist/controls/checkbox/map-checkbox.js +5 -0
- package/views/dist/controls/checkbox/tokens.d.ts +131 -0
- package/views/dist/controls/checkbox/tokens.js +35 -0
- package/views/dist/controls/checkbox.css +133 -0
- package/views/dist/controls/controls.d.ts +12 -3
- package/views/dist/controls/controls.js +13 -1
- package/views/dist/controls/field/field.d.ts +94 -0
- package/views/dist/controls/field/field.js +46 -0
- package/views/dist/controls/field/looks.d.ts +13 -0
- package/views/dist/controls/field/looks.js +22 -0
- package/views/dist/controls/field/tokens.d.ts +75 -0
- package/views/dist/controls/field/tokens.js +21 -0
- package/views/dist/controls/field.css +98 -0
- package/views/dist/controls/glass-button/glass-button.d.ts +40 -0
- package/views/dist/controls/glass-button/glass-button.js +16 -0
- package/views/dist/controls/glass-button/looks.d.ts +4 -0
- package/views/dist/controls/glass-button/looks.js +4 -0
- package/views/dist/controls/glass-button/tokens.d.ts +127 -0
- package/views/dist/controls/glass-button/tokens.js +34 -0
- package/views/dist/controls/glass-button.css +111 -0
- package/views/dist/controls/grip/grip.d.ts +14 -0
- package/views/dist/controls/grip/grip.js +9 -0
- package/views/dist/controls/index.d.ts +32 -0
- package/views/dist/controls/index.js +31 -0
- package/views/dist/controls/inline-input/inline-input.d.ts +14 -0
- package/views/dist/controls/inline-input/inline-input.js +10 -0
- package/views/dist/controls/inline-input/looks.d.ts +3 -0
- package/views/dist/controls/inline-input/looks.js +16 -0
- package/views/dist/controls/inline-input/tokens.d.ts +79 -0
- package/views/dist/controls/inline-input/tokens.js +22 -0
- package/views/dist/controls/inline-input.css +78 -0
- package/views/dist/controls/input/autofill.d.ts +25 -0
- package/views/dist/controls/input/autofill.js +17 -0
- package/views/dist/controls/input/input.d.ts +119 -0
- package/views/dist/controls/input/input.js +127 -0
- package/views/dist/controls/input/looks.d.ts +41 -0
- package/views/dist/controls/input/looks.js +48 -0
- package/views/dist/controls/input/map-input.d.ts +2 -0
- package/views/dist/controls/input/map-input.js +5 -0
- package/views/dist/controls/input/tokens.d.ts +171 -0
- package/views/dist/controls/input/tokens.js +45 -0
- package/views/dist/controls/input.css +381 -0
- package/views/dist/controls/internal/anchor.d.ts +16 -0
- package/views/dist/controls/internal/anchor.js +8 -0
- package/views/dist/controls/internal/close-reason.d.ts +5 -0
- package/views/dist/controls/internal/close-reason.js +2 -0
- package/views/dist/controls/internal/hold.d.ts +25 -0
- package/views/dist/controls/internal/hold.js +81 -0
- package/views/dist/controls/internal/icons.d.ts +8 -0
- package/views/dist/controls/internal/icons.js +65 -0
- package/views/dist/controls/internal/popup-host.d.ts +7 -0
- package/views/dist/controls/internal/popup-host.js +10 -0
- package/views/dist/controls/internal/read-token.d.ts +6 -0
- package/views/dist/controls/internal/read-token.js +11 -0
- package/views/dist/controls/internal/reorder.d.ts +44 -0
- package/views/dist/controls/internal/reorder.js +83 -0
- package/views/dist/controls/internal/scroll.d.ts +11 -0
- package/views/dist/controls/internal/scroll.js +14 -0
- package/views/dist/controls/kbd/kbd.d.ts +13 -0
- package/views/dist/controls/kbd/kbd.js +10 -0
- package/views/dist/controls/kbd/looks.d.ts +4 -0
- package/views/dist/controls/kbd/looks.js +4 -0
- package/views/dist/controls/kbd/tokens.d.ts +47 -0
- package/views/dist/controls/kbd/tokens.js +14 -0
- package/views/dist/controls/kbd.css +46 -0
- package/views/dist/controls/list/tokens.d.ts +139 -0
- package/views/dist/controls/list/tokens.js +37 -0
- package/views/dist/controls/list.css +188 -0
- package/views/dist/controls/menu-list/keys.d.ts +7 -0
- package/views/dist/controls/menu-list/keys.js +29 -0
- package/views/dist/controls/menu-list/looks.d.ts +4 -0
- package/views/dist/controls/menu-list/looks.js +20 -0
- package/views/dist/controls/menu-list/menu-list.d.ts +196 -0
- package/views/dist/controls/menu-list/menu-list.js +346 -0
- package/views/dist/controls/menu-list/tokens.d.ts +187 -0
- package/views/dist/controls/menu-list/tokens.js +49 -0
- package/views/dist/controls/menu-list.css +259 -0
- package/views/dist/controls/number-field/number-field.d.ts +48 -0
- package/views/dist/controls/number-field/number-field.js +34 -0
- package/views/dist/controls/number-field/tokens.d.ts +47 -0
- package/views/dist/controls/number-field/tokens.js +14 -0
- package/views/dist/controls/number-field.css +54 -0
- package/views/dist/controls/option/atom-tag.d.ts +6 -0
- package/views/dist/controls/option/atom-tag.js +6 -0
- package/views/dist/controls/option/looks.d.ts +7 -0
- package/views/dist/controls/option/looks.js +21 -0
- package/views/dist/controls/option/option.d.ts +35 -0
- package/views/dist/controls/option/option.js +32 -0
- package/views/dist/controls/option/tokens.d.ts +223 -0
- package/views/dist/controls/option/tokens.js +58 -0
- package/views/dist/controls/option.css +92 -0
- package/views/dist/controls/phone-header/header-bar.d.ts +18 -0
- package/views/dist/controls/phone-header/header-bar.js +9 -0
- package/views/dist/controls/phone-header/looks.d.ts +4 -0
- package/views/dist/controls/phone-header/looks.js +4 -0
- package/views/dist/controls/phone-header/soft-edge.d.ts +5 -0
- package/views/dist/controls/phone-header/soft-edge.js +3 -0
- package/views/dist/controls/phone-header/tokens.d.ts +59 -0
- package/views/dist/controls/phone-header/tokens.js +17 -0
- package/views/dist/controls/phone-header.css +51 -0
- package/views/dist/controls/popover/looks.d.ts +4 -0
- package/views/dist/controls/popover/looks.js +10 -0
- package/views/dist/controls/popover/map-popover.d.ts +3 -0
- package/views/dist/controls/popover/map-popover.js +5 -0
- package/views/dist/controls/popover/popover.d.ts +74 -0
- package/views/dist/controls/popover/popover.js +106 -0
- package/views/dist/controls/popover/tokens.d.ts +83 -0
- package/views/dist/controls/popover/tokens.js +23 -0
- package/views/dist/controls/popover.css +94 -0
- package/views/dist/controls/scrollbar/scrollbar.d.ts +10 -0
- package/views/dist/controls/scrollbar/scrollbar.js +143 -0
- package/views/dist/controls/scrollbar/tokens.d.ts +43 -0
- package/views/dist/controls/scrollbar/tokens.js +13 -0
- package/views/dist/controls/scrollbar.css +47 -0
- package/views/dist/controls/sheet/bottom-sheet.d.ts +98 -0
- package/views/dist/controls/sheet/bottom-sheet.js +375 -0
- package/views/dist/controls/sheet/forms.d.ts +38 -0
- package/views/dist/controls/sheet/forms.js +26 -0
- package/views/dist/controls/sheet/looks.d.ts +4 -0
- package/views/dist/controls/sheet/looks.js +10 -0
- package/views/dist/controls/sheet/map-sheet.d.ts +3 -0
- package/views/dist/controls/sheet/map-sheet.js +12 -0
- package/views/dist/controls/sheet/spring.d.ts +22 -0
- package/views/dist/controls/sheet/spring.js +48 -0
- package/views/dist/controls/sheet/tokens.d.ts +143 -0
- package/views/dist/controls/sheet/tokens.js +38 -0
- package/views/dist/controls/sheet.css +223 -0
- package/views/dist/controls/spinner/tokens.d.ts +55 -0
- package/views/dist/controls/spinner/tokens.js +16 -0
- package/views/dist/controls/status/atom-status-badge.d.ts +10 -0
- package/views/dist/controls/status/atom-status-badge.js +13 -0
- package/views/dist/controls/status/looks.d.ts +4 -0
- package/views/dist/controls/status/looks.js +22 -0
- package/views/dist/controls/status/marks.d.ts +26 -0
- package/views/dist/controls/status/marks.js +73 -0
- package/views/dist/controls/status/status.d.ts +43 -0
- package/views/dist/controls/status/status.js +26 -0
- package/views/dist/controls/status/tokens.d.ts +407 -0
- package/views/dist/controls/status/tokens.js +104 -0
- package/views/dist/controls/status.css +164 -0
- package/views/dist/controls/switch/looks.d.ts +4 -0
- package/views/dist/controls/switch/looks.js +19 -0
- package/views/dist/controls/switch/switch.d.ts +15 -0
- package/views/dist/controls/switch/switch.js +11 -0
- package/views/dist/controls/switch/tokens.d.ts +139 -0
- package/views/dist/controls/switch/tokens.js +37 -0
- package/views/dist/controls/switch.css +169 -0
- package/views/dist/controls/tag/atom-cell-more.d.ts +3 -0
- package/views/dist/controls/tag/atom-cell-more.js +5 -0
- package/views/dist/controls/tag/looks.d.ts +4 -0
- package/views/dist/controls/tag/looks.js +4 -0
- package/views/dist/controls/tag/tag.d.ts +25 -0
- package/views/dist/controls/tag/tag.js +19 -0
- package/views/dist/controls/tag/tokens.d.ts +63 -0
- package/views/dist/controls/tag/tokens.js +18 -0
- package/views/dist/controls/tag.css +81 -0
- package/views/dist/controls/toggle/looks.d.ts +3 -0
- package/views/dist/controls/toggle/looks.js +12 -0
- package/views/dist/controls/toggle/toggle.d.ts +47 -0
- package/views/dist/controls/toggle/toggle.js +23 -0
- package/views/dist/controls/toggle/tokens.d.ts +55 -0
- package/views/dist/controls/toggle/tokens.js +16 -0
- package/views/dist/controls/toggle.css +67 -0
- package/views/dist/controls/tokens.d.ts +16 -0
- package/views/dist/controls/tokens.js +49 -0
- package/views/dist/controls/tooltip/looks.d.ts +4 -0
- package/views/dist/controls/tooltip/looks.js +4 -0
- package/views/dist/controls/tooltip/map-tooltip.d.ts +3 -0
- package/views/dist/controls/tooltip/map-tooltip.js +5 -0
- package/views/dist/controls/tooltip/tokens.d.ts +75 -0
- package/views/dist/controls/tooltip/tokens.js +21 -0
- package/views/dist/controls/tooltip/tooltip.d.ts +54 -0
- package/views/dist/controls/tooltip/tooltip.js +78 -0
- package/views/dist/controls/tooltip.css +94 -0
- package/views/dist/grid/chrome/GridTable.js +21 -19
- package/views/dist/grid/chrome/grid-caret-keys.d.ts +7 -0
- package/views/dist/grid/chrome/grid-caret-keys.js +22 -0
- package/views/dist/grid/chrome/grid-row-window.js +3 -0
- package/views/dist/grid/chrome/useGridColumnLayout.d.ts +4 -1
- package/views/dist/grid/chrome/useGridColumnLayout.js +17 -2
- package/views/dist/grid/chrome/useGridFittedWidths.d.ts +32 -0
- package/views/dist/grid/chrome/useGridFittedWidths.js +59 -0
- package/views/dist/grid/chrome/useGridKeyboard.js +3 -0
- package/views/dist/looks/index.d.ts +16 -0
- package/views/dist/looks/index.js +16 -0
- package/views/dist/looks/looks.d.ts +10 -9
- package/views/dist/looks/pieces.js +38 -2
- package/views/dist/model/column-schema.d.ts +3 -2
- package/views/dist/model/column-state.d.ts +11 -1
- package/views/dist/model/column-state.js +8 -2
- package/views/dist/styles.css +2362 -7
- package/views/dist/styles.unlayered.css +2362 -7
- package/views/docs/contract.md +5 -97
- package/views/docs/controls/button.md +93 -0
- package/views/docs/controls/checkbox.md +38 -0
- package/views/docs/controls/field.md +26 -0
- package/views/docs/controls/glass-button.md +37 -0
- package/views/docs/controls/inline-input.md +27 -0
- package/views/docs/controls/input.md +48 -0
- package/views/docs/controls/kbd.md +17 -0
- package/views/docs/controls/list.md +40 -0
- package/views/docs/controls/menu-list.md +52 -0
- package/views/docs/controls/number-field.md +17 -0
- package/views/docs/controls/option.md +61 -0
- package/views/docs/controls/phone-header.md +20 -0
- package/views/docs/controls/popover.md +26 -0
- package/views/docs/controls/scrollbar.md +16 -0
- package/views/docs/controls/sheet.md +41 -0
- package/views/docs/controls/spinner.md +19 -0
- package/views/docs/controls/status.md +107 -0
- package/views/docs/controls/switch.md +40 -0
- package/views/docs/controls/tag.md +21 -0
- package/views/docs/controls/toggle.md +19 -0
- package/views/docs/controls/tooltip.md +24 -0
- package/views/docs/getting-started.md +1 -1
- package/views/docs/reference/controls.md +213 -2
- package/views/docs/reference/looks.md +70 -3
- package/views/docs/reference/views.md +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,33 @@ Until 0.19.0 ViewKit shipped as three packages; their changes are in [fields/CHA
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.23.0] — 2026-11-25
|
|
9
|
+
|
|
10
|
+
viewkitjs/views/controls: the Option, the Tag, the Status and the Switch, their looks in viewkitjs/views/looks; CONTROL_ATOMS draws ViewKit's Tag, StatusBadge and CellMore atoms with them for an app that spreads it into its atoms.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `viewkitjs/views/controls`: the bottom Sheet (`Sheet`, `SheetHead`, `SheetBody`, `SheetFoot`, `SheetStep`, `SheetButton`, `SheetClose`, `useSheetCloseAll`, `STOPS`), with its forms, its stops and its spring, and the phone's header bar (`HeaderBar`) with the soft edge it stands on (`SoftEdge`), join the default controls, on Base UI. `CONTROLS` now also holds `Sheet`. Their stylesheets are `viewkitjs/views/controls/sheet.css` and `phone-header.css`, and the ready stylesheet carries them.
|
|
15
|
+
- `viewkitjs/views/looks`: `SHEET_LOOKS` and `PHONE_HEADER_LOOKS`, by the Outright kit's names.
|
|
16
|
+
- `viewkitjs/views/controls`: the Popover, the Tooltip (with `TooltipGroup`, `TooltipShown` and `TOOLTIP_TIMING`), the Kbd, the Glass button (with `GlassButtonGroup`) and the Scrollbar join the default controls, on Base UI; `POPUP_HOST` and `popupHostOf` name where a popup stands. `CONTROLS` now also holds `Popover` and `Tooltip`. Each control's stylesheet is `viewkitjs/views/controls/<piece>.css` (`popover`, `tooltip`, `kbd`, `glass-button`, `scrollbar`), every name it reads listed on its page under `docs/controls/`, and the ready stylesheet carries them.
|
|
17
|
+
- `viewkitjs/views/looks`: `POPOVER_LOOKS`, `TOOLTIP_LOOKS`, `KBD_LOOKS` and `GLASS_BUTTON_LOOKS`, each control's options by the Outright kit's names.
|
|
18
|
+
- `viewkitjs/views/controls`: the Input (with its InputGroup, addons, buttons and segments, and a box's own look), the inline input, the Field (with FieldSet, FieldSeparator and Field rows), the Toggle and its group, the number field and the Checkbox (with its mark and list), on Base UI, as the Outright kit draws them; and `useAutofill`, which turns the browser's and the password managers' filling off on a box.
|
|
19
|
+
- `CONTROLS` draws the components map's `Input` and `Checkbox`.
|
|
20
|
+
- Their options and looks on `viewkitjs/views/looks`: `INPUT_LOOKS`, `INLINE_INPUT_LOOKS`, `FIELD_LOOKS`, `TOGGLE_LOOKS`, `CHECKBOX_LOOKS`; a box's own look beside the Input's (`InputOwnLook`, `inputAttrs`, `inputOwnAttrs`, `inputFrameAttrs`, `kindLook`, `attioBox`) and a Field rows card's (`fieldRowsAttrs`, `FieldRowsLook`).
|
|
21
|
+
- `VK_CONTROL_TOKENS_BY_PIECE` and `ControlToken`: each default control's own list of the names its stylesheet reads, with each name's kind and the Outright token it stands for (`outright`). `VK_CONTROL_TOKENS` gathers them, once each.
|
|
22
|
+
- Each control's names, kinds, Outright tokens and defaults are on its own page, `views/docs/controls/<piece>.md`.
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- `viewkitjs/views`: a column's `width` is optional. A grid column with no width of its own, and none the person or the saved view set, starts as wide as the values it first draws and its header need: never narrower than its header, at most 320 px, within the column's own `grid.minWidth` and `grid.maxWidth`. It keeps that width as rows scroll, load or change; a resize still wins, and a double-click on the handle goes back to it. On a phone the pinned columns with no width start at 160 px, so the rest of the row stays in view. A column that names a width is unchanged.
|
|
27
|
+
- The Sheet settles on the quick spring, with the smooth corner and the light dim where nothing is picked: My preset's picks, the Outright look's defaults.
|
|
28
|
+
- Where nothing says otherwise, the phone header's surface is Glass and two Glass buttons stand together on the pill, as their options' defaults say; only `data-phone-header-surface="flat"` or `data-glass-button-pair="separate"` set them apart.
|
|
29
|
+
- The default Popover's shadow is `md` and two Glass buttons share the glass pill unless something round them says `separate`: My preset's picks, the Outright look's defaults.
|
|
30
|
+
- The inline input's default is the Outright look's: the line, `md` corners, on a 20% tint of the brand (it was the `attio` look: `sm` corners on the overlay's ground). An app that picks none of its options, or only some, draws the new defaults for the rest.
|
|
31
|
+
- Their stylesheets, `viewkitjs/views/controls/{input,inline-input,field,toggle,number-field,checkbox}.css`, in the ready stylesheet too, and each one's tokens page under `views/docs/controls/`. Their phone rules hold below 640px, by the Outright Showcase's hooks (`o-phone`, `data-computer-host`), named in the controls' reference page.
|
|
32
|
+
- The number field's stepper gap is named with the addon it stands in (`.o-input-addon.o-number-steps`), so it wins over the addon's own gap whatever order the stylesheets load in.
|
|
33
|
+
- The controls' stylesheet doors are one pattern, `viewkitjs/views/controls/<piece>.css` (the outline's `smooth.css`, the Button's `button.css`, the Spinner's `spinner.css`), the same paths as before.
|
|
34
|
+
|
|
8
35
|
## [0.22.0] — 2026-11-25
|
|
9
36
|
|
|
10
37
|
### Added
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { type FieldConventions } from "./conventions.js";
|
|
2
2
|
import type { CategoryColor } from "./design/category-colors.js";
|
|
3
3
|
import type { StatusSlot } from "./design/status-slots.js";
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
export type CreatableFieldType = Exclude<FieldType, "actor" | "lookup" | "rollup" | "formula">;
|
|
4
|
+
import type { CreatableFieldType, FieldSpec } from "./types.js";
|
|
5
|
+
export type { CreatableFieldType } from "./types.js";
|
|
7
6
|
/** A setting applies only while another word or switch setting holds `is`; absent, that setting reads as its
|
|
8
7
|
* first word (a switch: off). When it stops holding, the setting is removed, and a block it leaves empty
|
|
9
8
|
* (`validation`, `format`, `code`) is removed with it: `checkFieldSpec` refuses the leftovers. */
|
|
@@ -16,6 +15,8 @@ export type FieldSettingWhen = {
|
|
|
16
15
|
type SettingBase = {
|
|
17
16
|
/** Where it sits in a definition, dotted: "validation.maxLength", "code.fixed". */
|
|
18
17
|
path: string;
|
|
18
|
+
/** Its name in the host's words, the message `setting.label`: "Decimals shown". */
|
|
19
|
+
label: string;
|
|
19
20
|
/** It holds a value whenever it applies: the starting definition carries one, or (a relation's kind) the app
|
|
20
21
|
* sets it before it saves. */
|
|
21
22
|
required?: true;
|
|
@@ -26,14 +27,18 @@ type SettingBase = {
|
|
|
26
27
|
/** One setting a definition of a type takes, with its kind and, for a word, its allowed words. */
|
|
27
28
|
export type FieldTypeSetting = SettingBase & ({
|
|
28
29
|
kind: "switch";
|
|
29
|
-
}
|
|
30
|
+
}
|
|
31
|
+
/** `wordLabels` names each word in the host's words, the message `setting.word`: "Up is good". */
|
|
32
|
+
| {
|
|
30
33
|
kind: "word";
|
|
31
34
|
words: readonly string[];
|
|
35
|
+
wordLabels: Readonly<Record<string, string>>;
|
|
32
36
|
}
|
|
33
37
|
/** Several of `words`, each once, in the person's order. */
|
|
34
38
|
| {
|
|
35
39
|
kind: "words";
|
|
36
40
|
words: readonly string[];
|
|
41
|
+
wordLabels: Readonly<Record<string, string>>;
|
|
37
42
|
} | {
|
|
38
43
|
kind: "number";
|
|
39
44
|
min?: number;
|
|
@@ -82,4 +87,3 @@ export declare const CREATABLE_FIELD_TYPES: readonly CreatableFieldType[];
|
|
|
82
87
|
* system sets, nor a lookup, rollup or formula, which are worked out from other fields.
|
|
83
88
|
*/
|
|
84
89
|
export declare function creatableFieldTypes(cv?: FieldConventions): readonly FieldTypeEntry[];
|
|
85
|
-
export {};
|
package/fields/dist/creatable.js
CHANGED
|
@@ -172,6 +172,13 @@ function deepFreeze(value) {
|
|
|
172
172
|
}
|
|
173
173
|
deepFreeze(ENTRIES);
|
|
174
174
|
export const CREATABLE_FIELD_TYPES = Object.freeze(ENTRIES.map((e) => e.type));
|
|
175
|
+
function labelled(type, setting, cv) {
|
|
176
|
+
const label = cv.messages({ key: "setting.label", values: { type, path: setting.path } });
|
|
177
|
+
if (setting.kind !== "word" && setting.kind !== "words")
|
|
178
|
+
return Object.freeze({ ...setting, label });
|
|
179
|
+
const wordLabels = Object.freeze(Object.fromEntries(setting.words.map((word) => [word, cv.messages({ key: "setting.word", values: { type, path: setting.path, word } })])));
|
|
180
|
+
return Object.freeze({ ...setting, label, wordLabels });
|
|
181
|
+
}
|
|
175
182
|
export function creatableFieldTypes(cv = DEFAULT_CONVENTIONS) {
|
|
176
183
|
cv = conventionsOr(cv);
|
|
177
184
|
return Object.freeze(ENTRIES.map(({ type, several, start, settings }) => {
|
|
@@ -181,7 +188,7 @@ export function creatableFieldTypes(cv = DEFAULT_CONVENTIONS) {
|
|
|
181
188
|
label,
|
|
182
189
|
icon: type,
|
|
183
190
|
several,
|
|
184
|
-
settings,
|
|
191
|
+
settings: Object.freeze(settings.map((setting) => labelled(type, setting, cv))),
|
|
185
192
|
spec: deepFreeze(JSON.parse(JSON.stringify({ type, label, ...start }))),
|
|
186
193
|
});
|
|
187
194
|
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActorType, FieldType, RollupFn } from "./types.js";
|
|
1
|
+
import type { ActorType, CreatableFieldType, FieldType, RollupFn } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* A typed message plus the values its host may interpolate. EVERY sentence the
|
|
4
4
|
* library writes is one of these — a host that translates them translates the
|
|
@@ -69,6 +69,24 @@ export type FieldMessage = {
|
|
|
69
69
|
values: {
|
|
70
70
|
type: FieldType;
|
|
71
71
|
};
|
|
72
|
+
}
|
|
73
|
+
/** A setting a New field dialog offers (`creatableFieldTypes`), by where it sits in the type's definition:
|
|
74
|
+
* "Decimals shown" for `format.decimals`. */
|
|
75
|
+
| {
|
|
76
|
+
key: "setting.label";
|
|
77
|
+
values: {
|
|
78
|
+
type: CreatableFieldType;
|
|
79
|
+
path: string;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** One of the words a word or words setting offers: "Up is good" for `format.signedTone`'s `positive-good`. */
|
|
83
|
+
| {
|
|
84
|
+
key: "setting.word";
|
|
85
|
+
values: {
|
|
86
|
+
type: CreatableFieldType;
|
|
87
|
+
path: string;
|
|
88
|
+
word: string;
|
|
89
|
+
};
|
|
72
90
|
} | {
|
|
73
91
|
key: "field.cannot-empty";
|
|
74
92
|
} | {
|
package/fields/dist/messages.js
CHANGED
|
@@ -24,6 +24,75 @@ const TYPE_LABELS = {
|
|
|
24
24
|
rollup: "Rollup",
|
|
25
25
|
formula: "Formula",
|
|
26
26
|
};
|
|
27
|
+
const SETTING_LABELS = {
|
|
28
|
+
default: "Default value",
|
|
29
|
+
"validation.minLength": "Fewest characters",
|
|
30
|
+
"validation.maxLength": "Most characters",
|
|
31
|
+
"validation.pattern": "Pattern it must match",
|
|
32
|
+
"format.long": "Written over several lines",
|
|
33
|
+
storage: "Stored as",
|
|
34
|
+
"validation.min": "Lowest value",
|
|
35
|
+
"validation.max": "Highest value",
|
|
36
|
+
"validation.integer": "Whole numbers only",
|
|
37
|
+
"validation.decimals": "Most decimals",
|
|
38
|
+
"format.style": "Shown as",
|
|
39
|
+
"format.decimals": "Decimals shown",
|
|
40
|
+
"format.suffix": "Unit after the number",
|
|
41
|
+
"format.signed": "Show + and −",
|
|
42
|
+
"format.signedTone": "A rise reads as",
|
|
43
|
+
"format.unit": "Stored in",
|
|
44
|
+
"format.durationStyle": "Duration style",
|
|
45
|
+
"format.display": "Shown as",
|
|
46
|
+
"code.fixed": "Currency",
|
|
47
|
+
of: "A range of",
|
|
48
|
+
period: "Per",
|
|
49
|
+
ahead: "A date to look forward to",
|
|
50
|
+
"format.dateStyle": "Date style",
|
|
51
|
+
"format.withTime": "Show the time",
|
|
52
|
+
options: "Options",
|
|
53
|
+
vocabulary: "Values allowed",
|
|
54
|
+
"validation.maxItems": "Most values",
|
|
55
|
+
normalize: "Tidy each value",
|
|
56
|
+
"relation.kind": "Links to",
|
|
57
|
+
cardinality: "How many",
|
|
58
|
+
multiple: "Holds several values",
|
|
59
|
+
parts: "Parts of the place",
|
|
60
|
+
};
|
|
61
|
+
const SETTING_LABEL_BY_TYPE = {
|
|
62
|
+
multiselect: { "validation.maxItems": "Most choices" },
|
|
63
|
+
name: { "validation.maxLength": "Most characters in each part" },
|
|
64
|
+
location: { "validation.maxLength": "Most characters in each part" },
|
|
65
|
+
};
|
|
66
|
+
const SETTING_WORDS = {
|
|
67
|
+
storage: { number: "Number", decimal: "Exact decimal" },
|
|
68
|
+
"format.style": {
|
|
69
|
+
plain: "Number",
|
|
70
|
+
duration: "Duration",
|
|
71
|
+
checkbox: "Checkbox",
|
|
72
|
+
icon: "Icon",
|
|
73
|
+
marker: "Marker",
|
|
74
|
+
text: "Words",
|
|
75
|
+
},
|
|
76
|
+
"format.signedTone": { "positive-good": "Up is good", neutral: "Neutral" },
|
|
77
|
+
"format.unit": { ms: "Milliseconds", s: "Seconds" },
|
|
78
|
+
"format.durationStyle": { adaptive: "Adaptive", clock: "Clock", units: "Units" },
|
|
79
|
+
"format.display": { text: "Number", bar: "Bar", ring: "Ring" },
|
|
80
|
+
of: { number: "Numbers", currency: "Amounts", percent: "Percents" },
|
|
81
|
+
period: { hour: "Hour", day: "Day", week: "Week", month: "Month", year: "Year" },
|
|
82
|
+
"format.dateStyle": { short: "Short", long: "Long", numeric: "Numbers only", relative: "Relative" },
|
|
83
|
+
vocabulary: { closed: "Only the listed options", "custom-values": "Any value typed in" },
|
|
84
|
+
normalize: { trim: "Trim spaces", lowercase: "Lowercase", hyphenate: "Spaces to hyphens" },
|
|
85
|
+
cardinality: { one: "One record", many: "Several records" },
|
|
86
|
+
parts: {
|
|
87
|
+
line1: "Address line 1",
|
|
88
|
+
line2: "Address line 2",
|
|
89
|
+
postalCode: "Postal code",
|
|
90
|
+
city: "City",
|
|
91
|
+
region: "Region",
|
|
92
|
+
regionCode: "Region code",
|
|
93
|
+
countryCode: "Country",
|
|
94
|
+
},
|
|
95
|
+
};
|
|
27
96
|
const ROLLUP_VERB = {
|
|
28
97
|
sum: "The sum of",
|
|
29
98
|
avg: "The average",
|
|
@@ -114,6 +183,12 @@ export const resolveFieldMessage = (message) => {
|
|
|
114
183
|
return message.values.provider;
|
|
115
184
|
case "type.label":
|
|
116
185
|
return TYPE_LABELS[message.values.type];
|
|
186
|
+
case "setting.label": {
|
|
187
|
+
const { type, path } = message.values;
|
|
188
|
+
return SETTING_LABEL_BY_TYPE[type]?.[path] ?? SETTING_LABELS[path] ?? path;
|
|
189
|
+
}
|
|
190
|
+
case "setting.word":
|
|
191
|
+
return SETTING_WORDS[message.values.path]?.[message.values.word] ?? message.values.word;
|
|
117
192
|
case "field.cannot-empty":
|
|
118
193
|
return "This field can't be emptied";
|
|
119
194
|
case "field.cannot-edit":
|
package/fields/dist/registry.js
CHANGED
|
@@ -8,7 +8,7 @@ import { NORMALIZE_STEPS } from "./normalize.js";
|
|
|
8
8
|
import { isDecimalText } from "./parse-number.js";
|
|
9
9
|
import { LOCATION_PARTS } from "./location.js";
|
|
10
10
|
import { isMultipleType } from "./value-list.js";
|
|
11
|
-
import { buildFieldSchema } from "./zod.js";
|
|
11
|
+
import { buildFieldSchema, readPattern } from "./zod.js";
|
|
12
12
|
export const FIELD_TYPES = [
|
|
13
13
|
"text",
|
|
14
14
|
"number",
|
|
@@ -463,12 +463,9 @@ export function checkFieldSpec(key, spec, all = {}, context = {}) {
|
|
|
463
463
|
if (f.emptiable && v?.minLength)
|
|
464
464
|
fail("an emptiable field cannot state a minLength above 0");
|
|
465
465
|
if (v?.pattern !== undefined) {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
catch {
|
|
470
|
-
fail("pattern is not a valid regular expression");
|
|
471
|
-
}
|
|
466
|
+
const read = readPattern(v.pattern);
|
|
467
|
+
if (!read.ok)
|
|
468
|
+
fail(`pattern ${read.why}`);
|
|
472
469
|
}
|
|
473
470
|
}
|
|
474
471
|
if (f.type === "location" && f.parts !== undefined) {
|
package/fields/dist/types.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ import type { ValueItem } from "./value-list.js";
|
|
|
12
12
|
* `datetime` is an instant. `percent` is stored 0–100 — the value IS the
|
|
13
13
|
* percent. `rollup` and `formula` carry a `result` that names what comes out. */
|
|
14
14
|
export type FieldType = "text" | "number" | "percent" | "currency" | "date" | "datetime" | "boolean" | "select" | "status" | "multiselect" | "relation" | "user" | "url" | "domain" | "email" | "phone" | "location" | "name" | "actor" | "rich_text" | "range" | "lookup" | "rollup" | "formula";
|
|
15
|
+
/** A type a person may create: every type but the one the system sets (actor) and those worked out from others. */
|
|
16
|
+
export type CreatableFieldType = Exclude<FieldType, "actor" | "lookup" | "rollup" | "formula">;
|
|
15
17
|
export type LocationValue = {
|
|
16
18
|
/** The street and number. */
|
|
17
19
|
line1?: string | null;
|
|
@@ -275,8 +277,8 @@ export type Breakdown = {
|
|
|
275
277
|
export type Freshness = "live" | "minute" | "sync";
|
|
276
278
|
/** The member shapes a rollup or formula may produce — declared once, used
|
|
277
279
|
* by the def union (with base keys) and by `result` (without them). */
|
|
278
|
-
/** What a text-like value may be held to. `pattern` is a regular expression
|
|
279
|
-
*
|
|
280
|
+
/** What a text-like value may be held to. `pattern` is a regular expression source in ViewKit's dialect, matched
|
|
281
|
+
* without backtracking; `checkFieldSpec` and `zodFor` refuse one outside it. */
|
|
280
282
|
export type TextualValidation = {
|
|
281
283
|
maxLength?: number;
|
|
282
284
|
pattern?: string;
|
package/fields/dist/zod.d.ts
CHANGED
|
@@ -26,4 +26,62 @@ export declare function linkRoleKey(kind: string, id: string, role: string): str
|
|
|
26
26
|
* is one once `https://` is put before it. What a kept url is held to (`accept.ts`). Text with a space or a control
|
|
27
27
|
* character inside is none: a split `java\tscript:` would hide its scheme here and lose it in the address parser. */
|
|
28
28
|
export declare function readsAsLink(value: unknown): boolean;
|
|
29
|
+
/** A pattern's source is at most this many characters. */
|
|
30
|
+
export declare const PATTERN_MAX_LENGTH = 500;
|
|
31
|
+
/** A pattern's program holds at most this many steps once its repeats are counted out (`a{3}` is three). */
|
|
32
|
+
export declare const PATTERN_MAX_STEPS = 1000;
|
|
33
|
+
/** What one value may cost against a pattern: its characters times the pattern's steps, at most this many, about a
|
|
34
|
+
* fifth of a second. A longer value is refused as too long before the pattern reads it (`BoundedPattern.maxValueLength`). */
|
|
35
|
+
export declare const PATTERN_MAX_WORK = 20000000;
|
|
36
|
+
/** A set of UTF-16 code units: sorted, merged, inclusive [low, high] pairs, read by binary search, so a class of any
|
|
37
|
+
* size costs one search per character. */
|
|
38
|
+
type Ranges = Int32Array;
|
|
39
|
+
type Assertion = "start" | "end" | "word" | "not-word";
|
|
40
|
+
declare const CHAR = 0;
|
|
41
|
+
declare const SPLIT = 1;
|
|
42
|
+
declare const JUMP = 2;
|
|
43
|
+
declare const ASSERT = 3;
|
|
44
|
+
declare const MATCH = 4;
|
|
45
|
+
type Step = {
|
|
46
|
+
op: typeof CHAR;
|
|
47
|
+
set: Ranges;
|
|
48
|
+
} | {
|
|
49
|
+
op: typeof SPLIT;
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
} | {
|
|
53
|
+
op: typeof JUMP;
|
|
54
|
+
x: number;
|
|
55
|
+
} | {
|
|
56
|
+
op: typeof ASSERT;
|
|
57
|
+
a: Assertion;
|
|
58
|
+
} | {
|
|
59
|
+
op: typeof MATCH;
|
|
60
|
+
};
|
|
61
|
+
type Program = readonly Step[];
|
|
62
|
+
/**
|
|
63
|
+
* A `RegExp` whose `test` runs ViewKit's matcher: what zod's `.regex()` calls, and the `source` a JSON Schema
|
|
64
|
+
* describes. Only `test` is bounded; `exec`, `match` and `replace` stay the engine's own, so nothing else should be
|
|
65
|
+
* handed one.
|
|
66
|
+
*/
|
|
67
|
+
export declare class BoundedPattern extends RegExp {
|
|
68
|
+
#private;
|
|
69
|
+
/** The longest value this pattern reads within `PATTERN_MAX_WORK`; `test` answers false past it, unread. */
|
|
70
|
+
readonly maxValueLength: number;
|
|
71
|
+
constructor(source: string, program: Program);
|
|
72
|
+
/** Built-ins that make a new expression from this one (`split`, `matchAll`) make a plain one. */
|
|
73
|
+
static get [Symbol.species](): RegExpConstructor;
|
|
74
|
+
test(value: string): boolean;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The pattern read in ViewKit's dialect, or why it is refused: words that follow "pattern ", the same wherever a
|
|
78
|
+
* pattern is checked (`checkFieldSpec`, `zodFor`).
|
|
79
|
+
*/
|
|
80
|
+
export declare function readPattern(source: string): {
|
|
81
|
+
ok: true;
|
|
82
|
+
pattern: BoundedPattern;
|
|
83
|
+
} | {
|
|
84
|
+
ok: false;
|
|
85
|
+
why: string;
|
|
86
|
+
};
|
|
29
87
|
export {};
|