@pixerate/editor-svelte 0.23.0 → 0.25.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.
Files changed (147) hide show
  1. package/README.md +4 -2
  2. package/dist/ExportDocxButton.svelte +48 -0
  3. package/dist/ExportDocxButton.svelte.d.ts +13 -0
  4. package/dist/ExportDocxButton.svelte.d.ts.map +1 -0
  5. package/dist/StylesGallery.svelte +169 -0
  6. package/dist/StylesGallery.svelte.d.ts +27 -0
  7. package/dist/StylesGallery.svelte.d.ts.map +1 -0
  8. package/dist/canvas/AnimationTimeline.svelte +217 -0
  9. package/dist/canvas/AnimationTimeline.svelte.d.ts +20 -0
  10. package/dist/canvas/AnimationTimeline.svelte.d.ts.map +1 -0
  11. package/dist/canvas/CanvasComponentsPanel.svelte +73 -0
  12. package/dist/canvas/CanvasComponentsPanel.svelte.d.ts +13 -0
  13. package/dist/canvas/CanvasComponentsPanel.svelte.d.ts.map +1 -0
  14. package/dist/canvas/CanvasInstanceInspector.svelte +136 -0
  15. package/dist/canvas/CanvasInstanceInspector.svelte.d.ts +16 -0
  16. package/dist/canvas/CanvasInstanceInspector.svelte.d.ts.map +1 -0
  17. package/dist/canvas/TokenBindingPicker.svelte +93 -0
  18. package/dist/canvas/TokenBindingPicker.svelte.d.ts +20 -0
  19. package/dist/canvas/TokenBindingPicker.svelte.d.ts.map +1 -0
  20. package/dist/canvas/TokenModeSwitcher.svelte +55 -0
  21. package/dist/canvas/TokenModeSwitcher.svelte.d.ts +18 -0
  22. package/dist/canvas/TokenModeSwitcher.svelte.d.ts.map +1 -0
  23. package/dist/canvas/createCanvasAnimation.svelte.d.ts +98 -0
  24. package/dist/canvas/createCanvasAnimation.svelte.d.ts.map +1 -0
  25. package/dist/canvas/createCanvasAnimation.svelte.js +79 -0
  26. package/dist/canvas/createCanvasArrange.svelte.d.ts +4 -0
  27. package/dist/canvas/createCanvasArrange.svelte.d.ts.map +1 -1
  28. package/dist/canvas/createCanvasAutoLayout.svelte.d.ts.map +1 -1
  29. package/dist/canvas/createCanvasComponents.svelte.d.ts +68 -0
  30. package/dist/canvas/createCanvasComponents.svelte.d.ts.map +1 -0
  31. package/dist/canvas/createCanvasComponents.svelte.js +31 -0
  32. package/dist/canvas/createCanvasTokens.svelte.d.ts +31 -0
  33. package/dist/canvas/createCanvasTokens.svelte.d.ts.map +1 -0
  34. package/dist/canvas/createCanvasTokens.svelte.js +50 -0
  35. package/dist/canvas/index.d.ts +12 -0
  36. package/dist/canvas/index.d.ts.map +1 -1
  37. package/dist/canvas/index.js +16 -0
  38. package/dist/docxExport.svelte.d.ts +26 -0
  39. package/dist/docxExport.svelte.d.ts.map +1 -0
  40. package/dist/docxExport.svelte.js +36 -0
  41. package/dist/fileImport.svelte.d.ts +8 -1
  42. package/dist/fileImport.svelte.d.ts.map +1 -1
  43. package/dist/fileImport.svelte.js +11 -1
  44. package/dist/generation/AssetMentionChips.svelte +130 -0
  45. package/dist/generation/AssetMentionChips.svelte.d.ts +21 -0
  46. package/dist/generation/AssetMentionChips.svelte.d.ts.map +1 -0
  47. package/dist/generation/GenerationHistory.svelte +161 -0
  48. package/dist/generation/GenerationHistory.svelte.d.ts +28 -0
  49. package/dist/generation/GenerationHistory.svelte.d.ts.map +1 -0
  50. package/dist/generation/index.d.ts +7 -0
  51. package/dist/generation/index.d.ts.map +1 -1
  52. package/dist/generation/index.js +3 -0
  53. package/dist/generation/records.svelte.d.ts +18 -0
  54. package/dist/generation/records.svelte.d.ts.map +1 -0
  55. package/dist/generation/records.svelte.js +66 -0
  56. package/dist/image-editor/ImageEditor.svelte +72 -1
  57. package/dist/image-editor/ImageEditor.svelte.d.ts.map +1 -1
  58. package/dist/image-editor/RefineEdgePanel.svelte +180 -0
  59. package/dist/image-editor/RefineEdgePanel.svelte.d.ts +13 -0
  60. package/dist/image-editor/RefineEdgePanel.svelte.d.ts.map +1 -0
  61. package/dist/image-editor/SelectionOptionsBar.svelte +135 -0
  62. package/dist/image-editor/SelectionOptionsBar.svelte.d.ts +15 -0
  63. package/dist/image-editor/SelectionOptionsBar.svelte.d.ts.map +1 -0
  64. package/dist/image-editor/index.d.ts +6 -0
  65. package/dist/image-editor/index.d.ts.map +1 -1
  66. package/dist/image-editor/index.js +2 -0
  67. package/dist/index.d.ts +9 -0
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +5 -0
  70. package/dist/paragraphStyles.svelte.d.ts +30 -0
  71. package/dist/paragraphStyles.svelte.d.ts.map +1 -0
  72. package/dist/paragraphStyles.svelte.js +44 -0
  73. package/dist/review/TrackedChangesList.svelte +67 -0
  74. package/dist/review/TrackedChangesList.svelte.d.ts +13 -0
  75. package/dist/review/TrackedChangesList.svelte.d.ts.map +1 -0
  76. package/dist/review/index.d.ts +3 -0
  77. package/dist/review/index.d.ts.map +1 -1
  78. package/dist/review/index.js +1 -0
  79. package/dist/review/review.svelte.d.ts +6 -0
  80. package/dist/review/review.svelte.d.ts.map +1 -1
  81. package/dist/review/review.svelte.js +3 -0
  82. package/dist/spreadsheet/FormulaBar.svelte +13 -4
  83. package/dist/spreadsheet/FormulaBar.svelte.d.ts.map +1 -1
  84. package/dist/spreadsheet/FormulaHints.svelte +7 -5
  85. package/dist/spreadsheet/FormulaHints.svelte.d.ts +3 -0
  86. package/dist/spreadsheet/FormulaHints.svelte.d.ts.map +1 -1
  87. package/dist/spreadsheet/NameManager.svelte +165 -0
  88. package/dist/spreadsheet/NameManager.svelte.d.ts +11 -0
  89. package/dist/spreadsheet/NameManager.svelte.d.ts.map +1 -0
  90. package/dist/spreadsheet/SheetTabs.svelte +161 -0
  91. package/dist/spreadsheet/SheetTabs.svelte.d.ts +10 -0
  92. package/dist/spreadsheet/SheetTabs.svelte.d.ts.map +1 -0
  93. package/dist/spreadsheet/SpreadsheetConditionalFormatPanel.svelte +184 -0
  94. package/dist/spreadsheet/SpreadsheetConditionalFormatPanel.svelte.d.ts +9 -0
  95. package/dist/spreadsheet/SpreadsheetConditionalFormatPanel.svelte.d.ts.map +1 -0
  96. package/dist/spreadsheet/SpreadsheetContextMenu.svelte +9 -4
  97. package/dist/spreadsheet/SpreadsheetContextMenu.svelte.d.ts +5 -1
  98. package/dist/spreadsheet/SpreadsheetContextMenu.svelte.d.ts.map +1 -1
  99. package/dist/spreadsheet/SpreadsheetDataValidationPanel.svelte +141 -0
  100. package/dist/spreadsheet/SpreadsheetDataValidationPanel.svelte.d.ts +9 -0
  101. package/dist/spreadsheet/SpreadsheetDataValidationPanel.svelte.d.ts.map +1 -0
  102. package/dist/spreadsheet/SpreadsheetEditor.svelte +273 -19
  103. package/dist/spreadsheet/SpreadsheetEditor.svelte.d.ts +8 -0
  104. package/dist/spreadsheet/SpreadsheetEditor.svelte.d.ts.map +1 -1
  105. package/dist/spreadsheet/SpreadsheetGroupRow.svelte +31 -3
  106. package/dist/spreadsheet/SpreadsheetGroupRow.svelte.d.ts +6 -0
  107. package/dist/spreadsheet/SpreadsheetGroupRow.svelte.d.ts.map +1 -1
  108. package/dist/spreadsheet/SpreadsheetValidationDialog.svelte +92 -0
  109. package/dist/spreadsheet/SpreadsheetValidationDialog.svelte.d.ts +9 -0
  110. package/dist/spreadsheet/SpreadsheetValidationDialog.svelte.d.ts.map +1 -0
  111. package/dist/spreadsheet/index.d.ts +10 -0
  112. package/dist/spreadsheet/index.d.ts.map +1 -1
  113. package/dist/spreadsheet/index.js +6 -0
  114. package/dist/spreadsheet/spreadsheet.svelte.d.ts +56 -3
  115. package/dist/spreadsheet/spreadsheet.svelte.d.ts.map +1 -1
  116. package/dist/spreadsheet/spreadsheet.svelte.js +105 -6
  117. package/dist/spreadsheet/viewport.svelte.d.ts +26 -0
  118. package/dist/spreadsheet/viewport.svelte.d.ts.map +1 -0
  119. package/dist/spreadsheet/viewport.svelte.js +93 -0
  120. package/dist/tables/InsertTableGrid.svelte +85 -0
  121. package/dist/tables/InsertTableGrid.svelte.d.ts +21 -0
  122. package/dist/tables/InsertTableGrid.svelte.d.ts.map +1 -0
  123. package/dist/tables/TableBubbleMenu.svelte +43 -0
  124. package/dist/tables/TableBubbleMenu.svelte.d.ts +18 -0
  125. package/dist/tables/TableBubbleMenu.svelte.d.ts.map +1 -0
  126. package/dist/tables/TableToolbar.svelte +81 -0
  127. package/dist/tables/TableToolbar.svelte.d.ts +19 -0
  128. package/dist/tables/TableToolbar.svelte.d.ts.map +1 -0
  129. package/dist/tables/index.d.ts +12 -0
  130. package/dist/tables/index.d.ts.map +1 -0
  131. package/dist/tables/index.js +4 -0
  132. package/dist/tables/tableMenu.svelte.d.ts +21 -0
  133. package/dist/tables/tableMenu.svelte.d.ts.map +1 -0
  134. package/dist/tables/tableMenu.svelte.js +27 -0
  135. package/dist/tokens/TokenSwatch.svelte +14 -0
  136. package/dist/tokens/TokenSwatch.svelte.d.ts +8 -0
  137. package/dist/tokens/TokenSwatch.svelte.d.ts.map +1 -0
  138. package/dist/tokens/TokensPanel.svelte +323 -0
  139. package/dist/tokens/TokensPanel.svelte.d.ts +14 -0
  140. package/dist/tokens/TokensPanel.svelte.d.ts.map +1 -0
  141. package/dist/tokens/createTokens.svelte.d.ts +31 -0
  142. package/dist/tokens/createTokens.svelte.d.ts.map +1 -0
  143. package/dist/tokens/createTokens.svelte.js +43 -0
  144. package/dist/tokens/index.d.ts +7 -0
  145. package/dist/tokens/index.d.ts.map +1 -0
  146. package/dist/tokens/index.js +3 -0
  147. package/package.json +10 -2
