vultus-core 0.5.0 → 0.5.2
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/README.md +52 -13
- package/dist/field.d.ts +1 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/kinds.d.ts +11 -7
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +35 -20
- package/dist/kinds.js.map +1 -1
- package/dist/numeric.d.ts +7 -0
- package/dist/numeric.d.ts.map +1 -1
- package/dist/numeric.js +12 -0
- package/dist/numeric.js.map +1 -1
- package/dist/parseApiError.d.ts +6 -0
- package/dist/parseApiError.d.ts.map +1 -1
- package/dist/parseApiError.js +7 -1
- package/dist/parseApiError.js.map +1 -1
- package/dist/tree.d.ts +21 -9
- package/dist/tree.d.ts.map +1 -1
- package/dist/tree.js +64 -21
- package/dist/tree.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/{useTreeField.d.ts → useManyOfTreeField.d.ts} +10 -9
- package/dist/useManyOfTreeField.d.ts.map +1 -0
- package/dist/{useTreeField.js → useManyOfTreeField.js} +9 -8
- package/dist/useManyOfTreeField.js.map +1 -0
- package/dist/useNumericField.d.ts.map +1 -1
- package/dist/useNumericField.js +2 -5
- package/dist/useNumericField.js.map +1 -1
- package/dist/useRangeField.d.ts.map +1 -1
- package/dist/useRangeField.js +2 -5
- package/dist/useRangeField.js.map +1 -1
- package/package.json +3 -2
- package/src/field.ts +1 -1
- package/src/index.ts +8 -4
- package/src/kinds.ts +35 -24
- package/src/numeric.ts +12 -0
- package/src/parseApiError.ts +7 -1
- package/src/tree.ts +71 -20
- package/src/types.ts +2 -2
- package/src/{useTreeField.ts → useManyOfTreeField.ts} +14 -13
- package/src/useNumericField.ts +2 -5
- package/src/useRangeField.ts +2 -5
- package/dist/useTreeField.d.ts.map +0 -1
- package/dist/useTreeField.js.map +0 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ npm install vultus-core
|
|
|
23
23
|
`useAction`, `useActionList`; the field context (`FieldContextProvider`,
|
|
24
24
|
`createFieldContext`, `useFieldContext`, `NO_FIELD_CONTEXT`); every field
|
|
25
25
|
kind's hook (`useBoolField`, `useMixedBoolField`, `useOneOfField`,
|
|
26
|
-
`useManyOfField`, `useNumericField`, `useRangeField`, `
|
|
26
|
+
`useManyOfField`, `useNumericField`, `useRangeField`, `useManyOfTreeField`,
|
|
27
27
|
`useTextField`, `useFieldCore` and their types) and their shared helpers
|
|
28
28
|
(`resolveChoice`, `normalizeText`, `clamp`, `resolveNumeric`, the tree
|
|
29
29
|
helpers `normalizeTreeValue` / `coveredNodes` / `toggleTreeValue` /
|
|
@@ -46,7 +46,12 @@ An action's `fire(args, ctx)` receives an `ExecutionContext` next to its argumen
|
|
|
46
46
|
`ctx.info(text)`, `ctx.warn(text)` and `ctx.error(text)` report messages while it runs.
|
|
47
47
|
They land on the action's status as `messages` (with their `severity`) and go to the
|
|
48
48
|
`MessageSink` (`(text, severity?)`). A thrown error still fails the action and ends the
|
|
49
|
-
run's messages; `errors` lists the error texts among them.
|
|
49
|
+
run's messages; `errors` lists the error texts among them. What a thrown error shows
|
|
50
|
+
(`parseApiError`): an API error's body message (ts-rest's `{ status, body: { message, reason } }`);
|
|
51
|
+
without one, a thrown `Error`'s own message (`throw new Error('Printer offline')` shows "Printer
|
|
52
|
+
offline", a failed fetch its TypeError's); with neither, "Action failed" (a routed action
|
|
53
|
+
(`errorRoute`): the registry's entry for the body's `reason`, else the message, else
|
|
54
|
+
`t('common.error')`). A field's commit is an action, so the same holds for the field's messages.
|
|
50
55
|
|
|
51
56
|
## Fields
|
|
52
57
|
|
|
@@ -118,6 +123,12 @@ printers probe the object without tripping the guard (`then`, `toJSON`,
|
|
|
118
123
|
context value can be logged, pattern-matched or passed around during tests
|
|
119
124
|
without the guard misfiring.
|
|
120
125
|
|
|
126
|
+
Caution: the parameter-count rule above only decides what a function gets
|
|
127
|
+
with no provider. With a provider, a function whose declared parameter
|
|
128
|
+
count is zero — a default parameter (`(ctx = {}) => ...`), a rest parameter
|
|
129
|
+
(`(...args) => ...`), or a bound `t` — still receives the guarded context,
|
|
130
|
+
and reading a key it was not given still throws.
|
|
131
|
+
|
|
121
132
|
```tsx
|
|
122
133
|
const { Provider: ModuleContext } = createFieldContext<{ items: Item[] }>();
|
|
123
134
|
|
|
@@ -171,7 +182,8 @@ The value is a single number. `min`, `max`, `step`, `integer` (moxb's
|
|
|
171
182
|
`onlyInteger`) and `unit` may each be a context function; `format(n, ctx)`
|
|
172
183
|
overrides the default display (the number followed by the unit, if any).
|
|
173
184
|
The shown value is always clamped into the bounds, then rounded when
|
|
174
|
-
`integer` (a stored `2.5` shows `3
|
|
185
|
+
`integer` to a whole number inside them (a stored `2.5` shows `3`; with
|
|
186
|
+
`max: 9.5`, `9.7` shows `9`), since a value from outside — a
|
|
175
187
|
passed-in `value`, a stored one — may fall outside them or be fractional
|
|
176
188
|
even though every request the hook itself makes fits; a non-finite request
|
|
177
189
|
(a widget that parsed `''`) is refused with a warning. `valueText` carries
|
|
@@ -198,7 +210,7 @@ const field = useRangeField({ id: 'years', min: 2010, max: 2026 });
|
|
|
198
210
|
field.valueText; // '2010–2026'
|
|
199
211
|
```
|
|
200
212
|
|
|
201
|
-
### tree (`
|
|
213
|
+
### many-of tree (`useManyOfTreeField`)
|
|
202
214
|
|
|
203
215
|
The value is a list of node ids (`nodes`: `TreeNode`, a choice with
|
|
204
216
|
`children`), kept as a set. `selection` says which of the covered nodes the
|
|
@@ -212,8 +224,33 @@ nodes a widget opens at first, controlled by `expand`: `'top'` (default),
|
|
|
212
224
|
`'none'`, `'selected'`, `'all'`) and `toggle(value)` (refused, with a
|
|
213
225
|
warning, for an unknown or disabled node, as many-of's does).
|
|
214
226
|
`coveredNodes(nodes, value, selection)` expands a value to every node it
|
|
215
|
-
stands for — what a module matches an item's categories against.
|
|
216
|
-
|
|
227
|
+
stands for — what a module matches an item's categories against.
|
|
228
|
+
|
|
229
|
+
Disabled nodes follow antd's check conduction, so the hook and the antd
|
|
230
|
+
widgets agree: a disabled node is never covered through a checked ancestor
|
|
231
|
+
(nor is its subtree, through it), and a parent counts as checked once all
|
|
232
|
+
its *enabled* children are; a parent whose children are all disabled, or a
|
|
233
|
+
disabled parent, is never checked through its children. With nodes
|
|
234
|
+
Geometria (Síkgeometria, Térgeometria — disabled), checking Síkgeometria
|
|
235
|
+
gives `['geometria']` under `'topmost'` and `['geometria', 'sikgeometria']`
|
|
236
|
+
under `'all'`, and `coveredNodes` does not include Térgeometria. A disabled
|
|
237
|
+
node in the value (`setValue` and a stored value do not police them) stays
|
|
238
|
+
there and covers itself only. Where a disabled node breaks the cascade, the
|
|
239
|
+
value names what the other named nodes would not cover: under `'topmost'`
|
|
240
|
+
a checked disabled node beside its checked parent (`['geometria',
|
|
241
|
+
'tergeometria']`), and checked children beside their checked disabled parent,
|
|
242
|
+
as antd TreeSelect's `SHOW_PARENT` does; under `'leaves'` a checked node with
|
|
243
|
+
children that is disabled or has only disabled children — where antd's
|
|
244
|
+
`SHOW_CHILD` would drop it (and with it what it covers), so vultus-antd's
|
|
245
|
+
`ManyOfTreePicker` requests the field's value with the clicked node toggled rather
|
|
246
|
+
than antd's list. So normalizing never changes what a value covers. The same rule sanitizes a stored value. The
|
|
247
|
+
cost: a parent in the value stands for its subtree as it is when read, so
|
|
248
|
+
under `'topmost'` (and `'all'`, which lists the parent too) a child that was
|
|
249
|
+
disabled when the value was stored and is enabled later is covered from
|
|
250
|
+
then on — a stored `['geometria']` then covers Térgeometria too; `'leaves'`
|
|
251
|
+
names only the leaves and does not widen.
|
|
252
|
+
|
|
253
|
+
Search over labels is accent- and case-insensitive (`normalizeText`); the matching
|
|
217
254
|
`filterTree(nodes, query)` follows antd TreeSelect's rule: a node whose own
|
|
218
255
|
label matches stays with its whole subtree, any other node stays if one of
|
|
219
256
|
its descendants matches (with only the children that stay), and the rest
|
|
@@ -221,7 +258,7 @@ is trimmed, leaving the nodes given unchanged. Implicit initial value: the
|
|
|
221
258
|
empty list.
|
|
222
259
|
|
|
223
260
|
```ts
|
|
224
|
-
const field =
|
|
261
|
+
const field = useManyOfTreeField({
|
|
225
262
|
id: 'categories',
|
|
226
263
|
nodes: [{ value: 'a', children: [{ value: 'a1' }, { value: 'a2' }] }],
|
|
227
264
|
});
|
|
@@ -248,7 +285,7 @@ const field = useTextField({ id: 'search', control: 'input' });
|
|
|
248
285
|
A `FieldDefinition` is a field's options in their "inside" form (no `value`
|
|
249
286
|
plus `onChange` or `commit`), tagged with a required `kind` — one of
|
|
250
287
|
`'boolean'`, `'mixed-boolean'`, `'oneOf'`, `'manyOf'`, `'numeric'`,
|
|
251
|
-
`'range'`, `'
|
|
288
|
+
`'range'`, `'manyOfTree'`, `'text'` (the same strings `FieldControls.type` already
|
|
252
289
|
carries). `kind` stays optional on each hook's own options — a hook knows
|
|
253
290
|
its own kind, and throws if a definition names a different one — but is
|
|
254
291
|
required once a field becomes plain data: a module declares its filters as a
|
|
@@ -297,7 +334,7 @@ type's own meaning (a list as a set, a range by both ends), used everywhere
|
|
|
297
334
|
two values of that type are compared — including whether a value is the
|
|
298
335
|
default, so it's left out of the store. `valueTypeOf(kind)` gives each field
|
|
299
336
|
kind's: `booleanType` (`'1'` / `'0'`), `stringType` (one-of, text),
|
|
300
|
-
`stringSetType` (many-of, tree — a sorted comma list; a *present but empty*
|
|
337
|
+
`stringSetType` (many-of, many-of tree — a sorted comma list; a *present but empty*
|
|
301
338
|
value reads as the empty list, which differs from the key being absent
|
|
302
339
|
altogether), `numberType`, `rangeType` (`from..to`). A mixed-boolean field
|
|
303
340
|
shows an aggregate of other data and has no value type:
|
|
@@ -315,7 +352,8 @@ the default (or is dropped from a list), with a `console.warn`.
|
|
|
315
352
|
namespaced as `${prefix}.${key}`, guarded for SSR so creating one outside a
|
|
316
353
|
browser is a safe no-op; where the browser blocks storage or refuses a
|
|
317
354
|
write, a failing read reads as absent and a failing write is skipped, with
|
|
318
|
-
one `console.warn` per store); a URL store comes from a router package
|
|
355
|
+
one `console.warn` per store); a URL store comes from a router package —
|
|
356
|
+
vultus-react-router for react-router.
|
|
319
357
|
Create a store once — outside render, or in `useMemo` — not on every
|
|
320
358
|
render: each store is a new subscription target, so a fresh one per render
|
|
321
359
|
makes every hook below resubscribe.
|
|
@@ -344,9 +382,10 @@ is `initialValueOf`. It returns `{ options, isDefault, reset }` — `options`
|
|
|
344
382
|
is the definition in its outside form (`value` plus `onChange`, ready for
|
|
345
383
|
the kind's hook), with the stored raw value made to fit the definition as
|
|
346
384
|
it is now (`sanitizeStored`: unknown choices or nodes dropped, numbers and
|
|
347
|
-
ranges clamped). A value that needed fixing up
|
|
348
|
-
value — not again on every render, and not
|
|
349
|
-
absent (then the default applies, and an
|
|
385
|
+
ranges clamped, and rounded when `integer`). A value that needed fixing up
|
|
386
|
+
warns once per field and per raw value — not again on every render, and not
|
|
387
|
+
at all when the key is simply absent (then the default applies, and an
|
|
388
|
+
absent key is not outside input).
|
|
350
389
|
`useStoredFields(definitions)` answers for several definitions over one
|
|
351
390
|
store subscription: `isDefault(id)` (throws for an id not among the
|
|
352
391
|
definitions), `changedCount`, and `resetAll(method)` (one write for every
|
package/dist/field.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { ConfirmationSpec, Decision, ErrorRoutesRegistry, ExecutionContext,
|
|
|
9
9
|
* Design notes: unitas docs/2026-10-05-vultus-field-model-design.md.
|
|
10
10
|
*/
|
|
11
11
|
/** The field kinds (FieldControls.type and a FieldDefinition's `kind`). */
|
|
12
|
-
export type FieldKind = 'boolean' | 'mixed-boolean' | 'oneOf' | 'manyOf' | 'numeric' | 'range' | '
|
|
12
|
+
export type FieldKind = 'boolean' | 'mixed-boolean' | 'oneOf' | 'manyOf' | 'numeric' | 'range' | 'manyOfTree' | 'text';
|
|
13
13
|
/** The widget to render a field with: a name, or a name with display options overriding its defaults. */
|
|
14
14
|
export type WidgetHint = string | {
|
|
15
15
|
name: string;
|
package/dist/field.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../src/field.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gBAAgB,EAChB,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,OAAO,EACP,SAAS,EACV,MAAM,YAAY,CAAC;AAEpB;;;;;;;;GAQG;AAEH,2EAA2E;AAC3E,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,eAAe,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../src/field.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gBAAgB,EAChB,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,OAAO,EACP,SAAS,EACV,MAAM,YAAY,CAAC;AAEpB;;;;;;;;GAQG;AAEH,2EAA2E;AAC3E,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,eAAe,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,YAAY,GAAG,MAAM,CAAC;AAEvH,yGAAyG;AACzG,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE9E,wGAAwG;AACxG,MAAM,WAAW,WAAW,CAAC,QAAQ,EAAE,OAAO,SAAS,MAAM,GAAG,MAAM;IACpE,IAAI,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACtE,wGAAwG;IACxG,YAAY,CAAC,EAAE,gBAAgB,GAAG,CAAC,CAAC,IAAI,E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Aa,CAAC,MAAM,EAAE,QAAQ,CAAC,CA6EjC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type { FormLike, Decision, ValueOrFn, Thunk, Severity, Message, ExecutionContext, ConfirmationSpec, ActionOptions, ActionStatus, ParsedApiError, RegistryEntry, ErrorRoutesRegistry, ApiErrorContext, ActionErrorCtx, } from './types.js';
|
|
2
2
|
export * from './decision.js';
|
|
3
3
|
export * from './resolve.js';
|
|
4
4
|
export * from './parseApiError.js';
|
|
@@ -18,7 +18,7 @@ export { clamp, resolveNumeric, type NumericBounds, type ResolvedNumeric } from
|
|
|
18
18
|
export { useNumericField, numericInitialValue, type NumericFieldControls, type NumericFieldOptions, type NumericOwnOptions, } from './useNumericField.js';
|
|
19
19
|
export { useRangeField, rangeInitialValue, type NumberRange, type RangeFieldControls, type RangeFieldOptions, type RangeOwnOptions, } from './useRangeField.js';
|
|
20
20
|
export { normalizeTreeValue, coveredNodes, toggleTreeValue, expandedTreeKeys, filterTree, type TreeNode, type TreeNodeControls, type TreeSelection, type TreeExpand, } from './tree.js';
|
|
21
|
-
export {
|
|
21
|
+
export { useManyOfTreeField, manyOfTreeInitialValue, type ManyOfTreeFieldControls, type ManyOfTreeFieldOptions, type ManyOfTreeOwnOptions, } from './useManyOfTreeField.js';
|
|
22
22
|
export { useTextField, textInitialValue, type TextFieldControls, type TextFieldOptions, type TextOwnOptions, } from './useTextField.js';
|
|
23
23
|
export { booleanType, stringType, stringSetType, numberType, rangeType, type ValueType, } from './valueTypes.js';
|
|
24
24
|
export { initialValueOf, valueTypeOf, sanitizeStored, type FieldDefinition } from './kinds.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":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c,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EACL,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EACtC,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,GACrD,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,GAC5E,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACpG,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,EACL,uBAAuB,EAAE,mBAAmB,EAAE,YAAY,EAAE,aAAa,EACzE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,GAChE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export * from './types.js';
|
|
2
1
|
export * from './decision.js';
|
|
3
2
|
export * from './resolve.js';
|
|
4
3
|
export * from './parseApiError.js';
|
|
@@ -18,7 +17,7 @@ export { clamp, resolveNumeric } from './numeric.js';
|
|
|
18
17
|
export { useNumericField, numericInitialValue, } from './useNumericField.js';
|
|
19
18
|
export { useRangeField, rangeInitialValue, } from './useRangeField.js';
|
|
20
19
|
export { normalizeTreeValue, coveredNodes, toggleTreeValue, expandedTreeKeys, filterTree, } from './tree.js';
|
|
21
|
-
export {
|
|
20
|
+
export { useManyOfTreeField, manyOfTreeInitialValue, } from './useManyOfTreeField.js';
|
|
22
21
|
export { useTextField, textInitialValue, } from './useTextField.js';
|
|
23
22
|
export { booleanType, stringType, stringSetType, numberType, rangeType, } from './valueTypes.js';
|
|
24
23
|
export { initialValueOf, valueTypeOf, sanitizeStored } from './kinds.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,oBAAoB,EAAE,kBAAkB,EAAE,eAAe,EAAE,gBAAgB,GAC5E,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,GAGnE,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAA8C,MAAM,cAAc,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAiD,MAAM,mBAAmB,CAAC;AAClH,OAAO,EACL,iBAAiB,EAAE,aAAa,EAAE,qBAAqB,GAExD,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,aAAa,EAAE,iBAAiB,GACjC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,cAAc,EAAE,kBAAkB,GAEnC,MAAM,qBA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} from './useNumericField.js';
|
|
|
7
7
|
import { type OneOfOwnOptions } from './useOneOfField.js';
|
|
8
8
|
import { type NumberRange, type RangeOwnOptions } from './useRangeField.js';
|
|
9
9
|
import { type TextOwnOptions } from './useTextField.js';
|
|
10
|
-
import { type
|
|
10
|
+
import { type ManyOfTreeOwnOptions } from './useManyOfTreeField.js';
|
|
11
11
|
import { type ValueType } from './valueTypes.js';
|
|
12
12
|
/**
|
|
13
13
|
* A definition of kind `K`: the kind's hook options in their inside form, with `kind` required.
|
|
@@ -24,7 +24,7 @@ type Definition<K extends FieldKind, V, Own, Ctx> = {
|
|
|
24
24
|
* by `kind`, a definition is its kind's hook options as they are: `useOneOfField(definition)`.
|
|
25
25
|
* Its functions receive the field context `Ctx` (see FieldContextProvider).
|
|
26
26
|
*/
|
|
27
|
-
export type FieldDefinition<Ctx = any> = Definition<'boolean', boolean, {}, Ctx> | Definition<'mixed-boolean', MixedBool, {}, Ctx> | Definition<'oneOf', string, OneOfOwnOptions<string, Ctx>, Ctx> | Definition<'manyOf', string[], ManyOfOwnOptions<string, Ctx>, Ctx> | Definition<'numeric', number, NumericOwnOptions<Ctx>, Ctx> | Definition<'range', NumberRange, RangeOwnOptions<Ctx>, Ctx> | Definition<'
|
|
27
|
+
export type FieldDefinition<Ctx = any> = Definition<'boolean', boolean, {}, Ctx> | Definition<'mixed-boolean', MixedBool, {}, Ctx> | Definition<'oneOf', string, OneOfOwnOptions<string, Ctx>, Ctx> | Definition<'manyOf', string[], ManyOfOwnOptions<string, Ctx>, Ctx> | Definition<'numeric', number, NumericOwnOptions<Ctx>, Ctx> | Definition<'range', NumberRange, RangeOwnOptions<Ctx>, Ctx> | Definition<'manyOfTree', string[], ManyOfTreeOwnOptions<string, Ctx>, Ctx> | Definition<'text', string, TextOwnOptions, Ctx>;
|
|
28
28
|
/**
|
|
29
29
|
* A definition's default: `initialValue` resolved with the field context, else its kind's
|
|
30
30
|
* implicit initial value (false; the first enabled choice; the empty list; `min`, or 0, clamped
|
|
@@ -40,11 +40,15 @@ export declare function valueTypeOf(kind: FieldKind): ValueType<any>;
|
|
|
40
40
|
* A stored value (already parsed by the kind's value type) made fit for the definition as it is
|
|
41
41
|
* now: choices, nodes and bounds follow the data, and an old URL may not. A one-of value that is
|
|
42
42
|
* not a choice becomes the initial value; many-of and tree values that are not choices or nodes
|
|
43
|
-
* are dropped; numbers and ranges are clamped into the bounds
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
43
|
+
* are dropped; numbers and ranges are clamped into the bounds, then rounded when the field is
|
|
44
|
+
* `integer` (so a stored `2.5` reads `3`; a whole number inside the bounds, see `fit`), with one
|
|
45
|
+
* warning for whichever of the two actually changed the value: "outside its bounds" when
|
|
46
|
+
* clamping did (whether or not rounding also did), "not a whole number" ("has ends that are not
|
|
47
|
+
* whole numbers" for a range) when only rounding did. Each such change warns, naming the
|
|
48
|
+
* field: the value came from outside, so it is not an error. Reordering is silent: lists come
|
|
49
|
+
* back in choice order or normalized under the tree's selection (a store keeps them sorted, so a
|
|
50
|
+
* warning would come on every read), and a range's ends in order. The warnings go to `warn`,
|
|
51
|
+
* console.warn unless a caller that only summarizes (useStoredFields) silences them.
|
|
48
52
|
*/
|
|
49
53
|
export declare function sanitizeStored(definition: FieldDefinition, value: unknown, ctx: FieldCtx, warn?: (message: string) => void): unknown;
|
|
50
54
|
export {};
|
package/dist/kinds.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../src/kinds.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAIlD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../src/kinds.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,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C,GAC9D,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,GAClE,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAC1D,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAC3D,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,GAC1E,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC;AAgDpD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,eAAe,EAAE,GAAG,EAAE,QAAQ,GAAG,OAAO,CAclF;AAED,gIAAgI;AAChI,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,CAY3D;AAQD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,eAAe,EAC3B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,QAAQ,EACb,IAAI,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAyC,GACnE,OAAO,CAyDT"}
|
package/dist/kinds.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveChoice } from './choices.js';
|
|
2
|
-
import { clamp, resolveNumeric } from './numeric.js';
|
|
2
|
+
import { clamp, fit, resolveNumeric } from './numeric.js';
|
|
3
3
|
import { resolveIn } from './resolve.js';
|
|
4
4
|
import { normalizeTreeValue } from './tree.js';
|
|
5
5
|
import { boolInitialValue } from './useBoolField.js';
|
|
@@ -9,7 +9,7 @@ import { numericInitialValue } from './useNumericField.js';
|
|
|
9
9
|
import { oneOfInitialValue } from './useOneOfField.js';
|
|
10
10
|
import { rangeInitialValue } from './useRangeField.js';
|
|
11
11
|
import { textInitialValue } from './useTextField.js';
|
|
12
|
-
import {
|
|
12
|
+
import { manyOfTreeInitialValue } from './useManyOfTreeField.js';
|
|
13
13
|
import { booleanType, numberType, rangeType, stringSetType, stringType } from './valueTypes.js';
|
|
14
14
|
const NOT_STORABLE = 'a mixed-boolean field is an aggregate of other data and cannot be stored';
|
|
15
15
|
/** A definition whose kind is none of FieldKind's (plain data can carry anything): fail loudly rather than give nothing. */
|
|
@@ -31,7 +31,7 @@ function nodeValues(nodes, into = new Set()) {
|
|
|
31
31
|
}
|
|
32
32
|
return into;
|
|
33
33
|
}
|
|
34
|
-
/** A tree definition's nodes, resolved as
|
|
34
|
+
/** A tree definition's nodes, resolved as useManyOfTreeField resolves them. */
|
|
35
35
|
function nodesOf(definition, ctx) {
|
|
36
36
|
return resolveIn(definition.nodes, [], ctx, `Field '${definition.id}': option 'nodes'`);
|
|
37
37
|
}
|
|
@@ -52,8 +52,8 @@ export function initialValueOf(definition, ctx) {
|
|
|
52
52
|
case 'manyOf': return manyOfInitialValue(definition, ctx, id);
|
|
53
53
|
case 'numeric': return numericInitialValue(definition, ctx, id);
|
|
54
54
|
case 'range': return rangeInitialValue(definition, ctx, id);
|
|
55
|
-
case '
|
|
56
|
-
return normalizeTreeValue(nodesOf(definition, ctx),
|
|
55
|
+
case 'manyOfTree':
|
|
56
|
+
return normalizeTreeValue(nodesOf(definition, ctx), manyOfTreeInitialValue(definition, ctx, id), definition.selection ?? 'topmost');
|
|
57
57
|
case 'text': return textInitialValue(definition, ctx, id);
|
|
58
58
|
default: return unknownKind(definition);
|
|
59
59
|
}
|
|
@@ -65,7 +65,7 @@ export function valueTypeOf(kind) {
|
|
|
65
65
|
case 'oneOf':
|
|
66
66
|
case 'text': return stringType;
|
|
67
67
|
case 'manyOf':
|
|
68
|
-
case '
|
|
68
|
+
case 'manyOfTree': return stringSetType;
|
|
69
69
|
case 'numeric': return numberType;
|
|
70
70
|
case 'range': return rangeType;
|
|
71
71
|
case 'mixed-boolean': throw new Error(NOT_STORABLE);
|
|
@@ -82,11 +82,15 @@ function warnDropped(id, among, dropped, warn) {
|
|
|
82
82
|
* A stored value (already parsed by the kind's value type) made fit for the definition as it is
|
|
83
83
|
* now: choices, nodes and bounds follow the data, and an old URL may not. A one-of value that is
|
|
84
84
|
* not a choice becomes the initial value; many-of and tree values that are not choices or nodes
|
|
85
|
-
* are dropped; numbers and ranges are clamped into the bounds
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
85
|
+
* are dropped; numbers and ranges are clamped into the bounds, then rounded when the field is
|
|
86
|
+
* `integer` (so a stored `2.5` reads `3`; a whole number inside the bounds, see `fit`), with one
|
|
87
|
+
* warning for whichever of the two actually changed the value: "outside its bounds" when
|
|
88
|
+
* clamping did (whether or not rounding also did), "not a whole number" ("has ends that are not
|
|
89
|
+
* whole numbers" for a range) when only rounding did. Each such change warns, naming the
|
|
90
|
+
* field: the value came from outside, so it is not an error. Reordering is silent: lists come
|
|
91
|
+
* back in choice order or normalized under the tree's selection (a store keeps them sorted, so a
|
|
92
|
+
* warning would come on every read), and a range's ends in order. The warnings go to `warn`,
|
|
93
|
+
* console.warn unless a caller that only summarizes (useStoredFields) silences them.
|
|
90
94
|
*/
|
|
91
95
|
export function sanitizeStored(definition, value, ctx, warn = (message) => console.warn(message)) {
|
|
92
96
|
const { id } = definition;
|
|
@@ -111,7 +115,7 @@ export function sanitizeStored(definition, value, ctx, warn = (message) => conso
|
|
|
111
115
|
warnDropped(id, 'choices', stored.filter((v) => !known.includes(v)), warn);
|
|
112
116
|
return known.filter((v) => stored.includes(v));
|
|
113
117
|
}
|
|
114
|
-
case '
|
|
118
|
+
case 'manyOfTree': {
|
|
115
119
|
const stored = value;
|
|
116
120
|
const nodes = nodesOf(definition, ctx);
|
|
117
121
|
const known = nodeValues(nodes);
|
|
@@ -120,20 +124,31 @@ export function sanitizeStored(definition, value, ctx, warn = (message) => conso
|
|
|
120
124
|
}
|
|
121
125
|
case 'numeric': {
|
|
122
126
|
const stored = value;
|
|
123
|
-
const { min, max } = resolveNumeric(id, definition, ctx);
|
|
127
|
+
const { min, max, integer } = resolveNumeric(id, definition, ctx);
|
|
124
128
|
const clamped = clamp(stored, min, max);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
129
|
+
const fitted = fit(stored, min, max, integer);
|
|
130
|
+
if (fitted !== stored) {
|
|
131
|
+
if (clamped !== stored)
|
|
132
|
+
warn(`Field '${id}': stored value ${stored} is outside its bounds, using ${fitted}`);
|
|
133
|
+
else
|
|
134
|
+
warn(`Field '${id}': stored value ${stored} is not a whole number, using ${fitted}`);
|
|
135
|
+
}
|
|
136
|
+
return fitted;
|
|
128
137
|
}
|
|
129
138
|
case 'range': {
|
|
130
139
|
const stored = value;
|
|
131
|
-
const { min, max } = resolveNumeric(id, definition, ctx);
|
|
132
|
-
const
|
|
133
|
-
const
|
|
140
|
+
const { min, max, integer } = resolveNumeric(id, definition, ctx);
|
|
141
|
+
const clampedChanged = clamp(stored[0], min, max) !== stored[0] || clamp(stored[1], min, max) !== stored[1];
|
|
142
|
+
const from = fit(stored[0], min, max, integer);
|
|
143
|
+
const to = fit(stored[1], min, max, integer);
|
|
134
144
|
const sanitized = [Math.min(from, to), Math.max(from, to)];
|
|
135
145
|
if (from !== stored[0] || to !== stored[1]) {
|
|
136
|
-
|
|
146
|
+
if (clampedChanged) {
|
|
147
|
+
warn(`Field '${id}': stored range ${rangeType.format(stored)} is outside its bounds, using ${rangeType.format(sanitized)}`);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
warn(`Field '${id}': stored range ${rangeType.format(stored)} has ends that are not whole numbers, using ${rangeType.format(sanitized)}`);
|
|
151
|
+
}
|
|
137
152
|
}
|
|
138
153
|
return sanitized;
|
|
139
154
|
}
|
package/dist/kinds.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kinds.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AAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;YACxE,IAAI,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3C,IAAI,cAAc,EAAE,CAAC;oBACnB,IAAI,CAAC,UAAU,EAAE,mBAAmB,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,iCAAiC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;gBAC9H,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,UAAU,EAAE,mBAAmB,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,+CAA+C,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;gBAC5I,CAAC;YACH,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,CAAC,CAAC,OAAO,WAAW,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC"}
|
package/dist/numeric.d.ts
CHANGED
|
@@ -26,6 +26,13 @@ export interface ResolvedNumeric {
|
|
|
26
26
|
}
|
|
27
27
|
/** Clamps `n` into [min, max]; either end left out leaves that side open. */
|
|
28
28
|
export declare function clamp(n: number, min?: number, max?: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* `n` clamped into [min, max], then, when `integer` is true, rounded and kept to the whole numbers
|
|
31
|
+
* inside the bounds ([ceil(min), floor(max)]: with `max: 9.5`, 9.7 is 9, not 10): the rule a
|
|
32
|
+
* numeric or range field's shown value and requests are fit by (useNumericField, useRangeField),
|
|
33
|
+
* and the one `sanitizeStored` fits a stored value by.
|
|
34
|
+
*/
|
|
35
|
+
export declare function fit(n: number, min: number | undefined, max: number | undefined, integer: boolean): number;
|
|
29
36
|
/**
|
|
30
37
|
* Resolves a numeric field's bounds and formatter with the field context. `format` goes by its
|
|
31
38
|
* own rule, not resolveIn's, as it always receives the number first; otherwise it is treated
|
package/dist/numeric.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numeric.d.ts","sourceRoot":"","sources":["../src/numeric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,aAAa,CAAC,GAAG,GAAG,GAAG;IACtC,GAAG,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,EAAE,GAAG,CAAC,CAAC;IACzC,GAAG,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,EAAE,GAAG,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,EAAE,GAAG,CAAC,CAAC;IAC1C,OAAO,CAAC,EAAE,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,EAAE,GAAG,CAAC,CAAC;IAC1C,qFAAqF;IACrF,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC;CAC1C;AAED,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B;AAED,6EAA6E;AAC7E,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CA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M,CAAC;CAC3B;AAED,6EAA6E;AAC7E,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAKnE;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAIzG;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,QAAQ,GAAG,eAAe,CAqB9F"}
|
package/dist/numeric.js
CHANGED
|
@@ -9,6 +9,18 @@ export function clamp(n, min, max) {
|
|
|
9
9
|
result = Math.min(result, max);
|
|
10
10
|
return result;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* `n` clamped into [min, max], then, when `integer` is true, rounded and kept to the whole numbers
|
|
14
|
+
* inside the bounds ([ceil(min), floor(max)]: with `max: 9.5`, 9.7 is 9, not 10): the rule a
|
|
15
|
+
* numeric or range field's shown value and requests are fit by (useNumericField, useRangeField),
|
|
16
|
+
* and the one `sanitizeStored` fits a stored value by.
|
|
17
|
+
*/
|
|
18
|
+
export function fit(n, min, max, integer) {
|
|
19
|
+
const clamped = clamp(n, min, max);
|
|
20
|
+
if (!integer)
|
|
21
|
+
return clamped;
|
|
22
|
+
return clamp(Math.round(clamped), min === undefined ? undefined : Math.ceil(min), max === undefined ? undefined : Math.floor(max));
|
|
23
|
+
}
|
|
12
24
|
/**
|
|
13
25
|
* Resolves a numeric field's bounds and formatter with the field context. `format` goes by its
|
|
14
26
|
* own rule, not resolveIn's, as it always receives the number first; otherwise it is treated
|
package/dist/numeric.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numeric.js","sourceRoot":"","sources":["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O,GAAG,SAAS,CAAU,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/E,MAAM,IAAI,GAAG,SAAS,CAAqB,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAErF,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB,IAAI,cAAqC,CAAC;IAC1C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,cAAc,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC;IAC9C,CAAC;SAAM,IAAI,GAAG,KAAK,gBAAgB,EAAE,CAAC;QACpC,cAAc,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,GAAY,CAAC,CAAC,CAAC;IACzF,CAAC;SAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,cAAc,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,SAAkB,CAAC,CAAC;IACxD,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,8EAA8E,CAAC,CAAC;IACpH,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;AACnE,CAAC"}
|
package/dist/parseApiError.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { ParsedApiError } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* What a thrown error says, for an action's or a field commit's error message: an API error's
|
|
4
|
+
* status, reason and message (ts-rest's reject shape, `{ status, body: { message, reason } }`);
|
|
5
|
+
* without a body message, a thrown `Error`'s own message (`new Error('Printer offline')`, a
|
|
6
|
+
* failed fetch's TypeError), unless empty. `status` is 0 when the error carries none.
|
|
7
|
+
*/
|
|
2
8
|
export declare function parseApiError(err: unknown): ParsedApiError;
|
|
3
9
|
//# sourceMappingURL=parseApiError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseApiError.d.ts","sourceRoot":"","sources":["../src/parseApiError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,CAQ1D"}
|
|
1
|
+
{"version":3,"file":"parseApiError.d.ts","sourceRoot":"","sources":["../src/parseApiError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,CAQ1D"}
|
package/dist/parseApiError.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a thrown error says, for an action's or a field commit's error message: an API error's
|
|
3
|
+
* status, reason and message (ts-rest's reject shape, `{ status, body: { message, reason } }`);
|
|
4
|
+
* without a body message, a thrown `Error`'s own message (`new Error('Printer offline')`, a
|
|
5
|
+
* failed fetch's TypeError), unless empty. `status` is 0 when the error carries none.
|
|
6
|
+
*/
|
|
1
7
|
export function parseApiError(err) {
|
|
2
8
|
if (typeof err !== 'object' || err === null)
|
|
3
9
|
return { status: 0 };
|
|
@@ -5,7 +11,7 @@ export function parseApiError(err) {
|
|
|
5
11
|
return {
|
|
6
12
|
status: e.status ?? 0,
|
|
7
13
|
reason: e.body?.reason,
|
|
8
|
-
message: e.body?.message,
|
|
14
|
+
message: e.body?.message ?? ((err instanceof Error && err.message) || undefined),
|
|
9
15
|
};
|
|
10
16
|
}
|
|
11
17
|
//# sourceMappingURL=parseApiError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseApiError.js","sourceRoot":"","sources":["../src/parseApiError.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAClE,MAAM,CAAC,GAAG,GAAwE,CAAC;IACnF,OAAO;QACL,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC;QACrB,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM;QACtB,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO;
|
|
1
|
+
{"version":3,"file":"parseApiError.js","sourceRoot":"","sources":["../src/parseApiError.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAClE,MAAM,CAAC,GAAG,GAAwE,CAAC;IACnF,OAAO;QACL,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC;QACrB,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM;QACtB,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC;KACjF,CAAC;AACJ,CAAC"}
|
package/dist/tree.d.ts
CHANGED
|
@@ -12,12 +12,20 @@ export interface TreeNodeControls<T extends string = string> extends OneOfChoice
|
|
|
12
12
|
/**
|
|
13
13
|
* What a tree field's value lists, as antd TreeSelect's `showCheckedStrategy` and
|
|
14
14
|
* `checkStrictly` do. In the three cascading selections a node stands for its subtree, and
|
|
15
|
-
* a node all of whose children are covered is covered too
|
|
16
|
-
* covered nodes the
|
|
15
|
+
* a node all of whose children are covered is covered too — disabled nodes aside, as antd
|
|
16
|
+
* conducts its checks (see `cascade`); they differ only in which of the covered nodes the
|
|
17
|
+
* value names:
|
|
17
18
|
* - `'topmost'` (`SHOW_PARENT`, the default): the covered nodes whose parent is not covered;
|
|
18
19
|
* - `'all'` (`SHOW_ALL`): every covered node;
|
|
19
20
|
* - `'leaves'` (`SHOW_CHILD`): the covered leaves.
|
|
20
21
|
*
|
|
22
|
+
* Where a disabled node breaks the cascade, the value also names what the others would not
|
|
23
|
+
* cover: `'topmost'` a covered disabled node under a covered parent, and a covered node under
|
|
24
|
+
* a covered disabled parent (as antd TreeSelect's SHOW_PARENT does); `'leaves'` a covered node
|
|
25
|
+
* with children that is disabled or has no enabled child (stricter than antd's SHOW_CHILD,
|
|
26
|
+
* which drops a checked disabled parent whose enabled children are all checked, and a parent
|
|
27
|
+
* whose only children are disabled and checked — so the value would no longer cover them).
|
|
28
|
+
*
|
|
21
29
|
* `'independent'` (`checkStrictly`, moxb's `strictSelect`): each node is chosen on its own.
|
|
22
30
|
*/
|
|
23
31
|
export type TreeSelection = 'topmost' | 'all' | 'leaves' | 'independent';
|
|
@@ -37,16 +45,20 @@ export declare function normalizeTreeValue<T extends string>(nodes: TreeNode<T>[
|
|
|
37
45
|
/**
|
|
38
46
|
* Every node a tree field's value stands for, in pre-order (what an item filed under some
|
|
39
47
|
* node matches against): in the cascading selections the covered nodes (the value's nodes,
|
|
40
|
-
* their descendants, and every node all of whose children are
|
|
41
|
-
* `'independent'` the value's nodes themselves. Values that
|
|
42
|
-
* normalizeTreeValue.
|
|
48
|
+
* their enabled descendants, and every enabled node all of whose enabled children are
|
|
49
|
+
* covered; see `cascade`); with `'independent'` the value's nodes themselves. Values that
|
|
50
|
+
* name no node follow, as in normalizeTreeValue. A node disabled when the value was stored
|
|
51
|
+
* and enabled now is covered from then on (with `'topmost'`, a stored parent covers it).
|
|
43
52
|
*/
|
|
44
53
|
export declare function coveredNodes<T extends string>(nodes: TreeNode<T>[], value: T[], selection?: TreeSelection): T[];
|
|
45
54
|
/**
|
|
46
|
-
* The value after flipping `node`, normalized
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
55
|
+
* The value after flipping `node`, normalized, as antd's Tree flips a checkbox. In the
|
|
56
|
+
* cascading selections a covered node is removed with the descendants it covers through
|
|
57
|
+
* enabled nodes and with its enabled ancestors up to the first disabled one (they no longer
|
|
58
|
+
* have all their enabled children); an uncovered one is added, covering its subtree as
|
|
59
|
+
* `cascade` says. With `'independent'` the node alone is added or removed. A `node` that is
|
|
60
|
+
* not one of the nodes changes nothing. Whether `node` itself may be flipped is the caller's
|
|
61
|
+
* to decide (useManyOfTreeField refuses a disabled one).
|
|
50
62
|
*/
|
|
51
63
|
export declare function toggleTreeValue<T extends string>(nodes: TreeNode<T>[], value: T[], node: T, selection: TreeSelection): T[];
|
|
52
64
|
/** The nodes a tree widget opens at first under `expand` (see TreeExpand), in pre-order. */
|
package/dist/tree.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAIrE,gFAAgF;AAChF,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;IACzE,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;CAC1B;AAED,8GAA8G;AAC9G,MAAM,WAAW,gBAAgB,CAAC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