@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
@@ -22,6 +22,7 @@
22
22
  onfocus?: (e: FocusEvent) => void;
23
23
  onblur?: (e: FocusEvent) => void;
24
24
  onkeydown?: (e: KeyboardEvent) => void;
25
+ autofocus?: boolean;
25
26
  }
26
27
 
27
28
  let {
@@ -39,6 +40,7 @@
39
40
  maxLength,
40
41
  showCount = false,
41
42
  autoResize = false,
43
+ autofocus = false,
42
44
  class: className = '',
43
45
  oninput,
44
46
  onchange,
@@ -103,6 +105,7 @@
103
105
  {/if}
104
106
 
105
107
  <div class="relative w-full">
108
+ <!-- svelte-ignore a11y_autofocus -->
106
109
  <textarea
107
110
  id={textareaId}
108
111
  {name}
@@ -111,6 +114,7 @@
111
114
  {readonly}
112
115
  {required}
113
116
  {rows}
117
+ {autofocus}
114
118
  maxlength={maxLength}
115
119
  bind:value
116
120
  aria-describedby={helperText ? helperId : undefined}
@@ -19,6 +19,7 @@ interface TextareaProps {
19
19
  onfocus?: (e: FocusEvent) => void;
20
20
  onblur?: (e: FocusEvent) => void;
21
21
  onkeydown?: (e: KeyboardEvent) => void;
22
+ autofocus?: boolean;
22
23
  }
23
24
  declare const Textarea: import("svelte").Component<TextareaProps, {}, "value">;
24
25
  type Textarea = ReturnType<typeof Textarea>;
@@ -10,6 +10,7 @@
10
10
  import Tooltip from '../../atoms/Tooltip/Tooltip.svelte';
11
11
  import ColorPicker from '../ColorPicker/ColorPicker.svelte';
12
12
  import FileUploader from '../../organisms/FileUploader/FileUploader.svelte';
13
+ import Dialog from '../../organisms/Dialog/Dialog.svelte';
13
14
  import {
14
15
  alignLayerRect,
15
16
  applyTextAutoSize,
@@ -24,10 +25,12 @@
24
25
  } from '../../../utils/canvasDocument.js';
25
26
  import {
26
27
  ANCHOR_PRESETS,
27
- LAYOUT_BOX_KINDS,
28
+ LAYOUT_POSITION_KINDS,
29
+ LAYOUT_SIZE_KINDS,
28
30
  computeAbsoluteRects,
29
31
  contentPadding,
30
32
  isContainerKind,
33
+ isEffectivelyLocked,
31
34
  slotFromLocalRect,
32
35
  syncSlotFromRect
33
36
  } from '../../../utils/canvasHierarchy.js';
@@ -47,6 +50,8 @@
47
50
  import AlignCenterHorizontal from '@lucide/svelte/icons/align-center-horizontal';
48
51
  import AlignEndHorizontal from '@lucide/svelte/icons/align-end-horizontal';
49
52
  import AlignCenter from '@lucide/svelte/icons/align-center';
53
+ import AlignLeft from '@lucide/svelte/icons/align-left';
54
+ import AlignRight from '@lucide/svelte/icons/align-right';
50
55
  import Maximize2 from '@lucide/svelte/icons/maximize-2';
51
56
 
52
57
  type IconComp = Component<{ class?: string }>;
@@ -61,7 +66,12 @@
61
66
  ondocumentchange?: (doc: CanvasDocument) => void;
62
67
  onchange?: (layer: CanvasLayer) => void;
63
68
  onalign?: (align: CanvasAlign) => void;
64
- onexpose?: (payload: { layerId: string; field: string; exposed: boolean; label: string }) => void;
69
+ onexpose?: (payload: {
70
+ layerId: string;
71
+ field: string;
72
+ exposed: boolean;
73
+ label: string;
74
+ }) => void;
65
75
  onoverride?: (payload: { propId: string; value: unknown }) => void;
66
76
  oneditwidget?: (definitionId: string) => void;
67
77
  onbreakwidget?: () => void;
@@ -82,10 +92,21 @@
82
92
  onbreakwidget
83
93
  }: CanvasInspectorProps = $props();
