@r2digisolutions/components 0.23.1 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/components/atoms/BrandMark/BrandMark.svelte +47 -7
  2. package/dist/components/atoms/BrandMark/BrandMark.svelte.d.ts +4 -0
  3. package/dist/components/atoms/Slider/Slider.svelte +19 -15
  4. package/dist/components/atoms/Slider/Slider.svelte.d.ts +2 -0
  5. package/dist/components/atoms/VerifiedBadge/VerifiedBadge.svelte +76 -0
  6. package/dist/components/atoms/VerifiedBadge/VerifiedBadge.svelte.d.ts +12 -0
  7. package/dist/components/molecules/AuthCard/AuthCard.svelte +19 -4
  8. package/dist/components/molecules/AuthCard/AuthCard.svelte.d.ts +4 -0
  9. package/dist/components/molecules/CanvasElementsPanel/CanvasElementsPanel.svelte +90 -26
  10. package/dist/components/molecules/CanvasInspector/CanvasInspector.svelte +176 -5
  11. package/dist/components/molecules/Combobox/Combobox.svelte +2 -2
  12. package/dist/components/molecules/DateTimePicker/DateTimePicker.svelte +121 -33
  13. package/dist/components/molecules/FormSection/FormSection.svelte +25 -28
  14. package/dist/components/molecules/ImageEditor/ImageEditor.svelte +183 -0
  15. package/dist/components/molecules/ImageEditor/ImageEditor.svelte.d.ts +19 -0
  16. package/dist/components/molecules/LocaleSwitcher/LocaleSwitcher.svelte +58 -35
  17. package/dist/components/molecules/MediaLayerItem/MediaLayerItem.svelte +293 -39
  18. package/dist/components/molecules/MediaLayerItem/MediaLayerItem.svelte.d.ts +6 -1
  19. package/dist/components/molecules/MediaStage/MediaStage.svelte +302 -245
  20. package/dist/components/molecules/MentionInput/MentionInput.svelte +332 -120
  21. package/dist/components/molecules/MentionInput/MentionInput.svelte.d.ts +13 -2
  22. package/dist/components/molecules/Select/Select.svelte +14 -1
  23. package/dist/components/molecules/Select/Select.svelte.d.ts +3 -0
  24. package/dist/components/molecules/UserMenu/UserMenu.svelte +30 -27
  25. package/dist/components/molecules/WidgetFrame/WidgetFrame.svelte +200 -17
  26. package/dist/components/molecules/WidgetFrame/WidgetFrame.svelte.d.ts +14 -0
  27. package/dist/components/organisms/AppShell/AppShell.svelte +7 -1
  28. package/dist/components/organisms/AppShell/AppShell.svelte.d.ts +2 -0
  29. package/dist/components/organisms/AuthShell/AuthShell.svelte +61 -29
  30. package/dist/components/organisms/AuthShell/AuthShell.svelte.d.ts +4 -0
  31. package/dist/components/organisms/CanvasEditor/CanvasEditor.svelte +156 -7
  32. package/dist/components/organisms/CanvasEditor/CanvasEditor.svelte.d.ts +5 -0
  33. package/dist/components/organisms/Navbar/Navbar.svelte +2 -2
  34. package/dist/components/organisms/ProfileHeaderUploader/ProfileHeaderUploader.svelte +343 -140
  35. package/dist/components/organisms/ProfileHeaderUploader/ProfileHeaderUploader.svelte.d.ts +25 -1
  36. package/dist/index.d.ts +4 -1
  37. package/dist/index.js +3 -1
  38. package/dist/styles.css +17 -0
  39. package/dist/utils/canvasDocument.d.ts +56 -4
  40. package/dist/utils/canvasDocument.js +91 -2
  41. package/dist/utils/canvasExport.d.ts +1 -1
  42. package/dist/utils/canvasExport.js +15 -25
  43. package/package.json +1 -1
@@ -101,7 +101,8 @@
101
101
  };
102
102
  });
103
103
 