@@ -0,0 +1,136 @@
1
+ <script lang="ts">
2
+ import { inspectCanvasInstance, listCanvasComponents, type CanvasComponentsController } from '@pixerate/editor/canvas';
3
+ import type { CanvasNode } from './types.js';
4
+
5
+ type Actions = Pick<
6
+ CanvasComponentsController<any>,
7
+ 'setInstanceProperties' | 'resetOverrides' | 'detachInstance' | 'goToMainComponent' | 'pushOverrides' | 'restoreMainComponent'
8
+ >;
9
+
10
+ interface Props {
11
+ nodes: CanvasNode[];
12
+ /** An instance, or a layer inside one; nothing is shown otherwise. */
13
+ nodeId: string | null | undefined;
14
+ components: Actions;
15
+ /** Receives refusals (e.g. a property value that would nest a component in itself). */
16
+ onerror?: (reason: string) => void;
17
+ class?: string;
18
+ }
19
+
20
+ let { nodes, nodeId, components, onerror, class: className = '' }: Props = $props();
21
+
22
+ const info = $derived(nodeId ? inspectCanvasInstance(nodes as any[], nodeId) : undefined);
23
+ const allComponents = $derived(listCanvasComponents(nodes as any[]).components);
24
+ const btn = 'rounded border border-border px-2 py-0.5 text-xs hover:bg-muted disabled:opacity-40';
25
+
26
+ function report(result: { ok: boolean; reason?: string } | undefined) {
27
+ if (result && !result.ok && result.reason) onerror?.(result.reason);
28
+ }
29
+ function setProp(name: string, value: unknown) {
30
+ if (info) report(components.setInstanceProperties({ [name]: value }, [info.id]));
31
+ }
32
+ </script>
33
+
34
+ {#if info}
35
+ <div data-instance-inspector="" data-instance-id={info.id} class="flex flex-col gap-2 text-xs text-foreground {className}">
36
+ <div class="flex items-center justify-between gap-2">
37
+ <span class="truncate font-medium" data-instance-main="">
38
+ {info.status === 'linked' ? info.componentName : 'Main component missing'}
39
+ </span>
40
+ {#if info.nested}<span class="text-muted-foreground">Nested</span>{/if}
41
+ </div>
42
+ {#each info.variantOptions as option (option.name)}
43
+ <label class="flex items-center gap-2" data-variant-property={option.name}>
44
+ <span class="w-24 shrink-0 truncate text-muted-foreground">{option.name}</span>
45
+ <select
46
+ aria-label="{option.name} variant"
47
+ class="min-w-0 flex-1 rounded border border-border bg-background px-1 py-0.5 text-xs"
48
+ value={info.variant[option.name] ?? ''}
49
+ onchange={(e) => setProp(option.name, e.currentTarget.value)}
50
+ >
51
+ {#each option.values as v (v)}
52
+ <option value={v}>{v}</option>
53
+ {/each}
54
+ </select>
55
+ </label>
56
+ {/each}
57
+ {#each info.properties as p (p.name)}
58
+ <label class="flex items-center gap-2" data-component-property={p.name}>
59
+ <span class="w-24 shrink-0 truncate text-muted-foreground">{p.name}</span>
60
+ {#if p.type === 'boolean'}
61
+ <input type="checkbox" aria-label={p.name} checked={p.value === true} onchange={(e) => setProp(p.name, e.currentTarget.checked)} />
62
+ {:else if p.type === 'text'}
63
+ {#key p.value}
64
+ <input
65
+ type="text"
66
+ aria-label={p.name}
67
+ value={String(p.value)}
68
+ class="min-w-0 flex-1 rounded border border-border bg-background px-1 py-0.5 text-xs"
69
+ onblur={(e) => {
70
+ if (e.currentTarget.value !== p.value) setProp(p.name, e.currentTarget.value);
71
+ }}
72
+ onkeydown={(e) => {
73
+ if (e.key === 'Enter') e.currentTarget.blur();
74
+ }}
75
+ />
76
+ {/key}
77
+ {:else}
78
+ <select
79
+ aria-label={p.name}
80
+ class="min-w-0 flex-1 rounded border border-border bg-background px-1 py-0.5 text-xs"
81
+ value={String(p.value)}
82
+ onchange={(e) => setProp(p.name, e.currentTarget.value)}
83
+ >
84
+ {#each allComponents.filter((c) => !p.preferred?.length || p.preferred.includes(c.id) || c.id === p.value) as c (c.id)}
85
+ <option value={c.id}>{c.name}</option>
86
+ {/each}
87
+ </select>
88
+ {/if}
89
+ </label>
90
+ {/each}
91
+ {#if info.overrides.length}
92
+ <div class="flex flex-col gap-1" data-instance-overrides="">
93
+ <span class="text-muted-foreground">Overrides</span>
94
+ {#each info.overrides as o (o.id)}
95
+ <div class="flex flex-wrap items-center gap-1" data-override-layer={o.id}>
96
+ <span class="mr-1 truncate">{o.name}</span>
97
+ {#each o.groups as g (g)}
98
+ <button
99
+ type="button"
100
+ class="rounded bg-muted px-1 text-[10px]"
101
+ data-override-group={g}
102
+ title="Reset {g}"
103
+ onclick={() => report(components.resetOverrides(o.id, g))}>{g} ×</button
104
+ >
105
+ {/each}
106
+ </div>
107
+ {/each}
108
+ </div>
109
+ {/if}
110
+ <div class="flex flex-wrap gap-1">
111
+ {#if info.status === 'linked'}
112
+ <button type="button" class={btn} data-action="reset" onclick={() => report(components.resetOverrides(info!.id))}>Reset all</button>
113
+ <button type="button" class={btn} data-action="go-to-main" onclick={() => components.goToMainComponent(info!.id)}>Go to main</button>
114
+ <button
115
+ type="button"
116
+ class={btn}
117
+ data-action="push"
118
+ disabled={info.overrides.length === 0}
119
+ onclick={() => report(components.pushOverrides(info!.rootId))}>Push changes</button
120
+ >
121
+ {:else}
122
+ <button type="button" class={btn} data-action="restore" onclick={() => report(components.restoreMainComponent(info!.rootId))}
123
+ >Restore main component</button
124
+ >
125
+ {/if}
126
+ <button
127
+ type="button"
128
+ class={btn}
129
+ data-action="detach"
130
+ disabled={info.nested}
131
+ title={info.nested ? 'Detach the outer instance first' : undefined}
132
+ onclick={() => report(components.detachInstance([info!.id]))}>Detach</button
133
+ >
134
+ </div>
135
+ </div>
136
+ {/if}
@@ -0,0 +1,16 @@
1
+ import { type CanvasComponentsController } from '@pixerate/editor/canvas';
2
+ import type { CanvasNode } from './types.js';
3
+ type Actions = Pick<CanvasComponentsController<any>, 'setInstanceProperties' | 'resetOverrides' | 'detachInstance' | 'goToMainComponent' | 'pushOverrides' | 'restoreMainComponent'>;
4
+ interface Props {
5
+ nodes: CanvasNode[];
6
+ /** An instance, or a layer inside one; nothing is shown otherwise. */
7
+ nodeId: string | null | undefined;
8
+ components: Actions;
9
+ /** Receives refusals (e.g. a property value that would nest a component in itself). */
10
+ onerror?: (reason: string) => void;
11
+ class?: string;
12
+ }
13
+ declare const CanvasInstanceInspector: import("svelte").Component<Props, {}, "">;
14
+ type CanvasInstanceInspector = ReturnType<typeof CanvasInstanceInspector>;
15
+ export default CanvasInstanceInspector;
16
+ //# sourceMappingURL=CanvasInstanceInspector.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CanvasInstanceInspector.svelte.d.ts","sourceRoot":"","sources":["../../src/canvas/CanvasInstanceInspector.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EAA+C,KAAK,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACvH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG5C,KAAK,OAAO,GAAG,IAAI,CAClB,0BAA0B,CAAC,GAAG,CAAC,EAC/B,uBAAuB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,mBAAmB,GAAG,eAAe,GAAG,sBAAsB,CAC9H,CAAC;AAEF,UAAU,KAAK;IACd,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,sEAAsE;IACtE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,uFAAuF;IACvF,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAyFF,QAAA,MAAM,uBAAuB,2CAAwC,CAAC;AACtE,KAAK,uBAAuB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAC1E,eAAe,uBAAuB,CAAC"}
@@ -0,0 +1,93 @@
1
+ <script lang="ts">
2
+ import {
3
+ bindCanvasToken,
4
+ getBindableTokenProperties,
5
+ getEffectiveTokenModes,
6
+ getNodeTokenBindings,
7
+ getTokensForProperty,
8
+ type CanvasTokenOptions
9
+ } from '@pixerate/editor/canvas';
10
+ import { resolveToken, type TokenState } from '@pixerate/editor/tokens';
11
+ import type { CanvasNode } from './types.js';
12
+
13
+ interface Props {
14
+ state: TokenState;
15
+ nodes: CanvasNode[];
16
+ /** Nodes to bind (the first one decides which properties are listed). */
17
+ selectedIds: readonly string[];
18
+ /** Receives the nodes with the binding applied and resolved. */
19
+ onchange: (nodes: CanvasNode[]) => void;
20
+ options?: CanvasTokenOptions;
21
+ /** Limit to these property keys (in this order). */
22
+ properties?: readonly string[];
23
+ onerror?: (error: Error) => void;
24
+ class?: string;
25
+ }
26
+
27
+ let { state, nodes, selectedIds, onchange, options = {}, properties, onerror, class: className = '' }: Props = $props();
28
+
29
+ const selected = $derived(nodes.filter((n) => selectedIds.includes(n.id)));
30
+ const first = $derived(selected[0]);
31
+ const rows = $derived.by(() => {
32
+ if (!first) return [];
33
+ const all = getBindableTokenProperties(first as any, options);
34
+ return properties ? properties.map((key) => all.find((p) => p.key === key)).filter((p) => !!p) : all;
35
+ });
36
+ const modes = $derived(first ? getEffectiveTokenModes(first as any, nodes as any, state, options) : {});
37
+
38
+ function valueOf(key: string) {
39
+ const ids = new Set(selected.map((n) => getNodeTokenBindings(n as any)[key] ?? ''));
40
+ return ids.size === 1 ? [...ids][0] : '__mixed';
41
+ }
42
+
43
+ function change(key: string, id: string) {
44
+ try {
45
+ onchange(bindCanvasToken(nodes as any[], selectedIds, key, id || null, state, options));
46
+ } catch (error) {
47
+ onerror?.(error as Error);
48
+ }
49
+ }
50
+ </script>
51
+
52
+ {#if first}
53
+ <div data-token-binding-picker="" class="flex flex-col gap-1 text-xs text-foreground {className}">
54
+ {#each rows as property (property!.key)}
55
+ {@const value = valueOf(property!.key)}
56
+ {@const resolved = value && value !== '__mixed' ? resolveToken(state, value, modes) : null}
57
+ <label class="flex items-center gap-2" data-token-property={property!.key}>
58
+ <span class="w-28 shrink-0 text-muted-foreground">{property!.label}</span>
59
+ <select
60
+ aria-label="{property!.label} variable"
61
+ class="min-w-0 flex-1 rounded border border-border bg-background px-1 py-0.5 text-xs"
62
+ {value}
63
+ onchange={(e) => change(property!.key, e.currentTarget.value)}
64
+ >
65
+ {#if value === '__mixed'}<option value="__mixed">Mixed</option>{/if}
66
+ <option value="">None</option>
67
+ {#each getTokensForProperty(state, property!, first as any) as v (v.id)}
68
+ {@const collection = state.collections.find((c) => c.id === v.collectionId)}
69
+ <option value={v.id}>{v.name}{collection && state.collections.length > 1 ? ` (${collection.name})` : ''}</option>
70
+ {/each}
71
+ </select>
72
+ <span class="w-16 shrink-0 truncate text-right text-muted-foreground" data-token-resolved="">
73
+ {#if resolved?.ok}
74
+ {#if property!.type === 'color'}
75
+ <span
76
+ class="inline-block h-3 w-3 rounded border border-border align-middle"
77
+ style:background={String(resolved.value)}
78
+ title={String(resolved.value)}
79
+ ></span>
80
+ {:else}
81
+ {String(resolved.value)}
82
+ {/if}
83
+ {:else if resolved}
84
+ <span title={resolved.message}>⚠</span>
85
+ {/if}
86
+ </span>
87
+ </label>
88
+ {/each}
89
+ {#if state.collections.length === 0}
90
+ <p class="text-muted-foreground">No variables yet.</p>
91
+ {/if}
92
+ </div>
93
+ {/if}
@@ -0,0 +1,20 @@
1
+ import { type CanvasTokenOptions } from '@pixerate/editor/canvas';
2
+ import { type TokenState } from '@pixerate/editor/tokens';
3
+ import type { CanvasNode } from './types.js';
4
+ interface Props {
5
+ state: TokenState;
6
+ nodes: CanvasNode[];
7
+ /** Nodes to bind (the first one decides which properties are listed). */
8
+ selectedIds: readonly string[];
9
+ /** Receives the nodes with the binding applied and resolved. */
10
+ onchange: (nodes: CanvasNode[]) => void;
11
+ options?: CanvasTokenOptions;
12
+ /** Limit to these property keys (in this order). */
13
+ properties?: readonly string[];
14
+ onerror?: (error: Error) => void;
15
+ class?: string;
16
+ }
17
+ declare const TokenBindingPicker: import("svelte").Component<Props, {}, "">;
18
+ type TokenBindingPicker = ReturnType<typeof TokenBindingPicker>;
19
+ export default TokenBindingPicker;
20
+ //# sourceMappingURL=TokenBindingPicker.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TokenBindingPicker.svelte.d.ts","sourceRoot":"","sources":["../../src/canvas/TokenBindingPicker.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EAML,KAAK,kBAAkB,EACvB,MAAM,yBAAyB,CAAC;AAClC,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG5C,UAAU,KAAK;IACd,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,yEAAyE;IACzE,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,gEAAgE;IAChE,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;IACxC,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,oDAAoD;IACpD,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAoEF,QAAA,MAAM,kBAAkB,2CAAwC,CAAC;AACjE,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,55 @@
1
+ <script lang="ts">
2
+ import {
3
+ getEffectiveTokenModes,
4
+ getNodeTokenModes,
5
+ setCanvasTokenMode,
6
+ type CanvasTokenOptions
7
+ } from '@pixerate/editor/canvas';
8
+ import { getCurrentMode, type TokenState } from '@pixerate/editor/tokens';
9
+ import type { CanvasNode } from './types.js';
10
+
11
+ interface Props {
12
+ state: TokenState;
13
+ nodes: CanvasNode[];
14
+ /** Frames / groups whose explicit mode is set (the first one's choice is shown). */
15
+ nodeIds: readonly string[];
16
+ onchange: (nodes: CanvasNode[]) => void;
17
+ options?: CanvasTokenOptions;
18
+ /** Show collections with a single mode too (default `false`). */
19
+ showSingleMode?: boolean;
20
+ class?: string;
21
+ }
22
+
23
+ let { state, nodes, nodeIds, onchange, options = {}, showSingleMode = false, class: className = '' }: Props = $props();
24
+
25
+ const first = $derived(nodes.find((n) => nodeIds.includes(n.id)));
26
+ const own = $derived(first ? getNodeTokenModes(first as any) : {});
27
+ const inherited = $derived.by(() => {
28
+ const parent = first?.parentId ? nodes.find((n) => n.id === first!.parentId) : undefined;
29
+ return parent ? getEffectiveTokenModes(parent as any, nodes as any, state, options) : { ...options.modes };
30
+ });
31
+ const collections = $derived(state.collections.filter((c) => showSingleMode || c.modes.length > 1));
32
+ </script>
33
+
34
+ {#if first}
35
+ <div data-token-mode-switcher="" class="flex flex-col gap-1 text-xs text-foreground {className}">
36
+ {#each collections as collection (collection.id)}
37
+ {@const explicit = collection.modes.some((m) => m.id === own[collection.id]) ? own[collection.id] : ''}
38
+ <label class="flex items-center gap-2" data-token-collection={collection.id}>
39
+ <span class="w-28 shrink-0 truncate text-muted-foreground">{collection.name}</span>
40
+ <select
41
+ aria-label="{collection.name} mode"
42
+ class="min-w-0 flex-1 rounded border border-border bg-background px-1 py-0.5 text-xs"
43
+ value={explicit}
44
+ onchange={(e) =>
45
+ onchange(setCanvasTokenMode(nodes as any[], nodeIds, collection.id, e.currentTarget.value || null, state, options))}
46
+ >
47
+ <option value="">Auto ({getCurrentMode(collection, inherited).name})</option>
48
+ {#each collection.modes as m (m.id)}
49
+ <option value={m.id}>{m.name}</option>
50
+ {/each}
51
+ </select>
52
+ </label>
53
+ {/each}
54
+ </div>
55
+ {/if}
@@ -0,0 +1,18 @@
1
+ import { type CanvasTokenOptions } from '@pixerate/editor/canvas';
2
+ import { type TokenState } from '@pixerate/editor/tokens';
3
+ import type { CanvasNode } from './types.js';
4
+ interface Props {
5
+ state: TokenState;
6
+ nodes: CanvasNode[];
7
+ /** Frames / groups whose explicit mode is set (the first one's choice is shown). */
8
+ nodeIds: readonly string[];
9
+ onchange: (nodes: CanvasNode[]) => void;
10
+ options?: CanvasTokenOptions;
11
+ /** Show collections with a single mode too (default `false`). */
12
+ showSingleMode?: boolean;
13
+ class?: string;
14
+ }
15
+ declare const TokenModeSwitcher: import("svelte").Component<Props, {}, "">;
16
+ type TokenModeSwitcher = ReturnType<typeof TokenModeSwitcher>;
17
+ export default TokenModeSwitcher;
18
+ //# sourceMappingURL=TokenModeSwitcher.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TokenModeSwitcher.svelte.d.ts","sourceRoot":"","sources":["../../src/canvas/TokenModeSwitcher.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,KAAK,kBAAkB,EACvB,MAAM,yBAAyB,CAAC;AAClC,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG5C,UAAU,KAAK;IACd,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,oFAAoF;IACpF,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;IACxC,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,iEAAiE;IACjE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAsCF,QAAA,MAAM,iBAAiB,2CAAwC,CAAC;AAChE,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC9D,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,98 @@
1
+ import { type AnimatableProperty, type AnimationHistoryTarget, type AnimationLoopMode, type CanvasAnimationState, type Clock } from '@pixerate/editor/canvas';
2
+ import type { CanvasNode } from './types.js';
3
+ export interface CreateCanvasAnimationOptions<TNode extends CanvasNode = CanvasNode> {
4
+ getNodes: () => TNode[];
5
+ setNodes: (nodes: TNode[]) => void;
6
+ /** When set, keyframe edits are undoable steps. */
7
+ history?: AnimationHistoryTarget;
8
+ /** Ids acted on without explicit ids (default: nodes with `selected: true`). */
9
+ getSelectedIds?: () => string[];
10
+ /** Playback time source (default `realClock`); pass a `ManualClock` for tests or rendering. */
11
+ clock?: Clock;
12
+ /** Fixed timeline length (ms); omitted = the last keyframe, at least `minDuration`. */
13
+ duration?: number;
14
+ minDuration?: number;
15
+ loop?: AnimationLoopMode;
16
+ playbackRate?: number;
17
+ fps?: number;
18
+ recording?: boolean;
19
+ properties?: readonly AnimatableProperty[];
20
+ onTime?: (time: number) => void;
21
+ }
22
+ /**
23
+ * Headless Svelte 5 rune for keyframe animation on the canvas (the Svelte twin of
24
+ * `useCanvasAnimation`): playback on an injectable clock, record mode, undoable keyframe
25
+ * edits, multi-keyframe drags with snapping, copy / paste and CSS / Web Animations export.
26
+ *
27
+ * Render `displayNodes` (the nodes evaluated at the playhead) and route edits made on them
28
+ * through `applyDisplayChanges`, so animated properties are keyed at the playhead. Call
29
+ * `refresh()` after changing the nodes yourself so the automatic duration follows them.
30
+ */
31
+ export declare function createCanvasAnimation<TNode extends CanvasNode = CanvasNode>(options: CreateCanvasAnimationOptions<TNode>): {
32
+ state: CanvasAnimationState;
33
+ time: number;
34
+ playing: boolean;
35
+ recording: boolean;
36
+ duration: number;
37
+ selection: readonly import("@pixerate/editor/canvas").KeyframeRef[];
38
+ drag: import("@pixerate/editor/canvas").KeyframeDragState | null;
39
+ revision: number;
40
+ clipboard: import("@pixerate/editor/canvas").AnimationKeyframeClipboard | null;
41
+ displayNodes: TNode[];
42
+ destroy(): void;
43
+ player: import("@pixerate/editor/canvas").AnimationPlayer;
44
+ getState: () => CanvasAnimationState;
45
+ subscribe(listener: (state: CanvasAnimationState) => void): () => void;
46
+ refresh(): void;
47
+ play: () => void;
48
+ pause: () => void;
49
+ toggle: () => void;
50
+ stop: () => void;
51
+ seek: (time: number) => void;
52
+ scrub: (time: number) => void;
53
+ endScrub: () => void;
54
+ setLoop: (loop: AnimationLoopMode) => void;
55
+ setPlaybackRate: (rate: number) => void;
56
+ setDuration(ms: number | null): void;
57
+ setFps(value: number): void;
58
+ setRecording(on: boolean): void;
59
+ toggleRecording(): void;
60
+ nextKeyframe(ids?: Iterable<string>): number | null;
61
+ previousKeyframe(ids?: Iterable<string>): number | null;
62
+ display: (nodes?: readonly any[] | undefined) => any[];
63
+ applyDisplayChanges(next: any[]): import("@pixerate/editor/canvas").KeyframeRef[];
64
+ addKeyframe(ids?: Iterable<string>, keys?: readonly string[], time?: number): import("@pixerate/editor/canvas").KeyframeRef[];
65
+ setKeyframe(nodeId: string, property: string, value: import("@pixerate/editor/canvas").AnimationValue, time?: number, easing?: import("@pixerate/editor/canvas").AnimationEasing | string): void;
66
+ updateKeyframe(ref: import("@pixerate/editor/canvas").KeyframeRef, patch: import("@pixerate/editor/canvas").KeyframePatch): void;
67
+ deleteKeyframes(refs?: readonly import("@pixerate/editor/canvas").KeyframeRef[]): boolean;
68
+ setEasing(easing: import("@pixerate/editor/canvas").AnimationEasing | string | null, refs?: readonly import("@pixerate/editor/canvas").KeyframeRef[]): boolean;
69
+ setTrackEnabled(nodeId: string, property: string, enabled: boolean): void;
70
+ removeTrack(nodeId: string, property: string): void;
71
+ setMotionPath(nodeId: string, motionPath: {
72
+ d: string;
73
+ autoRotate?: boolean;
74
+ } | null): void;
75
+ animateNode(nodeId: string, opts: Omit<import("@pixerate/editor/canvas").AnimateNodeOptions, "properties">): import("@pixerate/editor/canvas").KeyframeRef[];
76
+ moveKeyframes(delta: number, refs?: readonly import("@pixerate/editor/canvas").KeyframeRef[]): number;
77
+ scaleKeyframes(factor: number, refs?: readonly import("@pixerate/editor/canvas").KeyframeRef[], pivot?: number): number;
78
+ copyKeyframes(refs?: readonly import("@pixerate/editor/canvas").KeyframeRef[]): import("@pixerate/editor/canvas").AnimationKeyframeClipboard | null;
79
+ pasteKeyframes(data?: import("@pixerate/editor/canvas").AnimationKeyframeClipboard | null, nodeIds?: readonly string[], time?: number): import("@pixerate/editor/canvas").KeyframeRef[];
80
+ selectKeyframes(refs: readonly import("@pixerate/editor/canvas").KeyframeRef[], mode?: "replace" | "add" | "toggle"): void;
81
+ clearSelection(): void;
82
+ beginKeyframeDrag(refs?: readonly import("@pixerate/editor/canvas").KeyframeRef[]): void;
83
+ updateKeyframeDrag(delta: number, opts?: {
84
+ snap?: boolean;
85
+ thresholdMs?: number;
86
+ }): import("@pixerate/editor/canvas").KeyframeDragState | null;
87
+ endKeyframeDrag(): number;
88
+ cancelKeyframeDrag(): void;
89
+ timelineRows(ids?: Iterable<string>, opts?: Omit<import("@pixerate/editor/canvas").TimelineRowsOptions, "selection" | "dragDelta">): import("@pixerate/editor/canvas").TimelineRow[];
90
+ sampleFrames(opts?: import("@pixerate/editor/canvas").SampleAnimationOptions): import("@pixerate/editor/canvas").AnimationFrame[];
91
+ exportCss(nodeId: string, opts?: import("@pixerate/editor/canvas").CssExportOptions & {
92
+ name?: string;
93
+ selector?: string;
94
+ }): import("@pixerate/editor/canvas").CssAnimationExport;
95
+ toWebAnimations(nodeId: string, opts?: import("@pixerate/editor/canvas").CssExportOptions): import("@pixerate/editor/canvas").WebAnimationSpec[];
96
+ };
97
+ export type SvelteCanvasAnimation<TNode extends CanvasNode = CanvasNode> = ReturnType<typeof createCanvasAnimation<TNode>>;
98
+ //# sourceMappingURL=createCanvasAnimation.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createCanvasAnimation.svelte.d.ts","sourceRoot":"","sources":["../../src/canvas/createCanvasAnimation.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,KAAK,EACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,4BAA4B,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU;IAClF,QAAQ,EAAE,MAAM,KAAK,EAAE,CAAC;IACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;IACnC,mDAAmD;IACnD,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,gFAAgF;IAChF,cAAc,CAAC,EAAE,MAAM,MAAM,EAAE,CAAC;IAChC,+FAA+F;IAC/F,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,uFAAuF;IACvF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAC3C,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU,EAAE,OAAO,EAAE,4BAA4B,CAAC,KAAK,CAAC;;;;;;;;;;kBA2DnG,KAAK,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAakl6I,CAAC;;;;;;;;;;;YAAg/C,CAAC;mBAA8B,CAAC;;;;;;;YAAmjB,CAAC;gBAA0B,CAAC;;;EAH9s+I;AAED,MAAM,MAAM,qBAAqB,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU,IAAI,UAAU,CAAC,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC"}
@@ -0,0 +1,79 @@
1
+ import { createCanvasAnimationController } from '@pixerate/editor/canvas';
2
+ /**
3
+ * Headless Svelte 5 rune for keyframe animation on the canvas (the Svelte twin of
4
+ * `useCanvasAnimation`): playback on an injectable clock, record mode, undoable keyframe
5
+ * edits, multi-keyframe drags with snapping, copy / paste and CSS / Web Animations export.
6
+ *
7
+ * Render `displayNodes` (the nodes evaluated at the playhead) and route edits made on them
8
+ * through `applyDisplayChanges`, so animated properties are keyed at the playhead. Call
9
+ * `refresh()` after changing the nodes yourself so the automatic duration follows them.
10
+ */
11
+ export function createCanvasAnimation(options) {
12
+ const controller = createCanvasAnimationController({
13
+ getNodes: () => options.getNodes(),
14
+ setNodes: (next) => {
15
+ options.setNodes(next);
16
+ // Edits, undo and redo re-render views even when the nodes are not `$state`.
17
+ revision++;
18
+ controller.refresh();
19
+ },
20
+ history: options.history,
21
+ getSelectedIds: options.getSelectedIds,
22
+ clock: options.clock,
23
+ duration: options.duration,
24
+ minDuration: options.minDuration,
25
+ loop: options.loop,
26
+ playbackRate: options.playbackRate,
27
+ fps: options.fps,
28
+ recording: options.recording,
29
+ properties: options.properties,
30
+ onTime: (time) => options.onTime?.(time)
31
+ });
32
+ let state = $state.raw(controller.getState());
33
+ let revision = $state(0);
34
+ const unsubscribe = controller.subscribe((next) => {
35
+ state = next;
36
+ });
37
+ return {
38
+ ...controller,
39
+ /** Playback, selection and drag state (reactive). */
40
+ get state() {
41
+ return state;
42
+ },
43
+ get time() {
44
+ return state.time;
45
+ },
46
+ get playing() {
47
+ return state.playing;
48
+ },
49
+ get recording() {
50
+ return state.recording;
51
+ },
52
+ get duration() {
53
+ return state.duration;
54
+ },
55
+ get selection() {
56
+ return state.selection;
57
+ },
58
+ get drag() {
59
+ return state.drag;
60
+ },
61
+ /** Bumped whenever the rune writes the nodes (edits, undo, redo). */
62
+ get revision() {
63
+ return revision;
64
+ },
65
+ get clipboard() {
66
+ return controller.clipboard;
67
+ },
68
+ /** The nodes evaluated at the playhead (re-read when the time or the nodes change). */
69
+ get displayNodes() {
70
+ void state.time;
71
+ void revision;
72
+ return controller.display(options.getNodes());
73
+ },
74
+ destroy() {
75
+ unsubscribe();
76
+ controller.destroy();
77
+ }
78
+ };
79
+ }
@@ -51,6 +51,10 @@ export declare function createCanvasArrange<TNode extends CanvasNode = CanvasNod
51
51
  exclude: (ids?: Iterable<string>, o?: import("@pixerate/editor/canvas").CombineShapeNodesOptions) => import("@pixerate/editor/canvas").CombineShapeNodesResult<any>;
52
52
  divide: (ids?: Iterable<string>, o?: import("@pixerate/editor/canvas").CombineShapeNodesOptions) => import("@pixerate/editor/canvas").CombineShapeNodesResult<any>;
53
53
  canCombineShapes: (ids?: Iterable<string>) => boolean;
54
+ offsetShapes(distance: number, ids?: Iterable<string>, offsetOptions?: import("@pixerate/editor/canvas").OffsetShapeNodesOptions): import("@pixerate/editor/canvas").ShapePathEditResult<any>;
55
+ canOffsetShapes: (ids?: Iterable<string>) => boolean;
56
+ outlineStroke(ids?: Iterable<string>, outlineOptions?: import("@pixerate/editor/canvas").OutlineShapeStrokesOptions): import("@pixerate/editor/canvas").ShapePathEditResult<any>;
57
+ canOutlineStroke: (ids?: Iterable<string>) => boolean;
54
58
  runAction(action: CanvasArrangeAction): boolean;
55
59
  beginDrag(ids?: Iterable<string>): void;
56
60
  drag(ids?: Iterable<string>): import("@pixerate/editor/canvas").SnapNodeDragResult | null;
@@ -1 +1 @@
1
- {"version":3,"file":"createCanvasArrange.svelte.d.ts","sourceRoot":"","sources":["../../src/canvas/createCanvasArrange.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,EACnC,KAAK,SAAS,EACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI7C,KAAK,WAAW,GAAG,8BAA8B,CAAC,GAAG,CAAC,CAAC;AAEvD,MAAM,WAAW,0BAA0B,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU,CAChF,SAAQ,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,UAAU,GAAG,gBAAgB,CAAC;IACrE,QAAQ,EAAE,MAAM,KAAK,EAAE,CAAC;IACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;IACnC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;CAC/C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU,EACxE,OAAO,EAAE,0BAA0B,CAAC,KAAK,CAAC;;IAkBzC;;;;;OAKG;wBACiB,MAAM;;;;;;;;;;sBAoDwv0D,CAAC;sBAAiE,CAAC;sBAAiE,CAAC;oBAA+D,CAAC;cAAyD,CAAC;gBAAiD,CAAC;;;;;;;;;0BAA8tC,CAAC;;;;;;;;;;EAxCny3D;AAED,MAAM,MAAM,aAAa,CAAC,KAAK,SAAS,UAAU,GAA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AAS,UAAU,GAAG,UAAU,CACnF,SAAQ,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,UAAU,GAAG,gBAAgB,CAAC;IACrE,QAAQ,EAAE,MAAM,KAAK,EAAE,CAAC;IACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;IACnC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;CAC/C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU,EAAE,OAAO,EAAE,6BAA6B,CAAC,KAAK,CAAC;;;IA+BzH,2FAA2F;kBAC7E,OAAO,SAAS,kBAAkB,WAAW,OAAO,EAAE,GAAG,OAAO,EAAE;IAKhF,gFAAgF;0BAC1D,QAAQ,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAIjE,4EAA4E;iBAC/D,MAAM;IAInB;;;OAGG;wBACiB,MAAM;;;;;;;;aAiBsg/F,CAAC;;;;aAAiX,CAAC;cAAwB,CAAC;;;;;;;;;;gBAAqrD,CAAC;;;;EAHnmjG;AAED,MAAM,MAAM,gBAAgB,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU,IAAI,UAAU,CAAC,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { type CanvasComponentsControllerOptions } from '@pixerate/editor/canvas';
2
+ import type { CanvasNode } from './types.js';
3
+ type CoreOptions = CanvasComponentsControllerOptions<any>;
4
+ export interface CreateCanvasComponentsOptions<TNode extends CanvasNode = CanvasNode> extends Omit<CoreOptions, 'getNodes' | 'setNodes' | 'onReveal'> {
5
+ getNodes: () => TNode[];
6
+ setNodes: (nodes: TNode[]) => void;
7
+ /** Called by `goToMainComponent` with the main (e.g. to pan the viewport to it). */
8
+ onReveal?: (node: TNode) => void;
9
+ /**
10
+ * Sync instances with their mains whenever the nodes `getNodes` reads change (default
11
+ * `true`; needs `getNodes` to read reactive state). Otherwise call `sync()` after edits.
12
+ */
13
+ autoSync?: boolean;
14
+ }
15
+ /**
16
+ * Headless Svelte 5 rune for Figma-style components and instances on a SvelteFlow canvas.
17
+ * After node changes it records edits inside instances as overrides and rebuilds the
18
+ * instances of edited main components (keeping overrides). Its actions (`createComponent`,
19
+ * `createInstance`, `combineAsVariants`, `detachInstance`, `resetOverrides`, `pushOverrides`,
20
+ * `swapInstance`, `setInstanceProperties`, `restoreMainComponent`, …) are undoable steps with a
21
+ * `history`, and each has a `can…` check returning `true` or the reason it can't run. Call
22
+ * `destroy()` to stop the automatic sync.
23
+ */
24
+ export declare function createCanvasComponents<TNode extends CanvasNode = CanvasNode>(options: CreateCanvasComponentsOptions<TNode>): {
25
+ /** Stops the automatic sync. */
26
+ destroy(): void;
27
+ sync: () => any[];
28
+ syncAll(): any[];
29
+ createComponent(ids?: Iterable<string>, createOptions?: Omit<import("@pixerate/editor/canvas").CreateCanvasComponentOptions, keyof import("@pixerate/editor/canvas").CanvasComponentSyncOptions>): import("@pixerate/editor/canvas").CanvasComponentResult<any>;
30
+ canCreateComponent: (ids?: Iterable<string>) => string | true;
31
+ combineAsVariants(ids?: Iterable<string>, combineOptions?: {
32
+ id?: string;
33
+ name?: string;
34
+ padding?: number;
35
+ }): import("@pixerate/editor/canvas").CanvasComponentResult<any>;
36
+ canCombineAsVariants: (ids?: Iterable<string>) => string | true;
37
+ createInstance(componentId: string, createOptions?: Omit<import("@pixerate/editor/canvas").CreateCanvasInstanceOptions, keyof import("@pixerate/editor/canvas").CanvasComponentSyncOptions>): import("@pixerate/editor/canvas").CanvasComponentResult<any>;
38
+ canCreateInstance(componentId?: string, parentId?: string): true | string;
39
+ detachInstance(ids?: Iterable<string>): import("@pixerate/editor/canvas").CanvasComponentResult<any>;
40
+ canDetachInstance(ids?: Iterable<string>): true | string;
41
+ resetOverrides(id?: string, group?: string): import("@pixerate/editor/canvas").CanvasComponentResult<any>;
42
+ canResetOverrides(id?: string): true | string;
43
+ pushOverrides(id?: string): import("@pixerate/editor/canvas").CanvasComponentResult<any>;
44
+ canPushOverrides(id?: string): true | string;
45
+ swapInstance(componentId: string, ids?: Iterable<string>, swapOptions?: {
46
+ keepTextOverridesOnly?: boolean;
47
+ }): import("@pixerate/editor/canvas").CanvasComponentResult<any>;
48
+ canSwapInstance(componentId?: string, ids?: Iterable<string>): true | string;
49
+ setInstanceProperties(properties: Record<string, unknown>, ids?: Iterable<string>): import("@pixerate/editor/canvas").CanvasComponentResult<any>;
50
+ canSetInstanceProperties(ids?: Iterable<string>): true | string;
51
+ restoreMainComponent(id?: string): import("@pixerate/editor/canvas").CanvasComponentResult<any>;
52
+ canRestoreMainComponent(id?: string): true | string;
53
+ setComponentProperty(componentId: string, name: string, def: import("@pixerate/editor/canvas").CanvasComponentPropertyDef | null, propertyOptions?: {
54
+ newName?: string;
55
+ }): import("@pixerate/editor/canvas").CanvasComponentResult<any>;
56
+ bindComponentProperty(layerId: string, field: import("@pixerate/editor/canvas").CanvasComponentPropertyField, name: string | null): import("@pixerate/editor/canvas").CanvasComponentResult<any>;
57
+ goToMainComponent(id?: string): string | undefined;
58
+ canGoToMainComponent(id?: string): true | string;
59
+ list: () => {
60
+ components: import("@pixerate/editor/canvas").CanvasComponentInfo[];
61
+ sets: import("@pixerate/editor/canvas").CanvasComponentSetInfo[];
62
+ };
63
+ inspect: (id?: string) => import("@pixerate/editor/canvas").CanvasInstanceInfo | undefined;
64
+ rootInstanceOf: (id: string) => string | undefined;
65
+ };
66
+ export type CanvasComponents = ReturnType<typeof createCanvasComponents>;
67
+ export {};
68
+ //# sourceMappingURL=createCanvasComponents.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createCanvasComponents.svelte.d.ts","sourceRoot":"","sources":["../../src/canvas/createCanvasComponents.svelte.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,iCAAiC,EACtC,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI7C,KAAK,WAAW,GAAG,iCAAiC,CAAC,GAAG,CAAC,CAAC;AAE1D,MAAM,WAAW,6BAA6B,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU,CACnF,SAAQ,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;IAC/D,QAAQ,EAAE,MAAM,KAAK,EAAE,CAAC;IACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;IACnC,oFAAoF;IACpF,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU,EAAE,OAAO,EAAE,6BAA6B,CAAC,KAAK,CAAC;IAazH,gCAAgC;;;;;4BAS8wpK,CAAC;;UAAmM,CAAC;YAAsB,CAAC;eAAyB,CAAC;;8BAA8E,CAAC;;;;;;;;;;6BAA4nC,CAAC;;;;;;;;eAA6yB,CAAC;;;;;;;;;gBAAyvB,CAAC;;EAHzxvK;AAED,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC"}