@widgetic/editor 4.1.17 → 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 -2
- package/dist/components/editors/PropsEditor.svelte +115 -19
- package/dist/components/ic/AngleInputController.svelte +9 -5
- 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/FixedPositionInputController.svelte +1 -1
- package/dist/components/ic/FontInputController.svelte +39 -43
- package/dist/components/ic/InputControllerHeader.svelte +1 -1
- package/dist/components/ic/KnowledgeDocumentsInputController.svelte +7 -7
- package/dist/components/ic/NumberControls.svelte +23 -18
- 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 +37 -16
- 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 +153 -20
- package/dist/components/ic/shared/DropdownChevron.svelte +2 -2
- package/dist/components/ic/shared/DropdownChevron.svelte.d.ts +1 -1
- 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
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
/** COMPONENTS IMPORTS */
|
|
44
44
|
// Shadcn UI components imports from design-system
|
|
45
45
|
import { Popover, EmptyState, IconButton } from '@widgetic/design-system/components';
|
|
46
|
+
import { useEditorPickFile } from '../../pickFileContext';
|
|
46
47
|
|
|
47
48
|
import {
|
|
48
49
|
IconCloudUpload,
|
|
@@ -56,12 +57,14 @@
|
|
|
56
57
|
import { SearchInput } from '@widgetic/design-system/components';
|
|
57
58
|
import CategoryTabs from './shared/CategoryTabs.svelte';
|
|
58
59
|
import DropdownChevron from './shared/DropdownChevron.svelte';
|
|
60
|
+
import EditorFileBrowserOverlay from './shared/EditorFileBrowserOverlay.svelte';
|
|
59
61
|
import { RecentItemsSection, ItemGrid } from './shared';
|
|
60
62
|
import { useEditorLanguage } from '../../i18n/language';
|
|
61
63
|
import { categoryLabel } from '../../i18n/labels';
|
|
62
64
|
|
|
63
65
|
// The words of the editor in the language of the page.
|
|
64
66
|
const { t } = useEditorLanguage();
|
|
67
|
+
const getEditorPickFile = useEditorPickFile();
|
|
65
68
|
|
|
66
69
|
$: vectorLoadFailedLabel = $t('editor.vector.loadFailed');
|
|
67
70
|
|
|
@@ -125,6 +128,31 @@
|
|
|
125
128
|
let controllerElement: HTMLDivElement | undefined;
|
|
126
129
|
let vectorObserver = new IntersectionObserver(() => {});
|
|
127
130
|
|
|
131
|
+
// The picker is as tall as the room around its trigger allows (560px at most) and opens on the side that has more room,
|
|
132
|
+
// so that its header (the title and the upload button) is never cut off by the top or the bottom of the window.
|
|
133
|
+
let vectorTriggerBox: HTMLDivElement | undefined;
|
|
134
|
+
let vectorPopoverSide: 'top' | 'bottom' = 'bottom';
|
|
135
|
+
let vectorPopoverStyle = '';
|
|
136
|
+
|
|
137
|
+
function updateVectorPopoverBox() {
|
|
138
|
+
try {
|
|
139
|
+
if (!vectorTriggerBox || typeof window === 'undefined') return;
|
|
140
|
+
const triggerRect = vectorTriggerBox.getBoundingClientRect();
|
|
141
|
+
const collisionPadding = 12;
|
|
142
|
+
const sideOffset = 8;
|
|
143
|
+
const viewportHeight = window.visualViewport?.height ?? window.innerHeight;
|
|
144
|
+
const roomBelow = viewportHeight - triggerRect.bottom - collisionPadding - sideOffset;
|
|
145
|
+
const roomAbove = triggerRect.top - collisionPadding - sideOffset;
|
|
146
|
+
const opensAbove = roomAbove > roomBelow;
|
|
147
|
+
vectorPopoverSide = opensAbove ? 'top' : 'bottom';
|
|
148
|
+
const availableHeight = Math.max(0, opensAbove ? roomAbove : roomBelow);
|
|
149
|
+
const desiredHeight = Math.min(560, availableHeight);
|
|
150
|
+
vectorPopoverStyle = `height: ${desiredHeight}px; max-height: ${desiredHeight}px;`;
|
|
151
|
+
} catch (error) {
|
|
152
|
+
console.error('❌ [VectorInput] Could not measure the room around the picker:', error);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
128
156
|
// Initialize VectorManager instance
|
|
129
157
|
let vectorManagerInstance: VectorManager;
|
|
130
158
|
let buttonWidth = 0;
|
|
@@ -886,6 +914,9 @@
|
|
|
886
914
|
// vector: vectorValue
|
|
887
915
|
// });
|
|
888
916
|
}
|
|
917
|
+
if ($openDropdowns?.has(controllerId)) {
|
|
918
|
+
toggleDropdown(controllerId);
|
|
919
|
+
}
|
|
889
920
|
}
|
|
890
921
|
|
|
891
922
|
/**
|
|
@@ -998,6 +1029,54 @@
|
|
|
998
1029
|
}
|
|
999
1030
|
}
|
|
1000
1031
|
|
|
1032
|
+
// True while `fillVectorListUntilItScrolls` is asking for more vectors, so that two fills never run together
|
|
1033
|
+
let isFillingVectorList = false;
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* The first batch is eight vectors, which do not fill the list: the list cannot scroll, the scroll handler never asks
|
|
1037
|
+
* for more, and the user sees eight icons and never reaches the emoji faces. This asks for more, a batch at a time,
|
|
1038
|
+
* until the list is taller than its window (or there is nothing more to show).
|
|
1039
|
+
*/
|
|
1040
|
+
async function fillVectorListUntilItScrolls() {
|
|
1041
|
+
if (isFillingVectorList) return;
|
|
1042
|
+
isFillingVectorList = true;
|
|
1043
|
+
try {
|
|
1044
|
+
for (let attempt = 0; attempt < 8; attempt += 1) {
|
|
1045
|
+
await tick();
|
|
1046
|
+
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
|
|
1047
|
+
const listWindow = vectorListContainer;
|
|
1048
|
+
if (!listWindow || !$openDropdowns?.has(controllerId)) return;
|
|
1049
|
+
if (listWindow.scrollHeight > listWindow.clientHeight + 1) return;
|
|
1050
|
+
|
|
1051
|
+
if (searchTerm && currentSearchResults.length > 0) {
|
|
1052
|
+
const nextSearchBatch = currentSearchResults.slice(
|
|
1053
|
+
filteredVectors.length,
|
|
1054
|
+
filteredVectors.length + SEARCH_BATCH_SIZE
|
|
1055
|
+
);
|
|
1056
|
+
if (nextSearchBatch.length === 0) return;
|
|
1057
|
+
filteredVectors = [...filteredVectors, ...nextSearchBatch];
|
|
1058
|
+
} else if (
|
|
1059
|
+
!searchTerm &&
|
|
1060
|
+
!isLoadingBatch &&
|
|
1061
|
+
vectorManagerInstance?.hasMoreVectors(controllerId, currentFilter)
|
|
1062
|
+
) {
|
|
1063
|
+
await loadNextBatch();
|
|
1064
|
+
} else {
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
} catch (error) {
|
|
1069
|
+
console.error('❌ [VectorInput] Could not fill the vector list:', error);
|
|
1070
|
+
} finally {
|
|
1071
|
+
isFillingVectorList = false;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
// Whenever the open list changes (a category, a search, a new batch) check that it is still tall enough to scroll
|
|
1076
|
+
$: if ($openDropdowns?.has(controllerId) && filteredVectors.length > 0) {
|
|
1077
|
+
void fillVectorListUntilItScrolls();
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1001
1080
|
onDestroy(() => {
|
|
1002
1081
|
stopListeningForScroll();
|
|
1003
1082
|
|
|
@@ -1020,28 +1099,63 @@
|
|
|
1020
1099
|
* Opens the file browser for vector selection
|
|
1021
1100
|
*/
|
|
1022
1101
|
async function openFileBrowser() {
|
|
1023
|
-
//
|
|
1102
|
+
// The picker gives way to the file browser: two layers of choices must never be open on top of each other.
|
|
1103
|
+
if ($openDropdowns?.has(controllerId)) {
|
|
1104
|
+
toggleDropdown(controllerId);
|
|
1105
|
+
}
|
|
1106
|
+
const pickFile = getEditorPickFile();
|
|
1107
|
+
if (pickFile) {
|
|
1108
|
+
try {
|
|
1109
|
+
const picked = await pickFile({
|
|
1110
|
+
accept: ['image/svg+xml', '.svg'],
|
|
1111
|
+
multiple: false,
|
|
1112
|
+
signal: new AbortController().signal
|
|
1113
|
+
});
|
|
1114
|
+
const selectedFile = picked?.[0];
|
|
1115
|
+
if (selectedFile && onChange) {
|
|
1116
|
+
onChange({
|
|
1117
|
+
name: selectedFile.name.replace(/\.svg$/i, '') || selectedFile.name,
|
|
1118
|
+
category: 'Mine',
|
|
1119
|
+
url: selectedFile.url
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
} catch (error) {
|
|
1123
|
+
console.error('❌ [VectorInput] pickFile failed:', error);
|
|
1124
|
+
}
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1024
1127
|
|
|
1025
1128
|
try {
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
? vectorManagerInstance
|
|
1029
|
-
?.getCachedVectorList()
|
|
1030
|
-
.find((v) => v.name === value.name && v.category === 'Mine')?.name
|
|
1031
|
-
: undefined;
|
|
1032
|
-
|
|
1033
|
-
// console.log('🔍 [VectorInput] Opening file browser:', {
|
|
1034
|
-
// fileTypes: ['svg'],
|
|
1035
|
-
// selectedId
|
|
1036
|
-
// });
|
|
1037
|
-
|
|
1038
|
-
// TODO: Implement file browser functionality
|
|
1039
|
-
// This will be similar to FontInputController but for SVG files
|
|
1129
|
+
showVectorModal = true;
|
|
1130
|
+
await tick();
|
|
1040
1131
|
} catch (error) {
|
|
1041
1132
|
console.error('❌ [VectorInput] Error opening file browser:', error);
|
|
1042
1133
|
}
|
|
1043
1134
|
}
|
|
1044
1135
|
|
|
1136
|
+
function closeVectorFileBrowser() {
|
|
1137
|
+
showVectorModal = false;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
async function handleVectorFileBrowserSelect(
|
|
1141
|
+
event: CustomEvent<{ files?: Array<{ id: string; name?: string; file?: string; url: string }> }>
|
|
1142
|
+
) {
|
|
1143
|
+
try {
|
|
1144
|
+
const selectedFile = event.detail?.files?.[0];
|
|
1145
|
+
if (!selectedFile?.url || !onChange) return;
|
|
1146
|
+
const displayName =
|
|
1147
|
+
selectedFile.name || selectedFile.file || selectedFile.url.split('/').pop() || 'Custom';
|
|
1148
|
+
onChange({
|
|
1149
|
+
name: displayName.replace(/\.svg$/i, ''),
|
|
1150
|
+
category: 'Mine',
|
|
1151
|
+
url: selectedFile.url
|
|
1152
|
+
});
|
|
1153
|
+
closeVectorFileBrowser();
|
|
1154
|
+
} catch (error) {
|
|
1155
|
+
console.error('❌ [VectorInput] File browser selection failed:', error);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1045
1159
|
/**
|
|
1046
1160
|
* Handles category filter changes
|
|
1047
1161
|
*/
|
|
@@ -1412,7 +1526,10 @@
|
|
|
1412
1526
|
}
|
|
1413
1527
|
|
|
1414
1528
|
function isVectorSelected(vector: VectorItem) {
|
|
1415
|
-
return Boolean(
|
|
1529
|
+
return Boolean(
|
|
1530
|
+
value?.name === vector.name &&
|
|
1531
|
+
(value?.url ? value.url === vector.url : true)
|
|
1532
|
+
);
|
|
1416
1533
|
}
|
|
1417
1534
|
|
|
1418
1535
|
function isCustomVector(vector: VectorItem) {
|
|
@@ -1528,12 +1645,13 @@
|
|
|
1528
1645
|
|
|
1529
1646
|
<div bind:this={controllerElement} class="vector-ic flex w-full flex-col">
|
|
1530
1647
|
<InputControllerRow {label} helpText={description}>
|
|
1531
|
-
<div class="vector-input-ct w-full" onfocusin={onFocus}>
|
|
1648
|
+
<div bind:this={vectorTriggerBox} class="vector-input-ct w-full" onfocusin={onFocus}>
|
|
1532
1649
|
<Popover.Root
|
|
1533
1650
|
open={$openDropdowns?.has(controllerId)}
|
|
1534
1651
|
onOpenChange={(isOpen) => {
|
|
1535
1652
|
if (isOpen !== $openDropdowns?.has(controllerId)) {
|
|
1536
1653
|
if (isOpen) {
|
|
1654
|
+
updateVectorPopoverBox();
|
|
1537
1655
|
// Check if the selected vector image is valid
|
|
1538
1656
|
if (value?.name && value.url) {
|
|
1539
1657
|
// Create a temporary image to test if it loads
|
|
@@ -1591,7 +1709,7 @@
|
|
|
1591
1709
|
<div class="flex min-w-0 flex-1 items-center gap-2 truncate">
|
|
1592
1710
|
{#if value?.url}
|
|
1593
1711
|
{#if hasSvgLoadError(value.name)}
|
|
1594
|
-
<IconAlertTriangle class="size-4 shrink-0 stroke-
|
|
1712
|
+
<IconAlertTriangle class="size-4 shrink-0 stroke-2 text-destructive" />
|
|
1595
1713
|
<span class="truncate text-start text-body text-foreground">
|
|
1596
1714
|
{value?.name || $t('editor.vector.select')}
|
|
1597
1715
|
</span>
|
|
@@ -1616,9 +1734,12 @@
|
|
|
1616
1734
|
</Popover.Trigger>
|
|
1617
1735
|
|
|
1618
1736
|
<Popover.Content
|
|
1737
|
+
collisionPadding={12}
|
|
1738
|
+
side={vectorPopoverSide}
|
|
1619
1739
|
align="end"
|
|
1620
1740
|
sideOffset={8}
|
|
1621
|
-
class="vector-input-popover z-50 flex h-[560px] w-picker flex-col overflow-hidden rounded-xl border border-border bg-popover p-0 text-popover-foreground outline-none"
|
|
1741
|
+
class="vector-input-popover z-50 flex h-[560px] w-picker max-w-[calc(100vw-16px)] flex-col overflow-hidden rounded-xl border border-border bg-popover p-0 text-popover-foreground outline-none"
|
|
1742
|
+
style={vectorPopoverStyle}
|
|
1622
1743
|
>
|
|
1623
1744
|
<div class="vector-popover-content flex h-full min-h-0 flex-col">
|
|
1624
1745
|
<div class="flex shrink-0 flex-col gap-3 px-4 pt-4 pb-3">
|
|
@@ -1638,7 +1759,7 @@
|
|
|
1638
1759
|
}
|
|
1639
1760
|
}}
|
|
1640
1761
|
>
|
|
1641
|
-
<IconCloudUpload class="size-4 stroke-
|
|
1762
|
+
<IconCloudUpload class="size-4 stroke-2" />
|
|
1642
1763
|
</IconButton>
|
|
1643
1764
|
</div>
|
|
1644
1765
|
<!-- Search input -->
|
|
@@ -1827,6 +1948,18 @@
|
|
|
1827
1948
|
</InputControllerRow>
|
|
1828
1949
|
</div>
|
|
1829
1950
|
|
|
1951
|
+
{#if showVectorModal}
|
|
1952
|
+
<!-- The browser of the editor (shared with the other file fields); the vector field takes SVG files only. -->
|
|
1953
|
+
<EditorFileBrowserOverlay
|
|
1954
|
+
portalTarget="props-editor-file-browser-portal"
|
|
1955
|
+
fileFilter="svg"
|
|
1956
|
+
instanceId={`vector-input-${controllerId}`}
|
|
1957
|
+
addToEditorLabel={$t('editor.file.useFile')}
|
|
1958
|
+
onClose={closeVectorFileBrowser}
|
|
1959
|
+
on:select={handleVectorFileBrowserSelect}
|
|
1960
|
+
/>
|
|
1961
|
+
{/if}
|
|
1962
|
+
|
|
1830
1963
|
<style>
|
|
1831
1964
|
:global(.transition-border) {
|
|
1832
1965
|
transition: border-color 0.2s ease-in-out;
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
let {
|
|
10
10
|
open = false,
|
|
11
|
-
class: className = 'size-
|
|
11
|
+
class: className = 'size-3.5 shrink-0 stroke-[2.286] text-muted-foreground'
|
|
12
12
|
}: {
|
|
13
13
|
/** True while the list the trigger opens is open: the arrow points up. */
|
|
14
14
|
open?: boolean;
|
|
15
|
-
/** The size and colour of the arrow. */
|
|
15
|
+
/** The size and colour of the arrow. The default is the Figma one: 14 px, drawn with the 1.333 px stroke of every icon (`stroke-[2.286]` in the 24-unit viewBox). */
|
|
16
16
|
class?: string;
|
|
17
17
|
} = $props();
|
|
18
18
|
</script>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type $$ComponentProps = {
|
|
2
2
|
/** True while the list the trigger opens is open: the arrow points up. */
|
|
3
3
|
open?: boolean;
|
|
4
|
-
/** The size and colour of the arrow. */
|
|
4
|
+
/** The size and colour of the arrow. The default is the Figma one: 14 px, drawn with the 1.333 px stroke of every icon (`stroke-[2.286]` in the 24-unit viewBox). */
|
|
5
5
|
class?: string;
|
|
6
6
|
};
|
|
7
7
|
declare const DropdownChevron: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* The File Browser of the editor, laid over the props panel: the white surface of the panel, a header with the title
|
|
4
|
+
* and the X that closes it (at the end, centred in the height of the header, as in Figma), and the File Browser under
|
|
5
|
+
* it. Every control that picks a file (a file, an image, a vector) opens its browser through this, so they look and
|
|
6
|
+
* behave the same.
|
|
7
|
+
*
|
|
8
|
+
* The control fixes the type of file (`fileFilter`): the browser then draws no "Filter by" (the user cannot change the
|
|
9
|
+
* type) and the upload takes only that type. `fileFilter="all"` (any file) keeps the filter.
|
|
10
|
+
*/
|
|
11
|
+
import { Portal } from '@widgetic/design-system/components';
|
|
12
|
+
import { FileBrowser } from '@widgetic/file-browser';
|
|
13
|
+
import { IconX } from '@widgetic/design-system/icons';
|
|
14
|
+
import { useEditorMediaLibrary } from '../../../mediaLibraryContext';
|
|
15
|
+
import { useEditorLanguage } from '../../../i18n/language';
|
|
16
|
+
|
|
17
|
+
/** Where the overlay is drawn: the panel's own host (it then fills the panel), or any other element or id (a dialog). */
|
|
18
|
+
export let portalTarget: string | HTMLElement = 'portal-element';
|
|
19
|
+
/** The type of file the control takes: it decides what the browser lists, offers to filter by, and accepts as upload. */
|
|
20
|
+
export let fileFilter: 'all' | 'image' | 'video' | 'audio' | 'document' | 'font' | 'svg' = 'all';
|
|
21
|
+
/** Tells this browser from the others on the page (it keeps its own folder and sort between visits). */
|
|
22
|
+
export let instanceId: string;
|
|
23
|
+
/** The file the control has now: the browser keeps "use" disabled until a different one is picked. */
|
|
24
|
+
export let activeFileId: string | null = null;
|
|
25
|
+
/** The text of the button that hands the picked file to the control. */
|
|
26
|
+
export let addToEditorLabel: string | undefined = undefined;
|
|
27
|
+
/** Called when the user closes the browser without picking (the X, or a click outside when it is a dialog). */
|
|
28
|
+
export let onClose: () => void = () => {};
|
|
29
|
+
|
|
30
|
+
// The media library the editor was given (a partner's own storage, for instance), read through a getter because it
|
|
31
|
+
// reaches this component through context.
|
|
32
|
+
const getEditorMediaLibrary = useEditorMediaLibrary();
|
|
33
|
+
// The words of the editor in the language of the page, and the share of them that belongs to the File Browser inside it.
|
|
34
|
+
const { t, fileBrowser: fileBrowserLanguage } = useEditorLanguage();
|
|
35
|
+
|
|
36
|
+
/** Full-panel overlay when portaled to the props editor panel (not the document body). */
|
|
37
|
+
$: fillEditorPanel =
|
|
38
|
+
portalTarget === 'props-editor-file-browser-portal' ||
|
|
39
|
+
(portalTarget instanceof HTMLElement && portalTarget.id === 'props-editor-file-browser-portal');
|
|
40
|
+
/** The type is fixed by the control, so there is nothing to filter by; only "any file" can still be narrowed down. */
|
|
41
|
+
$: showFilters = fileFilter === 'all';
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<Portal target={portalTarget}>
|
|
45
|
+
<!-- Embedded in the props panel: neutral surface only (no dark scrim). Standalone portal: transparent overlay. -->
|
|
46
|
+
<div
|
|
47
|
+
class="editor-file-browser-overlay pointer-events-auto absolute inset-0 z-[999999] flex flex-col overflow-hidden p-0 {fillEditorPanel
|
|
48
|
+
? 'bg-background'
|
|
49
|
+
: 'bg-transparent'}"
|
|
50
|
+
>
|
|
51
|
+
{#if !fillEditorPanel}
|
|
52
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
53
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
54
|
+
<div class="editor-file-browser-backdrop absolute inset-0 bg-transparent" on:click={onClose}></div>
|
|
55
|
+
{/if}
|
|
56
|
+
|
|
57
|
+
<div
|
|
58
|
+
class="editor-file-browser-dialog editor-file-browser-dialog-animate relative z-[999999] flex min-h-0 w-full flex-col overflow-hidden border border-border bg-background"
|
|
59
|
+
class:absolute={fillEditorPanel}
|
|
60
|
+
class:inset-0={fillEditorPanel}
|
|
61
|
+
class:h-full={fillEditorPanel}
|
|
62
|
+
class:max-w-none={fillEditorPanel}
|
|
63
|
+
class:rounded-none={fillEditorPanel}
|
|
64
|
+
class:shadow-none={fillEditorPanel}
|
|
65
|
+
class:border-0={fillEditorPanel}
|
|
66
|
+
class:max-w-[520px]={!fillEditorPanel}
|
|
67
|
+
class:flex-1={!fillEditorPanel}
|
|
68
|
+
class:min-h-[550px]={fillEditorPanel}
|
|
69
|
+
class:self-center={!fillEditorPanel}
|
|
70
|
+
class:mx-auto={!fillEditorPanel}
|
|
71
|
+
class:rounded-xl={!fillEditorPanel}
|
|
72
|
+
class:shadow-md={!fillEditorPanel}
|
|
73
|
+
>
|
|
74
|
+
<div
|
|
75
|
+
class="editor-file-browser-header relative flex h-[47px] shrink-0 items-center border-b border-border ps-4 pe-12"
|
|
76
|
+
>
|
|
77
|
+
<span class="text-body-medium text-foreground">{$t('editor.file.dialogTitle')}</span>
|
|
78
|
+
<!-- Figma: the X is a 24px button 12px from the end, centred in the height of the header -->
|
|
79
|
+
<button
|
|
80
|
+
type="button"
|
|
81
|
+
class="editor-file-browser-close press-feedback absolute top-1/2 end-3 flex size-6 -translate-y-1/2 items-center justify-center rounded-lg p-0 transition-colors duration-fast hover:bg-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"
|
|
82
|
+
on:click={onClose}
|
|
83
|
+
aria-label={$t('editor.file.closeDialog')}
|
|
84
|
+
>
|
|
85
|
+
<IconX class="size-4 stroke-2" />
|
|
86
|
+
</button>
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<div class="editor-file-browser-body flex min-h-0 flex-1 flex-col overflow-hidden">
|
|
90
|
+
<!-- With a media library the File Browser keeps nothing about this visit (the filter it was left on, the
|
|
91
|
+
folder it was left in) in the page's localStorage: that storage belongs to the page this editor sits in,
|
|
92
|
+
which can be a partner's. Without one (the Widgetic site) it remembers them, as it always did. -->
|
|
93
|
+
<FileBrowser
|
|
94
|
+
class="h-full min-h-0 flex-1"
|
|
95
|
+
{instanceId}
|
|
96
|
+
initialFilter={fileFilter}
|
|
97
|
+
restrictUpload={fileFilter !== 'all'}
|
|
98
|
+
{showFilters}
|
|
99
|
+
useDemoContent={false}
|
|
100
|
+
mediaLibrary={getEditorMediaLibrary()}
|
|
101
|
+
persistHistory={!getEditorMediaLibrary()}
|
|
102
|
+
allowSelecting={true}
|
|
103
|
+
showAddToEditor={true}
|
|
104
|
+
maxSelections={1}
|
|
105
|
+
{activeFileId}
|
|
106
|
+
{addToEditorLabel}
|
|
107
|
+
locale={$fileBrowserLanguage.locale ?? undefined}
|
|
108
|
+
messages={$fileBrowserLanguage.messages ?? null}
|
|
109
|
+
on:select
|
|
110
|
+
/>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
</Portal>
|
|
115
|
+
|
|
116
|
+
<style>
|
|
117
|
+
.editor-file-browser-dialog-animate {
|
|
118
|
+
transform-origin: center center;
|
|
119
|
+
animation: editor-file-browser-scale-in 0.22s cubic-bezier(0.4, 0, 0.2, 1);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@keyframes editor-file-browser-scale-in {
|
|
123
|
+
from {
|
|
124
|
+
transform: scale(0.94);
|
|
125
|
+
opacity: 0;
|
|
126
|
+
}
|
|
127
|
+
to {
|
|
128
|
+
transform: scale(1);
|
|
129
|
+
opacity: 1;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
</style>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const EditorFileBrowserOverlay: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
+
/** Where the overlay is drawn: the panel's own host (it then fills the panel), or any other element or id (a dialog). */ portalTarget?: string | HTMLElement;
|
|
16
|
+
/** The type of file the control takes: it decides what the browser lists, offers to filter by, and accepts as upload. */ fileFilter?: "all" | "image" | "video" | "audio" | "document" | "font" | "svg";
|
|
17
|
+
/** Tells this browser from the others on the page (it keeps its own folder and sort between visits). */ instanceId: string;
|
|
18
|
+
/** The file the control has now: the browser keeps "use" disabled until a different one is picked. */ activeFileId?: string | null;
|
|
19
|
+
/** The text of the button that hands the picked file to the control. */ addToEditorLabel?: string | undefined;
|
|
20
|
+
/** Called when the user closes the browser without picking (the X, or a click outside when it is a dialog). */ onClose?: () => void;
|
|
21
|
+
}, {
|
|
22
|
+
select: CustomEvent<any>;
|
|
23
|
+
} & {
|
|
24
|
+
[evt: string]: CustomEvent<any>;
|
|
25
|
+
}, {}, {}, string>;
|
|
26
|
+
type EditorFileBrowserOverlay = InstanceType<typeof EditorFileBrowserOverlay>;
|
|
27
|
+
export default EditorFileBrowserOverlay;
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
tabindex="-1"
|
|
115
115
|
>
|
|
116
116
|
<IconCheck
|
|
117
|
-
class="size-4 shrink-0 stroke-
|
|
117
|
+
class="size-4 shrink-0 stroke-2 {selected
|
|
118
118
|
? 'text-foreground opacity-100'
|
|
119
119
|
: 'opacity-0'}"
|
|
120
120
|
/>
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
tabindex="-1"
|
|
136
136
|
>
|
|
137
137
|
<IconCheck
|
|
138
|
-
class="size-4 shrink-0 stroke-
|
|
138
|
+
class="size-4 shrink-0 stroke-2 {selected
|
|
139
139
|
? 'text-foreground opacity-100'
|
|
140
140
|
: 'opacity-0'}"
|
|
141
141
|
/>
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
tabindex="-1"
|
|
61
61
|
>
|
|
62
62
|
<IconCheck
|
|
63
|
-
class="size-4 shrink-0 stroke-
|
|
63
|
+
class="size-4 shrink-0 stroke-2 {selected
|
|
64
64
|
? 'text-foreground opacity-100'
|
|
65
65
|
: 'opacity-0'}"
|
|
66
66
|
/>
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
onItemDelete(item, e);
|
|
83
83
|
}}
|
|
84
84
|
>
|
|
85
|
-
<IconTrash class="size-4 stroke-
|
|
85
|
+
<IconTrash class="size-4 stroke-2" />
|
|
86
86
|
</IconButton>
|
|
87
87
|
{/if}
|
|
88
88
|
</div>
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
tabindex="-1"
|
|
101
101
|
>
|
|
102
102
|
<IconCheck
|
|
103
|
-
class="size-4 shrink-0 stroke-
|
|
103
|
+
class="size-4 shrink-0 stroke-2 {selected
|
|
104
104
|
? 'text-foreground opacity-100'
|
|
105
105
|
: 'opacity-0'}"
|
|
106
106
|
/>
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
onItemDelete(item, e);
|
|
123
123
|
}}
|
|
124
124
|
>
|
|
125
|
-
<IconTrash class="size-4 stroke-
|
|
125
|
+
<IconTrash class="size-4 stroke-2" />
|
|
126
126
|
</IconButton>
|
|
127
127
|
{/if}
|
|
128
128
|
</div>
|
|
@@ -168,7 +168,7 @@
|
|
|
168
168
|
onItemDelete(item, e);
|
|
169
169
|
}}
|
|
170
170
|
>
|
|
171
|
-
<IconTrash class="size-3 stroke-[
|
|
171
|
+
<IconTrash class="size-3 stroke-[2.667]" />
|
|
172
172
|
</IconButton>
|
|
173
173
|
{/if}
|
|
174
174
|
</div>
|
|
@@ -205,7 +205,7 @@
|
|
|
205
205
|
onItemDelete(item, e);
|
|
206
206
|
}}
|
|
207
207
|
>
|
|
208
|
-
<IconTrash class="size-3 stroke-[
|
|
208
|
+
<IconTrash class="size-3 stroke-[2.667]" />
|
|
209
209
|
</IconButton>
|
|
210
210
|
{/if}
|
|
211
211
|
</div>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared surface + embedded input classes for input controllers whose text is editable.
|
|
3
|
+
* Hover and focus rings live on the outer surface; the inner control stays visually neutral.
|
|
4
|
+
*/
|
|
5
|
+
/** Default horizontal padding for a single-line editable field (matches Figma IC Number / Text). */
|
|
6
|
+
export declare const editableFieldSurfacePadding = "px-3";
|
|
7
|
+
/**
|
|
8
|
+
* Outer control surface: full-box hover, focus-within ring, soft accent fill.
|
|
9
|
+
* Pass extra layout classes (gap, pe-2, min-h-9, etc.) via `class` on the same element.
|
|
10
|
+
*/
|
|
11
|
+
export declare const editableFieldSurfaceClass = "flex h-9 w-full min-w-0 items-center rounded-lg bg-accent transition-colors duration-fast hover:bg-accent-hover focus-within:outline-hidden focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background disabled:pointer-events-none disabled:opacity-50";
|
|
12
|
+
/**
|
|
13
|
+
* DS `Input` (and similar) embedded inside {@link editableFieldSurfaceClass}: no inner hover pill.
|
|
14
|
+
*/
|
|
15
|
+
export declare const embeddedInputClass = "h-full w-full min-w-0 border-0 bg-transparent px-0 text-body text-foreground shadow-none placeholder:text-muted-foreground hover:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared surface + embedded input classes for input controllers whose text is editable.
|
|
3
|
+
* Hover and focus rings live on the outer surface; the inner control stays visually neutral.
|
|
4
|
+
*/
|
|
5
|
+
/** Default horizontal padding for a single-line editable field (matches Figma IC Number / Text). */
|
|
6
|
+
export const editableFieldSurfacePadding = 'px-3';
|
|
7
|
+
/**
|
|
8
|
+
* Outer control surface: full-box hover, focus-within ring, soft accent fill.
|
|
9
|
+
* Pass extra layout classes (gap, pe-2, min-h-9, etc.) via `class` on the same element.
|
|
10
|
+
*/
|
|
11
|
+
export const editableFieldSurfaceClass = `flex h-9 w-full min-w-0 items-center rounded-lg bg-accent transition-colors duration-fast hover:bg-accent-hover focus-within:outline-hidden focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background disabled:pointer-events-none disabled:opacity-50`;
|
|
12
|
+
/**
|
|
13
|
+
* DS `Input` (and similar) embedded inside {@link editableFieldSurfaceClass}: no inner hover pill.
|
|
14
|
+
*/
|
|
15
|
+
export const embeddedInputClass = 'h-full w-full min-w-0 border-0 bg-transparent px-0 text-body text-foreground shadow-none placeholder:text-muted-foreground hover:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0';
|
|
@@ -7,3 +7,4 @@
|
|
|
7
7
|
// Export shared components
|
|
8
8
|
export { default as RecentItemsSection } from './RecentItemsSection.svelte';
|
|
9
9
|
export { default as ItemGrid } from './ItemGrid.svelte';
|
|
10
|
+
export { editableFieldSurfaceClass, editableFieldSurfacePadding, embeddedInputClass } from './editableFieldClasses';
|
|
@@ -1,23 +1,55 @@
|
|
|
1
1
|
<!-- Figma Calendar 210:3967 / Calendar Day 210:3450 — editor panel calendar sizing. -->
|
|
2
|
+
<!--
|
|
3
|
+
The rules name the attributes Bits UI writes on the calendar: `data-calendar-*` on the single calendar,
|
|
4
|
+
`data-range-calendar-*` on the range calendar, and `data-bits-day` on the day of both.
|
|
5
|
+
A rule written for an attribute that is not in the DOM does nothing, and then the cells keep the 36px of the design
|
|
6
|
+
system and seven of them (252px) do not fit the 224px the Figma popover leaves for them.
|
|
7
|
+
-->
|
|
2
8
|
<style>
|
|
9
|
+
:global(.calendar-editor-fit [data-calendar-grid-row]),
|
|
10
|
+
:global(.calendar-editor-fit [data-range-calendar-grid-row]) {
|
|
11
|
+
display: flex;
|
|
12
|
+
width: 100%;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
gap: 0;
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
max-width: 14rem;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:global(.calendar-editor-fit [data-calendar-head-cell]),
|
|
20
|
+
:global(.calendar-editor-fit [data-calendar-cell]),
|
|
21
|
+
:global(.calendar-editor-fit [data-range-calendar-head-cell]),
|
|
22
|
+
:global(.calendar-editor-fit [data-range-calendar-cell]) {
|
|
23
|
+
height: 2rem !important;
|
|
24
|
+
width: 2rem !important;
|
|
25
|
+
min-height: 2rem !important;
|
|
26
|
+
min-width: 2rem !important;
|
|
27
|
+
max-height: 2rem !important;
|
|
28
|
+
max-width: 2rem !important;
|
|
29
|
+
flex: 0 0 2rem;
|
|
30
|
+
padding: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
3
33
|
:global(.calendar-editor-fit [data-bits-day]) {
|
|
4
|
-
height: 2rem;
|
|
5
|
-
width: 2rem;
|
|
6
|
-
min-height: 2rem;
|
|
7
|
-
min-width: 2rem;
|
|
34
|
+
height: 2rem !important;
|
|
35
|
+
width: 2rem !important;
|
|
36
|
+
min-height: 2rem !important;
|
|
37
|
+
min-width: 2rem !important;
|
|
38
|
+
max-height: 2rem !important;
|
|
39
|
+
max-width: 2rem !important;
|
|
8
40
|
border-radius: var(--radius-lg);
|
|
9
41
|
font-size: inherit;
|
|
10
42
|
line-height: inherit;
|
|
11
43
|
}
|
|
12
44
|
|
|
13
|
-
:global(.calendar-editor-fit [data-
|
|
14
|
-
:global(.calendar-editor-fit
|
|
15
|
-
height: 1.5rem;
|
|
16
|
-
|
|
45
|
+
:global(.calendar-editor-fit [data-calendar-head-cell]),
|
|
46
|
+
:global(.calendar-editor-fit [data-range-calendar-head-cell]) {
|
|
47
|
+
height: 1.5rem !important;
|
|
48
|
+
min-height: 1.5rem !important;
|
|
49
|
+
max-height: 1.5rem !important;
|
|
17
50
|
font-weight: 500;
|
|
18
51
|
}
|
|
19
52
|
|
|
20
|
-
:global(.calendar-editor-fit [data-bits-calendar-row]),
|
|
21
53
|
:global(.calendar-editor-fit .mt-2.w-full) {
|
|
22
54
|
margin-top: 0.25rem;
|
|
23
55
|
}
|