104
- const avatarSize = $derived(size === 'sm' ? 'sm' : size === 'lg' ? 'lg' : 'md');
104
+ const compact = $derived(size === 'sm' && !showSubtitle);
105
+ const avatarSize = $derived(compact ? 'xs' : size === 'lg' ? 'lg' : size === 'sm' ? 'sm' : 'md');
105
106
  const statusLabel = $derived(
106
107
  status === 'online'
107
108
  ? 'Online'
@@ -221,34 +222,36 @@
221
222
  });
222
223
  </script>
223
224
 
224
- <div class={['relative flex w-full min-w-0', className]}>
225
+ <div class={['min-w-0 relative flex w-full', className]}>
225
226
  <button
226
227
  bind:this={triggerEl}
227
228
  type="button"
228
229
  class={[
229
- 'inline-flex w-full min-w-0 max-w-full items-center text-left transition-colors',
230
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500/40',
230
+ 'min-w-0 inline-flex w-full max-w-full items-center text-left transition-colors',
231
+ 'focus-visible:ring-brand-500/40 focus-visible:ring-2 focus-visible:outline-none',
231
232
  variant === 'outline' &&
232
- 'gap-2.5 rounded-xl border border-border bg-surface-elevated hover:bg-surface-overlay',
233
- variant === 'ghost' && 'gap-2 rounded-lg border border-transparent hover:bg-surface-overlay',
234
- size === 'sm' && (variant === 'ghost' ? 'px-1.5 py-1' : 'px-2 py-1.5'),
233
+ 'gap-2.5 rounded-xl border-border bg-surface-elevated hover:bg-surface-overlay border',
234
+ variant === 'ghost' && 'gap-2 rounded-lg hover:bg-surface-overlay border border-transparent',
235
+ compact && 'h-8 gap-2 py-0',
236
+ compact && (variant === 'ghost' ? 'px-1' : 'px-2'),
237
+ !compact && size === 'sm' && (variant === 'ghost' ? 'px-1.5 py-1' : 'px-2.5 py-1'),
235
238
  size === 'md' && (variant === 'ghost' ? 'px-2 py-1.5' : 'px-2.5 py-2'),
236
239
  size === 'lg' && (variant === 'ghost' ? 'px-2.5 py-2' : 'px-3 py-2.5'),
237
- open && (variant === 'ghost' ? 'bg-surface-overlay' : 'ring-2 ring-brand-500/30')
240
+ open && (variant === 'ghost' ? 'bg-surface-overlay' : 'ring-brand-500/30 ring-2')
238
241
  ]}
239
242
  aria-haspopup="menu"
240
243
  aria-expanded={open}
241
244
  aria-controls={menuId || undefined}
242
245
  {@attach popoverInvokerToggle(() => menuEl)}
243
246
  >
244
- <span class="shrink-0">
247
+ <span class="flex shrink-0 items-center">
245
248
  <Avatar {src} {name} size={avatarSize} {status} />
246
249
  </span>
