@heyramzi/ui 2.9.0 → 2.10.1

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 (313) hide show
  1. package/dist/agents/helpers.js +52 -0
  2. package/dist/agents/index.js +3 -0
  3. package/dist/agents/page-state.js +65 -0
  4. package/dist/agents/types.js +1 -0
  5. package/dist/agents/vendor/color.js +149 -0
  6. package/dist/agents/vendor/draw.js +548 -0
  7. package/dist/agents/vendor/engine.js +632 -0
  8. package/dist/agents/vendor/mesh.js +727 -0
  9. package/dist/agents/vendor/plastic.js +3273 -0
  10. package/dist/agents/vendor/presets.js +171 -0
  11. package/dist/agents/vendor/shapes.js +24 -0
  12. package/dist/agents/vendor/ticker.js +56 -0
  13. package/dist/agents/vendor/types.js +0 -0
  14. package/dist/agents/vendor/wear.js +1525 -0
  15. package/dist/ai/ai-button/index.js +2 -0
  16. package/dist/ai/confirmation/confirmation-context.svelte.js +12 -0
  17. package/dist/ai/confirmation/index.js +9 -0
  18. package/dist/ai/generation-progress/index.js +2 -0
  19. package/dist/ai/index.js +11 -0
  20. package/dist/ai/loading-state/index.js +3 -0
  21. package/dist/ai/prompt-input/index.js +6 -0
  22. package/dist/ai/reasoning/index.js +4 -0
  23. package/dist/ai/reasoning/reasoning-context.svelte.js +12 -0
  24. package/dist/ai/response/index.js +3 -0
  25. package/dist/ai/suggestion/index.js +3 -0
  26. package/dist/ai/thinking-dots/index.js +3 -0
  27. package/dist/ai/typing-dots/index.js +2 -0
  28. package/dist/ai/voice-waveform/index.js +3 -0
  29. package/dist/animations/text-swap.js +30 -0
  30. package/dist/brand/index.js +65 -0
  31. package/dist/canvas/card/resize.js +10 -0
  32. package/dist/canvas/edges/edge-path.js +284 -0
  33. package/dist/canvas/editor/context-menu.js +42 -0
  34. package/dist/canvas/editor/dispatch.svelte.js +157 -0
  35. package/dist/canvas/editor/editor-context.js +8 -0
  36. package/dist/canvas/editor/editor-mode.js +0 -0
  37. package/dist/canvas/editor/frame.js +87 -0
  38. package/dist/canvas/editor/hand-context.js +8 -0
  39. package/dist/canvas/editor/history-core.js +221 -0
  40. package/dist/canvas/editor/keymap.js +193 -0
  41. package/dist/canvas/editor/layout-actions.js +170 -0
  42. package/dist/canvas/editor/lock.js +65 -0
  43. package/dist/canvas/editor/rebase.js +279 -0
  44. package/dist/canvas/editor/style.js +174 -0
  45. package/dist/canvas/editor/text-field-context.js +8 -0
  46. package/dist/canvas/editor/z-order.js +82 -0
  47. package/dist/canvas/headless/alignment.js +20 -0
  48. package/dist/canvas/headless/break-apart-find.js +324 -0
  49. package/dist/canvas/headless/break-apart-pieces.js +74 -0
  50. package/dist/canvas/headless/break-apart-plan.js +378 -0
  51. package/dist/canvas/headless/break-apart-style.js +93 -0
  52. package/dist/canvas/headless/break-apart.js +206 -0
  53. package/dist/canvas/headless/canvas-cleanup.js +70 -0
  54. package/dist/canvas/headless/edge-anchors.js +134 -0
  55. package/dist/canvas/headless/edge-memo.js +28 -0
  56. package/dist/canvas/headless/edge-serialization.js +31 -0
  57. package/dist/canvas/headless/figure-geometry.js +331 -0
  58. package/dist/canvas/headless/fit-viewport.js +82 -0
  59. package/dist/canvas/headless/grid.js +96 -0
  60. package/dist/canvas/headless/icon-node.js +45 -0
  61. package/dist/canvas/headless/index.js +1 -0
  62. package/dist/canvas/headless/linkify.js +25 -0
  63. package/dist/canvas/headless/pen-marks.js +115 -0
  64. package/dist/canvas/headless/sketch.js +250 -0
  65. package/dist/canvas/headless/snap-guides.js +100 -0
  66. package/dist/canvas/headless/svg-figure.js +137 -0
  67. package/dist/canvas/headless/table-layout.js +161 -0
  68. package/dist/canvas/index.js +25 -0
  69. package/dist/canvas/lod/lod-mode.svelte.js +22 -0
  70. package/dist/canvas/lod/render-all.svelte.js +45 -0
  71. package/dist/canvas/ops/arrange.js +83 -0
  72. package/dist/canvas/ops/ops.js +318 -0
  73. package/dist/canvas/pen/colors.js +41 -0
  74. package/dist/canvas/pen/eraser.js +35 -0
  75. package/dist/canvas/pen/geometry.js +143 -0
  76. package/dist/canvas/pen/index.js +9 -0
  77. package/dist/canvas/pen/ops.js +15 -0
  78. package/dist/canvas/pen/pen-session.js +171 -0
  79. package/dist/canvas/pen/plugin.js +129 -0
  80. package/dist/canvas/pen/shapes.js +80 -0
  81. package/dist/canvas/pen/stroke-path.js +37 -0
  82. package/dist/canvas/pen/types.js +30 -0
  83. package/dist/canvas/pen/ui.js +20 -0
  84. package/dist/canvas/plugin.js +51 -0
  85. package/dist/canvas/screen/glyphs.js +24 -0
  86. package/dist/canvas/screen/labels.js +24 -0
  87. package/dist/canvas/screen/parts.js +140 -0
  88. package/dist/canvas/screen/plugin.js +71 -0
  89. package/dist/canvas/screen/types.js +44 -0
  90. package/dist/canvas/screen/ui.js +13 -0
  91. package/dist/canvas/test-utils.js +18 -0
  92. package/dist/canvas/types.js +0 -0
  93. package/dist/canvas/ui/forward-wheel.js +27 -0
  94. package/dist/canvas/ui/icons.js +133 -0
  95. package/dist/canvas/ui/place-panel.js +57 -0
  96. package/dist/canvas/ui/shortcut-tip.js +18 -0
  97. package/dist/canvas/ui/tools.js +411 -0
  98. package/dist/charts/dashboard/chart.js +1 -0
  99. package/dist/charts/dashboard/data-table.js +7 -0
  100. package/dist/charts/dashboard/index.js +13 -0
  101. package/dist/charts/dashboard/windows.js +5 -0
  102. package/dist/charts/edge-fade.js +7 -0
  103. package/dist/charts/hover-band.js +13 -0
  104. package/dist/charts/index.js +19 -0
  105. package/dist/charts/motion.js +15 -0
  106. package/dist/charts/primitives/chart-utils.js +22 -0
  107. package/dist/charts/primitives/index.js +4 -0
  108. package/dist/components/copy/clipboard.js +38 -0
  109. package/dist/components/copy/copied.svelte.js +26 -0
  110. package/dist/components/copy/index.js +3 -0
  111. package/dist/components/data-table/data-table.js +55 -0
  112. package/dist/components/data-table/index.js +7 -0
  113. package/dist/components/docs/index.js +3 -0
  114. package/dist/components/docs/scroll-spy.svelte.js +71 -0
  115. package/dist/components/field-row/index.js +1 -0
  116. package/dist/components/hold-to-confirm/index.js +1 -0
  117. package/dist/components/icon/index.js +1 -0
  118. package/dist/components/language-flag/index.js +1 -0
  119. package/dist/components/list-page/filter-section.js +4 -0
  120. package/dist/components/list-page/index.js +25 -0
  121. package/dist/components/list-page/list-table.js +5 -0
  122. package/dist/components/list-page/queue-rail.js +3 -0
  123. package/dist/components/list-page/section-host.js +8 -0
  124. package/dist/components/list-page/step.js +5 -0
  125. package/dist/components/list-page/types.js +0 -0
  126. package/dist/components/locale-switch/index.js +1 -0
  127. package/dist/components/mark/index.js +1 -0
  128. package/dist/components/open-in/index.js +1 -0
  129. package/dist/components/picker/index.js +3 -0
  130. package/dist/components/picker/trigger.js +33 -0
  131. package/dist/components/picker/types.js +0 -0
  132. package/dist/components/section-card/index.js +1 -0
  133. package/dist/components/section-header/index.js +2 -0
  134. package/dist/components/segmented/collapse.js +32 -0
  135. package/dist/components/segmented/index.js +8 -0
  136. package/dist/components/segmented/segmented.js +50 -0
  137. package/dist/components/star-rating-input/index.js +2 -0
  138. package/dist/components/svg/index.js +1 -0
  139. package/dist/components/table-view/index.js +1 -0
  140. package/dist/components/table-view/types.js +0 -0
  141. package/dist/components/tags-input/index.js +2 -0
  142. package/dist/components/tags-input/tags.js +90 -0
  143. package/dist/components/theme/index.js +3 -0
  144. package/dist/components/toolbar/index.js +3 -0
  145. package/dist/components/toolbar/toolbar-trigger.js +4 -0
  146. package/dist/editor/anchors.js +17 -0
  147. package/dist/editor/block-id.js +62 -0
  148. package/dist/editor/block-ops.js +105 -0
  149. package/dist/editor/doc-blocks.js +181 -0
  150. package/dist/editor/extensions.js +200 -0
  151. package/dist/editor/index.js +4 -0
  152. package/dist/editor/markdown-test-helpers.js +6 -0
  153. package/dist/editor/markdown.js +486 -0
  154. package/dist/editor/serializer.js +268 -0
  155. package/dist/editor/slash-items.js +104 -0
  156. package/dist/editor/youtube-url.js +27 -0
  157. package/dist/effects/animated-beam/index.js +1 -0
  158. package/dist/effects/animated-beam/path-calculator.svelte.js +42 -0
  159. package/dist/effects/animated-beam/types.js +0 -0
  160. package/dist/effects/border-beam/css.js +420 -0
  161. package/dist/effects/border-beam/presets.js +1792 -0
  162. package/dist/effects/border-beam/register-properties.js +39 -0
  163. package/dist/effects/border-beam/types.js +0 -0
  164. package/dist/effects/image-comparison/compare.js +4 -0
  165. package/dist/effects/image-reveal/index.js +1 -0
  166. package/dist/effects/image-reveal/types.js +0 -0
  167. package/dist/effects/magnetic/magnetic.js +54 -0
  168. package/dist/effects/reveal/index.js +4 -0
  169. package/dist/effects/reveal/observe.js +43 -0
  170. package/dist/effects/reveal/types.js +0 -0
  171. package/dist/effects/shader-gradient/color.js +34 -0
  172. package/dist/effects/shader-gradient/index.js +1 -0
  173. package/dist/effects/shader-gradient/renderer.js +320 -0
  174. package/dist/effects/shader-gradient/shaders.js +280 -0
  175. package/dist/effects/shader-gradient/types.js +0 -0
  176. package/dist/icons/apple-symbol-exports.js +126 -0
  177. package/dist/icons/sf-symbols.js +465 -0
  178. package/dist/icons/trades.js +34 -0
  179. package/dist/inbox/index.js +4 -0
  180. package/dist/inbox/logic.js +156 -0
  181. package/dist/inbox/types.js +46 -0
  182. package/dist/index.js +18 -0
  183. package/dist/lib/arrive.js +13 -0
  184. package/dist/lib/icon-types.js +0 -0
  185. package/dist/lib/initials.js +17 -0
  186. package/dist/lib/layout.js +1 -0
  187. package/dist/lib/panel.js +3 -0
  188. package/dist/lib/result.js +26 -0
  189. package/dist/lib/sliding-pill.js +45 -0
  190. package/dist/lib/theme-transition.js +53 -0
  191. package/dist/lib/tone.js +32 -0
  192. package/dist/lib/utils.js +5 -0
  193. package/dist/onboarding/define-tours.js +28 -0
  194. package/dist/onboarding/index.js +4 -0
  195. package/dist/onboarding/onboarding.svelte.js +15 -0
  196. package/dist/onboarding/pick.js +16 -0
  197. package/dist/onboarding/stores.js +50 -0
  198. package/dist/onboarding/types.js +1 -0
  199. package/dist/onboarding/wait.js +25 -0
  200. package/dist/panel/index.js +1 -0
  201. package/dist/panel/side-panel-types.js +0 -0
  202. package/dist/record/demo-data.js +512 -0
  203. package/dist/record/fields.js +148 -0
  204. package/dist/record/format.js +97 -0
  205. package/dist/record/gutter.js +1 -0
  206. package/dist/record/index.js +15 -0
  207. package/dist/record/kinds.js +110 -0
  208. package/dist/record/logic.js +255 -0
  209. package/dist/record/types.js +52 -0
  210. package/dist/shadcn/accordion/index.js +5 -0
  211. package/dist/shadcn/alert/index.js +5 -0
  212. package/dist/shadcn/alert-dialog/index.js +12 -0
  213. package/dist/shadcn/attachment/index.js +10 -0
  214. package/dist/shadcn/avatar/index.js +7 -0
  215. package/dist/shadcn/badge/index.js +2 -0
  216. package/dist/shadcn/breadcrumb/index.js +8 -0
  217. package/dist/shadcn/bubble/index.js +5 -0
  218. package/dist/shadcn/button/index.js +2 -0
  219. package/dist/shadcn/calendar/index.js +19 -0
  220. package/dist/shadcn/card/index.js +8 -0
  221. package/dist/shadcn/checkbox/index.js +2 -0
  222. package/dist/shadcn/code-block/index.js +9 -0
  223. package/dist/shadcn/collapsible/index.js +4 -0
  224. package/dist/shadcn/command/index.js +13 -0
  225. package/dist/shadcn/context-menu/index.js +17 -0
  226. package/dist/shadcn/dialog/index.js +11 -0
  227. package/dist/shadcn/dropdown-menu/index.js +19 -0
  228. package/dist/shadcn/dropdown-menu/menu-item.js +23 -0
  229. package/dist/shadcn/empty/index.js +7 -0
  230. package/dist/shadcn/field/index.js +12 -0
  231. package/dist/shadcn/hooks/highlighter.js +92 -0
  232. package/dist/shadcn/hooks/is-mobile.svelte.js +7 -0
  233. package/dist/shadcn/hooks/use-highlighted-code.svelte.js +65 -0
  234. package/dist/shadcn/hover-card/index.js +5 -0
  235. package/dist/shadcn/input/index.js +3 -0
  236. package/dist/shadcn/input-otp/index.js +5 -0
  237. package/dist/shadcn/kbd/index.js +3 -0
  238. package/dist/shadcn/label/index.js +2 -0
  239. package/dist/shadcn/marker/index.js +4 -0
  240. package/dist/shadcn/message/index.js +7 -0
  241. package/dist/shadcn/message-scroller/index.js +8 -0
  242. package/dist/shadcn/popover/index.js +9 -0
  243. package/dist/shadcn/progress/index.js +2 -0
  244. package/dist/shadcn/progress/tone.js +11 -0
  245. package/dist/shadcn/radio-group/index.js +3 -0
  246. package/dist/shadcn/scroll-area/index.js +3 -0
  247. package/dist/shadcn/select/index.js +12 -0
  248. package/dist/shadcn/separator/index.js +2 -0
  249. package/dist/shadcn/sheet/index.js +11 -0
  250. package/dist/shadcn/sidebar/constants.js +6 -0
  251. package/dist/shadcn/sidebar/context.svelte.js +38 -0
  252. package/dist/shadcn/sidebar/index.js +25 -0
  253. package/dist/shadcn/skeleton/index.js +2 -0
  254. package/dist/shadcn/slider/index.js +2 -0
  255. package/dist/shadcn/sonner/index.js +1 -0
  256. package/dist/shadcn/spinner/index.js +1 -0
  257. package/dist/shadcn/switch/index.js +2 -0
  258. package/dist/shadcn/table/index.js +9 -0
  259. package/dist/shadcn/tabs/index.js +5 -0
  260. package/dist/shadcn/textarea/index.js +2 -0
  261. package/dist/shadcn/toggle/index.js +3 -0
  262. package/dist/shadcn/toggle-group/index.js +3 -0
  263. package/dist/shadcn/tooltip/context.js +8 -0
  264. package/dist/shadcn/tooltip/index.js +6 -0
  265. package/dist/shadcn/trace/index.js +9 -0
  266. package/dist/slides/bridges.js +66 -0
  267. package/dist/slides/deck-controller.svelte.js +221 -0
  268. package/dist/slides/export/capture.js +81 -0
  269. package/dist/slides/export/ffmpeg.js +85 -0
  270. package/dist/slides/export/index.js +4 -0
  271. package/dist/slides/export/launch.js +8 -0
  272. package/dist/slides/export/pdf.js +78 -0
  273. package/dist/slides/export/types.js +0 -0
  274. package/dist/slides/index.js +7 -0
  275. package/dist/slides/labels.js +26 -0
  276. package/dist/slides/layout.js +47 -0
  277. package/dist/slides/model.js +9 -0
  278. package/dist/slides/navigation.js +89 -0
  279. package/dist/slides/types.js +6 -0
  280. package/dist/status/define-statuses.js +16 -0
  281. package/dist/status/index.js +4 -0
  282. package/dist/status/status-types.js +0 -0
  283. package/dist/test-setup.js +26 -0
  284. package/dist/thread/index.js +3 -0
  285. package/dist/thread/logic.js +94 -0
  286. package/dist/thread/types.js +23 -0
  287. package/dist/work/board-order.js +109 -0
  288. package/dist/work/dates.js +19 -0
  289. package/dist/work/detail/detail-types.js +20 -0
  290. package/dist/work/docs/edited.js +39 -0
  291. package/dist/work/docs/index.js +7 -0
  292. package/dist/work/docs/labels.js +38 -0
  293. package/dist/work/docs/menu.js +121 -0
  294. package/dist/work/docs/outline.js +39 -0
  295. package/dist/work/gantt/logic.js +260 -0
  296. package/dist/work/inbox/inbox-logic.js +94 -0
  297. package/dist/work/inbox/inbox-statuses.js +86 -0
  298. package/dist/work/inbox/inbox-types.js +0 -0
  299. package/dist/work/inbox/index.js +1 -0
  300. package/dist/work/index.js +21 -0
  301. package/dist/work/kanban-drag.js +25 -0
  302. package/dist/work/kanban-types.js +0 -0
  303. package/dist/work/presets/sales.js +35 -0
  304. package/dist/work/reorder.js +10 -0
  305. package/dist/work/task-types.js +0 -0
  306. package/dist/work/time/duration.js +60 -0
  307. package/dist/work/time/time-types.js +25 -0
  308. package/dist/work/use-kanban-dnd.svelte.js +128 -0
  309. package/package.json +45 -3
  310. package/src/components/toolbar/toolbar-trigger.ts +8 -2
  311. package/src/record/demo-data.ts +4 -4
  312. package/src/record/record-demo.svelte +2 -2
  313. package/src/status/status-dot.svelte +0 -2
