@quillmark/svelte 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/address.d.ts +17 -10
- package/dist/core/address.js +26 -12
- package/dist/core/bloom.js +4 -3
- package/dist/core/codec/decode.d.ts +17 -0
- package/dist/core/codec/decode.js +78 -19
- package/dist/core/codec/encode.js +1 -1
- package/dist/core/codec/field.d.ts +64 -15
- package/dist/core/codec/field.js +201 -65
- package/dist/core/codec/index.d.ts +3 -3
- package/dist/core/codec/index.js +3 -3
- package/dist/core/codec/islands.d.ts +5 -4
- package/dist/core/codec/islands.js +23 -38
- package/dist/core/codec/keymap.d.ts +5 -4
- package/dist/core/codec/keymap.js +5 -4
- package/dist/core/codec/prose.css +42 -0
- package/dist/core/codec/schema.d.ts +24 -5
- package/dist/core/codec/schema.js +40 -9
- package/dist/core/codec/slash.js +0 -0
- package/dist/core/errors.d.ts +3 -2
- package/dist/core/rungs.d.ts +8 -0
- package/dist/core/rungs.js +24 -0
- package/dist/core/theme.css +19 -6
- package/dist/preview/paint.js +21 -17
- package/dist/visual/ArrayField.svelte +649 -176
- package/dist/visual/ArrayField.svelte.d.ts +16 -1
- package/dist/visual/BooleanField.svelte +36 -11
- package/dist/visual/BooleanField.svelte.d.ts +2 -0
- package/dist/visual/Card.svelte +6 -25
- package/dist/visual/DateField.svelte +66 -31
- package/dist/visual/EnumField.svelte +27 -9
- package/dist/visual/EnumField.svelte.d.ts +5 -0
- package/dist/visual/Field.svelte +113 -38
- package/dist/visual/FormatPopover.svelte +4 -3
- package/dist/visual/MatrixField.svelte +353 -0
- package/dist/visual/MatrixField.svelte.d.ts +36 -0
- package/dist/visual/NumberField.svelte +31 -14
- package/dist/visual/NumberField.svelte.d.ts +5 -1
- package/dist/visual/ObjectField.svelte +404 -139
- package/dist/visual/ObjectField.svelte.d.ts +17 -2
- package/dist/visual/ProseField.svelte +53 -23
- package/dist/visual/ProseField.svelte.d.ts +15 -3
- package/dist/visual/ProseValue.svelte +102 -46
- package/dist/visual/ProseValue.svelte.d.ts +17 -5
- package/dist/visual/TextField.svelte +35 -18
- package/dist/visual/TextField.svelte.d.ts +7 -0
- package/dist/visual/VariantField.svelte +56 -2
- package/dist/visual/VariantField.svelte.d.ts +10 -1
- package/dist/visual/VisualEditorInner.svelte +77 -73
- package/dist/visual/controls.css +47 -5
- package/dist/visual/diagnostics.d.ts +26 -2
- package/dist/visual/diagnostics.js +52 -5
- package/dist/visual/hold.js +2 -2
- package/dist/visual/icons/nodes.d.ts +3 -0
- package/dist/visual/icons/nodes.js +2 -1
- package/dist/visual/leaves.d.ts +25 -12
- package/dist/visual/motion.d.ts +14 -5
- package/dist/visual/motion.js +13 -11
- package/dist/visual/strings.d.ts +27 -10
- package/dist/visual/strings.js +8 -2
- package/dist/visual/structure.d.ts +159 -40
- package/dist/visual/structure.js +337 -45
- package/package.json +2 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Content, PathStep, QuillFieldSchema } from '@quillmark/wasm';
|
|
2
|
+
import { type DeepDiagnostic } from './diagnostics.js';
|
|
3
|
+
import type { LandingBox } from './leaves.js';
|
|
4
|
+
import './controls.css';
|
|
5
|
+
interface Props {
|
|
6
|
+
/** The stored sparse map, or undefined while the field is unset. */
|
|
7
|
+
value: Record<string, unknown> | undefined;
|
|
8
|
+
/** The field's own schema: `members` is the roster, `properties` the columns. */
|
|
9
|
+
schema: QuillFieldSchema;
|
|
10
|
+
/** Field label, the naming prefix a member's columns compose with. */
|
|
11
|
+
label?: string;
|
|
12
|
+
/** Schema `description`: the label's help affordance. */
|
|
13
|
+
description?: string;
|
|
14
|
+
/** The label's own DOM id: the group's name, each tick keeping its own `<label>`. */
|
|
15
|
+
labelId?: string;
|
|
16
|
+
/** Where the description parks, for the group's `aria-describedby`. */
|
|
17
|
+
descriptionId?: string;
|
|
18
|
+
/** The field's control id: the base a member's tick and columns derive their own
|
|
19
|
+
* names from, one `-m-<member id>` segment down. */
|
|
20
|
+
idBase?: string;
|
|
21
|
+
/** The boundary's nested content read, rooted at this field: a member's content
|
|
22
|
+
* column reads at `[id, column]` (`reader.getContentAt`). */
|
|
23
|
+
contentAt: (path: PathStep[]) => Content | undefined;
|
|
24
|
+
onCommit: (v: Record<string, unknown> | undefined) => void;
|
|
25
|
+
/** The diagnostics routed into this field, each with its steps still to walk: one
|
|
26
|
+
* naming a member draws under that member, one naming nothing on the roster at the
|
|
27
|
+
* field's foot. */
|
|
28
|
+
diagnostics?: readonly DeepDiagnostic[];
|
|
29
|
+
}
|
|
30
|
+
declare const MatrixField: import("svelte").Component<Props, {
|
|
31
|
+
focus: () => void;
|
|
32
|
+
washBox: () => HTMLElement | undefined;
|
|
33
|
+
focusPath: (steps: readonly PathStep[], pos?: number) => LandingBox;
|
|
34
|
+
}, "">;
|
|
35
|
+
type MatrixField = ReturnType<typeof MatrixField>;
|
|
36
|
+
export default MatrixField;
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
(`-`, `1.`, `1e`) is never a document state worth a boundary round-trip, and
|
|
5
5
|
committing it live flashes a coercion diagnostic + `console.error` on every
|
|
6
6
|
intermediate prefix, announced by `DiagnosticList`'s `role="status"` live
|
|
7
|
-
region.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
region.
|
|
8
|
+
|
|
9
|
+
An unset field holds its resolved `default:` as its text, at the default rung
|
|
10
|
+
(theme.css), and an edit that settles writes it as authored, as `TextField` takes
|
|
11
|
+
its default. A number has no empty answer (canon `SCHEMAS.md` §"Native validation"),
|
|
12
|
+
so a blank entry commits `undefined`, the unset rung: the parent removes the field,
|
|
13
|
+
the engine renders the default, and the input holds it again.
|
|
11
14
|
|
|
12
15
|
`type="text"`, not `type="number"`: a native number input sanitizes an
|
|
13
16
|
invalid string to `""` before the DOM `value` setter even runs (verified:
|
|
@@ -26,7 +29,11 @@
|
|
|
26
29
|
interface Props {
|
|
27
30
|
value: number | undefined;
|
|
28
31
|
integer?: boolean;
|
|
29
|
-
|
|
32
|
+
/** The resolved `default:` as text: what an unset field holds. */
|
|
33
|
+
fallback?: string;
|
|
34
|
+
/** Words at rest about an unset field that holds no text: the `None` an optional
|
|
35
|
+
* cell prints. */
|
|
36
|
+
placeholder?: string;
|
|
30
37
|
/** Accessible name for an input nothing else names: an object property, whose
|
|
31
38
|
* name is the field label plus the property's. A field's own input takes `id`
|
|
32
39
|
* instead and is named by the `<label for>` beside it. */
|
|
@@ -38,16 +45,25 @@
|
|
|
38
45
|
describedBy?: string;
|
|
39
46
|
onCommit: (v: number | string | undefined) => void;
|
|
40
47
|
}
|
|
41
|
-
let { value, integer, fallback, label, id, describedBy, onCommit }: Props = $props();
|
|
48
|
+
let { value, integer, fallback, placeholder, label, id, describedBy, onCommit }: Props = $props();
|
|
42
49
|
|
|
43
|
-
// Local input state synced to `value` (as a string projection)
|
|
44
|
-
// stays local, only an external change reconciles
|
|
45
|
-
|
|
50
|
+
// Local input state synced to `value` (as a string projection), or to the default
|
|
51
|
+
// an unset field holds; own-typing stays local, only an external change reconciles
|
|
52
|
+
// back in (see `syncedLocal`).
|
|
53
|
+
const local = syncedLocal(() => (value != null ? String(value) : (fallback ?? '')));
|
|
54
|
+
const defaulted = $derived(value == null && !!fallback && local.value === fallback);
|
|
46
55
|
|
|
47
56
|
// Parse a settled entry and emit it; `local` is owned by `oninput`. Blank →
|
|
48
|
-
// `undefined
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
// `undefined`, and the input takes the default back: nothing else reconciles it, the
|
|
58
|
+
// projection having read the default throughout. Onto the element as well, since the
|
|
59
|
+
// attribute Svelte last wrote may already be the default, and it writes no repeat.
|
|
60
|
+
function commit(el: HTMLInputElement): void {
|
|
61
|
+
const raw = el.value;
|
|
62
|
+
if (raw.trim() === '') {
|
|
63
|
+
onCommit(undefined);
|
|
64
|
+
local.value = el.value = fallback ?? '';
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
51
67
|
// Number(), not parseFloat/parseInt: a prefix parse would silently commit
|
|
52
68
|
// `14.5` for `14.5x` (and truncate `11.9` → 11 on integer fields) instead
|
|
53
69
|
// of letting the boundary judge the full entry.
|
|
@@ -62,11 +78,12 @@
|
|
|
62
78
|
inputmode={integer ? 'numeric' : 'decimal'}
|
|
63
79
|
value={local.value}
|
|
64
80
|
{id}
|
|
65
|
-
placeholder
|
|
81
|
+
{placeholder}
|
|
82
|
+
data-default={defaulted ? '' : undefined}
|
|
66
83
|
aria-label={id ? undefined : label}
|
|
67
84
|
aria-describedby={describedBy}
|
|
68
85
|
oninput={(e) => {
|
|
69
86
|
local.value = (e.currentTarget as HTMLInputElement).value;
|
|
70
87
|
}}
|
|
71
|
-
onchange={(e) => commit(
|
|
88
|
+
onchange={(e) => commit(e.currentTarget as HTMLInputElement)}
|
|
72
89
|
/>
|
|
@@ -2,7 +2,11 @@ import './controls.css';
|
|
|
2
2
|
interface Props {
|
|
3
3
|
value: number | undefined;
|
|
4
4
|
integer?: boolean;
|
|
5
|
-
|
|
5
|
+
/** The resolved `default:` as text: what an unset field holds. */
|
|
6
|
+
fallback?: string;
|
|
7
|
+
/** Words at rest about an unset field that holds no text: the `None` an optional
|
|
8
|
+
* cell prints. */
|
|
9
|
+
placeholder?: string;
|
|
6
10
|
/** Accessible name for an input nothing else names: an object property, whose
|
|
7
11
|
* name is the field label plus the property's. A field's own input takes `id`
|
|
8
12
|
* instead and is named by the `<label for>` beside it. */
|