84
94
 
95
+ let contentEditorOpen = $state(false);
96
+ let contentEditorLayerId: string | null = null;
97
+
98
+ $effect(() => {
99
+ const id = layer?.id ?? null;
100
+ if (id !== contentEditorLayerId) {
101
+ contentEditorLayerId = id;
102
+ contentEditorOpen = false;
103
+ }
104
+ });
105
+
85
106
  const exposeMode = $derived(!!widgetDefinition);
86
107
  const instanceDef = $derived(
87
108
  layer?.kind === 'widget' && layer.definitionId
88
- ? (doc?.widgets ?? []).find((w) => w.id === layer.definitionId) ?? null
109
+ ? ((doc?.widgets ?? []).find((w) => w.id === layer.definitionId) ?? null)
89
110
  : null
90
111
  );
91
112
  const exposedGroups = $derived(instanceDef ? groupExposedPropsByLayer(instanceDef) : []);
@@ -114,8 +135,16 @@
114
135
  const parentLayoutLocked = $derived.by(() => {
115
136
  if (!doc || !layer?.parentId) return false;
116
137
  const parent = doc.layers.find((l) => l.id === layer.parentId);
117
- return !!parent && LAYOUT_BOX_KINDS.has(parent.kind);
138
+ return !!parent && LAYOUT_POSITION_KINDS.has(parent.kind);
118
139
  });
140
+ const parentSizeLocked = $derived.by(() => {
141
+ if (!doc || !layer?.parentId) return false;
142
+ const parent = doc.layers.find((l) => l.id === layer.parentId);
143
+ return !!parent && LAYOUT_SIZE_KINDS.has(parent.kind);
144
+ });
145
+ const lockInherited = $derived(
146
+ !!doc && !!layer && isEffectivelyLocked(doc.layers, layer.id) && !layer.locked
147
+ );
119
148
 
120
149
  function exposedFlag(field: string): boolean | null {
121
150
  if (!exposeMode || !layer || !widgetDefinition) return null;
@@ -139,11 +168,6 @@
139
168
  { value: '700', label: 'Bold' },
140
169
  { value: '800', label: 'Extra bold' }
141
170
  ];
142
- const alignOptions = [
143
- { value: 'left', label: 'Left' },
144
- { value: 'center', label: 'Center' },
145
- { value: 'right', label: 'Right' }
146
- ];
147
171
  const styleOptions = [
148
172
  { value: 'normal', label: 'Normal' },
149
173
  { value: 'italic', label: 'Italic' }
@@ -196,13 +220,9 @@
196
220
  ];
197
221
 
198
222
  const parentKind = $derived(
199
- layer?.parentId && doc
200
- ? (doc.layers.find((l) => l.id === layer.parentId)?.kind ?? null)
201
- : null
202
- );
203
- const showChildAlignment = $derived(
204
- parentKind === 'hBox' || parentKind === 'vBox'
223
+ layer?.parentId && doc ? (doc.layers.find((l) => l.id === layer.parentId)?.kind ?? null) : null
205
224
  );
225
+ const showChildAlignment = $derived(parentKind === 'hBox' || parentKind === 'vBox');
206
226
  const showContainerPadding = $derived(
207
227
  !!layer && (isContainerKind(layer.kind) || layer.kind === 'widget')
208
228
  );
@@ -252,6 +272,12 @@
252
272
  { id: 'full', label: 'Fill canvas', icon: Maximize2 }
253
273
  ];
254
274
 
