@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
@@ -30,14 +30,19 @@
30
30
  import {
31
31
  applyScrollBoxOffsets,
32
32
  computeAbsoluteRects,
33
- contentPadding,
34
- LAYOUT_BOX_KINDS,
33
+ enclosingGroupId,
34
+ fitGroupsToChildren,
35
+ isEffectivelyLocked,
35
36
  isEffectivelyVisible,
37
+ isLayoutPositionLocked,
38
+ isLayoutSizeLocked,
36
39
  isMarqueePassThroughKind,
40
+ layerFromAbsoluteRect,
37
41
  paintTransformForLayer,
42
+ scaleSubtreeAbsolute,
38
43
  scrollBoxOverflow,
39
44
  scrollBarMetrics,
40
- slotFromLocalRect,
45
+ selectionAncestorIds,
41
46
  clipPathForLayer
42
47
  } from '../../../utils/canvasHierarchy.js';
43
48
  import { flattenLayersWithWidgets } from '../../../utils/canvasWidget.js';
@@ -126,18 +131,14 @@
126
131
  const PAD = 48;
127
132
  const workingLayers = $derived(draftLayers ?? doc.layers);
128
133
  const displayLayers = $derived(
129
- expandWidgets
130
- ? flattenLayersWithWidgets(workingLayers, doc.widgets ?? [])
131
- : workingLayers
134
+ expandWidgets ? flattenLayersWithWidgets(workingLayers, doc.widgets ?? []) : workingLayers
132
135
  );
133
136
  const absMap = $derived(
134
137
  computeAbsoluteRects(displayLayers, { width: doc.width, height: doc.height })
135
138
  );
136
139
  /** Ephemeral scroll offsets for scrollBox preview (not persisted). */
137
140
  let scrollOffsets = $state<Map<string, { x: number; y: number }>>(new Map());
