@r2digisolutions/components 0.19.16 → 0.19.18
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 +61 -29
- package/dist/components/molecules/ColorPicker/ColorPicker.svelte +5 -1
- package/dist/components/molecules/ColorPicker/ColorPicker.svelte.d.ts +1 -1
- 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 +51 -30
- package/dist/components/molecules/PropertyField/PropertyField.svelte.d.ts +5 -1
- package/dist/components/molecules/PropertyField/PropertyFieldStory.svelte +2 -1
- package/dist/components/molecules/Select/Select.svelte +2 -1
- package/dist/components/molecules/Select/Select.svelte.d.ts +1 -1
- package/dist/components/organisms/CanvasEditor/CanvasEditor.svelte +2 -1
- package/dist/components/organisms/Menubar/Menubar.svelte +271 -53
- package/dist/components/organisms/Menubar/Menubar.svelte.d.ts +4 -0
- package/dist/components/organisms/Menubar/MenubarStory.svelte +53 -21
- 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
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
separator?: boolean;
|
|
7
7
|
shortcut?: string;
|
|
8
8
|
destructive?: boolean;
|
|
9
|
+
/** Show a leading check column (macOS / Cursor style). */
|
|
10
|
+
checked?: boolean;
|
|
11
|
+
/** Nested flyout submenu. */
|
|
12
|
+
children?: MenubarSubItem[];
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
export interface MenubarItem {
|
|
@@ -27,9 +31,11 @@
|
|
|
27
31
|
}: MenubarProps = $props();
|
|
28
32
|
|
|
29
33
|
let openId = $state<string | null>(null);
|
|
34
|
+
let flyoutId = $state<string | null>(null);
|
|
30
35
|
let menubarEl = $state<HTMLElement | null>(null);
|
|
31
36
|
let menuEl = $state<HTMLDivElement | null>(null);
|
|
32
37
|
let menuStyle = $state('');
|
|
38
|
+
let highlightedId = $state<string | null>(null);
|
|
33
39
|
|
|
34
40
|
function menuDomId(id: string) {
|
|
35
41
|
return `menubar-menu-${id}`;
|
|
@@ -44,6 +50,8 @@
|
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
52
|
openId = null;
|
|
53
|
+
flyoutId = null;
|
|
54
|
+
highlightedId = null;
|
|
47
55
|
menuStyle = '';
|
|
48
56
|
}
|
|
49
57
|
|
|
@@ -58,20 +66,22 @@
|
|
|
58
66
|
const spaceBelow = window.innerHeight - rect.bottom - pad;
|
|
59
67
|
const openUp = spaceBelow < menuH && rect.top > spaceBelow;
|
|
60
68
|
let left = rect.left;
|
|
61
|
-
const menuW = Math.max(
|
|
69
|
+
const menuW = Math.max(220, menuEl.offsetWidth || 220);
|
|
62
70
|
if (left + menuW > window.innerWidth - pad) {
|
|
63
71
|
left = Math.max(pad, window.innerWidth - menuW - pad);
|
|
64
72
|
}
|
|
65
73
|
// inset:auto must come BEFORE top/left — shorthand would clear them
|
|
66
74
|
if (openUp) {
|
|
67
|
-
menuStyle = `position:fixed;margin:0;inset:auto;bottom:${Math.round(window.innerHeight - rect.top +
|
|
75
|
+
menuStyle = `position:fixed;margin:0;inset:auto;bottom:${Math.round(window.innerHeight - rect.top + 2)}px;left:${Math.round(left)}px;`;
|
|
68
76
|
} else {
|
|
69
|
-
menuStyle = `position:fixed;margin:0;inset:auto;top:${Math.round(rect.bottom +
|
|
77
|
+
menuStyle = `position:fixed;margin:0;inset:auto;top:${Math.round(rect.bottom + 2)}px;left:${Math.round(left)}px;`;
|
|
70
78
|
}
|
|
71
79
|
}
|
|
72
80
|
|
|
73
81
|
function open(id: string) {
|
|
74
82
|
openId = id;
|
|
83
|
+
flyoutId = null;
|
|
84
|
+
highlightedId = null;
|
|
75
85
|
queueMicrotask(() => {
|
|
76
86
|
if (!menuEl) return;
|
|
77
87
|
try {
|
|
@@ -91,6 +101,7 @@
|
|
|
91
101
|
|
|
92
102
|
function select(subItem: MenubarSubItem, parentId: string) {
|
|
93
103
|
if (subItem.disabled || subItem.separator) return;
|
|
104
|
+
if (subItem.children?.length) return;
|
|
94
105
|
onselect?.(subItem.id, parentId);
|
|
95
106
|
close();
|
|
96
107
|
}
|
|
@@ -118,10 +129,16 @@
|
|
|
118
129
|
function onToggle(e: ToggleEvent) {
|
|
119
130
|
if (e.newState === 'closed') {
|
|
120
131
|
openId = null;
|
|
132
|
+
flyoutId = null;
|
|
133
|
+
highlightedId = null;
|
|
121
134
|
menuStyle = '';
|
|
122
135
|
}
|
|
123
136
|
}
|
|
124
137
|
|
|
138
|
+
function levelHasChecks(list: MenubarSubItem[]) {
|
|
139
|
+
return list.some((i) => !i.separator && i.checked !== undefined);
|
|
140
|
+
}
|
|
141
|
+
|
|
125
142
|
$effect(() => {
|
|
126
143
|
if (!openId) return;
|
|
127
144
|
const onWin = () => {
|
|
@@ -138,7 +155,87 @@
|
|
|
138
155
|
const openItem = $derived(items.find((i) => i.id === openId) ?? null);
|
|
139
156
|
</script>
|
|
140
157
|
|
|
141
|
-
|
|
158
|
+
{#snippet menuRows(list: MenubarSubItem[], parentId: string)}
|
|
159
|
+
{@const checks = levelHasChecks(list)}
|
|
160
|
+
{#each list as sub (sub.id)}
|
|
161
|
+
{#if sub.separator}
|
|
162
|
+
<div class="menubar-sep" role="separator"></div>
|
|
163
|
+
{:else}
|
|
164
|
+
{@const hasChildren = Boolean(sub.children?.length)}
|
|
165
|
+
{@const isHot = highlightedId === sub.id || flyoutId === sub.id}
|
|
166
|
+
<div
|
|
167
|
+
class="relative"
|
|
168
|
+
role="presentation"
|
|
169
|
+
onmouseenter={() => {
|
|
170
|
+
if (sub.disabled) return;
|
|
171
|
+
highlightedId = sub.id;
|
|
172
|
+
flyoutId = hasChildren ? sub.id : null;
|
|
173
|
+
}}
|
|
174
|
+
>
|
|
175
|
+
<button
|
|
176
|
+
type="button"
|
|
177
|
+
role={sub.checked !== undefined ? 'menuitemcheckbox' : 'menuitem'}
|
|
178
|
+
disabled={sub.disabled}
|
|
179
|
+
aria-disabled={sub.disabled || undefined}
|
|
180
|
+
aria-checked={sub.checked !== undefined ? sub.checked : undefined}
|
|
181
|
+
aria-haspopup={hasChildren ? 'menu' : undefined}
|
|
182
|
+
aria-expanded={hasChildren ? flyoutId === sub.id : undefined}
|
|
183
|
+
onclick={() => select(sub, parentId)}
|
|
184
|
+
class={[
|
|
185
|
+
'menubar-item',
|
|
186
|
+
isHot && !sub.disabled && 'menubar-item-hot',
|
|
187
|
+
sub.disabled && 'menubar-item-disabled',
|
|
188
|
+
!sub.disabled && sub.destructive && 'menubar-item-danger',
|
|
189
|
+
!sub.disabled && !sub.destructive && 'menubar-item-default'
|
|
190
|
+
]}
|
|
191
|
+
>
|
|
192
|
+
{#if checks}
|
|
193
|
+
<span class="menubar-check" aria-hidden="true">
|
|
194
|
+
{#if sub.checked}
|
|
195
|
+
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.75">
|
|
196
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" />
|
|
197
|
+
</svg>
|
|
198
|
+
{/if}
|
|
199
|
+
</span>
|
|
200
|
+
{/if}
|
|
201
|
+
<span class="menubar-label">{sub.label}</span>
|
|
202
|
+
{#if sub.shortcut && !hasChildren}
|
|
203
|
+
<span class="menubar-shortcut">{sub.shortcut}</span>
|
|
204
|
+
{:else if hasChildren}
|
|
205
|
+
<svg
|
|
206
|
+
class="menubar-chevron"
|
|
207
|
+
width="12"
|
|
208
|
+
height="12"
|
|
209
|
+
viewBox="0 0 24 24"
|
|
210
|
+
fill="none"
|
|
211
|
+
stroke="currentColor"
|
|
212
|
+
stroke-width="2.25"
|
|
213
|
+
aria-hidden="true"
|
|
214
|
+
>
|
|
215
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7" />
|
|
216
|
+
</svg>
|
|
217
|
+
{/if}
|
|
218
|
+
</button>
|
|
219
|
+
|
|
220
|
+
{#if hasChildren && flyoutId === sub.id && sub.children?.length}
|
|
221
|
+
<div
|
|
222
|
+
class="menubar-panel menubar-flyout"
|
|
223
|
+
role="menu"
|
|
224
|
+
tabindex="-1"
|
|
225
|
+
onmouseenter={() => {
|
|
226
|
+
flyoutId = sub.id;
|
|
227
|
+
highlightedId = sub.id;
|
|
228
|
+
}}
|
|
229
|
+
>
|
|
230
|
+
{@render menuRows(sub.children, parentId)}
|
|
231
|
+
</div>
|
|
232
|
+
{/if}
|
|
233
|
+
</div>
|
|
234
|
+
{/if}
|
|
235
|
+
{/each}
|
|
236
|
+
{/snippet}
|
|
237
|
+
|
|
238
|
+
<div bind:this={menubarEl} class={['menubar-bar flex items-center gap-px', className]} role="menubar">
|
|
142
239
|
{#each items as item (item.id)}
|
|
143
240
|
{@const isOpen = openId === item.id}
|
|
144
241
|
<button
|
|
@@ -154,29 +251,14 @@
|
|
|
154
251
|
}}
|
|
155
252
|
onkeydown={(e) => handleMenuKeydown(e, item)}
|
|
156
253
|
class={[
|
|
157
|
-
'
|
|
158
|
-
'
|
|
159
|
-
isOpen
|
|
160
|
-
? 'bg-surface-overlay text-primary'
|
|
161
|
-
: 'text-secondary hover:bg-surface-overlay hover:text-primary'
|
|
254
|
+
'menubar-trigger',
|
|
255
|
+
isOpen ? 'menubar-trigger-open' : 'menubar-trigger-idle'
|
|
162
256
|
]}
|
|
163
257
|
>
|
|
164
258
|
{item.label}
|
|
165
|
-
{#if item.items?.length}
|
|
166
|
-
<svg
|
|
167
|
-
class={['h-3 w-3 opacity-60 transition-transform duration-150', isOpen && 'rotate-180']}
|
|
168
|
-
viewBox="0 0 24 24"
|
|
169
|
-
fill="none"
|
|
170
|
-
stroke="currentColor"
|
|
171
|
-
stroke-width="2.5"
|
|
172
|
-
aria-hidden="true"
|
|
173
|
-
>
|
|
174
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7" />
|
|
175
|
-
</svg>
|
|
176
|
-
{/if}
|
|
177
259
|
</button>
|
|
178
260
|
{/each}
|
|
179
|
-
</
|
|
261
|
+
</div>
|
|
180
262
|
|
|
181
263
|
<!-- Single shared menu in the top layer (native Popover) -->
|
|
182
264
|
<div
|
|
@@ -184,41 +266,13 @@
|
|
|
184
266
|
id={openId ? menuDomId(openId) : 'menubar-menu'}
|
|
185
267
|
popover="auto"
|
|
186
268
|
role="menu"
|
|
269
|
+
tabindex="-1"
|
|
187
270
|
ontoggle={onToggle}
|
|
188
271
|
style={menuStyle}
|
|
189
|
-
class="menubar-popover m-0
|
|
272
|
+
class="menubar-popover menubar-panel m-0 outline-none"
|
|
190
273
|
>
|
|
191
274
|
{#if openItem?.items?.length}
|
|
192
|
-
{
|
|
193
|
-
{#if sub.separator}
|
|
194
|
-
<div class="my-1 h-px bg-border" role="separator"></div>
|
|
195
|
-
{:else}
|
|
196
|
-
<button
|
|
197
|
-
type="button"
|
|
198
|
-
role="menuitem"
|
|
199
|
-
disabled={sub.disabled}
|
|
200
|
-
onclick={() => select(sub, openItem.id)}
|
|
201
|
-
class={[
|
|
202
|
-
'flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm transition-colors duration-75 outline-none',
|
|
203
|
-
sub.disabled && 'cursor-not-allowed opacity-40',
|
|
204
|
-
!sub.disabled &&
|
|
205
|
-
sub.destructive &&
|
|
206
|
-
'text-red-500 hover:bg-red-50 dark:hover:bg-red-950/40',
|
|
207
|
-
!sub.disabled && !sub.destructive && 'text-primary hover:bg-surface-overlay',
|
|
208
|
-
'focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-brand-500/30'
|
|
209
|
-
]}
|
|
210
|
-
>
|
|
211
|
-
<span class="min-w-0 flex-1 truncate">{sub.label}</span>
|
|
212
|
-
{#if sub.shortcut}
|
|
213
|
-
<kbd
|
|
214
|
-
class="ml-auto shrink-0 rounded bg-surface-overlay px-1.5 py-0.5 font-mono text-[10px] text-muted"
|
|
215
|
-
>
|
|
216
|
-
{sub.shortcut}
|
|
217
|
-
</kbd>
|
|
218
|
-
{/if}
|
|
219
|
-
</button>
|
|
220
|
-
{/if}
|
|
221
|
-
{/each}
|
|
275
|
+
{@render menuRows(openItem.items, openItem.id)}
|
|
222
276
|
{/if}
|
|
223
277
|
</div>
|
|
224
278
|
|
|
@@ -227,4 +281,168 @@
|
|
|
227
281
|
.menubar-popover:popover-open {
|
|
228
282
|
inset: unset;
|
|
229
283
|
}
|
|
284
|
+
|
|
285
|
+
.menubar-trigger {
|
|
286
|
+
display: flex;
|
|
287
|
+
align-items: center;
|
|
288
|
+
height: 1.5rem;
|
|
289
|
+
padding: 0 0.5rem;
|
|
290
|
+
border-radius: 0.25rem;
|
|
291
|
+
font-size: 0.8125rem;
|
|
292
|
+
line-height: 1;
|
|
293
|
+
font-weight: 400;
|
|
294
|
+
letter-spacing: -0.01em;
|
|
295
|
+
outline: none;
|
|
296
|
+
transition: background-color 80ms ease, color 80ms ease;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.menubar-trigger:focus-visible {
|
|
300
|
+
box-shadow: 0 0 0 2px color-mix(in oklab, var(--color-brand-500, #3b82f6) 35%, transparent);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.menubar-trigger-idle {
|
|
304
|
+
color: var(--text-secondary, var(--color-text-secondary, #737373));
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.menubar-trigger-idle:hover {
|
|
308
|
+
/* text-primary is light in dark mode → soft white wash (never surface-overlay #171717) */
|
|
309
|
+
background: color-mix(in oklab, var(--text-primary, var(--color-text-primary, CanvasText)) 14%, transparent);
|
|
310
|
+
color: var(--text-primary, var(--color-text-primary, CanvasText));
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.menubar-trigger-open {
|
|
314
|
+
background: color-mix(in oklab, var(--color-brand-500, #3b82f6) 22%, transparent);
|
|
315
|
+
color: var(--text-primary, var(--color-text-primary, CanvasText));
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
:global(.dark) .menubar-trigger-idle:hover,
|
|
319
|
+
:global(html.dark) .menubar-trigger-idle:hover,
|
|
320
|
+
:global(:root.dark) .menubar-trigger-idle:hover {
|
|
321
|
+
background: color-mix(in oklab, #fff 14%, transparent);
|
|
322
|
+
color: #fff;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
:global(.dark) .menubar-trigger-open,
|
|
326
|
+
:global(html.dark) .menubar-trigger-open,
|
|
327
|
+
:global(:root.dark) .menubar-trigger-open {
|
|
328
|
+
background: color-mix(in oklab, var(--color-brand-500, #3b82f6) 32%, transparent);
|
|
329
|
+
color: #fff;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
:global(.menubar-panel) {
|
|
333
|
+
min-width: 13.75rem;
|
|
334
|
+
padding: 0.25rem;
|
|
335
|
+
border-radius: 0.5rem;
|
|
336
|
+
border: 1px solid color-mix(in oklab, var(--color-border, #e5e5e5) 90%, transparent);
|
|
337
|
+
background: color-mix(in oklab, var(--color-surface-elevated, #fff) 88%, transparent);
|
|
338
|
+
backdrop-filter: blur(20px) saturate(1.4);
|
|
339
|
+
-webkit-backdrop-filter: blur(20px) saturate(1.4);
|
|
340
|
+
box-shadow:
|
|
341
|
+
0 0 0 0.5px color-mix(in oklab, #000 8%, transparent),
|
|
342
|
+
0 10px 40px -8px color-mix(in oklab, #000 35%, transparent),
|
|
343
|
+
0 4px 12px -4px color-mix(in oklab, #000 18%, transparent);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
:global(.dark) :global(.menubar-panel),
|
|
347
|
+
:global([data-theme='dark']) :global(.menubar-panel) {
|
|
348
|
+
border-color: color-mix(in oklab, #fff 12%, transparent);
|
|
349
|
+
background: color-mix(in oklab, #1c1c1e 82%, transparent);
|
|
350
|
+
box-shadow:
|
|
351
|
+
0 0 0 0.5px color-mix(in oklab, #fff 8%, transparent),
|
|
352
|
+
0 16px 48px -12px color-mix(in oklab, #000 65%, transparent),
|
|
353
|
+
0 4px 16px -4px color-mix(in oklab, #000 40%, transparent);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
:global(.menubar-flyout) {
|
|
357
|
+
position: absolute;
|
|
358
|
+
left: calc(100% - 2px);
|
|
359
|
+
top: -0.25rem;
|
|
360
|
+
z-index: 2;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
:global(.menubar-sep) {
|
|
364
|
+
height: 1px;
|
|
365
|
+
margin: 0.25rem 0.5rem;
|
|
366
|
+
background: color-mix(in oklab, var(--color-border, #e5e5e5) 85%, transparent);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
:global(.dark) :global(.menubar-sep) {
|
|
370
|
+
background: color-mix(in oklab, #fff 12%, transparent);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
:global(.menubar-item) {
|
|
374
|
+
display: flex;
|
|
375
|
+
width: 100%;
|
|
376
|
+
align-items: center;
|
|
377
|
+
gap: 0.5rem;
|
|
378
|
+
min-height: 1.375rem;
|
|
379
|
+
padding: 0.2rem 0.5rem;
|
|
380
|
+
border-radius: 0.25rem;
|
|
381
|
+
font-size: 0.8125rem;
|
|
382
|
+
line-height: 1.2;
|
|
383
|
+
letter-spacing: -0.01em;
|
|
384
|
+
text-align: left;
|
|
385
|
+
outline: none;
|
|
386
|
+
transition: background-color 60ms ease, color 60ms ease;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
:global(.menubar-item-default) {
|
|
390
|
+
color: var(--text-primary, var(--color-text-primary, #171717));
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
:global(.dark) :global(.menubar-item-default) {
|
|
394
|
+
color: #f5f5f5;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
:global(.menubar-item-hot) {
|
|
398
|
+
background: var(--color-brand-500, #007aff) !important;
|
|
399
|
+
color: #fff !important;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
:global(.menubar-item-hot) :global(.menubar-shortcut),
|
|
403
|
+
:global(.menubar-item-hot) :global(.menubar-chevron),
|
|
404
|
+
:global(.menubar-item-hot) :global(.menubar-check) {
|
|
405
|
+
color: color-mix(in oklab, #fff 78%, transparent) !important;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
:global(.menubar-item-danger):not(:global(.menubar-item-hot)) {
|
|
409
|
+
color: #ef4444;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
:global(.menubar-item-disabled) {
|
|
413
|
+
cursor: not-allowed;
|
|
414
|
+
opacity: 0.38;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
:global(.menubar-check) {
|
|
418
|
+
display: flex;
|
|
419
|
+
width: 0.875rem;
|
|
420
|
+
height: 0.875rem;
|
|
421
|
+
flex-shrink: 0;
|
|
422
|
+
align-items: center;
|
|
423
|
+
justify-content: center;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
:global(.menubar-label) {
|
|
427
|
+
min-width: 0;
|
|
428
|
+
flex: 1;
|
|
429
|
+
overflow: hidden;
|
|
430
|
+
text-overflow: ellipsis;
|
|
431
|
+
white-space: nowrap;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
:global(.menubar-shortcut) {
|
|
435
|
+
margin-left: 1.5rem;
|
|
436
|
+
flex-shrink: 0;
|
|
437
|
+
font-size: 0.75rem;
|
|
438
|
+
letter-spacing: 0.02em;
|
|
439
|
+
color: var(--color-muted, #a3a3a3);
|
|
440
|
+
font-variant-numeric: tabular-nums;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
:global(.menubar-chevron) {
|
|
444
|
+
margin-left: 0.75rem;
|
|
445
|
+
flex-shrink: 0;
|
|
446
|
+
opacity: 0.7;
|
|
447
|
+
}
|
|
230
448
|
</style>
|
|
@@ -5,6 +5,10 @@ export interface MenubarSubItem {
|
|
|
5
5
|
separator?: boolean;
|
|
6
6
|
shortcut?: string;
|
|
7
7
|
destructive?: boolean;
|
|
8
|
+
/** Show a leading check column (macOS / Cursor style). */
|
|
9
|
+
checked?: boolean;
|
|
10
|
+
/** Nested flyout submenu. */
|
|
11
|
+
children?: MenubarSubItem[];
|
|
8
12
|
}
|
|
9
13
|
export interface MenubarItem {
|
|
10
14
|
id: string;
|
|
@@ -6,13 +6,40 @@
|
|
|
6
6
|
id: 'file',
|
|
7
7
|
label: 'File',
|
|
8
8
|
items: [
|
|
9
|
-
{ id: 'new', label: 'New File', shortcut: '⌘N' },
|
|
10
|
-
{ id: '
|
|
11
|
-
{
|
|
12
|
-
|
|
9
|
+
{ id: 'new-file', label: 'New Text File', shortcut: '⌘N' },
|
|
10
|
+
{ id: 'new-window', label: 'New Window', shortcut: '⇧⌘N' },
|
|
11
|
+
{
|
|
12
|
+
id: 'new-profile',
|
|
13
|
+
label: 'New Window with Profile',
|
|
14
|
+
children: [
|
|
15
|
+
{ id: 'profile-default', label: 'Default' },
|
|
16
|
+
{ id: 'profile-work', label: 'Work' },
|
|
17
|
+
{ id: 'sep-profiles', label: '', separator: true },
|
|
18
|
+
{ id: 'profile-manage', label: 'Manage Profiles…' }
|
|
19
|
+
]
|
|
20
|
+
},
|
|
13
21
|
{ id: 'sep1', label: '', separator: true },
|
|
14
|
-
{ id: '
|
|
15
|
-
{ id: '
|
|
22
|
+
{ id: 'open', label: 'Open…', shortcut: '⌘O' },
|
|
23
|
+
{ id: 'open-folder', label: 'Open Folder…', shortcut: '⌘K ⌘O' },
|
|
24
|
+
{
|
|
25
|
+
id: 'open-recent',
|
|
26
|
+
label: 'Open Recent',
|
|
27
|
+
children: [
|
|
28
|
+
{ id: 'recent-1', label: 'crm' },
|
|
29
|
+
{ id: 'recent-2', label: 'components' },
|
|
30
|
+
{ id: 'sep-recent', label: '', separator: true },
|
|
31
|
+
{ id: 'recent-clear', label: 'Clear Recently Opened' }
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
{ id: 'sep2', label: '', separator: true },
|
|
35
|
+
{ id: 'save', label: 'Save', shortcut: '⌘S' },
|
|
36
|
+
{ id: 'save-as', label: 'Save As…', shortcut: '⇧⌘S' },
|
|
37
|
+
{ id: 'save-all', label: 'Save All', shortcut: '⌥⌘S', disabled: true },
|
|
38
|
+
{ id: 'sep3', label: '', separator: true },
|
|
39
|
+
{ id: 'auto-save', label: 'Auto Save', checked: true },
|
|
40
|
+
{ id: 'sep4', label: '', separator: true },
|
|
41
|
+
{ id: 'close-editor', label: 'Close Editor', shortcut: '⌘W' },
|
|
42
|
+
{ id: 'close-window', label: 'Close Window', shortcut: '⇧⌘W', destructive: true }
|
|
16
43
|
]
|
|
17
44
|
},
|
|
18
45
|
{
|
|
@@ -20,26 +47,25 @@
|
|
|
20
47
|
label: 'Edit',
|
|
21
48
|
items: [
|
|
22
49
|
{ id: 'undo', label: 'Undo', shortcut: '⌘Z' },
|
|
23
|
-
{ id: 'redo', label: 'Redo', shortcut: '
|
|
24
|
-
{ id: '
|
|
50
|
+
{ id: 'redo', label: 'Redo', shortcut: '⇧⌘Z' },
|
|
51
|
+
{ id: 'sep-e1', label: '', separator: true },
|
|
25
52
|
{ id: 'cut', label: 'Cut', shortcut: '⌘X' },
|
|
26
53
|
{ id: 'copy', label: 'Copy', shortcut: '⌘C' },
|
|
27
54
|
{ id: 'paste', label: 'Paste', shortcut: '⌘V' },
|
|
28
|
-
{ id: '
|
|
29
|
-
{ id: '
|
|
55
|
+
{ id: 'sep-e2', label: '', separator: true },
|
|
56
|
+
{ id: 'select-all', label: 'Select All', shortcut: '⌘A' }
|
|
30
57
|
]
|
|
31
58
|
},
|
|
32
59
|
{
|
|
33
60
|
id: 'view',
|
|
34
61
|
label: 'View',
|
|
35
62
|
items: [
|
|
36
|
-
{ id: 'sidebar', label: 'Toggle Sidebar', shortcut: '⌘B' },
|
|
37
|
-
{ id: '
|
|
38
|
-
{ id: '
|
|
39
|
-
{ id: '
|
|
40
|
-
{ id: '
|
|
41
|
-
{ id: '
|
|
42
|
-
{ id: 'zoomreset', label: 'Reset Zoom', shortcut: '⌘0' }
|
|
63
|
+
{ id: 'sidebar', label: 'Toggle Sidebar', shortcut: '⌘B', checked: true },
|
|
64
|
+
{ id: 'inspector', label: 'Toggle Inspector', shortcut: '⌘I', checked: true },
|
|
65
|
+
{ id: 'sep-v1', label: '', separator: true },
|
|
66
|
+
{ id: 'zoom-in', label: 'Zoom In', shortcut: '⌘+' },
|
|
67
|
+
{ id: 'zoom-out', label: 'Zoom Out', shortcut: '⌘-' },
|
|
68
|
+
{ id: 'zoom-reset', label: 'Reset Zoom', shortcut: '⌘0' }
|
|
43
69
|
]
|
|
44
70
|
},
|
|
45
71
|
{
|
|
@@ -48,7 +74,7 @@
|
|
|
48
74
|
items: [
|
|
49
75
|
{ id: 'docs', label: 'Documentation' },
|
|
50
76
|
{ id: 'shortcuts', label: 'Keyboard Shortcuts', shortcut: '⌘K ⌘S' },
|
|
51
|
-
{ id: '
|
|
77
|
+
{ id: 'sep-h', label: '', separator: true },
|
|
52
78
|
{ id: 'about', label: 'About' }
|
|
53
79
|
]
|
|
54
80
|
}
|
|
@@ -57,11 +83,17 @@
|
|
|
57
83
|
let lastAction = $state('');
|
|
58
84
|
</script>
|
|
59
85
|
|
|
60
|
-
<div class="space-y-4">
|
|
61
|
-
<
|
|
86
|
+
<div class="space-y-4 rounded-xl border border-border bg-surface p-4 dark:bg-neutral-950">
|
|
87
|
+
<div
|
|
88
|
+
class="flex items-center gap-2 rounded-lg border border-border bg-surface-elevated/90 px-2 py-1 backdrop-blur"
|
|
89
|
+
>
|
|
90
|
+
<span class="px-1 text-xs font-semibold tracking-tight text-primary">App</span>
|
|
91
|
+
<div class="h-3.5 w-px bg-border" aria-hidden="true"></div>
|
|
92
|
+
<Menubar {items} class="min-w-0 flex-1" onselect={(id, parent) => (lastAction = `${parent} › ${id}`)} />
|
|
93
|
+
</div>
|
|
62
94
|
{#if lastAction}
|
|
63
95
|
<p class="text-xs text-muted">
|
|
64
|
-
Acción: <span class="text-primary
|
|
96
|
+
Acción: <span class="font-medium text-primary">{lastAction}</span>
|
|
65
97
|
</p>
|
|
66
98
|
{/if}
|
|
67
99
|
</div>
|
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 = [];
|