275
+ const textAlignDock: { id: 'left' | 'center' | 'right'; label: string; icon: IconComp }[] = [
276
+ { id: 'left', label: 'Align left', icon: AlignLeft },
277
+ { id: 'center', label: 'Align center', icon: AlignCenter },
278
+ { id: 'right', label: 'Align right', icon: AlignRight }
279
+ ];
280
+
255
281
  function patchDoc(partial: Partial<CanvasDocument>) {
256
282
  if (!doc) return;
257
283
  ondocumentchange?.({ ...doc, ...partial });
@@ -305,11 +331,11 @@
305
331
 
306
332
  <div class={['min-w-0', className]}>
307
333
  {#if selectionCount > 1}
308
- <p class="px-3 py-6 text-center text-xs text-muted">
334
+ <p class="px-3 py-6 text-xs text-muted text-center">
309
335
  {selectionCount} layers selected — use the bulk dock
310
336
  </p>
311
337
  {:else if !layer}
312
- <p class="px-3 py-6 text-center text-xs text-muted">Select a layer to edit</p>
338
+ <p class="px-3 py-6 text-xs text-muted text-center">Select a layer to edit</p>
313
339
  {:else}
314
340
  <PropertyGroup title="Layer">
315
341
  <PropertyField
@@ -331,11 +357,7 @@
331
357
  onreset={() => resetField('visible')}
332
358
  valueAlign="end"
333
359
  >
334
- <Toggle
335
- checked={layer.visible}
336
- onchange={(v) => patch({ visible: v })}
337
- size="sm"
338
- />
360
+ <Toggle checked={layer.visible} onchange={(v) => patch({ visible: v })} size="sm" />
339
361
  </PropertyField>
340
362
  <PropertyField
341
363
  label="Locked"
@@ -343,8 +365,18 @@
343
365
  onreset={() => resetField('locked')}
344
366
  valueAlign="end"
345
367
  >
346
- <Toggle checked={layer.locked} onchange={(v) => patch({ locked: v })} size="sm" />
368
+ <Toggle
369
+ checked={layer.locked || lockInherited}
370
+ disabled={lockInherited}
371
+ onchange={(v) => patch({ locked: v })}
372
+ size="sm"
373
+ />
347
374
  </PropertyField>
375
+ {#if lockInherited}
376
+ <p class="px-1 pb-1 leading-snug text-muted text-[10px]">
377
+ Locked by parent. Unlock the parent to edit this layer.
378
+ </p>
379
+ {/if}
348
380
  <PropertyField
349
381
  label="Opacity"
350
382
  exposed={exposedFlag('opacity')}
@@ -369,9 +401,9 @@
369
401
  {#if instanceDef && layer.kind === 'widget'}
370
402
  <PropertyGroup title="Widget · {instanceDef.name}">
371
403
  {#each exposedGroups as group (group.layerId)}
372
- <div class="space-y-0.5 border-b border-border/60 py-1 last:border-b-0">
404
+ <div class="space-y-0.5 border-border/60 py-1 border-b last:border-b-0">
373
405
  <p
374
- class="px-2 pt-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted"
406
+ class="px-2 pt-0.5 font-semibold tracking-wide text-muted text-[10px] uppercase"
375
407
  title="Blueprint layer"
376
408
  >
377
409
  {group.layerName}
@@ -423,21 +455,21 @@
423
455
  {/each}
424
456
  </div>
425
457
  {:else}
426
- <p class="px-2 py-2 text-[11px] text-muted">
458
+ <p class="px-2 py-2 text-muted text-[11px]">
427
459
  No exposed properties — edit the widget and use the eye icon on fields
428
460
  </p>
429
461
  {/each}
430
- <div class="flex flex-col gap-1 px-1 py-1">
462
+ <div class="gap-1 px-1 py-1 flex flex-col">
431
463
  <button
432
464
  type="button"
433
- class="rounded-md border border-border px-2 py-1.5 text-xs hover:bg-surface-overlay"
465
+ class="rounded-md border-border px-2 py-1.5 text-xs hover:bg-surface-overlay border"
434
466
  onclick={() => layer.definitionId && oneditwidget?.(layer.definitionId)}
435
467
  >
436
468
  Edit widget blueprint
437
469
  </button>
438
470
  <button
439
471
  type="button"
440
- class="rounded-md border border-border px-2 py-1.5 text-xs text-danger hover:bg-surface-overlay"
472
+ class="rounded-md border-border px-2 py-1.5 text-xs text-danger hover:bg-surface-overlay border"
441
473
  onclick={() => onbreakwidget?.()}
442
474
  >
443
475
  Break instance
@@ -454,7 +486,10 @@
454
486
  value={layer.slotName ?? layer.name}
455
487
  oninput={(e) => {
456
488
  const v = (e.currentTarget as HTMLInputElement).value;
457
- patch({ slotName: v, name: layer.name === (layer.slotName ?? layer.name) ? v : layer.name });
489
+ patch({
490
+ slotName: v,
491
+ name: layer.name === (layer.slotName ?? layer.name) ? v : layer.name
492
+ });
458
493
  }}
459
494
  />
460
495
  </PropertyField>
@@ -482,9 +517,9 @@
482
517
  onchange={(v) => setAnchorPreset(v)}
483
518
  />
484
519
  </PropertyField>
485
- <p class="px-1 pb-1 text-[10px] leading-snug text-muted">
486
- Cómo se sujeta al padre al redimensionarlo: esquina fija, centro, o Stretch para
487
- estirarse con el contenedor (como UMG).
520
+ <p class="px-1 pb-1 leading-snug text-muted text-[10px]">
521
+ Cómo se sujeta al padre al redimensionarlo: esquina fija, centro, o Stretch para estirarse
522
+ con el contenedor (como UMG).
488
523
  </p>
489
524
  <PropertyField label="Size rule">
490
525
  <Select
@@ -504,7 +539,7 @@
504
539
  />
505
540
  </PropertyField>
506
541
  {#if showChildAlignment}
507
- <div class="grid grid-cols-2 gap-2">
542
+ <div class="gap-2 grid grid-cols-2">
508
543
  <PropertyField label={parentKind === 'hBox' ? 'Align Y' : 'Align X'}>
509
544
  <Select
510
545
  size="xs"
@@ -535,7 +570,7 @@
535
570
  </div>
536
571
  {/if}
537
572
  {#if showContainerPadding}
538
- <div class="grid grid-cols-2 gap-x-1 gap-y-0.5">
573
+ <div class="gap-x-1 gap-y-0.5 grid grid-cols-2">
539
574
  <PropertyField label="Pad L" labelWidth="2.75rem" compact>
540
575
  <Input
541
576
  type="number"
@@ -656,8 +691,7 @@
656
691
  type="number"
657
692
  size="sm"
658
693
  value={String(layer.gap ?? 0)}
659
- oninput={(e) =>
660
- patch({ gap: Number((e.currentTarget as HTMLInputElement).value) })}
694
+ oninput={(e) => patch({ gap: Number((e.currentTarget as HTMLInputElement).value) })}
661
695
  />
662
696
  </PropertyField>
663
697
  {/if}
@@ -673,16 +707,18 @@
673
707
  min={1}
674
708
  value={String(layer.columns ?? 2)}
675
709
  oninput={(e) =>
676
- patch({ columns: Math.max(1, Number((e.currentTarget as HTMLInputElement).value) || 1) })}
710
+ patch({
711
+ columns: Math.max(1, Number((e.currentTarget as HTMLInputElement).value) || 1)
712
+ })}
677
713
  />
678
714
  </PropertyField>
679
715
  {/if}
680
716
  </PropertyGroup>
681
717
 
682
718
  <PropertyGroup title="Transform">
683
- <div class="mx-1 mb-1.5 flex w-full min-w-0 flex-col gap-1.5">
719
+ <div class="mx-1 mb-1.5 min-w-0 gap-1.5 flex w-full flex-col">
684
720
  <div
685
- class="flex w-full flex-nowrap items-center justify-between gap-0 overflow-x-auto rounded-xl border border-border bg-surface-elevated p-0.5 shadow-sm"
721
+ class="gap-0 rounded-xl border-border bg-surface-elevated p-0.5 shadow-sm flex w-full flex-nowrap items-center justify-between overflow-x-auto border"
686
722
  role="toolbar"
687
723
  aria-label="Position"
688
724
  >
@@ -693,6 +729,7 @@
693
729
  label={action.label}
694
730
  size="xs"
695
731
  variant="ghost"
732
+ disabled={parentLayoutLocked}
696
733
  onclick={() => applyAlign(action.id)}
697
734
  >
698
735
  <Icon class="h-3.5 w-3.5" />
@@ -701,7 +738,7 @@
701
738
  {/each}
702
739
  </div>
703
740
  <div
704
- class="mx-auto flex w-fit flex-nowrap items-center gap-0 rounded-xl border border-border bg-surface-elevated p-0.5 shadow-sm"
741
+ class="gap-0 rounded-xl border-border bg-surface-elevated p-0.5 shadow-sm mx-auto flex w-fit flex-nowrap items-center border"
705
742
  role="toolbar"
706
743
  aria-label="Flip"
707
744
  >
@@ -732,15 +769,14 @@
732
769
  </div>
733
770
  </div>
734
771
 
735
- <div class="grid grid-cols-2 gap-x-1 gap-y-0.5">
772
+ <div class="gap-x-1 gap-y-0.5 grid grid-cols-2">
736
773
  <PropertyField label="X" labelWidth="1.25rem" compact>
737
774
  <Input
738
775
  type="number"
739
776
  size="sm"
740
777
  disabled={parentLayoutLocked}
741
778
  value={String(Math.round(layer.rect.x))}
742
- oninput={(e) =>
743
- patchRect({ x: Number((e.currentTarget as HTMLInputElement).value) })}
779
+ oninput={(e) => patchRect({ x: Number((e.currentTarget as HTMLInputElement).value) })}
744
780
  />
745
781
  </PropertyField>
746
782
  <PropertyField label="Y" labelWidth="1.25rem" compact>
@@ -749,36 +785,41 @@
749
785
  size="sm"
750
786
  disabled={parentLayoutLocked}
751
787
  value={String(Math.round(layer.rect.y))}
752
- oninput={(e) =>
753
- patchRect({ y: Number((e.currentTarget as HTMLInputElement).value) })}
788
+ oninput={(e) => patchRect({ y: Number((e.currentTarget as HTMLInputElement).value) })}
754
789
  />
755
790
  </PropertyField>
756
791
  <PropertyField label="W" labelWidth="1.25rem" compact>
757
792
  <Input
758
793
  type="number"
759
794
  size="sm"
795
+ disabled={parentSizeLocked}
760
796
  value={String(Math.round(layer.rect.w))}
761
- oninput={(e) =>
762
- patchRect({ w: Number((e.currentTarget as HTMLInputElement).value) })}
797
+ oninput={(e) => patchRect({ w: Number((e.currentTarget as HTMLInputElement).value) })}
763
798
  />
764
799
  </PropertyField>
765
800
  <PropertyField label="H" labelWidth="1.25rem" compact>
766
801
  <Input
767
802
  type="number"
768
803
  size="sm"
804
+ disabled={parentSizeLocked}
769
805
  value={String(Math.round(layer.rect.h))}
770
- oninput={(e) =>
771
- patchRect({ h: Number((e.currentTarget as HTMLInputElement).value) })}
806
+ oninput={(e) => patchRect({ h: Number((e.currentTarget as HTMLInputElement).value) })}
772
807
  />
773
808
  </PropertyField>
774
809
  </div>
775
- {#if parentLayoutLocked}
776
- <p class="px-1 pb-1 text-[10px] leading-snug text-muted">
777
- X/Y los controla el layout del padre (HBox, VBox, Grid…). Usa Group / Border /
778
- Overlay / Canvas Panel para posición libre.
810
+ {#if parentLayoutLocked || parentSizeLocked}
811
+ <p class="px-1 pb-1 leading-snug text-muted text-[10px]">
812
+ {#if parentLayoutLocked && parentSizeLocked}
813
+ Position and size follow the parent layout (Grid / Scale Box).
814
+ {:else if parentLayoutLocked}
815
+ X/Y follow the parent layout (HBox, VBox, Wrap, Grid). Resize is still allowed. Use
816
+ Group / Border / Overlay for free placement.
817
+ {:else}
818
+ W/H follow the parent layout (Grid / Scale Box).
819
+ {/if}
779
820
  </p>
780
821
  {:else if layer.parentId}
781
- <p class="px-1 pb-1 text-[10px] leading-snug text-muted">
822
+ <p class="px-1 pb-1 leading-snug text-muted text-[10px]">
782
823
  X/Y relativos al padre (0,0 = esquina superior izquierda del contenido).
783
824
  </p>
784
825
  {/if}
@@ -877,7 +918,8 @@
877
918
  size="sm"
878
919
  value={layer.src ?? ''}
879
920
  placeholder="https://…"
880
- oninput={(e) => patch({ src: (e.currentTarget as HTMLInputElement).value || undefined })}
921
+ oninput={(e) =>
922
+ patch({ src: (e.currentTarget as HTMLInputElement).value || undefined })}
881
923
  />
882
924
  </PropertyField>
883
925
  <PropertyField
@@ -924,11 +966,27 @@
924
966
  modified={fieldModified('text')}
925
967
  onreset={() => resetField('text')}
926
968
  >
927
- <Textarea
928
- rows={3}
929
- value={layer.text ?? ''}
930
- oninput={(e) => patch({ text: (e.currentTarget as HTMLTextAreaElement).value })}
931
- />
969
+ <div class="relative min-w-0 w-full">
970
+ <Textarea
971
+ rows={2}
972
+ placeholder="Write the text…"
973
+ class="[&_textarea]:min-h-9 [&_textarea]:resize-none [&_textarea]:py-1.5 [&_textarea]:pr-8 [&_textarea]:text-xs"
974
+ value={layer.text ?? ''}
975
+ oninput={(e) => patch({ text: (e.currentTarget as HTMLTextAreaElement).value })}
976
+ />
977
+ <div class="absolute top-0.5 right-0.5">
978
+ <Tooltip content="Open large editor" side="left">
979
+ <IconButton
980
+ label="Edit content"
981
+ size="xs"
982
+ variant="ghost"
983
+ onclick={() => (contentEditorOpen = true)}
984
+ >
985
+ <Maximize2 class="h-3.5 w-3.5" />
986
+ </IconButton>
987
+ </Tooltip>
988
+ </div>
989
+ </div>
932
990
  </PropertyField>
933
991
  <PropertyField
934
992
  label="Auto size"
@@ -981,13 +1039,33 @@
981
1039
  onchange={(v) => patch({ textDecoration: v as CanvasLayer['textDecoration'] })}
982
1040
  />
983
1041
  </PropertyField>
984
- <PropertyField label="Align">
985
- <Select
986
- size="xs"
987
- options={alignOptions}
988
- value={layer.textAlign ?? 'left'}
989
- onchange={(v) => patch({ textAlign: v as CanvasLayer['textAlign'] })}
990
- />
1042
+ <PropertyField
1043
+ label="Align"
1044
+ modified={fieldModified('textAlign')}
1045
+ onreset={() => resetField('textAlign')}
1046
+ >
1047
+ <div
1048
+ class="gap-0 rounded-xl border-border bg-surface-elevated p-0.5 shadow-sm flex w-full items-center justify-between border"
1049
+ role="toolbar"
1050
+ aria-label="Text align"
1051
+ >
1052
+ {#each textAlignDock as action (action.id)}
1053
+ {@const Icon = action.icon}
1054
+ {@const active = (layer.textAlign ?? 'left') === action.id}
1055
+ <Tooltip content={action.label} side="top" class="min-w-0 flex-1">
1056
+ <IconButton
1057
+ label={action.label}
1058
+ size="xs"
1059
+ variant={active ? 'secondary' : 'ghost'}
1060
+ class="w-full"
1061
+ aria-pressed={active}
1062
+ onclick={() => patch({ textAlign: action.id })}
1063
+ >
1064
+ <Icon class="h-3.5 w-3.5" />
1065
+ </IconButton>
1066
+ </Tooltip>
1067
+ {/each}
1068
+ </div>
991
1069
  </PropertyField>
992
1070
  <PropertyField
993
1071
  label="Color"
@@ -1053,6 +1131,22 @@
1053
1131
  />
1054
1132
  </PropertyField>
1055
1133
  </PropertyGroup>
1134
+ <Dialog
1135
+ bind:open={contentEditorOpen}
1136
+ title="Edit content"
1137
+ description="Changes apply to the canvas as you type."
1138
+ size="lg"
1139
+ confirmLabel="Done"
1140
+ showCancel={false}
1141
+ >
1142
+ <Textarea
1143
+ rows={12}
1144
+ autofocus
1145
+ placeholder="Write the text…"
1146
+ value={layer.text ?? ''}
1147
+ oninput={(e) => patch({ text: (e.currentTarget as HTMLTextAreaElement).value })}
1148
+ />
1149
+ </Dialog>
1056
1150
  {/if}
1057
1151
 
1058
1152
  {#if shapeKinds.includes(layer.kind) && layer.kind !== 'sticky'}
@@ -1127,7 +1221,7 @@
1127
1221
  {#if doc && !layer && selectionCount <= 1}
1128
1222
  <PropertyGroup title={widgetDefinition ? 'Widget artboard' : 'Artboard'}>
1129
1223
  {#if widgetDefinition}
1130
- <div class="grid grid-cols-2 gap-2 px-1">
1224
+ <div class="gap-2 px-1 grid grid-cols-2">
1131
1225
  <PropertyField label="Width">
1132
1226
  <Input
1133
1227
  type="number"
@@ -1152,7 +1246,7 @@
1152
1246
  </PropertyField>
1153
1247
  </div>
1154
1248
  {:else}
1155
- <p class="px-1 text-[11px] text-muted">{doc.width} × {doc.height}px</p>
1249
+ <p class="px-1 text-muted text-[11px]">{doc.width} × {doc.height}px</p>
1156
1250
  {/if}
1157
1251
  <PropertyField label="Background">
1158
1252
  <ColorPicker
@@ -1163,7 +1257,7 @@
1163
1257
  />
1164
1258
  </PropertyField>
1165
1259
  {#if widgetDefinition}
1166
- <p class="px-1 pt-1 text-[10px] text-muted">
1260
+ <p class="px-1 pt-1 text-muted text-[10px]">
1167
1261
  Select a layer to edit it. Use the eye icon on properties to expose them on instances.
1168
1262
  </p>
1169
1263
  {/if}
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { on } from 'svelte/events';
3
+ import { popoverInvokerToggle } from '../../../utils/popoverInvoker.js';
3
4
 
4
5
  export interface CascaderOption {
5
6
  value: string;
@@ -168,6 +169,7 @@
168
169
  {disabled}
169
170
  popovertarget={popoverId}
170
171
  popovertargetaction="toggle"
172
+ {@attach popoverInvokerToggle(() => popoverEl)}
171
173
  class={[
172
174
  'flex h-10 w-full items-center justify-between gap-2 rounded-lg border border-border bg-surface-elevated px-3.5 text-left text-sm outline-none transition-colors',
173
175
  'focus-visible:border-brand-500 focus-visible:ring-2 focus-visible:ring-brand-500/20',
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { createId } from '../../../utils/id.js';
3
+ import { popoverInvokerToggle } from '../../../utils/popoverInvoker.js';
3
4
 
4
5
  export type ColorFormat = 'hex' | 'rgb' | 'hsl';
5
6
  type ColorPickerSize = 'xs' | 'sm' | 'md' | 'lg';
@@ -220,22 +221,10 @@
220
221
  ].join(';');
221
222
  }
222
223
 
223
- function showPanel() {
224
- if (disabled || !panelEl) return;
225
- positionPanel();
226
- if (!panelEl.matches(':popover-open')) panelEl.showPopover();
227
- }
228
-
229
224
  function hidePanel() {
230
225
  if (panelEl?.matches(':popover-open')) panelEl.hidePopover();
231
226
  }
232
227
 
233
- function togglePanel() {
234
- if (disabled) return;
235
- if (panelEl?.matches(':popover-open')) hidePanel();
236
- else showPanel();
237
- }
238
-
239
228
  function handleBeforeToggle(event: ToggleEvent) {
240
229
  if (event.newState === 'open') {
241
230
  if (disabled) {
@@ -270,7 +259,9 @@
270
259
  aria-expanded={open}
271
260
  aria-controls={panelId}
272
261
  aria-haspopup="dialog"
273
- onclick={togglePanel}
262
+ popovertarget={panelId}
263
+ popovertargetaction="toggle"
264
+ {@attach popoverInvokerToggle(() => panelEl)}
274
265
  class={[
275
266
  'flex w-full items-center border border-border bg-surface-elevated text-left transition-colors',
276
267
  triggerSizeClasses[size],
@@ -7,6 +7,7 @@
7
7
  import { i18n } from '../../../utils/i18n.svelte.js';
8
8
  import { resolveLocaleTag } from '../../../utils/i18n.js';
9
9
  import { createId } from '../../../utils/id.js';
10
+ import { popoverInvokerToggle } from '../../../utils/popoverInvoker.js';
10
11
 
11
12
  export type DatePickerPlacement =
12
13
  | 'auto'
@@ -417,6 +418,7 @@
417
418
  {disabled}
418
419
  popovertarget={panelId}
419
420
  popovertargetaction="toggle"
421
+ {@attach popoverInvokerToggle(() => panelEl)}
420
422
  onclick={() => {
421
423
  activeField = 'value';
422
424
  }}
@@ -6,6 +6,7 @@
6
6
  import type { TimeFormat } from '../TimePicker/TimePicker.svelte';
7
7
  import { i18n } from '../../../utils/i18n.svelte.js';
8
8
  import { createId } from '../../../utils/id.js';
9
+ import { popoverInvokerToggle } from '../../../utils/popoverInvoker.js';
9
10
 
10
11
  interface DateTimePickerProps {
11
12
  /** Date part `YYYY-MM-DD`. */
@@ -359,6 +360,7 @@
359
360
  {disabled}
360
361
  popovertarget={panelId}
361
362
  popovertargetaction="toggle"
363
+ {@attach popoverInvokerToggle(() => panelEl)}
362
364
  aria-expanded={open}
363
365
  aria-haspopup="dialog"
364
366
  aria-controls={panelId}
@@ -2,6 +2,7 @@
2
2
  import type { Component, Snippet } from 'svelte';
3
3
  import { on } from 'svelte/events';
4
4
  import { createId } from '../../../utils/id.js';
5
+ import { popoverInvokerToggle } from '../../../utils/popoverInvoker.js';
5
6
 
6
7
  export interface DropdownItem {
7
8
  id: string;
@@ -248,23 +249,6 @@
248
249
  if (menuEl?.matches(':popover-open')) menuEl.hidePopover();
249
250
  }
250
251
 
251
- $effect(() => {
252
- const btn = triggerEl;
253
- if (!btn) return;
254
- const onClick = (event: MouseEvent) => {
255
- event.stopPropagation();
256
- if (disabled) return;
257
- const el = menuEl;
258
- if (!el) return;
259
- const isOpen = el.matches(':popover-open');
260
- setTimeout(() => {
261
- if (isOpen) closeMenu();
262
- else openMenu();
263
- }, 0);
264
- };
265
- btn.addEventListener('click', onClick);
266
- return () => btn.removeEventListener('click', onClick);
267
- });
268
252
 
269
253
  function handleBeforeToggle(event: ToggleEvent) {
270
254
  if (event.newState === 'open') {
@@ -445,6 +429,9 @@
445
429
  aria-haspopup="menu"
446
430
  aria-expanded={open}
447
431
  aria-controls={menuId}
432
+ popovertarget={menuId}
433
+ popovertargetaction="toggle"
434
+ {@attach popoverInvokerToggle(() => menuEl)}
448
435
  >
449
436
  {#if trigger}
450
437
  {@render trigger()}
@@ -607,8 +594,10 @@
607
594
  </div>
608
595
 
609
596
  <style>
610
- .dropdown-menu {
597
+ .dropdown-menu[popover] {
611
598
  position: fixed;
599
+ inset: unset;
600
+ margin: 0;
612
601
  }
613
602
 
614
603
  .dropdown-menu-list {