138
- const paintAbsMap = $derived(
139
- applyScrollBoxOffsets(displayLayers, absMap, scrollOffsets)
140
- );
141
+ const paintAbsMap = $derived(applyScrollBoxOffsets(displayLayers, absMap, scrollOffsets));
141
142
  const sorted = $derived.by(() => {
142
143
  const out: typeof displayLayers = [];
143
144
  const walk = (parentId: string | null) => {
@@ -162,6 +163,8 @@
162
163
  });
163
164
  const selectedSet = $derived(new Set(selectedIds));
164
165
  const sceneLayerIds = $derived(new Set(workingLayers.map((l) => l.id)));
166
+ const ancestorOutlineIds = $derived(selectionAncestorIds(workingLayers, selectedIds));
167
+ const workingById = $derived(new Map(workingLayers.map((l) => [l.id, l])));
165
168
 
166
169
  function resolveSelectableId(id: string): string {
167
170
  if (sceneLayerIds.has(id)) return id;
@@ -310,32 +313,15 @@
310
313
  const parentId = layer.parentId ?? null;
311
314
  const parentAbs = parentId ? (absMap.get(parentId) ?? null) : null;
312
315
  const parentLayer = parentId ? (workingLayers.find((l) => l.id === parentId) ?? null) : null;
313
- const pad = parentLayer
314
- ? contentPadding(parentLayer)
315
- : { left: 0, top: 0, right: 0, bottom: 0 };
316
- const originX = (parentAbs?.x ?? 0) + pad.left;
317
- const originY = (parentAbs?.y ?? 0) + pad.top;
318
- const contentW = parentAbs
319
- ? Math.max(0, parentAbs.w - pad.left - pad.right)
320
- : doc.width;
321
- const contentH = parentAbs
322
- ? Math.max(0, parentAbs.h - pad.top - pad.bottom)
323
- : doc.height;
324
- const local = {
325
- x: absRect.x - originX,
326
- y: absRect.y - originY,
327
- w: absRect.w,
328
- h: absRect.h
329
- };
330
- const anchors = layer.slot?.anchors ?? { minX: 0, minY: 0, maxX: 0, maxY: 0 };
331
- const slot = {
332
- ...slotFromLocalRect({ width: contentW, height: contentH }, local, anchors),
333
- padding: layer.slot?.padding,
334
- sizeRule: layer.slot?.sizeRule,
335
- alignment: layer.slot?.alignment,
336
- order: layer.slot?.order
337
- };
338
- return { ...layer, rect: local, slot };
316
+ return layerFromAbsoluteRect(layer, absRect, parentAbs, parentLayer, {
317
+ width: doc.width,
318
+ height: doc.height
319
+ });
320
+ }
321
+
322
+ function commitGroupGeometry(next: CanvasLayer[]) {
323
+ draftLayers = fitGroupsToChildren(next, { width: doc.width, height: doc.height });
324
+ if (interactCount === 0) commitDraft();
339
325
  }
340
326
 
341
327
  function commitDraft() {
@@ -360,22 +346,31 @@
360
346
  }
361
347
 
362
348
  function isLayoutLocked(layer: CanvasLayer): boolean {
363
- const parentId = layer.parentId ?? null;
364
- if (!parentId) return false;
365
- const parent = workingLayers.find((l) => l.id === parentId);
366
- return !!parent && LAYOUT_BOX_KINDS.has(parent.kind);
349
+ return isLayoutPositionLocked(workingLayers, layer.id, workingById);
350
+ }
351
+
352
+ function isSizeLocked(layer: CanvasLayer): boolean {
353
+ return isLayoutSizeLocked(workingLayers, layer.id, workingById);
354
+ }
355
+
356
+ function layerLocked(layer: CanvasLayer): boolean {
357
+ const realId = resolveSelectableId(layer.id);
358
+ return isEffectivelyLocked(workingLayers, realId, workingById);
367
359
  }
368
360
 
369
361
  function handleRect(layer: CanvasLayer, rect: WidgetRect) {
370
362
  if (!sceneLayerIds.has(layer.id)) return;
371
- if (isLayoutLocked(layer)) return;
363
+ if (layerLocked(layer)) return;
364
+ const positionLocked = isLayoutLocked(layer);
365
+ const sizeLocked = isSizeLocked(layer);
366
+ if (positionLocked && sizeLocked) return;
372
367
  const layers = draftLayers ?? doc.layers;
373
368
  const source = layers.find((l) => l.id === layer.id);
374
369
  if (!source) return;
375
370
 
376
371
  const minW = source.kind === 'line' || source.kind === 'arrow' ? 24 : 40;
377
372
  const minH = source.kind === 'line' ? 2 : 24;
378
- const nextAbs = snapLayerRect(
373
+ let nextAbs = snapLayerRect(
379
374
  { x: rect.x, y: rect.y, w: rect.w, h: rect.h },
380
375
  cellSize,
381
376
  snap,
@@ -386,46 +381,78 @@
386
381
  );
387
382
 
388
383
  const prevAbs = absMap.get(source.id) ?? source.rect;
384
+ if (positionLocked) {
385
+ nextAbs = { ...nextAbs, x: prevAbs.x, y: prevAbs.y };
386
+ }
387
+ if (sizeLocked) {
388
+ nextAbs = { ...nextAbs, w: prevAbs.w, h: prevAbs.h };
389
+ }
389
390
  const dx = nextAbs.x - prevAbs.x;
390
391
  const dy = nextAbs.y - prevAbs.y;
391
- const moving =
392
- Math.abs(nextAbs.w - prevAbs.w) < 0.5 && Math.abs(nextAbs.h - prevAbs.h) < 0.5;
392
+ const moving = Math.abs(nextAbs.w - prevAbs.w) < 0.5 && Math.abs(nextAbs.h - prevAbs.h) < 0.5;
393
+ if (moving && Math.abs(dx) < 0.01 && Math.abs(dy) < 0.01) return;
393
394
  const groupMove =
394
395
  moving &&
396
+ !positionLocked &&
395
397
  selectedIds.length > 1 &&
396
398
  selectedSet.has(source.id) &&
397
399
  (Math.abs(dx) > 0.01 || Math.abs(dy) > 0.01);
398
400
 
399
401
  if (groupMove) {
400
- draftLayers = layers.map((l) => {
401
- if (!selectedSet.has(l.id) || l.locked) return l;
402
- const a = absMap.get(l.id) ?? l.rect;
403
- const moved = {
404
- x: a.x + dx,
405
- y: a.y + dy,
406
- w: a.w,
407
- h: a.h
408
- };
409
- return absToLocalUpdate(l, moved);
410
- });
402
+ commitGroupGeometry(
403
+ layers.map((l) => {
404
+ if (!selectedSet.has(l.id) || isEffectivelyLocked(workingLayers, l.id, workingById)) {
405
+ return l;
406
+ }
407
+ if (isLayoutPositionLocked(workingLayers, l.id, workingById)) return l;
408
+ const a = absMap.get(l.id) ?? l.rect;
409
+ const moved = {
410
+ x: a.x + dx,
411
+ y: a.y + dy,
412
+ w: a.w,
413
+ h: a.h
414
+ };
415
+ return absToLocalUpdate(l, moved);
416
+ })
417
+ );
411
418
  return;
412
419
  }
413
420
 
414
- const updated = applyTextAutoSize(
415
- source,
416
- absToLocalUpdate(source, nextAbs),
417
- prevAbs,
418
- nextAbs
419
- );
420
- draftLayers = layers.map((l) => (l.id === updated.id ? updated : l));
421
- // If somehow interact end already fired without draft, commit immediately.
422
- if (interactCount === 0) commitDraft();
421
+ const sizeChanged = !moving;
422
+ const rootSize = { width: doc.width, height: doc.height };
423
+ let nextLayers = layers;
424
+ if (source.kind === 'group' && sizeChanged) {
425
+ nextLayers = scaleSubtreeAbsolute(layers, source.id, prevAbs, nextAbs, rootSize);
426
+ } else {
427
+ const updated = applyTextAutoSize(
428
+ source,
429
+ absToLocalUpdate(source, nextAbs),
430
+ prevAbs,
431
+ nextAbs
432
+ );
433
+ nextLayers = layers.map((l) => (l.id === updated.id ? updated : l));
434
+ }
435
+ commitGroupGeometry(nextLayers);
436
+ }
437
+
438
+ function groupedChildPassthrough(layer: CanvasLayer): boolean {
439
+ if (selectedSet.has(layer.id)) return false;
440
+ return !!enclosingGroupId(workingLayers, layer.id);
423
441
  }
424
442
 
425
443
  function selectLayer(id: string, e: MouseEvent) {
426
444
  e.stopPropagation();
427
- const realId = resolveSelectableId(id);
428
- if (e.shiftKey || e.metaKey || e.ctrlKey) {
445
+ let realId = resolveSelectableId(id);
446
+ if (e.metaKey || e.ctrlKey) {
447
+ const hit = pickLayerAtDoc(clientToDoc(e.clientX, e.clientY));
448
+ if (hit) realId = resolveSelectableId(hit);
449
+ const set = new Set(selectedIds);
450
+ if (set.has(realId)) set.delete(realId);
451
+ else set.add(realId);
452
+ onselect?.([...set]);
453
+ return;
454
+ }
455
+ if (e.shiftKey) {
429
456
  const set = new Set(selectedIds);
430
457
  if (set.has(realId)) set.delete(realId);
431
458
  else set.add(realId);
@@ -490,7 +517,12 @@
490
517
  const s = scale;
491
518
  return sorted
492
519
  .filter((l) => {
493
- if (!effectivelyVisible.has(l.id) || l.locked) return false;
520
+ if (
521
+ !effectivelyVisible.has(l.id) ||
522
+ isEffectivelyLocked(workingLayers, l.id, workingById)
523
+ ) {
524
+ return false;
525
+ }
494
526
  const realId = resolveSelectableId(l.id);
495
527
  if (!sceneLayerIds.has(realId)) return false;
496
528
  // Don't always rubber-band-select the full-bleed root panel.
@@ -523,7 +555,9 @@
523
555
  function pickLayerAtDoc(pt: { x: number; y: number }): string | null {
524
556
  for (let i = sorted.length - 1; i >= 0; i--) {
525
557
  const l = sorted[i];
526
- if (!effectivelyVisible.has(l.id) || l.locked) continue;
558
+ if (!effectivelyVisible.has(l.id) || isEffectivelyLocked(workingLayers, l.id, workingById)) {
559
+ continue;
560
+ }
527
561
  const selectable = resolveSelectableId(l.id);
528
562
  if (!sceneLayerIds.has(l.id) && !sceneLayerIds.has(selectable)) continue;
529
563
  const r = paintAbsMap.get(l.id) ?? l.rect;
@@ -556,17 +590,17 @@
556
590
  const pt = clientToDoc(e.clientX, e.clientY);
557
591
  const boxId = findScrollBoxAtDoc(pt);
558
592
  if (!boxId) return;
559
- setScrollOffset(boxId, {
560
- x: (scrollOffsets.get(boxId)?.x ?? 0) + e.deltaX,
561
- y: (scrollOffsets.get(boxId)?.y ?? 0) + e.deltaY
562
- }, e);
593
+ setScrollOffset(
594
+ boxId,
595
+ {
596
+ x: (scrollOffsets.get(boxId)?.x ?? 0) + e.deltaX,
597
+ y: (scrollOffsets.get(boxId)?.y ?? 0) + e.deltaY
598
+ },
599
+ e
600
+ );
563
601
  }
564
602
 
565
- function setScrollOffset(
566
- boxId: string,
567
- raw: { x: number; y: number },
568
- e?: WheelEvent
569
- ) {
603
+ function setScrollOffset(boxId: string, raw: { x: number; y: number }, e?: WheelEvent) {
570
604
  const { maxX, maxY } = scrollBoxOverflow(boxId, displayLayers, absMap);
571
605
  if (maxX <= 0 && maxY <= 0) return;
572
606
  const cur = scrollOffsets.get(boxId) ?? { x: 0, y: 0 };
@@ -729,7 +763,7 @@
729
763
  }
730
764
 
731
765
  function beginPathPointDrag(index: number, e: PointerEvent) {
732
- if (!selectedPath || selectedPath.locked) return;
766
+ if (!selectedPath || isEffectivelyLocked(workingLayers, selectedPath.id, workingById)) return;
733
767
  e.preventDefault();
734
768
  e.stopPropagation();
735
769
  activePathPoint = index;
@@ -758,7 +792,7 @@
758
792
  }
759
793
 
760
794
  function insertPathPoint(afterIndex: number, e: MouseEvent) {
761
- if (!selectedPath || selectedPath.locked) return;
795
+ if (!selectedPath || isEffectivelyLocked(workingLayers, selectedPath.id, workingById)) return;
762
796
  e.preventDefault();
763
797
  e.stopPropagation();
764
798
  const docs = pathAbsPoints(selectedPath);
@@ -768,7 +802,12 @@
768
802
  }
769
803
 
770
804
  function removeActivePathPoint() {
771
- if (!selectedPath || selectedPath.locked || activePathPoint == null) return;
805
+ if (
806
+ !selectedPath ||
807
+ isEffectivelyLocked(workingLayers, selectedPath.id, workingById) ||
808
+ activePathPoint == null
809
+ )
810
+ return;
772
811
  const docs = pathAbsPoints(selectedPath);
773
812
  if (docs.length <= 2) return;
774
813
  docs.splice(activePathPoint, 1);
@@ -816,10 +855,7 @@
816
855
  const onMove = (ev: PointerEvent) => {
817
856
  setGuidePreview(guide.orientation, ev.clientX, ev.clientY);
818
857
  const pt = clientToDoc(ev.clientX, ev.clientY);
819
- const pos = clampGuidePos(
820
- guide.orientation,
821
- guide.orientation === 'vertical' ? pt.x : pt.y
822
- );
858
+ const pos = clampGuidePos(guide.orientation, guide.orientation === 'vertical' ? pt.x : pt.y);
823
859
  patchGuides(guides.map((g) => (g.id === guide.id ? { ...g, position: pos } : g)));
824
860
  };
825
861
  const onUp = (ev: PointerEvent) => {
@@ -1018,20 +1054,20 @@
1018
1054
  }}
1019
1055
  />
1020
1056
 
1021
- <div bind:this={stageEl} class={['relative flex h-full min-h-0 w-full flex-col', className]}>
1057
+ <div bind:this={stageEl} class={['min-h-0 relative flex h-full w-full flex-col', className]}>
1022
1058
  <!-- Top ruler — slim, crisp ticks -->
1023
1059
  <div
1024
- class="relative z-30 flex shrink-0 border-b border-black/10 bg-[#eceff3] dark:border-white/10 dark:bg-[#1e2329]"
1060
+ class="border-black/10 dark:border-white/10 relative z-30 flex shrink-0 border-b bg-[#eceff3] dark:bg-[#1e2329]"
1025
1061
  >
1026
1062
  <div
1027
- class="shrink-0 border-r border-black/10 bg-[#e2e6eb] dark:border-white/10 dark:bg-[#181c21]"
1063
+ class="border-black/10 dark:border-white/10 shrink-0 border-r bg-[#e2e6eb] dark:bg-[#181c21]"
1028
1064
  style:width={`${RULER_LEFT}px`}
1029
1065
  style:height={`${RULER_TOP}px`}
1030
1066
  ></div>
1031
1067
  <!-- svelte-ignore a11y_no_static_element_interactions -->
1032
1068
  <div
1033
1069
  data-ruler="x"
1034
- class="relative min-w-0 flex-1 cursor-ns-resize overflow-hidden"
1070
+ class="min-w-0 relative flex-1 cursor-ns-resize overflow-hidden"
1035
1071
  style:height={`${RULER_TOP}px`}
1036
1072
  title="Drag down to add a horizontal guide"
1037
1073
  onpointerdown={(e) => {
@@ -1039,7 +1075,7 @@
1039
1075
  beginRulerDrag('horizontal', e);
1040
1076
  }}
1041
1077
  >
1042
- <svg class="absolute inset-0 h-full w-full" aria-hidden="true">
1078
+ <svg class="inset-0 absolute h-full w-full" aria-hidden="true">
1043
1079
  {#each rulerTicksX as tick (tick.pos)}
1044
1080
  {@const left = tickX(tick.pos)}
1045
1081
  {#if left >= -8 && left <= (vw || 0) + 8}
@@ -1073,12 +1109,12 @@
1073
1109
  </div>
1074
1110
  </div>
1075
1111
 
1076
- <div class="flex min-h-0 min-w-0 flex-1">
1112
+ <div class="min-h-0 min-w-0 flex flex-1">
1077
1113
  <!-- Left ruler — upright labels (not rotated) so digits stay readable -->
1078
1114
  <!-- svelte-ignore a11y_no_static_element_interactions -->
1079
1115
  <div
1080
1116
  data-ruler="y"
1081
- class="relative z-30 shrink-0 cursor-ew-resize overflow-hidden border-r border-black/10 bg-[#eceff3] dark:border-white/10 dark:bg-[#1e2329]"
1117
+ class="border-black/10 dark:border-white/10 relative z-30 shrink-0 cursor-ew-resize overflow-hidden border-r bg-[#eceff3] dark:bg-[#1e2329]"
1082
1118
  style:width={`${RULER_LEFT}px`}
1083
1119
  title="Drag right to add a vertical guide"
1084
1120
  onpointerdown={(e) => {
@@ -1086,7 +1122,7 @@
1086
1122
  beginRulerDrag('vertical', e);
1087
1123
  }}
1088
1124
  >
1089
- <svg class="pointer-events-none absolute inset-0 h-full w-full" aria-hidden="true">
1125
+ <svg class="inset-0 pointer-events-none absolute h-full w-full" aria-hidden="true">
1090
1126
  {#each rulerTicksY as tick (tick.pos)}
1091
1127
  {@const top = tickY(tick.pos)}
1092
1128
  {#if top >= -8 && top <= (vh || 0) + 8}
@@ -1111,7 +1147,7 @@
1111
1147
  {@const top = tickY(tick.pos)}
1112
1148
  {#if top >= 4 && top <= (vh || 0) - 2}
1113
1149
  <span
1114
- class="pointer-events-none absolute left-0.5 w-[20px] text-right font-mono text-[9px] leading-none tabular-nums text-slate-700 dark:text-slate-200"
1150
+ class="left-0.5 font-mono text-slate-700 dark:text-slate-200 pointer-events-none absolute w-[20px] text-right text-[9px] leading-none tabular-nums"
1115
1151
  style:top={`${top}px`}
1116
1152
  style:transform="translateY(-50%)"
1117
1153
  >
@@ -1126,9 +1162,11 @@
1126
1162
  <!-- svelte-ignore a11y_no_static_element_interactions -->
1127
1163
  <div
1128
1164
  bind:this={viewportEl}
1129
- class="relative min-h-0 min-w-0 flex-1 overflow-auto"
1165
+ class="min-h-0 min-w-0 relative flex-1 overflow-auto"
1130
1166
  style:background-color="#dfe3e8"
1131
- style:background-image="linear-gradient(45deg,#cfd5dc 25%,transparent 25%),linear-gradient(-45deg,#cfd5dc 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#cfd5dc 75%),linear-gradient(-45deg,transparent 75%,#cfd5dc 75%)"
1167
+ style:background-image="linear-gradient(45deg,#cfd5dc 25%,transparent
1168
+ 25%),linear-gradient(-45deg,#cfd5dc 25%,transparent 25%),linear-gradient(45deg,transparent
1169
+ 75%,#cfd5dc 75%),linear-gradient(-45deg,transparent 75%,#cfd5dc 75%)"
1132
1170
  style:background-size="16px 16px"
1133
1171
  style:background-position="0 0,0 8px,8px -8px,-8px 0"
1134
1172
  role="presentation"
@@ -1166,104 +1204,127 @@
1166
1204
  }}
1167
1205
  onmousemove={handleDrawMove}
1168
1206
  class={[
1169
- 'relative shrink-0 overflow-visible shadow-[0_8px_40px_rgba(15,23,42,0.18)] ring-1 ring-black/10',
1207
+ 'ring-black/10 relative shrink-0 overflow-visible shadow-[0_8px_40px_rgba(15,23,42,0.18)] ring-1',
1170
1208
  drawMode && 'cursor-crosshair'
1171
1209
  ]}
1172
1210
  style:width={`${boardW}px`}
1173
1211
  style:height={`${boardH}px`}
1174
1212
  >
1175
1213
  <div
1176
- class="absolute left-0 top-0 origin-top-left overflow-visible"
1214
+ class="left-0 top-0 absolute origin-top-left overflow-visible"
1177
1215
  style:width={`${doc.width}px`}
1178
1216
  style:height={`${doc.height}px`}
1179
1217
  style:transform={`scale(${scale})`}
1180
1218
  >
1181
1219
  <!-- Artboard surface (clipped). Layers sit above and may overhang like a compositor. -->
1182
- <div class="pointer-events-none absolute inset-0 overflow-hidden" aria-hidden="true">
1220
+ <div class="inset-0 pointer-events-none absolute overflow-hidden" aria-hidden="true">
1183
1221
  {#if artboardTransparent}
1184
1222
  <div
1185
- class="absolute inset-0"
1223
+ class="inset-0 absolute"
1186
1224
  style:background-color="#e8ebef"
1187
- style:background-image="linear-gradient(45deg,#cfd5dc 25%,transparent 25%),linear-gradient(-45deg,#cfd5dc 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#cfd5dc 75%),linear-gradient(-45deg,transparent 75%,#cfd5dc 75%)"
1225
+ style:background-image="linear-gradient(45deg,#cfd5dc 25%,transparent
1226
+ 25%),linear-gradient(-45deg,#cfd5dc 25%,transparent
1227
+ 25%),linear-gradient(45deg,transparent 75%,#cfd5dc
1228
+ 75%),linear-gradient(-45deg,transparent 75%,#cfd5dc 75%)"
1188
1229
  style:background-size="16px 16px"
1189
1230
  style:background-position="0 0,0 8px,8px -8px,-8px 0"
1190
1231
  ></div>
1191
1232
  {/if}
1192
- <div class="absolute inset-0" style:background-color={doc.background}></div>
1233
+ <div class="inset-0 absolute" style:background-color={doc.background}></div>
1193
1234
  </div>
1194
1235
 
1195
1236
  {#if showGrid}
1196
1237
  <div
1197
- class="pointer-events-none absolute inset-0 z-100 overflow-hidden"
1238
+ class="inset-0 pointer-events-none absolute z-100 overflow-hidden"
1198
1239
  style={gridOverlayStyle}
1199
1240
  aria-hidden="true"
1200
1241
  ></div>
1201
1242
  {/if}
1202
1243
 
1203
- <div class={['absolute inset-0 overflow-visible', drawMode && 'pointer-events-none']}>
1244
+ <div class={['inset-0 absolute overflow-visible', drawMode && 'pointer-events-none']}>
1204
1245
  {#each sorted as layer, paintIndex (layer.id)}
1205
1246
  {#if effectivelyVisible.has(layer.id)}
1206
- {@const realId = resolveSelectableId(layer.id)}
1207
- {@const isSynthetic = !sceneLayerIds.has(layer.id)}
1208
- {@const lockedPass = !!layer.locked || isSynthetic}
1209
- {@const displayRect = paintAbsMap.get(layer.id) ?? layer.rect}
1210
- {@const clipPath = clipPathForLayer(layer.id, displayLayers, paintAbsMap)}
1211
- {@const sceneLayer = workingLayers.find((l) => l.id === realId)}
1212
- {@const marqueeBg =
1213
- !!sceneLayer && isMarqueePassThroughKind(sceneLayer.kind)}
1214
- {@const isSelected = selectedSet.has(realId) && !isSynthetic}
1215
- {@const dragOk =
1216
- !layer.locked &&
1217
- !isSynthetic &&
1218
- !isLayoutLocked(layer) &&
1219
- (!marqueeBg ||
1220
- (isSelected && sceneLayer?.kind !== 'canvasPanel'))}
1221
- <!-- svelte-ignore a11y_no_static_element_interactions -->
1222
- <div
1223
- data-layer-item
1224
- data-marquee-id={realId}
1225
- class="contents"
1226
- oncontextmenu={(e) => {
1227
- if (lockedPass && isSynthetic) {
1247
+ {@const realId = resolveSelectableId(layer.id)}
1248
+ {@const isSynthetic = !sceneLayerIds.has(layer.id)}
1249
+ {@const lockedPass = layerLocked(layer) || isSynthetic}
1250
+ {@const displayRect = paintAbsMap.get(layer.id) ?? layer.rect}
1251
+ {@const clipPath = clipPathForLayer(layer.id, displayLayers, paintAbsMap)}
1252
+ {@const sceneLayer = workingLayers.find((l) => l.id === realId)}
1253
+ {@const marqueeBg = !!sceneLayer && isMarqueePassThroughKind(sceneLayer.kind)}
1254
+ {@const isSelected = selectedSet.has(realId) && !isSynthetic}
1255
+ {@const positionLocked = isLayoutLocked(layer)}
1256
+ {@const sizeLocked = isSizeLocked(layer)}
1257
+ {@const dragOk =
1258
+ !lockedPass &&
1259
+ (!marqueeBg || (isSelected && sceneLayer?.kind !== 'canvasPanel'))}
1260
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
1261
+ <div
1262
+ data-layer-item
1263
+ data-marquee-id={realId}
1264
+ class="contents"
1265
+ oncontextmenu={(e) => {
1266
+ if (lockedPass && isSynthetic) {
1267
+ e.preventDefault();
1268
+ e.stopPropagation();
1269
+ onselect?.([realId]);
1270
+ oncontextlayer?.({ id: realId, x: e.clientX, y: e.clientY });
1271
+ return;
1272
+ }
1273
+ if (lockedPass) return;
1228
1274
  e.preventDefault();
1229
1275
  e.stopPropagation();
1230
- onselect?.([realId]);
1276
+ if (!selectedSet.has(realId)) onselect?.([realId]);
1231
1277
  oncontextlayer?.({ id: realId, x: e.clientX, y: e.clientY });
1232
- return;
1233
- }
1234
- if (layer.locked) return;
1235
- e.preventDefault();
1236
- e.stopPropagation();
1237
- if (!selectedSet.has(realId)) onselect?.([realId]);
1238
- oncontextlayer?.({ id: realId, x: e.clientX, y: e.clientY });
1239
- }}
1240
- >
1241
- <MediaLayerItem
1242
- {layer}
1243
- {displayRect}
1244
- {clipPath}
1245
- stackIndex={paintIndex}
1246
- paintTransform={paintTransformForLayer(
1278
+ }}
1279
+ >
1280
+ <MediaLayerItem
1281
+ {layer}
1282
+ {displayRect}
1283
+ {clipPath}
1284
+ stackIndex={paintIndex}
1285
+ paintTransform={paintTransformForLayer(
1286
+ displayLayers,
1287
+ layer.id,
1288
+ paintAbsMap,
1289
+ layerById
1290
+ )}
1291
+ selected={isSelected}
1292
+ passthrough={lockedPass || groupedChildPassthrough(layer)}
1293
+ readOnly={isSynthetic}
1294
+ layoutPositionLocked={positionLocked || (marqueeBg && !dragOk)}
1295
+ layoutSizeLocked={sizeLocked}
1296
+ onclick={(e) => selectLayer(layer.id, e)}
1297
+ ondblclick={(e) => {
1298
+ if (lockedPass) return;
1299
+ const pt = clientToDoc(e.clientX, e.clientY);
1300
+ const hit = pickLayerAtDoc(pt) ?? realId;
1301
+ onenterlayer?.(hit);
1302
+ }}
1303
+ onchange={(rect) => handleRect(layer, rect)}
1304
+ oninteract={handleLayerInteract}
1305
+ />
1306
+ </div>
1307
+ {/if}
1308
+ {/each}
1309
+
1310
+ {#each ancestorOutlineIds as pid (pid)}
1311
+ {@const outline = paintAbsMap.get(pid)}
1312
+ {#if outline}
1313
+ <div
1314
+ class="pointer-events-none absolute z-[999980] outline outline-1 outline-[#3b82f6]/80 outline-dashed"
1315
+ style:left="{outline.x}px"
1316
+ style:top="{outline.y}px"
1317
+ style:width="{outline.w}px"
1318
+ style:height="{outline.h}px"
1319
+ style:transform={paintTransformForLayer(
1247
1320
  displayLayers,
1248
- layer.id,
1321
+ pid,
1249
1322
  paintAbsMap,
1250
1323
  layerById
1251
1324
  )}
1252
- selected={isSelected}
1253
- passthrough={!!layer.locked}
1254
- readOnly={isSynthetic}
1255
- layoutLocked={isLayoutLocked(layer) || (marqueeBg && !dragOk)}
1256
- onclick={(e) => selectLayer(layer.id, e)}
1257
- ondblclick={(e) => {
1258
- if (layer.locked) return;
1259
- const pt = clientToDoc(e.clientX, e.clientY);
1260
- const hit = pickLayerAtDoc(pt) ?? realId;
1261
- onenterlayer?.(hit);
1262
- }}
1263
- onchange={(rect) => handleRect(layer, rect)}
1264
- oninteract={handleLayerInteract}
1265
- />
1266
- </div>
1325
+ style:transform-origin="0 0"
1326
+ aria-hidden="true"
1327
+ ></div>
1267
1328
  {/if}
1268
1329
  {/each}
1269
1330
 
@@ -1280,13 +1341,9 @@
1280
1341
  maxY: scrollOver.maxY
1281
1342
  }}
1282
1343
  {@const vScroll =
1283
- chrome.maxY > 0
1284
- ? scrollBarMetrics(boxRect.h, chrome.maxY, chrome.y)
1285
- : null}
1344
+ chrome.maxY > 0 ? scrollBarMetrics(boxRect.h, chrome.maxY, chrome.y) : null}
1286
1345
  {@const hScroll =
1287
- chrome.maxX > 0
1288
- ? scrollBarMetrics(boxRect.w, chrome.maxX, chrome.x)
1289
- : null}
1346
+ chrome.maxX > 0 ? scrollBarMetrics(boxRect.w, chrome.maxX, chrome.x) : null}
1290
1347
  {#if vScroll || hScroll}
1291
1348
  <div
1292
1349
  class="pointer-events-none absolute z-[999990]"
@@ -1298,56 +1355,42 @@
1298
1355
  {#if vScroll}
1299
1356
  <!-- svelte-ignore a11y_no_static_element_interactions -->
1300
1357
  <div
1301
- class="pointer-events-auto absolute bottom-0 right-0 top-0 w-2.5 rounded-r-md bg-black/[0.04] dark:bg-white/[0.06]"
1358
+ class="bottom-0 right-0 top-0 w-2.5 rounded-r-md bg-black/[0.04] dark:bg-white/[0.06] pointer-events-auto absolute"
1302
1359
  style:margin-bottom={hScroll ? '10px' : '0'}
1303
1360
  onpointerdown={(e) =>
1304
1361
  jumpScrollTrack(box.id, 'y', chrome, vScroll, hScroll, e)}
1305
1362
  >
1306
1363
  <div
1307
1364
  data-scroll-thumb="y"
1308
- class="absolute left-0.5 right-0.5 cursor-grab rounded-full bg-slate-400/75 shadow-sm active:cursor-grabbing dark:bg-slate-500/85"
1365
+ class="left-0.5 right-0.5 bg-slate-400/75 shadow-sm dark:bg-slate-500/85 absolute cursor-grab rounded-full active:cursor-grabbing"
1309
1366
  style:top="{vScroll.offset}px"
1310
1367
  style:height="{vScroll.thumb}px"
1311
1368
  onpointerdown={(e) =>
1312
- beginScrollThumbDrag(
1313
- box.id,
1314
- 'y',
1315
- chrome,
1316
- vScroll,
1317
- hScroll,
1318
- e
1319
- )}
1369
+ beginScrollThumbDrag(box.id, 'y', chrome, vScroll, hScroll, e)}
1320
1370
  ></div>
1321
1371
  </div>
1322
1372
  {/if}
1323
1373
  {#if hScroll}
1324
1374
  <!-- svelte-ignore a11y_no_static_element_interactions -->
1325
1375
  <div
1326
- class="pointer-events-auto absolute bottom-0 left-0 h-2.5 rounded-b-md bg-black/[0.04] dark:bg-white/[0.06]"
1376
+ class="bottom-0 left-0 h-2.5 rounded-b-md bg-black/[0.04] dark:bg-white/[0.06] pointer-events-auto absolute"
1327
1377
  style:right={vScroll ? '10px' : '0'}
1328
1378
  onpointerdown={(e) =>
1329
1379
  jumpScrollTrack(box.id, 'x', chrome, vScroll, hScroll, e)}
1330
1380
  >
1331
1381
  <div
1332
1382
  data-scroll-thumb="x"
1333
- class="absolute top-0.5 bottom-0.5 cursor-grab rounded-full bg-slate-400/75 shadow-sm active:cursor-grabbing dark:bg-slate-500/85"
1383
+ class="top-0.5 bottom-0.5 bg-slate-400/75 shadow-sm dark:bg-slate-500/85 absolute cursor-grab rounded-full active:cursor-grabbing"
1334
1384
  style:left="{hScroll.offset}px"
1335
1385
  style:width="{hScroll.thumb}px"
1336
1386
  onpointerdown={(e) =>
1337
- beginScrollThumbDrag(
1338
- box.id,
1339
- 'x',
1340
- chrome,
1341
- vScroll,
1342
- hScroll,
1343
- e
1344
- )}
1387
+ beginScrollThumbDrag(box.id, 'x', chrome, vScroll, hScroll, e)}
1345
1388
  ></div>
1346
1389
  </div>
1347
1390
  {/if}
1348
1391
  {#if vScroll && hScroll}
1349
1392
  <div
1350
- class="absolute bottom-0 right-0 h-2.5 w-2.5 rounded-br-md bg-black/[0.06] dark:bg-white/[0.08]"
1393
+ class="bottom-0 right-0 h-2.5 w-2.5 rounded-br-md bg-black/[0.06] dark:bg-white/[0.08] absolute"
1351
1394
  aria-hidden="true"
1352
1395
  ></div>
1353
1396
  {/if}
@@ -1382,9 +1425,7 @@
1382
1425
  locked && 'cursor-default',
1383
1426
  hiding && 'opacity-0'
1384
1427
  ]}
1385
- style={guide.orientation === 'vertical'
1386
- ? `left:${screenX}px`
1387
- : `top:${screenY}px`}
1428
+ style={guide.orientation === 'vertical' ? `left:${screenX}px` : `top:${screenY}px`}
1388
1429
  title={locked ? 'Guide locked' : 'Drag to move · Double-click to remove'}
1389
1430
  onpointerdown={(e) => beginGuideDrag(guide, e)}
1390
1431
  ondblclick={() => removeGuide(guide.id)}
@@ -1393,7 +1434,7 @@
1393
1434
  class={[
1394
1435
  'pointer-events-none absolute bg-[#00c2ff]',
1395
1436
  guide.orientation === 'vertical'
1396
- ? 'left-1/2 top-0 h-full w-px -translate-x-1/2'
1437
+ ? 'top-0 left-1/2 h-full w-px -translate-x-1/2'
1397
1438
  : 'left-0 top-1/2 h-px w-full -translate-y-1/2',
1398
1439
  locked && 'opacity-60'
1399
1440
  ]}
@@ -1406,10 +1447,7 @@
1406
1447
 
1407
1448
  <!-- Pen draft preview -->
1408
1449
  {#if drawMode && draftPoints.length}
1409
- <svg
1410
- class="pointer-events-none absolute inset-0 z-45 overflow-visible"
1411
- aria-hidden="true"
1412
- >
1450
+ <svg class="inset-0 pointer-events-none absolute z-45 overflow-visible" aria-hidden="true">
1413
1451
  {#each draftPoints as p, i (i)}
1414
1452
  {@const sx = RULER_LEFT + tickX(p.x)}
1415
1453
  {@const sy = RULER_TOP + tickY(p.y)}
@@ -1442,14 +1480,14 @@
1442
1480
  {/if}
1443
1481
  </svg>
1444
1482
  <div
1445
- class="pointer-events-none absolute bottom-3 left-1/2 z-50 -translate-x-1/2 rounded-md bg-slate-900/90 px-3 py-1.5 text-[11px] text-white shadow"
1483
+ class="bottom-3 rounded-md bg-slate-900/90 px-3 py-1.5 text-white shadow pointer-events-none absolute left-1/2 z-50 -translate-x-1/2 text-[11px]"
1446
1484
  >
1447
1485
  Click to add · near start to close · double-click / Enter to finish · Esc cancel
1448
1486
  </div>
1449
1487
  {/if}
1450
1488
 
1451
1489
  <!-- Editable path points -->
1452
- {#if selectedPath && !drawMode && !selectedPath.locked}
1490
+ {#if selectedPath && !drawMode && !isEffectivelyLocked(workingLayers, selectedPath.id, workingById)}
1453
1491
  {@const docs = pathAbsPoints(selectedPath)}
1454
1492
  {#each docs as p, i (i)}
1455
1493
  {@const sx = RULER_LEFT + tickX(p.x)}
@@ -1461,7 +1499,7 @@
1461
1499
  <!-- svelte-ignore a11y_no_static_element_interactions -->
1462
1500
  <button
1463
1501
  type="button"
1464
- class="absolute z-45 h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full border border-dashed border-blue-400/80 bg-white/80"
1502
+ class="h-3 w-3 border-blue-400/80 bg-white/80 absolute z-45 -translate-x-1/2 -translate-y-1/2 rounded-full border border-dashed"
1465
1503
  style:left={`${mx}px`}
1466
1504
  style:top={`${my}px`}
1467
1505
  title="Double-click to add point"
@@ -1472,8 +1510,8 @@
1472
1510
  <div
1473
1511
  data-path-point={i}
1474
1512
  class={[
1475
- 'absolute z-46 h-3 w-3 -translate-x-1/2 -translate-y-1/2 cursor-grab rounded-full border-2 border-blue-500 bg-white shadow',
1476
- activePathPoint === i && 'ring-2 ring-blue-400'
1513
+ 'h-3 w-3 border-blue-500 bg-white shadow absolute z-46 -translate-x-1/2 -translate-y-1/2 cursor-grab rounded-full border-2',
1514
+ activePathPoint === i && 'ring-blue-400 ring-2'
1477
1515
  ]}
1478
1516
  style:left={`${sx}px`}
1479
1517
  style:top={`${sy}px`}
@@ -1485,16 +1523,16 @@
1485
1523
 
1486
1524
  <!-- Full-stage guide preview while dragging (edge to edge) -->
1487
1525
  {#if guidePreview}
1488
- <div class="pointer-events-none absolute inset-0 z-50" aria-hidden="true">
1526
+ <div class="inset-0 pointer-events-none absolute z-50" aria-hidden="true">
1489
1527
  {#if guidePreview.orientation === 'vertical'}
1490
1528
  <div
1491
- class="absolute top-0 bottom-0 w-px bg-[#00c2ff]"
1529
+ class="top-0 bottom-0 absolute w-px bg-[#00c2ff]"
1492
1530
  style:left={`${guidePreview.x}px`}
1493
1531
  style:box-shadow="0 0 0 1px rgba(0,194,255,0.35)"
1494
1532
  ></div>
1495
1533
  {:else}
1496
1534
  <div
1497
- class="absolute left-0 right-0 h-px bg-[#00c2ff]"
1535
+ class="left-0 right-0 absolute h-px bg-[#00c2ff]"
1498
1536
  style:top={`${guidePreview.y}px`}
1499
1537
  style:box-shadow="0 0 0 1px rgba(0,194,255,0.35)"
1500
1538
  ></div>