@yenio-pld/blocks 1.2.0-rc.12 → 1.2.0-rc.14
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/index.cjs +482 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -2
- package/dist/index.d.ts +18 -2
- package/dist/index.js +387 -20
- package/dist/index.js.map +1 -1
- package/dist/ui/button.d.ts +2 -2
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var React5 = require('react');
|
|
5
5
|
var skeleton_js = require('./ui/skeleton.js');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var lucideReact = require('lucide-react');
|
|
@@ -24,6 +24,7 @@ var combobox_js = require('./ui/combobox.js');
|
|
|
24
24
|
var dialog_js = require('./ui/dialog.js');
|
|
25
25
|
var drawer_js = require('./ui/drawer.js');
|
|
26
26
|
var input_js = require('./ui/input.js');
|
|
27
|
+
var libphonenumberJs = require('libphonenumber-js');
|
|
27
28
|
var slider_js = require('./ui/slider.js');
|
|
28
29
|
var toggle_js = require('./ui/toggle.js');
|
|
29
30
|
var framerMotion = require('framer-motion');
|
|
@@ -47,11 +48,11 @@ function _interopNamespace(e) {
|
|
|
47
48
|
return Object.freeze(n);
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
var
|
|
51
|
+
var React5__namespace = /*#__PURE__*/_interopNamespace(React5);
|
|
51
52
|
|
|
52
|
-
var LanguageContext =
|
|
53
|
+
var LanguageContext = React5.createContext(null);
|
|
53
54
|
function useLanguageContext() {
|
|
54
|
-
return
|
|
55
|
+
return React5.useContext(LanguageContext);
|
|
55
56
|
}
|
|
56
57
|
function PageTitle({
|
|
57
58
|
title,
|
|
@@ -295,8 +296,8 @@ function renderShellLink({
|
|
|
295
296
|
}
|
|
296
297
|
function DismissMobileSidebar({ pathname }) {
|
|
297
298
|
const { setOpenMobile } = sidebar_js.useSidebar();
|
|
298
|
-
const previous =
|
|
299
|
-
|
|
299
|
+
const previous = React5.useRef(pathname);
|
|
300
|
+
React5.useEffect(() => {
|
|
300
301
|
if (previous.current === pathname) return;
|
|
301
302
|
previous.current = pathname;
|
|
302
303
|
setOpenMobile(false);
|
|
@@ -485,7 +486,7 @@ function NavTabs({
|
|
|
485
486
|
"aria-current": active ? "page" : void 0,
|
|
486
487
|
children: label2
|
|
487
488
|
});
|
|
488
|
-
return
|
|
489
|
+
return React5.cloneElement(link, { key: tab.href });
|
|
489
490
|
})
|
|
490
491
|
}
|
|
491
492
|
);
|
|
@@ -685,14 +686,14 @@ function LoadMoreControls({
|
|
|
685
686
|
pending,
|
|
686
687
|
onLoadMore
|
|
687
688
|
}) {
|
|
688
|
-
const sentinelRef =
|
|
689
|
-
const pendingRef =
|
|
690
|
-
const onLoadMoreRef =
|
|
691
|
-
const armedRef =
|
|
692
|
-
const wasPendingRef =
|
|
689
|
+
const sentinelRef = React5.useRef(null);
|
|
690
|
+
const pendingRef = React5.useRef(pending);
|
|
691
|
+
const onLoadMoreRef = React5.useRef(onLoadMore);
|
|
692
|
+
const armedRef = React5.useRef(true);
|
|
693
|
+
const wasPendingRef = React5.useRef(false);
|
|
693
694
|
pendingRef.current = pending;
|
|
694
695
|
onLoadMoreRef.current = onLoadMore;
|
|
695
|
-
|
|
696
|
+
React5.useEffect(() => {
|
|
696
697
|
const node = sentinelRef.current;
|
|
697
698
|
if (!node || typeof IntersectionObserver === "undefined") return;
|
|
698
699
|
function maybeLoad() {
|
|
@@ -710,7 +711,7 @@ function LoadMoreControls({
|
|
|
710
711
|
observer.observe(node);
|
|
711
712
|
return () => observer.disconnect();
|
|
712
713
|
}, []);
|
|
713
|
-
|
|
714
|
+
React5.useEffect(() => {
|
|
714
715
|
if (pending) {
|
|
715
716
|
wasPendingRef.current = true;
|
|
716
717
|
return;
|
|
@@ -850,15 +851,15 @@ function NavigationProgress({
|
|
|
850
851
|
ariaLabel = "Loading",
|
|
851
852
|
forceVisible = false
|
|
852
853
|
}) {
|
|
853
|
-
const [visible, setVisible] =
|
|
854
|
-
const [runId, setRunId] =
|
|
855
|
-
const startedAt =
|
|
856
|
-
const startedRoute =
|
|
857
|
-
const committedRoute =
|
|
858
|
-
|
|
854
|
+
const [visible, setVisible] = React5.useState(forceVisible);
|
|
855
|
+
const [runId, setRunId] = React5.useState(0);
|
|
856
|
+
const startedAt = React5.useRef(0);
|
|
857
|
+
const startedRoute = React5.useRef(null);
|
|
858
|
+
const committedRoute = React5.useRef(null);
|
|
859
|
+
React5.useEffect(() => {
|
|
859
860
|
committedRoute.current = routeKey(pathname, search);
|
|
860
861
|
}, [pathname, search]);
|
|
861
|
-
|
|
862
|
+
React5.useEffect(() => {
|
|
862
863
|
if (forceVisible) return;
|
|
863
864
|
function begin(route) {
|
|
864
865
|
if (navigationSuppressed) return;
|
|
@@ -895,12 +896,12 @@ function NavigationProgress({
|
|
|
895
896
|
window.removeEventListener("popstate", onPopState);
|
|
896
897
|
};
|
|
897
898
|
}, [forceVisible, pathname, search]);
|
|
898
|
-
|
|
899
|
+
React5.useEffect(() => {
|
|
899
900
|
if (forceVisible || !visible) return;
|
|
900
901
|
const safety = window.setTimeout(() => setVisible(false), SAFETY_MS);
|
|
901
902
|
return () => window.clearTimeout(safety);
|
|
902
903
|
}, [forceVisible, runId, visible]);
|
|
903
|
-
|
|
904
|
+
React5.useEffect(() => {
|
|
904
905
|
if (forceVisible || !visible) return;
|
|
905
906
|
const started = startedRoute.current;
|
|
906
907
|
if (!started) return;
|
|
@@ -1383,20 +1384,20 @@ function useEditableSection({
|
|
|
1383
1384
|
...DEFAULT_EDITABLE_SECTION_LABELS,
|
|
1384
1385
|
...labels
|
|
1385
1386
|
};
|
|
1386
|
-
const [mode, setMode] =
|
|
1387
|
-
const [status, setStatus] =
|
|
1388
|
-
const [confirmOpen, setConfirmOpen] =
|
|
1389
|
-
const [minHeightPx, setMinHeightPx] =
|
|
1390
|
-
const contentRef =
|
|
1391
|
-
const editButtonRef =
|
|
1392
|
-
const measuredHeightRef =
|
|
1393
|
-
const shouldFocusEditRef =
|
|
1394
|
-
const shouldFocusFirstFieldRef =
|
|
1395
|
-
const editButtonId =
|
|
1396
|
-
const contentFormId =
|
|
1387
|
+
const [mode, setMode] = React5.useState("reading");
|
|
1388
|
+
const [status, setStatus] = React5.useState(null);
|
|
1389
|
+
const [confirmOpen, setConfirmOpen] = React5.useState(false);
|
|
1390
|
+
const [minHeightPx, setMinHeightPx] = React5.useState(void 0);
|
|
1391
|
+
const contentRef = React5.useRef(null);
|
|
1392
|
+
const editButtonRef = React5.useRef(null);
|
|
1393
|
+
const measuredHeightRef = React5.useRef(0);
|
|
1394
|
+
const shouldFocusEditRef = React5.useRef(false);
|
|
1395
|
+
const shouldFocusFirstFieldRef = React5.useRef(false);
|
|
1396
|
+
const editButtonId = React5.useId();
|
|
1397
|
+
const contentFormId = React5.useId();
|
|
1397
1398
|
const isEditing = mode === "editing" || mode === "saving";
|
|
1398
1399
|
const isSaving = mode === "saving";
|
|
1399
|
-
|
|
1400
|
+
React5.useEffect(() => {
|
|
1400
1401
|
if (mode === "reading" && shouldFocusEditRef.current) {
|
|
1401
1402
|
shouldFocusEditRef.current = false;
|
|
1402
1403
|
editButtonRef.current?.focus();
|
|
@@ -1414,18 +1415,18 @@ function useEditableSection({
|
|
|
1414
1415
|
focusFirstField(contentRef.current);
|
|
1415
1416
|
}
|
|
1416
1417
|
}, [mode]);
|
|
1417
|
-
const exitToReading =
|
|
1418
|
+
const exitToReading = React5.useCallback(() => {
|
|
1418
1419
|
setConfirmOpen(false);
|
|
1419
1420
|
shouldFocusEditRef.current = true;
|
|
1420
1421
|
setMode("reading");
|
|
1421
1422
|
onDiscard?.();
|
|
1422
1423
|
}, [onDiscard]);
|
|
1423
|
-
const startEdit =
|
|
1424
|
+
const startEdit = React5.useCallback(() => {
|
|
1424
1425
|
setStatus(null);
|
|
1425
1426
|
shouldFocusFirstFieldRef.current = true;
|
|
1426
1427
|
setMode("editing");
|
|
1427
1428
|
}, []);
|
|
1428
|
-
const requestCancel =
|
|
1429
|
+
const requestCancel = React5.useCallback(() => {
|
|
1429
1430
|
if (isSaving) return;
|
|
1430
1431
|
if (isDirty) {
|
|
1431
1432
|
setConfirmOpen(true);
|
|
@@ -1433,7 +1434,7 @@ function useEditableSection({
|
|
|
1433
1434
|
}
|
|
1434
1435
|
exitToReading();
|
|
1435
1436
|
}, [exitToReading, isDirty, isSaving]);
|
|
1436
|
-
const handleSubmit =
|
|
1437
|
+
const handleSubmit = React5.useCallback(
|
|
1437
1438
|
(event) => {
|
|
1438
1439
|
event.preventDefault();
|
|
1439
1440
|
if (isSaving) return;
|
|
@@ -1453,7 +1454,7 @@ function useEditableSection({
|
|
|
1453
1454
|
},
|
|
1454
1455
|
[isSaving, onSave, resolvedLabels.saved]
|
|
1455
1456
|
);
|
|
1456
|
-
const handleFormKeyDown =
|
|
1457
|
+
const handleFormKeyDown = React5.useCallback(
|
|
1457
1458
|
(event) => {
|
|
1458
1459
|
if (event.key !== "Escape") return;
|
|
1459
1460
|
event.preventDefault();
|
|
@@ -1461,7 +1462,7 @@ function useEditableSection({
|
|
|
1461
1462
|
},
|
|
1462
1463
|
[requestCancel]
|
|
1463
1464
|
);
|
|
1464
|
-
|
|
1465
|
+
React5.useEffect(() => {
|
|
1465
1466
|
if (!stableHeight || !isEditing) return;
|
|
1466
1467
|
const el = contentRef.current;
|
|
1467
1468
|
if (!el) return;
|
|
@@ -1707,16 +1708,16 @@ function SafeImage({
|
|
|
1707
1708
|
className,
|
|
1708
1709
|
...imgProps
|
|
1709
1710
|
}) {
|
|
1710
|
-
const [failed, setFailed] =
|
|
1711
|
-
const [loaded, setLoaded] =
|
|
1712
|
-
const imgRef =
|
|
1711
|
+
const [failed, setFailed] = React5.useState(false);
|
|
1712
|
+
const [loaded, setLoaded] = React5.useState(false);
|
|
1713
|
+
const imgRef = React5.useRef(null);
|
|
1713
1714
|
const resolvedSrc = typeof src === "string" && src.length > 0 ? src : null;
|
|
1714
1715
|
const resolvedBlur = resolveBlurDataUrl(blurDataUrl);
|
|
1715
|
-
|
|
1716
|
+
React5.useLayoutEffect(() => {
|
|
1716
1717
|
setFailed(false);
|
|
1717
1718
|
setLoaded(false);
|
|
1718
1719
|
}, [resolvedSrc]);
|
|
1719
|
-
|
|
1720
|
+
React5.useLayoutEffect(() => {
|
|
1720
1721
|
const img = imgRef.current;
|
|
1721
1722
|
if (!img) return;
|
|
1722
1723
|
if (isBrokenImage(img)) {
|
|
@@ -1826,17 +1827,17 @@ function ThemeSwitcher({
|
|
|
1826
1827
|
labels: userLabels
|
|
1827
1828
|
}) {
|
|
1828
1829
|
const { theme, setTheme } = nextThemes.useTheme();
|
|
1829
|
-
const [mounted, setMounted] =
|
|
1830
|
+
const [mounted, setMounted] = React5.useState(false);
|
|
1830
1831
|
const sizes = sizeClasses[size];
|
|
1831
1832
|
const shapeClass = shapeClasses[shape];
|
|
1832
1833
|
const labels = { ...defaultLabels, ...userLabels };
|
|
1833
|
-
const handleThemeClick =
|
|
1834
|
+
const handleThemeClick = React5.useCallback(
|
|
1834
1835
|
(themeKey) => {
|
|
1835
1836
|
setTheme(themeKey);
|
|
1836
1837
|
},
|
|
1837
1838
|
[setTheme]
|
|
1838
1839
|
);
|
|
1839
|
-
|
|
1840
|
+
React5.useEffect(() => {
|
|
1840
1841
|
setMounted(true);
|
|
1841
1842
|
}, []);
|
|
1842
1843
|
if (!mounted) {
|
|
@@ -3085,8 +3086,8 @@ function CountryPicker({
|
|
|
3085
3086
|
"aria-invalid": ariaInvalid
|
|
3086
3087
|
}) {
|
|
3087
3088
|
const labels = { ...defaultLabels2(purpose, locale), ...labelsProp };
|
|
3088
|
-
const items =
|
|
3089
|
-
const selected =
|
|
3089
|
+
const items = React5__namespace.useMemo(() => countryPickerItems(locale), [locale]);
|
|
3090
|
+
const selected = React5__namespace.useMemo(() => findItem(items, value), [items, value]);
|
|
3090
3091
|
const dialogPortalContainer = dialog_js.useDialogPortalContainer();
|
|
3091
3092
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3092
3093
|
name ? /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name, value: value.trim().toUpperCase() }) : null,
|
|
@@ -3187,8 +3188,8 @@ function CountryPicker({
|
|
|
3187
3188
|
] });
|
|
3188
3189
|
}
|
|
3189
3190
|
function useMediaQuery(query) {
|
|
3190
|
-
const [matches, setMatches] =
|
|
3191
|
-
|
|
3191
|
+
const [matches, setMatches] = React5.useState(false);
|
|
3192
|
+
React5.useEffect(() => {
|
|
3192
3193
|
if (typeof window === "undefined" || !window.matchMedia) return;
|
|
3193
3194
|
const mql = window.matchMedia(query);
|
|
3194
3195
|
const onChange = () => setMatches(mql.matches);
|
|
@@ -3236,25 +3237,27 @@ function SearchablePicker({
|
|
|
3236
3237
|
id,
|
|
3237
3238
|
className,
|
|
3238
3239
|
"aria-invalid": ariaInvalid,
|
|
3239
|
-
onOpenChange
|
|
3240
|
+
onOpenChange,
|
|
3241
|
+
onCreate,
|
|
3242
|
+
createLabel
|
|
3240
3243
|
}) {
|
|
3241
3244
|
const isMdUp = useMediaQuery(MD_UP);
|
|
3242
3245
|
const dialogPortalContainer = dialog_js.useDialogPortalContainer();
|
|
3243
|
-
const [open, setOpen] =
|
|
3244
|
-
const searchRef =
|
|
3246
|
+
const [open, setOpen] = React5__namespace.useState(false);
|
|
3247
|
+
const searchRef = React5__namespace.useRef(null);
|
|
3245
3248
|
function setOpenState(next) {
|
|
3246
3249
|
setOpen(next);
|
|
3247
3250
|
onOpenChange?.(next);
|
|
3248
3251
|
if (!next) onQueryChange("");
|
|
3249
3252
|
}
|
|
3250
|
-
const selected =
|
|
3253
|
+
const selected = React5__namespace.useMemo(() => {
|
|
3251
3254
|
if (!value) return null;
|
|
3252
3255
|
return options.find((option) => option.id === value) ?? {
|
|
3253
3256
|
id: value,
|
|
3254
3257
|
label: selectedLabel || value
|
|
3255
3258
|
};
|
|
3256
3259
|
}, [options, selectedLabel, value]);
|
|
3257
|
-
|
|
3260
|
+
React5__namespace.useEffect(() => {
|
|
3258
3261
|
if (!open || isMdUp) return;
|
|
3259
3262
|
const handle = window.setTimeout(() => searchRef.current?.focus(), 0);
|
|
3260
3263
|
return () => window.clearTimeout(handle);
|
|
@@ -3268,9 +3271,29 @@ function SearchablePicker({
|
|
|
3268
3271
|
onChange("");
|
|
3269
3272
|
onQueryChange("");
|
|
3270
3273
|
}
|
|
3274
|
+
const trimmedQuery = query.trim();
|
|
3275
|
+
const showCreate = Boolean(onCreate) && trimmedQuery !== "" && !loading;
|
|
3276
|
+
function handleCreate() {
|
|
3277
|
+
if (!onCreate || trimmedQuery === "") return;
|
|
3278
|
+
onCreate(trimmedQuery);
|
|
3279
|
+
setOpenState(false);
|
|
3280
|
+
}
|
|
3271
3281
|
const display = selectedLabel || selected?.label || "";
|
|
3272
3282
|
const sheetTitle = title || placeholder;
|
|
3273
3283
|
const searchLabel = searchPlaceholder || placeholder;
|
|
3284
|
+
const createActionLabel = createLabel ?? `Add "${trimmedQuery}"`;
|
|
3285
|
+
const createButton = showCreate ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3286
|
+
button_js.Button,
|
|
3287
|
+
{
|
|
3288
|
+
className: "w-full justify-start",
|
|
3289
|
+
disabled,
|
|
3290
|
+
size: "sm",
|
|
3291
|
+
type: "button",
|
|
3292
|
+
variant: "ghost",
|
|
3293
|
+
onClick: handleCreate,
|
|
3294
|
+
children: createActionLabel
|
|
3295
|
+
}
|
|
3296
|
+
) : null;
|
|
3274
3297
|
const loadMoreButton = hasMore && onLoadMore ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3275
3298
|
button_js.Button,
|
|
3276
3299
|
{
|
|
@@ -3392,7 +3415,10 @@ function SearchablePicker({
|
|
|
3392
3415
|
)
|
|
3393
3416
|
}
|
|
3394
3417
|
),
|
|
3395
|
-
loadMoreButton ? /* @__PURE__ */ jsxRuntime.
|
|
3418
|
+
createButton || loadMoreButton ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-t border-border p-1", children: [
|
|
3419
|
+
createButton,
|
|
3420
|
+
loadMoreButton
|
|
3421
|
+
] }) : null
|
|
3396
3422
|
] })
|
|
3397
3423
|
]
|
|
3398
3424
|
}
|
|
@@ -3479,8 +3505,9 @@ function SearchablePicker({
|
|
|
3479
3505
|
onChange: (event) => onQueryChange(event.target.value)
|
|
3480
3506
|
}
|
|
3481
3507
|
) }),
|
|
3482
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3483
|
-
|
|
3508
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-y-auto px-2 pb-4", children: loading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingRows, {}) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3509
|
+
options.length === 0 && !showCreate ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-2 py-3 text-sm text-muted-foreground", children: emptyLabel }) : null,
|
|
3510
|
+
options.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "flex flex-col gap-1 p-1", children: options.map((option) => {
|
|
3484
3511
|
const isSelected = option.id === value;
|
|
3485
3512
|
return /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3486
3513
|
"button",
|
|
@@ -3506,9 +3533,10 @@ function SearchablePicker({
|
|
|
3506
3533
|
]
|
|
3507
3534
|
}
|
|
3508
3535
|
) }, option.id);
|
|
3509
|
-
}) }),
|
|
3536
|
+
}) }) : null,
|
|
3537
|
+
createButton,
|
|
3510
3538
|
loadMoreButton
|
|
3511
|
-
] })
|
|
3539
|
+
] }) })
|
|
3512
3540
|
] }) })
|
|
3513
3541
|
] });
|
|
3514
3542
|
}
|
|
@@ -3550,18 +3578,18 @@ function PaginatedCombobox({
|
|
|
3550
3578
|
}) {
|
|
3551
3579
|
const labels = { ...DEFAULT_LABELS, ...labelsProp };
|
|
3552
3580
|
const dialogPortalContainer = dialog_js.useDialogPortalContainer();
|
|
3553
|
-
const selected =
|
|
3581
|
+
const selected = React5__namespace.useMemo(
|
|
3554
3582
|
() => resolveSelected(value, items, selectedItem),
|
|
3555
3583
|
[value, items, selectedItem]
|
|
3556
3584
|
);
|
|
3557
|
-
const listItems =
|
|
3585
|
+
const listItems = React5__namespace.useMemo(() => {
|
|
3558
3586
|
if (!selected) return items;
|
|
3559
3587
|
if (items.some((item) => item.value === selected.value)) return items;
|
|
3560
3588
|
return [selected, ...items];
|
|
3561
3589
|
}, [items, selected]);
|
|
3562
|
-
const queryRef =
|
|
3563
|
-
const debounceRef =
|
|
3564
|
-
|
|
3590
|
+
const queryRef = React5__namespace.useRef("");
|
|
3591
|
+
const debounceRef = React5__namespace.useRef(null);
|
|
3592
|
+
React5__namespace.useEffect(() => {
|
|
3565
3593
|
return () => {
|
|
3566
3594
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3567
3595
|
};
|
|
@@ -3834,7 +3862,7 @@ function PasswordInput({
|
|
|
3834
3862
|
hideLabel = "Hide password",
|
|
3835
3863
|
...props
|
|
3836
3864
|
}) {
|
|
3837
|
-
const [visible, setVisible] =
|
|
3865
|
+
const [visible, setVisible] = React5__namespace.useState(false);
|
|
3838
3866
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full", children: [
|
|
3839
3867
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3840
3868
|
input_js.Input,
|
|
@@ -3861,6 +3889,345 @@ function PasswordInput({
|
|
|
3861
3889
|
)
|
|
3862
3890
|
] });
|
|
3863
3891
|
}
|
|
3892
|
+
var MD_UP2 = "(min-width: 768px)";
|
|
3893
|
+
var ROW_CLASS = "flex h-8 w-full min-w-0 items-stretch overflow-hidden rounded-lg border border-input bg-transparent transition-colors outline-none focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40";
|
|
3894
|
+
var SEARCH_CLASS2 = "h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 md:text-sm dark:bg-input/30";
|
|
3895
|
+
function isCountryCode(value) {
|
|
3896
|
+
return libphonenumberJs.getCountries().includes(value);
|
|
3897
|
+
}
|
|
3898
|
+
function resolveCountry(code, fallback) {
|
|
3899
|
+
const normalized = (code ?? "").trim().toUpperCase();
|
|
3900
|
+
return isCountryCode(normalized) ? normalized : fallback;
|
|
3901
|
+
}
|
|
3902
|
+
function flagEmoji(iso) {
|
|
3903
|
+
const code = iso.trim().toUpperCase();
|
|
3904
|
+
if (!/^[A-Z]{2}$/.test(code)) return "\u{1F3F3}\uFE0F";
|
|
3905
|
+
return String.fromCodePoint(
|
|
3906
|
+
...code.split("").map((char) => 127397 + char.charCodeAt(0))
|
|
3907
|
+
);
|
|
3908
|
+
}
|
|
3909
|
+
var regionNames;
|
|
3910
|
+
function countryName(code) {
|
|
3911
|
+
try {
|
|
3912
|
+
regionNames ??= new Intl.DisplayNames(["en"], { type: "region" });
|
|
3913
|
+
return regionNames.of(code) ?? code;
|
|
3914
|
+
} catch {
|
|
3915
|
+
return code;
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
function buildCountryOptions() {
|
|
3919
|
+
return libphonenumberJs.getCountries().map((id) => {
|
|
3920
|
+
const dialCode = `+${libphonenumberJs.getCountryCallingCode(id)}`;
|
|
3921
|
+
const name = countryName(id);
|
|
3922
|
+
return {
|
|
3923
|
+
id,
|
|
3924
|
+
dialCode,
|
|
3925
|
+
flag: flagEmoji(id),
|
|
3926
|
+
label: `${name} (${dialCode})`
|
|
3927
|
+
};
|
|
3928
|
+
}).sort((left, right) => left.label.localeCompare(right.label, "en"));
|
|
3929
|
+
}
|
|
3930
|
+
var COUNTRY_OPTIONS2 = buildCountryOptions();
|
|
3931
|
+
function nationalDigits(value) {
|
|
3932
|
+
return value.replace(/\D/g, "");
|
|
3933
|
+
}
|
|
3934
|
+
function formatNational(country, raw) {
|
|
3935
|
+
const digits = nationalDigits(raw);
|
|
3936
|
+
if (!digits) return "";
|
|
3937
|
+
return new libphonenumberJs.AsYouType(country).input(digits);
|
|
3938
|
+
}
|
|
3939
|
+
function toE164(country, national) {
|
|
3940
|
+
const digits = nationalDigits(national);
|
|
3941
|
+
if (!digits) return "";
|
|
3942
|
+
const parsed = libphonenumberJs.parsePhoneNumberFromString(digits, country);
|
|
3943
|
+
if (parsed?.number) return parsed.number;
|
|
3944
|
+
return `+${libphonenumberJs.getCountryCallingCode(country)}${digits}`;
|
|
3945
|
+
}
|
|
3946
|
+
function parseIncoming(value, defaultCountry) {
|
|
3947
|
+
const trimmed = value.trim();
|
|
3948
|
+
if (!trimmed) {
|
|
3949
|
+
return { country: defaultCountry, national: "" };
|
|
3950
|
+
}
|
|
3951
|
+
const parsed = libphonenumberJs.parsePhoneNumberFromString(trimmed, defaultCountry);
|
|
3952
|
+
if (parsed) {
|
|
3953
|
+
const country = parsed.country ?? defaultCountry;
|
|
3954
|
+
const national = parsed.formatNational();
|
|
3955
|
+
return { country, national };
|
|
3956
|
+
}
|
|
3957
|
+
return {
|
|
3958
|
+
country: defaultCountry,
|
|
3959
|
+
national: formatNational(defaultCountry, trimmed)
|
|
3960
|
+
};
|
|
3961
|
+
}
|
|
3962
|
+
function filterCountries2(options, query) {
|
|
3963
|
+
const needle = query.trim().toLowerCase();
|
|
3964
|
+
if (!needle) return options;
|
|
3965
|
+
return options.filter((option) => {
|
|
3966
|
+
const haystack = `${option.label} ${option.id} ${option.dialCode}`.toLowerCase();
|
|
3967
|
+
return haystack.includes(needle);
|
|
3968
|
+
});
|
|
3969
|
+
}
|
|
3970
|
+
function PhoneInput({
|
|
3971
|
+
value,
|
|
3972
|
+
onValueChange,
|
|
3973
|
+
defaultCountry = "MX",
|
|
3974
|
+
searchPlaceholder = "Search country or code\u2026",
|
|
3975
|
+
countryListLabel = "Country",
|
|
3976
|
+
countryTriggerLabel = "Select country",
|
|
3977
|
+
emptyLabel = "No matches",
|
|
3978
|
+
className,
|
|
3979
|
+
disabled,
|
|
3980
|
+
id,
|
|
3981
|
+
name,
|
|
3982
|
+
"aria-invalid": ariaInvalid,
|
|
3983
|
+
"aria-label": ariaLabel,
|
|
3984
|
+
placeholder,
|
|
3985
|
+
...props
|
|
3986
|
+
}) {
|
|
3987
|
+
const resolvedDefault = resolveCountry(defaultCountry, "MX");
|
|
3988
|
+
const [country, setCountry] = React5__namespace.useState(
|
|
3989
|
+
() => parseIncoming(value, resolvedDefault).country
|
|
3990
|
+
);
|
|
3991
|
+
const [national, setNational] = React5__namespace.useState(
|
|
3992
|
+
() => parseIncoming(value, resolvedDefault).national
|
|
3993
|
+
);
|
|
3994
|
+
const [open, setOpen] = React5__namespace.useState(false);
|
|
3995
|
+
const [query, setQuery] = React5__namespace.useState("");
|
|
3996
|
+
const lastEmittedRef = React5__namespace.useRef(value);
|
|
3997
|
+
const isMdUp = useMediaQuery(MD_UP2);
|
|
3998
|
+
const dialogPortalContainer = dialog_js.useDialogPortalContainer();
|
|
3999
|
+
const searchRef = React5__namespace.useRef(null);
|
|
4000
|
+
React5__namespace.useEffect(() => {
|
|
4001
|
+
if (value === lastEmittedRef.current) return;
|
|
4002
|
+
lastEmittedRef.current = value;
|
|
4003
|
+
const next = parseIncoming(value, resolvedDefault);
|
|
4004
|
+
setCountry(next.country);
|
|
4005
|
+
setNational(next.national);
|
|
4006
|
+
}, [value, resolvedDefault]);
|
|
4007
|
+
React5__namespace.useEffect(() => {
|
|
4008
|
+
if (!open || isMdUp) return;
|
|
4009
|
+
const handle = window.setTimeout(() => searchRef.current?.focus(), 0);
|
|
4010
|
+
return () => window.clearTimeout(handle);
|
|
4011
|
+
}, [isMdUp, open]);
|
|
4012
|
+
const selected = COUNTRY_OPTIONS2.find((option) => option.id === country) ?? COUNTRY_OPTIONS2.find((option) => option.id === resolvedDefault);
|
|
4013
|
+
const filtered = React5__namespace.useMemo(
|
|
4014
|
+
() => filterCountries2(COUNTRY_OPTIONS2, query),
|
|
4015
|
+
[query]
|
|
4016
|
+
);
|
|
4017
|
+
function emit(nextCountry, nextNational) {
|
|
4018
|
+
const nextValue = toE164(nextCountry, nextNational);
|
|
4019
|
+
lastEmittedRef.current = nextValue;
|
|
4020
|
+
setCountry(nextCountry);
|
|
4021
|
+
setNational(nextNational);
|
|
4022
|
+
onValueChange(nextValue);
|
|
4023
|
+
}
|
|
4024
|
+
function setOpenState(next) {
|
|
4025
|
+
setOpen(next);
|
|
4026
|
+
if (!next) setQuery("");
|
|
4027
|
+
}
|
|
4028
|
+
function selectCountry(next) {
|
|
4029
|
+
const formatted = formatNational(next, national);
|
|
4030
|
+
emit(next, formatted);
|
|
4031
|
+
setOpenState(false);
|
|
4032
|
+
}
|
|
4033
|
+
function onNationalChange(nextRaw) {
|
|
4034
|
+
const formatted = formatNational(country, nextRaw);
|
|
4035
|
+
emit(country, formatted);
|
|
4036
|
+
}
|
|
4037
|
+
const dialDisplay = selected.dialCode;
|
|
4038
|
+
const countryTriggerClass = "inline-flex h-full shrink-0 items-center gap-1 border-r border-input px-2 text-sm outline-none disabled:pointer-events-none";
|
|
4039
|
+
const desktopPicker = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4040
|
+
combobox_js.Combobox.Root,
|
|
4041
|
+
{
|
|
4042
|
+
items: filtered,
|
|
4043
|
+
value: selected,
|
|
4044
|
+
open,
|
|
4045
|
+
onOpenChange: setOpenState,
|
|
4046
|
+
inputValue: query,
|
|
4047
|
+
onInputValueChange: setQuery,
|
|
4048
|
+
onValueChange: (item) => {
|
|
4049
|
+
if (item) selectCountry(item.id);
|
|
4050
|
+
},
|
|
4051
|
+
disabled,
|
|
4052
|
+
filter: null,
|
|
4053
|
+
autoComplete: "none",
|
|
4054
|
+
itemToStringLabel: (item) => item.label,
|
|
4055
|
+
itemToStringValue: (item) => item.id,
|
|
4056
|
+
isItemEqualToValue: (item, current) => item.id === current.id,
|
|
4057
|
+
children: [
|
|
4058
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4059
|
+
combobox_js.Combobox.Trigger,
|
|
4060
|
+
{
|
|
4061
|
+
"aria-invalid": ariaInvalid,
|
|
4062
|
+
"aria-label": countryTriggerLabel,
|
|
4063
|
+
className: countryTriggerClass,
|
|
4064
|
+
disabled,
|
|
4065
|
+
children: [
|
|
4066
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, className: "text-base leading-none", children: selected.flag }),
|
|
4067
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "tabular-nums text-muted-foreground", children: dialDisplay }),
|
|
4068
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4069
|
+
lucideReact.ChevronDownIcon,
|
|
4070
|
+
{
|
|
4071
|
+
"aria-hidden": true,
|
|
4072
|
+
className: "size-3.5 shrink-0 text-muted-foreground"
|
|
4073
|
+
}
|
|
4074
|
+
)
|
|
4075
|
+
]
|
|
4076
|
+
}
|
|
4077
|
+
),
|
|
4078
|
+
/* @__PURE__ */ jsxRuntime.jsx(combobox_js.Combobox.Portal, { container: dialogPortalContainer ?? void 0, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4079
|
+
combobox_js.Combobox.Positioner,
|
|
4080
|
+
{
|
|
4081
|
+
className: "pointer-events-auto isolate z-[60] outline-none",
|
|
4082
|
+
sideOffset: 4,
|
|
4083
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4084
|
+
combobox_js.Combobox.Popup,
|
|
4085
|
+
{
|
|
4086
|
+
className: cn(
|
|
4087
|
+
"pointer-events-auto z-[60] flex w-[min(20rem,var(--anchor-width))] min-w-[16rem] flex-col overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10",
|
|
4088
|
+
"motion-safe:data-open:animate-in motion-safe:data-open:fade-in-0 motion-safe:data-open:zoom-in-95"
|
|
4089
|
+
),
|
|
4090
|
+
children: [
|
|
4091
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sticky top-0 z-10 border-b border-border bg-popover p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4092
|
+
combobox_js.Combobox.Input,
|
|
4093
|
+
{
|
|
4094
|
+
"aria-label": searchPlaceholder,
|
|
4095
|
+
className: SEARCH_CLASS2,
|
|
4096
|
+
placeholder: searchPlaceholder
|
|
4097
|
+
}
|
|
4098
|
+
) }),
|
|
4099
|
+
/* @__PURE__ */ jsxRuntime.jsx(combobox_js.Combobox.Empty, { className: "px-3 py-3 text-sm text-muted-foreground", children: emptyLabel }),
|
|
4100
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4101
|
+
combobox_js.Combobox.List,
|
|
4102
|
+
{
|
|
4103
|
+
"aria-label": countryListLabel,
|
|
4104
|
+
className: "max-h-60 overflow-y-auto p-1 outline-none",
|
|
4105
|
+
onWheel: (event) => event.stopPropagation(),
|
|
4106
|
+
children: (item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4107
|
+
combobox_js.Combobox.Item,
|
|
4108
|
+
{
|
|
4109
|
+
value: item,
|
|
4110
|
+
className: cn(
|
|
4111
|
+
"relative flex cursor-default items-center gap-2 rounded-md py-2 pr-2 pl-8 text-sm outline-none select-none",
|
|
4112
|
+
"data-highlighted:bg-accent data-highlighted:text-accent-foreground"
|
|
4113
|
+
),
|
|
4114
|
+
children: [
|
|
4115
|
+
/* @__PURE__ */ jsxRuntime.jsx(combobox_js.Combobox.ItemIndicator, { className: "absolute left-2 flex size-4 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckIcon, { className: "size-4", "aria-hidden": true }) }),
|
|
4116
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, className: "text-base leading-none", children: item.flag }),
|
|
4117
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: item.label })
|
|
4118
|
+
]
|
|
4119
|
+
},
|
|
4120
|
+
item.id
|
|
4121
|
+
)
|
|
4122
|
+
}
|
|
4123
|
+
)
|
|
4124
|
+
]
|
|
4125
|
+
}
|
|
4126
|
+
)
|
|
4127
|
+
}
|
|
4128
|
+
) })
|
|
4129
|
+
]
|
|
4130
|
+
}
|
|
4131
|
+
);
|
|
4132
|
+
const mobileTrigger = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4133
|
+
"button",
|
|
4134
|
+
{
|
|
4135
|
+
"aria-expanded": open,
|
|
4136
|
+
"aria-haspopup": "dialog",
|
|
4137
|
+
"aria-invalid": ariaInvalid,
|
|
4138
|
+
"aria-label": countryTriggerLabel,
|
|
4139
|
+
className: countryTriggerClass,
|
|
4140
|
+
disabled,
|
|
4141
|
+
type: "button",
|
|
4142
|
+
onClick: () => setOpenState(true),
|
|
4143
|
+
children: [
|
|
4144
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, className: "text-base leading-none", children: selected.flag }),
|
|
4145
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "tabular-nums text-muted-foreground", children: dialDisplay }),
|
|
4146
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4147
|
+
lucideReact.ChevronDownIcon,
|
|
4148
|
+
{
|
|
4149
|
+
"aria-hidden": true,
|
|
4150
|
+
className: "size-3.5 shrink-0 text-muted-foreground"
|
|
4151
|
+
}
|
|
4152
|
+
)
|
|
4153
|
+
]
|
|
4154
|
+
}
|
|
4155
|
+
);
|
|
4156
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4157
|
+
"div",
|
|
4158
|
+
{
|
|
4159
|
+
"aria-invalid": ariaInvalid,
|
|
4160
|
+
className: cn(
|
|
4161
|
+
ROW_CLASS,
|
|
4162
|
+
disabled ? "pointer-events-none cursor-not-allowed bg-input/50 opacity-50 dark:bg-input/80" : null,
|
|
4163
|
+
className
|
|
4164
|
+
),
|
|
4165
|
+
children: [
|
|
4166
|
+
name ? /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name, value }) : null,
|
|
4167
|
+
isMdUp ? desktopPicker : mobileTrigger,
|
|
4168
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4169
|
+
"input",
|
|
4170
|
+
{
|
|
4171
|
+
...props,
|
|
4172
|
+
"aria-invalid": ariaInvalid,
|
|
4173
|
+
"aria-label": ariaLabel,
|
|
4174
|
+
autoComplete: props.autoComplete ?? "tel-national",
|
|
4175
|
+
className: "h-full min-w-0 flex-1 border-0 bg-transparent px-2.5 py-1 text-base outline-none placeholder:text-muted-foreground md:text-sm",
|
|
4176
|
+
disabled,
|
|
4177
|
+
id,
|
|
4178
|
+
inputMode: "tel",
|
|
4179
|
+
placeholder,
|
|
4180
|
+
type: "tel",
|
|
4181
|
+
value: national,
|
|
4182
|
+
onChange: (event) => onNationalChange(event.target.value)
|
|
4183
|
+
}
|
|
4184
|
+
),
|
|
4185
|
+
!isMdUp ? /* @__PURE__ */ jsxRuntime.jsx(drawer_js.Drawer, { open, onOpenChange: setOpenState, children: /* @__PURE__ */ jsxRuntime.jsxs(drawer_js.DrawerContent, { className: "max-h-[85vh]", children: [
|
|
4186
|
+
/* @__PURE__ */ jsxRuntime.jsx(drawer_js.DrawerHeader, { className: "text-left", children: /* @__PURE__ */ jsxRuntime.jsx(drawer_js.DrawerTitle, { children: countryListLabel }) }),
|
|
4187
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sticky top-0 z-10 border-b border-border bg-background px-4 pb-3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4188
|
+
input_js.Input,
|
|
4189
|
+
{
|
|
4190
|
+
ref: searchRef,
|
|
4191
|
+
"aria-label": searchPlaceholder,
|
|
4192
|
+
disabled,
|
|
4193
|
+
placeholder: searchPlaceholder,
|
|
4194
|
+
value: query,
|
|
4195
|
+
onChange: (event) => setQuery(event.target.value)
|
|
4196
|
+
}
|
|
4197
|
+
) }),
|
|
4198
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-y-auto px-2 pb-4", children: filtered.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-2 py-3 text-sm text-muted-foreground", children: emptyLabel }) : /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "flex flex-col gap-1 p-1", role: "listbox", children: filtered.map((option) => {
|
|
4199
|
+
const isSelected = option.id === country;
|
|
4200
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4201
|
+
"button",
|
|
4202
|
+
{
|
|
4203
|
+
"aria-selected": isSelected,
|
|
4204
|
+
className: cn(
|
|
4205
|
+
"flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm outline-none transition-colors",
|
|
4206
|
+
"hover:bg-muted/60 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",
|
|
4207
|
+
isSelected ? "bg-accent" : null
|
|
4208
|
+
),
|
|
4209
|
+
role: "option",
|
|
4210
|
+
type: "button",
|
|
4211
|
+
onClick: () => selectCountry(option.id),
|
|
4212
|
+
children: [
|
|
4213
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, className: "text-base leading-none", children: option.flag }),
|
|
4214
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: option.label }),
|
|
4215
|
+
isSelected ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4216
|
+
lucideReact.CheckIcon,
|
|
4217
|
+
{
|
|
4218
|
+
"aria-hidden": true,
|
|
4219
|
+
className: "size-4 shrink-0"
|
|
4220
|
+
}
|
|
4221
|
+
) : null
|
|
4222
|
+
]
|
|
4223
|
+
}
|
|
4224
|
+
) }, option.id);
|
|
4225
|
+
}) }) })
|
|
4226
|
+
] }) }) : null
|
|
4227
|
+
]
|
|
4228
|
+
}
|
|
4229
|
+
);
|
|
4230
|
+
}
|
|
3864
4231
|
var DEFAULT_LABELS2 = {
|
|
3865
4232
|
uploadAria: "Upload image",
|
|
3866
4233
|
uploadHint: "Click to upload",
|
|
@@ -3889,18 +4256,18 @@ function AvatarEditor({
|
|
|
3889
4256
|
labels
|
|
3890
4257
|
}) {
|
|
3891
4258
|
const t = { ...DEFAULT_LABELS2, ...labels };
|
|
3892
|
-
const canvasRef =
|
|
3893
|
-
const fileInputRef =
|
|
3894
|
-
const containerRef =
|
|
3895
|
-
const [image, setImage] =
|
|
3896
|
-
const [imageLoaded, setImageLoaded] =
|
|
3897
|
-
const [zoom, setZoom] =
|
|
3898
|
-
const [rotation, setRotation] =
|
|
3899
|
-
const [position, setPosition] =
|
|
3900
|
-
const [isDragging, setIsDragging] =
|
|
3901
|
-
const [dragStart, setDragStart] =
|
|
3902
|
-
const [showGrid, setShowGrid] =
|
|
3903
|
-
const generateOutput =
|
|
4259
|
+
const canvasRef = React5.useRef(null);
|
|
4260
|
+
const fileInputRef = React5.useRef(null);
|
|
4261
|
+
const containerRef = React5.useRef(null);
|
|
4262
|
+
const [image, setImage] = React5.useState(null);
|
|
4263
|
+
const [imageLoaded, setImageLoaded] = React5.useState(false);
|
|
4264
|
+
const [zoom, setZoom] = React5.useState(1);
|
|
4265
|
+
const [rotation, setRotation] = React5.useState(0);
|
|
4266
|
+
const [position, setPosition] = React5.useState({ x: 0, y: 0 });
|
|
4267
|
+
const [isDragging, setIsDragging] = React5.useState(false);
|
|
4268
|
+
const [dragStart, setDragStart] = React5.useState({ x: 0, y: 0 });
|
|
4269
|
+
const [showGrid, setShowGrid] = React5.useState(initialShowGrid);
|
|
4270
|
+
const generateOutput = React5.useCallback(() => {
|
|
3904
4271
|
if (!canvasRef.current || !image) return null;
|
|
3905
4272
|
const outputCanvas = document.createElement("canvas");
|
|
3906
4273
|
outputCanvas.width = outputSize;
|
|
@@ -3911,7 +4278,7 @@ function AvatarEditor({
|
|
|
3911
4278
|
const mimeType = `image/${outputFormat}`;
|
|
3912
4279
|
return outputCanvas.toDataURL(mimeType, outputQuality);
|
|
3913
4280
|
}, [image, outputSize, outputFormat, outputQuality]);
|
|
3914
|
-
|
|
4281
|
+
React5.useEffect(() => {
|
|
3915
4282
|
if (!canvasRef.current || !image || !imageLoaded) return;
|
|
3916
4283
|
const canvas = canvasRef.current;
|
|
3917
4284
|
const ctx = canvas.getContext("2d");
|
|
@@ -3955,12 +4322,12 @@ function AvatarEditor({
|
|
|
3955
4322
|
generateOutput,
|
|
3956
4323
|
onChange
|
|
3957
4324
|
]);
|
|
3958
|
-
const resetTransforms =
|
|
4325
|
+
const resetTransforms = React5.useCallback(() => {
|
|
3959
4326
|
setZoom(1);
|
|
3960
4327
|
setRotation(0);
|
|
3961
4328
|
setPosition({ x: 0, y: 0 });
|
|
3962
4329
|
}, []);
|
|
3963
|
-
const handleFileSelect =
|
|
4330
|
+
const handleFileSelect = React5.useCallback(
|
|
3964
4331
|
(e) => {
|
|
3965
4332
|
const file = e.target.files?.[0];
|
|
3966
4333
|
if (!file) return;
|
|
@@ -3979,7 +4346,7 @@ function AvatarEditor({
|
|
|
3979
4346
|
},
|
|
3980
4347
|
[resetTransforms]
|
|
3981
4348
|
);
|
|
3982
|
-
const handleMouseDown =
|
|
4349
|
+
const handleMouseDown = React5.useCallback(
|
|
3983
4350
|
(e) => {
|
|
3984
4351
|
if (!imageLoaded) return;
|
|
3985
4352
|
setIsDragging(true);
|
|
@@ -3987,7 +4354,7 @@ function AvatarEditor({
|
|
|
3987
4354
|
},
|
|
3988
4355
|
[imageLoaded, position]
|
|
3989
4356
|
);
|
|
3990
|
-
const handleMouseMove =
|
|
4357
|
+
const handleMouseMove = React5.useCallback(
|
|
3991
4358
|
(e) => {
|
|
3992
4359
|
if (!isDragging) return;
|
|
3993
4360
|
setPosition({
|
|
@@ -3997,10 +4364,10 @@ function AvatarEditor({
|
|
|
3997
4364
|
},
|
|
3998
4365
|
[isDragging, dragStart]
|
|
3999
4366
|
);
|
|
4000
|
-
const handleMouseUp =
|
|
4367
|
+
const handleMouseUp = React5.useCallback(() => {
|
|
4001
4368
|
setIsDragging(false);
|
|
4002
4369
|
}, []);
|
|
4003
|
-
const handleTouchStart =
|
|
4370
|
+
const handleTouchStart = React5.useCallback(
|
|
4004
4371
|
(e) => {
|
|
4005
4372
|
if (!imageLoaded) return;
|
|
4006
4373
|
const touch = e.touches[0];
|
|
@@ -4012,7 +4379,7 @@ function AvatarEditor({
|
|
|
4012
4379
|
},
|
|
4013
4380
|
[imageLoaded, position]
|
|
4014
4381
|
);
|
|
4015
|
-
const handleTouchMove =
|
|
4382
|
+
const handleTouchMove = React5.useCallback(
|
|
4016
4383
|
(e) => {
|
|
4017
4384
|
if (!isDragging) return;
|
|
4018
4385
|
const touch = e.touches[0];
|
|
@@ -4023,7 +4390,7 @@ function AvatarEditor({
|
|
|
4023
4390
|
},
|
|
4024
4391
|
[isDragging, dragStart]
|
|
4025
4392
|
);
|
|
4026
|
-
const handleDiscard =
|
|
4393
|
+
const handleDiscard = React5.useCallback(() => {
|
|
4027
4394
|
setImage(null);
|
|
4028
4395
|
setImageLoaded(false);
|
|
4029
4396
|
resetTransforms();
|
|
@@ -4394,8 +4761,8 @@ function AvatarEditor({
|
|
|
4394
4761
|
);
|
|
4395
4762
|
}
|
|
4396
4763
|
function useMediaQuery2(query) {
|
|
4397
|
-
const [matches, setMatches] =
|
|
4398
|
-
|
|
4764
|
+
const [matches, setMatches] = React5.useState(false);
|
|
4765
|
+
React5.useEffect(() => {
|
|
4399
4766
|
const media = window.matchMedia(query);
|
|
4400
4767
|
if (media.matches !== matches) {
|
|
4401
4768
|
setMatches(media.matches);
|
|
@@ -4425,17 +4792,17 @@ function AvatarEditorDialog({
|
|
|
4425
4792
|
className,
|
|
4426
4793
|
editorLabels
|
|
4427
4794
|
}) {
|
|
4428
|
-
const [isOpen, setIsOpen] =
|
|
4429
|
-
const [editedValue, setEditedValue] =
|
|
4430
|
-
const [displaySrc, setDisplaySrc] =
|
|
4431
|
-
const [isSaving, setIsSaving] =
|
|
4432
|
-
const [feedback, setFeedback] =
|
|
4433
|
-
|
|
4795
|
+
const [isOpen, setIsOpen] = React5.useState(false);
|
|
4796
|
+
const [editedValue, setEditedValue] = React5.useState(value ?? null);
|
|
4797
|
+
const [displaySrc, setDisplaySrc] = React5.useState(value ?? null);
|
|
4798
|
+
const [isSaving, setIsSaving] = React5.useState(false);
|
|
4799
|
+
const [feedback, setFeedback] = React5.useState(null);
|
|
4800
|
+
React5.useEffect(() => {
|
|
4434
4801
|
setDisplaySrc(value ?? null);
|
|
4435
4802
|
}, [value]);
|
|
4436
4803
|
const isMobile = useMediaQuery2("(max-width: 640px)");
|
|
4437
4804
|
const caption = (placeholder ?? "").trim();
|
|
4438
|
-
const handleOpenChange =
|
|
4805
|
+
const handleOpenChange = React5.useCallback(
|
|
4439
4806
|
(open) => {
|
|
4440
4807
|
if (open) {
|
|
4441
4808
|
setEditedValue(value ?? null);
|
|
@@ -4445,7 +4812,7 @@ function AvatarEditorDialog({
|
|
|
4445
4812
|
},
|
|
4446
4813
|
[value]
|
|
4447
4814
|
);
|
|
4448
|
-
const handleAccept =
|
|
4815
|
+
const handleAccept = React5.useCallback(async () => {
|
|
4449
4816
|
if (!editedValue) return;
|
|
4450
4817
|
setIsSaving(true);
|
|
4451
4818
|
setFeedback(null);
|
|
@@ -4712,10 +5079,10 @@ function FileDropzone({
|
|
|
4712
5079
|
className
|
|
4713
5080
|
}) {
|
|
4714
5081
|
const labels = { ...DEFAULT_FILE_DROPZONE_LABELS, ...labelOverrides };
|
|
4715
|
-
const inputId =
|
|
4716
|
-
const inputRef =
|
|
4717
|
-
const [dragging, setDragging] =
|
|
4718
|
-
const [message, setMessage] =
|
|
5082
|
+
const inputId = React5.useId();
|
|
5083
|
+
const inputRef = React5.useRef(null);
|
|
5084
|
+
const [dragging, setDragging] = React5.useState(false);
|
|
5085
|
+
const [message, setMessage] = React5.useState(null);
|
|
4719
5086
|
function takeFile(file) {
|
|
4720
5087
|
if (!file || disabled) return;
|
|
4721
5088
|
if (!fileMatchesAccept(file, accept)) {
|
|
@@ -4969,7 +5336,7 @@ function FileUploadMenu({
|
|
|
4969
5336
|
}) {
|
|
4970
5337
|
const labels = { ...DEFAULT_FILE_UPLOAD_TRAY_LABELS, ...labelOverrides };
|
|
4971
5338
|
const visible = jobs.filter((job) => job.status !== "cancelled");
|
|
4972
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
5339
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React5.useState(false);
|
|
4973
5340
|
const isControlled = open !== void 0;
|
|
4974
5341
|
const resolvedOpen = isControlled ? open : uncontrolledOpen;
|
|
4975
5342
|
function setResolvedOpen(next) {
|
|
@@ -5580,10 +5947,10 @@ function CookieConsentBanner({
|
|
|
5580
5947
|
className
|
|
5581
5948
|
}) {
|
|
5582
5949
|
const copy = { ...DEFAULT_COOKIE_CONSENT_BANNER_LABELS, ...labels };
|
|
5583
|
-
const [consent, setConsent] =
|
|
5950
|
+
const [consent, setConsent] = React5.useState(
|
|
5584
5951
|
"pending"
|
|
5585
5952
|
);
|
|
5586
|
-
|
|
5953
|
+
React5.useEffect(() => {
|
|
5587
5954
|
if (variant === "embed" || isEmbeddedWindow()) {
|
|
5588
5955
|
setConsent("necessary");
|
|
5589
5956
|
return;
|
|
@@ -6060,7 +6427,7 @@ function FormSection({
|
|
|
6060
6427
|
);
|
|
6061
6428
|
}
|
|
6062
6429
|
function useDirtyGuard(dirty) {
|
|
6063
|
-
|
|
6430
|
+
React5.useEffect(() => {
|
|
6064
6431
|
if (!dirty) return;
|
|
6065
6432
|
function onBeforeUnload(event) {
|
|
6066
6433
|
event.preventDefault();
|
|
@@ -6212,7 +6579,7 @@ function useQueueKeys({
|
|
|
6212
6579
|
selectedId,
|
|
6213
6580
|
onSelect
|
|
6214
6581
|
}) {
|
|
6215
|
-
const move =
|
|
6582
|
+
const move = React5.useCallback(
|
|
6216
6583
|
(delta) => {
|
|
6217
6584
|
if (ids.length === 0) return;
|
|
6218
6585
|
const currentIndex = selectedId ? ids.indexOf(selectedId) : -1;
|
|
@@ -6227,7 +6594,7 @@ function useQueueKeys({
|
|
|
6227
6594
|
},
|
|
6228
6595
|
[ids, onSelect, selectedId]
|
|
6229
6596
|
);
|
|
6230
|
-
|
|
6597
|
+
React5.useEffect(() => {
|
|
6231
6598
|
if (!enabled) return;
|
|
6232
6599
|
function onKeyDown(event) {
|
|
6233
6600
|
if (isTypingTarget(event.target)) return;
|
|
@@ -6331,8 +6698,8 @@ function prefersReducedMotion() {
|
|
|
6331
6698
|
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
6332
6699
|
}
|
|
6333
6700
|
function useSectionNav(sections) {
|
|
6334
|
-
const [active, setActive] =
|
|
6335
|
-
|
|
6701
|
+
const [active, setActive] = React5.useState(sections[0]?.id ?? "");
|
|
6702
|
+
React5.useEffect(() => {
|
|
6336
6703
|
const elements = sections.map((section) => document.getElementById(section.id)).filter((node) => node !== null);
|
|
6337
6704
|
if (elements.length === 0) return;
|
|
6338
6705
|
const observer = new IntersectionObserver(
|
|
@@ -6811,8 +7178,8 @@ function MatchReview({
|
|
|
6811
7178
|
className
|
|
6812
7179
|
}) {
|
|
6813
7180
|
const copy = { ...DEFAULT_MATCH_REVIEW_LABELS, ...labels };
|
|
6814
|
-
const reasonId =
|
|
6815
|
-
const [reason, setReason] =
|
|
7181
|
+
const reasonId = React5.useId();
|
|
7182
|
+
const [reason, setReason] = React5.useState("");
|
|
6816
7183
|
const trimmed = reason.trim();
|
|
6817
7184
|
if (!hit) {
|
|
6818
7185
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6990,6 +7357,7 @@ exports.PageTitle = PageTitle;
|
|
|
6990
7357
|
exports.PageTitleSkeleton = PageTitleSkeleton;
|
|
6991
7358
|
exports.PaginatedCombobox = PaginatedCombobox;
|
|
6992
7359
|
exports.PasswordInput = PasswordInput;
|
|
7360
|
+
exports.PhoneInput = PhoneInput;
|
|
6993
7361
|
exports.QueueLayout = QueueLayout;
|
|
6994
7362
|
exports.RfcInput = RfcInput;
|
|
6995
7363
|
exports.RiskBadge = RiskBadge;
|