@r2digisolutions/components 0.19.21 → 0.20.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 (30) hide show
  1. package/dist/components/atoms/Textarea/Textarea.svelte +4 -0
  2. package/dist/components/atoms/Textarea/Textarea.svelte.d.ts +1 -0
  3. package/dist/components/molecules/CanvasInspector/CanvasInspector.svelte +165 -71
  4. package/dist/components/molecules/Cascader/Cascader.svelte +2 -0
  5. package/dist/components/molecules/ColorPicker/ColorPicker.svelte +4 -13
  6. package/dist/components/molecules/DatePicker/DatePicker.svelte +2 -0
  7. package/dist/components/molecules/DateTimePicker/DateTimePicker.svelte +2 -0
  8. package/dist/components/molecules/DropdownMenu/DropdownMenu.svelte +7 -18
  9. package/dist/components/molecules/MediaLayerItem/MediaLayerItem.svelte +11 -3
  10. package/dist/components/molecules/MediaLayerItem/MediaLayerItem.svelte.d.ts +5 -1
  11. package/dist/components/molecules/MediaLayerList/MediaLayerList.svelte +31 -4
  12. package/dist/components/molecules/MediaStage/MediaStage.svelte +237 -199
  13. package/dist/components/molecules/MediaStage/MediaStage.svelte.d.ts +1 -45
  14. package/dist/components/molecules/MultiSelect/MultiSelect.svelte +2 -0
  15. package/dist/components/molecules/Popover/Popover.svelte +6 -0
  16. package/dist/components/molecules/Select/Select.svelte +36 -14
  17. package/dist/components/molecules/TimePicker/TimePicker.svelte +2 -0
  18. package/dist/components/molecules/TreeSelect/TreeSelect.svelte +2 -0
  19. package/dist/components/molecules/UserMenu/UserMenu.svelte +2 -0
  20. package/dist/components/organisms/CanvasEditor/CanvasEditor.svelte +173 -150
  21. package/dist/components/organisms/Dialog/Dialog.svelte +19 -3
  22. package/dist/components/organisms/NotificationCenter/NotificationCenter.svelte +2 -0
  23. package/dist/components/organisms/PricingTable/PricingTable.svelte +3 -3
  24. package/dist/index.d.ts +2 -1
  25. package/dist/index.js +2 -1
  26. package/dist/utils/canvasHierarchy.d.ts +55 -0
  27. package/dist/utils/canvasHierarchy.js +245 -13
  28. package/dist/utils/popoverInvoker.d.ts +11 -0
  29. package/dist/utils/popoverInvoker.js +39 -0
  30. package/package.json +1 -1
@@ -36,12 +36,19 @@
36
36
  import {
37
37
  deleteSubtree,
38
38
  duplicateSubtree,
39
- groupLayers,
39
+ fitGroupsToChildren,
40
+ getAncestors,
40
41
  isContainerKind,
42
+ isEffectivelyLocked,
43
+ isLayoutPositionLocked,
41
44
  computeAbsoluteRects,
42
45
  contentPadding,
43
46
  reparentLayer,
44
47
  reorderSiblings,
48
+ resolveSlotRect,
49
+ scaleSubtreeAbsolute,
50
+ stepAxis,
51
+ syncSlotFromRect,
45
52
  ungroupLayers,
46
53
  wrapSelection,
47
54
  slotFromLocalRect
@@ -173,9 +180,7 @@
173
180
  ];
174
181
 
175
182
  const editingWidget = $derived(
176
- editingWidgetId
177
- ? ((value.widgets ?? []).find((w) => w.id === editingWidgetId) ?? null)
178
- : null
183
+ editingWidgetId ? ((value.widgets ?? []).find((w) => w.id === editingWidgetId) ?? null) : null
179
184
  );
180
185
 
181
186
  const stageDoc = $derived.by((): CanvasDocument => {
@@ -192,9 +197,7 @@
192
197
  });
193
198
 
194
199
  const selectedLayer = $derived(
195
- selectedIds.length === 1
196
- ? (stageDoc.layers.find((l) => l.id === selectedIds[0]) ?? null)
197
- : null
200
+ selectedIds.length === 1 ? (stageDoc.layers.find((l) => l.id === selectedIds[0]) ?? null) : null
198
201
  );
199
202
  const zoomLabel = $derived(zoom === 1 ? 'Fit' : `${Math.round(zoom * 100)}%`);
200
203
  const presetValue = $derived(presetIdForSize(value.width, value.height));
@@ -298,8 +301,7 @@
298
301
  ];
299
302
 
