@r2digisolutions/components 0.19.16 → 0.19.17
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/Slider/Slider.stories.d.ts +8 -1
- package/dist/components/atoms/Slider/Slider.stories.js +17 -1
- package/dist/components/atoms/Slider/Slider.svelte +89 -64
- package/dist/components/atoms/Slider/Slider.svelte.d.ts +3 -1
- package/dist/components/atoms/Slider/SliderStory.svelte +4 -2
- package/dist/components/atoms/Slider/SliderStory.svelte.d.ts +2 -1
- package/dist/components/molecules/BulkActionBar/BulkActionBar.stories.d.ts +1 -1
- package/dist/components/molecules/CanvasInspector/CanvasInspector.svelte +44 -20
- package/dist/components/molecules/MediaStage/MediaStage.svelte +7 -1
- package/dist/components/molecules/NewsletterSignup/NewsletterSignup.stories.d.ts +1 -1
- package/dist/components/molecules/PropertyField/PropertyField.svelte +41 -20
- package/dist/components/molecules/PropertyField/PropertyField.svelte.d.ts +5 -1
- package/dist/components/molecules/PropertyField/PropertyFieldStory.svelte +2 -1
- package/dist/components/organisms/CanvasEditor/CanvasEditor.svelte +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/canvasDocument.d.ts +11 -1
- package/dist/utils/canvasDocument.js +31 -1
- package/package.json +1 -1
|
@@ -9,7 +9,8 @@ declare const meta: {
|
|
|
9
9
|
value?: number;
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
showValue?: boolean;
|
|
12
|
-
valuePosition?: "header" | "tooltip";
|
|
12
|
+
valuePosition?: "header" | "tooltip" | "inline";
|
|
13
|
+
variant?: "default" | "inset";
|
|
13
14
|
showMarks?: boolean;
|
|
14
15
|
unit?: string;
|
|
15
16
|
size?: "sm" | "md" | "lg";
|
|
@@ -41,6 +42,10 @@ declare const meta: {
|
|
|
41
42
|
control: "select";
|
|
42
43
|
options: string[];
|
|
43
44
|
};
|
|
45
|
+
variant: {
|
|
46
|
+
control: "select";
|
|
47
|
+
options: string[];
|
|
48
|
+
};
|
|
44
49
|
showMarks: {
|
|
45
50
|
control: "boolean";
|
|
46
51
|
};
|
|
@@ -61,6 +66,7 @@ declare const meta: {
|
|
|
61
66
|
disabled: false;
|
|
62
67
|
showValue: true;
|
|
63
68
|
valuePosition: "tooltip";
|
|
69
|
+
variant: "default";
|
|
64
70
|
showMarks: true;
|
|
65
71
|
unit: string;
|
|
66
72
|
size: "md";
|
|
@@ -70,4 +76,5 @@ export default meta;
|
|
|
70
76
|
type Story = StoryObj<typeof meta>;
|
|
71
77
|
export declare const FloatingTooltip: Story;
|
|
72
78
|
export declare const HeaderValue: Story;
|
|
79
|
+
export declare const InsetPanel: Story;
|
|
73
80
|
export declare const LargeSize: Story;
|
|
@@ -11,7 +11,8 @@ const meta = {
|
|
|
11
11
|
value: { control: 'number' },
|
|
12
12
|
disabled: { control: 'boolean' },
|
|
13
13
|
showValue: { control: 'boolean' },
|
|
14
|
-
valuePosition: { control: 'select', options: ['tooltip', 'header'] },
|
|
14
|
+
valuePosition: { control: 'select', options: ['tooltip', 'header', 'inline'] },
|
|
15
|
+
variant: { control: 'select', options: ['default', 'inset'] },
|
|
15
16
|
showMarks: { control: 'boolean' },
|
|
16
17
|
unit: { control: 'text' },
|
|
17
18
|
size: { control: 'select', options: ['sm', 'md', 'lg'] }
|
|
@@ -25,6 +26,7 @@ const meta = {
|
|
|
25
26
|
disabled: false,
|
|
26
27
|
showValue: true,
|
|
27
28
|
valuePosition: 'tooltip',
|
|
29
|
+
variant: 'default',
|
|
28
30
|
showMarks: true,
|
|
29
31
|
unit: '%',
|
|
30
32
|
size: 'md'
|
|
@@ -37,6 +39,20 @@ export const FloatingTooltip = {
|
|
|
37
39
|
export const HeaderValue = {
|
|
38
40
|
args: { label: 'Budget Limit', valuePosition: 'header', min: 100, max: 2000, step: 50, value: 850, unit: '€', showMarks: true }
|
|
39
41
|
};
|
|
42
|
+
export const InsetPanel = {
|
|
43
|
+
args: {
|
|
44
|
+
label: undefined,
|
|
45
|
+
variant: 'inset',
|
|
46
|
+
valuePosition: 'inline',
|
|
47
|
+
size: 'sm',
|
|
48
|
+
value: 0.65,
|
|
49
|
+
min: 0,
|
|
50
|
+
max: 1,
|
|
51
|
+
step: 0.01,
|
|
52
|
+
showMarks: false,
|
|
53
|
+
unit: ''
|
|
54
|
+
}
|
|
55
|
+
};
|
|
40
56
|
export const LargeSize = {
|
|
41
57
|
args: { label: 'Zoom Level', size: 'lg', value: 120, min: 50, max: 200, unit: '%', showMarks: true }
|
|
42
58
|
};
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
value?: number;
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
showValue?: boolean;
|
|
12
|
-
valuePosition?: 'header' | 'tooltip';
|
|
12
|
+
valuePosition?: 'header' | 'tooltip' | 'inline';
|
|
13
|
+
/** Bordered inset control — for UE-style details / inspector panels. */
|
|
14
|
+
variant?: 'default' | 'inset';
|
|
13
15
|
showMarks?: boolean;
|
|
14
16
|
unit?: string;
|
|
15
17
|
size?: 'sm' | 'md' | 'lg';
|
|
@@ -29,6 +31,7 @@
|
|
|
29
31
|
disabled = false,
|
|
30
32
|
showValue = true,
|
|
31
33
|
valuePosition = 'tooltip',
|
|
34
|
+
variant = 'default',
|
|
32
35
|
showMarks = false,
|
|
33
36
|
unit = '',
|
|
34
37
|
size = 'md',
|
|
@@ -42,19 +45,27 @@
|
|
|
42
45
|
|
|
43
46
|
const sliderId = $derived(id ?? `slider-${Math.random().toString(36).slice(2, 9)}`);
|
|
44
47
|
const percentage = $derived(Math.min(100, Math.max(0, ((value - min) / (max - min)) * 100)));
|
|
48
|
+
const inset = $derived(variant === 'inset');
|
|
49
|
+
const inlineValue = $derived(showValue && (valuePosition === 'inline' || inset));
|
|
45
50
|
|
|
46
51
|
const trackHeightClasses = {
|
|
47
|
-
sm: 'h-1
|
|
48
|
-
md: 'h-
|
|
49
|
-
lg: 'h-
|
|
52
|
+
sm: 'h-1',
|
|
53
|
+
md: 'h-1.5',
|
|
54
|
+
lg: 'h-2'
|
|
50
55
|
};
|
|
51
56
|
|
|
52
57
|
const thumbSizeClasses = {
|
|
53
|
-
sm: 'h-
|
|
54
|
-
md: 'h-5 w-5 -ml-
|
|
55
|
-
lg: 'h-
|
|
58
|
+
sm: 'h-3 w-3 -ml-1.5',
|
|
59
|
+
md: 'h-3.5 w-3.5 -ml-[7px]',
|
|
60
|
+
lg: 'h-4 w-4 -ml-2'
|
|
56
61
|
};
|
|
57
62
|
|
|
63
|
+
function formatValue(v: number): string {
|
|
64
|
+
if (Number.isInteger(step) && Number.isInteger(v)) return String(v);
|
|
65
|
+
const decimals = String(step).includes('.') ? String(step).split('.')[1]?.length ?? 2 : 2;
|
|
66
|
+
return v.toFixed(Math.min(decimals, 2));
|
|
67
|
+
}
|
|
68
|
+
|
|
58
69
|
function handleInput(e: Event) {
|
|
59
70
|
const target = e.target as HTMLInputElement;
|
|
60
71
|
value = parseFloat(target.value);
|
|
@@ -68,17 +79,17 @@
|
|
|
68
79
|
}
|
|
69
80
|
</script>
|
|
70
81
|
|
|
71
|
-
<div class={['flex
|
|
72
|
-
{#if label || (showValue && valuePosition === 'header')}
|
|
82
|
+
<div class={['flex w-full select-none flex-col gap-1.5', className]}>
|
|
83
|
+
{#if label || (showValue && valuePosition === 'header' && !inset)}
|
|
73
84
|
<div class="flex items-center justify-between text-sm font-medium">
|
|
74
85
|
{#if label}
|
|
75
86
|
<label for={sliderId} class="text-primary">{label}</label>
|
|
76
87
|
{:else}
|
|
77
88
|
<span></span>
|
|
78
89
|
{/if}
|
|
79
|
-
{#if showValue && valuePosition === 'header'}
|
|
80
|
-
<span class="text-xs font-semibold
|
|
81
|
-
{value}{unit}
|
|
90
|
+
{#if showValue && valuePosition === 'header' && !inset}
|
|
91
|
+
<span class="font-mono text-xs font-semibold text-brand-600 dark:text-brand-400">
|
|
92
|
+
{formatValue(value)}{unit}
|
|
82
93
|
</span>
|
|
83
94
|
{/if}
|
|
84
95
|
</div>
|
|
@@ -86,69 +97,83 @@
|
|
|
86
97
|
|
|
87
98
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
88
99
|
<div
|
|
89
|
-
class=
|
|
100
|
+
class={[
|
|
101
|
+
'relative flex w-full items-center gap-2',
|
|
102
|
+
inset &&
|
|
103
|
+
'h-7 rounded-md border border-border bg-surface-overlay/80 px-2 shadow-sm dark:bg-surface-overlay/50',
|
|
104
|
+
!inset && 'py-1.5'
|
|
105
|
+
]}
|
|
90
106
|
onmouseenter={() => (isHovered = true)}
|
|
91
107
|
onmouseleave={() => (isHovered = false)}
|
|
92
108
|
>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
109
|
+
<div class="relative flex min-w-0 flex-1 cursor-pointer touch-none items-center py-1">
|
|
110
|
+
<!-- Track background -->
|
|
111
|
+
<div
|
|
112
|
+
class={[
|
|
113
|
+
'relative w-full overflow-hidden rounded-full',
|
|
114
|
+
inset ? 'bg-border dark:bg-surface-elevated' : 'bg-border-strong dark:bg-surface-overlay',
|
|
115
|
+
trackHeightClasses[size]
|
|
116
|
+
]}
|
|
117
|
+
>
|
|
118
|
+
<!-- Fill bar -->
|
|
119
|
+
<div class="h-full rounded-full bg-brand-500" style="width: {percentage}%"></div>
|
|
120
|
+
</div>
|
|
103
121
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
<span class="h-1.5 w-1.5 rounded-full bg-brand-500"></span>
|
|
122
|
+
<!-- Custom Floating Thumb / Handle -->
|
|
123
|
+
<div
|
|
124
|
+
class={[
|
|
125
|
+
'pointer-events-none absolute top-1/2 flex -translate-y-1/2 items-center justify-center rounded-full border-2 border-brand-500 bg-white shadow-md dark:bg-slate-900',
|
|
126
|
+
'transition-[transform,box-shadow] duration-100',
|
|
127
|
+
thumbSizeClasses[size],
|
|
128
|
+
(isFocused || isHovered) && 'scale-110 ring-2 ring-brand-500/25',
|
|
129
|
+
disabled && 'border-gray-400 opacity-50'
|
|
130
|
+
]}
|
|
131
|
+
style="left: {percentage}%"
|
|
132
|
+
>
|
|
133
|
+
<span class="h-1 w-1 rounded-full bg-brand-500"></span>
|
|
117
134
|
|
|
118
|
-
|
|
119
|
-
{#if showValue && valuePosition === 'tooltip' && (isHovered || isFocused)}
|
|
120
|
-
<div
|
|
121
|
-
class="absolute -top-9 left-1/2 -translate-x-1/2 px-2 py-0.5 rounded-md bg-slate-900 dark:bg-slate-100 text-white dark:text-slate-900 text-[11px] font-bold font-mono shadow-lg whitespace-nowrap pointer-events-none animate-in fade-in zoom-in-95 duration-150"
|
|
122
|
-
>
|
|
123
|
-
{value}{unit}
|
|
124
|
-
<!-- Tooltip arrow -->
|
|
135
|
+
{#if showValue && valuePosition === 'tooltip' && !inset && (isHovered || isFocused)}
|
|
125
136
|
<div
|
|
126
|
-
class="absolute -
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
137
|
+
class="pointer-events-none absolute -top-8 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-md bg-slate-900 px-1.5 py-0.5 font-mono text-[10px] font-bold text-white shadow-lg animate-in fade-in zoom-in-95 duration-150 dark:bg-slate-100 dark:text-slate-900"
|
|
138
|
+
>
|
|
139
|
+
{formatValue(value)}{unit}
|
|
140
|
+
<div
|
|
141
|
+
class="absolute -bottom-1 left-1/2 h-1.5 w-1.5 -translate-x-1/2 rotate-45 bg-slate-900 dark:bg-slate-100"
|
|
142
|
+
></div>
|
|
143
|
+
</div>
|
|
144
|
+
{/if}
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
<!-- Transparent native input for accessibility and drag interaction -->
|
|
148
|
+
<input
|
|
149
|
+
id={sliderId}
|
|
150
|
+
type="range"
|
|
151
|
+
{name}
|
|
152
|
+
{min}
|
|
153
|
+
{max}
|
|
154
|
+
{step}
|
|
155
|
+
{disabled}
|
|
156
|
+
bind:value
|
|
157
|
+
class="absolute inset-0 z-10 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed"
|
|
158
|
+
oninput={handleInput}
|
|
159
|
+
onchange={handleChange}
|
|
160
|
+
onfocus={() => (isFocused = true)}
|
|
161
|
+
onblur={() => (isFocused = false)}
|
|
162
|
+
/>
|
|
130
163
|
</div>
|
|
131
164
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
{disabled}
|
|
141
|
-
bind:value
|
|
142
|
-
class="absolute inset-0 w-full opacity-0 cursor-pointer disabled:cursor-not-allowed h-full z-10"
|
|
143
|
-
oninput={handleInput}
|
|
144
|
-
onchange={handleChange}
|
|
145
|
-
onfocus={() => (isFocused = true)}
|
|
146
|
-
onblur={() => (isFocused = false)}
|
|
147
|
-
/>
|
|
165
|
+
{#if inlineValue}
|
|
166
|
+
<span
|
|
167
|
+
class="w-9 shrink-0 text-right font-mono text-[10px] font-semibold tabular-nums text-secondary"
|
|
168
|
+
aria-hidden="true"
|
|
169
|
+
>
|
|
170
|
+
{formatValue(value)}{unit}
|
|
171
|
+
</span>
|
|
172
|
+
{/if}
|
|
148
173
|
</div>
|
|
149
174
|
|
|
150
175
|
{#if showMarks}
|
|
151
|
-
<div class="flex items-center justify-between
|
|
176
|
+
<div class="-mt-0.5 flex items-center justify-between px-0.5 font-mono text-[10px] text-muted">
|
|
152
177
|
<span>{min}{unit}</span>
|
|
153
178
|
<span>{max}{unit}</span>
|
|
154
179
|
</div>
|
|
@@ -8,7 +8,9 @@ interface SliderProps {
|
|
|
8
8
|
value?: number;
|
|
9
9
|
disabled?: boolean;
|
|
10
10
|
showValue?: boolean;
|
|
11
|
-
valuePosition?: 'header' | 'tooltip';
|
|
11
|
+
valuePosition?: 'header' | 'tooltip' | 'inline';
|
|
12
|
+
/** Bordered inset control — for UE-style details / inspector panels. */
|
|
13
|
+
variant?: 'default' | 'inset';
|
|
12
14
|
showMarks?: boolean;
|
|
13
15
|
unit?: string;
|
|
14
16
|
size?: 'sm' | 'md' | 'lg';
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
value?: number;
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
showValue?: boolean;
|
|
12
|
-
valuePosition?: 'header' | 'tooltip';
|
|
12
|
+
valuePosition?: 'header' | 'tooltip' | 'inline';
|
|
13
|
+
variant?: 'default' | 'inset';
|
|
13
14
|
showMarks?: boolean;
|
|
14
15
|
unit?: string;
|
|
15
16
|
size?: 'sm' | 'md' | 'lg';
|
|
@@ -18,13 +19,14 @@
|
|
|
18
19
|
|
|
19
20
|
<div class="w-80 max-w-full p-4">
|
|
20
21
|
<Slider
|
|
21
|
-
label={props.label
|
|
22
|
+
label={props.label}
|
|
22
23
|
min={props.min ?? 0}
|
|
23
24
|
max={props.max ?? 100}
|
|
24
25
|
step={props.step ?? 1}
|
|
25
26
|
disabled={props.disabled ?? false}
|
|
26
27
|
showValue={props.showValue ?? true}
|
|
27
28
|
valuePosition={props.valuePosition ?? 'tooltip'}
|
|
29
|
+
variant={props.variant ?? 'default'}
|
|
28
30
|
showMarks={props.showMarks ?? true}
|
|
29
31
|
unit={props.unit ?? '%'}
|
|
30
32
|
size={props.size ?? 'md'}
|
|
@@ -6,7 +6,8 @@ type $$ComponentProps = {
|
|
|
6
6
|
value?: number;
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
showValue?: boolean;
|
|
9
|
-
valuePosition?: 'header' | 'tooltip';
|
|
9
|
+
valuePosition?: 'header' | 'tooltip' | 'inline';
|
|
10
|
+
variant?: 'default' | 'inset';
|
|
10
11
|
showMarks?: boolean;
|
|
11
12
|
unit?: string;
|
|
12
13
|
size?: 'sm' | 'md' | 'lg';
|
|
@@ -2,7 +2,7 @@ import type { StoryObj } from '@storybook/svelte';
|
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
4
|
component: import("svelte").Component<{
|
|
5
|
-
example?: "loading" | "default" | "
|
|
5
|
+
example?: "loading" | "default" | "inline" | "neutral" | "compact" | "icons";
|
|
6
6
|
size?: import("./BulkActionBar.svelte.ts").BulkActionBarSize;
|
|
7
7
|
placement?: import("./BulkActionBar.svelte.ts").BulkActionBarPlacement;
|
|
8
8
|
tone?: import("./BulkActionBar.svelte.ts").BulkActionBarTone;
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import FileUploader from '../../organisms/FileUploader/FileUploader.svelte';
|
|
13
13
|
import {
|
|
14
14
|
alignLayerRect,
|
|
15
|
+
applyTextAutoSize,
|
|
15
16
|
isCanvasFieldModified,
|
|
16
17
|
resetCanvasField,
|
|
17
18
|
type CanvasAlign,
|
|
@@ -272,8 +273,10 @@
|
|
|
272
273
|
|
|
273
274
|
function patchRect(partial: Partial<CanvasLayer['rect']>) {
|
|
274
275
|
if (!layer || !doc) return;
|
|
276
|
+
const prev = layer.rect;
|
|
275
277
|
const rect = { ...layer.rect, ...partial };
|
|
276
|
-
|
|
278
|
+
const synced = syncSlotFromRect({ ...layer, rect }, parentContentSize);
|
|
279
|
+
onchange?.(applyTextAutoSize(layer, synced, prev, rect));
|
|
277
280
|
}
|
|
278
281
|
|
|
279
282
|
function applyAlign(align: CanvasAlign) {
|
|
@@ -282,9 +285,9 @@
|
|
|
282
285
|
return;
|
|
283
286
|
}
|
|
284
287
|
if (!layer || !doc) return;
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
});
|
|
288
|
+
const prev = layer.rect;
|
|
289
|
+
const rect = alignLayerRect(layer.rect, { width: doc.width, height: doc.height }, align);
|
|
290
|
+
onchange?.(applyTextAutoSize(layer, { ...layer, rect }, prev, rect));
|
|
288
291
|
}
|
|
289
292
|
|
|
290
293
|
function replaceMedia(files: File[]) {
|
|
@@ -326,6 +329,7 @@
|
|
|
326
329
|
onexpose={(v) => toggleExpose('visible', 'Visible', v)}
|
|
327
330
|
modified={fieldModified('visible')}
|
|
328
331
|
onreset={() => resetField('visible')}
|
|
332
|
+
valueAlign="end"
|
|
329
333
|
>
|
|
330
334
|
<Toggle
|
|
331
335
|
checked={layer.visible}
|
|
@@ -337,6 +341,7 @@
|
|
|
337
341
|
label="Locked"
|
|
338
342
|
modified={fieldModified('locked')}
|
|
339
343
|
onreset={() => resetField('locked')}
|
|
344
|
+
valueAlign="end"
|
|
340
345
|
>
|
|
341
346
|
<Toggle checked={layer.locked} onchange={(v) => patch({ locked: v })} size="sm" />
|
|
342
347
|
</PropertyField>
|
|
@@ -349,12 +354,13 @@
|
|
|
349
354
|
>
|
|
350
355
|
<Slider
|
|
351
356
|
size="sm"
|
|
357
|
+
variant="inset"
|
|
352
358
|
min={0}
|
|
353
359
|
max={1}
|
|
354
360
|
step={0.01}
|
|
355
361
|
value={layer.opacity}
|
|
356
362
|
showValue
|
|
357
|
-
valuePosition="
|
|
363
|
+
valuePosition="inline"
|
|
358
364
|
oninput={(v) => patch({ opacity: v })}
|
|
359
365
|
/>
|
|
360
366
|
</PropertyField>
|
|
@@ -528,8 +534,8 @@
|
|
|
528
534
|
</div>
|
|
529
535
|
{/if}
|
|
530
536
|
{#if showContainerPadding}
|
|
531
|
-
<div class="grid grid-cols-2 gap-
|
|
532
|
-
<PropertyField label="Pad L">
|
|
537
|
+
<div class="grid grid-cols-2 gap-x-1 gap-y-0.5">
|
|
538
|
+
<PropertyField label="Pad L" labelWidth="2.75rem" compact>
|
|
533
539
|
<Input
|
|
534
540
|
type="number"
|
|
535
541
|
size="sm"
|
|
@@ -553,7 +559,7 @@
|
|
|
553
559
|
}}
|
|
554
560
|
/>
|
|
555
561
|
</PropertyField>
|
|
556
|
-
<PropertyField label="Pad T">
|
|
562
|
+
<PropertyField label="Pad T" labelWidth="2.75rem" compact>
|
|
557
563
|
<Input
|
|
558
564
|
type="number"
|
|
559
565
|
size="sm"
|
|
@@ -577,7 +583,7 @@
|
|
|
577
583
|
}}
|
|
578
584
|
/>
|
|
579
585
|
</PropertyField>
|
|
580
|
-
<PropertyField label="Pad R">
|
|
586
|
+
<PropertyField label="Pad R" labelWidth="2.75rem" compact>
|
|
581
587
|
<Input
|
|
582
588
|
type="number"
|
|
583
589
|
size="sm"
|
|
@@ -601,7 +607,7 @@
|
|
|
601
607
|
}}
|
|
602
608
|
/>
|
|
603
609
|
</PropertyField>
|
|
604
|
-
<PropertyField label="Pad B">
|
|
610
|
+
<PropertyField label="Pad B" labelWidth="2.75rem" compact>
|
|
605
611
|
<Input
|
|
606
612
|
type="number"
|
|
607
613
|
size="sm"
|
|
@@ -631,6 +637,7 @@
|
|
|
631
637
|
label="Clip children"
|
|
632
638
|
modified={fieldModified('clipChildren')}
|
|
633
639
|
onreset={() => resetField('clipChildren')}
|
|
640
|
+
valueAlign="end"
|
|
634
641
|
>
|
|
635
642
|
<Toggle
|
|
636
643
|
checked={!!layer.clipChildren || layer.kind === 'scrollBox'}
|
|
@@ -724,8 +731,8 @@
|
|
|
724
731
|
</div>
|
|
725
732
|
</div>
|
|
726
733
|
|
|
727
|
-
<div class="grid grid-cols-2 gap-
|
|
728
|
-
<PropertyField label="X">
|
|
734
|
+
<div class="grid grid-cols-2 gap-x-1 gap-y-0.5">
|
|
735
|
+
<PropertyField label="X" labelWidth="1.25rem" compact>
|
|
729
736
|
<Input
|
|
730
737
|
type="number"
|
|
731
738
|
size="sm"
|
|
@@ -735,7 +742,7 @@
|
|
|
735
742
|
patchRect({ x: Number((e.currentTarget as HTMLInputElement).value) })}
|
|
736
743
|
/>
|
|
737
744
|
</PropertyField>
|
|
738
|
-
<PropertyField label="Y">
|
|
745
|
+
<PropertyField label="Y" labelWidth="1.25rem" compact>
|
|
739
746
|
<Input
|
|
740
747
|
type="number"
|
|
741
748
|
size="sm"
|
|
@@ -745,7 +752,7 @@
|
|
|
745
752
|
patchRect({ y: Number((e.currentTarget as HTMLInputElement).value) })}
|
|
746
753
|
/>
|
|
747
754
|
</PropertyField>
|
|
748
|
-
<PropertyField label="W">
|
|
755
|
+
<PropertyField label="W" labelWidth="1.25rem" compact>
|
|
749
756
|
<Input
|
|
750
757
|
type="number"
|
|
751
758
|
size="sm"
|
|
@@ -754,7 +761,7 @@
|
|
|
754
761
|
patchRect({ w: Number((e.currentTarget as HTMLInputElement).value) })}
|
|
755
762
|
/>
|
|
756
763
|
</PropertyField>
|
|
757
|
-
<PropertyField label="H">
|
|
764
|
+
<PropertyField label="H" labelWidth="1.25rem" compact>
|
|
758
765
|
<Input
|
|
759
766
|
type="number"
|
|
760
767
|
size="sm"
|
|
@@ -781,12 +788,13 @@
|
|
|
781
788
|
>
|
|
782
789
|
<Slider
|
|
783
790
|
size="sm"
|
|
791
|
+
variant="inset"
|
|
784
792
|
min={-180}
|
|
785
793
|
max={180}
|
|
786
794
|
step={1}
|
|
787
795
|
value={layer.rotation ?? 0}
|
|
788
796
|
showValue
|
|
789
|
-
valuePosition="
|
|
797
|
+
valuePosition="inline"
|
|
790
798
|
unit="°"
|
|
791
799
|
oninput={(v) => patch({ rotation: v })}
|
|
792
800
|
/>
|
|
@@ -801,12 +809,13 @@
|
|
|
801
809
|
>
|
|
802
810
|
<Slider
|
|
803
811
|
size="sm"
|
|
812
|
+
variant="inset"
|
|
804
813
|
min={0}
|
|
805
814
|
max={64}
|
|
806
815
|
step={1}
|
|
807
816
|
value={layer.shadowBlur ?? 0}
|
|
808
817
|
showValue
|
|
809
|
-
valuePosition="
|
|
818
|
+
valuePosition="inline"
|
|
810
819
|
unit="px"
|
|
811
820
|
oninput={(v) => patch({ shadowBlur: v })}
|
|
812
821
|
/>
|
|
@@ -829,12 +838,13 @@
|
|
|
829
838
|
>
|
|
830
839
|
<Slider
|
|
831
840
|
size="sm"
|
|
841
|
+
variant="inset"
|
|
832
842
|
min={0}
|
|
833
843
|
max={40}
|
|
834
844
|
step={1}
|
|
835
845
|
value={layer.blur ?? 0}
|
|
836
846
|
showValue
|
|
837
|
-
valuePosition="
|
|
847
|
+
valuePosition="inline"
|
|
838
848
|
unit="px"
|
|
839
849
|
oninput={(v) => patch({ blur: v })}
|
|
840
850
|
/>
|
|
@@ -889,12 +899,13 @@
|
|
|
889
899
|
>
|
|
890
900
|
<Slider
|
|
891
901
|
size="sm"
|
|
902
|
+
variant="inset"
|
|
892
903
|
min={0}
|
|
893
904
|
max={200}
|
|
894
905
|
step={1}
|
|
895
906
|
value={layer.borderRadius ?? 0}
|
|
896
907
|
showValue
|
|
897
|
-
valuePosition="
|
|
908
|
+
valuePosition="inline"
|
|
898
909
|
unit="px"
|
|
899
910
|
oninput={(v) => patch({ borderRadius: v })}
|
|
900
911
|
/>
|
|
@@ -917,6 +928,18 @@
|
|
|
917
928
|
oninput={(e) => patch({ text: (e.currentTarget as HTMLTextAreaElement).value })}
|
|
918
929
|
/>
|
|
919
930
|
</PropertyField>
|
|
931
|
+
<PropertyField
|
|
932
|
+
label="Auto size"
|
|
933
|
+
modified={fieldModified('autoSize')}
|
|
934
|
+
onreset={() => resetField('autoSize')}
|
|
935
|
+
valueAlign="end"
|
|
936
|
+
>
|
|
937
|
+
<Toggle
|
|
938
|
+
checked={layer.autoSize ?? layer.kind === 'text'}
|
|
939
|
+
onchange={(v) => patch({ autoSize: v })}
|
|
940
|
+
size="sm"
|
|
941
|
+
/>
|
|
942
|
+
</PropertyField>
|
|
920
943
|
<PropertyField
|
|
921
944
|
label="Size"
|
|
922
945
|
exposed={exposedFlag('fontSize')}
|
|
@@ -1051,12 +1074,13 @@
|
|
|
1051
1074
|
>
|
|
1052
1075
|
<Slider
|
|
1053
1076
|
size="sm"
|
|
1077
|
+
variant="inset"
|
|
1054
1078
|
min={0}
|
|
1055
1079
|
max={200}
|
|
1056
1080
|
step={1}
|
|
1057
1081
|
value={layer.borderRadius ?? 0}
|
|
1058
1082
|
showValue
|
|
1059
|
-
valuePosition="
|
|
1083
|
+
valuePosition="inline"
|
|
1060
1084
|
unit="px"
|
|
1061
1085
|
oninput={(v) => patch({ borderRadius: v })}
|
|
1062
1086
|
/>
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
type MarqueeRect as MarqueeBox
|
|
17
17
|
} from '../../../utils/marqueeSelect.js';
|
|
18
18
|
import {
|
|
19
|
+
applyTextAutoSize,
|
|
19
20
|
createCanvasGuide,
|
|
20
21
|
pathPointsToDoc,
|
|
21
22
|
rebakePathLayer,
|
|
@@ -410,7 +411,12 @@
|
|
|
410
411
|
return;
|
|
411
412
|
}
|
|
412
413
|
|
|
413
|
-
const updated =
|
|
414
|
+
const updated = applyTextAutoSize(
|
|
415
|
+
source,
|
|
416
|
+
absToLocalUpdate(source, nextAbs),
|
|
417
|
+
prevAbs,
|
|
418
|
+
nextAbs
|
|
419
|
+
);
|
|
414
420
|
draftLayers = layers.map((l) => (l.id === updated.id ? updated : l));
|
|
415
421
|
// If somehow interact end already fired without draft, commit immediately.
|
|
416
422
|
if (interactCount === 0) commitDraft();
|
|
@@ -2,7 +2,7 @@ import type { StoryObj } from '@storybook/svelte';
|
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
4
|
component: import("svelte").Component<{
|
|
5
|
-
example?: "error" | "success" | "
|
|
5
|
+
example?: "error" | "success" | "inline" | "banner" | "card" | "stacked" | "minimal" | "consent";
|
|
6
6
|
title?: string;
|
|
7
7
|
description?: string;
|
|
8
8
|
variant?: import("./NewsletterSignup.svelte.ts").NewsletterVariant;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
interface PropertyFieldProps {
|
|
11
11
|
label: string;
|
|
12
|
-
/**
|
|
12
|
+
/** Fixed label column width (CSS). Use rem for UE-style alignment across the panel. */
|
|
13
13
|
labelWidth?: string;
|
|
14
14
|
disabled?: boolean;
|
|
15
15
|
class?: string;
|
|
@@ -24,47 +24,60 @@
|
|
|
24
24
|
modified?: boolean;
|
|
25
25
|
/** Reset this property to its default (UE details panel). */
|
|
26
26
|
onreset?: () => void;
|
|
27
|
+
/** Align control in the value column. Defaults to stretch/fill. */
|
|
28
|
+
valueAlign?: 'start' | 'end' | 'stretch';
|
|
29
|
+
/** Skip reset gutter — for dense 2-col rows (X/Y/W/H). */
|
|
30
|
+
compact?: boolean;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
const {
|
|
30
34
|
label,
|
|
31
|
-
labelWidth = '
|
|
35
|
+
labelWidth = '7rem',
|
|
32
36
|
disabled = false,
|
|
33
37
|
class: className = '',
|
|
34
38
|
children,
|
|
35
39
|
exposed = null,
|
|
36
40
|
onexpose,
|
|
37
41
|
modified = false,
|
|
38
|
-
onreset
|
|
42
|
+
onreset,
|
|
43
|
+
valueAlign = 'stretch',
|
|
44
|
+
compact = false
|
|
39
45
|
}: PropertyFieldProps = $props();
|
|
40
46
|
|
|
41
47
|
const canReset = $derived(!!onreset && modified && !disabled);
|
|
48
|
+
const columns = $derived(
|
|
49
|
+
compact ? `${labelWidth} minmax(0, 1fr)` : `1.25rem ${labelWidth} minmax(0, 1fr)`
|
|
50
|
+
);
|
|
42
51
|
</script>
|
|
43
52
|
|
|
44
53
|
<div
|
|
45
54
|
class={[
|
|
46
|
-
'grid min-h-7 items-center gap-2 px-1 py-0.5',
|
|
55
|
+
'grid min-h-7 items-center gap-x-2 px-1 py-0.5',
|
|
47
56
|
'rounded-sm hover:bg-surface-overlay/70',
|
|
48
57
|
disabled && 'pointer-events-none opacity-50',
|
|
49
58
|
className
|
|
50
59
|
]}
|
|
51
|
-
style:grid-template-columns={
|
|
60
|
+
style:grid-template-columns={columns}
|
|
52
61
|
>
|
|
62
|
+
{#if !compact}
|
|
63
|
+
<!-- Reset gutter: always reserved so every row shares the same label/value columns -->
|
|
64
|
+
<span class="flex h-7 w-5 items-center justify-center">
|
|
65
|
+
{#if canReset}
|
|
66
|
+
<Tooltip content="Reset to default" side="top">
|
|
67
|
+
<IconButton
|
|
68
|
+
label="Reset to default"
|
|
69
|
+
size="xs"
|
|
70
|
+
class="text-amber-500 hover:bg-amber-500/10 hover:text-amber-600 dark:text-amber-400 dark:hover:text-amber-300"
|
|
71
|
+
onclick={() => onreset?.()}
|
|
72
|
+
>
|
|
73
|
+
<RotateCcw class="h-3 w-3" strokeWidth={2.5} />
|
|
74
|
+
</IconButton>
|
|
75
|
+
</Tooltip>
|
|
76
|
+
{/if}
|
|
77
|
+
</span>
|
|
78
|
+
{/if}
|
|
79
|
+
|
|
53
80
|
<span class="flex min-w-0 items-center gap-0.5 truncate" title={label}>
|
|
54
|
-
{#if canReset}
|
|
55
|
-
<Tooltip content="Reset to default" side="top">
|
|
56
|
-
<IconButton
|
|
57
|
-
label="Reset to default"
|
|
58
|
-
size="xs"
|
|
59
|
-
class="text-amber-500 hover:bg-amber-500/10 hover:text-amber-600 dark:text-amber-400 dark:hover:text-amber-300"
|
|
60
|
-
onclick={() => onreset?.()}
|
|
61
|
-
>
|
|
62
|
-
<RotateCcw class="h-3 w-3" strokeWidth={2.5} />
|
|
63
|
-
</IconButton>
|
|
64
|
-
</Tooltip>
|
|
65
|
-
{:else if onreset}
|
|
66
|
-
<span class="inline-flex h-7 w-7 shrink-0" aria-hidden="true"></span>
|
|
67
|
-
{/if}
|
|
68
81
|
{#if exposed !== null}
|
|
69
82
|
<IconButton
|
|
70
83
|
label={exposed ? 'Hide from instances' : 'Expose on instances'}
|
|
@@ -88,7 +101,15 @@
|
|
|
88
101
|
{label}
|
|
89
102
|
</Text>
|
|
90
103
|
</span>
|
|
91
|
-
|
|
104
|
+
|
|
105
|
+
<div
|
|
106
|
+
class={[
|
|
107
|
+
'flex min-h-7 min-w-0 items-center',
|
|
108
|
+
valueAlign === 'end' && 'justify-end',
|
|
109
|
+
valueAlign === 'start' && 'justify-start',
|
|
110
|
+
valueAlign === 'stretch' && '[&>*]:min-w-0 [&>*]:w-full'
|
|
111
|
+
]}
|
|
112
|
+
>
|
|
92
113
|
{#if children}
|
|
93
114
|
{@render children()}
|
|
94
115
|
{/if}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
interface PropertyFieldProps {
|
|
3
3
|
label: string;
|
|
4
|
-
/**
|
|
4
|
+
/** Fixed label column width (CSS). Use rem for UE-style alignment across the panel. */
|
|
5
5
|
labelWidth?: string;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
class?: string;
|
|
@@ -16,6 +16,10 @@ interface PropertyFieldProps {
|
|
|
16
16
|
modified?: boolean;
|
|
17
17
|
/** Reset this property to its default (UE details panel). */
|
|
18
18
|
onreset?: () => void;
|
|
19
|
+
/** Align control in the value column. Defaults to stretch/fill. */
|
|
20
|
+
valueAlign?: 'start' | 'end' | 'stretch';
|
|
21
|
+
/** Skip reset gutter — for dense 2-col rows (X/Y/W/H). */
|
|
22
|
+
compact?: boolean;
|
|
19
23
|
}
|
|
20
24
|
declare const PropertyField: import("svelte").Component<PropertyFieldProps, {}, "">;
|
|
21
25
|
type PropertyField = ReturnType<typeof PropertyField>;
|
|
@@ -24,12 +24,13 @@
|
|
|
24
24
|
>
|
|
25
25
|
<Slider
|
|
26
26
|
size="sm"
|
|
27
|
+
variant="inset"
|
|
27
28
|
min={0}
|
|
28
29
|
max={1}
|
|
29
30
|
step={0.01}
|
|
30
31
|
bind:value={opacity}
|
|
31
32
|
showValue
|
|
32
|
-
valuePosition="
|
|
33
|
+
valuePosition="inline"
|
|
33
34
|
/>
|
|
34
35
|
</PropertyField>
|
|
35
36
|
<p class="px-1 pt-1 text-[10px] text-muted">
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
import {
|
|
21
21
|
CANVAS_PRESETS,
|
|
22
22
|
alignLayerRect,
|
|
23
|
+
applyTextAutoSize,
|
|
23
24
|
createCanvasGuide,
|
|
24
25
|
createCanvasLayer,
|
|
25
26
|
createPathFromDocPoints,
|
|
@@ -664,7 +665,7 @@
|
|
|
664
665
|
alignment: l.slot?.alignment,
|
|
665
666
|
order: l.slot?.order
|
|
666
667
|
};
|
|
667
|
-
return { ...l, rect, slot };
|
|
668
|
+
return applyTextAutoSize(l, { ...l, rect, slot }, l.rect, rect);
|
|
668
669
|
})
|
|
669
670
|
);
|
|
670
671
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -862,7 +862,7 @@ export { msToPx, pxToMs, pxPerMsFromZoom, snapMs, clampMs, formatTimecode, ticks
|
|
|
862
862
|
export type { TimeTick, TimeTickLevel } from './utils/mediaTime.js';
|
|
863
863
|
export type { MediaAsset, MediaAssetKind, MediaClip, MediaClipAlign, MediaClipRect, MediaClipResettableField, MediaClipRectAxis, MediaTransitionPlayback, MediaTrack, MediaTrackKind } from './utils/mediaTracks.js';
|
|
864
864
|
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
|
-
export { emptyCanvasDocument, createCanvasLayer, createCanvasGuide, createPathFromDocPoints, rebakePathLayer, pathPointsToDoc, reorderCanvasLayers, updateCanvasLayer, updateCanvasLayers, alignLayerRect, snapLayerRect, snapRectToGuides, migrateCanvasDocument, defaultSlotFromRect, rectFromSlot, ensureLayerSlot, canvasLayerFieldDefault, isCanvasFieldModified, resetCanvasField, CANVAS_PRESETS, presetIdForSize } from './utils/canvasDocument.js';
|
|
865
|
+
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
866
|
export type { CanvasDocument, CanvasLayer, CanvasLayerKind, CanvasLayerRect, CanvasPoint, CanvasObjectFit, CanvasTextAlign, CanvasResettableField, CanvasAlign, CanvasFontStyle, CanvasTextDecoration, CanvasGuide, CanvasGuideOrientation, CanvasAnchors, CanvasSlot, CanvasExposedProp, CanvasWidgetDefinition } from './utils/canvasDocument.js';
|
|
867
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
868
|
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';
|
package/dist/index.js
CHANGED
|
@@ -585,7 +585,7 @@ export { queryStringToGroup, groupToQueryString, groupToFilterItems, removeRuleF
|
|
|
585
585
|
export { emptyBlogDocument, createBlock, createComponentBlock, serializeBlogDocument, parseBlogDocument, registerBlogComponent, unregisterBlogComponent, getBlogComponent, listBlogComponents, clearBlogComponentRegistry, NATIVE_BLOCK_TYPES, defaultDataForType, blogWidthClass, blogAlignClass, blogAspectPadding } from './utils/blogDocument.js';
|
|
586
586
|
export { msToPx, pxToMs, pxPerMsFromZoom, snapMs, clampMs, formatTimecode, ticksForDuration, snapStepForZoom } from './utils/mediaTime.js';
|
|
587
587
|
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
|
-
export { emptyCanvasDocument, createCanvasLayer, createCanvasGuide, createPathFromDocPoints, rebakePathLayer, pathPointsToDoc, reorderCanvasLayers, updateCanvasLayer, updateCanvasLayers, alignLayerRect, snapLayerRect, snapRectToGuides, migrateCanvasDocument, defaultSlotFromRect, rectFromSlot, ensureLayerSlot, canvasLayerFieldDefault, isCanvasFieldModified, resetCanvasField, CANVAS_PRESETS, presetIdForSize } from './utils/canvasDocument.js';
|
|
588
|
+
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
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
590
|
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
591
|
export { createCanvasHistory, pushCanvasHistory, undoCanvasHistory, redoCanvasHistory, serializeCanvasDoc, parseCanvasDoc } from './utils/canvasHistory.js';
|
|
@@ -78,6 +78,11 @@ export interface CanvasLayer {
|
|
|
78
78
|
letterSpacing?: number;
|
|
79
79
|
lineHeight?: number;
|
|
80
80
|
textAlign?: CanvasTextAlign;
|
|
81
|
+
/**
|
|
82
|
+
* When true, resizing the text box scales `fontSize` with the box
|
|
83
|
+
* (geometric mean of width/height scale — Unreal/Canva-style).
|
|
84
|
+
*/
|
|
85
|
+
autoSize?: boolean;
|
|
81
86
|
color?: string;
|
|
82
87
|
/** Text box background */
|
|
83
88
|
textBackground?: string;
|
|
@@ -156,11 +161,16 @@ export declare function ensureLayerSlot(layer: CanvasLayer): CanvasLayer;
|
|
|
156
161
|
export declare function createCanvasGuide(orientation: CanvasGuideOrientation, position: number, partial?: Partial<Omit<CanvasGuide, 'id' | 'orientation' | 'position'>>): CanvasGuide;
|
|
157
162
|
export declare function createCanvasLayer(kind: CanvasLayerKind, partial?: Partial<Omit<CanvasLayer, 'id' | 'kind'>>): CanvasLayer;
|
|
158
163
|
/** Scalar fields that can reset to createCanvasLayer defaults (UE-style details). */
|
|
159
|
-
export type CanvasResettableField = 'opacity' | 'rotation' | 'visible' | 'locked' | 'flipX' | 'flipY' | 'blur' | 'shadowBlur' | 'shadowColor' | 'fill' | 'stroke' | 'strokeWidth' | 'fontSize' | 'fontWeight' | 'fontFamily' | 'fontStyle' | 'textDecoration' | 'letterSpacing' | 'lineHeight' | 'textAlign' | 'color' | 'textBackground' | 'objectFit' | 'borderRadius' | 'gap' | 'columns' | 'clipChildren' | 'text' | 'name';
|
|
164
|
+
export type CanvasResettableField = 'opacity' | 'rotation' | 'visible' | 'locked' | 'flipX' | 'flipY' | 'blur' | 'shadowBlur' | 'shadowColor' | 'fill' | 'stroke' | 'strokeWidth' | 'fontSize' | 'fontWeight' | 'fontFamily' | 'fontStyle' | 'textDecoration' | 'letterSpacing' | 'lineHeight' | 'textAlign' | 'autoSize' | 'color' | 'textBackground' | 'objectFit' | 'borderRadius' | 'gap' | 'columns' | 'clipChildren' | 'text' | 'name';
|
|
160
165
|
/** Default value for a layer field (same as createCanvasLayer would use). */
|
|
161
166
|
export declare function canvasLayerFieldDefault(kind: CanvasLayerKind, field: CanvasResettableField): unknown;
|
|
162
167
|
export declare function isCanvasFieldModified(layer: CanvasLayer, field: CanvasResettableField): boolean;
|
|
163
168
|
export declare function resetCanvasField(layer: CanvasLayer, field: CanvasResettableField): Partial<CanvasLayer>;
|
|
169
|
+
/**
|
|
170
|
+
* Scale fontSize with the box when `autoSize` is on (text / sticky).
|
|
171
|
+
* Uses geometric mean of width & height scale so both axes affect size.
|
|
172
|
+
*/
|
|
173
|
+
export declare function applyTextAutoSize(from: CanvasLayer, to: CanvasLayer, prev: Pick<CanvasLayerRect, 'w' | 'h'>, next: Pick<CanvasLayerRect, 'w' | 'h'>): CanvasLayer;
|
|
164
174
|
export declare function reorderCanvasLayers(layers: CanvasLayer[], orderedIds: string[]): CanvasLayer[];
|
|
165
175
|
export declare function updateCanvasLayer(doc: CanvasDocument, layerId: string, updater: (l: CanvasLayer) => CanvasLayer): CanvasDocument;
|
|
166
176
|
export declare function updateCanvasLayers(doc: CanvasDocument, ids: string[], updater: (l: CanvasLayer) => CanvasLayer): CanvasDocument;
|
|
@@ -158,6 +158,7 @@ export function createCanvasLayer(kind, partial) {
|
|
|
158
158
|
letterSpacing: partial?.letterSpacing,
|
|
159
159
|
lineHeight: partial?.lineHeight,
|
|
160
160
|
textAlign: partial?.textAlign ?? (kind === 'text' || kind === 'sticky' ? 'left' : undefined),
|
|
161
|
+
autoSize: partial?.autoSize ?? (kind === 'text' ? true : kind === 'sticky' ? false : undefined),
|
|
161
162
|
color: partial?.color ?? d.color ?? (kind === 'text' ? '#0f172a' : undefined),
|
|
162
163
|
textBackground: partial?.textBackground,
|
|
163
164
|
objectFit: partial?.objectFit ?? (kind === 'image' || kind === 'video' ? 'cover' : undefined),
|
|
@@ -231,6 +232,8 @@ export function canvasLayerFieldDefault(kind, field) {
|
|
|
231
232
|
case 'letterSpacing':
|
|
232
233
|
case 'lineHeight':
|
|
233
234
|
return undefined;
|
|
235
|
+
case 'autoSize':
|
|
236
|
+
return kind === 'text' ? true : kind === 'sticky' ? false : undefined;
|
|
234
237
|
case 'textAlign':
|
|
235
238
|
return kind === 'text' || kind === 'sticky' ? 'left' : undefined;
|
|
236
239
|
case 'color':
|
|
@@ -256,13 +259,40 @@ export function canvasLayerFieldDefault(kind, field) {
|
|
|
256
259
|
}
|
|
257
260
|
}
|
|
258
261
|
export function isCanvasFieldModified(layer, field) {
|
|
259
|
-
const cur = layer[field];
|
|
260
262
|
const def = canvasLayerFieldDefault(layer.kind, field);
|
|
263
|
+
const raw = layer[field];
|
|
264
|
+
// Missing autoSize on older docs → treat as the kind default (text=true).
|
|
265
|
+
const cur = field === 'autoSize' && raw === undefined ? def : raw;
|
|
261
266
|
return !canvasValuesEqual(cur, def);
|
|
262
267
|
}
|
|
263
268
|
export function resetCanvasField(layer, field) {
|
|
264
269
|
return { [field]: canvasLayerFieldDefault(layer.kind, field) };
|
|
265
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Scale fontSize with the box when `autoSize` is on (text / sticky).
|
|
273
|
+
* Uses geometric mean of width & height scale so both axes affect size.
|
|
274
|
+
*/
|
|
275
|
+
export function applyTextAutoSize(from, to, prev, next) {
|
|
276
|
+
if (from.kind !== 'text' && from.kind !== 'sticky')
|
|
277
|
+
return to;
|
|
278
|
+
const enabled = from.autoSize ?? from.kind === 'text';
|
|
279
|
+
if (!enabled)
|
|
280
|
+
return to;
|
|
281
|
+
const dw = Math.abs(next.w - prev.w);
|
|
282
|
+
const dh = Math.abs(next.h - prev.h);
|
|
283
|
+
if (dw < 0.5 && dh < 0.5)
|
|
284
|
+
return to;
|
|
285
|
+
const sx = next.w / Math.max(1, prev.w);
|
|
286
|
+
const sy = next.h / Math.max(1, prev.h);
|
|
287
|
+
const scale = Math.sqrt(sx * sy);
|
|
288
|
+
if (!Number.isFinite(scale) || Math.abs(scale - 1) < 0.001)
|
|
289
|
+
return to;
|
|
290
|
+
const base = from.fontSize ?? (from.kind === 'sticky' ? 20 : 32);
|
|
291
|
+
return {
|
|
292
|
+
...to,
|
|
293
|
+
fontSize: Math.max(8, Math.min(400, Math.round(base * scale)))
|
|
294
|
+
};
|
|
295
|
+
}
|
|
266
296
|
export function reorderCanvasLayers(layers, orderedIds) {
|
|
267
297
|
const map = new Map(layers.map((l) => [l.id, l]));
|
|
268
298
|
const next = [];
|