@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.
- package/dist/components/atoms/Textarea/Textarea.svelte +4 -0
- package/dist/components/atoms/Textarea/Textarea.svelte.d.ts +1 -0
- package/dist/components/molecules/CanvasInspector/CanvasInspector.svelte +165 -71
- package/dist/components/molecules/Cascader/Cascader.svelte +2 -0
- package/dist/components/molecules/ColorPicker/ColorPicker.svelte +4 -13
- package/dist/components/molecules/DatePicker/DatePicker.svelte +2 -0
- package/dist/components/molecules/DateTimePicker/DateTimePicker.svelte +2 -0
- package/dist/components/molecules/DropdownMenu/DropdownMenu.svelte +7 -18
- package/dist/components/molecules/MediaLayerItem/MediaLayerItem.svelte +11 -3
- package/dist/components/molecules/MediaLayerItem/MediaLayerItem.svelte.d.ts +5 -1
- package/dist/components/molecules/MediaLayerList/MediaLayerList.svelte +31 -4
- package/dist/components/molecules/MediaStage/MediaStage.svelte +237 -199
- package/dist/components/molecules/MediaStage/MediaStage.svelte.d.ts +1 -45
- package/dist/components/molecules/MultiSelect/MultiSelect.svelte +2 -0
- package/dist/components/molecules/Popover/Popover.svelte +6 -0
- package/dist/components/molecules/Select/Select.svelte +36 -14
- package/dist/components/molecules/TimePicker/TimePicker.svelte +2 -0
- package/dist/components/molecules/TreeSelect/TreeSelect.svelte +2 -0
- package/dist/components/molecules/UserMenu/UserMenu.svelte +2 -0
- package/dist/components/organisms/CanvasEditor/CanvasEditor.svelte +173 -150
- package/dist/components/organisms/Dialog/Dialog.svelte +19 -3
- package/dist/components/organisms/NotificationCenter/NotificationCenter.svelte +2 -0
- package/dist/components/organisms/PricingTable/PricingTable.svelte +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/utils/canvasHierarchy.d.ts +55 -0
- package/dist/utils/canvasHierarchy.js +245 -13
- package/dist/utils/popoverInvoker.d.ts +11 -0
- package/dist/utils/popoverInvoker.js +39 -0
- package/package.json +1 -1
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
md: 'max-w-md',
|
|
88
88
|
lg: 'max-w-lg',
|
|
89
89
|
xl: 'max-w-2xl',
|
|
90
|
-
full: '
|
|
90
|
+
full: ''
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
const footerAlignClasses: Record<FooterAlign, string> = {
|
|
@@ -212,6 +212,7 @@
|
|
|
212
212
|
{id}
|
|
213
213
|
class={[
|
|
214
214
|
'dialog-root',
|
|
215
|
+
size === 'full' && 'dialog-full',
|
|
215
216
|
sizeClasses[size],
|
|
216
217
|
position === 'top' && 'dialog-top',
|
|
217
218
|
!blurBackdrop && 'dialog-no-blur',
|
|
@@ -279,10 +280,10 @@
|
|
|
279
280
|
{#if children}
|
|
280
281
|
<div
|
|
281
282
|
class={[
|
|
282
|
-
'min-h-0 flex-1 px-5 py-2 text-sm text-primary',
|
|
283
|
+
'min-h-0 min-w-0 flex-1 px-5 py-2 text-sm text-primary',
|
|
283
284
|
scrollable &&
|
|
284
285
|
(size === 'full'
|
|
285
|
-
? '
|
|
286
|
+
? 'overflow-auto'
|
|
286
287
|
: size === 'xl'
|
|
287
288
|
? 'max-h-[min(70vh,36rem)] overflow-y-auto'
|
|
288
289
|
: 'max-h-[min(60vh,28rem)] overflow-y-auto')
|
|
@@ -332,6 +333,14 @@
|
|
|
332
333
|
overflow: visible;
|
|
333
334
|
}
|
|
334
335
|
|
|
336
|
+
.dialog-root.dialog-full {
|
|
337
|
+
width: calc(100% - 1.5rem);
|
|
338
|
+
height: calc(100% - 1.5rem);
|
|
339
|
+
max-width: none;
|
|
340
|
+
max-height: none;
|
|
341
|
+
overflow: hidden;
|
|
342
|
+
}
|
|
343
|
+
|
|
335
344
|
.dialog-root.dialog-top {
|
|
336
345
|
margin-top: 8vh;
|
|
337
346
|
margin-bottom: auto;
|
|
@@ -359,6 +368,13 @@
|
|
|
359
368
|
box-shadow: var(--shadow-xl);
|
|
360
369
|
overflow: hidden;
|
|
361
370
|
max-height: calc(100vh - 2rem);
|
|
371
|
+
min-width: 0;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.dialog-root.dialog-full .dialog-panel {
|
|
375
|
+
height: 100%;
|
|
376
|
+
max-height: 100%;
|
|
377
|
+
width: 100%;
|
|
362
378
|
}
|
|
363
379
|
|
|
364
380
|
.dialog-root[open] {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { on } from 'svelte/events';
|
|
3
3
|
import NotificationRow from '../../molecules/NotificationRow/NotificationRow.svelte';
|
|
4
|
+
import { popoverInvokerToggle } from '../../../utils/popoverInvoker.js';
|
|
4
5
|
|
|
5
6
|
export interface NotificationItem {
|
|
6
7
|
id: string;
|
|
@@ -169,6 +170,7 @@
|
|
|
169
170
|
type="button"
|
|
170
171
|
popovertarget={popoverId}
|
|
171
172
|
popovertargetaction="toggle"
|
|
173
|
+
{@attach popoverInvokerToggle(() => popoverEl)}
|
|
172
174
|
aria-label="{copy.trigger}{unreadCount > 0 ? withCount(copy.unreadSuffix, unreadCount) : ''}"
|
|
173
175
|
aria-expanded={open}
|
|
174
176
|
aria-controls={popoverId}
|
|
@@ -427,8 +427,8 @@
|
|
|
427
427
|
{/snippet}
|
|
428
428
|
|
|
429
429
|
{#snippet comparisonTable(withPricingHeader: boolean)}
|
|
430
|
-
<div class="w-full overflow-x-auto rounded-xl border border-border bg-surface-elevated">
|
|
431
|
-
<table class="w-full min-w-
|
|
430
|
+
<div class="min-w-0 w-full overflow-x-auto rounded-xl border border-border bg-surface-elevated">
|
|
431
|
+
<table class="w-full min-w-max border-collapse text-sm" aria-label="Plan feature comparison">
|
|
432
432
|
<thead class="sticky top-0 z-30">
|
|
433
433
|
{#if withPricingHeader}
|
|
434
434
|
<tr class="border-b border-border bg-surface-elevated shadow-sm">
|
|
@@ -571,7 +571,7 @@
|
|
|
571
571
|
</div>
|
|
572
572
|
{/snippet}
|
|
573
573
|
|
|
574
|
-
<div class={['w-full space-y-4', className]}>
|
|
574
|
+
<div class={['min-w-0 w-full space-y-4', className]}>
|
|
575
575
|
{#if canToggleBilling}
|
|
576
576
|
<div class="flex justify-center">
|
|
577
577
|
<SegmentedControl
|
package/dist/index.d.ts
CHANGED
|
@@ -834,6 +834,7 @@ export { default as AudioEditorTemplate } from './components/templates/AudioEdit
|
|
|
834
834
|
export { themeStore } from './utils/theme.svelte.js';
|
|
835
835
|
export type { Theme, ThemePalette } from './utils/theme.svelte.js';
|
|
836
836
|
export { createId } from './utils/id.js';
|
|
837
|
+
export { bindPopoverInvokerToggle, popoverInvokerToggle } from './utils/popoverInvoker.js';
|
|
837
838
|
export { resolveAccessor, accessorPatchKey, resolveRowKey } from './utils/columnAccessor.js';
|
|
838
839
|
export type { ColumnAccessor, RowKey } from './utils/columnAccessor.js';
|
|
839
840
|
export { pageVisibility } from './utils/pageVisibility.svelte.js';
|
|
@@ -864,7 +865,7 @@ export type { MediaAsset, MediaAssetKind, MediaClip, MediaClipAlign, MediaClipRe
|
|
|
864
865
|
export { uid, createMediaClip, createMediaTrack, createMediaAsset, clipDurationMs, moveClip, trimClipStart, trimClipEnd, isClipActiveAt, findClipAt, updateClipInTracks, removeClipFromTracks, removeClipsFromTracks, splitClipAt, splitClipsAt, duplicateClipInTracks, mergeClipsInTracks, canMergeMediaClips, moveClipsByDelta, findClipById, nextTrackName, reorderTracks, moveTrack, removeTrack, removeTracks, defaultOverlayRect, defaultMediaClipRect, resolveClipRect, alignClipRect, alignMediaRect, clipHasSpatialRect, isMediaClipFieldModified, resetMediaClipField, findTransitionAt, transitionLayerStyle, transitionDipOverlay, resolvePreviewOpacity, resolveClipOpacity, MEDIA_CLIP_DEFAULTS, kindFromFile, probeMediaSrc } from './utils/mediaTracks.js';
|
|
865
866
|
export { emptyCanvasDocument, createCanvasLayer, createCanvasGuide, createPathFromDocPoints, rebakePathLayer, pathPointsToDoc, reorderCanvasLayers, updateCanvasLayer, updateCanvasLayers, alignLayerRect, snapLayerRect, snapRectToGuides, migrateCanvasDocument, defaultSlotFromRect, rectFromSlot, ensureLayerSlot, canvasLayerFieldDefault, isCanvasFieldModified, resetCanvasField, applyTextAutoSize, CANVAS_PRESETS, presetIdForSize } from './utils/canvasDocument.js';
|
|
866
867
|
export type { CanvasDocument, CanvasLayer, CanvasLayerKind, CanvasLayerRect, CanvasPoint, CanvasObjectFit, CanvasTextAlign, CanvasResettableField, CanvasAlign, CanvasFontStyle, CanvasTextDecoration, CanvasGuide, CanvasGuideOrientation, CanvasAnchors, CanvasSlot, CanvasExposedProp, CanvasWidgetDefinition } from './utils/canvasDocument.js';
|
|
867
|
-
export { isContainerKind, canHaveChildren, getChildren, getDescendantIds, getSubtreeIds, getAncestors, isEffectivelyVisible, paintTransformForLayer, isDescendant, canReparent, ANCHOR_PRESETS, resolveSlotRect, slotFromLocalRect, computeAbsoluteRects, absoluteRectFor, reparentLayer, wrapSelection, groupLayers, ungroupLayers, deleteSubtree, duplicateSubtree, reorderSiblings, clipPathForLayer, scrollBoxOverflow, scrollBarMetrics, applyScrollBoxOffsets } from './utils/canvasHierarchy.js';
|
|
868
|
+
export { isContainerKind, canHaveChildren, getChildren, getDescendantIds, getSubtreeIds, getAncestors, enclosingGroupId, isEffectivelyVisible, isEffectivelyLocked, isLayoutPositionLocked, isLayoutSizeLocked, selectionAncestorIds, LAYOUT_POSITION_KINDS, LAYOUT_SIZE_KINDS, paintTransformForLayer, isDescendant, canReparent, ANCHOR_PRESETS, resolveSlotRect, slotFromLocalRect, translateSlot, stepAxis, computeAbsoluteRects, absoluteRectFor, reparentLayer, wrapSelection, groupLayers, ungroupLayers, layerFromAbsoluteRect, fitGroupsToChildren, scaleSubtreeAbsolute, deleteSubtree, duplicateSubtree, reorderSiblings, clipPathForLayer, scrollBoxOverflow, scrollBarMetrics, applyScrollBoxOffsets } from './utils/canvasHierarchy.js';
|
|
868
869
|
export { createWidgetDefinition, createWidgetFromSelection, placeWidgetInstance, resolveWidgetInstance, flattenLayersWithWidgets, breakWidgetInstance, updateWidgetDefinition, deleteWidgetDefinition, renameWidgetDefinition, duplicateWidgetDefinition, syncInstanceSizesToDefinition, setExposedProp, isPropExposed, getExposedProp, getExposedFieldDefault, resolveExposedPropValue, groupExposedPropsByLayer, setInstanceOverride, getNamedSlotsFromDefinition, listFillableSlotsForInstance } from './utils/canvasWidget.js';
|
|
869
870
|
export { createCanvasHistory, pushCanvasHistory, undoCanvasHistory, redoCanvasHistory, serializeCanvasDoc, parseCanvasDoc } from './utils/canvasHistory.js';
|
|
870
871
|
export type { CanvasHistoryState } from './utils/canvasHistory.js';
|
package/dist/index.js
CHANGED
|
@@ -568,6 +568,7 @@ export { default as AudioEditorTemplate } from './components/templates/AudioEdit
|
|
|
568
568
|
// ── Utils ────────────────────────────────────────────────────────────────────
|
|
569
569
|
export { themeStore } from './utils/theme.svelte.js';
|
|
570
570
|
export { createId } from './utils/id.js';
|
|
571
|
+
export { bindPopoverInvokerToggle, popoverInvokerToggle } from './utils/popoverInvoker.js';
|
|
571
572
|
export { resolveAccessor, accessorPatchKey, resolveRowKey } from './utils/columnAccessor.js';
|
|
572
573
|
export { pageVisibility } from './utils/pageVisibility.svelte.js';
|
|
573
574
|
export { network } from './utils/network.svelte.js';
|
|
@@ -586,7 +587,7 @@ export { emptyBlogDocument, createBlock, createComponentBlock, serializeBlogDocu
|
|
|
586
587
|
export { msToPx, pxToMs, pxPerMsFromZoom, snapMs, clampMs, formatTimecode, ticksForDuration, snapStepForZoom } from './utils/mediaTime.js';
|
|
587
588
|
export { uid, createMediaClip, createMediaTrack, createMediaAsset, clipDurationMs, moveClip, trimClipStart, trimClipEnd, isClipActiveAt, findClipAt, updateClipInTracks, removeClipFromTracks, removeClipsFromTracks, splitClipAt, splitClipsAt, duplicateClipInTracks, mergeClipsInTracks, canMergeMediaClips, moveClipsByDelta, findClipById, nextTrackName, reorderTracks, moveTrack, removeTrack, removeTracks, defaultOverlayRect, defaultMediaClipRect, resolveClipRect, alignClipRect, alignMediaRect, clipHasSpatialRect, isMediaClipFieldModified, resetMediaClipField, findTransitionAt, transitionLayerStyle, transitionDipOverlay, resolvePreviewOpacity, resolveClipOpacity, MEDIA_CLIP_DEFAULTS, kindFromFile, probeMediaSrc } from './utils/mediaTracks.js';
|
|
588
589
|
export { emptyCanvasDocument, createCanvasLayer, createCanvasGuide, createPathFromDocPoints, rebakePathLayer, pathPointsToDoc, reorderCanvasLayers, updateCanvasLayer, updateCanvasLayers, alignLayerRect, snapLayerRect, snapRectToGuides, migrateCanvasDocument, defaultSlotFromRect, rectFromSlot, ensureLayerSlot, canvasLayerFieldDefault, isCanvasFieldModified, resetCanvasField, applyTextAutoSize, CANVAS_PRESETS, presetIdForSize } from './utils/canvasDocument.js';
|
|
589
|
-
export { isContainerKind, canHaveChildren, getChildren, getDescendantIds, getSubtreeIds, getAncestors, isEffectivelyVisible, paintTransformForLayer, isDescendant, canReparent, ANCHOR_PRESETS, resolveSlotRect, slotFromLocalRect, computeAbsoluteRects, absoluteRectFor, reparentLayer, wrapSelection, groupLayers, ungroupLayers, deleteSubtree, duplicateSubtree, reorderSiblings, clipPathForLayer, scrollBoxOverflow, scrollBarMetrics, applyScrollBoxOffsets } from './utils/canvasHierarchy.js';
|
|
590
|
+
export { isContainerKind, canHaveChildren, getChildren, getDescendantIds, getSubtreeIds, getAncestors, enclosingGroupId, isEffectivelyVisible, isEffectivelyLocked, isLayoutPositionLocked, isLayoutSizeLocked, selectionAncestorIds, LAYOUT_POSITION_KINDS, LAYOUT_SIZE_KINDS, paintTransformForLayer, isDescendant, canReparent, ANCHOR_PRESETS, resolveSlotRect, slotFromLocalRect, translateSlot, stepAxis, computeAbsoluteRects, absoluteRectFor, reparentLayer, wrapSelection, groupLayers, ungroupLayers, layerFromAbsoluteRect, fitGroupsToChildren, scaleSubtreeAbsolute, deleteSubtree, duplicateSubtree, reorderSiblings, clipPathForLayer, scrollBoxOverflow, scrollBarMetrics, applyScrollBoxOffsets } from './utils/canvasHierarchy.js';
|
|
590
591
|
export { createWidgetDefinition, createWidgetFromSelection, placeWidgetInstance, resolveWidgetInstance, flattenLayersWithWidgets, breakWidgetInstance, updateWidgetDefinition, deleteWidgetDefinition, renameWidgetDefinition, duplicateWidgetDefinition, syncInstanceSizesToDefinition, setExposedProp, isPropExposed, getExposedProp, getExposedFieldDefault, resolveExposedPropValue, groupExposedPropsByLayer, setInstanceOverride, getNamedSlotsFromDefinition, listFillableSlotsForInstance } from './utils/canvasWidget.js';
|
|
591
592
|
export { createCanvasHistory, pushCanvasHistory, undoCanvasHistory, redoCanvasHistory, serializeCanvasDoc, parseCanvasDoc } from './utils/canvasHistory.js';
|
|
592
593
|
export { renderCanvasDocument, exportCanvasBlob, downloadBlob, backgroundAlpha } from './utils/canvasExport.js';
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { CanvasAnchors, CanvasDocument, CanvasLayer, CanvasLayerKind, CanvasLayerRect, CanvasSlot } from './canvasDocument.js';
|
|
2
2
|
export declare const CONTAINER_KINDS: ReadonlySet<CanvasLayerKind>;
|
|
3
3
|
export declare const LAYOUT_BOX_KINDS: ReadonlySet<CanvasLayerKind>;
|
|
4
|
+
/** Parents that own child X/Y (UMG slot layout). Group / panel / overlay stay freeform. */
|
|
5
|
+
export declare const LAYOUT_POSITION_KINDS: ReadonlySet<CanvasLayerKind>;
|
|
6
|
+
/** Parents that own child W/H (cell / uniform scale). */
|
|
7
|
+
export declare const LAYOUT_SIZE_KINDS: ReadonlySet<CanvasLayerKind>;
|
|
4
8
|
/**
|
|
5
9
|
* Structural shells whose empty area should start a marquee (not a layer drag),
|
|
6
10
|
* matching Figma-style select-drag on the canvas / inside frames.
|
|
11
|
+
* Groups are omitted: they behave like a single object (click/drag the group).
|
|
7
12
|
*/
|
|
8
13
|
export declare const MARQUEE_PASS_KINDS: ReadonlySet<CanvasLayerKind>;
|
|
9
14
|
export declare function isContainerKind(kind: CanvasLayerKind): boolean;
|
|
@@ -13,8 +18,21 @@ export declare function getChildren(layers: CanvasLayer[], parentId: string | nu
|
|
|
13
18
|
export declare function getDescendantIds(layers: CanvasLayer[], rootId: string): string[];
|
|
14
19
|
export declare function getSubtreeIds(layers: CanvasLayer[], rootId: string): string[];
|
|
15
20
|
export declare function getAncestors(layers: CanvasLayer[], layerId: string): CanvasLayer[];
|
|
21
|
+
/** Outermost `group` ancestor, or null if the layer is not inside a group. */
|
|
22
|
+
export declare function enclosingGroupId(layers: CanvasLayer[], layerId: string): string | null;
|
|
16
23
|
/** True when the layer and every ancestor is visible (flat stage paint must check this). */
|
|
17
24
|
export declare function isEffectivelyVisible(layers: CanvasLayer[], layerId: string, map?: Map<string, CanvasLayer>): boolean;
|
|
25
|
+
/** True when the layer or any ancestor is locked (parent lock freezes the whole subtree). */
|
|
26
|
+
export declare function isEffectivelyLocked(layers: CanvasLayer[], layerId: string, map?: Map<string, CanvasLayer>): boolean;
|
|
27
|
+
/** Child X/Y is owned by an hBox / vBox / wrap / grid parent. */
|
|
28
|
+
export declare function isLayoutPositionLocked(layers: CanvasLayer[], layerId: string, map?: Map<string, CanvasLayer>): boolean;
|
|
29
|
+
/** Child W/H is owned by a grid / scaleBox parent. */
|
|
30
|
+
export declare function isLayoutSizeLocked(layers: CanvasLayer[], layerId: string, map?: Map<string, CanvasLayer>): boolean;
|
|
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.
|
|
34
|
+
*/
|
|
35
|
+
export declare function selectionAncestorIds(layers: CanvasLayer[], selectedIds: string[]): string[];
|
|
18
36
|
/**
|
|
19
37
|
* CSS transform for a flat-stage layer so ancestor rotations orbit children
|
|
20
38
|
* around each ancestor's center (DOM is not nested).
|
|
@@ -107,6 +125,20 @@ export declare function slotFromLocalRect(parentSize: {
|
|
|
107
125
|
width: number;
|
|
108
126
|
height: number;
|
|
109
127
|
}, rect: CanvasLayerRect, anchors?: CanvasAnchors): CanvasSlot;
|
|
128
|
+
/**
|
|
129
|
+
* Translate a UMG slot without changing size.
|
|
130
|
+
* `right` / `bottom` are inverted (distance from the opposite anchored edge).
|
|
131
|
+
*/
|
|
132
|
+
export declare function translateSlot(slot: CanvasSlot, dx: number, dy: number): CanvasSlot;
|
|
133
|
+
/**
|
|
134
|
+
* Keyboard nudge along one axis.
|
|
135
|
+
* With snap: land on the next/previous grid line (if already on-grid, move one cell; Shift = two).
|
|
136
|
+
*/
|
|
137
|
+
export declare function stepAxis(value: number, dir: 1 | -1, opts: {
|
|
138
|
+
snap: boolean;
|
|
139
|
+
cell: number;
|
|
140
|
+
coarse?: boolean;
|
|
141
|
+
}): number;
|
|
110
142
|
export declare function contentPadding(layer: CanvasLayer): {
|
|
111
143
|
left: number;
|
|
112
144
|
top: number;
|
|
@@ -158,6 +190,7 @@ export declare function reparentLayer(layers: CanvasLayer[], layerId: string, ne
|
|
|
158
190
|
width: number;
|
|
159
191
|
height: number;
|
|
160
192
|
}): CanvasLayer[];
|
|
193
|
+
/** Wrap one or more layers in a new parent (`group`, `hBox`, `border`, …). */
|
|
161
194
|
export declare function wrapSelection(doc: CanvasDocument, selectedIds: string[], wrapKind?: CanvasLayerKind): {
|
|
162
195
|
doc: CanvasDocument;
|
|
163
196
|
wrapperId: string;
|
|
@@ -187,3 +220,25 @@ export declare function syncSlotFromRect(layer: CanvasLayer, parentSize: {
|
|
|
187
220
|
width: number;
|
|
188
221
|
height: number;
|
|
189
222
|
}): CanvasLayer;
|
|
223
|
+
/** Write an absolute rect back to layer.rect / slot in parent-local space. */
|
|
224
|
+
export declare function layerFromAbsoluteRect(layer: CanvasLayer, absRect: CanvasLayerRect, parentAbs: CanvasLayerRect | null, parentLayer: CanvasLayer | null, rootSize: {
|
|
225
|
+
width: number;
|
|
226
|
+
height: number;
|
|
227
|
+
}): CanvasLayer;
|
|
228
|
+
/**
|
|
229
|
+
* Figma-style groups: origin + size is the AABB of direct children.
|
|
230
|
+
* Children keep their absolute positions (local coords are rebased).
|
|
231
|
+
* Nested groups are fitted innermost-first.
|
|
232
|
+
*/
|
|
233
|
+
export declare function fitGroupsToChildren(layers: CanvasLayer[], rootSize: {
|
|
234
|
+
width: number;
|
|
235
|
+
height: number;
|
|
236
|
+
}): CanvasLayer[];
|
|
237
|
+
/**
|
|
238
|
+
* Scale a group (or any subtree) from `prevAbs` to `nextAbs`.
|
|
239
|
+
* Descendants keep their relative placement inside the box.
|
|
240
|
+
*/
|
|
241
|
+
export declare function scaleSubtreeAbsolute(layers: CanvasLayer[], rootId: string, prevAbs: CanvasLayerRect, nextAbs: CanvasLayerRect, rootSize: {
|
|
242
|
+
width: number;
|
|
243
|
+
height: number;
|
|
244
|
+
}): CanvasLayer[];
|
|
@@ -27,14 +27,23 @@ export const LAYOUT_BOX_KINDS = new Set([
|
|
|
27
27
|
'uniformGrid',
|
|
28
28
|
'scrollBox'
|
|
29
29
|
]);
|
|
30
|
+
/** Parents that own child X/Y (UMG slot layout). Group / panel / overlay stay freeform. */
|
|
31
|
+
export const LAYOUT_POSITION_KINDS = new Set([
|
|
32
|
+
'hBox',
|
|
33
|
+
'vBox',
|
|
34
|
+
'wrapBox',
|
|
35
|
+
'uniformGrid'
|
|
36
|
+
]);
|
|
37
|
+
/** Parents that own child W/H (cell / uniform scale). */
|
|
38
|
+
export const LAYOUT_SIZE_KINDS = new Set(['uniformGrid', 'scaleBox']);
|
|
30
39
|
/**
|
|
31
40
|
* Structural shells whose empty area should start a marquee (not a layer drag),
|
|
32
41
|
* matching Figma-style select-drag on the canvas / inside frames.
|
|
42
|
+
* Groups are omitted: they behave like a single object (click/drag the group).
|
|
33
43
|
*/
|
|
34
44
|
export const MARQUEE_PASS_KINDS = new Set([
|
|
35
45
|
'canvasPanel',
|
|
36
46
|
'overlay',
|
|
37
|
-
'group',
|
|
38
47
|
...LAYOUT_BOX_KINDS
|
|
39
48
|
]);
|
|
40
49
|
export function isContainerKind(kind) {
|
|
@@ -78,6 +87,11 @@ export function getAncestors(layers, layerId) {
|
|
|
78
87
|
}
|
|
79
88
|
return out;
|
|
80
89
|
}
|
|
90
|
+
/** Outermost `group` ancestor, or null if the layer is not inside a group. */
|
|
91
|
+
export function enclosingGroupId(layers, layerId) {
|
|
92
|
+
const groups = getAncestors(layers, layerId).filter((a) => a.kind === 'group');
|
|
93
|
+
return groups.length ? groups[groups.length - 1].id : null;
|
|
94
|
+
}
|
|
81
95
|
/** True when the layer and every ancestor is visible (flat stage paint must check this). */
|
|
82
96
|
export function isEffectivelyVisible(layers, layerId, map) {
|
|
83
97
|
const byId = map ?? new Map(layers.map((l) => [l.id, l]));
|
|
@@ -89,6 +103,50 @@ export function isEffectivelyVisible(layers, layerId, map) {
|
|
|
89
103
|
}
|
|
90
104
|
return true;
|
|
91
105
|
}
|
|
106
|
+
/** True when the layer or any ancestor is locked (parent lock freezes the whole subtree). */
|
|
107
|
+
export function isEffectivelyLocked(layers, layerId, map) {
|
|
108
|
+
const byId = map ?? new Map(layers.map((l) => [l.id, l]));
|
|
109
|
+
let cur = byId.get(layerId);
|
|
110
|
+
while (cur) {
|
|
111
|
+
if (cur.locked)
|
|
112
|
+
return true;
|
|
113
|
+
cur = cur.parentId ? byId.get(cur.parentId) : undefined;
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
function parentOf(layers, layerId, map) {
|
|
118
|
+
const byId = map ?? new Map(layers.map((l) => [l.id, l]));
|
|
119
|
+
const layer = byId.get(layerId);
|
|
120
|
+
return layer?.parentId ? byId.get(layer.parentId) : undefined;
|
|
121
|
+
}
|
|
122
|
+
/** Child X/Y is owned by an hBox / vBox / wrap / grid parent. */
|
|
123
|
+
export function isLayoutPositionLocked(layers, layerId, map) {
|
|
124
|
+
const parent = parentOf(layers, layerId, map);
|
|
125
|
+
return !!parent && LAYOUT_POSITION_KINDS.has(parent.kind);
|
|
126
|
+
}
|
|
127
|
+
/** Child W/H is owned by a grid / scaleBox parent. */
|
|
128
|
+
export function isLayoutSizeLocked(layers, layerId, map) {
|
|
129
|
+
const parent = parentOf(layers, layerId, map);
|
|
130
|
+
return !!parent && LAYOUT_SIZE_KINDS.has(parent.kind);
|
|
131
|
+
}
|
|
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.
|
|
135
|
+
*/
|
|
136
|
+
export function selectionAncestorIds(layers, selectedIds) {
|
|
137
|
+
const selected = new Set(selectedIds);
|
|
138
|
+
const out = [];
|
|
139
|
+
const seen = new Set();
|
|
140
|
+
for (const id of selectedIds) {
|
|
141
|
+
for (const anc of getAncestors(layers, id)) {
|
|
142
|
+
if (selected.has(anc.id) || seen.has(anc.id) || anc.kind === 'canvasPanel')
|
|
143
|
+
continue;
|
|
144
|
+
seen.add(anc.id);
|
|
145
|
+
out.push(anc.id);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
92
150
|
/**
|
|
93
151
|
* CSS transform for a flat-stage layer so ancestor rotations orbit children
|
|
94
152
|
* around each ancestor's center (DOM is not nested).
|
|
@@ -179,6 +237,43 @@ export function slotFromLocalRect(parentSize, rect, anchors = ANCHOR_PRESETS.top
|
|
|
179
237
|
}
|
|
180
238
|
};
|
|
181
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* Translate a UMG slot without changing size.
|
|
242
|
+
* `right` / `bottom` are inverted (distance from the opposite anchored edge).
|
|
243
|
+
*/
|
|
244
|
+
export function translateSlot(slot, dx, dy) {
|
|
245
|
+
if (!dx && !dy)
|
|
246
|
+
return slot;
|
|
247
|
+
return {
|
|
248
|
+
...slot,
|
|
249
|
+
offsets: {
|
|
250
|
+
left: slot.offsets.left + dx,
|
|
251
|
+
right: slot.offsets.right - dx,
|
|
252
|
+
top: slot.offsets.top + dy,
|
|
253
|
+
bottom: slot.offsets.bottom - dy
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Keyboard nudge along one axis.
|
|
259
|
+
* With snap: land on the next/previous grid line (if already on-grid, move one cell; Shift = two).
|
|
260
|
+
*/
|
|
261
|
+
export function stepAxis(value, dir, opts) {
|
|
262
|
+
const cell = opts.cell;
|
|
263
|
+
if (!opts.snap || cell <= 0)
|
|
264
|
+
return value + dir * (opts.coarse ? 10 : 1);
|
|
265
|
+
const step = opts.coarse ? cell * 2 : cell;
|
|
266
|
+
const eps = 1e-6;
|
|
267
|
+
const onGrid = Math.abs(value - Math.round(value / cell) * cell) < eps;
|
|
268
|
+
if (dir > 0) {
|
|
269
|
+
if (onGrid)
|
|
270
|
+
return value + step;
|
|
271
|
+
return Math.ceil((value + eps) / cell) * cell;
|
|
272
|
+
}
|
|
273
|
+
if (onGrid)
|
|
274
|
+
return value - step;
|
|
275
|
+
return Math.floor((value - eps) / cell) * cell;
|
|
276
|
+
}
|
|
182
277
|
export function contentPadding(layer) {
|
|
183
278
|
const p = layer.slot?.padding;
|
|
184
279
|
return {
|
|
@@ -217,7 +312,9 @@ export function computeAbsoluteRects(layers, rootSize) {
|
|
|
217
312
|
return;
|
|
218
313
|
const parentW = parentAbs?.w ?? rootSize.width;
|
|
219
314
|
const parentH = parentAbs?.h ?? rootSize.height;
|
|
220
|
-
const pad = parentLayer
|
|
315
|
+
const pad = parentLayer
|
|
316
|
+
? contentPadding(parentLayer)
|
|
317
|
+
: { left: 0, top: 0, right: 0, bottom: 0 };
|
|
221
318
|
const originX = (parentAbs?.x ?? 0) + pad.left;
|
|
222
319
|
const originY = (parentAbs?.y ?? 0) + pad.top;
|
|
223
320
|
const contentW = Math.max(0, parentW - pad.left - pad.right);
|
|
@@ -490,6 +587,7 @@ export function reparentLayer(layers, layerId, newParentId, rootSize) {
|
|
|
490
587
|
}
|
|
491
588
|
: l);
|
|
492
589
|
}
|
|
590
|
+
/** Wrap one or more layers in a new parent (`group`, `hBox`, `border`, …). */
|
|
493
591
|
export function wrapSelection(doc, selectedIds, wrapKind = 'group') {
|
|
494
592
|
if (!selectedIds.length)
|
|
495
593
|
return null;
|
|
@@ -499,7 +597,7 @@ export function wrapSelection(doc, selectedIds, wrapKind = 'group') {
|
|
|
499
597
|
// Exclude descendants when parent+child are both selected
|
|
500
598
|
let selected = layers.filter((l) => set.has(l.id));
|
|
501
599
|
selected = selected.filter((l) => !selected.some((other) => other.id !== l.id && isDescendant(layers, l.id, other.id)));
|
|
502
|
-
if (selected.length
|
|
600
|
+
if (!selected.length)
|
|
503
601
|
return null;
|
|
504
602
|
const wrapIds = selected.map((l) => l.id);
|
|
505
603
|
// Only wrap siblings that share the same parent — otherwise lift to root first
|
|
@@ -509,7 +607,9 @@ export function wrapSelection(doc, selectedIds, wrapKind = 'group') {
|
|
|
509
607
|
layers = reparentLayer(layers, id, null, rootSize);
|
|
510
608
|
}
|
|
511
609
|
parentId = null;
|
|
512
|
-
selected = wrapIds
|
|
610
|
+
selected = wrapIds
|
|
611
|
+
.map((id) => layers.find((l) => l.id === id))
|
|
612
|
+
.filter(Boolean);
|
|
513
613
|
}
|
|
514
614
|
const absMap = computeAbsoluteRects(layers, rootSize);
|
|
515
615
|
let minX = Infinity;
|
|
@@ -619,18 +719,13 @@ export function duplicateSubtree(doc, rootIds, offset = { x: 16, y: 16 }) {
|
|
|
619
719
|
? (layer.parentId ?? null)
|
|
620
720
|
: (layer.parentId ?? null);
|
|
621
721
|
let rect = { ...layer.rect };
|
|
622
|
-
let slot = layer.slot
|
|
722
|
+
let slot = layer.slot
|
|
723
|
+
? { ...layer.slot, anchors: { ...layer.slot.anchors }, offsets: { ...layer.slot.offsets } }
|
|
724
|
+
: undefined;
|
|
623
725
|
if (isRoot) {
|
|
624
726
|
rect = { ...rect, x: rect.x + offset.x, y: rect.y + offset.y };
|
|
625
727
|
if (slot) {
|
|
626
|
-
slot =
|
|
627
|
-
...slot,
|
|
628
|
-
offsets: {
|
|
629
|
-
...slot.offsets,
|
|
630
|
-
left: slot.offsets.left + offset.x,
|
|
631
|
-
top: slot.offsets.top + offset.y
|
|
632
|
-
}
|
|
633
|
-
};
|
|
728
|
+
slot = translateSlot(slot, offset.x, offset.y);
|
|
634
729
|
}
|
|
635
730
|
}
|
|
636
731
|
return {
|
|
@@ -672,3 +767,140 @@ export function syncSlotFromRect(layer, parentSize) {
|
|
|
672
767
|
};
|
|
673
768
|
return { ...layer, slot, rect: rectFromSlot(slot, parentSize) };
|
|
674
769
|
}
|
|
770
|
+
const GROUP_FIT_EPS = 0.5;
|
|
771
|
+
function rectsApproxEqual(a, b, eps = GROUP_FIT_EPS) {
|
|
772
|
+
return (Math.abs(a.x - b.x) < eps &&
|
|
773
|
+
Math.abs(a.y - b.y) < eps &&
|
|
774
|
+
Math.abs(a.w - b.w) < eps &&
|
|
775
|
+
Math.abs(a.h - b.h) < eps);
|
|
776
|
+
}
|
|
777
|
+
function rootFrame(rootSize) {
|
|
778
|
+
return { x: 0, y: 0, w: rootSize.width, h: rootSize.height };
|
|
779
|
+
}
|
|
780
|
+
function ancestorDepth(layers, layerId, map) {
|
|
781
|
+
let d = 0;
|
|
782
|
+
let cur = map.get(layerId);
|
|
783
|
+
while (cur?.parentId) {
|
|
784
|
+
d += 1;
|
|
785
|
+
cur = map.get(cur.parentId);
|
|
786
|
+
if (d > layers.length)
|
|
787
|
+
break;
|
|
788
|
+
}
|
|
789
|
+
return d;
|
|
790
|
+
}
|
|
791
|
+
/** Write an absolute rect back to layer.rect / slot in parent-local space. */
|
|
792
|
+
export function layerFromAbsoluteRect(layer, absRect, parentAbs, parentLayer, rootSize) {
|
|
793
|
+
const pad = parentLayer ? contentPadding(parentLayer) : { left: 0, top: 0, right: 0, bottom: 0 };
|
|
794
|
+
const frame = parentAbs ?? rootFrame(rootSize);
|
|
795
|
+
const originX = frame.x + pad.left;
|
|
796
|
+
const originY = frame.y + pad.top;
|
|
797
|
+
const contentW = Math.max(0, frame.w - pad.left - pad.right);
|
|
798
|
+
const contentH = Math.max(0, frame.h - pad.top - pad.bottom);
|
|
799
|
+
const local = {
|
|
800
|
+
x: absRect.x - originX,
|
|
801
|
+
y: absRect.y - originY,
|
|
802
|
+
w: absRect.w,
|
|
803
|
+
h: absRect.h
|
|
804
|
+
};
|
|
805
|
+
return syncSlotFromRect({ ...layer, rect: local }, { width: contentW, height: contentH });
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Figma-style groups: origin + size is the AABB of direct children.
|
|
809
|
+
* Children keep their absolute positions (local coords are rebased).
|
|
810
|
+
* Nested groups are fitted innermost-first.
|
|
811
|
+
*/
|
|
812
|
+
export function fitGroupsToChildren(layers, rootSize) {
|
|
813
|
+
const byId = new Map(layers.map((l) => [l.id, l]));
|
|
814
|
+
const groups = layers
|
|
815
|
+
.filter((l) => l.kind === 'group')
|
|
816
|
+
.sort((a, b) => ancestorDepth(layers, b.id, byId) - ancestorDepth(layers, a.id, byId));
|
|
817
|
+
if (!groups.length)
|
|
818
|
+
return layers;
|
|
819
|
+
let next = layers;
|
|
820
|
+
for (const group of groups) {
|
|
821
|
+
next = fitOneGroup(next, group.id, rootSize);
|
|
822
|
+
}
|
|
823
|
+
return next;
|
|
824
|
+
}
|
|
825
|
+
function fitOneGroup(layers, groupId, rootSize) {
|
|
826
|
+
const children = getChildren(layers, groupId);
|
|
827
|
+
if (!children.length)
|
|
828
|
+
return layers;
|
|
829
|
+
const absMap = computeAbsoluteRects(layers, rootSize);
|
|
830
|
+
const group = layers.find((l) => l.id === groupId);
|
|
831
|
+
if (!group)
|
|
832
|
+
return layers;
|
|
833
|
+
let minX = Infinity;
|
|
834
|
+
let minY = Infinity;
|
|
835
|
+
let maxX = -Infinity;
|
|
836
|
+
let maxY = -Infinity;
|
|
837
|
+
for (const c of children) {
|
|
838
|
+
const r = absMap.get(c.id);
|
|
839
|
+
if (!r)
|
|
840
|
+
continue;
|
|
841
|
+
minX = Math.min(minX, r.x);
|
|
842
|
+
minY = Math.min(minY, r.y);
|
|
843
|
+
maxX = Math.max(maxX, r.x + r.w);
|
|
844
|
+
maxY = Math.max(maxY, r.y + r.h);
|
|
845
|
+
}
|
|
846
|
+
if (!Number.isFinite(minX))
|
|
847
|
+
return layers;
|
|
848
|
+
const newAbs = {
|
|
849
|
+
x: minX,
|
|
850
|
+
y: minY,
|
|
851
|
+
w: Math.max(1, maxX - minX),
|
|
852
|
+
h: Math.max(1, maxY - minY)
|
|
853
|
+
};
|
|
854
|
+
const oldAbs = absMap.get(groupId) ?? group.rect;
|
|
855
|
+
if (rectsApproxEqual(oldAbs, newAbs))
|
|
856
|
+
return layers;
|
|
857
|
+
const byId = new Map(layers.map((l) => [l.id, l]));
|
|
858
|
+
const parent = group.parentId ? (byId.get(group.parentId) ?? null) : null;
|
|
859
|
+
const parentAbs = group.parentId ? (absMap.get(group.parentId) ?? null) : rootFrame(rootSize);
|
|
860
|
+
const updated = new Map();
|
|
861
|
+
updated.set(groupId, layerFromAbsoluteRect(group, newAbs, parentAbs, parent, rootSize));
|
|
862
|
+
for (const c of children) {
|
|
863
|
+
const r = absMap.get(c.id);
|
|
864
|
+
if (!r)
|
|
865
|
+
continue;
|
|
866
|
+
updated.set(c.id, layerFromAbsoluteRect(c, r, newAbs, group, rootSize));
|
|
867
|
+
}
|
|
868
|
+
return layers.map((l) => updated.get(l.id) ?? l);
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Scale a group (or any subtree) from `prevAbs` to `nextAbs`.
|
|
872
|
+
* Descendants keep their relative placement inside the box.
|
|
873
|
+
*/
|
|
874
|
+
export function scaleSubtreeAbsolute(layers, rootId, prevAbs, nextAbs, rootSize) {
|
|
875
|
+
const sx = prevAbs.w > 0 ? nextAbs.w / prevAbs.w : 1;
|
|
876
|
+
const sy = prevAbs.h > 0 ? nextAbs.h / prevAbs.h : 1;
|
|
877
|
+
const absMap = computeAbsoluteRects(layers, rootSize);
|
|
878
|
+
const ids = new Set(getSubtreeIds(layers, rootId));
|
|
879
|
+
const byId = new Map(layers.map((l) => [l.id, l]));
|
|
880
|
+
const nextAbsMap = new Map();
|
|
881
|
+
for (const id of ids) {
|
|
882
|
+
const r = absMap.get(id);
|
|
883
|
+
if (!r)
|
|
884
|
+
continue;
|
|
885
|
+
if (id === rootId) {
|
|
886
|
+
nextAbsMap.set(id, { ...nextAbs });
|
|
887
|
+
continue;
|
|
888
|
+
}
|
|
889
|
+
nextAbsMap.set(id, {
|
|
890
|
+
x: nextAbs.x + (r.x - prevAbs.x) * sx,
|
|
891
|
+
y: nextAbs.y + (r.y - prevAbs.y) * sy,
|
|
892
|
+
w: Math.max(1, r.w * sx),
|
|
893
|
+
h: Math.max(1, r.h * sy)
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
return layers.map((l) => {
|
|
897
|
+
const abs = nextAbsMap.get(l.id);
|
|
898
|
+
if (!abs)
|
|
899
|
+
return l;
|
|
900
|
+
const parent = l.parentId ? (byId.get(l.parentId) ?? null) : null;
|
|
901
|
+
const parentAbs = l.parentId
|
|
902
|
+
? (nextAbsMap.get(l.parentId) ?? absMap.get(l.parentId) ?? null)
|
|
903
|
+
: rootFrame(rootSize);
|
|
904
|
+
return layerFromAbsoluteRect(l, abs, parentAbs, parent, rootSize);
|
|
905
|
+
});
|
|
906
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Attachment } from 'svelte/attachments';
|
|
2
|
+
/**
|
|
3
|
+
* Second click on a popover invoker must close it.
|
|
4
|
+
*
|
|
5
|
+
* `popover="auto"` light-dismisses when the trigger (outside the panel) is
|
|
6
|
+
* clicked, then `popovertargetaction="toggle"` / a custom `onclick` opens it
|
|
7
|
+
* again. Remember "was open" on pointerdown and cancel that reopen.
|
|
8
|
+
*/
|
|
9
|
+
export declare function bindPopoverInvokerToggle(trigger: HTMLElement, getPanel: () => HTMLElement | null | undefined): () => void;
|
|
10
|
+
/** `{@attach popoverInvokerToggle(() => panelEl)}` on a popover invoker button. */
|
|
11
|
+
export declare function popoverInvokerToggle(getPanel: () => HTMLElement | null | undefined): Attachment<HTMLElement>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Second click on a popover invoker must close it.
|
|
3
|
+
*
|
|
4
|
+
* `popover="auto"` light-dismisses when the trigger (outside the panel) is
|
|
5
|
+
* clicked, then `popovertargetaction="toggle"` / a custom `onclick` opens it
|
|
6
|
+
* again. Remember "was open" on pointerdown and cancel that reopen.
|
|
7
|
+
*/
|
|
8
|
+
export function bindPopoverInvokerToggle(trigger, getPanel) {
|
|
9
|
+
let closeOnClick = false;
|
|
10
|
+
const onPointerDown = () => {
|
|
11
|
+
closeOnClick = !!getPanel()?.matches(':popover-open');
|
|
12
|
+
};
|
|
13
|
+
const onClick = (event) => {
|
|
14
|
+
if (!closeOnClick)
|
|
15
|
+
return;
|
|
16
|
+
closeOnClick = false;
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
event.stopImmediatePropagation();
|
|
19
|
+
const panel = getPanel();
|
|
20
|
+
if (panel?.matches(':popover-open')) {
|
|
21
|
+
try {
|
|
22
|
+
panel.hidePopover();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
/* ignore */
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
trigger.addEventListener('pointerdown', onPointerDown, true);
|
|
30
|
+
trigger.addEventListener('click', onClick, true);
|
|
31
|
+
return () => {
|
|
32
|
+
trigger.removeEventListener('pointerdown', onPointerDown, true);
|
|
33
|
+
trigger.removeEventListener('click', onClick, true);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** `{@attach popoverInvokerToggle(() => panelEl)}` on a popover invoker button. */
|
|
37
|
+
export function popoverInvokerToggle(getPanel) {
|
|
38
|
+
return (node) => bindPopoverInvokerToggle(node, getPanel);
|
|
39
|
+
}
|