@widgetic/editor 4.1.17 → 4.1.19
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 +79 -16
- package/dist/components/editors/CompositionEditorApp.svelte +71 -35
- package/dist/components/editors/CompositionEditorApp.svelte.d.ts +3 -1
- package/dist/components/editors/ContentTabBulkDrop.svelte +268 -0
- package/dist/components/editors/ContentTabBulkDrop.svelte.d.ts +37 -0
- package/dist/components/editors/EmbedAssistantPanel.svelte +303 -0
- package/dist/components/editors/EmbedAssistantPanel.svelte.d.ts +29 -0
- package/dist/components/editors/EmbedEditor.svelte +221 -15
- package/dist/components/editors/EmbedEditor.svelte.d.ts +31 -3
- package/dist/components/editors/PropsEditor.svelte +326 -37
- package/dist/components/editors/PropsEditor.svelte.d.ts +11 -0
- package/dist/components/editors/propsEditorContentStateFlatten.d.ts +12 -0
- package/dist/components/editors/propsEditorContentStateFlatten.js +40 -0
- package/dist/components/ic/AngleInputController.svelte +9 -5
- package/dist/components/ic/BrowserInputController.svelte +208 -132
- package/dist/components/ic/BrowserInputController.svelte.d.ts +2 -0
- package/dist/components/ic/CheckboxInputController.svelte +11 -0
- package/dist/components/ic/ColorPickerInputController.svelte +122 -49
- package/dist/components/ic/DatePickerInputController.svelte +23 -13
- package/dist/components/ic/FixedPositionInputController.svelte +1 -1
- package/dist/components/ic/FontInputController.svelte +48 -47
- package/dist/components/ic/InputControllerHeader.svelte +5 -4
- package/dist/components/ic/KnowledgeDocumentsInputController.svelte +20 -7
- package/dist/components/ic/NumberControls.svelte +163 -35
- package/dist/components/ic/PositionInputController.svelte +24 -15
- package/dist/components/ic/RadioGroupInputController.svelte +11 -0
- package/dist/components/ic/RangeCalendarInputController.svelte +73 -28
- package/dist/components/ic/RoundedCornersInputController.svelte +2 -2
- package/dist/components/ic/SliderInputController.svelte +11 -4
- package/dist/components/ic/TextAreaInputController.svelte +620 -327
- package/dist/components/ic/TextAreaPreviewInputController.svelte +53 -64
- package/dist/components/ic/TextInputController.svelte +15 -2
- package/dist/components/ic/TimeInputController.svelte +1 -1
- package/dist/components/ic/VectorInputController.svelte +152 -20
- package/dist/components/ic/numberControlsValueArea.d.ts +29 -0
- package/dist/components/ic/numberControlsValueArea.js +51 -0
- package/dist/components/ic/optionGroupCardPointerDown.d.ts +9 -0
- package/dist/components/ic/optionGroupCardPointerDown.js +20 -0
- 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 +174 -0
- package/dist/components/ic/shared/EditorFileBrowserOverlay.svelte.d.ts +30 -0
- package/dist/components/ic/shared/EditorSelectedFilePreviewOverlay.svelte +34 -0
- package/dist/components/ic/shared/EditorSelectedFilePreviewOverlay.svelte.d.ts +24 -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/fileBrowserOverlayEscape.d.ts +29 -0
- package/dist/components/ic/shared/fileBrowserOverlayEscape.js +21 -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/composition/compositionApi.d.ts +16 -0
- package/dist/composition/compositionApi.js +16 -1
- package/dist/composition/compositionEditorController.d.ts +46 -0
- package/dist/composition/compositionEditorController.js +277 -5
- package/dist/composition/compositionEditorSchemaCache.d.ts +35 -0
- package/dist/composition/compositionEditorSchemaCache.js +82 -0
- package/dist/contentBulkDrop/applyContentPlan.d.ts +18 -0
- package/dist/contentBulkDrop/applyContentPlan.js +55 -0
- package/dist/contentBulkDrop/bulkDropSummary.d.ts +4 -0
- package/dist/contentBulkDrop/bulkDropSummary.js +12 -0
- package/dist/contentBulkDrop/dragIntent.d.ts +7 -0
- package/dist/contentBulkDrop/dragIntent.js +24 -0
- package/dist/contentBulkDrop/filterDropFiles.d.ts +2 -0
- package/dist/contentBulkDrop/filterDropFiles.js +21 -0
- package/dist/contentBulkDrop/formatFileSize.d.ts +2 -0
- package/dist/contentBulkDrop/formatFileSize.js +13 -0
- package/dist/contentBulkDrop/types.d.ts +34 -0
- package/dist/contentBulkDrop/types.js +1 -0
- package/dist/contentBulkDrop/uploadQueue.d.ts +41 -0
- package/dist/contentBulkDrop/uploadQueue.js +114 -0
- package/dist/drafts/compositionDraft.d.ts +65 -0
- package/dist/drafts/compositionDraft.js +136 -0
- package/dist/drafts/compositionEditorViewState.d.ts +9 -0
- package/dist/drafts/compositionEditorViewState.js +33 -0
- package/dist/drafts/draftJournal.d.ts +59 -0
- package/dist/drafts/draftJournal.js +261 -0
- package/dist/embed/__fixtures__/gatewayGeneratedEmbedCodes.json +25 -0
- package/dist/embed/__fixtures__/generatedEmbedCodes.json +320 -0
- package/dist/embed/parseCompositionEmbedCode.d.ts +21 -0
- package/dist/embed/parseCompositionEmbedCode.js +376 -0
- package/dist/embedAssistant/embedAssistantEvents.d.ts +22 -0
- package/dist/embedAssistant/embedAssistantEvents.js +39 -0
- package/dist/embedAssistant/embedAssistantStream.d.ts +30 -0
- package/dist/embedAssistant/embedAssistantStream.js +125 -0
- package/dist/embedAssistant/highlightTiming.d.ts +1 -0
- package/dist/embedAssistant/highlightTiming.js +6 -0
- package/dist/embedAssistant/types.d.ts +27 -0
- package/dist/embedAssistant/types.js +1 -0
- package/dist/i18n/labels.js +8 -4
- package/dist/i18n/language.d.ts +297 -3
- package/dist/i18n/messages.d.ts +38 -1
- package/dist/i18n/messages.js +40 -1
- package/dist/i18n/translate.d.ts +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -0
- package/dist/utils/FontManager.d.ts +2 -0
- package/dist/utils/FontManager.js +16 -1
- package/dist/utils/angleMath.d.ts +2 -0
- package/dist/utils/angleMath.js +6 -0
- package/dist/utils/isEditableEventTarget.d.ts +5 -0
- package/dist/utils/isEditableEventTarget.js +25 -0
- package/dist/utils/linkUrlValidation.d.ts +17 -0
- package/dist/utils/linkUrlValidation.js +120 -0
- package/dist/utils/mediaFileValue.d.ts +12 -0
- package/dist/utils/mediaFileValue.js +24 -0
- package/dist/utils/placeRichTextCaretAtDocumentEnd.d.ts +11 -0
- package/dist/utils/placeRichTextCaretAtDocumentEnd.js +26 -0
- package/package.json +6 -6
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
* Shadcn UI checkbox components for consistent styling and behavior
|
|
25
25
|
*/
|
|
26
26
|
import { Label, Checkbox } from '@widgetic/design-system/components';
|
|
27
|
+
import { shouldPreventOptionGroupBackgroundFocusSteal } from './optionGroupCardPointerDown';
|
|
27
28
|
|
|
28
29
|
export let value: CheckboxInputControllerProps['value'];
|
|
29
30
|
export let onChange: CheckboxInputControllerProps['onChange'];
|
|
@@ -68,6 +69,14 @@
|
|
|
68
69
|
* Handles click on the entire row
|
|
69
70
|
* @param optionValue - The value to toggle
|
|
70
71
|
*/
|
|
72
|
+
|
|
73
|
+
/** `mousedown` default moves focus to `body` on non-focusable targets; cancel only that (not pointerdown). */
|
|
74
|
+
function handleCardMouseDown(event: MouseEvent) {
|
|
75
|
+
if (shouldPreventOptionGroupBackgroundFocusSteal(event.target)) {
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
71
80
|
function handleRowClick(optionValue: string) {
|
|
72
81
|
// Toggle the checkbox
|
|
73
82
|
const isCurrentlySelected = selectedValues.includes(optionValue);
|
|
@@ -106,9 +115,11 @@
|
|
|
106
115
|
</script>
|
|
107
116
|
|
|
108
117
|
<div class="flex flex-col gap-1">
|
|
118
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
109
119
|
<div
|
|
110
120
|
class="flex w-full flex-col gap-2 rounded-lg bg-accent px-3 py-4 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"
|
|
111
121
|
onfocusin={onFocus}
|
|
122
|
+
onmousedowncapture={handleCardMouseDown}
|
|
112
123
|
>
|
|
113
124
|
{#each options as option}
|
|
114
125
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
// Shadcn UI Components
|
|
54
54
|
import { Input } from '@widgetic/design-system/components';
|
|
55
55
|
import InputControllerRow from './InputControllerRow.svelte';
|
|
56
|
+
import { editableFieldSurfaceClass, embeddedInputClass } from './shared/editableFieldClasses';
|
|
56
57
|
|
|
57
58
|
// Icons from Widgetic Design System
|
|
58
59
|
import CheckerBoardBackground from '../ui/checkerboard-background/CheckerboardBackground.svelte';
|
|
@@ -150,6 +151,8 @@
|
|
|
150
151
|
|
|
151
152
|
// Local open state — not derived from store
|
|
152
153
|
let open = false;
|
|
154
|
+
/** Ignore scroll events right after opening (bits-ui / layout nudges). */
|
|
155
|
+
let lastPickerOpenTimestamp = 0;
|
|
153
156
|
|
|
154
157
|
// Listen for "close all color pickers except me" events from other instances
|
|
155
158
|
function onCloseOtherPickers(e: CustomEvent<string>) {
|
|
@@ -471,6 +474,11 @@
|
|
|
471
474
|
|
|
472
475
|
if (event.key === 'Escape') {
|
|
473
476
|
event.preventDefault();
|
|
477
|
+
if (open) {
|
|
478
|
+
handleToggle(false);
|
|
479
|
+
triggerRef?.focus();
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
474
482
|
closeAutosuggestions();
|
|
475
483
|
if (!currentInputValue.trim()) {
|
|
476
484
|
restoreCurrentColor();
|
|
@@ -514,6 +522,7 @@
|
|
|
514
522
|
if (isOpen === open) return;
|
|
515
523
|
|
|
516
524
|
if (!isOpen) {
|
|
525
|
+
popoverStyle = '';
|
|
517
526
|
saveToRecentColors(value, lastKnownOpacity);
|
|
518
527
|
if (isColorSelectOpen) {
|
|
519
528
|
dispatch('colorselectmodalclose');
|
|
@@ -523,11 +532,20 @@
|
|
|
523
532
|
// Close all other color pickers before opening this one
|
|
524
533
|
window.dispatchEvent(new CustomEvent('widgetic:close-color-pickers', { detail: instanceId }));
|
|
525
534
|
closeAutosuggestions();
|
|
535
|
+
recentColors = recentColorsUtil.getRecentColors();
|
|
526
536
|
dispatch('colorselectmodalopen');
|
|
527
537
|
isColorSelectOpen = true;
|
|
538
|
+
lastPickerOpenTimestamp = performance.now();
|
|
539
|
+
// Measure after the swatch is in view so fixed coords match what the user sees (panels can scroll on open).
|
|
540
|
+
try {
|
|
541
|
+
triggerRef?.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
542
|
+
} catch (scrollError) {
|
|
543
|
+
console.error('[ColorPicker] scrollIntoView before positioning failed:', scrollError);
|
|
544
|
+
}
|
|
528
545
|
updatePopoverPosition();
|
|
529
546
|
// Re-position after portal is mounted and layout stabilizes
|
|
530
547
|
tick().then(() => {
|
|
548
|
+
updatePopoverPosition();
|
|
531
549
|
requestAnimationFrame(updatePopoverPosition);
|
|
532
550
|
});
|
|
533
551
|
}
|
|
@@ -567,6 +585,17 @@
|
|
|
567
585
|
if (scrollTarget instanceof Element && scrollTarget.closest('[data-allow-scroll="true"]')) {
|
|
568
586
|
return;
|
|
569
587
|
}
|
|
588
|
+
if (open && performance.now() - lastPickerOpenTimestamp < 300) {
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
if (
|
|
592
|
+
open &&
|
|
593
|
+
scrollTarget instanceof Element &&
|
|
594
|
+
(scrollTarget.closest('.color-picker-popover-content') ||
|
|
595
|
+
scrollTarget.closest('.color-picker-wrapper'))
|
|
596
|
+
) {
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
570
599
|
|
|
571
600
|
// Close both suggestions and color picker
|
|
572
601
|
if (suggestionVisible || open) {
|
|
@@ -993,6 +1022,38 @@
|
|
|
993
1022
|
// shadow root, so a listener on the window alone does not hear about those)
|
|
994
1023
|
let stopListeningForScroll: () => void = () => {};
|
|
995
1024
|
|
|
1025
|
+
function handleWindowKeyDown(event: KeyboardEvent) {
|
|
1026
|
+
if (!open) return;
|
|
1027
|
+
if (event.key === 'Escape') {
|
|
1028
|
+
event.preventDefault();
|
|
1029
|
+
event.stopPropagation();
|
|
1030
|
+
handleToggle(false);
|
|
1031
|
+
triggerRef?.focus();
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
function handleWheelWhileOpen(event: WheelEvent) {
|
|
1036
|
+
if (!open) return;
|
|
1037
|
+
if (performance.now() - lastPickerOpenTimestamp < 300) return;
|
|
1038
|
+
const target = event.target;
|
|
1039
|
+
if (target instanceof Element && target.closest('.color-picker-popover-content')) return;
|
|
1040
|
+
handleToggle(false);
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
function handlePointerDownOutside(event: MouseEvent) {
|
|
1044
|
+
if (!open) return;
|
|
1045
|
+
const target = event.target;
|
|
1046
|
+
if (!(target instanceof Element)) return;
|
|
1047
|
+
if (
|
|
1048
|
+
target.closest('.color-picker-popover-content') ||
|
|
1049
|
+
target.closest('.color-preview-button') ||
|
|
1050
|
+
target.closest('.color-input-main-container')
|
|
1051
|
+
) {
|
|
1052
|
+
return;
|
|
1053
|
+
}
|
|
1054
|
+
handleToggle(false);
|
|
1055
|
+
}
|
|
1056
|
+
|
|
996
1057
|
// Sets up event listeners when the component mounts
|
|
997
1058
|
onMount(() => {
|
|
998
1059
|
initializeColor();
|
|
@@ -1000,7 +1061,10 @@
|
|
|
1000
1061
|
window.addEventListener('mousemove', handleGlobalMouseMove);
|
|
1001
1062
|
window.addEventListener('keydown', handlePopupKeyDown);
|
|
1002
1063
|
window.addEventListener('keyup', handlePopupKeyUp);
|
|
1003
|
-
|
|
1064
|
+
window.addEventListener('keydown', handleWindowKeyDown, true);
|
|
1065
|
+
window.addEventListener('mousedown', handlePointerDownOutside, true);
|
|
1066
|
+
window.addEventListener('wheel', handleWheelWhileOpen, { capture: true, passive: true });
|
|
1067
|
+
stopListeningForScroll = listenForScroll(controllerRoot, handleScroll);
|
|
1004
1068
|
window.addEventListener('widgetic:close-color-pickers', onCloseOtherPickers as EventListener);
|
|
1005
1069
|
});
|
|
1006
1070
|
|
|
@@ -1012,6 +1076,9 @@
|
|
|
1012
1076
|
window.removeEventListener('mousemove', handleGlobalMouseMove);
|
|
1013
1077
|
window.removeEventListener('keydown', handlePopupKeyDown);
|
|
1014
1078
|
window.removeEventListener('keyup', handlePopupKeyUp);
|
|
1079
|
+
window.removeEventListener('keydown', handleWindowKeyDown, true);
|
|
1080
|
+
window.removeEventListener('mousedown', handlePointerDownOutside, true);
|
|
1081
|
+
window.removeEventListener('wheel', handleWheelWhileOpen, true);
|
|
1015
1082
|
stopListeningForScroll();
|
|
1016
1083
|
window.removeEventListener(
|
|
1017
1084
|
'widgetic:close-color-pickers',
|
|
@@ -1143,6 +1210,7 @@
|
|
|
1143
1210
|
}
|
|
1144
1211
|
|
|
1145
1212
|
let inputRef: HTMLDivElement;
|
|
1213
|
+
let controllerRoot: HTMLDivElement;
|
|
1146
1214
|
|
|
1147
1215
|
/**
|
|
1148
1216
|
* Restores the current color value when input is invalid or empty
|
|
@@ -1208,30 +1276,32 @@
|
|
|
1208
1276
|
// Track trigger position for fixed-position popover
|
|
1209
1277
|
let triggerRef: HTMLDivElement;
|
|
1210
1278
|
let popoverStyle = '';
|
|
1279
|
+
let popoverContentRef: HTMLDivElement | null = null;
|
|
1280
|
+
|
|
1281
|
+
const popoverGapPx = 8;
|
|
1282
|
+
const popoverWidthPx = 256;
|
|
1211
1283
|
|
|
1212
1284
|
function updatePopoverPosition() {
|
|
1213
1285
|
if (!triggerRef) return;
|
|
1214
|
-
const
|
|
1286
|
+
const swatchRect = triggerRef.getBoundingClientRect();
|
|
1215
1287
|
// Guard: if trigger hasn't been laid out yet, defer
|
|
1216
|
-
if (
|
|
1288
|
+
if (swatchRect.width === 0 && swatchRect.height === 0) {
|
|
1217
1289
|
requestAnimationFrame(updatePopoverPosition);
|
|
1218
1290
|
return;
|
|
1219
1291
|
}
|
|
1220
|
-
const popoverHeight = 420;
|
|
1221
|
-
const spaceBelow = window.innerHeight -
|
|
1222
|
-
const spaceAbove =
|
|
1223
|
-
const openAbove = spaceBelow < popoverHeight +
|
|
1224
|
-
const top = openAbove
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
popoverStyle = `top: ${top}px; right: ${right}px;`; // rtl-ok: the end edge of a left to right field is its right edge
|
|
1234
|
-
}
|
|
1292
|
+
const popoverHeight = popoverContentRef?.offsetHeight ?? 420;
|
|
1293
|
+
const spaceBelow = window.innerHeight - swatchRect.bottom;
|
|
1294
|
+
const spaceAbove = swatchRect.top;
|
|
1295
|
+
const openAbove = spaceBelow < popoverHeight + popoverGapPx && spaceAbove > spaceBelow;
|
|
1296
|
+
const top = openAbove
|
|
1297
|
+
? Math.round(swatchRect.top - popoverHeight - popoverGapPx)
|
|
1298
|
+
: Math.round(swatchRect.bottom + popoverGapPx);
|
|
1299
|
+
// Anchor horizontally to the swatch: centered when it fits, clamped inside the viewport otherwise.
|
|
1300
|
+
let left = Math.round(swatchRect.left + swatchRect.width / 2 - popoverWidthPx / 2);
|
|
1301
|
+
const horizontalMargin = 8;
|
|
1302
|
+
const maxLeft = window.innerWidth - popoverWidthPx - horizontalMargin;
|
|
1303
|
+
left = Math.max(horizontalMargin, Math.min(left, maxLeft));
|
|
1304
|
+
popoverStyle = `top: ${top}px; left: ${left}px;`; /* rtl-ok: viewport coords from getBoundingClientRect; popover is dir=ltr */
|
|
1235
1305
|
}
|
|
1236
1306
|
|
|
1237
1307
|
// Position is calculated in handleToggle after tick()
|
|
@@ -1268,16 +1338,34 @@
|
|
|
1268
1338
|
// Add these computed styles for layout
|
|
1269
1339
|
$: opacityBarWidthPx = `${pickerSize}px`;
|
|
1270
1340
|
$: recentColorsMaxWidth = `${pickerSize + sliderWidth}px`;
|
|
1341
|
+
|
|
1342
|
+
$: if (open && popoverContentRef) {
|
|
1343
|
+
tick().then(() => {
|
|
1344
|
+
updatePopoverPosition();
|
|
1345
|
+
requestAnimationFrame(updatePopoverPosition);
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1271
1348
|
</script>
|
|
1272
1349
|
|
|
1273
1350
|
<!-- Color Picker Input Controller Container -->
|
|
1274
1351
|
<!-- Figma IC Color 172:116, Color Picker 211:3877 -->
|
|
1275
|
-
<div class="color-picker-input-controller-ct">
|
|
1352
|
+
<div class="color-picker-input-controller-ct" bind:this={controllerRoot}>
|
|
1276
1353
|
<!-- Input Controller Header -->
|
|
1277
1354
|
<InputControllerRow {label} {helpText}>
|
|
1278
1355
|
<!-- Input Controller Container -->
|
|
1279
1356
|
<div
|
|
1280
|
-
class="color-input-main-container
|
|
1357
|
+
class="color-input-main-container {editableFieldSurfaceClass} gap-2 pe-2 ps-3"
|
|
1358
|
+
role="presentation"
|
|
1359
|
+
onclick={(e) => {
|
|
1360
|
+
const hexInputElement = inputRef?.querySelector('input');
|
|
1361
|
+
if (
|
|
1362
|
+
hexInputElement instanceof HTMLInputElement &&
|
|
1363
|
+
e.target instanceof Element &&
|
|
1364
|
+
!e.target.closest('.color-preview-button')
|
|
1365
|
+
) {
|
|
1366
|
+
hexInputElement.focus();
|
|
1367
|
+
}
|
|
1368
|
+
}}
|
|
1281
1369
|
>
|
|
1282
1370
|
<!-- Hex Input Container -->
|
|
1283
1371
|
<div class="hex-input-container min-w-0 flex-1" bind:this={inputRef}>
|
|
@@ -1286,7 +1374,7 @@
|
|
|
1286
1374
|
bind:this={inputComponent}
|
|
1287
1375
|
type="text"
|
|
1288
1376
|
dir="ltr"
|
|
1289
|
-
class="
|
|
1377
|
+
class="{embeddedInputClass} p-0"
|
|
1290
1378
|
value={hexInput}
|
|
1291
1379
|
onfocus={(e) => {
|
|
1292
1380
|
dispatch('focus', e);
|
|
@@ -1338,6 +1426,12 @@
|
|
|
1338
1426
|
e.stopPropagation();
|
|
1339
1427
|
handleToggle(!open);
|
|
1340
1428
|
}}
|
|
1429
|
+
onkeydown={(e) => {
|
|
1430
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
1431
|
+
e.preventDefault();
|
|
1432
|
+
handleToggle(!open);
|
|
1433
|
+
}
|
|
1434
|
+
}}
|
|
1341
1435
|
>
|
|
1342
1436
|
<CheckerBoardBackground
|
|
1343
1437
|
className="absolute inset-0 w-full h-full pointer-events-none rounded-[inherit]"
|
|
@@ -1410,15 +1504,12 @@
|
|
|
1410
1504
|
style="position: fixed; inset: 0; z-index: 99999; pointer-events: none;"
|
|
1411
1505
|
>
|
|
1412
1506
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
1413
|
-
<div
|
|
1414
|
-
class="color-picker-backdrop"
|
|
1415
|
-
style="z-index: 1;"
|
|
1416
|
-
onmousedown={() => handleToggle(false)}
|
|
1417
|
-
></div>
|
|
1507
|
+
<div class="color-picker-backdrop" style="z-index: 1;" aria-hidden="true"></div>
|
|
1418
1508
|
|
|
1419
1509
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
1420
1510
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
1421
1511
|
<div
|
|
1512
|
+
bind:this={popoverContentRef}
|
|
1422
1513
|
class="color-picker-popover-content w-64 rounded-xl border border-border bg-popover p-3 text-popover-foreground shadow-none"
|
|
1423
1514
|
dir="ltr"
|
|
1424
1515
|
style="{popoverStyle} z-index: 2;"
|
|
@@ -1427,7 +1518,7 @@
|
|
|
1427
1518
|
>
|
|
1428
1519
|
<!-- Color Picker Popover Content Wrapper -->
|
|
1429
1520
|
<div class="color-picker-popover-content-wrapper flex flex-col gap-3">
|
|
1430
|
-
{#if saveRecentColors
|
|
1521
|
+
{#if saveRecentColors}
|
|
1431
1522
|
<!-- Recent Colors Container -->
|
|
1432
1523
|
<div class="recent-colors-container w-full">
|
|
1433
1524
|
{#if recentColors.length > 0}
|
|
@@ -1435,8 +1526,7 @@
|
|
|
1435
1526
|
{#each recentColors.slice(0, 5) as { color, alpha }, i}
|
|
1436
1527
|
<button
|
|
1437
1528
|
type="button"
|
|
1438
|
-
class="
|
|
1439
|
-
style="animation-delay: {i * 0.05}s"
|
|
1529
|
+
class="recent-color-swatch relative size-10 overflow-hidden rounded-lg border border-border"
|
|
1440
1530
|
onclick={() => {
|
|
1441
1531
|
try {
|
|
1442
1532
|
isInternalUpdate = true;
|
|
@@ -1534,7 +1624,7 @@
|
|
|
1534
1624
|
type="number"
|
|
1535
1625
|
min="0"
|
|
1536
1626
|
max="100"
|
|
1537
|
-
class="
|
|
1627
|
+
class="{embeddedInputClass} p-0 text-center [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"
|
|
1538
1628
|
value={opacityPercentage}
|
|
1539
1629
|
oninput={(e) => {
|
|
1540
1630
|
e.stopPropagation();
|
|
@@ -1601,12 +1691,12 @@
|
|
|
1601
1691
|
cursor: grabbing !important;
|
|
1602
1692
|
}
|
|
1603
1693
|
|
|
1604
|
-
/* Backdrop
|
|
1694
|
+
/* Backdrop is visual only — wheel events pass through; outside clicks use capture on window. */
|
|
1605
1695
|
.color-picker-backdrop {
|
|
1606
1696
|
position: fixed;
|
|
1607
1697
|
inset: 0;
|
|
1608
1698
|
z-index: 99998;
|
|
1609
|
-
pointer-events:
|
|
1699
|
+
pointer-events: none;
|
|
1610
1700
|
}
|
|
1611
1701
|
|
|
1612
1702
|
/* Popover content — fixed position relative to viewport */
|
|
@@ -1616,23 +1706,6 @@
|
|
|
1616
1706
|
pointer-events: auto;
|
|
1617
1707
|
}
|
|
1618
1708
|
|
|
1619
|
-
/* Updated animation for individual recent colors */
|
|
1620
|
-
@keyframes zoomIn {
|
|
1621
|
-
from {
|
|
1622
|
-
transform: scale(0.6);
|
|
1623
|
-
opacity: 0;
|
|
1624
|
-
}
|
|
1625
|
-
to {
|
|
1626
|
-
transform: scale(1);
|
|
1627
|
-
opacity: 1;
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
|
|
1631
|
-
:global(.animate-recent-color) {
|
|
1632
|
-
animation: zoomIn 0.2s var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1)) backwards;
|
|
1633
|
-
transform-origin: center center;
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1636
1709
|
/* Add these styles */
|
|
1637
1710
|
.color-preview-button {
|
|
1638
1711
|
outline: none !important;
|
|
@@ -73,6 +73,12 @@
|
|
|
73
73
|
let placeholder = today(getLocalTimeZone());
|
|
74
74
|
let currentValue: CalendarDate | undefined;
|
|
75
75
|
|
|
76
|
+
// Watch for value changes and update internal state.
|
|
77
|
+
// It stays above `defaultYear` and `defaultMonth`: the placeholder is assigned inside `updateCurrentValue()`, which the
|
|
78
|
+
// compiler cannot see, so a statement written before this one would read the placeholder of today and never run again
|
|
79
|
+
// (the header would say November 2026 above a grid of October 2024).
|
|
80
|
+
$: (value, updateCurrentValue());
|
|
81
|
+
|
|
76
82
|
// Month and year options setup: the names of the months are written by the language of the page
|
|
77
83
|
$: monthFmt = new DateFormatter($locale, { month: 'long' });
|
|
78
84
|
$: monthOptions = Array.from({ length: 12 }, (_, monthIndex) => ({
|
|
@@ -143,17 +149,10 @@
|
|
|
143
149
|
// console.log('🎯 [DatePicker] Final state:', { currentValue, placeholder });
|
|
144
150
|
}
|
|
145
151
|
|
|
146
|
-
// Watch for value changes and update internal state
|
|
147
|
-
$: (value, updateCurrentValue());
|
|
148
|
-
|
|
149
152
|
// Track dropdown state through store subscription
|
|
150
153
|
$: open = $openDropdowns?.has(controllerId) || false;
|
|
151
154
|
|
|
152
155
|
// Computed values for Calendar component with extra safety
|
|
153
|
-
$: calendarValue = currentValue;
|
|
154
|
-
$: calendarDefaultMonth = placeholder;
|
|
155
|
-
$: isCalendarReady = placeholder instanceof CalendarDate;
|
|
156
|
-
|
|
157
156
|
/**
|
|
158
157
|
* Formats a CalendarDate for display
|
|
159
158
|
* Handles undefined dates and invalid objects
|
|
@@ -198,6 +197,13 @@
|
|
|
198
197
|
toggleDropdown(controllerId);
|
|
199
198
|
}
|
|
200
199
|
|
|
200
|
+
/** Keep controlled popover state aligned with bits-ui (avoid toggle-on-open). */
|
|
201
|
+
function handleOpenChange(isOpen: boolean) {
|
|
202
|
+
if (isOpen !== open) {
|
|
203
|
+
toggleDropdown(controllerId);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
201
207
|
/**
|
|
202
208
|
* Closes the dropdown if it's currently open
|
|
203
209
|
* Used for cleanup and external close triggers
|
|
@@ -255,9 +261,9 @@
|
|
|
255
261
|
<!-- Date Picker Container (Figma IC Date Picker 172:399 + Calendar 210:3967) -->
|
|
256
262
|
<div bind:this={controllerElement} class="date-picker-input-controller">
|
|
257
263
|
<InputControllerRow {label} {description}>
|
|
258
|
-
<Popover.Root {open} onOpenChange={
|
|
264
|
+
<Popover.Root {open} onOpenChange={handleOpenChange}>
|
|
259
265
|
<Popover.Trigger
|
|
260
|
-
class="date-picker-trigger group flex h-9 w-full items-center gap-2 rounded-lg bg-accent
|
|
266
|
+
class="date-picker-trigger group flex h-9 w-full items-center gap-2 rounded-lg bg-accent px-3 transition-colors duration-fast hover:bg-accent-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
|
261
267
|
onfocusin={onFocus}
|
|
262
268
|
>
|
|
263
269
|
<span
|
|
@@ -268,13 +274,13 @@
|
|
|
268
274
|
{formatDate(currentValue, $locale, $t)}
|
|
269
275
|
</span>
|
|
270
276
|
<IconCalendar
|
|
271
|
-
class="size-4 shrink-0 stroke-
|
|
277
|
+
class="size-4 shrink-0 stroke-2 text-muted-foreground transition-colors duration-fast group-hover:text-foreground"
|
|
272
278
|
aria-hidden="true"
|
|
273
279
|
/>
|
|
274
280
|
</Popover.Trigger>
|
|
275
281
|
|
|
276
282
|
<Popover.Content
|
|
277
|
-
class="date-picker-popover z-50 w-[
|
|
283
|
+
class="date-picker-popover z-50 w-[15.625rem] border border-border p-3 shadow-none"
|
|
278
284
|
align="end"
|
|
279
285
|
sideOffset={8}
|
|
280
286
|
>
|
|
@@ -307,7 +313,8 @@
|
|
|
307
313
|
>
|
|
308
314
|
<span class="truncate">{defaultMonth?.label || $t('editor.date.selectMonth')}</span>
|
|
309
315
|
</Select.Trigger>
|
|
310
|
-
|
|
316
|
+
<!-- No overflow-y-auto of its own (round 26): the list scrolls inside its viewport with the arrow buttons, which show the hand cursor; a second scroller here could only add a double scrollbar -->
|
|
317
|
+
<Select.Content class="month-year-dropdown-content max-h-[200px]">
|
|
311
318
|
{#each monthOptions as { value, label }}
|
|
312
319
|
<Select.Item {value} {label}>
|
|
313
320
|
{label}
|
|
@@ -341,7 +348,8 @@
|
|
|
341
348
|
>
|
|
342
349
|
<span class="truncate">{defaultYear?.label || $t('editor.date.selectYear')}</span>
|
|
343
350
|
</Select.Trigger>
|
|
344
|
-
|
|
351
|
+
<!-- Same as the month list: the viewport scrolls, with the arrow buttons (round 26) -->
|
|
352
|
+
<Select.Content class="month-year-dropdown-content max-h-[200px]">
|
|
345
353
|
{#each yearOptions as { value, label }}
|
|
346
354
|
<Select.Item {value} {label}>
|
|
347
355
|
{label}
|
|
@@ -355,6 +363,8 @@
|
|
|
355
363
|
<Calendar
|
|
356
364
|
mode="single"
|
|
357
365
|
locale={$locale}
|
|
366
|
+
bind:placeholder
|
|
367
|
+
value={currentValue}
|
|
358
368
|
calendarLabel={$t('editor.date.calendarLabel')}
|
|
359
369
|
previousLabel={$t('editor.date.previousMonth')}
|
|
360
370
|
nextLabel={$t('editor.date.nextMonth')}
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
Command,
|
|
47
47
|
EmptyState,
|
|
48
48
|
IconButton,
|
|
49
|
-
Skeleton
|
|
49
|
+
Skeleton,
|
|
50
|
+
Select
|
|
50
51
|
} from '@widgetic/design-system/components';
|
|
51
52
|
|
|
52
53
|
import {
|
|
@@ -66,7 +67,10 @@
|
|
|
66
67
|
recentFontsStore
|
|
67
68
|
} from '../../utils/fontUtils';
|
|
68
69
|
import type { FontData } from '../../utils/FontManager';
|
|
69
|
-
import FontManager, {
|
|
70
|
+
import FontManager, {
|
|
71
|
+
mapGoogleVariantIdsToWeightNames,
|
|
72
|
+
normalizeFontWeightName
|
|
73
|
+
} from '../../utils/FontManager';
|
|
70
74
|
|
|
71
75
|
import { shouldSkipFont } from '../../utils/skipFonts';
|
|
72
76
|
import { escapeHtml, cssQuotedString } from '../../utils/htmlSafety';
|
|
@@ -193,7 +197,7 @@
|
|
|
193
197
|
if (typeof raw === 'object' && raw.family) {
|
|
194
198
|
return {
|
|
195
199
|
family: raw.family,
|
|
196
|
-
weight: raw.weight || 'Regular',
|
|
200
|
+
weight: normalizeFontWeightName(raw.weight || 'Regular'),
|
|
197
201
|
category: raw.category || 'Sans Serif'
|
|
198
202
|
};
|
|
199
203
|
}
|
|
@@ -305,7 +309,7 @@
|
|
|
305
309
|
ensureFontPickerPortal();
|
|
306
310
|
const coerced = coerceFontValue(value);
|
|
307
311
|
if (coerced?.weight) {
|
|
308
|
-
selectedWeight = `${controllerId}-${coerced.weight}`;
|
|
312
|
+
selectedWeight = `${controllerId}-${normalizeFontWeightName(coerced.weight)}`;
|
|
309
313
|
}
|
|
310
314
|
if (typeof value === 'string' && coerced && onChange) {
|
|
311
315
|
onChange(coerced);
|
|
@@ -805,6 +809,9 @@
|
|
|
805
809
|
* Handles font selection and updates recent fonts
|
|
806
810
|
*/
|
|
807
811
|
function handleFontSelect(font: FontItem | RecentFont) {
|
|
812
|
+
if ($openDropdowns?.has(controllerId)) {
|
|
813
|
+
toggleDropdown(controllerId);
|
|
814
|
+
}
|
|
808
815
|
if (onChange) {
|
|
809
816
|
// The family has to reach the card even when the weight catalog fails.
|
|
810
817
|
onChange({
|
|
@@ -1701,10 +1708,23 @@
|
|
|
1701
1708
|
category: current?.category || 'Sans Serif'
|
|
1702
1709
|
});
|
|
1703
1710
|
}
|
|
1711
|
+
if ($openDropdowns?.has('weight-' + controllerId)) {
|
|
1712
|
+
toggleDropdown('weight-' + controllerId);
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
function handleWeightOpenChange(isOpen: boolean) {
|
|
1717
|
+
if (Date.now() < fontPickerReadyAt) return;
|
|
1718
|
+
const wasOpen = !!$openDropdowns?.has('weight-' + controllerId);
|
|
1719
|
+
if (isOpen !== wasOpen) {
|
|
1720
|
+
toggleDropdown('weight-' + controllerId);
|
|
1721
|
+
}
|
|
1704
1722
|
}
|
|
1705
1723
|
|
|
1706
1724
|
// Update the template to use the modified weight
|
|
1707
|
-
$: displayWeight =
|
|
1725
|
+
$: displayWeight = normalizeFontWeightName(
|
|
1726
|
+
selectedWeight.replace(`${controllerId}-`, '') || 'Regular'
|
|
1727
|
+
);
|
|
1708
1728
|
|
|
1709
1729
|
// Update arrow click handler to use filteredFonts
|
|
1710
1730
|
function handleArrowClick(direction: 'up' | 'down') {
|
|
@@ -1857,7 +1877,7 @@
|
|
|
1857
1877
|
}
|
|
1858
1878
|
}}
|
|
1859
1879
|
>
|
|
1860
|
-
<IconCloudUpload class="size-4 stroke-
|
|
1880
|
+
<IconCloudUpload class="size-4 stroke-2" />
|
|
1861
1881
|
</IconButton>
|
|
1862
1882
|
</div>
|
|
1863
1883
|
<!-- Search input -->
|
|
@@ -1992,7 +2012,7 @@
|
|
|
1992
2012
|
tabindex="-1"
|
|
1993
2013
|
>
|
|
1994
2014
|
<IconCheck
|
|
1995
|
-
class="size-4 shrink-0 stroke-
|
|
2015
|
+
class="size-4 shrink-0 stroke-2 {selected
|
|
1996
2016
|
? 'text-foreground opacity-100'
|
|
1997
2017
|
: 'opacity-0'}"
|
|
1998
2018
|
/>
|
|
@@ -2021,7 +2041,7 @@
|
|
|
2021
2041
|
removeFont(font.family);
|
|
2022
2042
|
}}
|
|
2023
2043
|
>
|
|
2024
|
-
<IconTrash class="size-4 stroke-
|
|
2044
|
+
<IconTrash class="size-4 stroke-2 text-muted-foreground" />
|
|
2025
2045
|
</button>
|
|
2026
2046
|
{/if}
|
|
2027
2047
|
</div>
|
|
@@ -2039,56 +2059,37 @@
|
|
|
2039
2059
|
|
|
2040
2060
|
<InputControllerRow label={label ? $t('editor.font.weight') : ''}>
|
|
2041
2061
|
<div class="font-weight-input-ct w-full">
|
|
2042
|
-
<
|
|
2062
|
+
<Select.Root
|
|
2063
|
+
type="single"
|
|
2064
|
+
value={displayWeight || 'Regular'}
|
|
2065
|
+
onValueChange={handleWeightSelect}
|
|
2043
2066
|
open={$openDropdowns?.has('weight-' + controllerId)}
|
|
2044
|
-
onOpenChange={
|
|
2045
|
-
if (isOpen && Date.now() < fontPickerReadyAt) return;
|
|
2046
|
-
if (isOpen !== $openDropdowns?.has('weight-' + controllerId)) {
|
|
2047
|
-
toggleDropdown('weight-' + controllerId);
|
|
2048
|
-
}
|
|
2049
|
-
}}
|
|
2067
|
+
onOpenChange={handleWeightOpenChange}
|
|
2050
2068
|
>
|
|
2051
|
-
<
|
|
2069
|
+
<Select.Trigger
|
|
2052
2070
|
tabindex={-1}
|
|
2053
|
-
class="font-ic-trigger group flex h-9 w-full items-center gap-2 rounded-lg bg-accent px-3 transition-colors duration-fast hover:bg-accent-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
|
2071
|
+
class="font-ic-trigger group flex h-9 w-full items-center gap-2 rounded-lg border-0 bg-accent px-3 shadow-none transition-colors duration-fast hover:bg-accent-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background data-[state=open]:bg-accent-hover [&>svg:last-child]:hidden"
|
|
2054
2072
|
>
|
|
2055
2073
|
<span class="truncate flex-1 text-start text-body text-foreground">
|
|
2056
2074
|
{fontWeightLabel(displayWeight || 'Regular', $t)}
|
|
2057
2075
|
</span>
|
|
2058
2076
|
<DropdownChevron open={$openDropdowns?.has('weight-' + controllerId)} />
|
|
2059
|
-
</
|
|
2060
|
-
|
|
2077
|
+
</Select.Trigger>
|
|
2078
|
+
<!-- The list of weights keeps its name for a screen reader ("Font weights"), as it had when it was a command list -->
|
|
2079
|
+
<Select.Content
|
|
2061
2080
|
align="end"
|
|
2062
2081
|
sideOffset={8}
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
portalProps={{ to: fontPickerPortalHost }}
|
|
2082
|
+
aria-label={$t('editor.font.weightList')}
|
|
2083
|
+
class="font-weight-select-content z-50 min-w-[12.5rem] rounded-xl border border-border bg-popover p-1 shadow-none"
|
|
2084
|
+
portalProps={fontPickerPortalHost ? { to: fontPickerPortalHost } : undefined}
|
|
2067
2085
|
>
|
|
2068
|
-
|
|
2069
|
-
<
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
tabindex={-1}
|
|
2076
|
-
onSelect={() => handleWeightSelect(weight)}
|
|
2077
|
-
class="flex h-8 cursor-pointer items-center gap-2 rounded-lg px-2 text-body outline-none data-[selected=true]:bg-brand-subtle hover:bg-accent"
|
|
2078
|
-
>
|
|
2079
|
-
<IconCheck
|
|
2080
|
-
class="size-4 shrink-0 stroke-[1.333] {selected
|
|
2081
|
-
? 'opacity-100'
|
|
2082
|
-
: 'opacity-0'}"
|
|
2083
|
-
/>
|
|
2084
|
-
<span class="truncate">{fontWeightLabel(weight, $t)}</span>
|
|
2085
|
-
</Command.Item>
|
|
2086
|
-
{/each}
|
|
2087
|
-
</Command.Group>
|
|
2088
|
-
</Command.List>
|
|
2089
|
-
</Command.Root>
|
|
2090
|
-
</Popover.Content>
|
|
2091
|
-
</Popover.Root>
|
|
2086
|
+
{#each availableWeights as weight}
|
|
2087
|
+
<Select.Item value={weight} label={fontWeightLabel(weight, $t)} class="h-8">
|
|
2088
|
+
{fontWeightLabel(weight, $t)}
|
|
2089
|
+
</Select.Item>
|
|
2090
|
+
{/each}
|
|
2091
|
+
</Select.Content>
|
|
2092
|
+
</Select.Root>
|
|
2092
2093
|
</div>
|
|
2093
2094
|
</InputControllerRow>
|
|
2094
2095
|
|