@widgetic/editor 4.1.16 → 4.1.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/PreviewChromeControls.svelte +2 -2
- package/dist/components/WidgetPreview.svelte +2 -2
- package/dist/components/editors/EmbedEditor.svelte +2 -1
- package/dist/components/editors/PropsEditor.svelte +127 -28
- package/dist/components/ic/AngleInputController.svelte +10 -6
- package/dist/components/ic/BrowserInputController.svelte +25 -112
- package/dist/components/ic/ColorPickerInputController.svelte +120 -48
- package/dist/components/ic/DatePickerInputController.svelte +18 -10
- package/dist/components/ic/DropdownInputController.svelte +2 -12
- package/dist/components/ic/FixedPositionInputController.svelte +1 -1
- package/dist/components/ic/FontInputController.svelte +42 -55
- package/dist/components/ic/InputControllerHeader.svelte +1 -1
- package/dist/components/ic/KnowledgeDocumentsInputController.svelte +7 -7
- package/dist/components/ic/NumberControls.svelte +92 -43
- package/dist/components/ic/NumberControls.svelte.d.ts +5 -1
- package/dist/components/ic/PositionInputController.svelte +24 -15
- package/dist/components/ic/RangeCalendarInputController.svelte +38 -18
- package/dist/components/ic/RoundedCornersInputController.svelte +2 -2
- package/dist/components/ic/SliderInputController.svelte +11 -4
- package/dist/components/ic/TextAreaInputController.svelte +40 -27
- package/dist/components/ic/TextAreaPreviewInputController.svelte +9 -8
- package/dist/components/ic/TextInputController.svelte +15 -2
- package/dist/components/ic/TimeInputController.svelte +1 -1
- package/dist/components/ic/VectorInputController.svelte +155 -27
- package/dist/components/ic/numberControlsSteps.d.ts +17 -0
- package/dist/components/ic/numberControlsSteps.js +23 -0
- package/dist/components/ic/shared/DropdownChevron.svelte +23 -0
- package/dist/components/ic/shared/DropdownChevron.svelte.d.ts +9 -0
- package/dist/components/ic/shared/EditorFileBrowserOverlay.svelte +132 -0
- package/dist/components/ic/shared/EditorFileBrowserOverlay.svelte.d.ts +27 -0
- package/dist/components/ic/shared/ItemGrid.svelte +2 -2
- package/dist/components/ic/shared/RecentItemsSection.svelte +6 -6
- package/dist/components/ic/shared/editableFieldClasses.d.ts +15 -0
- package/dist/components/ic/shared/editableFieldClasses.js +15 -0
- package/dist/components/ic/shared/index.d.ts +1 -0
- package/dist/components/ic/shared/index.js +1 -0
- package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte +41 -9
- package/dist/i18n/language.d.ts +260 -2
- package/dist/utils/angleMath.d.ts +2 -0
- package/dist/utils/angleMath.js +6 -0
- package/package.json +4 -4
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
onclick={() => onDevice(false)}
|
|
34
34
|
onpointerdown={(event) => event.stopPropagation()}
|
|
35
35
|
>
|
|
36
|
-
<IconDeviceDesktop class="size-4 stroke-
|
|
36
|
+
<IconDeviceDesktop class="size-4 stroke-2" aria-hidden="true" />
|
|
37
37
|
</button>
|
|
38
38
|
<button
|
|
39
39
|
type="button"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
onclick={() => onDevice(true)}
|
|
44
44
|
onpointerdown={(event) => event.stopPropagation()}
|
|
45
45
|
>
|
|
46
|
-
<IconDeviceMobile class="size-4 stroke-
|
|
46
|
+
<IconDeviceMobile class="size-4 stroke-2" aria-hidden="true" />
|
|
47
47
|
</button>
|
|
48
48
|
</div>
|
|
49
49
|
{/if}
|
|
@@ -912,7 +912,7 @@
|
|
|
912
912
|
<div class="widget-preview-unpublished-ct flex items-center justify-center h-full w-full">
|
|
913
913
|
<div class="widget-preview-unpublished-content-ct flex flex-col items-center gap-3 text-center px-6">
|
|
914
914
|
<div class="size-12 rounded-xl bg-brand-subtle flex items-center justify-center">
|
|
915
|
-
<IconAlertTriangle class="size-5 stroke-[1.
|
|
915
|
+
<IconAlertTriangle class="size-5 stroke-[1.6] text-foreground" aria-hidden="true" />
|
|
916
916
|
</div>
|
|
917
917
|
<div>
|
|
918
918
|
<p class="text-body-medium text-foreground">{widget.name || $t('editor.preview.widgetName')}</p>
|
|
@@ -962,7 +962,7 @@
|
|
|
962
962
|
onpointerdown={startPreviewDrag}
|
|
963
963
|
>
|
|
964
964
|
{#if enableDrag}
|
|
965
|
-
<span class="preview-chrome-drag-grip shrink-0 text-muted-foreground leading-none" title={$t('editor.preview.dragHandle')} aria-hidden="true"><IconGripVertical class="size-4 stroke-
|
|
965
|
+
<span class="preview-chrome-drag-grip shrink-0 text-muted-foreground leading-none" title={$t('editor.preview.dragHandle')} aria-hidden="true"><IconGripVertical class="size-4 stroke-2" /></span>
|
|
966
966
|
{/if}
|
|
967
967
|
<span class="preview-chrome-title text-label text-muted-foreground shrink-0">{$t('editor.preview.title')}</span>
|
|
968
968
|
<PreviewChromeControls
|
|
@@ -112,8 +112,9 @@
|
|
|
112
112
|
on:propertyChange
|
|
113
113
|
>
|
|
114
114
|
{#snippet headerContent()}
|
|
115
|
+
<!-- The title sits where the tabs of the props editor sit: its text starts at the same height (the 32 row is 30 under the grip row, as the 36 tab bar is 28), and the code card is 16 under it, as the first card is under the tabs. No padding below: the 16 gap to the first accordion belongs to the list under it (PropsEditor). -->
|
|
115
116
|
<section
|
|
116
|
-
class="embed-editor-code-header flex flex-col
|
|
117
|
+
class="embed-editor-code-header flex flex-col px-6 pt-1.5 pb-0"
|
|
117
118
|
aria-label={$t('editor.embed.headerArea')}
|
|
118
119
|
aria-busy={loading}
|
|
119
120
|
>
|
|
@@ -152,6 +152,9 @@
|
|
|
152
152
|
|
|
153
153
|
/** Portal slot for FileBrowser overlay — scoped to editor panel, not document body. */
|
|
154
154
|
let fileBrowserPortalHost: HTMLDivElement | null = null;
|
|
155
|
+
/** Tab scroll panels — passed to textarea preview portals so overlays stay inside the card. */
|
|
156
|
+
let designTabPortalHost: HTMLDivElement | null = null;
|
|
157
|
+
let contentTabPortalHost: HTMLDivElement | null = null;
|
|
155
158
|
|
|
156
159
|
// Determine if the first accordion item should be open by default
|
|
157
160
|
export let defaultOpen: boolean = true;
|
|
@@ -170,6 +173,11 @@
|
|
|
170
173
|
|
|
171
174
|
/** Optional content below the shared toolbar, before property fields. */
|
|
172
175
|
export let headerContent = undefined;
|
|
176
|
+
/**
|
|
177
|
+
* The space above the first accordion when there is only one tab. Under a header block (the Embed code header) Figma's panel gap
|
|
178
|
+
* puts the first accordion 16 below it; without a header the list starts 24 below the panel's top edge.
|
|
179
|
+
*/
|
|
180
|
+
$: singleTabTopPaddingClass = headerContent ? 'pt-4' : 'pt-6';
|
|
173
181
|
export let headerClass = '';
|
|
174
182
|
export let dragHandleClass = '';
|
|
175
183
|
export let title: string | undefined = undefined;
|
|
@@ -521,6 +529,10 @@
|
|
|
521
529
|
designOpenAccordion = designSchema[0].components
|
|
522
530
|
.flatMap((c: any) => (c.propertyGroups || []).map((pg: PropertyGroup) => pg.name))
|
|
523
531
|
.filter(Boolean);
|
|
532
|
+
const initialDesignSections = [...designOpenAccordion];
|
|
533
|
+
requestAnimationFrame(() => {
|
|
534
|
+
markAccordionSectionsMounted('design', initialDesignSections);
|
|
535
|
+
});
|
|
524
536
|
}
|
|
525
537
|
|
|
526
538
|
// Return cleanup function
|
|
@@ -985,7 +997,10 @@
|
|
|
985
997
|
let initialValue = stateValue !== undefined ? stateValue : (property.value !== undefined ? property.value : property.defaultValue);
|
|
986
998
|
|
|
987
999
|
// portalTarget for overlays (browser = full editor panel; textarea preview = tab panel)
|
|
988
|
-
let portalTarget: string | HTMLElement =
|
|
1000
|
+
let portalTarget: string | HTMLElement =
|
|
1001
|
+
schema === 'design'
|
|
1002
|
+
? (designTabPortalHost ?? 'tab-design-container')
|
|
1003
|
+
: (contentTabPortalHost ?? 'tab-content-container');
|
|
989
1004
|
if (inputController.type.toLowerCase() === 'browser') {
|
|
990
1005
|
portalTarget = fileBrowserPortalHost ?? 'props-editor-file-browser-portal';
|
|
991
1006
|
}
|
|
@@ -1281,6 +1296,35 @@
|
|
|
1281
1296
|
// Add after the state declarations
|
|
1282
1297
|
$: isItemOpen = (itemId: string) => openItems.has(itemId);
|
|
1283
1298
|
|
|
1299
|
+
/**
|
|
1300
|
+
* A content card keeps its body mounted for a while after it closes. A closed Collapsible only hides its content, so a
|
|
1301
|
+
* card that was open a moment ago opens again as a display change and not as a mount of all its input controllers
|
|
1302
|
+
* (which took 60 to 170 ms for the card with every kind of controller when the machine was busy). Only the last few
|
|
1303
|
+
* closed bodies are kept, so a long list does not keep every card it ever opened alive: each kept body still follows
|
|
1304
|
+
* the schema, and that is the price of keeping it.
|
|
1305
|
+
*/
|
|
1306
|
+
const MAX_CLOSED_ITEM_BODIES_KEPT = 4;
|
|
1307
|
+
let closedItemBodies: string[] = [];
|
|
1308
|
+
let previousOpenItemIds = new Set<string>();
|
|
1309
|
+
|
|
1310
|
+
/** Works out which cards closed since the last run, from the open set alone, so every way a card closes is covered. */
|
|
1311
|
+
function trackClosedItemBodies(currentOpenItems: Set<string>) {
|
|
1312
|
+
try {
|
|
1313
|
+
const justClosedItemIds = [...previousOpenItemIds].filter((itemId) => !currentOpenItems.has(itemId));
|
|
1314
|
+
const stillKeptItemIds = closedItemBodies.filter(
|
|
1315
|
+
(itemId) => !currentOpenItems.has(itemId) && !justClosedItemIds.includes(itemId)
|
|
1316
|
+
);
|
|
1317
|
+
// "Last few closed bodies": the oldest ones are dropped first.
|
|
1318
|
+
closedItemBodies = [...stillKeptItemIds, ...justClosedItemIds].slice(-MAX_CLOSED_ITEM_BODIES_KEPT);
|
|
1319
|
+
previousOpenItemIds = new Set(currentOpenItems);
|
|
1320
|
+
} catch (error) {
|
|
1321
|
+
console.error('[PropsEditor] Could not track the closed content card bodies:', error);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
// Keep this statement above `isItemBodyMounted`: that one reads what this one assigns.
|
|
1325
|
+
$: trackClosedItemBodies(openItems);
|
|
1326
|
+
$: isItemBodyMounted = (itemId: string) => openItems.has(itemId) || closedItemBodies.includes(itemId);
|
|
1327
|
+
|
|
1284
1328
|
/**
|
|
1285
1329
|
* Manages the open/closed state of content items
|
|
1286
1330
|
* @param itemId - Identifier for the content item to toggle
|
|
@@ -1379,13 +1423,46 @@
|
|
|
1379
1423
|
}
|
|
1380
1424
|
|
|
1381
1425
|
// Update the Accordion components to include value prop
|
|
1426
|
+
/** Accordion bodies stay unmounted until first open so heavy input controllers are not created eagerly. */
|
|
1427
|
+
let designAccordionMounted = new Set<string>();
|
|
1428
|
+
let contentAccordionMounted = new Set<string>();
|
|
1429
|
+
|
|
1430
|
+
function markAccordionSectionsMounted(tab: 'design' | 'content', sectionIds: string[]) {
|
|
1431
|
+
const targetSet = tab === 'design' ? designAccordionMounted : contentAccordionMounted;
|
|
1432
|
+
let grew = false;
|
|
1433
|
+
for (const sectionId of sectionIds) {
|
|
1434
|
+
if (!targetSet.has(sectionId)) {
|
|
1435
|
+
targetSet.add(sectionId);
|
|
1436
|
+
grew = true;
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
if (grew) {
|
|
1440
|
+
if (tab === 'design') {
|
|
1441
|
+
designAccordionMounted = new Set(targetSet);
|
|
1442
|
+
} else {
|
|
1443
|
+
contentAccordionMounted = new Set(targetSet);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1382
1448
|
function handleAccordionChange(value: string | string[]) {
|
|
1383
1449
|
const arr = Array.isArray(value) ? value : [value];
|
|
1450
|
+
const previousOpen = currentTab === 'design' ? designOpenAccordion : contentOpenAccordion;
|
|
1451
|
+
const newlyOpenedSections = arr.filter((sectionId) => !previousOpen.includes(sectionId));
|
|
1384
1452
|
if (currentTab === 'design') {
|
|
1385
1453
|
designOpenAccordion = arr;
|
|
1386
1454
|
} else {
|
|
1387
1455
|
contentOpenAccordion = arr;
|
|
1388
1456
|
}
|
|
1457
|
+
if (newlyOpenedSections.length > 0) {
|
|
1458
|
+
const tab: 'design' | 'content' = currentTab === 'design' ? 'design' : 'content';
|
|
1459
|
+
// Mount heavy accordion bodies after the open animation paints (avoids long tasks on the click frame).
|
|
1460
|
+
requestAnimationFrame(() => {
|
|
1461
|
+
requestAnimationFrame(() => {
|
|
1462
|
+
markAccordionSectionsMounted(tab, newlyOpenedSections);
|
|
1463
|
+
});
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1389
1466
|
}
|
|
1390
1467
|
|
|
1391
1468
|
// Stores content property values for open groups
|
|
@@ -2071,7 +2148,7 @@
|
|
|
2071
2148
|
class="drag-handle-container flex cursor-move items-center justify-center opacity-100 duration-fast transition-opacity {showSaveButton ? 'h-8' : 'h-4'}"
|
|
2072
2149
|
onmousedown={handleDragStart}
|
|
2073
2150
|
>
|
|
2074
|
-
<IconGripHorizontal class="size-4 stroke-
|
|
2151
|
+
<IconGripHorizontal class="size-4 stroke-2 text-muted-foreground {dragHandleClass}" />
|
|
2075
2152
|
</div>
|
|
2076
2153
|
{#if showSaveButton}
|
|
2077
2154
|
{#if titleLabel}
|
|
@@ -2093,7 +2170,7 @@
|
|
|
2093
2170
|
onmousedown={(e) => e.stopPropagation()}
|
|
2094
2171
|
>
|
|
2095
2172
|
{#if saveSaving}
|
|
2096
|
-
<IconLoader2 class="size-4 animate-spin stroke-
|
|
2173
|
+
<IconLoader2 class="size-4 animate-spin stroke-2" aria-hidden="true" />
|
|
2097
2174
|
{/if}
|
|
2098
2175
|
{saveSaving ? $t('editor.props.saving') : $t('editor.props.save')}
|
|
2099
2176
|
</Button>
|
|
@@ -2132,7 +2209,9 @@
|
|
|
2132
2209
|
{/if}
|
|
2133
2210
|
|
|
2134
2211
|
<!-- Design Tab Content -->
|
|
2135
|
-
<div
|
|
2212
|
+
<div
|
|
2213
|
+
bind:this={designTabPortalHost}
|
|
2214
|
+
class="tab-design-container grow scroll-area relative hidden min-h-0 flex-1 overflow-hidden"
|
|
2136
2215
|
class:hidden={currentTab !== 'design'}
|
|
2137
2216
|
style="max-height: {!designSchema || !contentSchema ? '100%' : `calc(100% - ${HEADER_HEIGHT}px)`}"
|
|
2138
2217
|
data-scrollable={$designScrollState.shouldShowScroll}
|
|
@@ -2141,10 +2220,10 @@
|
|
|
2141
2220
|
class="h-full"
|
|
2142
2221
|
type="hover"
|
|
2143
2222
|
scrollHideDelay={0}
|
|
2144
|
-
scrollbarYClasses="flex w-6 touch-none select-none px-2 pb-6 transition-colors duration-fast {headerContent ? 'bg-transparent' : 'bg-background'} {!designSchema || !contentSchema ?
|
|
2223
|
+
scrollbarYClasses="flex w-6 touch-none select-none px-2 pb-6 transition-colors duration-fast {headerContent ? 'bg-transparent' : 'bg-background'} {!designSchema || !contentSchema ? singleTabTopPaddingClass : 'pt-0'} [&>div]:w-2 [&>div]:cursor-pointer [&>div]:rounded-full [&>div]:bg-border [&>div]:duration-fast [&>div]:hover:bg-muted-foreground/30"
|
|
2145
2224
|
>
|
|
2146
|
-
<div class="scroll-viewport" data-radix-scroll-area-viewport bind:this={designScrollViewport}>
|
|
2147
|
-
<div class="
|
|
2225
|
+
<div class="scroll-viewport props-editor-scroll-viewport" data-radix-scroll-area-viewport bind:this={designScrollViewport}>
|
|
2226
|
+
<div class="props-editor-scroll-inner pb-6 {!designSchema || !contentSchema ? singleTabTopPaddingClass : 'pt-0'}" bind:this={designContentWrapper}>
|
|
2148
2227
|
<Tabs.Content
|
|
2149
2228
|
value="design"
|
|
2150
2229
|
class="design-tab-content mt-0! tabs-content-container w-full outline-none {isFirstLoad ? 'initial-load' : !isInitialTabLoad ? 'animate-slide-left' : ''}"
|
|
@@ -2176,6 +2255,7 @@
|
|
|
2176
2255
|
|
|
2177
2256
|
<!-- The DS body pads 4 / 16 / 16 / 16 (Figma Accordion Item). Every row carries 6 above and below its 36px control (48 pitch), so the list pulls 6 back at both ends and the padding lands on the controls. -->
|
|
2178
2257
|
<Accordion.Content class="accordion-content w-full min-w-0" data-accordion-content>
|
|
2258
|
+
{#if designAccordionMounted.has(propertyGroup.name)}
|
|
2179
2259
|
<div class="properties-list -my-1.5 flex w-full flex-col">
|
|
2180
2260
|
{#each propertyGroup.properties as property, propertyIndex (propertyGroup.name + '_' + (property.id ?? property.name ?? propertyIndex))}
|
|
2181
2261
|
{@const result = renderInputController('design', property, propertyIndex, groupIndex === 0)}
|
|
@@ -2222,6 +2302,7 @@
|
|
|
2222
2302
|
{/if}
|
|
2223
2303
|
{/each}
|
|
2224
2304
|
</div>
|
|
2305
|
+
{/if}
|
|
2225
2306
|
</Accordion.Content>
|
|
2226
2307
|
</Accordion.Item>
|
|
2227
2308
|
{/each}
|
|
@@ -2248,7 +2329,9 @@
|
|
|
2248
2329
|
|
|
2249
2330
|
<!-- Content Tab Content -->
|
|
2250
2331
|
{#if contentSchema}
|
|
2251
|
-
<div
|
|
2332
|
+
<div
|
|
2333
|
+
bind:this={contentTabPortalHost}
|
|
2334
|
+
class="tab-content-container scroll-area relative hidden min-h-0 grow overflow-hidden"
|
|
2252
2335
|
class:hidden={currentTab !== 'content'}
|
|
2253
2336
|
style="max-height: {!contentSchema || !designSchema ? '100%' : `calc(100% - ${HEADER_HEIGHT}px)`}"
|
|
2254
2337
|
data-scrollable={$contentScrollState.shouldShowScroll}
|
|
@@ -2257,10 +2340,10 @@
|
|
|
2257
2340
|
class="h-full"
|
|
2258
2341
|
type="hover"
|
|
2259
2342
|
scrollHideDelay={0}
|
|
2260
|
-
scrollbarYClasses="flex w-6 touch-none select-none px-2 pb-6 transition-colors duration-fast {headerContent ? 'bg-transparent' : 'bg-background'} {!designSchema || !contentSchema ?
|
|
2343
|
+
scrollbarYClasses="flex w-6 touch-none select-none px-2 pb-6 transition-colors duration-fast {headerContent ? 'bg-transparent' : 'bg-background'} {!designSchema || !contentSchema ? singleTabTopPaddingClass : 'pt-0'} [&>div]:w-2 [&>div]:cursor-pointer [&>div]:rounded-full [&>div]:bg-border [&>div]:duration-fast [&>div]:hover:bg-muted-foreground/30"
|
|
2261
2344
|
>
|
|
2262
|
-
<div class="scroll-viewport" data-radix-scroll-area-viewport bind:this={contentScrollViewport}>
|
|
2263
|
-
<div class="
|
|
2345
|
+
<div class="scroll-viewport props-editor-scroll-viewport" data-radix-scroll-area-viewport bind:this={contentScrollViewport}>
|
|
2346
|
+
<div class="props-editor-scroll-inner pb-6 {!designSchema || !contentSchema ? singleTabTopPaddingClass : 'pt-0'}" bind:this={contentWrapper}>
|
|
2264
2347
|
<Tabs.Content
|
|
2265
2348
|
value="content"
|
|
2266
2349
|
class="content-tab-content mt-0! tabs-content-container w-full {isFirstLoad ? 'initial-load' : !isInitialTabLoad ? 'animate-slide-right' : ''}"
|
|
@@ -2279,12 +2362,12 @@
|
|
|
2279
2362
|
<Collapsible.Trigger class="generic-content-trigger w-full focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background">
|
|
2280
2363
|
<div class="flex h-12 cursor-pointer items-center gap-2 px-4 hover:bg-accent duration-fast transition-colors">
|
|
2281
2364
|
<h3 class="text-body-medium text-foreground flex-1 text-start content-title">{contentSchema?.genericContent?.title || $t('editor.props.contentCard')}</h3>
|
|
2282
|
-
<IconChevronDown class="chevron size-4 shrink-0 stroke-
|
|
2365
|
+
<IconChevronDown class="chevron size-4 shrink-0 stroke-2 text-muted-foreground transition-transform duration-base {isGenericContentOpen ? 'rotate-180' : ''}" />
|
|
2283
2366
|
</div>
|
|
2284
2367
|
</Collapsible.Trigger>
|
|
2285
2368
|
|
|
2286
2369
|
<Collapsible.Content>
|
|
2287
|
-
|
|
2370
|
+
<!-- Always mounted: the Collapsible only hides a closed body, so closing and opening this card (the one with every kind of controller) is a display change and not a mount of all its controllers. It is open by default, so the controllers are mounted anyway. -->
|
|
2288
2371
|
<Card.Content class="p-0 px-4">
|
|
2289
2372
|
<!-- Figma Content Card body: 4 / 16 / 16 / 16; every row carries 6 above and below its 36px control (48 pitch), so the list pulls 6 back at both ends. -->
|
|
2290
2373
|
<div class="pt-1 pb-4">
|
|
@@ -2340,7 +2423,6 @@
|
|
|
2340
2423
|
</div>
|
|
2341
2424
|
</div>
|
|
2342
2425
|
</Card.Content>
|
|
2343
|
-
{/if}
|
|
2344
2426
|
</Collapsible.Content>
|
|
2345
2427
|
</Collapsible.Root>
|
|
2346
2428
|
</Card.Root>
|
|
@@ -2372,7 +2454,7 @@
|
|
|
2372
2454
|
<div class="flex h-12 cursor-pointer items-center hover:bg-accent duration-fast transition-colors">
|
|
2373
2455
|
<!-- 32 wide, grip centred: the 16px icon sits 8 from the start and the title begins at 32 (Figma Card Header). -->
|
|
2374
2456
|
<div class="drag-handle flex w-8 shrink-0 cursor-move items-center justify-center touch-none">
|
|
2375
|
-
<IconGripVertical class="size-4 stroke-
|
|
2457
|
+
<IconGripVertical class="size-4 stroke-2 text-muted-foreground duration-fast transition-colors" />
|
|
2376
2458
|
</div>
|
|
2377
2459
|
|
|
2378
2460
|
<!-- Item Title — user caption/title wins; Slide N / Item 0N follow list position -->
|
|
@@ -2381,13 +2463,14 @@
|
|
|
2381
2463
|
</h4>
|
|
2382
2464
|
|
|
2383
2465
|
<div class="pe-4">
|
|
2384
|
-
<IconChevronDown class="chevron size-4 shrink-0 stroke-
|
|
2466
|
+
<IconChevronDown class="chevron size-4 shrink-0 stroke-2 text-muted-foreground transition-transform duration-base {isItemOpen(item.id) ? 'rotate-180' : ''}" />
|
|
2385
2467
|
</div>
|
|
2386
2468
|
</div>
|
|
2387
2469
|
</Collapsible.Trigger>
|
|
2388
2470
|
|
|
2389
2471
|
<Collapsible.Content>
|
|
2390
|
-
|
|
2472
|
+
<!-- Mounted while open and for a while after it closes (see `closedItemBodies`). -->
|
|
2473
|
+
{#if isItemBodyMounted(item.id)}
|
|
2391
2474
|
<Card.Content class="p-0 px-4">
|
|
2392
2475
|
<div class="pt-1 pb-4">
|
|
2393
2476
|
<div class="properties-list -my-1.5 flex w-full flex-col">
|
|
@@ -2467,14 +2550,16 @@
|
|
|
2467
2550
|
|
|
2468
2551
|
{#if canAddContentItem()}
|
|
2469
2552
|
<div class="content-add-item-ct mt-4">
|
|
2470
|
-
<
|
|
2553
|
+
<Button
|
|
2471
2554
|
type="button"
|
|
2472
|
-
|
|
2555
|
+
variant="stroke"
|
|
2556
|
+
size="default"
|
|
2557
|
+
class="content-add-item-button w-full"
|
|
2473
2558
|
onclick={handleAddNewItem}
|
|
2474
2559
|
>
|
|
2475
|
-
<IconPlus class="size-4
|
|
2560
|
+
<IconPlus class="size-4 text-brand" aria-hidden="true" />
|
|
2476
2561
|
{$t('editor.props.addItem')}
|
|
2477
|
-
</
|
|
2562
|
+
</Button>
|
|
2478
2563
|
</div>
|
|
2479
2564
|
{/if}
|
|
2480
2565
|
</div>
|
|
@@ -2500,6 +2585,22 @@
|
|
|
2500
2585
|
--has-both-schemas: 0;
|
|
2501
2586
|
}
|
|
2502
2587
|
|
|
2588
|
+
/* Keep the vertical scrollbar inside the panel's horizontal padding so it never sits on card borders. */
|
|
2589
|
+
:global(.props-editor-container .props-editor-scroll-viewport) {
|
|
2590
|
+
scrollbar-gutter: stable;
|
|
2591
|
+
padding-inline: 1.5rem;
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
/* Inset the vertical scrollbar by the panel's horizontal padding so it never sits on card borders. */
|
|
2595
|
+
:global(.props-editor-container [data-orientation='vertical'][data-state]) {
|
|
2596
|
+
inset-inline-end: 1.5rem;
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
:global(.props-editor-container .props-editor-scroll-inner) {
|
|
2600
|
+
padding-inline: 0;
|
|
2601
|
+
min-width: 0;
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2503
2604
|
/* Both tabs: design content sits below the tab list when both schemas exist. */
|
|
2504
2605
|
.props-editor-container:has(.tabs-header) {
|
|
2505
2606
|
--has-both-schemas: 1rem;
|
|
@@ -2558,13 +2659,11 @@
|
|
|
2558
2659
|
position: static;
|
|
2559
2660
|
}
|
|
2560
2661
|
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
transition: transform var(--duration-base) ease-out;
|
|
2567
|
-
}
|
|
2662
|
+
/*
|
|
2663
|
+
* The accordion arrow is turned and eased by the design system's own trigger (`[&[data-state=open]>svg]:rotate-180` with
|
|
2664
|
+
* `transition-transform duration-base`). A second `transform: rotate(180deg)` here used to be added to the trigger's `rotate`
|
|
2665
|
+
* (Tailwind 4 uses the `rotate` property), which made an open accordion turn a full 360 degrees and point down again.
|
|
2666
|
+
*/
|
|
2568
2667
|
|
|
2569
2668
|
/* Content card headers: underline title on hover, not when hovering the drag handle. */
|
|
2570
2669
|
:global(.content-item-trigger:hover .content-title),
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
import { onDestroy } from 'svelte';
|
|
25
25
|
import InputControllerRow from './InputControllerRow.svelte';
|
|
26
26
|
import NumberControls from './NumberControls.svelte';
|
|
27
|
+
import { normalizeAngleDegrees } from '../../utils/angleMath';
|
|
27
28
|
|
|
28
29
|
export let label: AngleInputControllerProps['label'];
|
|
29
30
|
export let value: AngleInputControllerProps['value'] = 0;
|
|
@@ -40,9 +41,12 @@
|
|
|
40
41
|
let startValue = 0;
|
|
41
42
|
|
|
42
43
|
// Configuration with defaults
|
|
43
|
-
$: min = config.min
|
|
44
|
-
$: max = config.max
|
|
45
|
-
$: step = config.step
|
|
44
|
+
$: min = config.min ?? 0;
|
|
45
|
+
$: max = config.max ?? 360;
|
|
46
|
+
$: step = config.step ?? 1;
|
|
47
|
+
|
|
48
|
+
/** Needle rotation must treat 0° as valid (never skip with falsy checks). */
|
|
49
|
+
$: displayAngleDegrees = normalizeAngleDegrees(value);
|
|
46
50
|
|
|
47
51
|
// Keep input value in sync with value prop
|
|
48
52
|
$: {
|
|
@@ -181,14 +185,14 @@
|
|
|
181
185
|
<!-- Sized in scoped CSS: with only w-0.5 + bg-primary, measure.mjs reported background transparent until width/height are explicit. -->
|
|
182
186
|
<div
|
|
183
187
|
class="angle-dial-needle pointer-events-none absolute top-1/2 start-1/2 origin-bottom bg-primary"
|
|
184
|
-
style="transform: translate(-50%, -100%) rotate({
|
|
188
|
+
style="transform: translate(-50%, -100%) rotate({displayAngleDegrees}deg)"
|
|
185
189
|
></div>
|
|
186
190
|
</div>
|
|
187
191
|
|
|
188
192
|
<NumberControls
|
|
189
193
|
class="min-w-0 flex-1"
|
|
190
|
-
surfacePaddingClass="pe-1.5
|
|
191
|
-
|
|
194
|
+
surfacePaddingClass="pe-1.5"
|
|
195
|
+
bind:value
|
|
192
196
|
{onChange}
|
|
193
197
|
{min}
|
|
194
198
|
{max}
|
|
@@ -32,13 +32,9 @@
|
|
|
32
32
|
import { onDestroy, tick } from 'svelte';
|
|
33
33
|
|
|
34
34
|
// Shadcn UI Components
|
|
35
|
-
import {
|
|
35
|
+
import { Tooltip, showToast } from '@widgetic/design-system/components';
|
|
36
36
|
import { ThumbHashImage } from '@widgetic/design-system/components';
|
|
37
|
-
import {
|
|
38
|
-
FileBrowser,
|
|
39
|
-
setFileBrowserUploadConfig,
|
|
40
|
-
persistentSelectStore
|
|
41
|
-
} from '@widgetic/file-browser';
|
|
37
|
+
import { setFileBrowserUploadConfig, persistentSelectStore } from '@widgetic/file-browser';
|
|
42
38
|
import { useEditorMediaLibrary } from '../../mediaLibraryContext';
|
|
43
39
|
import { useEditorPickFile, type PartnerPickFile } from '../../pickFileContext';
|
|
44
40
|
import { useEditorStoreFileUrl } from '../../fileStorageUrlContext';
|
|
@@ -58,6 +54,7 @@
|
|
|
58
54
|
import { queryInTreeOf } from '../../utils/shadowDom';
|
|
59
55
|
|
|
60
56
|
import InputControllerRow from './InputControllerRow.svelte';
|
|
57
|
+
import EditorFileBrowserOverlay from './shared/EditorFileBrowserOverlay.svelte';
|
|
61
58
|
|
|
62
59
|
// Component props with default values
|
|
63
60
|
export let header: BrowserInputControllerProps['header'] = undefined;
|
|
@@ -66,10 +63,6 @@
|
|
|
66
63
|
export let onChange: BrowserInputControllerProps['onChange'] = () => {};
|
|
67
64
|
export let portalTarget: BrowserInputControllerProps['portalTarget'] = 'portal-element';
|
|
68
65
|
|
|
69
|
-
/** Full-panel overlay when portaled to props-editor panel (not document body). */
|
|
70
|
-
$: fillEditorPanel =
|
|
71
|
-
portalTarget === 'props-editor-file-browser-portal' ||
|
|
72
|
-
(portalTarget instanceof HTMLElement && portalTarget.id === 'props-editor-file-browser-portal');
|
|
73
66
|
export let config: BrowserInputControllerProps['config'] = {};
|
|
74
67
|
|
|
75
68
|
// The media library the editor above was given (a partner's own storage, for instance), read through a getter
|
|
@@ -79,8 +72,8 @@
|
|
|
79
72
|
const getEditorStoreFileUrl = useEditorStoreFileUrl();
|
|
80
73
|
let pickAbortController: AbortController | null = null;
|
|
81
74
|
|
|
82
|
-
// The words of the editor in the language of the page
|
|
83
|
-
const { t
|
|
75
|
+
// The words of the editor in the language of the page
|
|
76
|
+
const { t } = useEditorLanguage();
|
|
84
77
|
|
|
85
78
|
// Extract allowed file types from config or default to all files
|
|
86
79
|
const fileTypes = config.fileTypes || ['*'];
|
|
@@ -625,7 +618,7 @@
|
|
|
625
618
|
aria-label={isPlaying ? $t('editor.file.pause') : $t('editor.file.play')}
|
|
626
619
|
>
|
|
627
620
|
{#if !isPlaying}
|
|
628
|
-
<IconVideo class="size-4 stroke-
|
|
621
|
+
<IconVideo class="size-4 stroke-2 text-muted-foreground" />
|
|
629
622
|
{/if}
|
|
630
623
|
<!-- The video plays inside the tile (it is see-through while paused, the camera icon shows) -->
|
|
631
624
|
<!-- svelte-ignore a11y-media-has-caption -->
|
|
@@ -645,7 +638,7 @@
|
|
|
645
638
|
class="absolute inset-0 flex items-center justify-center bg-transparent opacity-0 transition-opacity duration-fast hover:bg-foreground/40 hover:opacity-100"
|
|
646
639
|
aria-hidden="true"
|
|
647
640
|
>
|
|
648
|
-
<IconPlayerPause class="size-4 stroke-
|
|
641
|
+
<IconPlayerPause class="size-4 stroke-2 text-primary-foreground" />
|
|
649
642
|
</span>
|
|
650
643
|
{/if}
|
|
651
644
|
</div>
|
|
@@ -660,9 +653,9 @@
|
|
|
660
653
|
>
|
|
661
654
|
<!-- While the sound plays the tile shows a pause icon, so the state is seen as well as heard -->
|
|
662
655
|
{#if isPlaying}
|
|
663
|
-
<IconPlayerPause class="size-4 stroke-
|
|
656
|
+
<IconPlayerPause class="size-4 stroke-2 text-foreground" />
|
|
664
657
|
{:else}
|
|
665
|
-
<IconMusic class="size-4 stroke-
|
|
658
|
+
<IconMusic class="size-4 stroke-2 text-muted-foreground" />
|
|
666
659
|
{/if}
|
|
667
660
|
<!-- Audio element hidden but needed for playback -->
|
|
668
661
|
<!-- svelte-ignore a11y-media-has-caption -->
|
|
@@ -683,13 +676,13 @@
|
|
|
683
676
|
role="button"
|
|
684
677
|
tabindex={0}
|
|
685
678
|
>
|
|
686
|
-
<IconFileText class="size-4 stroke-
|
|
679
|
+
<IconFileText class="size-4 stroke-2 text-muted-foreground" />
|
|
687
680
|
</div>
|
|
688
681
|
{:else}
|
|
689
682
|
<div
|
|
690
683
|
class="browser-input-controller-thumbnail flex size-7 shrink-0 items-center justify-center rounded-lg border border-border bg-background"
|
|
691
684
|
>
|
|
692
|
-
<IconFolderOpen class="size-4 stroke-
|
|
685
|
+
<IconFolderOpen class="size-4 stroke-2 text-muted-foreground" />
|
|
693
686
|
</div>
|
|
694
687
|
{/if}
|
|
695
688
|
{:else if previewUrl && hasError}
|
|
@@ -698,13 +691,13 @@
|
|
|
698
691
|
class="browser-input-controller-thumbnail flex size-7 shrink-0 items-center justify-center rounded-lg border border-destructive bg-background"
|
|
699
692
|
aria-label={$t('editor.file.notFound')}
|
|
700
693
|
>
|
|
701
|
-
<IconAlertTriangle class="size-4 stroke-
|
|
694
|
+
<IconAlertTriangle class="size-4 stroke-2 text-destructive" />
|
|
702
695
|
</div>
|
|
703
696
|
{:else}
|
|
704
697
|
<div
|
|
705
698
|
class="browser-input-controller-thumbnail flex size-7 shrink-0 items-center justify-center rounded-lg border border-border bg-background"
|
|
706
699
|
>
|
|
707
|
-
<IconFolderOpen class="size-4 stroke-
|
|
700
|
+
<IconFolderOpen class="size-4 stroke-2 text-muted-foreground" />
|
|
708
701
|
</div>
|
|
709
702
|
{/if}
|
|
710
703
|
|
|
@@ -715,7 +708,7 @@
|
|
|
715
708
|
on:click|stopPropagation={handleContentRemoval}
|
|
716
709
|
aria-label={$t('editor.file.clear')}
|
|
717
710
|
>
|
|
718
|
-
<IconX class="size-4 stroke-
|
|
711
|
+
<IconX class="size-4 stroke-2 text-muted-foreground" />
|
|
719
712
|
</button>
|
|
720
713
|
{:else if isChecking}
|
|
721
714
|
<div class="ms-auto size-7 shrink-0 animate-pulse rounded-lg bg-muted"></div>
|
|
@@ -727,7 +720,7 @@
|
|
|
727
720
|
on:click|stopPropagation={openFileBrowser}
|
|
728
721
|
aria-label={$t('editor.file.emptyFolder')}
|
|
729
722
|
>
|
|
730
|
-
<IconFolderOpen class="size-4 stroke-
|
|
723
|
+
<IconFolderOpen class="size-4 stroke-2 text-muted-foreground" />
|
|
731
724
|
</button>
|
|
732
725
|
{/if}
|
|
733
726
|
</div>
|
|
@@ -735,94 +728,14 @@
|
|
|
735
728
|
</div>
|
|
736
729
|
|
|
737
730
|
{#if isFileBrowserOpen}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
<div
|
|
750
|
-
class="browser-input-file-browser-dialog browser-input-file-browser-dialog-animate relative z-[999999] flex min-h-0 w-full flex-col overflow-hidden border border-border bg-background"
|
|
751
|
-
class:absolute={fillEditorPanel}
|
|
752
|
-
class:inset-0={fillEditorPanel}
|
|
753
|
-
class:h-full={fillEditorPanel}
|
|
754
|
-
class:max-w-none={fillEditorPanel}
|
|
755
|
-
class:rounded-none={fillEditorPanel}
|
|
756
|
-
class:shadow-none={fillEditorPanel}
|
|
757
|
-
class:max-w-[520px]={!fillEditorPanel}
|
|
758
|
-
class:flex-1={!fillEditorPanel}
|
|
759
|
-
class:min-h-[550px]={fillEditorPanel}
|
|
760
|
-
class:self-center={!fillEditorPanel}
|
|
761
|
-
class:mx-auto={!fillEditorPanel}
|
|
762
|
-
class:rounded-xl={!fillEditorPanel}
|
|
763
|
-
>
|
|
764
|
-
<div
|
|
765
|
-
class="browser-input-file-browser-header relative flex h-12 shrink-0 items-center border-b border-border ps-4 pe-8"
|
|
766
|
-
>
|
|
767
|
-
<span class="text-body-medium text-foreground">{$t('editor.file.dialogTitle')}</span>
|
|
768
|
-
<button
|
|
769
|
-
type="button"
|
|
770
|
-
class="browser-input-file-browser-close inline-flex h-6 w-6 items-center justify-center p-0"
|
|
771
|
-
style="position:absolute;top:4px;inset-inline-end:4px;"
|
|
772
|
-
on:click={closeFileBrowser}
|
|
773
|
-
aria-label={$t('editor.file.closeDialog')}
|
|
774
|
-
>
|
|
775
|
-
<IconX class="size-4 stroke-[1.333]" />
|
|
776
|
-
</button>
|
|
777
|
-
</div>
|
|
778
|
-
|
|
779
|
-
<div class="browser-input-file-browser-body flex min-h-0 flex-1 flex-col overflow-hidden">
|
|
780
|
-
<!-- With a media library the File Browser keeps nothing about this visit (the filter it was left on, the
|
|
781
|
-
folder it was left in) in the page's localStorage: that storage belongs to the page this editor sits in,
|
|
782
|
-
which can be a partner's. Without one (the Widgetic site) it remembers them, as it always did. -->
|
|
783
|
-
<FileBrowser
|
|
784
|
-
class="h-full min-h-0 flex-1"
|
|
785
|
-
instanceId={`props-editor-browser-input-${fileBrowserFilter}`}
|
|
786
|
-
initialFilter={fileBrowserFilter}
|
|
787
|
-
restrictUpload={fileBrowserRestrictUpload}
|
|
788
|
-
useDemoContent={false}
|
|
789
|
-
mediaLibrary={getEditorMediaLibrary()}
|
|
790
|
-
persistHistory={!getEditorMediaLibrary()}
|
|
791
|
-
allowSelecting={true}
|
|
792
|
-
showAddToEditor={true}
|
|
793
|
-
maxSelections={1}
|
|
794
|
-
activeFileId={getCurrentFileId()}
|
|
795
|
-
addToEditorLabel={fileBrowserAddToEditorLabelSingular}
|
|
796
|
-
locale={$fileBrowserLanguage.locale ?? undefined}
|
|
797
|
-
messages={$fileBrowserLanguage.messages ?? null}
|
|
798
|
-
on:select={handleFileBrowserSelect}
|
|
799
|
-
/>
|
|
800
|
-
</div>
|
|
801
|
-
</div>
|
|
802
|
-
</div>
|
|
803
|
-
</Portal>
|
|
731
|
+
<!-- The browser of the editor (shared with the other file fields); the type of file is fixed by this field. -->
|
|
732
|
+
<EditorFileBrowserOverlay
|
|
733
|
+
{portalTarget}
|
|
734
|
+
fileFilter={fileBrowserFilter}
|
|
735
|
+
instanceId={`props-editor-browser-input-${fileBrowserFilter}`}
|
|
736
|
+
activeFileId={getCurrentFileId()}
|
|
737
|
+
addToEditorLabel={fileBrowserAddToEditorLabelSingular}
|
|
738
|
+
onClose={closeFileBrowser}
|
|
739
|
+
on:select={handleFileBrowserSelect}
|
|
740
|
+
/>
|
|
804
741
|
{/if}
|
|
805
|
-
|
|
806
|
-
<style>
|
|
807
|
-
.browser-input-file-browser-close {
|
|
808
|
-
position: absolute;
|
|
809
|
-
top: 4px;
|
|
810
|
-
inset-inline-end: 4px;
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
.browser-input-file-browser-dialog-animate {
|
|
814
|
-
transform-origin: center center;
|
|
815
|
-
animation: browser-input-fb-scale-in 0.22s cubic-bezier(0.4, 0, 0.2, 1);
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
@keyframes browser-input-fb-scale-in {
|
|
819
|
-
from {
|
|
820
|
-
transform: scale(0.94);
|
|
821
|
-
opacity: 0;
|
|
822
|
-
}
|
|
823
|
-
to {
|
|
824
|
-
transform: scale(1);
|
|
825
|
-
opacity: 1;
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
</style>
|