viewkitjs 0.23.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/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 +1 -1
- 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 +6 -0
- package/views/dist/controls/index.js +6 -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/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/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/sheet/bottom-sheet.js +3 -0
- package/views/dist/controls/sheet.css +3 -0
- package/views/dist/controls/tokens.js +4 -0
- 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/useGridFittedWidths.d.ts +3 -0
- package/views/dist/grid/chrome/useGridFittedWidths.js +16 -3
- package/views/dist/grid/chrome/useGridKeyboard.js +3 -0
- package/views/dist/looks/index.d.ts +1 -0
- package/views/dist/looks/index.js +1 -0
- package/views/dist/looks/looks.d.ts +10 -9
- package/views/dist/looks/pieces.js +2 -0
- package/views/dist/styles.css +443 -11
- package/views/dist/styles.unlayered.css +443 -11
- package/views/docs/controls/list.md +40 -0
- package/views/docs/controls/menu-list.md +52 -0
- package/views/docs/getting-started.md +1 -1
- package/views/docs/reference/controls.md +40 -0
- package/views/docs/reference/looks.md +3 -1
|
@@ -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 {};
|