300
303
  const ctxItems = $derived.by((): ContextMenuItem[] => {
301
- const focusIds =
302
- ctxLayerId && !selectedIds.includes(ctxLayerId) ? [ctxLayerId] : selectedIds;
304
+ const focusIds = ctxLayerId && !selectedIds.includes(ctxLayerId) ? [ctxLayerId] : selectedIds;
303
305
  const hasParent = focusIds.some((id) => {
304
306
  const l = stageDoc.layers.find((x) => x.id === id);
305
307
  return !!l?.parentId;
@@ -421,27 +423,39 @@
421
423
  }
422
424
 
423
425
  function emitStageLayers(layers: CanvasLayer[], extra?: Partial<CanvasDocument>) {
426
+ const width = extra?.width ?? stageDoc.width;
427
+ const height = extra?.height ?? stageDoc.height;
428
+ const fitted = fitGroupsToChildren(layers, { width, height });
424
429
  if (editingWidgetId) {
425
430
  let next = updateWidgetDefinition(value, editingWidgetId, (d) => ({
426
431
  ...d,
427
- layers,
432
+ layers: fitted,
428
433
  width: extra?.width ?? d.width,
429
434
  height: extra?.height ?? d.height,
430
435
  background: extra?.background ?? d.background
431
436
  }));
432
- const sizeChanged =
433
- extra?.width != null || extra?.height != null;
437
+ const sizeChanged = extra?.width != null || extra?.height != null;
434
438
  if (sizeChanged && syncInstanceSizes) {
435
439
  next = syncInstanceSizesToDefinition(next, editingWidgetId);
436
440
  }
437
441
  emit(next);
438
442
  return;
439
443
  }
440
- emit({ ...value, ...extra, layers });
444
+ emit({ ...value, ...extra, layers: fitted });
441
445
  }
442
446
 
443
447
  function patchLayer(layer: CanvasLayer) {
444
- emitStageLayers(stageDoc.layers.map((l) => (l.id === layer.id ? layer : l)));
448
+ const rootSize = { width: stageDoc.width, height: stageDoc.height };
449
+ const prev = stageDoc.layers.find((l) => l.id === layer.id);
450
+ let layers = stageDoc.layers.map((l) => (l.id === layer.id ? layer : l));
451
+ if (prev && layer.kind === 'group') {
452
+ const prevAbs = computeAbsoluteRects(stageDoc.layers, rootSize).get(prev.id) ?? prev.rect;
453
+ const nextAbs = computeAbsoluteRects(layers, rootSize).get(layer.id) ?? layer.rect;
454
+ if (Math.abs(nextAbs.w - prevAbs.w) > 0.5 || Math.abs(nextAbs.h - prevAbs.h) > 0.5) {
455
+ layers = scaleSubtreeAbsolute(stageDoc.layers, layer.id, prevAbs, nextAbs, rootSize);
456
+ }
457
+ }
458
+ emitStageLayers(layers);
445
459
  }
446
460
 
447
461
  function addLayer(layer: CanvasLayer, opts?: { parentId?: string | null }) {
@@ -513,8 +527,7 @@
513
527
  const candidate = stageDoc.layers.find((l) => l.id === selectedIds[0]);
514
528
  if (candidate && isContainerKind(candidate.kind)) nestParentId = candidate.id;
515
529
  }
516
- const nesting =
517
- nestParentId !== undefined ? { parentId: nestParentId } : undefined;
530
+ const nesting = nestParentId !== undefined ? { parentId: nestParentId } : undefined;
518
531
 
519
532
  const fillRootCanvas =
520
533
  def.kind === 'canvasPanel' &&
@@ -585,9 +598,7 @@
585
598
 
586
599
  function addGuide(orientation: 'horizontal' | 'vertical') {
587
600
  const position =
588
- orientation === 'vertical'
589
- ? Math.round(stageDoc.width / 2)
590
- : Math.round(stageDoc.height / 2);
601
+ orientation === 'vertical' ? Math.round(stageDoc.width / 2) : Math.round(stageDoc.height / 2);
591
602
  emit({
592
603
  ...value,
593
604
  guides: [...(value.guides ?? []), createCanvasGuide(orientation, position)]
@@ -599,29 +610,46 @@
599
610
  emit({ ...value, guidesLocked: !value.guidesLocked });
600
611
  }
601
612
 
602
- function nudgeSelected(dx: number, dy: number) {
603
- if (!selectedIds.length) return;
613
+ function parentContentSize(
614
+ layer: CanvasLayer,
615
+ absMap: Map<string, { x: number; y: number; w: number; h: number }>
616
+ ) {
617
+ const parentId = layer.parentId ?? null;
618
+ let bounds = { width: stageDoc.width, height: stageDoc.height };
619
+ if (!parentId) return bounds;
620
+ const parent = stageDoc.layers.find((p) => p.id === parentId);
621
+ const parentAbs = absMap.get(parentId);
622
+ if (parent && parentAbs) {
623
+ const pad = contentPadding(parent);
624
+ bounds = {
625
+ width: Math.max(1, parentAbs.w - pad.left - pad.right),
626
+ height: Math.max(1, parentAbs.h - pad.top - pad.bottom)
627
+ };
628
+ }
629
+ return bounds;
630
+ }
631
+
632
+ function nudgeSelected(dirX: -1 | 0 | 1, dirY: -1 | 0 | 1, coarse: boolean) {
633
+ if (!selectedIds.length || (!dirX && !dirY)) return;
604
634
  const set = new Set(selectedIds);
635
+ const absMap = computeAbsoluteRects(stageDoc.layers, {
636
+ width: stageDoc.width,
637
+ height: stageDoc.height
638
+ });
639
+ const stepOpts = { snap, cell: cellSize, coarse };
605
640
  emitStageLayers(
606
641
  stageDoc.layers.map((l) => {
607
- if (!set.has(l.id) || l.locked) return l;
608
- const x = l.rect.x + dx;
609
- const y = l.rect.y + dy;
610
- const rect = { ...l.rect, x, y };
611
- return {
612
- ...l,
613
- rect,
614
- slot: l.slot
615
- ? {
616
- ...l.slot,
617
- offsets: {
618
- ...l.slot.offsets,
619
- left: l.slot.offsets.left + dx,
620
- top: l.slot.offsets.top + dy
621
- }
622
- }
623
- : defaultSlotFromRect(rect)
642
+ if (!set.has(l.id) || isEffectivelyLocked(stageDoc.layers, l.id)) return l;
643
+ if (getAncestors(stageDoc.layers, l.id).some((a) => set.has(a.id))) return l;
644
+ if (isLayoutPositionLocked(stageDoc.layers, l.id)) return l;
645
+ const bounds = parentContentSize(l, absMap);
646
+ const local = l.slot ? resolveSlotRect(bounds, l.slot) : l.rect;
647
+ const rect = {
648
+ ...local,
649
+ x: dirX ? stepAxis(local.x, dirX, stepOpts) : local.x,
650
+ y: dirY ? stepAxis(local.y, dirY, stepOpts) : local.y
624
651
  };
652
+ return syncSlotFromRect({ ...l, rect }, bounds);
625
653
  })
626
654
  );
627
655
  }
@@ -644,6 +672,8 @@
644
672
  emitStageLayers(
645
673
  stageDoc.layers.map((l) => {
646
674
  if (!set.has(l.id)) return l;
675
+ if (isEffectivelyLocked(stageDoc.layers, l.id)) return l;
676
+ if (isLayoutPositionLocked(stageDoc.layers, l.id)) return l;
647
677
  const parentId = l.parentId ?? null;
648
678
  let bounds = { width: stageDoc.width, height: stageDoc.height };
649
679
  if (parentId) {
@@ -673,19 +703,13 @@
673
703
 
674
704
  function deleteSelected() {
675
705
  if (!selectedIds.length) return;
676
- const next = deleteSubtree(
677
- { ...stageDoc, widgets: value.widgets },
678
- selectedIds
679
- );
706
+ const next = deleteSubtree({ ...stageDoc, widgets: value.widgets }, selectedIds);
680
707
  emitStageLayers(next.layers);
681
708
  selectedIds = [];
682
709
  }
683
710
 
684
711
  function duplicateSelected() {
685
- const result = duplicateSubtree(
686
- { ...stageDoc, widgets: value.widgets },
687
- selectedIds
688
- );
712
+ const result = duplicateSubtree({ ...stageDoc, widgets: value.widgets }, selectedIds);
689
713
  emitStageLayers(result.doc.layers);
690
714
  selectedIds = result.newIds;
691
715
  }
@@ -716,7 +740,9 @@
716
740
  function sendBack() {
717
741
  const set = new Set(selectedIds);
718
742
  let layers = stageDoc.layers;
719
- const parents = new Set(stageDoc.layers.filter((l) => set.has(l.id)).map((l) => l.parentId ?? null));
743
+ const parents = new Set(
744
+ stageDoc.layers.filter((l) => set.has(l.id)).map((l) => l.parentId ?? null)
745
+ );
720
746
  for (const pid of parents) {
721
747
  const siblings = layers
722
748
  .filter((l) => (l.parentId ?? null) === pid)
@@ -729,25 +755,26 @@
729
755
  emitStageLayers(layers);
730
756
  }
731
757
 
732
- function wrapSelected(kind: CanvasLayerKind) {
758
+ function wrapSelected(kind: CanvasLayerKind, ids = selectedIds) {
759
+ if (!ids.length) {
760
+ toast.warning('Select one or more layers to wrap');
761
+ return;
762
+ }
733
763
  const result = wrapSelection(
734
764
  { ...stageDoc, version: 2, widgets: value.widgets ?? [] },
735
- selectedIds,
765
+ ids,
736
766
  kind
737
767
  );
738
- if (!result) return;
768
+ if (!result) {
769
+ toast.warning('Could not wrap selection');
770
+ return;
771
+ }
739
772
  emitStageLayers(result.doc.layers);
740
773
  selectedIds = [result.wrapperId];
741
774
  }
742
775
 
743
- function groupSelected() {
744
- const result = groupLayers(
745
- { ...stageDoc, version: 2, widgets: value.widgets ?? [] },
746
- selectedIds
747
- );
748
- if (!result) return;
749
- emitStageLayers(result.doc.layers);
750
- selectedIds = [result.wrapperId];
776
+ function groupSelected(ids = selectedIds) {
777
+ wrapSelected('group', ids);
751
778
  }
752
779
 
753
780
  function ungroupSelected() {
@@ -803,15 +830,16 @@
803
830
 
804
831
  function handleCtx(id: string) {
805
832
  const targetId = ctxLayerId;
833
+ const focusIds = targetId && !selectedIds.includes(targetId) ? [targetId] : selectedIds;
806
834
  if (targetId && !selectedIds.includes(targetId)) selectedIds = [targetId];
807
835
  if (id === 'duplicate') duplicateSelected();
808
836
  else if (id === 'delete') deleteSelected();
809
837
  else if (id === 'bring-front') bringFront();
810
838
  else if (id === 'send-back') sendBack();
811
- else if (id === 'group') groupSelected();
839
+ else if (id === 'group') groupSelected(focusIds);
812
840
  else if (id === 'ungroup') ungroupSelected();
813
841
  else if (id === 'detach') detachSelected();
814
- else if (id.startsWith('wrap-')) wrapSelected(id.slice(5) as CanvasLayerKind);
842
+ else if (id.startsWith('wrap-')) wrapSelected(id.slice(5) as CanvasLayerKind, focusIds);
815
843
  else if (id === 'create-widget') createWidgetSelected();
816
844
  else if (id === 'lock') {
817
845
  const set = new Set(selectedIds);
@@ -820,9 +848,7 @@
820
848
  );
821
849
  } else if (id === 'hide') {
822
850
  const set = new Set(selectedIds);
823
- emitStageLayers(
824
- stageDoc.layers.map((l) => (set.has(l.id) ? { ...l, visible: false } : l))
825
- );
851
+ emitStageLayers(stageDoc.layers.map((l) => (set.has(l.id) ? { ...l, visible: false } : l)));
826
852
  selectedIds = [];
827
853
  }
828
854
  }
@@ -832,14 +858,10 @@
832
858
  else if (id === 'delete') deleteSelected();
833
859
  else if (id === 'lock') {
834
860
  const set = new Set(selectedIds);
835
- emitStageLayers(
836
- stageDoc.layers.map((l) => (set.has(l.id) ? { ...l, locked: true } : l))
837
- );
861
+ emitStageLayers(stageDoc.layers.map((l) => (set.has(l.id) ? { ...l, locked: true } : l)));
838
862
  } else if (id === 'hide') {
839
863
  const set = new Set(selectedIds);
840
- emitStageLayers(
841
- stageDoc.layers.map((l) => (set.has(l.id) ? { ...l, visible: false } : l))
842
- );
864
+ emitStageLayers(stageDoc.layers.map((l) => (set.has(l.id) ? { ...l, visible: false } : l)));
843
865
  selectedIds = [];
844
866
  } else if (id === 'front') bringFront();
845
867
  else if (id === 'back') sendBack();
@@ -875,8 +897,41 @@
875
897
  }
876
898
  }
877
899
 
900
+ function isEditingText(target: EventTarget | null): boolean {
901
+ if (!(target instanceof HTMLElement)) return false;
902
+ if (target.isContentEditable || target.closest('[contenteditable="true"]')) return true;
903
+ const field = target.closest('textarea, select, input');
904
+ if (!field) return false;
905
+ if (field instanceof HTMLTextAreaElement || field instanceof HTMLSelectElement) return true;
906
+ if (field instanceof HTMLInputElement) {
907
+ const type = (field.type || 'text').toLowerCase();
908
+ return (
909
+ type !== 'number' &&
910
+ type !== 'range' &&
911
+ type !== 'checkbox' &&
912
+ type !== 'radio' &&
913
+ type !== 'button' &&
914
+ type !== 'hidden'
915
+ );
916
+ }
917
+ return false;
918
+ }
919
+
878
920
  function handleKeydown(e: KeyboardEvent) {
879
921
  const t = e.target as HTMLElement | null;
922
+ const arrow =
923
+ e.key === 'ArrowLeft' ||
924
+ e.key === 'ArrowRight' ||
925
+ e.key === 'ArrowUp' ||
926
+ e.key === 'ArrowDown';
927
+ if (arrow && selectedIds.length && !isEditingText(e.target)) {
928
+ if (drawMode) return;
929
+ e.preventDefault();
930
+ const dirX: -1 | 0 | 1 = e.key === 'ArrowLeft' ? -1 : e.key === 'ArrowRight' ? 1 : 0;
931
+ const dirY: -1 | 0 | 1 = e.key === 'ArrowUp' ? -1 : e.key === 'ArrowDown' ? 1 : 0;
932
+ nudgeSelected(dirX, dirY, e.shiftKey);
933
+ return;
934
+ }
880
935
  if (t?.closest?.('input, textarea, select, [contenteditable="true"]')) return;
881
936
 
882
937
  if (drawMode) {
@@ -915,9 +970,7 @@
915
970
  if (selectedIds.length === 1) {
916
971
  const cur = stageDoc.layers.find((l) => l.id === selectedIds[0]);
917
972
  const pid = cur?.parentId ?? null;
918
- selectedIds = stageDoc.layers
919
- .filter((l) => (l.parentId ?? null) === pid)
920
- .map((l) => l.id);
973
+ selectedIds = stageDoc.layers.filter((l) => (l.parentId ?? null) === pid).map((l) => l.id);
921
974
  } else if (selectedIds.length > 1) {
922
975
  const parents = new Set(
923
976
  selectedIds.map((id) => stageDoc.layers.find((l) => l.id === id)?.parentId ?? null)
@@ -933,9 +986,7 @@
933
986
  .map((l) => l.id);
934
987
  }
935
988
  } else {
936
- selectedIds = stageDoc.layers
937
- .filter((l) => (l.parentId ?? null) === null)
938
- .map((l) => l.id);
989
+ selectedIds = stageDoc.layers.filter((l) => (l.parentId ?? null) === null).map((l) => l.id);
939
990
  }
940
991
  return;
941
992
  }
@@ -965,16 +1016,6 @@
965
1016
  return;
966
1017
  }
967
1018
  }
968
-
969
- if (e.key === 'ArrowLeft' || e.key === 'ArrowRight' || e.key === 'ArrowUp' || e.key === 'ArrowDown') {
970
- if (!selectedIds.length) return;
971
- e.preventDefault();
972
- const step = e.shiftKey ? (snap ? cellSize * 2 : 10) : snap ? cellSize : 1;
973
- if (e.key === 'ArrowLeft') nudgeSelected(-step, 0);
974
- else if (e.key === 'ArrowRight') nudgeSelected(step, 0);
975
- else if (e.key === 'ArrowUp') nudgeSelected(0, -step);
976
- else nudgeSelected(0, step);
977
- }
978
1019
  }
979
1020
 
980
1021
  async function handleExport(format: CanvasExportFormat) {
@@ -1060,17 +1101,17 @@
1060
1101
  }
1061
1102
  </script>
1062
1103
 
1063
- <svelte:window onkeydown={handleKeydown} />
1104
+ <svelte:window onkeydowncapture={handleKeydown} />
1064
1105
 
1065
- <div class={['relative flex h-full min-h-0 flex-col', className]}>
1106
+ <div class={['min-h-0 relative flex h-full flex-col', className]}>
1066
1107
  <header
1067
- class="flex shrink-0 items-center gap-3 border-b border-border bg-surface-elevated px-3 py-2"
1108
+ class="gap-3 border-border bg-surface-elevated px-3 py-2 flex shrink-0 items-center border-b"
1068
1109
  >
1069
- <div class="flex min-w-0 items-center gap-2">
1110
+ <div class="min-w-0 gap-2 flex items-center">
1070
1111
  {#if editingWidget}
1071
1112
  <button
1072
1113
  type="button"
1073
- class="inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-xs font-medium text-secondary hover:bg-surface-overlay"
1114
+ class="gap-1 rounded-md px-1.5 py-1 text-xs font-medium text-secondary hover:bg-surface-overlay inline-flex items-center"
1074
1115
  onclick={() => {
1075
1116
  exitWidgetEdit();
1076
1117
  selectedIds = [];
@@ -1080,9 +1121,9 @@
1080
1121
  Scene
1081
1122
  </button>
1082
1123
  <span class="text-muted">/</span>
1083
- <span class="truncate text-sm font-semibold text-primary">{editingWidget.name}</span>
1124
+ <span class="text-sm font-semibold text-primary truncate">{editingWidget.name}</span>
1084
1125
  {:else}
1085
- <span class="hidden text-sm font-semibold text-primary sm:inline">Canvas</span>
1126
+ <span class="text-sm font-semibold text-primary sm:inline hidden">Canvas</span>
1086
1127
  <Select
1087
1128
  size="sm"
1088
1129
  class="w-44"
@@ -1095,15 +1136,15 @@
1095
1136
  {/if}
1096
1137
  </div>
1097
1138
 
1098
- <div class="hidden h-5 w-px bg-border sm:block"></div>
1139
+ <div class="h-5 bg-border sm:block hidden w-px"></div>
1099
1140
 
1100
- <div class="flex items-center rounded-lg border border-border bg-surface p-0.5">
1141
+ <div class="rounded-lg border-border bg-surface p-0.5 flex items-center border">
1101
1142
  <IconButton label="Zoom out" size="sm" onclick={() => setZoom(zoom - 0.1)}>
1102
1143
  <ZoomOut class="h-3.5 w-3.5" />
1103
1144
  </IconButton>
1104
1145
  <button
1105
1146
  type="button"
1106
- class="min-w-11 rounded-md px-1 py-1 font-mono text-[11px] tabular-nums text-secondary hover:bg-surface-overlay"
1147
+ class="min-w-11 rounded-md px-1 py-1 font-mono text-secondary hover:bg-surface-overlay text-[11px] tabular-nums"
1107
1148
  onclick={() => setZoom(1)}
1108
1149
  title="Fit to view"
1109
1150
  >
@@ -1114,26 +1155,16 @@
1114
1155
  </IconButton>
1115
1156
  </div>
1116
1157
 
1117
- <div class="flex items-center rounded-lg border border-border bg-surface p-0.5">
1118
- <IconButton
1119
- label="Undo"
1120
- size="sm"
1121
- disabled={!history.past.length}
1122
- onclick={undo}
1123
- >
1158
+ <div class="rounded-lg border-border bg-surface p-0.5 flex items-center border">
1159
+ <IconButton label="Undo" size="sm" disabled={!history.past.length} onclick={undo}>
1124
1160
  <Undo2 class="h-3.5 w-3.5" />
1125
1161
  </IconButton>
1126
- <IconButton
1127
- label="Redo"
1128
- size="sm"
1129
- disabled={!history.future.length}
1130
- onclick={redo}
1131
- >
1162
+ <IconButton label="Redo" size="sm" disabled={!history.future.length} onclick={redo}>
1132
1163
  <Redo2 class="h-3.5 w-3.5" />
1133
1164
  </IconButton>
1134
1165
  </div>
1135
1166
 
1136
- <div class="flex items-center rounded-lg border border-border bg-surface p-0.5">
1167
+ <div class="rounded-lg border-border bg-surface p-0.5 flex items-center border">
1137
1168
  <Tooltip content="Toggle grid">
1138
1169
  <IconButton
1139
1170
  label="Toggle grid"
@@ -1150,7 +1181,7 @@
1150
1181
  </Tooltip>
1151
1182
  {#if showGrid}
1152
1183
  <select
1153
- class="h-8 min-w-0 shrink-0 rounded-md border-0 bg-transparent px-1 font-mono text-[11px] tabular-nums text-secondary outline-none hover:bg-surface-overlay focus-visible:bg-surface-overlay"
1184
+ class="h-8 min-w-0 rounded-md px-1 font-mono text-secondary hover:bg-surface-overlay focus-visible:bg-surface-overlay shrink-0 border-0 bg-transparent text-[11px] tabular-nums outline-none"
1154
1185
  aria-label="Grid cell size"
1155
1186
  value={String(cellSize)}
1156
1187
  onchange={(e) => (cellSize = Number(e.currentTarget.value))}
@@ -1176,9 +1207,9 @@
1176
1207
  </Tooltip>
1177
1208
  </div>
1178
1209
 
1179
- <div class="hidden h-5 w-px bg-border sm:block"></div>
1210
+ <div class="h-5 bg-border sm:block hidden w-px"></div>
1180
1211
 
1181
- <div class="flex items-center gap-0.5">
1212
+ <div class="gap-0.5 flex items-center">
1182
1213
  <Tooltip content={drawMode ? 'Exit pen tool (Esc)' : 'Pen — draw path / shape'}>
1183
1214
  <IconButton
1184
1215
  label="Pen tool"
@@ -1191,9 +1222,9 @@
1191
1222
  </Tooltip>
1192
1223
  </div>
1193
1224
 
1194
- <div class="hidden h-5 w-px bg-border sm:block"></div>
1225
+ <div class="h-5 bg-border sm:block hidden w-px"></div>
1195
1226
 
1196
- <div class="flex items-center gap-0.5">
1227
+ <div class="gap-0.5 flex items-center">
1197
1228
  <Tooltip content={showGuides ? 'Hide guides' : 'Show guides'}>
1198
1229
  <IconButton
1199
1230
  label="Toggle guides"
@@ -1231,8 +1262,8 @@
1231
1262
  </div>
1232
1263
 
1233
1264
  {#if selectedIds.length}
1234
- <div class="hidden h-5 w-px bg-border md:block"></div>
1235
- <div class="hidden items-center gap-1 md:flex">
1265
+ <div class="h-5 bg-border md:block hidden w-px"></div>
1266
+ <div class="gap-1 md:flex hidden items-center">
1236
1267
  <DropdownMenu
1237
1268
  size="sm"
1238
1269
  align="start"
@@ -1241,9 +1272,7 @@
1241
1272
  onselect={(id) => alignSelected(id as CanvasAlign)}
1242
1273
  >
1243
1274
  {#snippet trigger()}
1244
- <span
1245
- class="inline-flex items-center gap-1.5 text-xs font-medium text-secondary"
1246
- >
1275
+ <span class="gap-1.5 text-xs font-medium text-secondary inline-flex items-center">
1247
1276
  <AlignHorizontalJustifyCenter class="h-3.5 w-3.5" />
1248
1277
  Align
1249
1278
  </span>
@@ -1257,7 +1286,7 @@
1257
1286
  onselect={handleWrapMenu}
1258
1287
  >
1259
1288
  {#snippet trigger()}
1260
- <span class="inline-flex items-center gap-1.5 text-xs font-medium text-secondary">
1289
+ <span class="gap-1.5 text-xs font-medium text-secondary inline-flex items-center">
1261
1290
  <Group class="h-3.5 w-3.5" />
1262
1291
  Group
1263
1292
  </span>
@@ -1266,7 +1295,7 @@
1266
1295
  </div>
1267
1296
  {/if}
1268
1297
 
1269
- <div class="ml-auto flex items-center gap-1">
1298
+ <div class="gap-1 ml-auto flex items-center">
1270
1299
  <IconButton
1271
1300
  label="Toggle sidebar"
1272
1301
  size="sm"
@@ -1293,7 +1322,7 @@
1293
1322
  onselect={(id) => handleExport(id as CanvasExportFormat)}
1294
1323
  >
1295
1324
  {#snippet trigger()}
1296
- <span class="inline-flex items-center gap-1.5 px-1 text-xs font-medium">
1325
+ <span class="gap-1.5 px-1 text-xs font-medium inline-flex items-center">
1297
1326
  <Download class="h-3.5 w-3.5" />
1298
1327
  {exporting ? 'Exporting…' : 'Export'}
1299
1328
  </span>
@@ -1302,7 +1331,7 @@
1302
1331
  </div>
1303
1332
  </header>
1304
1333
 
1305
- <div class="relative min-h-0 flex-1">
1334
+ <div class="min-h-0 relative flex-1">
1306
1335
  <EditorShell
1307
1336
  sidebarTitle="Assets"
1308
1337
  inspectorTitle="Inspector"
@@ -1335,12 +1364,12 @@
1335
1364
  class="h-full"
1336
1365
  >
1337
1366
  {#snippet start()}
1338
- <div class="flex h-full min-h-0 flex-col bg-surface-elevated">
1339
- <div class="flex shrink-0 gap-1 border-b border-border p-2">
1367
+ <div class="min-h-0 bg-surface-elevated flex h-full flex-col">
1368
+ <div class="gap-1 border-border p-2 flex shrink-0 border-b">
1340
1369
  <button
1341
1370
  type="button"
1342
1371
  class={[
1343
- 'flex-1 rounded-md px-2 py-1.5 text-xs font-medium transition-colors',
1372
+ 'rounded-md px-2 py-1.5 text-xs font-medium flex-1 transition-colors',
1344
1373
  sidebarTab === 'elements'
1345
1374
  ? 'bg-brand-500 text-white'
1346
1375
  : 'text-secondary hover:bg-surface-overlay'
@@ -1352,7 +1381,7 @@
1352
1381
  <button
1353
1382
  type="button"
1354
1383
  class={[
1355
- 'flex-1 rounded-md px-2 py-1.5 text-xs font-medium transition-colors',
1384
+ 'rounded-md px-2 py-1.5 text-xs font-medium flex-1 transition-colors',
1356
1385
  sidebarTab === 'widgets'
1357
1386
  ? 'bg-brand-500 text-white'
1358
1387
  : 'text-secondary hover:bg-surface-overlay'
@@ -1364,7 +1393,7 @@
1364
1393
  <button
1365
1394
  type="button"
1366
1395
  class={[
1367
- 'flex-1 rounded-md px-2 py-1.5 text-xs font-medium transition-colors',
1396
+ 'rounded-md px-2 py-1.5 text-xs font-medium flex-1 transition-colors',
1368
1397
  sidebarTab === 'uploads'
1369
1398
  ? 'bg-brand-500 text-white'
1370
1399
  : 'text-secondary hover:bg-surface-overlay'
@@ -1378,11 +1407,11 @@
1378
1407
  {#if sidebarTab === 'elements'}
1379
1408
  <CanvasElementsPanel onadd={addElement} />
1380
1409
  {:else if sidebarTab === 'widgets'}
1381
- <div class="flex flex-col gap-2 p-3">
1382
- <p class="text-[11px] text-muted">
1410
+ <div class="gap-2 p-3 flex flex-col">
1411
+ <p class="text-muted text-[11px]">
1383
1412
  Click to place · pencil to edit · dblclick name to rename
1384
1413
  </p>
1385
- <label class="flex items-center gap-2 text-[11px] text-secondary">
1414
+ <label class="gap-2 text-secondary flex items-center text-[11px]">
1386
1415
  <input
1387
1416
  type="checkbox"
1388
1417
  class="rounded border-border"
@@ -1393,15 +1422,15 @@
1393
1422
  {#each value.widgets ?? [] as w (w.id)}
1394
1423
  <div
1395
1424
  class={[
1396
- 'flex items-center gap-0.5 rounded-lg border bg-surface px-1 py-1 text-xs',
1425
+ 'gap-0.5 rounded-lg bg-surface px-1 py-1 text-xs flex items-center border',
1397
1426
  editingWidgetId === w.id
1398
- ? 'border-brand-500 ring-1 ring-brand-500/30'
1427
+ ? 'border-brand-500 ring-brand-500/30 ring-1'
1399
1428
  : 'border-border'
1400
1429
  ]}
1401
1430
  >
1402
1431
  <button
1403
1432
  type="button"
1404
- class="flex min-w-0 flex-1 items-center gap-2 rounded-md px-1.5 py-1.5 text-left hover:bg-surface-overlay"
1433
+ class="min-w-0 gap-2 rounded-md px-1.5 py-1.5 hover:bg-surface-overlay flex flex-1 items-center text-left"
1405
1434
  title="Place instance on canvas"
1406
1435
  onclick={() => {
1407
1436
  if (editingWidgetId) {
@@ -1416,13 +1445,11 @@
1416
1445
  }
1417
1446
  }}
1418
1447
  >
1419
- <Component class="h-4 w-4 shrink-0 text-brand-600" />
1420
- <span class="min-w-0 flex-1 truncate font-medium" title={w.name}>
1448
+ <Component class="h-4 w-4 text-brand-600 shrink-0" />
1449
+ <span class="min-w-0 font-medium flex-1 truncate" title={w.name}>
1421
1450
  {w.name}
1422
1451
  </span>
1423
- <span class="shrink-0 text-[10px] text-muted"
1424
- >{w.width}×{w.height}</span
1425
- >
1452
+ <span class="text-muted shrink-0 text-[10px]">{w.width}×{w.height}</span>
1426
1453
  </button>
1427
1454
  <IconButton
1428
1455
  label="Rename widget"
@@ -1466,7 +1493,7 @@
1466
1493
  </IconButton>
1467
1494
  </div>
1468
1495
  {:else}
1469
- <p class="py-6 text-center text-xs text-muted">
1496
+ <p class="py-6 text-xs text-muted text-center">
1470
1497
  Select layers and Create Widget, or Group → Create Widget
1471
1498
  </p>
1472
1499
  {/each}
@@ -1478,7 +1505,7 @@
1478
1505
  accept="image/*,video/*"
1479
1506
  helperText="Images or video"
1480
1507
  allowText={false}
1481
- onassetschange={onassetschange}
1508
+ {onassetschange}
1482
1509
  onselect={(id) => {
1483
1510
  const asset = assets.find((a) => a.id === id);
1484
1511
  if (asset) addFromAsset(asset);
@@ -1503,15 +1530,11 @@
1503
1530
  onselect={selectFromList}
1504
1531
  ontogglevisible={(id) =>
1505
1532
  emitStageLayers(
1506
- stageDoc.layers.map((l) =>
1507
- l.id === id ? { ...l, visible: !l.visible } : l
1508
- )
1533
+ stageDoc.layers.map((l) => (l.id === id ? { ...l, visible: !l.visible } : l))
1509
1534
  )}
1510
1535
  ontogglelocked={(id) =>
1511
1536
  emitStageLayers(
1512
- stageDoc.layers.map((l) =>
1513
- l.id === id ? { ...l, locked: !l.locked } : l
1514
- )
1537
+ stageDoc.layers.map((l) => (l.id === id ? { ...l, locked: !l.locked } : l))
1515
1538
  )}
1516
1539
  onreorder={(ids, parentId) =>
1517
1540
  emitStageLayers(reorderSiblings(stageDoc.layers, parentId, ids))}
@@ -1536,7 +1559,7 @@
1536
1559
  {/snippet}
1537
1560
 
1538
1561
  {#snippet workspace()}
1539
- <div class="h-full min-h-0">
1562
+ <div class="min-h-0 h-full">
1540
1563
  <MediaStage
1541
1564
  document={stageDoc}
1542
1565
  {selectedIds}
@@ -1626,7 +1649,7 @@
1626
1649
  </EditorShell>
1627
1650
 
1628
1651
  {#if selectedIds.length > 1}
1629
- <div class="pointer-events-none absolute inset-x-0 bottom-4 z-30 flex justify-center px-4">
1652
+ <div class="inset-x-0 bottom-4 px-4 pointer-events-none absolute z-30 flex justify-center">
1630
1653
  <div class="pointer-events-auto">
1631
1654
  <BulkActionBar
1632
1655
  count={selectedIds.length}
@@ -1667,7 +1690,7 @@
1667
1690
  {#snippet trigger()}
1668
1691
  <Tooltip content="Wrap in parent" side="top">
1669
1692
  <span
1670
- class="inline-flex h-7 w-7 items-center justify-center rounded-md text-secondary hover:bg-surface-overlay hover:text-primary"
1693
+ class="h-7 w-7 rounded-md text-secondary hover:bg-surface-overlay hover:text-primary inline-flex items-center justify-center"
1671
1694
  aria-label="Wrap in parent"
1672
1695
  >
1673
1696
  <Group class="h-3.5 w-3.5" />