@@ -0,0 +1,140 @@
1
+ import { MAX_LABEL, MAX_LIST_ITEMS, MAX_PARTS, PART_DEFAULTS, PART_KINDS, SCREEN_MODES, SCREEN_NODE, SCREEN_WIDTH } from "./types.js";
2
+ const isKind = (value)=>typeof value === "string" && PART_KINDS.includes(value);
3
+ const text = (value, fallback = "")=>typeof value === "string" ? value.slice(0, MAX_LABEL) : fallback;
4
+ export function nextPartId(parts) {
5
+ const taken = new Set(parts.map((part)=>part.id));
6
+ let n = parts.length + 1;
7
+ while(taken.has(`p${n}`))n += 1;
8
+ return `p${n}`;
9
+ }
10
+ export function createPart(kind, parts, seed = {}) {
11
+ const base = PART_DEFAULTS[kind];
12
+ const part = {
13
+ ...base,
14
+ ...seed,
15
+ id: nextPartId(parts),
16
+ kind
17
+ };
18
+ if (part.items) part.items = [
19
+ ...part.items
20
+ ];
21
+ return part;
22
+ }
23
+ function uniquePartId(raw, parts, seen) {
24
+ const id = typeof raw === "string" && raw ? raw : "";
25
+ const unique = !id || seen.has(id) ? nextPartId(parts) : id;
26
+ seen.add(unique);
27
+ return unique;
28
+ }
29
+ function kindFields(kind, part) {
30
+ if (kind === "list") {
31
+ const items = Array.isArray(part.items) ? part.items : PART_DEFAULTS.list.items;
32
+ return {
33
+ items: (items ?? []).slice(0, MAX_LIST_ITEMS).map((item)=>text(item))
34
+ };
35
+ }
36
+ if (kind === "modal") return {
37
+ text: text(part.text, PART_DEFAULTS.modal.text)
38
+ };
39
+ if (kind === "button") return {
40
+ variant: part.variant === "secondary" ? "secondary" : "primary"
41
+ };
42
+ return {};
43
+ }
44
+ function normalizePart(entry, parts, seen) {
45
+ const part = entry ?? {};
46
+ if (!isKind(part.kind)) return null;
47
+ const kind = part.kind;
48
+ const id = uniquePartId(part.id, parts, seen);
49
+ return {
50
+ id,
51
+ kind,
52
+ label: text(part.label, PART_DEFAULTS[kind].label),
53
+ ...kindFields(kind, part)
54
+ };
55
+ }
56
+ export function normalizeScreen(data) {
57
+ const raw = data ?? {};
58
+ const seen = new Set();
59
+ const parts = [];
60
+ const rawParts = Array.isArray(raw.parts) ? raw.parts : [];
61
+ for (const entry of rawParts.slice(0, MAX_PARTS)){
62
+ const next = normalizePart(entry, parts, seen);
63
+ if (next) parts.push(next);
64
+ }
65
+ return {
66
+ label: text(raw.label),
67
+ mode: SCREEN_MODES.includes(raw.mode) ? raw.mode : "wireframe",
68
+ parts
69
+ };
70
+ }
71
+ export function addPart(parts, kind, seed, index = parts.length) {
72
+ if (parts.length >= MAX_PARTS) return [
73
+ ...parts
74
+ ];
75
+ const at = Math.max(0, Math.min(index, parts.length));
76
+ return [
77
+ ...parts.slice(0, at),
78
+ createPart(kind, parts, seed),
79
+ ...parts.slice(at)
80
+ ];
81
+ }
82
+ export function removePart(parts, id) {
83
+ return parts.filter((part)=>part.id !== id);
84
+ }
85
+ export function movePart(parts, id, step) {
86
+ const from = parts.findIndex((part)=>part.id === id);
87
+ const to = from + step;
88
+ if (from < 0 || to < 0 || to >= parts.length) return [
89
+ ...parts
90
+ ];
91
+ const next = [
92
+ ...parts
93
+ ];
94
+ [next[from], next[to]] = [
95
+ next[to],
96
+ next[from]
97
+ ];
98
+ return next;
99
+ }
100
+ export function patchPart(parts, id, patch) {
101
+ return parts.map((part)=>part.id === id ? {
102
+ ...part,
103
+ ...patch
104
+ } : part);
105
+ }
106
+ export function setItem(items, index, value) {
107
+ return items.map((item, i)=>i === index ? value : item);
108
+ }
109
+ export function addItem(items) {
110
+ return items.length >= MAX_LIST_ITEMS ? [
111
+ ...items
112
+ ] : [
113
+ ...items,
114
+ "Item"
115
+ ];
116
+ }
117
+ export function removeItem(items, index) {
118
+ return items.filter((_, i)=>i !== index);
119
+ }
120
+ export function buildScreenNode(options) {
121
+ let parts = [];
122
+ for (const entry of options.parts ?? []){
123
+ const { kind, ...seed } = entry;
124
+ parts = addPart(parts, kind, seed);
125
+ }
126
+ const data = normalizeScreen({
127
+ label: options.label,
128
+ mode: options.mode,
129
+ parts
130
+ });
131
+ return {
132
+ id: options.id,
133
+ type: SCREEN_NODE,
134
+ position: options.position,
135
+ data,
136
+ style: {
137
+ width: options.width ?? SCREEN_WIDTH
138
+ }
139
+ };
140
+ }
@@ -0,0 +1,71 @@
1
+ import { z } from "zod";
2
+ import { CanvasOpError } from "../ops/ops.js";
3
+ import { definePlugin } from "../plugin.js";
4
+ import { buildScreenNode } from "./parts.js";
5
+ import { MAX_LABEL, MAX_LIST_ITEMS, MAX_PARTS, PART_KINDS, SCREEN_MODES, SCREEN_NODE, SCREEN_WIDTH } from "./types.js";
6
+ const partSchema = z.object({
7
+ kind: z.enum(PART_KINDS),
8
+ label: z.string().max(MAX_LABEL).optional(),
9
+ items: z.array(z.string().max(MAX_LABEL)).max(MAX_LIST_ITEMS).optional(),
10
+ text: z.string().max(MAX_LABEL).optional(),
11
+ variant: z.enum([
12
+ "primary",
13
+ "secondary"
14
+ ]).optional()
15
+ });
16
+ const addScreenOp = z.object({
17
+ kind: z.literal("addScreen"),
18
+ id: z.string().min(1).optional(),
19
+ at: z.object({
20
+ x: z.number(),
21
+ y: z.number()
22
+ }),
23
+ label: z.string().max(MAX_LABEL).optional(),
24
+ mode: z.enum(SCREEN_MODES).optional(),
25
+ parts: z.array(partSchema).max(MAX_PARTS).optional(),
26
+ width: z.number().positive().optional()
27
+ });
28
+ function applyAddScreen(state, op, opIndex) {
29
+ const id = op.id ?? crypto.randomUUID();
30
+ if (state.nodes.some((node)=>node.id === id)) {
31
+ throw new CanvasOpError(`Node id already exists: ${id}`, opIndex);
32
+ }
33
+ const node = buildScreenNode({
34
+ id,
35
+ position: op.at,
36
+ label: op.label,
37
+ mode: op.mode,
38
+ parts: op.parts,
39
+ width: op.width
40
+ });
41
+ state.nodes = [
42
+ ...state.nodes,
43
+ node
44
+ ];
45
+ }
46
+ export const screenKind = {
47
+ type: SCREEN_NODE,
48
+ label: "Screen",
49
+ sizing: "content-sized",
50
+ size: {
51
+ width: SCREEN_WIDTH
52
+ },
53
+ createData: ()=>({
54
+ label: "",
55
+ mode: "wireframe",
56
+ parts: []
57
+ })
58
+ };
59
+ export const screenPlugin = definePlugin({
60
+ id: "screen",
61
+ nodes: [
62
+ screenKind
63
+ ],
64
+ ops: [
65
+ {
66
+ kind: "addScreen",
67
+ schema: addScreenOp,
68
+ apply: applyAddScreen
69
+ }
70
+ ]
71
+ });
@@ -0,0 +1,44 @@
1
+ export const SCREEN_NODE = "screen";
2
+ export const SCREEN_WIDTH = 320;
3
+ export const PART_KINDS = [
4
+ "header",
5
+ "button",
6
+ "input",
7
+ "image",
8
+ "list",
9
+ "modal"
10
+ ];
11
+ export const SCREEN_MODES = [
12
+ "wireframe",
13
+ "mockup"
14
+ ];
15
+ export const MAX_PARTS = 24;
16
+ export const MAX_LIST_ITEMS = 12;
17
+ export const MAX_LABEL = 120;
18
+ export const PART_DEFAULTS = {
19
+ header: {
20
+ label: "Title"
21
+ },
22
+ button: {
23
+ label: "Button",
24
+ variant: "primary"
25
+ },
26
+ input: {
27
+ label: "Label"
28
+ },
29
+ image: {
30
+ label: "Image"
31
+ },
32
+ list: {
33
+ label: "List",
34
+ items: [
35
+ "Item",
36
+ "Item",
37
+ "Item"
38
+ ]
39
+ },
40
+ modal: {
41
+ label: "Title",
42
+ text: "Text"
43
+ }
44
+ };
@@ -0,0 +1,13 @@
1
+ import { definePlugin } from "../plugin.js";
2
+ import { screenKind, screenPlugin } from "./plugin.js";
3
+ import ScreenCard from "../../../src/canvas/screen/ScreenCard.svelte";
4
+ export { ScreenCard };
5
+ export const screenUiPlugin = definePlugin({
6
+ ...screenPlugin,
7
+ nodes: [
8
+ {
9
+ ...screenKind,
10
+ component: ScreenCard
11
+ }
12
+ ]
13
+ });
@@ -0,0 +1,18 @@
1
+ export function makeNode(overrides = {}) {
2
+ return {
3
+ id: overrides.id ?? `node-${Math.random().toString(36).slice(2, 8)}`,
4
+ type: "node",
5
+ position: {
6
+ x: 0,
7
+ y: 0
8
+ },
9
+ data: {
10
+ label: "Test Node"
11
+ },
12
+ ...overrides
13
+ };
14
+ }
15
+ export function expectDefined(value, what = "value") {
16
+ if (value === null || value === undefined) throw new Error(`Expected ${what} to be defined`);
17
+ return value;
18
+ }
File without changes
@@ -0,0 +1,27 @@
1
+ export function forwardWheel(node) {
2
+ const handler = (event)=>{
3
+ const zoomPane = node.closest(".svelte-flow")?.querySelector(".svelte-flow__zoom");
4
+ if (!zoomPane) return;
5
+ event.preventDefault();
6
+ zoomPane.dispatchEvent(new WheelEvent("wheel", {
7
+ deltaX: event.deltaX,
8
+ deltaY: event.deltaY,
9
+ deltaZ: event.deltaZ,
10
+ deltaMode: event.deltaMode,
11
+ clientX: event.clientX,
12
+ clientY: event.clientY,
13
+ screenX: event.screenX,
14
+ screenY: event.screenY,
15
+ ctrlKey: event.ctrlKey,
16
+ shiftKey: event.shiftKey,
17
+ altKey: event.altKey,
18
+ metaKey: event.metaKey,
19
+ bubbles: true,
20
+ cancelable: true
21
+ }));
22
+ };
23
+ node.addEventListener("wheel", handler, {
24
+ passive: false
25
+ });
26
+ return ()=>node.removeEventListener("wheel", handler);
27
+ }
@@ -0,0 +1,133 @@
1
+ export const ICON_PATHS = {
2
+ select: [
3
+ "M5 3.5 18.5 10l-5.6 1.9L10.7 17.5z"
4
+ ],
5
+ hand: [
6
+ "M8 13V6.5a1.5 1.5 0 0 1 3 0V11m0-5.5a1.5 1.5 0 0 1 3 0V11m0-4a1.5 1.5 0 0 1 3 0v6.5a6.5 6.5 0 0 1-6.5 6.5h-.4a6 6 0 0 1-4.7-2.3L4.6 14.6a1.5 1.5 0 0 1 2.3-1.9L8 14"
7
+ ],
8
+ pen: [
9
+ "M4 20l1-4L16.5 4.5a2.1 2.1 0 0 1 3 3L8 19z",
10
+ "M14.5 6.5l3 3"
11
+ ],
12
+ highlighter: [
13
+ "M14.5 4.5l5 5-8 8-5 1.5 1-5z",
14
+ "M4 21h16"
15
+ ],
16
+ eraser: [
17
+ "M4.5 15l8.5-8.5a2.1 2.1 0 0 1 3 0l3 3a2.1 2.1 0 0 1 0 3L12 20H8z",
18
+ "M10.5 9l6 6M12 20h8"
19
+ ],
20
+ text: [
21
+ "M5 7V5.5h14V7M12 5.5V19M9 19h6"
22
+ ],
23
+ rectangle: [
24
+ "M6 6h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z"
25
+ ],
26
+ ellipse: [
27
+ "M4 12a8 6 0 1 0 16 0a8 6 0 1 0-16 0"
28
+ ],
29
+ diamond: [
30
+ "M12 4l8 8-8 8-8-8z"
31
+ ],
32
+ frame: [
33
+ "M8 4v16M16 4v16M4 8h16M4 16h16"
34
+ ],
35
+ shapes: [
36
+ "M5 12.5h5a1.5 1.5 0 0 1 1.5 1.5v5a1.5 1.5 0 0 1-1.5 1.5H5A1.5 1.5 0 0 1 3.5 19v-5A1.5 1.5 0 0 1 5 12.5z",
37
+ "M11.5 8a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0-9 0"
38
+ ],
39
+ undo: [
40
+ "M9 14 4 9l5-5M4 9h9.5a6 6 0 0 1 0 12H11"
41
+ ],
42
+ redo: [
43
+ "M15 14l5-5-5-5M20 9h-9.5a6 6 0 0 0 0 12H13"
44
+ ],
45
+ cards: [
46
+ "M7 4h10a3 3 0 0 1 3 3v10a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3z",
47
+ "M12 8.5v7M8.5 12h7"
48
+ ],
49
+ search: [
50
+ "M4.5 11a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0-13 0",
51
+ "M16 16l4 4"
52
+ ],
53
+ note: [
54
+ "M6 4h12a1 1 0 0 1 1 1v9l-5 5H6a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1z",
55
+ "M19 14h-4a1 1 0 0 0-1 1v4"
56
+ ],
57
+ insert: [
58
+ "M12 5v14M5 12h14"
59
+ ],
60
+ connect: [
61
+ "M4.5 4.5a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0-3 0",
62
+ "M6 6v4.5a3 3 0 0 0 3 3h9",
63
+ "M15 10.5l3.5 3-3.5 3"
64
+ ],
65
+ "distribute-h": [
66
+ "M4 4v16M20 4v16",
67
+ "M9 8h6v8H9z"
68
+ ],
69
+ "distribute-v": [
70
+ "M4 4h16M4 20h16",
71
+ "M8 9h8v6H8z"
72
+ ],
73
+ minus: [
74
+ "M5 12h14"
75
+ ],
76
+ more: [
77
+ "M4.8 12a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0",
78
+ "M10.8 12a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0",
79
+ "M16.8 12a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0"
80
+ ],
81
+ "mm-child": [
82
+ "M4.0 8h3.0a1.5 1.5 0 0 1 1.5 1.5v5.0a1.5 1.5 0 0 1-1.5 1.5h-3.0a1.5 1.5 0 0 1-1.5-1.5v-5.0a1.5 1.5 0 0 1 1.5-1.5z",
83
+ "M8.5 12h3.5",
84
+ "M14 7h5.5a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-5.5a2 2 0 0 1-2-2v-6a2 2 0 0 1 2-2z",
85
+ "M16.75 10v4M14.75 12h4"
86
+ ],
87
+ "mm-sibling": [
88
+ "M4 6h2.5M4 17.5h2.5M4 6v11.5",
89
+ "M8.5 3h7a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-7a2 2 0 0 1-2-2v-2a2 2 0 0 1 2-2z",
90
+ "M8.5 14.5h7a2 2 0 0 1 2 2v2.5a2 2 0 0 1-2 2h-7a2 2 0 0 1-2-2v-2.5a2 2 0 0 1 2-2z",
91
+ "M12 15.75v4M10 17.75h4"
92
+ ],
93
+ "mm-line-solid": [
94
+ "M2.5 12a2 2 0 1 0 4 0a2 2 0 1 0-4 0",
95
+ "M6.5 12h11",
96
+ "M17.5 12a2 2 0 1 0 4 0a2 2 0 1 0-4 0"
97
+ ],
98
+ "mm-line-dashed": [
99
+ "M2.5 12a2 2 0 1 0 4 0a2 2 0 1 0-4 0",
100
+ "M7.5 12h2M11 12h2M14.5 12h2",
101
+ "M17.5 12a2 2 0 1 0 4 0a2 2 0 1 0-4 0"
102
+ ],
103
+ "mm-ai": [
104
+ "M10.5 5l1.9 5.1L17.5 12l-5.1 1.9L10.5 19l-1.9-5.1L3.5 12l5.1-1.9z",
105
+ "M18.5 3.5v4M16.5 5.5h4"
106
+ ],
107
+ "mm-map": [
108
+ "M9 10h6v4H9z",
109
+ "M9 12C6 12 6 6 3 6M9 12c-3 0-3 6-6 6M15 12c3 0 3-6 6-6M15 12c3 0 3 6 6 6"
110
+ ],
111
+ "mm-right": [
112
+ "M3 10h6v4H3z",
113
+ "M9 12c4 0 4-6 8-6h4M9 12c4 0 4 6 8 6h4"
114
+ ],
115
+ "mm-tree": [
116
+ "M9 3h6v4H9z",
117
+ "M12 7v4M5 11h14M5 11v3M19 11v3M12 11v3",
118
+ "M3 14h4v4H3zM10 14h4v4h-4zM17 14h4v4h-4z"
119
+ ],
120
+ "mm-curve": [
121
+ "M4 18c8 0 8-12 16-12"
122
+ ],
123
+ "mm-elbow": [
124
+ "M4 18h8V6h8"
125
+ ],
126
+ "mm-straight": [
127
+ "M4 18 20 6"
128
+ ],
129
+ "mm-center": [
130
+ "M12 8a4 4 0 1 0 0 8 4 4 0 1 0 0-8z",
131
+ "M12 3v3M12 18v3M3 12h3M18 12h3"
132
+ ]
133
+ };
@@ -0,0 +1,57 @@
1
+ export const CLEARANCE = 20;
2
+ const CHIP_ROOM = 40;
3
+ const INSET = {
4
+ left: 72,
5
+ top: 12,
6
+ right: 12,
7
+ bottom: 76
8
+ };
9
+ const MINIMAP = {
10
+ width: 232,
11
+ height: 172
12
+ };
13
+ export function placeBeside(selection, panel, canvas) {
14
+ const free = {
15
+ left: INSET.left,
16
+ top: INSET.top,
17
+ right: canvas.width - INSET.right,
18
+ bottom: canvas.height - INSET.bottom
19
+ };
20
+ const centreX = (selection.left + selection.right) / 2 - panel.width / 2;
21
+ const centreY = (selection.top + selection.bottom) / 2 - panel.height / 2;
22
+ const floor = (x, width)=>x + width > canvas.width - MINIMAP.width ? canvas.height - MINIMAP.height : free.bottom;
23
+ const clampX = (x)=>Math.min(Math.max(x, free.left), free.right - panel.width);
24
+ const clampY = (y, x)=>Math.min(Math.max(y, free.top), floor(x, panel.width) - panel.height);
25
+ const tries = [
26
+ {
27
+ side: "right",
28
+ x: selection.right + CLEARANCE,
29
+ y: clampY(centreY, selection.right + CLEARANCE),
30
+ fits: selection.right + CLEARANCE + panel.width <= free.right
31
+ },
32
+ {
33
+ side: "left",
34
+ x: selection.left - CLEARANCE - panel.width,
35
+ y: clampY(centreY, selection.left - CLEARANCE - panel.width),
36
+ fits: selection.left - CLEARANCE - panel.width >= free.left
37
+ },
38
+ {
39
+ side: "below",
40
+ x: clampX(centreX),
41
+ y: selection.bottom + CLEARANCE + CHIP_ROOM,
42
+ fits: selection.bottom + CLEARANCE + CHIP_ROOM + panel.height <= floor(clampX(centreX), panel.width)
43
+ },
44
+ {
45
+ side: "above",
46
+ x: clampX(centreX),
47
+ y: selection.top - CLEARANCE - panel.height,
48
+ fits: selection.top - CLEARANCE - panel.height >= free.top
49
+ }
50
+ ];
51
+ const found = tries.find((attempt)=>attempt.fits);
52
+ return found ? {
53
+ x: found.x,
54
+ y: found.y,
55
+ side: found.side
56
+ } : null;
57
+ }
@@ -0,0 +1,18 @@
1
+ const GLYPHS = {
2
+ mod: {
3
+ mac: "⌘",
4
+ other: "Ctrl"
5
+ },
6
+ shift: {
7
+ mac: "⇧",
8
+ other: "Shift"
9
+ }
10
+ };
11
+ export function isMacPlatform() {
12
+ return typeof navigator !== "undefined" && navigator.platform.includes("Mac");
13
+ }
14
+ export function shortcutTip(label, keys, mac = isMacPlatform()) {
15
+ if (keys.length === 0) return label;
16
+ const parts = keys.map((key)=>GLYPHS[key]?.[mac ? "mac" : "other"] ?? key);
17
+ return `${label} ${parts.join(mac ? "" : "+")}`;
18
+ }