@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
|
@@ -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');
|
|
@@ -525,9 +534,17 @@
|
|
|
525
534
|
closeAutosuggestions();
|
|
526
535
|
dispatch('colorselectmodalopen');
|
|
527
536
|
isColorSelectOpen = true;
|
|
537
|
+
lastPickerOpenTimestamp = performance.now();
|
|
538
|
+
// Measure after the swatch is in view so fixed coords match what the user sees (panels can scroll on open).
|
|
539
|
+
try {
|
|
540
|
+
triggerRef?.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
541
|
+
} catch (scrollError) {
|
|
542
|
+
console.error('[ColorPicker] scrollIntoView before positioning failed:', scrollError);
|
|
543
|
+
}
|
|
528
544
|
updatePopoverPosition();
|
|
529
545
|
// Re-position after portal is mounted and layout stabilizes
|
|
530
546
|
tick().then(() => {
|
|
547
|
+
updatePopoverPosition();
|
|
531
548
|
requestAnimationFrame(updatePopoverPosition);
|
|
532
549
|
});
|
|
533
550
|
}
|
|
@@ -567,6 +584,17 @@
|
|
|
567
584
|
if (scrollTarget instanceof Element && scrollTarget.closest('[data-allow-scroll="true"]')) {
|
|
568
585
|
return;
|
|
569
586
|
}
|
|
587
|
+
if (open && performance.now() - lastPickerOpenTimestamp < 300) {
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
if (
|
|
591
|
+
open &&
|
|
592
|
+
scrollTarget instanceof Element &&
|
|
593
|
+
(scrollTarget.closest('.color-picker-popover-content') ||
|
|
594
|
+
scrollTarget.closest('.color-picker-wrapper'))
|
|
595
|
+
) {
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
570
598
|
|
|
571
599
|
// Close both suggestions and color picker
|
|
572
600
|
if (suggestionVisible || open) {
|
|
@@ -993,6 +1021,38 @@
|
|
|
993
1021
|
// shadow root, so a listener on the window alone does not hear about those)
|
|
994
1022
|
let stopListeningForScroll: () => void = () => {};
|
|
995
1023
|
|
|
1024
|
+
function handleWindowKeyDown(event: KeyboardEvent) {
|
|
1025
|
+
if (!open) return;
|
|
1026
|
+
if (event.key === 'Escape') {
|
|
1027
|
+
event.preventDefault();
|
|
1028
|
+
event.stopPropagation();
|
|
1029
|
+
handleToggle(false);
|
|
1030
|
+
triggerRef?.focus();
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
function handleWheelWhileOpen(event: WheelEvent) {
|
|
1035
|
+
if (!open) return;
|
|
1036
|
+
if (performance.now() - lastPickerOpenTimestamp < 300) return;
|
|
1037
|
+
const target = event.target;
|
|
1038
|
+
if (target instanceof Element && target.closest('.color-picker-popover-content')) return;
|
|
1039
|
+
handleToggle(false);
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
function handlePointerDownOutside(event: MouseEvent) {
|
|
1043
|
+
if (!open) return;
|
|
1044
|
+
const target = event.target;
|
|
1045
|
+
if (!(target instanceof Element)) return;
|
|
1046
|
+
if (
|
|
1047
|
+
target.closest('.color-picker-popover-content') ||
|
|
1048
|
+
target.closest('.color-preview-button') ||
|
|
1049
|
+
target.closest('.color-input-main-container')
|
|
1050
|
+
) {
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
handleToggle(false);
|
|
1054
|
+
}
|
|
1055
|
+
|
|
996
1056
|
// Sets up event listeners when the component mounts
|
|
997
1057
|
onMount(() => {
|
|
998
1058
|
initializeColor();
|
|
@@ -1000,7 +1060,10 @@
|
|
|
1000
1060
|
window.addEventListener('mousemove', handleGlobalMouseMove);
|
|
1001
1061
|
window.addEventListener('keydown', handlePopupKeyDown);
|
|
1002
1062
|
window.addEventListener('keyup', handlePopupKeyUp);
|
|
1003
|
-
|
|
1063
|
+
window.addEventListener('keydown', handleWindowKeyDown, true);
|
|
1064
|
+
window.addEventListener('mousedown', handlePointerDownOutside, true);
|
|
1065
|
+
window.addEventListener('wheel', handleWheelWhileOpen, { capture: true, passive: true });
|
|
1066
|
+
stopListeningForScroll = listenForScroll(controllerRoot, handleScroll);
|
|
1004
1067
|
window.addEventListener('widgetic:close-color-pickers', onCloseOtherPickers as EventListener);
|
|
1005
1068
|
});
|
|
1006
1069
|
|
|
@@ -1012,6 +1075,9 @@
|
|
|
1012
1075
|
window.removeEventListener('mousemove', handleGlobalMouseMove);
|
|
1013
1076
|
window.removeEventListener('keydown', handlePopupKeyDown);
|
|
1014
1077
|
window.removeEventListener('keyup', handlePopupKeyUp);
|
|
1078
|
+
window.removeEventListener('keydown', handleWindowKeyDown, true);
|
|
1079
|
+
window.removeEventListener('mousedown', handlePointerDownOutside, true);
|
|
1080
|
+
window.removeEventListener('wheel', handleWheelWhileOpen, true);
|
|
1015
1081
|
stopListeningForScroll();
|
|
1016
1082
|
window.removeEventListener(
|
|
1017
1083
|
'widgetic:close-color-pickers',
|
|
@@ -1143,6 +1209,7 @@
|
|
|
1143
1209
|
}
|
|
1144
1210
|
|
|
1145
1211
|
let inputRef: HTMLDivElement;
|
|
1212
|
+
let controllerRoot: HTMLDivElement;
|
|
1146
1213
|
|
|
1147
1214
|
/**
|
|
1148
1215
|
* Restores the current color value when input is invalid or empty
|
|
@@ -1208,30 +1275,32 @@
|
|
|
1208
1275
|
// Track trigger position for fixed-position popover
|
|
1209
1276
|
let triggerRef: HTMLDivElement;
|
|
1210
1277
|
let popoverStyle = '';
|
|
1278
|
+
let popoverContentRef: HTMLDivElement | null = null;
|
|
1279
|
+
|
|
1280
|
+
const popoverGapPx = 8;
|
|
1281
|
+
const popoverWidthPx = 256;
|
|
1211
1282
|
|
|
1212
1283
|
function updatePopoverPosition() {
|
|
1213
1284
|
if (!triggerRef) return;
|
|
1214
|
-
const
|
|
1285
|
+
const swatchRect = triggerRef.getBoundingClientRect();
|
|
1215
1286
|
// Guard: if trigger hasn't been laid out yet, defer
|
|
1216
|
-
if (
|
|
1287
|
+
if (swatchRect.width === 0 && swatchRect.height === 0) {
|
|
1217
1288
|
requestAnimationFrame(updatePopoverPosition);
|
|
1218
1289
|
return;
|
|
1219
1290
|
}
|
|
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
|
-
}
|
|
1291
|
+
const popoverHeight = popoverContentRef?.offsetHeight ?? 420;
|
|
1292
|
+
const spaceBelow = window.innerHeight - swatchRect.bottom;
|
|
1293
|
+
const spaceAbove = swatchRect.top;
|
|
1294
|
+
const openAbove = spaceBelow < popoverHeight + popoverGapPx && spaceAbove > spaceBelow;
|
|
1295
|
+
const top = openAbove
|
|
1296
|
+
? Math.round(swatchRect.top - popoverHeight - popoverGapPx)
|
|
1297
|
+
: Math.round(swatchRect.bottom + popoverGapPx);
|
|
1298
|
+
// Anchor horizontally to the swatch: centered when it fits, clamped inside the viewport otherwise.
|
|
1299
|
+
let left = Math.round(swatchRect.left + swatchRect.width / 2 - popoverWidthPx / 2);
|
|
1300
|
+
const horizontalMargin = 8;
|
|
1301
|
+
const maxLeft = window.innerWidth - popoverWidthPx - horizontalMargin;
|
|
1302
|
+
left = Math.max(horizontalMargin, Math.min(left, maxLeft));
|
|
1303
|
+
popoverStyle = `top: ${top}px; left: ${left}px;`; /* rtl-ok: viewport coords from getBoundingClientRect; popover is dir=ltr */
|
|
1235
1304
|
}
|
|
1236
1305
|
|
|
1237
1306
|
// Position is calculated in handleToggle after tick()
|
|
@@ -1268,16 +1337,34 @@
|
|
|
1268
1337
|
// Add these computed styles for layout
|
|
1269
1338
|
$: opacityBarWidthPx = `${pickerSize}px`;
|
|
1270
1339
|
$: recentColorsMaxWidth = `${pickerSize + sliderWidth}px`;
|
|
1340
|
+
|
|
1341
|
+
$: if (open && popoverContentRef) {
|
|
1342
|
+
tick().then(() => {
|
|
1343
|
+
updatePopoverPosition();
|
|
1344
|
+
requestAnimationFrame(updatePopoverPosition);
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1271
1347
|
</script>
|
|
1272
1348
|
|
|
1273
1349
|
<!-- Color Picker Input Controller Container -->
|
|
1274
1350
|
<!-- Figma IC Color 172:116, Color Picker 211:3877 -->
|
|
1275
|
-
<div class="color-picker-input-controller-ct">
|
|
1351
|
+
<div class="color-picker-input-controller-ct" bind:this={controllerRoot}>
|
|
1276
1352
|
<!-- Input Controller Header -->
|
|
1277
1353
|
<InputControllerRow {label} {helpText}>
|
|
1278
1354
|
<!-- Input Controller Container -->
|
|
1279
1355
|
<div
|
|
1280
|
-
class="color-input-main-container
|
|
1356
|
+
class="color-input-main-container {editableFieldSurfaceClass} gap-2 pe-2 ps-3"
|
|
1357
|
+
role="presentation"
|
|
1358
|
+
onclick={(e) => {
|
|
1359
|
+
const hexInputElement = inputRef?.querySelector('input');
|
|
1360
|
+
if (
|
|
1361
|
+
hexInputElement instanceof HTMLInputElement &&
|
|
1362
|
+
e.target instanceof Element &&
|
|
1363
|
+
!e.target.closest('.color-preview-button')
|
|
1364
|
+
) {
|
|
1365
|
+
hexInputElement.focus();
|
|
1366
|
+
}
|
|
1367
|
+
}}
|
|
1281
1368
|
>
|
|
1282
1369
|
<!-- Hex Input Container -->
|
|
1283
1370
|
<div class="hex-input-container min-w-0 flex-1" bind:this={inputRef}>
|
|
@@ -1286,7 +1373,7 @@
|
|
|
1286
1373
|
bind:this={inputComponent}
|
|
1287
1374
|
type="text"
|
|
1288
1375
|
dir="ltr"
|
|
1289
|
-
class="
|
|
1376
|
+
class="{embeddedInputClass} p-0"
|
|
1290
1377
|
value={hexInput}
|
|
1291
1378
|
onfocus={(e) => {
|
|
1292
1379
|
dispatch('focus', e);
|
|
@@ -1338,6 +1425,12 @@
|
|
|
1338
1425
|
e.stopPropagation();
|
|
1339
1426
|
handleToggle(!open);
|
|
1340
1427
|
}}
|
|
1428
|
+
onkeydown={(e) => {
|
|
1429
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
1430
|
+
e.preventDefault();
|
|
1431
|
+
handleToggle(!open);
|
|
1432
|
+
}
|
|
1433
|
+
}}
|
|
1341
1434
|
>
|
|
1342
1435
|
<CheckerBoardBackground
|
|
1343
1436
|
className="absolute inset-0 w-full h-full pointer-events-none rounded-[inherit]"
|
|
@@ -1410,15 +1503,12 @@
|
|
|
1410
1503
|
style="position: fixed; inset: 0; z-index: 99999; pointer-events: none;"
|
|
1411
1504
|
>
|
|
1412
1505
|
<!-- 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>
|
|
1506
|
+
<div class="color-picker-backdrop" style="z-index: 1;" aria-hidden="true"></div>
|
|
1418
1507
|
|
|
1419
1508
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
1420
1509
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
1421
1510
|
<div
|
|
1511
|
+
bind:this={popoverContentRef}
|
|
1422
1512
|
class="color-picker-popover-content w-64 rounded-xl border border-border bg-popover p-3 text-popover-foreground shadow-none"
|
|
1423
1513
|
dir="ltr"
|
|
1424
1514
|
style="{popoverStyle} z-index: 2;"
|
|
@@ -1435,8 +1525,7 @@
|
|
|
1435
1525
|
{#each recentColors.slice(0, 5) as { color, alpha }, i}
|
|
1436
1526
|
<button
|
|
1437
1527
|
type="button"
|
|
1438
|
-
class="
|
|
1439
|
-
style="animation-delay: {i * 0.05}s"
|
|
1528
|
+
class="recent-color-swatch relative size-10 overflow-hidden rounded-lg border border-border"
|
|
1440
1529
|
onclick={() => {
|
|
1441
1530
|
try {
|
|
1442
1531
|
isInternalUpdate = true;
|
|
@@ -1534,7 +1623,7 @@
|
|
|
1534
1623
|
type="number"
|
|
1535
1624
|
min="0"
|
|
1536
1625
|
max="100"
|
|
1537
|
-
class="
|
|
1626
|
+
class="{embeddedInputClass} p-0 text-center [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"
|
|
1538
1627
|
value={opacityPercentage}
|
|
1539
1628
|
oninput={(e) => {
|
|
1540
1629
|
e.stopPropagation();
|
|
@@ -1601,12 +1690,12 @@
|
|
|
1601
1690
|
cursor: grabbing !important;
|
|
1602
1691
|
}
|
|
1603
1692
|
|
|
1604
|
-
/* Backdrop
|
|
1693
|
+
/* Backdrop is visual only — wheel events pass through; outside clicks use capture on window. */
|
|
1605
1694
|
.color-picker-backdrop {
|
|
1606
1695
|
position: fixed;
|
|
1607
1696
|
inset: 0;
|
|
1608
1697
|
z-index: 99998;
|
|
1609
|
-
pointer-events:
|
|
1698
|
+
pointer-events: none;
|
|
1610
1699
|
}
|
|
1611
1700
|
|
|
1612
1701
|
/* Popover content — fixed position relative to viewport */
|
|
@@ -1616,23 +1705,6 @@
|
|
|
1616
1705
|
pointer-events: auto;
|
|
1617
1706
|
}
|
|
1618
1707
|
|
|
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
1708
|
/* Add these styles */
|
|
1637
1709
|
.color-preview-button {
|
|
1638
1710
|
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,7 +261,7 @@
|
|
|
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
266
|
class="date-picker-trigger group flex h-9 w-full items-center gap-2 rounded-lg bg-accent pe-2 ps-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}
|
|
@@ -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
|
>
|
|
@@ -355,6 +361,8 @@
|
|
|
355
361
|
<Calendar
|
|
356
362
|
mode="single"
|
|
357
363
|
locale={$locale}
|
|
364
|
+
bind:placeholder
|
|
365
|
+
value={currentValue}
|
|
358
366
|
calendarLabel={$t('editor.date.calendarLabel')}
|
|
359
367
|
previousLabel={$t('editor.date.previousMonth')}
|
|
360
368
|
nextLabel={$t('editor.date.nextMonth')}
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
* Shadcn UI select components for consistent styling and behavior
|
|
39
39
|
*/
|
|
40
40
|
import { Select } from '@widgetic/design-system/components';
|
|
41
|
-
import
|
|
41
|
+
import DropdownChevron from './shared/DropdownChevron.svelte';
|
|
42
42
|
|
|
43
43
|
// The words of the editor in the language of the page.
|
|
44
44
|
const { t } = useEditorLanguage();
|
|
@@ -182,17 +182,7 @@
|
|
|
182
182
|
>
|
|
183
183
|
{triggerContent}
|
|
184
184
|
</span>
|
|
185
|
-
{
|
|
186
|
-
<IconChevronUp
|
|
187
|
-
class="size-4 shrink-0 stroke-[1.333] text-muted-foreground"
|
|
188
|
-
aria-hidden="true"
|
|
189
|
-
/>
|
|
190
|
-
{:else}
|
|
191
|
-
<IconChevronDown
|
|
192
|
-
class="size-4 shrink-0 stroke-[1.333] text-muted-foreground"
|
|
193
|
-
aria-hidden="true"
|
|
194
|
-
/>
|
|
195
|
-
{/if}
|
|
185
|
+
<DropdownChevron {open} />
|
|
196
186
|
</Select.Trigger>
|
|
197
187
|
|
|
198
188
|
<Select.Content
|
|
@@ -46,14 +46,13 @@
|
|
|
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 {
|
|
53
54
|
IconCheck,
|
|
54
55
|
IconCloudUpload,
|
|
55
|
-
IconChevronDown,
|
|
56
|
-
IconChevronUp,
|
|
57
56
|
IconTrash
|
|
58
57
|
} from '@widgetic/design-system/icons';
|
|
59
58
|
import fontsJsonUrl from '../../assets/fonts.json?url';
|
|
@@ -86,6 +85,7 @@
|
|
|
86
85
|
// Import shared components
|
|
87
86
|
import { SearchInput } from '@widgetic/design-system/components';
|
|
88
87
|
import CategoryTabs from './shared/CategoryTabs.svelte';
|
|
88
|
+
import DropdownChevron from './shared/DropdownChevron.svelte';
|
|
89
89
|
import { RecentItemsSection, ItemGrid } from './shared';
|
|
90
90
|
import { useEditorLanguage } from '../../i18n/language';
|
|
91
91
|
import { categoryLabel, fontWeightLabel } from '../../i18n/labels';
|
|
@@ -806,6 +806,9 @@
|
|
|
806
806
|
* Handles font selection and updates recent fonts
|
|
807
807
|
*/
|
|
808
808
|
function handleFontSelect(font: FontItem | RecentFont) {
|
|
809
|
+
if ($openDropdowns?.has(controllerId)) {
|
|
810
|
+
toggleDropdown(controllerId);
|
|
811
|
+
}
|
|
809
812
|
if (onChange) {
|
|
810
813
|
// The family has to reach the card even when the weight catalog fails.
|
|
811
814
|
onChange({
|
|
@@ -1702,6 +1705,17 @@
|
|
|
1702
1705
|
category: current?.category || 'Sans Serif'
|
|
1703
1706
|
});
|
|
1704
1707
|
}
|
|
1708
|
+
if ($openDropdowns?.has('weight-' + controllerId)) {
|
|
1709
|
+
toggleDropdown('weight-' + controllerId);
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
function handleWeightOpenChange(isOpen: boolean) {
|
|
1714
|
+
if (Date.now() < fontPickerReadyAt) return;
|
|
1715
|
+
const wasOpen = !!$openDropdowns?.has('weight-' + controllerId);
|
|
1716
|
+
if (isOpen !== wasOpen) {
|
|
1717
|
+
toggleDropdown('weight-' + controllerId);
|
|
1718
|
+
}
|
|
1705
1719
|
}
|
|
1706
1720
|
|
|
1707
1721
|
// Update the template to use the modified weight
|
|
@@ -1825,11 +1839,7 @@
|
|
|
1825
1839
|
>
|
|
1826
1840
|
{resolvedFont?.family || $t('editor.font.select')}
|
|
1827
1841
|
</span>
|
|
1828
|
-
{
|
|
1829
|
-
<IconChevronUp class="size-4 shrink-0 stroke-[1.333] text-muted-foreground" />
|
|
1830
|
-
{:else}
|
|
1831
|
-
<IconChevronDown class="size-4 shrink-0 stroke-[1.333] text-muted-foreground" />
|
|
1832
|
-
{/if}
|
|
1842
|
+
<DropdownChevron open={$openDropdowns?.has(controllerId)} />
|
|
1833
1843
|
</Popover.Trigger>
|
|
1834
1844
|
|
|
1835
1845
|
<Popover.Content
|
|
@@ -1862,7 +1872,7 @@
|
|
|
1862
1872
|
}
|
|
1863
1873
|
}}
|
|
1864
1874
|
>
|
|
1865
|
-
<IconCloudUpload class="size-4 stroke-
|
|
1875
|
+
<IconCloudUpload class="size-4 stroke-2" />
|
|
1866
1876
|
</IconButton>
|
|
1867
1877
|
</div>
|
|
1868
1878
|
<!-- Search input -->
|
|
@@ -1997,7 +2007,7 @@
|
|
|
1997
2007
|
tabindex="-1"
|
|
1998
2008
|
>
|
|
1999
2009
|
<IconCheck
|
|
2000
|
-
class="size-4 shrink-0 stroke-
|
|
2010
|
+
class="size-4 shrink-0 stroke-2 {selected
|
|
2001
2011
|
? 'text-foreground opacity-100'
|
|
2002
2012
|
: 'opacity-0'}"
|
|
2003
2013
|
/>
|
|
@@ -2026,7 +2036,7 @@
|
|
|
2026
2036
|
removeFont(font.family);
|
|
2027
2037
|
}}
|
|
2028
2038
|
>
|
|
2029
|
-
<IconTrash class="size-4 stroke-
|
|
2039
|
+
<IconTrash class="size-4 stroke-2 text-muted-foreground" />
|
|
2030
2040
|
</button>
|
|
2031
2041
|
{/if}
|
|
2032
2042
|
</div>
|
|
@@ -2044,60 +2054,37 @@
|
|
|
2044
2054
|
|
|
2045
2055
|
<InputControllerRow label={label ? $t('editor.font.weight') : ''}>
|
|
2046
2056
|
<div class="font-weight-input-ct w-full">
|
|
2047
|
-
<
|
|
2057
|
+
<Select.Root
|
|
2058
|
+
type="single"
|
|
2059
|
+
value={displayWeight || 'Regular'}
|
|
2060
|
+
onValueChange={handleWeightSelect}
|
|
2048
2061
|
open={$openDropdowns?.has('weight-' + controllerId)}
|
|
2049
|
-
onOpenChange={
|
|
2050
|
-
if (isOpen && Date.now() < fontPickerReadyAt) return;
|
|
2051
|
-
if (isOpen !== $openDropdowns?.has('weight-' + controllerId)) {
|
|
2052
|
-
toggleDropdown('weight-' + controllerId);
|
|
2053
|
-
}
|
|
2054
|
-
}}
|
|
2062
|
+
onOpenChange={handleWeightOpenChange}
|
|
2055
2063
|
>
|
|
2056
|
-
<
|
|
2064
|
+
<Select.Trigger
|
|
2057
2065
|
tabindex={-1}
|
|
2058
|
-
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"
|
|
2066
|
+
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"
|
|
2059
2067
|
>
|
|
2060
2068
|
<span class="truncate flex-1 text-start text-body text-foreground">
|
|
2061
2069
|
{fontWeightLabel(displayWeight || 'Regular', $t)}
|
|
2062
2070
|
</span>
|
|
2063
|
-
{
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
{/if}
|
|
2068
|
-
</Popover.Trigger>
|
|
2069
|
-
<Popover.Content
|
|
2071
|
+
<DropdownChevron open={$openDropdowns?.has('weight-' + controllerId)} />
|
|
2072
|
+
</Select.Trigger>
|
|
2073
|
+
<!-- The list of weights keeps its name for a screen reader ("Font weights"), as it had when it was a command list -->
|
|
2074
|
+
<Select.Content
|
|
2070
2075
|
align="end"
|
|
2071
2076
|
sideOffset={8}
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
portalProps={{ to: fontPickerPortalHost }}
|
|
2077
|
+
aria-label={$t('editor.font.weightList')}
|
|
2078
|
+
class="font-weight-select-content z-50 min-w-[12.5rem] rounded-xl border border-border bg-popover p-1 shadow-none"
|
|
2079
|
+
portalProps={fontPickerPortalHost ? { to: fontPickerPortalHost } : undefined}
|
|
2076
2080
|
>
|
|
2077
|
-
|
|
2078
|
-
<
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
tabindex={-1}
|
|
2085
|
-
onSelect={() => handleWeightSelect(weight)}
|
|
2086
|
-
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"
|
|
2087
|
-
>
|
|
2088
|
-
<IconCheck
|
|
2089
|
-
class="size-4 shrink-0 stroke-[1.333] {selected
|
|
2090
|
-
? 'opacity-100'
|
|
2091
|
-
: 'opacity-0'}"
|
|
2092
|
-
/>
|
|
2093
|
-
<span class="truncate">{fontWeightLabel(weight, $t)}</span>
|
|
2094
|
-
</Command.Item>
|
|
2095
|
-
{/each}
|
|
2096
|
-
</Command.Group>
|
|
2097
|
-
</Command.List>
|
|
2098
|
-
</Command.Root>
|
|
2099
|
-
</Popover.Content>
|
|
2100
|
-
</Popover.Root>
|
|
2081
|
+
{#each availableWeights as weight}
|
|
2082
|
+
<Select.Item value={weight} label={fontWeightLabel(weight, $t)} class="h-8">
|
|
2083
|
+
{fontWeightLabel(weight, $t)}
|
|
2084
|
+
</Select.Item>
|
|
2085
|
+
{/each}
|
|
2086
|
+
</Select.Content>
|
|
2087
|
+
</Select.Root>
|
|
2101
2088
|
</div>
|
|
2102
2089
|
</InputControllerRow>
|
|
2103
2090
|
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
onmouseenter={handleMouseEnter}
|
|
113
113
|
onmouseleave={handleMouseLeave}
|
|
114
114
|
>
|
|
115
|
-
<IconHelpCircle class="size-4 stroke-
|
|
115
|
+
<IconHelpCircle class="size-4 stroke-2 text-muted-foreground" />
|
|
116
116
|
</span>
|
|
117
117
|
</Tooltip.Trigger>
|
|
118
118
|
|