@quillmark/svelte 0.18.0 → 0.19.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.
@@ -91,7 +91,7 @@
91
91
  const CHEVRON = 16;
92
92
 
93
93
  interface Props {
94
- value: unknown[] | undefined;
94
+ value: unknown;
95
95
  /** The declared `default:`: the rows an unset array draws, which a gesture takes. */
96
96
  fallback?: unknown[];
97
97
  items: QuillFieldSchema | undefined;
@@ -156,11 +156,18 @@
156
156
  const table = $derived(layout === 'table' && control === 'object');
157
157
  const columns = $derived(Object.entries(items?.properties ?? {}));
158
158
  const defaulted = $derived(value == null && (fallback?.length ?? 0) > 0);
159
- const arr = $derived((value ?? fallback ?? []) as unknown[]);
160
- /** The rows' content read: the boundary's, or, while the rows are the default, the
161
- * literal's own leaf at the codec its declared type names. */
159
+ // A bare value is the one-element list the render floor wraps it into (canon
160
+ // `SCHEMAS.md` §"Type coercion"), and the reader answers no element of it.
161
+ const bare = $derived(value != null && !Array.isArray(value));
162
+ const arr = $derived(rowsOf(value));
163
+ function rowsOf(v: unknown): unknown[] {
164
+ if (v == null) return fallback ?? [];
165
+ return Array.isArray(v) ? v : [v];
166
+ }
167
+ /** The rows' content read: the boundary's, or, while the rows are the default or a
168
+ * bare value, the literal's own leaf at the codec its declared type names. */
162
169
  function readAt(path: PathStep[]): Content | undefined {
163
- if (!defaulted) return contentAt(path);
170
+ if (!defaulted && !bare) return contentAt(path);
164
171
  const leaf = schemaAt({ type: 'array', items }, path);
165
172
  let v: unknown = arr;
166
173
  for (const step of path) v = (v as Record<string | number, unknown> | undefined)?.[step];
@@ -177,7 +184,7 @@
177
184
  // an effect-only seed mounts every element editor in a second render.
178
185
  const seq = new IdSeq();
179
186
  // svelte-ignore state_referenced_locally
180
- let ids = $state<string[]>(seq.take((value ?? fallback ?? []).length));
187
+ let ids = $state<string[]>(seq.take(rowsOf(value).length));
181
188
  // Length reconcile (defend against an out-of-band length change);
182
189
  // order is maintained by the mutators, not here.
183
190
  $effect(() => {
@@ -3,7 +3,7 @@ import { type ArrayLayout } from './structure.js';
3
3
  import { type DeepDiagnostic } from './diagnostics.js';
4
4
  import type { LandingBox } from './leaves.js';
5
5
  interface Props {
6
- value: unknown[] | undefined;
6
+ value: unknown;
7
7
  /** The declared `default:`: the rows an unset array draws, which a gesture takes. */
8
8
  fallback?: unknown[];
9
9
  items: QuillFieldSchema | undefined;
@@ -361,7 +361,7 @@
361
361
  {:else if field.control === 'array'}
362
362
  <ArrayField
363
363
  bind:this={arrayEl}
364
- value={value as unknown[] | undefined}
364
+ {value}
365
365
  fallback={Array.isArray(field.schema.default) ? field.schema.default : undefined}
366
366
  items={field.schema.items}
367
367
  layout={arrayLayout(field.schema)}
@@ -376,7 +376,7 @@
376
376
  under an open row costs is two rungs of the ladder and one figure. -->
377
377
  <ArrayField
378
378
  bind:this={nestedEls[key]}
379
- value={obj[key] as unknown[] | undefined}
379
+ value={obj[key]}
380
380
  fallback={Array.isArray(sub.default) ? sub.default : undefined}
381
381
  items={sub.items}
382
382
  layout={arrayLayout(sub)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillmark/svelte",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "Editor, live-preview and source surfaces over a Quillmark WASM session.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -69,7 +69,7 @@
69
69
  "check": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings"
70
70
  },
71
71
  "peerDependencies": {
72
- "@quillmark/wasm": ">=0.122.0-0",
72
+ "@quillmark/wasm": ">=0.123.0-0",
73
73
  "svelte": "^5.33.0"
74
74
  },
75
75
  "dependencies": {