247
250
  {#if showMeta}
248
- <span class="hidden min-w-0 flex-1 overflow-hidden sm:block">
249
- <span class="block truncate text-sm font-medium text-primary">{name}</span>
251
+ <span class="min-w-0 sm:block hidden flex-1 overflow-hidden">
252
+ <span class="text-sm font-medium text-primary block truncate">{name}</span>
250
253
  {#if showSubtitle && (email || role)}
251
- <span class="block truncate text-xs text-muted">
254
+ <span class="text-xs text-muted block truncate">
252
255
  {role ? `${role}` : ''}{role && email ? ' · ' : ''}{email ?? ''}
253
256
  </span>
254
257
  {/if}
@@ -256,7 +259,7 @@
256
259
  {/if}
257
260
  {#if showChevron}
258
261
  <svg
259
- class={['h-4 w-4 shrink-0 text-muted transition-transform', open && 'rotate-180']}
262
+ class={['h-4 w-4 text-muted shrink-0 transition-transform', open && 'rotate-180']}
260
263
  viewBox="0 0 24 24"
261
264
  fill="none"
262
265
  stroke="currentColor"
@@ -278,26 +281,26 @@
278
281
  style={menuStyle}
279
282
  ontoggle={handleToggle}
280
283
  onbeforetoggle={handleBeforeToggle}
281
- class="user-menu m-0 overflow-hidden rounded-2xl border border-border bg-surface-elevated shadow-xl inset-auto outline-none"
284
+ class="user-menu m-0 rounded-2xl border-border bg-surface-elevated shadow-xl inset-auto overflow-hidden border outline-none"
282
285
  >
283
286
  {#if header}
284
287
  {@render header()}
285
288
  {:else}
286
- <div class="border-b border-border bg-surface-overlay/50 px-3.5 py-3">
287
- <div class="flex items-start gap-3">
289
+ <div class="border-border bg-surface-overlay/50 px-3.5 py-3 border-b">
290
+ <div class="gap-3 flex items-start">
288
291
  <Avatar {src} {name} size="lg" {status} />
289
- <div class="min-w-0 flex-1 pt-0.5">
290
- <p class="truncate text-sm font-semibold text-primary">{name}</p>
292
+ <div class="min-w-0 pt-0.5 flex-1">
293
+ <p class="text-sm font-semibold text-primary truncate">{name}</p>
291
294
  {#if email}
292
- <p class="truncate text-xs text-muted">{email}</p>
295
+ <p class="text-xs text-muted truncate">{email}</p>
293
296
  {/if}
294
- <div class="mt-2 flex flex-wrap items-center gap-2">
297
+ <div class="mt-2 gap-2 flex flex-wrap items-center">
295
298
  {#if status && statusLabel}
296
299
  <StatusDot {status} size="sm" showLabel label={statusLabel} />
297
300
  {/if}
298
301
  {#if role}
299
302
  <span
300
- class="rounded-md bg-surface-elevated px-1.5 py-0.5 text-[10px] font-medium text-secondary ring-1 ring-border"
303
+ class="rounded-md bg-surface-elevated px-1.5 py-0.5 font-medium text-secondary ring-border text-[10px] ring-1"
301
304
  >
302
305
  {role}
303
306
  </span>
@@ -314,7 +317,7 @@
314
317
  <div class="p-1.5">
315
318
  {#each items as item (item.id)}
316
319
  {#if item.separator}
317
- <div class="my-1.5 border-t border-border" role="separator"></div>
320
+ <div class="my-1.5 border-border border-t" role="separator"></div>
318
321
  {:else}
319
322
  <button
320
323
  type="button"
@@ -322,8 +325,8 @@
322
325
  disabled={item.disabled}
323
326
  onclick={() => select(item)}
324
327
  class={[
325
- 'flex w-full items-start gap-2 rounded-xl px-2.5 py-2 text-left transition-colors',
326
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500/30',
328
+ 'gap-2 rounded-xl px-2.5 py-2 flex w-full items-start text-left transition-colors',
329
+ 'focus-visible:ring-brand-500/30 focus-visible:ring-2 focus-visible:outline-none',
327
330
  item.destructive
328
331
  ? 'text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40'
329
332
  : 'text-primary hover:bg-surface-overlay',
@@ -331,13 +334,13 @@
331
334
  ]}
332
335
  >
333
336
  <span class="min-w-0 flex-1">
334
- <span class="block text-sm font-medium">{item.label}</span>
337
+ <span class="text-sm font-medium block">{item.label}</span>
335
338
  {#if item.description}
336
- <span class="block text-xs text-muted">{item.description}</span>
339
+ <span class="text-xs text-muted block">{item.description}</span>
337
340
  {/if}
338
341
  </span>
339
342
  {#if item.shortcut}
340
- <span class="mt-0.5 shrink-0 font-mono text-[10px] text-muted">{item.shortcut}</span>
343
+ <span class="mt-0.5 font-mono text-muted shrink-0 text-[10px]">{item.shortcut}</span>
341
344
  {/if}
342
345
  </button>
343
346
  {/if}
@@ -6,12 +6,13 @@
6
6
 
7
7
  <script lang="ts">
8
8
  import type { Snippet } from 'svelte';
9
- import { getContext } from 'svelte';
9
+ import { getContext, untrack } from 'svelte';
10
10
  import DragHandle from '../../atoms/DragHandle/DragHandle.svelte';
11
11
  import Skeleton from '../../atoms/Skeleton/Skeleton.svelte';
12
12
  import Spinner from '../../atoms/Spinner/Spinner.svelte';
13
13
  import ChevronDown from '@lucide/svelte/icons/chevron-down';
14
14
  import RefreshCw from '@lucide/svelte/icons/refresh-cw';
15
+ import RotateCw from '@lucide/svelte/icons/rotate-cw';
15
16
  import X from '@lucide/svelte/icons/x';
16
17
  import {
17
18
  WIDGET_CANVAS_CONTEXT,
@@ -67,6 +68,18 @@
67
68
  stackIndex?: number;
68
69
  /** CSS transform on the freeform root (e.g. rotate/flip) so chrome rotates too. */
69
70
  transform?: string;
71
+ /** Current rotation in degrees. With `onrotation`, Canva chrome shows a rotate handle. */
72
+ rotation?: number;
73
+ onrotation?: (degrees: number) => void;
74
+ /**
75
+ * Size the frame from its content (`width: max-content; height: auto`).
76
+ * Used by text so the box stays stuck to the glyphs.
77
+ */
78
+ hugContent?: boolean;
79
+ /** Wrap limit in px. The box stays as wide as the text until this cap. */
80
+ hugMaxWidth?: number;
81
+ /** Fired when hugged content changes size. Not a user resize. */
82
+ oncontentresize?: (rect: WidgetRect) => void;
70
83
  collapsible?: boolean;
71
84
  collapsed?: boolean;
72
85
  loading?: boolean;
@@ -87,6 +100,8 @@
87
100
  onreload?: () => void | Promise<void>;
88
101
  oncollapse?: (collapsed: boolean) => void;
89
102
  onchange?: (rect: WidgetRect) => void;
103
+ /** When false, content may paint outside the frame. Text uses this so glyphs are not cropped. */
104
+ clipContent?: boolean;
90
105
  /**
91
106
  * When false, `onchange` still fires but this frame does not write `rect`.
92
107
  * Use when a parent owns live position (rigid multi-select / group move).
@@ -116,6 +131,11 @@
116
131
  raiseOnSelect = true,
117
132
  stackIndex,
118
133
  transform: frameTransform,
134
+ rotation = 0,
135
+ onrotation,
136
+ hugContent = false,
137
+ hugMaxWidth = 0,
138
+ oncontentresize,
119
139
  collapsible = false,
120
140
  collapsed = $bindable(false),
121
141
  loading = false,
@@ -135,6 +155,7 @@
135
155
  onreload,
136
156
  oncollapse,
137
157
  onchange,
158
+ clipContent = true,
138
159
  applyRect = true,
139
160
  oninteract
140
161
  }: WidgetFrameProps = $props();
@@ -142,6 +163,8 @@
142
163
  const canvas = getContext<WidgetCanvasContext | undefined>(WIDGET_CANVAS_CONTEXT);
143
164
 
144
165
  let mode = $state<'move' | 'resize' | null>(null);
166
+ let rotating = $state(false);
167
+ let rotateStart: { angle: number; rotation: number; cx: number; cy: number } | null = null;
145
168
  let edge = $state<WidgetResizeEdge>('se');
146
169
  let start = $state({ px: 0, py: 0, x: 0, y: 0, w: 0, h: 0 });
147
170
  /** Pointer down awaiting movement threshold before starting freeform drag (preserves dblclick). */
@@ -159,7 +182,14 @@
159
182
  /** Tamaño local cuando resizable sin freeform (EditableChrome, etc.) */
160
183
  let localW = $state<number | null>(null);
161
184
  let localH = $state<number | null>(null);
162
- let rootEl: HTMLDivElement | null = null;
185
+ let rootEl = $state<HTMLDivElement | null>(null);
186
+ /** Último tamaño ya enviado. Evita que medir → guardar → medir no pare. */
187
+ let hugSentW = -1;
188
+ let hugSentH = -1;
189
+ let hugPrevW = -1;
190
+ let hugPrevH = -1;
191
+ /** Alto real del texto (el rect del drag solo manda en el ancho). */
192
+ let hugLiveH = $state(0);
163
193
 
164
194
  function attachRoot(node: HTMLElement) {
165
195
  rootEl = node as HTMLDivElement;
@@ -168,6 +198,40 @@
168
198
  };
169
199
  }
170
200
 
201
+ $effect(() => {
202
+ const el = rootEl;
203
+ if (!hugContent || !el || !oncontentresize) return;
204
+ let frame = 0;
205
+ const publish = () => {
206
+ const w = el.offsetWidth;
207
+ const h = el.offsetHeight;
208
+ if (w < 1 || h < 1) return;
209
+ hugLiveH = h;
210
+ if (untrack(() => mode) === 'resize') return;
211
+ const same =
212
+ (Math.abs(w - hugSentW) <= 1 && Math.abs(h - hugSentH) <= 1) ||
213
+ (Math.abs(w - hugPrevW) <= 1 && Math.abs(h - hugPrevH) <= 1);
214
+ if (same) return;
215
+ const current = untrack(() => rect);
216
+ hugPrevW = hugSentW;
217
+ hugPrevH = hugSentH;
218
+ hugSentW = w;
219
+ hugSentH = h;
220
+ if (Math.abs(w - current.w) <= 1 && Math.abs(h - current.h) <= 1) return;
221
+ oncontentresize({ x: current.x, y: current.y, w, h });
222
+ };
223
+ const observer = new ResizeObserver(() => {
224
+ cancelAnimationFrame(frame);
225
+ frame = requestAnimationFrame(publish);
226
+ });
227
+ observer.observe(el);
228
+ frame = requestAnimationFrame(publish);
229
+ return () => {
230
+ cancelAnimationFrame(frame);
231
+ observer.disconnect();
232
+ };
233
+ });
234
+
171
235
  const showDragHandle = $derived(showChrome && (editable || freeform) && draggable);
172
236
  const showResizeHandle = $derived((editable || freeform) && resizable && !collapsed);
173
237
  const showReload = $derived(!!onreload);
@@ -207,13 +271,24 @@
207
271
  w: Math.max(minW, next.w),
208
272
  h: Math.max(minH, next.h)
209
273
  };
210
- if (canvas) {
211
- if (shouldSnapNow) r = canvas.snapRect(r, minW, minH);
212
- r = canvas.clampRect(r, minW, minH);
213
- } else {
214
- r = { ...r, x: Math.max(0, r.x), y: Math.max(0, r.y) };
274
+ if (!canvas) {
275
+ return { ...r, x: Math.max(0, r.x), y: Math.max(0, r.y) };
215
276
  }
216
- return r;
277
+ if (hugContent) {
278
+ // El tamaño es el del texto: la rejilla y el borde solo mueven x / y.
279
+ const el = rootEl;
280
+ const measured = {
281
+ ...r,
282
+ w: el && el.offsetWidth > 0 ? el.offsetWidth : r.w,
283
+ h: el && el.offsetHeight > 0 ? el.offsetHeight : r.h
284
+ };
285
+ let pos = measured;
286
+ if (shouldSnapNow) pos = canvas.snapRect(pos, minW, minH);
287
+ pos = canvas.clampRect({ ...measured, x: pos.x, y: pos.y }, minW, minH);
288
+ return { ...r, x: pos.x, y: pos.y };
289
+ }
290
+ if (shouldSnapNow) r = canvas.snapRect(r, minW, minH);
291
+ return canvas.clampRect(r, minW, minH);
217
292
  }
218
293
 
219
294
  function emitRect(next: WidgetRect) {
@@ -222,6 +297,49 @@
222
297
  onchange?.(r);
223
298
  }
224
299
 
300
+ function beginRotate(e: PointerEvent) {
301
+ if (!onrotation || !rootEl) return;
302
+ if (e.button !== 0 && e.pointerType === 'mouse') return;
303
+ e.preventDefault();
304
+ e.stopPropagation();
305
+ const box = rootEl.getBoundingClientRect();
306
+ rotateStart = {
307
+ angle: Math.atan2(
308
+ e.clientY - (box.top + box.height / 2),
309
+ e.clientX - (box.left + box.width / 2)
310
+ ),
311
+ rotation,
312
+ cx: box.left + box.width / 2,
313
+ cy: box.top + box.height / 2
314
+ };
315
+ rotating = true;
316
+ (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);
317
+ oninteract?.(true);
318
+ }
319
+
320
+ function moveRotate(e: PointerEvent) {
321
+ if (!rotating || !rotateStart || !onrotation) return;
322
+ const angle = Math.atan2(e.clientY - rotateStart.cy, e.clientX - rotateStart.cx);
323
+ let deg = rotateStart.rotation + ((angle - rotateStart.angle) * 180) / Math.PI;
324
+ deg = Math.round(deg);
325
+ if (e.shiftKey) deg = Math.round(deg / 15) * 15;
326
+ const norm = ((deg % 360) + 360) % 360;
327
+ for (const axis of [0, 90, 180, 270, 360]) {
328
+ if (!e.shiftKey && Math.abs(norm - axis) <= 4) {
329
+ deg = axis === 360 ? 0 : axis;
330
+ break;
331
+ }
332
+ }
333
+ onrotation(deg);
334
+ }
335
+
336
+ function endRotate() {
337
+ if (!rotating) return;
338
+ rotating = false;
339
+ rotateStart = null;
340
+ oninteract?.(false);
341
+ }
342
+
225
343
  function beginMove(e: PointerEvent) {
226
344
  if (e.button !== 0 && e.pointerType === 'mouse') return;
227
345
  bringToFront();
@@ -238,6 +356,10 @@
238
356
  e.stopPropagation();
239
357
  bringToFront();
240
358
  pendingMove = null;
359
+ hugSentW = -1;
360
+ hugSentH = -1;
361
+ hugPrevW = -1;
362
+ hugPrevH = -1;
241
363
  onresizestart?.(e, nextEdge);
242
364
  if (delegateResize || !builtinResize) return;
243
365
 
@@ -245,6 +367,10 @@
245
367
  edge = nextEdge;
246
368
  oninteract?.(true);
247
369
  if (freeform) {
370
+ if (hugContent && rootEl && rootEl.offsetWidth > 0) {
371
+ // Arrancar desde el tamaño real del texto, no del rect guardado: sin salto al pulsar.
372
+ rect = { ...rect, w: rootEl.offsetWidth, h: rootEl.offsetHeight };
373
+ }
248
374
  start = { px: e.clientX, py: e.clientY, ...rect };
249
375
  } else {
250
376
  const box = rootEl?.getBoundingClientRect();
@@ -352,8 +478,13 @@
352
478
  const wasInteracting = mode === 'move' || mode === 'resize' || !!pendingMove;
353
479
  pendingMove = null;
354
480
  if (mode === 'resize' && freeform) {
481
+ // Con hug el alto lo pone el texto: el rect del drag solo aporta x / y / ancho.
482
+ emitRect(hugContent && hugLiveH > 0 ? { ...rect, h: hugLiveH } : { ...rect });
483
+ hugSentW = -1;
484
+ hugSentH = -1;
485
+ hugPrevW = -1;
486
+ hugPrevH = -1;
355
487
  mode = null;
356
- emitRect({ ...rect });
357
488
  if (wasInteracting) oninteract?.(false);
358
489
  return;
359
490
  }
@@ -438,6 +569,11 @@
438
569
  const rootStyle = $derived.by(() => {
439
570
  if (freeform) {
440
571
  const xf = frameTransform ? `transform:${frameTransform};transform-origin:0 0;` : '';
572
+ if (hugContent) {
573
+ const liveWidth =
574
+ mode === 'resize' ? `${rect.w}px` : hugMaxWidth > 0 ? `${hugMaxWidth}px` : 'max-content';
575
+ return `left:${rect.x}px;top:${rect.y}px;width:${liveWidth};height:auto;z-index:${paintZ};${xf}`;
576
+ }
441
577
  return `left:${rect.x}px;top:${rect.y}px;width:${rect.w}px;height:${collapsed ? 'auto' : `${rect.h}px`};z-index:${paintZ};${xf}`;
442
578
  }
443
579
  if (localW != null) {
@@ -485,8 +621,7 @@
485
621
  ? String(className)
486
622
  .split(/\s+/)
487
623
  .filter(
488
- (token) =>
489
- token && token !== 'h-full' && token !== 'min-h-0' && token !== 'flex-1'
624
+ (token) => token && token !== 'h-full' && token !== 'min-h-0' && token !== 'flex-1'
490
625
  )
491
626
  : [];
492
627
  return [...base, 'h-auto', 'max-h-fit', 'w-full', 'shrink-0'].join(' ');
@@ -496,12 +631,10 @@
496
631
  const contentFit = $derived(
497
632
  collapsed ||
498
633
  (typeof className === 'string' &&
499
- className
500
- .split(/\s+/)
501
- .some((token) => token === 'h-auto' || token === 'max-h-fit'))
634
+ className.split(/\s+/).some((token) => token === 'h-auto' || token === 'max-h-fit'))
502
635
  );
503
636
  const bodyOverflowClass = $derived(
504
- contentFit ? 'overflow-visible' : flush ? 'overflow-hidden' : 'overflow-auto'
637
+ contentFit || !clipContent ? 'overflow-visible' : flush ? 'overflow-hidden' : 'overflow-auto'
505
638
  );
506
639
  </script>
507
640
 
@@ -509,7 +642,8 @@
509
642
  <div
510
643
  {@attach attachRoot}
511
644
  class={[
512
- 'group/widget min-h-0 min-w-0 flex flex-col overflow-visible',
645
+ 'group/widget flex flex-col overflow-visible',
646
+ hugContent ? 'min-h-min min-w-min' : 'min-h-0 min-w-0',
513
647
  !isCanva && showChrome && 'rounded-xl border-border bg-surface-elevated overflow-hidden border',
514
648
  !isCanva && !showChrome && 'bg-transparent',
515
649
  isCanva && 'bg-transparent',
@@ -628,7 +762,7 @@
628
762
  <div
629
763
  class={[
630
764
  'relative',
631
- contentFit ? 'flex-none' : 'min-h-0 flex-1',
765
+ contentFit || hugContent ? 'flex-none' : 'min-h-0 flex-1',
632
766
  flush ? 'p-0' : 'p-3',
633
767
  bodyOverflowClass
634
768
  ]}
@@ -678,6 +812,21 @@
678
812
  </div>
679
813
  {/if}
680
814
 
815
+ {#if isCanva && mode === 'resize'}
816
+ <div
817
+ class="rounded-md bg-neutral-900 px-2 py-1 font-medium text-white top-0 shadow-md pointer-events-none absolute left-1/2 z-30 -translate-x-1/2 -translate-y-[calc(100%+8px)] text-[11px] whitespace-nowrap"
818
+ >
819
+ {Math.round(rect.w)} × {Math.round(hugContent && hugLiveH > 0 ? hugLiveH : rect.h)}
820
+ </div>
821
+ {/if}
822
+ {#if isCanva && rotating}
823
+ <div
824
+ class="rounded-md bg-neutral-900 px-2 py-1 font-medium text-white mt-8 shadow-md pointer-events-none absolute top-full left-1/2 z-30 -translate-x-1/2 text-[11px] whitespace-nowrap"
825
+ >
826
+ {Math.round(rotation)}°
827
+ </div>
828
+ {/if}
829
+
681
830
  {#if showResizeHandle}
682
831
  {#each visibleResizeEdges as h (h.edge)}
683
832
  <div
@@ -690,6 +839,40 @@
690
839
  ></div>
691
840
  {/each}
692
841
 
842
+ {#if isCanva && onrotation}
843
+ <div
844
+ class="h-3 pointer-events-none absolute top-full left-1/2 z-20 w-px -translate-x-1/2 bg-[#3b82f6]"
845
+ ></div>
846
+ <div
847
+ class={[
848
+ edgeAccent,
849
+ 'mt-3 h-6 w-6 top-full left-1/2 z-20 flex -translate-x-1/2 cursor-grab items-center justify-center active:cursor-grabbing'
850
+ ]}
851
+ role="slider"
852
+ tabindex="0"
853
+ aria-label="Rotar"
854
+ aria-valuemin={-180}
855
+ aria-valuemax={180}
856
+ aria-valuenow={Math.round(rotation)}
857
+ onpointerdown={beginRotate}
858
+ onpointermove={moveRotate}
859
+ onpointerup={endRotate}
860
+ onpointercancel={endRotate}
861
+ onkeydown={(e) => {
862
+ if (!onrotation) return;
863
+ const step = e.shiftKey ? 15 : 1;
864
+ if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') {
865
+ e.preventDefault();
866
+ onrotation(rotation - step);
867
+ } else if (e.key === 'ArrowRight' || e.key === 'ArrowUp') {
868
+ e.preventDefault();
869
+ onrotation(rotation + step);
870
+ }
871
+ }}
872
+ >
873
+ <RotateCw class="h-3 w-3 text-[#3b82f6]" />
874
+ </div>
875
+ {/if}
693
876
  {#if !isCanva}
694
877
  <!-- SE grip (visual only, small) -->
695
878
  <div
@@ -51,6 +51,18 @@ interface WidgetFrameProps {
51
51
  stackIndex?: number;
52
52
  /** CSS transform on the freeform root (e.g. rotate/flip) so chrome rotates too. */
53
53
  transform?: string;
54
+ /** Current rotation in degrees. With `onrotation`, Canva chrome shows a rotate handle. */
55
+ rotation?: number;
56
+ onrotation?: (degrees: number) => void;
57
+ /**
58
+ * Size the frame from its content (`width: max-content; height: auto`).
59
+ * Used by text so the box stays stuck to the glyphs.
60
+ */
61
+ hugContent?: boolean;
62
+ /** Wrap limit in px. The box stays as wide as the text until this cap. */
63
+ hugMaxWidth?: number;
64
+ /** Fired when hugged content changes size. Not a user resize. */
65
+ oncontentresize?: (rect: WidgetRect) => void;
54
66
  collapsible?: boolean;
55
67
  collapsed?: boolean;
56
68
  loading?: boolean;
@@ -71,6 +83,8 @@ interface WidgetFrameProps {
71
83
  onreload?: () => void | Promise<void>;
72
84
  oncollapse?: (collapsed: boolean) => void;
73
85
  onchange?: (rect: WidgetRect) => void;
86
+ /** When false, content may paint outside the frame. Text uses this so glyphs are not cropped. */
87
+ clipContent?: boolean;
74
88
  /**
75
89
  * When false, `onchange` still fires but this frame does not write `rect`.
76
90
  * Use when a parent owns live position (rigid multi-select / group move).
@@ -45,6 +45,8 @@
45
45
  /** Extra classes for the main content region (e.g. `p-0` for flush panels). */
46
46
  mainClass?: string;
47
47
  class?: string;
48
+ /** Left side of the navbar, after the mobile menu button. */
49
+ leading?: Snippet;
48
50
  actions?: Snippet;
49
51
  children?: Snippet;
50
52
  }
@@ -74,6 +76,7 @@
74
76
  framed = false,
75
77
  mainClass = '',
76
78
  class: className = '',
79
+ leading: leadingSlot,
77
80
  actions: actionsSlot,
78
81
  children
79
82
  }: AppShellProps = $props();
@@ -240,11 +243,12 @@
240
243
  bind:value={navValue}
241
244
  showBrand={!showSidebar && !showRail}
242
245
  variant="pills"
243
- size="sm"
246
+ size="md"
244
247
  bordered
245
248
  maxWidth="full"
246
249
  >
247
250
  {#snippet leading()}
251
+ <div class="gap-2 flex min-w-0 items-center">
248
252
  <div class="md:hidden">
249
253
  <IconButton
250
254
  label={mobileOpen ? 'Cerrar menú' : 'Abrir menú'}
@@ -271,6 +275,8 @@
271
275
  </svg>
272
276
  </IconButton>
273
277
  </div>
278
+ {#if leadingSlot}{@render leadingSlot()}{/if}
279
+ </div>
274
280
  {/snippet}
275
281
  {#snippet actions()}
276
282
  {#if actionsSlot}{@render actionsSlot()}{/if}
@@ -34,6 +34,8 @@ interface AppShellProps {
34
34
  /** Extra classes for the main content region (e.g. `p-0` for flush panels). */
35
35
  mainClass?: string;
36
36
  class?: string;
37
+ /** Left side of the navbar, after the mobile menu button. */
38
+ leading?: Snippet;
37
39
  actions?: Snippet;
38
40
  children?: Snippet;
39
41
  }