@r2digisolutions/components 0.21.0 → 0.21.2

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.
@@ -150,10 +150,9 @@
150
150
  bind:rect
151
151
  minW={layer.kind === 'line' || layer.kind === 'arrow' || layer.kind === 'path' ? 16 : 40}
152
152
  minH={layer.kind === 'line' ? 4 : layer.kind === 'arrow' || layer.kind === 'path' ? 16 : 24}
153
- class={[
154
- 'bg-transparent',
155
- passthrough || readOnly ? 'pointer-events-none' : ''
156
- ].filter(Boolean).join(' ')}
153
+ class={['bg-transparent', passthrough || readOnly ? 'pointer-events-none' : '']
154
+ .filter(Boolean)
155
+ .join(' ')}
157
156
  onchange={(r) => {
158
157
  rect = r;
159
158
  onchange?.(r);
@@ -184,12 +183,12 @@
184
183
  <video src={layer.src} class={['h-full w-full', fitClass]} muted playsinline></video>
185
184
  {:else if layer.kind === 'text' || layer.kind === 'sticky'}
186
185
  <div
187
- class="flex h-full w-full px-2 py-1"
186
+ class="px-2 py-1 flex h-full w-full"
188
187
  style:background={layer.kind === 'sticky'
189
188
  ? (layer.fill ?? '#fef08a')
190
189
  : layer.textBackground}
191
190
  style:color={layer.color ?? (layer.kind === 'sticky' ? '#713f12' : '#0f172a')}
192
- style:font-size="{(layer.fontSize ?? (layer.kind === 'sticky' ? 20 : 32))}px"
191
+ style:font-size="{layer.fontSize ?? (layer.kind === 'sticky' ? 20 : 32)}px"
193
192
  style:font-weight={layer.fontWeight ?? 600}
194
193
  style:font-family={layer.fontFamily}
195
194
  style:font-style={layer.fontStyle ?? 'normal'}
@@ -249,7 +248,7 @@
249
248
  class={[
250
249
  'absolute rounded-full',
251
250
  vertical
252
- ? 'left-1/2 top-0 h-full -translate-x-1/2'
251
+ ? 'top-0 left-1/2 h-full -translate-x-1/2'
253
252
  : 'left-0 top-1/2 w-full -translate-y-1/2'
254
253
  ]}
255
254
  style:background={layer.fill ?? '#94a3b8'}
@@ -264,7 +263,11 @@
264
263
  {@const len = vertical ? bh : bw}
265
264
  {@const thick = vertical ? bw : bh}
266
265
  {@const head = Math.min(Math.max(14, thick * 0.9), len * 0.35, 40)}
267
- <svg class="h-full w-full overflow-visible" viewBox={`0 0 ${bw} ${bh}`} aria-hidden="true">
266
+ <svg
267
+ class="h-full w-full overflow-visible"
268
+ viewBox={`0 0 ${bw} ${bh}`}
269
+ aria-hidden="true"
270
+ >
268
271
  {#if vertical}
269
272
  {@const cx = bw / 2}
270
273
  <line
@@ -303,7 +306,11 @@
303
306
  {@const d = layer.points
304
307
  .map((p, i) => `${i === 0 ? 'M' : 'L'} ${p.x * bw} ${p.y * bh}`)
305
308
  .join(' ')}
306
- <svg class="h-full w-full overflow-visible" viewBox={`0 0 ${bw} ${bh}`} aria-hidden="true">
309
+ <svg
310
+ class="h-full w-full overflow-visible"
311
+ viewBox={`0 0 ${bw} ${bh}`}
312
+ aria-hidden="true"
313
+ >
307
314
  <path
308
315
  d={layer.closed ? `${d} Z` : d}
309
316
  fill={layer.closed ? (layer.fill ?? '#0f172a') : 'none'}
@@ -318,7 +325,9 @@
318
325
  <div
319
326
  class="relative h-full w-full"
320
327
  style:overflow={panelClip ? 'hidden' : 'visible'}
321
- style:background={layer.fill && layer.fill !== 'transparent' ? layer.fill : 'transparent'}
328
+ style:background={layer.fill && layer.fill !== 'transparent'
329
+ ? layer.fill
330
+ : 'transparent'}
322
331
  style:border={layer.kind === 'namedSlot'
323
332
  ? '1px dashed color-mix(in oklab, #3b82f6 50%, transparent)'
324
333
  : layer.kind === 'scrollBox'
@@ -332,14 +341,14 @@
332
341
  >
333
342
  {#if layer.kind === 'namedSlot'}
334
343
  <span
335
- class="pointer-events-none absolute left-1.5 top-1.5 rounded bg-brand-500/15 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-brand-600"
344
+ class="left-1.5 top-1.5 rounded bg-brand-500/15 px-1.5 py-0.5 font-semibold tracking-wide text-brand-600 pointer-events-none absolute text-[9px] uppercase"
336
345
  >
337
346
  {layer.slotName || layer.name || 'Slot'}
338
347
  </span>
339
348
  {/if}
340
349
  {#if layer.kind === 'scrollBox'}
341
350
  <span
342
- class="pointer-events-none absolute left-1.5 top-1.5 rounded bg-surface-overlay/90 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-muted"
351
+ class="left-1.5 top-1.5 rounded bg-surface-overlay/90 px-1.5 py-0.5 font-semibold tracking-wide text-muted pointer-events-none absolute text-[9px] uppercase"
343
352
  >
344
353
  Scroll
345
354
  </span>
@@ -347,7 +356,7 @@
347
356
  </div>
348
357
  {:else}
349
358
  <div
350
- class="flex h-full w-full items-center justify-center gap-2 bg-surface-overlay/80 text-secondary"
359
+ class="gap-2 bg-surface-overlay/80 text-secondary flex h-full w-full items-center justify-center"
351
360
  >
352
361
  <MediaKindIcon kind={layer.kind === 'audio' ? 'audio' : 'image'} />
353
362
  <span class="text-xs">{layer.name}</span>
@@ -63,18 +63,6 @@
63
63
 
64
64
  const activeIds = $derived(selectedIds ?? (selectedId ? [selectedId] : []));
65
65
  const activeSet = $derived(new Set(activeIds));
66
- const ancestorOfSelection = $derived.by(() => {
67
- const map = new Map(layers.map((l) => [l.id, l]));
68
- const out = new Set<string>();
69
- for (const id of activeIds) {
70
- let cur = map.get(id);
71
- while (cur?.parentId) {
72
- out.add(cur.parentId);
73
- cur = map.get(cur.parentId);
74
- }
75
- }
76
- return out;
77
- });
78
66
  const inheritedLocked = $derived.by(() => {
79
67
  const map = new Map(layers.map((l) => [l.id, l]));
80
68
  const out = new Set<string>();
@@ -280,9 +268,7 @@
280
268
  'flex w-full items-center gap-0.5 rounded-md px-1 py-1 text-left text-xs transition-colors',
281
269
  activeSet.has(layer.id)
282
270
  ? 'bg-brand-500/15 text-primary'
283
- : ancestorOfSelection.has(layer.id)
284
- ? 'bg-brand-500/10 text-primary ring-1 ring-inset ring-brand-500/35'
285
- : 'text-secondary hover:bg-surface-overlay hover:text-primary',
271
+ : 'text-secondary hover:bg-surface-overlay hover:text-primary',
286
272
  dragId === layer.id && 'opacity-50',
287
273
  nesting && 'ring-1 ring-brand-500 bg-brand-500/10'
288
274
  ]}
@@ -29,8 +29,9 @@ export declare function isLayoutPositionLocked(layers: CanvasLayer[], layerId: s
29
29
  /** Child W/H is owned by a grid / scaleBox parent. */
30
30
  export declare function isLayoutSizeLocked(layers: CanvasLayer[], layerId: string, map?: Map<string, CanvasLayer>): boolean;
31
31
  /**
32
- * Ancestors to draw while a nested layer is selected (UMG / Canva parent chrome).
33
- * Skips `canvasPanel` (full-bleed artboard) and layers already in the selection.
32
+ * Ancestors to draw while a nested layer is selected (frame clip bounds).
33
+ * Skips the artboard, the current selection, and `group` — groups hug the
34
+ * children AABB, so outlining them looks like extra selection.
34
35
  */
35
36
  export declare function selectionAncestorIds(layers: CanvasLayer[], selectedIds: string[]): string[];
36
37
  /**
@@ -130,8 +130,9 @@ export function isLayoutSizeLocked(layers, layerId, map) {
130
130
  return !!parent && LAYOUT_SIZE_KINDS.has(parent.kind);
131
131
  }
132
132
  /**
133
- * Ancestors to draw while a nested layer is selected (UMG / Canva parent chrome).
134
- * Skips `canvasPanel` (full-bleed artboard) and layers already in the selection.
133
+ * Ancestors to draw while a nested layer is selected (frame clip bounds).
134
+ * Skips the artboard, the current selection, and `group` — groups hug the
135
+ * children AABB, so outlining them looks like extra selection.
135
136
  */
136
137
  export function selectionAncestorIds(layers, selectedIds) {
137
138
  const selected = new Set(selectedIds);
@@ -139,8 +140,12 @@ export function selectionAncestorIds(layers, selectedIds) {
139
140
  const seen = new Set();
140
141
  for (const id of selectedIds) {
141
142
  for (const anc of getAncestors(layers, id)) {
142
- if (selected.has(anc.id) || seen.has(anc.id) || anc.kind === 'canvasPanel')
143
+ if (selected.has(anc.id) ||
144
+ seen.has(anc.id) ||
145
+ anc.kind === 'canvasPanel' ||
146
+ anc.kind === 'group') {
143
147
  continue;
148
+ }
144
149
  seen.add(anc.id);
145
150
  out.push(anc.id);
146
151
  }
@@ -91,9 +91,7 @@ export function createWidgetFromSelection(doc, selectedIds, name = 'Widget') {
91
91
  const wasRoot = oldId ? selectedIds.includes(oldId) : false;
92
92
  if (wasRoot) {
93
93
  const abs = oldId ? absMap.get(oldId) : null;
94
- const local = abs
95
- ? { x: abs.x - minX, y: abs.y - minY, w: abs.w, h: abs.h }
96
- : l.rect;
94
+ const local = abs ? { x: abs.x - minX, y: abs.y - minY, w: abs.w, h: abs.h } : l.rect;
97
95
  return {
98
96
  ...l,
99
97
  parentId: null,
@@ -168,9 +166,7 @@ export function placeWidgetInstance(doc, definitionId, opts) {
168
166
  const parentAbs = parentId
169
167
  ? (absMap.get(parentId) ?? { x: 0, y: 0, w: doc.width, h: doc.height })
170
168
  : { x: 0, y: 0, w: doc.width, h: doc.height };
171
- const pad = parentLayer
172
- ? contentPadding(parentLayer)
173
- : { left: 0, top: 0, right: 0, bottom: 0 };
169
+ const pad = parentLayer ? contentPadding(parentLayer) : { left: 0, top: 0, right: 0, bottom: 0 };
174
170
  const contentW = Math.max(1, parentAbs.w - pad.left - pad.right);
175
171
  const contentH = Math.max(1, parentAbs.h - pad.top - pad.bottom);
176
172
  const x = opts?.x ?? (parentId ? Math.round((contentW - def.width) / 2) : 80);
@@ -334,7 +330,7 @@ export function flattenLayersWithWidgets(layers, widgets, depth = 0) {
334
330
  continue;
335
331
  }
336
332
  const resolved = resolveWidgetInstance(layer, def);
337
- let nested = resolved.map((l) => l.parentId === null ? { ...l, parentId: layer.id } : l);
333
+ let nested = resolved.map((l) => (l.parentId === null ? { ...l, parentId: layer.id } : l));
338
334
  const defW = Math.max(1, def.width);
339
335
  const defH = Math.max(1, def.height);
340
336
  const instW = Math.max(1, layer.rect.w);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r2digisolutions/components",
3
- "version": "0.21.0",
3
+ "version": "0.21.2",
4
4
  "private": false,
5
5
  "description": "R2DigiSolutions Svelte 5 component library — Atomic Design, Tailwind 4, Light/Dark mode",
6
6
  "license": "MIT",