mado-ui 0.2.3 → 0.3.0
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/css/index.css +975 -3421
- package/dist/components/button.d.ts +32 -10
- package/dist/components/details.d.ts +18 -0
- package/dist/components/drop-down.d.ts +28 -0
- package/dist/components/form/fieldset.d.ts +9 -0
- package/dist/components/form/index.d.ts +2 -1
- package/dist/components/form/input/index.d.ts +1 -1
- package/dist/components/form/submit-button.d.ts +24 -5
- package/dist/components/form/textarea.d.ts +1 -1
- package/dist/components/index.d.ts +5 -2
- package/dist/components/link.d.ts +31 -8
- package/dist/components/modal.d.ts +1 -2
- package/dist/components/tooltip.d.ts +26 -0
- package/dist/components.esm.js +2562 -285
- package/dist/components.esm.js.map +1 -1
- package/dist/components.js +2621 -313
- package/dist/components.js.map +1 -1
- package/dist/hooks.esm.js.map +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/icons.esm.js.map +1 -1
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.esm.js +2932 -663
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2972 -671
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/utils.d.ts +5 -7
- package/dist/utils/helpers.d.ts +7 -2
- package/dist/utils.esm.js.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +12 -9
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
2
2
|
import { extendTailwindMerge, twJoin } from 'tailwind-merge';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Children, isValidElement, Fragment, createContext, useContext, useSyncExternalStore, useRef, Suspense, useLayoutEffect, useState, useEffect, useCallback, cloneElement, useId } from 'react';
|
|
5
|
+
import { Button as Button$1, Disclosure, DisclosurePanel, DisclosureButton, Menu, MenuButton, MenuItem, MenuItems, MenuSection, MenuHeading, MenuSeparator, Fieldset as Fieldset$1, Legend, Field, Label, Input as Input$1, Description, Textarea as Textarea$1, Dialog, DialogBackdrop, DialogPanel } from '@headlessui/react';
|
|
6
|
+
import * as ReactDOM from 'react-dom';
|
|
5
7
|
import { createPortal } from 'react-dom';
|
|
6
8
|
|
|
7
9
|
const integerList = Array.from({ length: 100 }, (_, i) => `${i + 1}`);
|
|
@@ -308,7 +310,7 @@ function twSort(className) {
|
|
|
308
310
|
return className;
|
|
309
311
|
}
|
|
310
312
|
|
|
311
|
-
function Anchor({ className, disabled, href, onClick,
|
|
313
|
+
function Anchor({ as, className, disabled, href, onClick, target, rel, ...props }) {
|
|
312
314
|
const isExternal = `${href}`.startsWith('http'), hasHash = `${href}`.includes('#');
|
|
313
315
|
const handleClick = e => {
|
|
314
316
|
if (disabled)
|
|
@@ -316,7 +318,8 @@ function Anchor({ className, disabled, href, onClick, ref, target, rel, ...props
|
|
|
316
318
|
onClick?.(e);
|
|
317
319
|
setTimeout(() => history.replaceState({}, document.title, location.pathname), 100);
|
|
318
320
|
};
|
|
319
|
-
|
|
321
|
+
const AnchorElement = as || 'a';
|
|
322
|
+
return (jsx(AnchorElement, { ...props, "aria-disabled": disabled, className: twMerge(className, disabled && 'pointer-events-none'), href: href, target: target || (isExternal ? '_blank' : '_self'), onClick: hasHash ? handleClick : onClick, rel: rel !== undefined
|
|
320
323
|
? rel === 'nofollow'
|
|
321
324
|
? `${rel} noreferrer noopener`
|
|
322
325
|
: `${rel} prefetch`
|
|
@@ -345,68 +348,104 @@ const lineLiftClasses = twJoin([
|
|
|
345
348
|
]);
|
|
346
349
|
const fillClasses = twJoin(baseClasses, 'whitespace-nowrap transition-[transform_color] after:top-1/2 after:h-[calc(100%+0.05rem)] after:w-[calc(100%+0.25rem)] after:-translate-y-1/2 after:rounded after:ease-exponential active:text-zinc-50 pointer-fine:hover:text-zinc-50');
|
|
347
350
|
// Define theme-specific fill color transition classes
|
|
348
|
-
const getFillColorTransitionClasses = (theme = 'blue') => {
|
|
351
|
+
const getFillColorTransitionClasses = (theme = 'blue', customTheme) => {
|
|
352
|
+
let fillColorTransitionClasses = twJoin(fillClasses, 'transition-transform after:bg-(--theme-color)');
|
|
349
353
|
switch (theme) {
|
|
354
|
+
case 'blue':
|
|
355
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, 'after:[--theme-color:var(--color-ui-blue)]');
|
|
356
|
+
break;
|
|
350
357
|
case 'brown':
|
|
351
|
-
|
|
358
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, 'after:[--theme-color:var(--color-ui-brow)]');
|
|
359
|
+
break;
|
|
352
360
|
case 'green':
|
|
353
|
-
|
|
361
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, 'after:[--theme-color:var(--color-ui-green)]');
|
|
362
|
+
break;
|
|
354
363
|
case 'grey':
|
|
355
|
-
|
|
364
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, 'after:[--theme-color:var(--color-ui-grey)]');
|
|
365
|
+
break;
|
|
356
366
|
case 'sky-blue':
|
|
357
|
-
|
|
367
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, 'after:[--theme-color:var(--color-ui-sky-blue)]');
|
|
368
|
+
break;
|
|
358
369
|
case 'magenta':
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
return twJoin(fillClasses, 'after:bg-zinc-700 after:transition-transform contrast-more:after:bg-zinc-700 dark:after:bg-zinc-300 dark:contrast-more:after:bg-zinc-300');
|
|
370
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, 'after:[--theme-color:var(--color-ui-magenta)]');
|
|
371
|
+
break;
|
|
362
372
|
case 'orange':
|
|
363
|
-
|
|
373
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, 'after:[--theme-color:var(--color-ui-orange)]');
|
|
374
|
+
break;
|
|
364
375
|
case 'pink':
|
|
365
|
-
|
|
376
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, 'after:[--theme-color:var(--color-ui-pink)]');
|
|
377
|
+
break;
|
|
366
378
|
case 'purple':
|
|
367
|
-
|
|
379
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, 'after:[--theme-color:var(--color-ui-purple)]');
|
|
380
|
+
break;
|
|
368
381
|
case 'red':
|
|
369
|
-
|
|
382
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, 'after:[--theme-color:var(--color-ui-red)]');
|
|
383
|
+
break;
|
|
370
384
|
case 'violet':
|
|
371
|
-
|
|
385
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, 'after:[--theme-color:var(--color-ui-violet)]');
|
|
386
|
+
break;
|
|
372
387
|
case 'yellow':
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
388
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, 'after:[--theme-color:var(--color-ui-yellow)]');
|
|
389
|
+
break;
|
|
390
|
+
case 'custom':
|
|
391
|
+
if (customTheme && customTheme.themeColor && !customTheme.themeColor.includes('after:[--theme-color:'))
|
|
392
|
+
throw new Error('`customTheme.themeColor` must modify the `--theme-color` variable on the ::after pseudo element. Otherwise, please use `customTheme.classes`.');
|
|
393
|
+
fillColorTransitionClasses = customTheme.themeColor
|
|
394
|
+
? twMerge(fillColorTransitionClasses, customTheme.themeColor)
|
|
395
|
+
: twMerge(fillClasses, customTheme.classes);
|
|
396
|
+
break;
|
|
377
397
|
}
|
|
398
|
+
return fillColorTransitionClasses;
|
|
378
399
|
};
|
|
379
400
|
// Define theme-specific fill center classes
|
|
380
|
-
const getFillCenterClasses = (theme = 'blue') => {
|
|
401
|
+
const getFillCenterClasses = (theme = 'blue', customTheme) => {
|
|
402
|
+
let fillCenterColorClasses = twJoin(fillClasses, 'after:scale-x-50 after:scale-y-[0.25] after:bg-(--theme-color)/0 after:transition-[transform_background-color] active:after:scale-x-100 active:after:scale-y-100 active:after:bg-(--theme-color) pointer-fine:hover:after:scale-x-100 pointer-fine:hover:after:scale-y-100 pointer-fine:hover:after:bg-(--theme-color)');
|
|
381
403
|
switch (theme) {
|
|
404
|
+
case 'blue':
|
|
405
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, 'after:[--theme-color:var(--color-ui-blue)]');
|
|
406
|
+
break;
|
|
382
407
|
case 'brown':
|
|
383
|
-
|
|
408
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, 'after:[--theme-color:var(--color-ui-brown)]');
|
|
409
|
+
break;
|
|
384
410
|
case 'green':
|
|
385
|
-
|
|
411
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, 'after:[--theme-color:var(--color-ui-green)]');
|
|
412
|
+
break;
|
|
386
413
|
case 'grey':
|
|
387
|
-
|
|
414
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, 'after:[--theme-color:var(--color-ui-grey)]');
|
|
415
|
+
break;
|
|
388
416
|
case 'sky-blue':
|
|
389
|
-
|
|
417
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, 'after:[--theme-color:var(--color-ui-sky-blue)]');
|
|
418
|
+
break;
|
|
390
419
|
case 'magenta':
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
return twJoin(fillClasses, 'after:scale-x-50 after:scale-y-[0.25] after:bg-zinc-700/0 after:transition-[transform_background-color] active:after:scale-x-100 active:after:scale-y-100 active:after:bg-zinc-700 dark:after:bg-zinc-300/0 dark:active:after:bg-zinc-300 pointer-fine:hover:after:scale-x-100 pointer-fine:hover:after:scale-y-100 pointer-fine:hover:after:bg-zinc-700 dark:pointer-fine:hover:after:bg-zinc-300');
|
|
420
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, 'after:[--theme-color:var(--color-ui-magenta)]');
|
|
421
|
+
break;
|
|
394
422
|
case 'orange':
|
|
395
|
-
|
|
423
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, 'after:[--theme-color:var(--color-ui-orange)]');
|
|
424
|
+
break;
|
|
396
425
|
case 'pink':
|
|
397
|
-
|
|
426
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, 'after:[--theme-color:var(--color-ui-pink)]');
|
|
427
|
+
break;
|
|
398
428
|
case 'purple':
|
|
399
|
-
|
|
429
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, 'after:[--theme-color:var(--color-ui-purple)]');
|
|
430
|
+
break;
|
|
400
431
|
case 'red':
|
|
401
|
-
|
|
432
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, 'after:[--theme-color:var(--color-ui-red)]');
|
|
433
|
+
break;
|
|
402
434
|
case 'violet':
|
|
403
|
-
|
|
435
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, 'after:[--theme-color:var(--color-ui-violet)]');
|
|
436
|
+
break;
|
|
404
437
|
case 'yellow':
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
438
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, 'after:[--theme-color:var(--color-ui-yellow)]');
|
|
439
|
+
break;
|
|
440
|
+
case 'custom':
|
|
441
|
+
if (customTheme && customTheme.themeColor && !customTheme.themeColor.includes('after:[--theme-color:'))
|
|
442
|
+
throw new Error('`customTheme.themeColor` must modify the `--theme-color` variable on the ::after pseudo element. Otherwise, please use `customTheme.classes`.');
|
|
443
|
+
fillCenterColorClasses = customTheme.themeColor
|
|
444
|
+
? twMerge(fillCenterColorClasses, customTheme.themeColor)
|
|
445
|
+
: twMerge(fillClasses, customTheme.classes);
|
|
446
|
+
break;
|
|
409
447
|
}
|
|
448
|
+
return fillCenterColorClasses;
|
|
410
449
|
};
|
|
411
450
|
const multilineBaseClasses = twSort('bg-linear-to-r from-current to-current bg-no-repeat active:scale-95');
|
|
412
451
|
const multilineLineStaticClasses = 'underline';
|
|
@@ -418,80 +457,115 @@ const multilineLineRtlClasses = twJoin([multilineXClasses, 'bg-[position:100%_10
|
|
|
418
457
|
const multilineLineCenterClasses = twJoin([multilineXClasses, 'bg-[position:50%_100%]']);
|
|
419
458
|
const multilineLineLiftClasses = twJoin(multilineLineClasses, 'bg-[size:auto_0px] focus-visible:bg-[size:auto_2px] active:bg-[size:auto_2px] pointer-fine:hover:bg-[size:auto_2px]');
|
|
420
459
|
const multilineFillBaseClasses = twJoin(multilineBaseClasses, 'rounded px-0.5 py-0.75 focus-visible:text-zinc-50 active:text-zinc-50 pointer-fine:hover:text-zinc-50');
|
|
421
|
-
const getMultilineFillColorClasses = (theme = 'blue') => {
|
|
460
|
+
const getMultilineFillColorClasses = (theme = 'blue', customTheme) => {
|
|
461
|
+
let multilineFillColorClasses = twJoin(multilineFillBaseClasses, 'from-(--theme-color) to-(--theme-color) transition-[background-size_color]');
|
|
422
462
|
switch (theme) {
|
|
463
|
+
case 'blue':
|
|
464
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-blue)]');
|
|
465
|
+
break;
|
|
423
466
|
case 'brown':
|
|
424
|
-
|
|
467
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-brown)]');
|
|
468
|
+
break;
|
|
425
469
|
case 'green':
|
|
426
|
-
|
|
470
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-green)]');
|
|
471
|
+
break;
|
|
427
472
|
case 'grey':
|
|
428
|
-
|
|
473
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-grey)]');
|
|
474
|
+
break;
|
|
429
475
|
case 'sky-blue':
|
|
430
|
-
|
|
476
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-sky-blue)]');
|
|
477
|
+
break;
|
|
431
478
|
case 'magenta':
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
return twJoin(multilineFillBaseClasses, 'from-zinc-700 to-zinc-700 transition-[background-size_color] contrast-more:from-zinc-700 contrast-more:to-zinc-700 dark:from-zinc-300 dark:to-zinc-300 dark:contrast-more:from-zinc-300 dark:contrast-more:to-zinc-300');
|
|
479
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-magenta)]');
|
|
480
|
+
break;
|
|
435
481
|
case 'orange':
|
|
436
|
-
|
|
482
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-orange)]');
|
|
483
|
+
break;
|
|
437
484
|
case 'pink':
|
|
438
|
-
|
|
485
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-pink)]');
|
|
486
|
+
break;
|
|
439
487
|
case 'purple':
|
|
440
|
-
|
|
488
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-purple)]');
|
|
489
|
+
break;
|
|
441
490
|
case 'red':
|
|
442
|
-
|
|
491
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-red)]');
|
|
492
|
+
break;
|
|
443
493
|
case 'violet':
|
|
444
|
-
|
|
494
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-violet)]');
|
|
495
|
+
break;
|
|
445
496
|
case 'yellow':
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
497
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-yellow)]');
|
|
498
|
+
break;
|
|
499
|
+
case 'custom':
|
|
500
|
+
if (customTheme && customTheme.themeColor && !customTheme.themeColor.includes('[--theme-color:'))
|
|
501
|
+
throw new Error('`customTheme.themeColor` must modify the `--theme-color` variable. Otherwise, please use `customTheme.classes`.');
|
|
502
|
+
multilineFillColorClasses = customTheme.themeColor
|
|
503
|
+
? twMerge(multilineFillColorClasses, customTheme.themeColor)
|
|
504
|
+
: twMerge(multilineFillBaseClasses, customTheme.classes);
|
|
505
|
+
break;
|
|
450
506
|
}
|
|
507
|
+
return multilineFillColorClasses;
|
|
451
508
|
};
|
|
452
|
-
|
|
453
|
-
|
|
509
|
+
const getMultilineFillClasses = (theme = 'blue', customTheme) => {
|
|
510
|
+
let multilineFillColorClasses = twJoin(multilineFillBaseClasses, 'from-(--theme-color)/0 to-(--theme-color)/0 bg-[size:50%_0px] bg-[position:50%_50%] transition-[background-size_background-image_color] focus-visible:from-(--theme-color) focus-visible:to-(--theme-color) focus-visible:bg-[size:100%_100%] active:from-(--theme-color) active:to-(--theme-color) active:bg-[size:100%_100%] contrast-more:from-(--theme-color)/0 pointer-fine:hover:from-(--theme-color) pointer-fine:hover:to-(--theme-color) pointer-fine:hover:bg-[size:100%_100%]');
|
|
454
511
|
switch (theme) {
|
|
512
|
+
case 'blue':
|
|
513
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-blue)]');
|
|
514
|
+
break;
|
|
455
515
|
case 'brown':
|
|
456
|
-
|
|
516
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-brown)]');
|
|
517
|
+
break;
|
|
457
518
|
case 'green':
|
|
458
|
-
|
|
519
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-green)]');
|
|
520
|
+
break;
|
|
459
521
|
case 'grey':
|
|
460
|
-
|
|
522
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-grey)]');
|
|
523
|
+
break;
|
|
461
524
|
case 'sky-blue':
|
|
462
|
-
|
|
525
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-sky-blue)]');
|
|
526
|
+
break;
|
|
463
527
|
case 'magenta':
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
return twJoin(multilineFillBaseClasses, 'from-zinc-700/0 to-zinc-700/0 bg-[size:50%_0px] bg-[position:50%_50%] transition-[background-size_background-image_color] focus-visible:from-zinc-700 focus-visible:to-zinc-700 focus-visible:bg-[size:100%_100%] active:from-zinc-700 active:to-zinc-700 active:bg-[size:100%_100%] contrast-more:from-zinc-700/0 contrast-more:to-zinc-700/0 focus-visible:contrast-more:from-zinc-700 focus-visible:contrast-more:to-zinc-700 active:contrast-more:from-zinc-700 active:contrast-more:to-zinc-700 dark:from-zinc-300/0 dark:to-zinc-300/0 dark:focus-visible:from-zinc-300 dark:focus-visible:to-zinc-300 dark:active:from-zinc-300 dark:active:to-zinc-300 dark:contrast-more:from-zinc-300/0 dark:contrast-more:to-zinc-300/0 dark:focus-visible:contrast-more:from-zinc-300 dark:focus-visible:contrast-more:to-zinc-300 dark:active:contrast-more:from-zinc-300 dark:active:contrast-more:to-zinc-300 pointer-fine:hover:from-zinc-700 pointer-fine:hover:to-zinc-700 pointer-fine:hover:bg-[size:100%_100%] pointer-fine:hover:contrast-more:from-zinc-700 pointer-fine:hover:contrast-more:to-zinc-700 dark:pointer-fine:hover:from-zinc-300 dark:pointer-fine:hover:to-zinc-300 dark:pointer-fine:hover:contrast-more:from-zinc-300 dark:pointer-fine:hover:contrast-more:to-zinc-300');
|
|
528
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-magenta)]');
|
|
529
|
+
break;
|
|
467
530
|
case 'orange':
|
|
468
|
-
|
|
531
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-orange)]');
|
|
532
|
+
break;
|
|
469
533
|
case 'pink':
|
|
470
|
-
|
|
534
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-pink)]');
|
|
535
|
+
break;
|
|
471
536
|
case 'purple':
|
|
472
|
-
|
|
537
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-purple)]');
|
|
538
|
+
break;
|
|
473
539
|
case 'red':
|
|
474
|
-
|
|
540
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-red)]');
|
|
541
|
+
break;
|
|
475
542
|
case 'violet':
|
|
476
|
-
|
|
543
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-violet)]');
|
|
544
|
+
break;
|
|
477
545
|
case 'yellow':
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
546
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, '[--theme-color:var(--color-ui-yellow)]');
|
|
547
|
+
break;
|
|
548
|
+
case 'custom':
|
|
549
|
+
if (customTheme && customTheme.themeColor && !customTheme.themeColor.includes('[--theme-color:'))
|
|
550
|
+
throw new Error('`customTheme.themeColor` must modify the `--theme-color` variable. Otherwise, please use `customTheme.classes`.');
|
|
551
|
+
multilineFillColorClasses = customTheme.themeColor
|
|
552
|
+
? twMerge(multilineFillColorClasses, customTheme.themeColor)
|
|
553
|
+
: twMerge(multilineFillBaseClasses, customTheme.classes);
|
|
554
|
+
break;
|
|
482
555
|
}
|
|
556
|
+
return multilineFillColorClasses;
|
|
483
557
|
};
|
|
484
|
-
const getMultilineFillLiftClasses = (theme = 'blue') => {
|
|
485
|
-
return twJoin(getMultilineFillColorClasses(theme), 'bg-[size:auto_0px] bg-[position:50%_100%] focus-visible:bg-[size:auto_100%] active:bg-[size:auto_100%] pointer-fine:hover:bg-[size:auto_100%]');
|
|
558
|
+
const getMultilineFillLiftClasses = (theme = 'blue', customTheme) => {
|
|
559
|
+
return twJoin(getMultilineFillColorClasses(theme, customTheme), 'bg-[size:auto_0px] bg-[position:50%_100%] focus-visible:bg-[size:auto_100%] active:bg-[size:auto_100%] pointer-fine:hover:bg-[size:auto_100%]');
|
|
486
560
|
};
|
|
487
|
-
const getMultilineFillXClasses = (theme = 'blue') => {
|
|
488
|
-
return twJoin(getMultilineFillColorClasses(theme), 'bg-[size:0%_100%] focus-visible:bg-[size:100%_100%] active:bg-[size:100%_100%] pointer-fine:hover:bg-[size:100%_100%]');
|
|
561
|
+
const getMultilineFillXClasses = (theme = 'blue', customTheme) => {
|
|
562
|
+
return twJoin(getMultilineFillColorClasses(theme, customTheme), 'bg-[size:0%_100%] focus-visible:bg-[size:100%_100%] active:bg-[size:100%_100%] pointer-fine:hover:bg-[size:100%_100%]');
|
|
489
563
|
};
|
|
490
|
-
const getMultilineFillRtlClasses = (theme = 'blue') => {
|
|
491
|
-
return twJoin(getMultilineFillXClasses(theme), 'bg-[position:100%_auto]');
|
|
564
|
+
const getMultilineFillRtlClasses = (theme = 'blue', customTheme) => {
|
|
565
|
+
return twJoin(getMultilineFillXClasses(theme, customTheme), 'bg-[position:100%_auto]');
|
|
492
566
|
};
|
|
493
|
-
const getMultilineFillCenterClasses = (theme = 'blue') => {
|
|
494
|
-
return twJoin(getMultilineFillXClasses(theme), 'bg-[position:50%_auto]');
|
|
567
|
+
const getMultilineFillCenterClasses = (theme = 'blue', customTheme) => {
|
|
568
|
+
return twJoin(getMultilineFillXClasses(theme, customTheme), 'bg-[position:50%_auto]');
|
|
495
569
|
};
|
|
496
570
|
/**
|
|
497
571
|
* # Link
|
|
@@ -522,7 +596,7 @@ const getMultilineFillCenterClasses = (theme = 'blue') => {
|
|
|
522
596
|
* @example
|
|
523
597
|
* <Link href='/about' type='fill-ltr' theme='red' title='About Us'>Learn more about our company</Link>
|
|
524
598
|
*/
|
|
525
|
-
function Link({ as, className,
|
|
599
|
+
function Link({ as, className, customTheme, theme = 'blue', type, ...props }) {
|
|
526
600
|
const getLinkClasses = () => {
|
|
527
601
|
switch (type) {
|
|
528
602
|
case 'static':
|
|
@@ -536,13 +610,13 @@ function Link({ as, className, ref, theme = 'blue', type, ...props }) {
|
|
|
536
610
|
case 'lift':
|
|
537
611
|
return lineLiftClasses;
|
|
538
612
|
case 'fill':
|
|
539
|
-
return getFillCenterClasses(theme);
|
|
613
|
+
return getFillCenterClasses(theme, customTheme);
|
|
540
614
|
case 'fill-ltr':
|
|
541
|
-
return twJoin([getFillColorTransitionClasses(theme), scaleXClasses, 'after:origin-left']);
|
|
615
|
+
return twJoin([getFillColorTransitionClasses(theme, customTheme), scaleXClasses, 'after:origin-left']);
|
|
542
616
|
case 'fill-rtl':
|
|
543
|
-
return twJoin([getFillColorTransitionClasses(theme), scaleXClasses, 'after:origin-right']);
|
|
617
|
+
return twJoin([getFillColorTransitionClasses(theme, customTheme), scaleXClasses, 'after:origin-right']);
|
|
544
618
|
case 'fill-lift':
|
|
545
|
-
return twJoin([getFillColorTransitionClasses(theme), scaleYClasses, 'after:origin-bottom']);
|
|
619
|
+
return twJoin([getFillColorTransitionClasses(theme, customTheme), scaleYClasses, 'after:origin-bottom']);
|
|
546
620
|
case 'multiline':
|
|
547
621
|
return multilineNormalClasses;
|
|
548
622
|
case 'multiline-static':
|
|
@@ -556,29 +630,29 @@ function Link({ as, className, ref, theme = 'blue', type, ...props }) {
|
|
|
556
630
|
case 'multiline-lift':
|
|
557
631
|
return multilineLineLiftClasses;
|
|
558
632
|
case 'multiline-fill':
|
|
559
|
-
return getMultilineFillClasses(theme);
|
|
633
|
+
return getMultilineFillClasses(theme, customTheme);
|
|
560
634
|
case 'multiline-fill-ltr':
|
|
561
|
-
return getMultilineFillXClasses(theme);
|
|
635
|
+
return getMultilineFillXClasses(theme, customTheme);
|
|
562
636
|
case 'multiline-fill-rtl':
|
|
563
|
-
return getMultilineFillRtlClasses(theme);
|
|
637
|
+
return getMultilineFillRtlClasses(theme, customTheme);
|
|
564
638
|
case 'multiline-fill-center':
|
|
565
|
-
return getMultilineFillCenterClasses(theme);
|
|
639
|
+
return getMultilineFillCenterClasses(theme, customTheme);
|
|
566
640
|
case 'multiline-fill-lift':
|
|
567
|
-
return getMultilineFillLiftClasses(theme);
|
|
641
|
+
return getMultilineFillLiftClasses(theme, customTheme);
|
|
568
642
|
default:
|
|
569
643
|
return lineNormalClasses;
|
|
570
644
|
}
|
|
571
645
|
};
|
|
572
646
|
const linkClasses = getLinkClasses();
|
|
573
647
|
const LinkElement = as || Anchor;
|
|
574
|
-
return jsx(LinkElement, { ...props, className: twMerge(linkClasses, className)
|
|
648
|
+
return jsx(LinkElement, { ...props, className: twMerge(linkClasses, className) });
|
|
575
649
|
}
|
|
576
650
|
|
|
577
651
|
/**
|
|
578
652
|
* # Button
|
|
579
653
|
* - A pre-styled button with utility props for easy customization depending on use case.
|
|
580
654
|
*/
|
|
581
|
-
function Button({ className, padding = 'md', rounded = 'lg', theme = 'blue',
|
|
655
|
+
function Button({ className, customTheme, gradient = false, padding = 'md', rounded = 'lg', theme = 'blue', ...props }) {
|
|
582
656
|
const getPaddingClasses = () => {
|
|
583
657
|
switch (padding) {
|
|
584
658
|
case 'xs':
|
|
@@ -609,578 +683,90 @@ function Button({ className, padding = 'md', rounded = 'lg', theme = 'blue', ref
|
|
|
609
683
|
return 'rounded-full';
|
|
610
684
|
}
|
|
611
685
|
};
|
|
612
|
-
const
|
|
613
|
-
const classList = [];
|
|
686
|
+
const getThemeColorVariable = () => {
|
|
614
687
|
switch (theme) {
|
|
615
688
|
case 'blue':
|
|
616
|
-
|
|
617
|
-
break;
|
|
618
|
-
case 'blue-gradient':
|
|
619
|
-
classList.push(twSort('bg-ui-blue text-white shadow-lg shadow-ui-blue/25 transition-transform before:absolute before:inset-0 before:rounded-[inherit] before:bg-linear-to-t before:from-black/75 before:via-transparent before:to-white/75 before:opacity-75 before:mix-blend-soft-light before:transition-[filter] before:duration-300 before:ease-exponential active:before:brightness-90 pointer-fine:hover:before:brightness-110 pointer-fine:active:before:brightness-90'));
|
|
620
|
-
break;
|
|
689
|
+
return twSort('text-white [--theme-color:var(--color-ui-blue)]');
|
|
621
690
|
case 'brown':
|
|
622
|
-
|
|
623
|
-
break;
|
|
624
|
-
case 'brown-gradient':
|
|
625
|
-
classList.push(twSort('bg-ui-brown text-white shadow-lg shadow-ui-brown/25 transition-transform before:absolute before:inset-0 before:rounded-[inherit] before:bg-linear-to-t before:from-black/75 before:via-transparent before:to-white/75 before:opacity-75 before:mix-blend-soft-light before:transition-[filter] before:duration-300 before:ease-exponential active:before:brightness-90 pointer-fine:hover:before:brightness-110 pointer-fine:active:before:brightness-90'));
|
|
626
|
-
break;
|
|
691
|
+
return twSort('text-white [--theme-color:var(--color-ui-brown)]');
|
|
627
692
|
case 'green':
|
|
628
|
-
|
|
629
|
-
break;
|
|
630
|
-
case 'green-gradient':
|
|
631
|
-
classList.push(twSort('bg-ui-green text-white shadow-lg shadow-ui-green/25 transition-transform before:absolute before:inset-0 before:rounded-[inherit] before:bg-linear-to-t before:from-black/75 before:via-transparent before:to-white/75 before:opacity-75 before:mix-blend-soft-light before:transition-[filter] before:duration-300 before:ease-exponential active:before:brightness-90 pointer-fine:hover:before:brightness-110 pointer-fine:active:before:brightness-90'));
|
|
632
|
-
break;
|
|
693
|
+
return twSort('text-white [--theme-color:var(--color-ui-green)]');
|
|
633
694
|
case 'grey':
|
|
634
|
-
|
|
635
|
-
break;
|
|
636
|
-
case 'grey-gradient':
|
|
637
|
-
classList.push(twSort('bg-ui-grey text-white shadow-lg shadow-ui-grey/25 transition-transform before:absolute before:inset-0 before:rounded-[inherit] before:bg-linear-to-t before:from-black/75 before:via-transparent before:to-white/75 before:opacity-75 before:mix-blend-soft-light before:transition-[filter] before:duration-300 before:ease-exponential active:before:brightness-90 pointer-fine:hover:before:brightness-110 pointer-fine:active:before:brightness-90'));
|
|
638
|
-
break;
|
|
639
|
-
case 'sky-blue':
|
|
640
|
-
classList.push(twSort('text-white shadow-lg shadow-ui-sky-blue/25 transition-transform before:absolute before:inset-0 before:-z-10 before:rounded-[inherit] before:bg-ui-sky-blue before:transition-[filter] before:duration-300 before:ease-exponential active:before:brightness-90 pointer-fine:hover:before:brightness-110 pointer-fine:active:before:brightness-90'));
|
|
641
|
-
break;
|
|
642
|
-
case 'sky-blue-gradient':
|
|
643
|
-
classList.push(twSort('bg-ui-sky-blue text-white shadow-lg shadow-ui-sky-blue/25 transition-transform before:absolute before:inset-0 before:rounded-[inherit] before:bg-linear-to-t before:from-black/75 before:via-transparent before:to-white/75 before:opacity-75 before:mix-blend-soft-light before:transition-[filter] before:duration-300 before:ease-exponential active:before:brightness-90 pointer-fine:hover:before:brightness-110 pointer-fine:active:before:brightness-90'));
|
|
644
|
-
break;
|
|
695
|
+
return twSort('text-white [--theme-color:var(--color-ui-grey)]');
|
|
645
696
|
case 'magenta':
|
|
646
|
-
|
|
647
|
-
break;
|
|
648
|
-
case 'magenta-gradient':
|
|
649
|
-
classList.push(twSort('bg-ui-magenta text-white shadow-lg shadow-ui-magenta/25 transition-transform before:absolute before:inset-0 before:rounded-[inherit] before:bg-linear-to-t before:from-black/75 before:via-transparent before:to-white/75 before:opacity-75 before:mix-blend-soft-light before:transition-[filter] before:duration-300 before:ease-exponential active:before:brightness-90 pointer-fine:hover:before:brightness-110 pointer-fine:active:before:brightness-90'));
|
|
650
|
-
break;
|
|
651
|
-
case 'neutral':
|
|
652
|
-
classList.push(twSort('pointer-fine:active:before:brightness-90text-white dark bg-zinc-200 text-black before:absolute before:inset-0 before:rounded-[inherit] before:transition-[filter] before:duration-300 before:ease-exponential active:before:brightness-90 dark:bg-zinc-800 pointer-fine:hover:before:brightness-110'));
|
|
653
|
-
break;
|
|
654
|
-
case 'neutral-gradient':
|
|
655
|
-
classList.push(twSort('dark bg-linear-to-t from-zinc-300 via-zinc-200 to-zinc-100 text-black before:transition-[filter] before:duration-300 before:ease-exponential active:before:brightness-90 dark:from-zinc-900 dark:via-zinc-800 dark:to-zinc-700 pointer-fine:hover:before:brightness-110 pointer-fine:active:before:brightness-90'));
|
|
656
|
-
break;
|
|
697
|
+
return twSort('text-white [--theme-color:var(--color-ui-magenta)]');
|
|
657
698
|
case 'orange':
|
|
658
|
-
|
|
659
|
-
break;
|
|
660
|
-
case 'orange-gradient':
|
|
661
|
-
classList.push(twSort('bg-ui-orange text-white shadow-lg shadow-ui-orange/25 transition-transform before:absolute before:inset-0 before:rounded-[inherit] before:bg-linear-to-t before:from-black/75 before:via-transparent before:to-white/75 before:opacity-75 before:mix-blend-soft-light before:transition-[filter] before:duration-300 before:ease-exponential active:before:brightness-90 pointer-fine:hover:before:brightness-110 pointer-fine:active:before:brightness-90'));
|
|
662
|
-
break;
|
|
699
|
+
return twSort('text-white [--theme-color:var(--color-ui-orange)]');
|
|
663
700
|
case 'pink':
|
|
664
|
-
|
|
665
|
-
break;
|
|
666
|
-
case 'pink-gradient':
|
|
667
|
-
classList.push(twSort('before:to-white/75/75 bg-ui-pink text-white shadow-lg shadow-ui-pink/25 transition-transform before:absolute before:inset-0 before:rounded-[inherit] before:bg-linear-to-t before:from-black/75 before:via-transparent before:opacity-75 before:mix-blend-soft-light before:transition-[filter] before:duration-300 before:ease-exponential active:before:brightness-90 pointer-fine:hover:before:brightness-110 pointer-fine:active:before:brightness-90'));
|
|
668
|
-
break;
|
|
701
|
+
return twSort('text-white [--theme-color:var(--color-ui-pink)]');
|
|
669
702
|
case 'purple':
|
|
670
|
-
|
|
671
|
-
break;
|
|
672
|
-
case 'purple-gradient':
|
|
673
|
-
classList.push(twSort('bg-ui-purple text-white shadow-lg shadow-ui-purple/25 transition-transform before:absolute before:inset-0 before:rounded-[inherit] before:bg-linear-to-t before:from-black/75 before:via-transparent before:to-white/75 before:opacity-75 before:mix-blend-soft-light before:transition-[filter] before:duration-300 before:ease-exponential active:before:brightness-90 pointer-fine:hover:before:brightness-110 pointer-fine:active:before:brightness-90'));
|
|
674
|
-
break;
|
|
703
|
+
return twSort('text-white [--theme-color:var(--color-ui-purple)]');
|
|
675
704
|
case 'red':
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
classList.push(twSort('bg-ui-red text-white shadow-lg shadow-ui-red/25 transition-transform before:absolute before:inset-0 before:rounded-[inherit] before:bg-linear-to-t before:from-black/75 before:via-transparent before:to-white/75 before:opacity-75 before:mix-blend-soft-light before:transition-[filter] before:duration-300 before:ease-exponential active:before:brightness-90 pointer-fine:hover:before:brightness-110 pointer-fine:active:before:brightness-90'));
|
|
680
|
-
break;
|
|
705
|
+
return twSort('text-white [--theme-color:var(--color-ui-red)]');
|
|
706
|
+
case 'sky-blue':
|
|
707
|
+
return twSort('text-white [--theme-color:var(--color-ui-sky-blue)]');
|
|
681
708
|
case 'violet':
|
|
682
|
-
|
|
683
|
-
break;
|
|
684
|
-
case 'violet-gradient':
|
|
685
|
-
classList.push(twSort('bg-ui-violet text-white shadow-lg shadow-ui-violet/25 transition-transform before:absolute before:inset-0 before:rounded-[inherit] before:bg-linear-to-t before:from-black/75 before:via-transparent before:to-white/75 before:opacity-75 before:mix-blend-soft-light before:transition-[filter] before:duration-300 before:ease-exponential active:before:brightness-90 pointer-fine:hover:before:brightness-110 pointer-fine:active:before:brightness-90'));
|
|
686
|
-
break;
|
|
709
|
+
return twSort('text-white [--theme-color:var(--color-ui-violet)]');
|
|
687
710
|
case 'yellow':
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
711
|
+
return twSort('text-black [--theme-color:var(--color-ui-yellow)]');
|
|
712
|
+
case 'custom':
|
|
713
|
+
if (customTheme && customTheme.themeColor && !customTheme.themeColor.includes('[--theme-color:'))
|
|
714
|
+
throw new Error('`customTheme.themeColor` must modify the `--theme-color` variable. Otherwise, please use `customTheme.classes`.');
|
|
715
|
+
return customTheme.themeColor || customTheme.classes;
|
|
693
716
|
}
|
|
694
|
-
return classList.join(' ');
|
|
695
717
|
};
|
|
696
|
-
const paddingClasses = getPaddingClasses(), roundedClasses = getRoundedClasses(),
|
|
718
|
+
const paddingClasses = getPaddingClasses(), roundedClasses = getRoundedClasses(), themeColorVariable = getThemeColorVariable();
|
|
719
|
+
const themeClasses = customTheme && customTheme.classes
|
|
720
|
+
? customTheme.classes
|
|
721
|
+
: [
|
|
722
|
+
gradient
|
|
723
|
+
? twSort('bg-linear-to-t from-[color-mix(in_oklab,var(--theme-color),var(--color-black)_20%)] via-(--theme-color) to-[color-mix(in_oklab,var(--theme-color),var(--color-white)_20%)] bg-[size:100%_200%] transition-[scale,background-position-y] [background-position-y:50%] active:[background-position-y:100%] data-focus:[background-position-y:0%] pointer-fine:hover:[background-position-y:0%] pointer-fine:hover:active:[background-position-y:100%]')
|
|
724
|
+
: twSort('bg-(--theme-color) transition-[scale,background-color] active:bg-[color-mix(in_oklab,var(--theme-color),var(--color-black)_10%)] data-focus:bg-[color-mix(in_oklab,var(--theme-color),var(--color-white)_10%)] pointer-fine:hover:bg-[color-mix(in_oklab,var(--theme-color),var(--color-white)_10%)] pointer-fine:hover:active:bg-[color-mix(in_oklab,var(--theme-color),var(--color-black)_10%)]'),
|
|
725
|
+
'shadow-(--theme-color)/25',
|
|
726
|
+
].join(' ');
|
|
697
727
|
const buttonClasses = twMerge([
|
|
698
|
-
'block w-fit min-w-fit text-center font-semibold duration-300 ease-exponential
|
|
728
|
+
'block w-fit min-w-fit text-center font-semibold shadow-lg duration-300 ease-exponential active:scale-99 data-focus:scale-101 pointer-fine:hover:scale-101 pointer-fine:hover:active:scale-99',
|
|
699
729
|
paddingClasses,
|
|
700
730
|
roundedClasses,
|
|
731
|
+
themeColorVariable,
|
|
701
732
|
themeClasses,
|
|
702
733
|
className,
|
|
703
734
|
]);
|
|
704
|
-
|
|
735
|
+
const ButtonElement = 'as' in props ? props.as : props.href ? Anchor : Button$1;
|
|
736
|
+
const { as, ...restProps } = 'as' in props ? props : { ...props, as: undefined };
|
|
737
|
+
return jsx(ButtonElement, { ...restProps, className: buttonClasses });
|
|
705
738
|
}
|
|
706
739
|
|
|
707
|
-
function
|
|
708
|
-
|
|
709
|
-
const store = useRef(initialState), get = () => store.current, subscribers = useRef(new Set());
|
|
710
|
-
const set = (value) => {
|
|
711
|
-
if (typeof value === 'function') {
|
|
712
|
-
store.current = value(store.current);
|
|
713
|
-
}
|
|
714
|
-
else {
|
|
715
|
-
store.current = value;
|
|
716
|
-
}
|
|
717
|
-
subscribers.current.forEach(callback => callback());
|
|
718
|
-
};
|
|
719
|
-
const subscribe = (callback) => {
|
|
720
|
-
subscribers.current.add(callback);
|
|
721
|
-
return () => subscribers.current.delete(callback);
|
|
722
|
-
};
|
|
723
|
-
return {
|
|
724
|
-
get,
|
|
725
|
-
set,
|
|
726
|
-
subscribe,
|
|
727
|
-
};
|
|
728
|
-
}
|
|
729
|
-
const StoreContext = createContext(null);
|
|
730
|
-
function Provider({ initialValue = defaultInitialState, ...props }) {
|
|
731
|
-
return jsx(StoreContext.Provider, { value: useStoreData(initialValue), ...props });
|
|
732
|
-
}
|
|
733
|
-
function useStore(selector, initialValue) {
|
|
734
|
-
const store = useContext(StoreContext);
|
|
735
|
-
if (!store) {
|
|
736
|
-
const localStoreValue = initialValue !== undefined ? initialValue : defaultInitialState;
|
|
737
|
-
const selectedValue = selector(localStoreValue);
|
|
738
|
-
const noOpSet = () => console.warn('Attempting to set store value outside of Provider');
|
|
739
|
-
return [selectedValue, noOpSet];
|
|
740
|
-
}
|
|
741
|
-
const state = useSyncExternalStore(store.subscribe, () => selector(store.get()), () => selector(initialValue !== undefined ? initialValue : defaultInitialState));
|
|
742
|
-
return [state, store.set];
|
|
743
|
-
}
|
|
744
|
-
return {
|
|
745
|
-
Provider,
|
|
746
|
-
useStore,
|
|
747
|
-
};
|
|
740
|
+
function Airplane(props) {
|
|
741
|
+
return (jsx("svg", { viewBox: '0 0 64 63.9', ...props, children: jsx("path", { d: 'M62.7,1.3c-0.9-0.9-2-1.3-3.4-1.2c-1.4,0.1-3,0.5-4.5,1.2c-1.6,0.8-3.2,1.9-4.6,3.4L41,13.7c-0.7,0.7-1.2,1.1-1.6,1.2 c-0.5,0.2-1.1,0.3-1.9,0.2L5.5,13.8c-1.1-0.1-1.9,0.3-2.6,0.9l-2.6,2.6C0.1,17.6,0,18,0,18.4c0.1,0.4,0.3,0.7,0.9,0.8l25.3,9.5 L15.9,41.5L4.3,38.1c-0.9-0.3-1.6,0-2.4,0.7l-1,1c-0.3,0.3-0.5,0.6-0.5,1c0,0.4,0.1,0.7,0.5,1l21.3,21.3c0.3,0.3,0.6,0.5,1,0.4 c0.4-0.1,0.7-0.1,1-0.5l1-1c0.7-0.7,1-1.5,0.7-2.4L22.5,48l12.8-10.2l9.5,25.3c0.2,0.5,0.5,0.7,0.8,0.9c0.4,0.1,0.7,0,1-0.3l2.6-2.6 c0.7-0.7,1-1.5,0.9-2.6l-1.4-31.9c-0.1-0.8,0-1.4,0.2-1.9c0.2-0.5,0.6-1,1.2-1.6l9.1-9.1c1.4-1.4,2.6-3,3.4-4.6 C63.5,7.6,64,6.1,64,4.7S63.5,2.2,62.7,1.3z' }) }));
|
|
748
742
|
}
|
|
749
743
|
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
*
|
|
753
|
-
* This is a helper function to define a field in a form context with type safety.
|
|
754
|
-
*/
|
|
755
|
-
function defineField(fieldDefinition) {
|
|
756
|
-
return fieldDefinition;
|
|
744
|
+
function ArrowTriangle2CirclepathCircle(props) {
|
|
745
|
+
return (jsxs("svg", { viewBox: '0 0 64 64', ...props, children: [jsx("path", { d: 'M61.5,19.6c-1.7-3.9-4-7.3-6.9-10.2c-3-3-6.4-5.3-10.2-6.9C40.5,0.8,36.3,0,31.9,0c-4.4,0-8.5,0.8-12.3,2.5 c-3.9,1.7-7.3,4-10.2,6.9c-2.9,3-5.2,6.4-6.9,10.2C0.8,23.5,0,27.6,0,32c0,4.4,0.8,8.5,2.5,12.3c1.7,3.9,4,7.3,6.9,10.2 c2.9,3,6.3,5.3,10.2,6.9c3.9,1.7,8,2.5,12.3,2.5c4.4,0,8.5-0.8,12.4-2.5c3.9-1.7,7.3-4,10.2-6.9c2.9-3,5.3-6.4,6.9-10.2 S64,36.3,64,32C64,27.6,63.2,23.5,61.5,19.6z M56.6,42.4c-1.4,3.2-3.3,6.1-5.7,8.5c-2.4,2.4-5.3,4.4-8.5,5.7 c-3.2,1.4-6.7,2.1-10.4,2.1c-3.7,0-7.1-0.7-10.4-2.1c-3.2-1.4-6-3.3-8.5-5.7c-2.4-2.4-4.3-5.3-5.7-8.5C6.1,39.1,5.4,35.7,5.4,32 s0.7-7.1,2-10.4s3.3-6.1,5.7-8.5c2.4-2.4,5.3-4.4,8.5-5.7c3.2-1.4,6.7-2.1,10.4-2.1c3.7,0,7.2,0.7,10.4,2.1c3.2,1.4,6.1,3.3,8.5,5.7 c2.4,2.4,4.4,5.3,5.7,8.5s2.1,6.7,2.1,10.4S58,39.1,56.6,42.4z' }), jsx("path", { d: 'M32.1,49.5c2,0,3.9-0.3,5.7-1c1.9-0.6,3.5-1.5,4.8-2.6c0.7-0.6,1.2-1.3,1.3-2c0.2-0.7,0-1.4-0.6-2c-0.6-0.6-1.2-0.9-1.9-0.8 c-0.7,0-1.3,0.3-1.9,0.7c-1.1,0.9-2.3,1.6-3.5,2c-1.2,0.5-2.6,0.7-4.1,0.7c-2.1,0-4-0.4-5.8-1.3s-3.3-2-4.5-3.5 c-1.2-1.5-2.1-3.1-2.5-5h3.3c0.7,0,1.2-0.3,1.3-0.8c0.2-0.6,0-1.1-0.3-1.7l-5.1-7.1c-0.4-0.6-1-0.9-1.6-0.9c-0.6,0-1.2,0.3-1.6,0.9 l-5,7.1c-0.4,0.6-0.5,1.1-0.4,1.7s0.6,0.8,1.3,0.8h3.3c0.5,2.9,1.6,5.4,3.2,7.7c1.6,2.2,3.7,3.9,6.1,5.2 C26.4,48.9,29.1,49.5,32.1,49.5z' }), jsx("path", { d: 'M32,14.4c-2,0-3.9,0.3-5.7,1c-1.9,0.6-3.5,1.5-4.8,2.7c-0.8,0.6-1.2,1.2-1.4,2c-0.1,0.7,0.1,1.4,0.6,2 c0.5,0.6,1.1,0.9,1.8,0.8c0.7,0,1.3-0.3,1.9-0.8c1.1-0.9,2.3-1.5,3.5-2c1.2-0.5,2.6-0.7,4.1-0.7c2.1,0,4,0.4,5.8,1.3 c1.8,0.9,3.3,2,4.5,3.5c1.2,1.5,2.1,3.1,2.6,5h-3.5c-0.7,0-1.2,0.3-1.3,0.8c-0.2,0.6-0.1,1.1,0.4,1.7l5.1,7.1 c0.4,0.6,0.9,0.9,1.6,0.9c0.6,0,1.2-0.3,1.6-0.9l5-7.1c0.4-0.6,0.5-1.1,0.4-1.7c-0.2-0.6-0.6-0.8-1.3-0.8h-3.1 c-0.5-2.9-1.6-5.5-3.2-7.7s-3.7-3.9-6.2-5.2C37.8,15,35,14.4,32,14.4z' })] }));
|
|
757
746
|
}
|
|
758
|
-
|
|
759
|
-
function
|
|
760
|
-
return jsx(
|
|
747
|
+
|
|
748
|
+
function ArrowTriangle2CirclepathCircleFill(props) {
|
|
749
|
+
return (jsx("svg", { viewBox: '0 0 64 64', ...props, children: jsx("path", { d: 'M61.5,19.6c-1.7-3.9-4-7.3-6.9-10.2c-3-3-6.4-5.3-10.2-6.9C40.5,0.8,36.3,0,31.9,0c-4.4,0-8.5,0.8-12.3,2.5 c-3.9,1.7-7.3,4-10.2,6.9c-2.9,3-5.2,6.4-6.9,10.2C0.8,23.5,0,27.6,0,32s0.8,8.5,2.5,12.3c1.7,3.9,4,7.3,6.9,10.2 c2.9,3,6.3,5.3,10.2,6.9c3.9,1.7,8,2.5,12.3,2.5c4.4,0,8.5-0.8,12.4-2.5c3.9-1.7,7.3-4,10.2-6.9c2.9-3,5.3-6.4,6.9-10.2 S64,36.3,64,32S63.2,23.5,61.5,19.6z M44.5,44.2c-0.2,0.8-0.6,1.5-1.4,2.1c-1.4,1.1-3,2-4.9,2.7c-1.9,0.7-3.9,1-5.9,1 c-3.1,0-5.9-0.6-8.4-1.9c-2.5-1.3-4.6-3.1-6.3-5.3c-1.7-2.3-2.8-4.9-3.3-7.9h-3.4c-0.8,0-1.2-0.3-1.4-0.9c-0.2-0.6,0-1.2,0.4-1.7 l5.1-7.3c0.5-0.6,1-0.9,1.7-0.9c0.7,0,1.2,0.3,1.6,0.9l5.2,7.3c0.4,0.6,0.6,1.2,0.4,1.7s-0.6,0.9-1.4,0.9H19 c0.7,2.9,2.3,5.3,4.7,7.2c2.4,1.9,5.3,2.9,8.5,2.9c1.6,0,3-0.2,4.2-0.7s2.4-1.2,3.6-2.1c0.6-0.5,1.3-0.7,2-0.8 c0.7-0.1,1.3,0.2,1.9,0.8C44.4,42.8,44.6,43.5,44.5,44.2z M54.4,31.6l-5.2,7.3c-0.5,0.7-1,1-1.7,0.9c-0.7,0-1.2-0.3-1.6-0.9 l-5.3-7.3c-0.4-0.6-0.5-1.2-0.4-1.7c0.2-0.6,0.6-0.9,1.4-0.9h3.6c-0.7-2.9-2.3-5.3-4.7-7.2c-2.4-1.9-5.2-2.9-8.4-2.9 c-1.6,0-3,0.2-4.2,0.7s-2.4,1.2-3.6,2.1c-0.6,0.5-1.3,0.7-2,0.8c-0.7,0-1.3-0.2-1.9-0.8c-0.6-0.6-0.8-1.3-0.6-2 c0.2-0.8,0.6-1.5,1.4-2.1c1.4-1.1,3-2,4.9-2.7c1.9-0.7,3.9-1,5.9-1c3.1,0,5.9,0.6,8.4,1.9c2.5,1.3,4.6,3.1,6.3,5.3s2.8,4.9,3.3,7.9 h3.2c0.8,0,1.2,0.3,1.4,0.9S54.8,31,54.4,31.6z' }) }));
|
|
761
750
|
}
|
|
762
|
-
|
|
763
|
-
|
|
751
|
+
|
|
752
|
+
function BagFill(props) {
|
|
753
|
+
return (jsx("svg", { viewBox: '0 0 55.6 64', ...props, children: jsx("path", { d: 'M53.1,14.6c-1.6-1.6-4.1-2.4-7.4-2.4h-5c-0.1-2.2-0.7-4.2-1.9-6s-2.7-3.3-4.7-4.4C32.3,0.6,30.1,0,27.8,0 c-2.3,0-4.5,0.6-6.4,1.7c-1.9,1.1-3.5,2.6-4.7,4.4c-1.2,1.8-1.8,3.9-1.9,6h-5c-3.3,0-5.7,0.8-7.4,2.4C0.8,16.2,0,18.7,0,21.9v32.4 c0,3.2,0.8,5.7,2.5,7.3S6.6,64,9.8,64h36.8c2.8,0,5-0.8,6.6-2.4c1.6-1.6,2.3-4.1,2.3-7.3V21.9C55.6,18.7,54.7,16.2,53.1,14.6z M19.8,12.2c0-1.4,0.4-2.6,1.1-3.7c0.7-1.1,1.6-2,2.8-2.7c1.2-0.7,2.5-1,4-1c1.5,0,2.8,0.3,4,1c1.2,0.7,2.1,1.6,2.8,2.7 c0.7,1.1,1.1,2.4,1.1,3.7H19.8z' }) }));
|
|
764
754
|
}
|
|
765
755
|
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
function FormStatusProvider({ children, initialStatus = DEFAULT_STATUS, }) {
|
|
769
|
-
return (jsx(Suspense, { children: jsx(Provider, { initialValue: initialStatus, children: children }) }));
|
|
756
|
+
function Banknote(props) {
|
|
757
|
+
return (jsxs("svg", { viewBox: '0 0 64 40.1', ...props, children: [jsx("path", { d: 'M62.1,0H1.9C0.8,0,0,0.8,0,1.9v36.2c0,1.2,0.8,2,1.9,2h60.1c1.2,0,1.9-0.8,1.9-2V1.9C64,0.8,63.2,0,62.1,0z M60.1,35.5 c0,0.5-0.2,0.7-0.7,0.7H4.6c-0.5,0-0.7-0.2-0.7-0.7V4.6c0-0.5,0.2-0.7,0.7-0.7h54.8c0.5,0,0.7,0.2,0.7,0.7V35.5z' }), jsx("path", { d: 'M56.1,6.5H7.9C7,6.5,6.5,7,6.5,7.9v24.2c0,0.9,0.5,1.4,1.4,1.4h48.2c0.9,0,1.4-0.5,1.4-1.4V7.9C57.5,7,57,6.5,56.1,6.5z M55,30.5c0,0.4-0.2,0.6-0.5,0.6h-45c-0.4,0-0.5-0.2-0.5-0.6v-21c0-0.4,0.2-0.6,0.5-0.6h45c0.4,0,0.5,0.2,0.5,0.6V30.5z' }), jsx("path", { d: 'M31.9,6.5c-5.1,0-9.2,5.2-9.2,13.5c0,8.3,4.1,13.5,9.2,13.5c5.2,0,9.4-5.2,9.4-13.5C41.3,11.7,37.1,6.5,31.9,6.5z M31.9,30.7c-3.5,0-6.4-4.1-6.4-10.7c0-6.6,2.9-10.6,6.4-10.6c3.6,0,6.6,4.1,6.6,10.6C38.5,26.6,35.5,30.7,31.9,30.7z' })] }));
|
|
770
758
|
}
|
|
771
|
-
|
|
772
|
-
|
|
759
|
+
|
|
760
|
+
function BellFill(props) {
|
|
761
|
+
return (jsxs("svg", { viewBox: '0 0 57.4 64', ...props, children: [jsx("path", { d: 'M4.6,51.9h48.2c1.4,0,2.6-0.3,3.4-1c0.8-0.7,1.2-1.6,1.2-2.7c0-1.5-0.6-3-1.9-4.4c-1.3-1.4-2.5-2.8-3.8-4.1 c-0.7-0.7-1.2-1.6-1.6-2.7c-0.4-1.1-0.7-2.3-0.8-3.6s-0.3-2.5-0.4-3.6c-0.1-5.8-1-10.7-2.7-14.6c-1.7-3.9-4.6-6.6-8.7-8.1 c-0.6-2-1.6-3.6-3.1-5C32.8,0.7,31,0,28.7,0c-2.2,0-4.1,0.7-5.7,2.1c-1.5,1.4-2.6,3-3.1,5c-4.1,1.5-6.9,4.2-8.7,8.1 C9.5,19,8.6,23.9,8.5,29.7c-0.1,1.2-0.2,2.4-0.4,3.6c-0.2,1.3-0.5,2.4-0.8,3.6c-0.4,1.1-0.9,2-1.6,2.7c-1.3,1.3-2.6,2.7-3.9,4.1 C0.6,45.2,0,46.6,0,48.1c0,1.1,0.4,2,1.2,2.7C2,51.5,3.2,51.9,4.6,51.9z' }), jsx("path", { d: 'M28.7,64c2.6,0,4.7-0.8,6.4-2.4c1.7-1.6,2.7-3.5,2.9-5.6H19.4c0.2,2.1,1.1,4,2.9,5.6C24,63.2,26.1,64,28.7,64z' })] }));
|
|
773
762
|
}
|
|
774
763
|
|
|
775
|
-
function
|
|
776
|
-
|
|
777
|
-
if (!required && noValue)
|
|
778
|
-
return true;
|
|
779
|
-
if (noValue)
|
|
780
|
-
return false;
|
|
781
|
-
switch (type) {
|
|
782
|
-
case 'email':
|
|
783
|
-
return isEmail(value);
|
|
784
|
-
case 'number':
|
|
785
|
-
return !isNaN(Number(value));
|
|
786
|
-
case 'tel':
|
|
787
|
-
return isPhoneNumber(value);
|
|
788
|
-
default:
|
|
789
|
-
return true;
|
|
790
|
-
}
|
|
764
|
+
function BoltCar(props) {
|
|
765
|
+
return (jsxs("svg", { viewBox: '0 0 64 50.1', ...props, children: [jsx("path", { d: 'M60.5,20.6l-2.3-3c-1-4.9-2.8-10-3.7-12c-1.4-3-4.3-4.9-7.8-5.3C44.9,0.1,39-0.1,32-0.1S19.1,0.1,17.3,0.3 c-3.6,0.4-6.4,2.3-7.8,5.3c-0.9,2-2.7,7.1-3.7,12l-2.3,3C1,23.8,0.1,26.5,0.1,31.1v4.8c0,3.5,2.1,5.5,5.7,5.9c4.9,0.6,17,1,26.1,1 s21.2-0.4,26.3-1c3.7-0.4,5.7-2.4,5.7-5.9v-4.8C63.9,26.5,63,24,60.5,20.6z M60.4,34.9c0,2.1-0.8,3.3-3.1,3.5 c-4.4,0.5-16.2,0.9-25.4,0.9s-21-0.4-25.3-0.9c-2.3-0.3-3.1-1.5-3.1-3.5v-3.7c0-3.7,0.6-5.4,2.7-8.2L9,19.4 c0.7-3.9,2.5-9.4,3.6-11.9c0.9-1.9,2.6-3,5.1-3.3C19.4,4,24.9,3.7,32,3.7c7.1,0,12.7,0.3,14.2,0.5c2.6,0.3,4.2,1.5,5.1,3.3 c1.2,2.5,2.9,8,3.6,11.9l2.8,3.6c2.1,2.7,2.7,4.5,2.7,8.2V34.9z' }), jsx("path", { d: 'M4.8,50.2H8c2,0,3.6-1.5,3.6-3.5v-6.4L1.2,38.8v7.9C1.3,48.7,2.8,50.2,4.8,50.2z' }), jsx("path", { d: 'M55.7,50.2h3.2c2,0,3.6-1.5,3.6-3.5v-7.9l-10.4,1.5v6.4C52.1,48.7,53.7,50.2,55.7,50.2z' }), jsx("path", { d: 'M23.3,23.1c0,0.5,0.4,0.9,0.9,0.9h6.7l-3.6,9.6c-0.5,1.3,0.9,2,1.7,0.9l10.8-13.6c0.2-0.2,0.4-0.5,0.4-0.8 c0-0.5-0.4-0.9-0.9-0.9h-6.7l3.5-9.6c0.5-1.3-0.9-2-1.7-0.9L23.6,22.3C23.4,22.6,23.3,22.8,23.3,23.1z' })] }));
|
|
791
766
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
placeholder = name + (required && !label ? '*' : '');
|
|
796
|
-
if (label === '*')
|
|
797
|
-
label = name;
|
|
798
|
-
const uniqueID = useId(), fieldContextID = toLowerCase(name, [, '_']) + '§' + uniqueID;
|
|
799
|
-
if (Boolean(formContext?.find(field => field.id === fieldContextID)?.invalid))
|
|
800
|
-
invalid = true;
|
|
801
|
-
const getFieldContextType = () => {
|
|
802
|
-
switch (type) {
|
|
803
|
-
case 'email':
|
|
804
|
-
return 'email';
|
|
805
|
-
case 'file':
|
|
806
|
-
return 'file';
|
|
807
|
-
case 'number':
|
|
808
|
-
return 'number';
|
|
809
|
-
case 'tel':
|
|
810
|
-
return 'tel';
|
|
811
|
-
case 'url':
|
|
812
|
-
return 'url';
|
|
813
|
-
default:
|
|
814
|
-
return 'string';
|
|
815
|
-
}
|
|
816
|
-
};
|
|
817
|
-
const fieldContextType = getFieldContextType();
|
|
818
|
-
const initialFieldContext = defineField({
|
|
819
|
-
type: fieldContextType,
|
|
820
|
-
id: fieldContextID,
|
|
821
|
-
invalid,
|
|
822
|
-
name,
|
|
823
|
-
required,
|
|
824
|
-
value: value ? `${value}` : defaultValue ? `${defaultValue}` : '',
|
|
825
|
-
});
|
|
826
|
-
useEffect(() => {
|
|
827
|
-
if (!setFormContext)
|
|
828
|
-
return;
|
|
829
|
-
setFormContext(prevContext => {
|
|
830
|
-
const otherFields = (prevContext || []).filter(field => field.id !== initialFieldContext.id);
|
|
831
|
-
return [...otherFields, initialFieldContext];
|
|
832
|
-
});
|
|
833
|
-
return () => {
|
|
834
|
-
setFormContext(prevContext => (prevContext || []).filter(field => field.id !== initialFieldContext.id));
|
|
835
|
-
};
|
|
836
|
-
}, [setFormContext]);
|
|
837
|
-
const fieldContext = formContext?.find(({ id: fieldID }) => fieldID === initialFieldContext.id) || initialFieldContext;
|
|
838
|
-
const debounceTimerRef = useRef(undefined);
|
|
839
|
-
const handleChange = e => {
|
|
840
|
-
if (disabled) {
|
|
841
|
-
e.preventDefault();
|
|
842
|
-
return;
|
|
843
|
-
}
|
|
844
|
-
clearTimeout(debounceTimerRef.current);
|
|
845
|
-
const { currentTarget } = e, { value: newValue } = currentTarget;
|
|
846
|
-
setFormContext?.(prevContext => {
|
|
847
|
-
if (!prevContext)
|
|
848
|
-
return [];
|
|
849
|
-
const field = prevContext.find(({ id: fieldID }) => fieldID === initialFieldContext.id);
|
|
850
|
-
if (!field)
|
|
851
|
-
throw new Error(`Field with id "${initialFieldContext.id}" not found in form context.`);
|
|
852
|
-
const otherFields = prevContext.filter(({ id: fieldID }) => fieldID !== initialFieldContext.id);
|
|
853
|
-
const updatedField = { ...field, value: newValue };
|
|
854
|
-
return [...otherFields, updatedField];
|
|
855
|
-
});
|
|
856
|
-
debounceTimerRef.current = setTimeout(() => {
|
|
857
|
-
const field = formContext?.find(({ id: fieldID }) => fieldID === initialFieldContext.id);
|
|
858
|
-
if (!field)
|
|
859
|
-
return;
|
|
860
|
-
const invalid = validateField$1(newValue, field) === false;
|
|
861
|
-
if (invalid !== field.invalid)
|
|
862
|
-
setFormContext?.(prevContext => {
|
|
863
|
-
if (!prevContext)
|
|
864
|
-
return [];
|
|
865
|
-
const field = prevContext.find(({ id: fieldID }) => fieldID === initialFieldContext.id);
|
|
866
|
-
if (!field)
|
|
867
|
-
throw new Error(`Field with id "${initialFieldContext.id}" not found in form context.`);
|
|
868
|
-
const otherFields = prevContext.filter(({ id: fieldID }) => fieldID !== initialFieldContext.id);
|
|
869
|
-
const updatedField = { ...field, invalid };
|
|
870
|
-
return [...otherFields, updatedField];
|
|
871
|
-
});
|
|
872
|
-
}, 500);
|
|
873
|
-
onChange?.(e);
|
|
874
|
-
};
|
|
875
|
-
const handleBlur = e => {
|
|
876
|
-
if (disabled) {
|
|
877
|
-
e.preventDefault();
|
|
878
|
-
return;
|
|
879
|
-
}
|
|
880
|
-
const { currentTarget } = e, { value: newValue } = currentTarget;
|
|
881
|
-
switch (type) {
|
|
882
|
-
case 'email':
|
|
883
|
-
setFormContext?.(prevContext => {
|
|
884
|
-
if (!prevContext)
|
|
885
|
-
return [];
|
|
886
|
-
const field = prevContext.find(({ id: fieldID }) => fieldID === initialFieldContext.id);
|
|
887
|
-
if (!field)
|
|
888
|
-
throw new Error(`Field with id "${initialFieldContext.id}" not found in form context.`);
|
|
889
|
-
const otherFields = prevContext.filter(({ id: fieldID }) => fieldID !== initialFieldContext.id);
|
|
890
|
-
const updatedField = { ...field, value: newValue.toLowerCase() };
|
|
891
|
-
return [...otherFields, updatedField];
|
|
892
|
-
});
|
|
893
|
-
break;
|
|
894
|
-
case 'tel':
|
|
895
|
-
setFormContext?.(prevContext => {
|
|
896
|
-
if (!prevContext)
|
|
897
|
-
return [];
|
|
898
|
-
const field = prevContext.find(({ id: fieldID }) => fieldID === initialFieldContext.id);
|
|
899
|
-
if (!field)
|
|
900
|
-
throw new Error(`Field with id "${initialFieldContext.id}" not found in form context.`);
|
|
901
|
-
const otherFields = prevContext.filter(({ id: fieldID }) => fieldID !== initialFieldContext.id);
|
|
902
|
-
const updatedField = { ...field, value: formatPhoneNumber(newValue, '1') };
|
|
903
|
-
return [...otherFields, updatedField];
|
|
904
|
-
});
|
|
905
|
-
break;
|
|
906
|
-
}
|
|
907
|
-
onBlur?.(e);
|
|
908
|
-
};
|
|
909
|
-
const restFieldProps = fieldProps
|
|
910
|
-
? Object.fromEntries(Object.entries(fieldProps).filter(([key]) => key !== 'className'))
|
|
911
|
-
: {};
|
|
912
|
-
const restLabelProps = labelProps
|
|
913
|
-
? Object.fromEntries(Object.entries(labelProps).filter(([key]) => key !== 'className'))
|
|
914
|
-
: {};
|
|
915
|
-
const restDescriptionProps = descriptionProps
|
|
916
|
-
? Object.fromEntries(Object.entries(descriptionProps).filter(([key]) => key !== 'className'))
|
|
917
|
-
: {};
|
|
918
|
-
return (jsxs(Field, { ...restFieldProps, className: bag => twMerge('grid gap-1', typeof fieldProps?.className === 'function' ? fieldProps?.className(bag) : fieldProps?.className), disabled: disabled, children: [label && (jsx(Label, { ...restLabelProps, className: bag => twMerge('text-sm font-medium', required ? 'after:text-ui-red after:content-["_*"]' : '', typeof labelProps?.className === 'function' ? labelProps?.className(bag) : labelProps?.className), children: label })), jsx(Input$1, { ...props, className: bag => twMerge(
|
|
919
|
-
// Base styles
|
|
920
|
-
'rounded-xl border-1 border-neutral-500/50 bg-neutral-100 py-1 pl-2 text-neutral-950 outline-offset-1 outline-ui-sky-blue/95 transition-[background-color] duration-300 ease-exponential dark:bg-neutral-700 dark:text-neutral-50',
|
|
921
|
-
// Pseudo styles
|
|
922
|
-
'focus-visible:bg-neutral-50 focus-visible:outline-3 active:bg-neutral-200 dark:focus-visible:bg-neutral-600 dark:active:bg-neutral-800 pointer-fine:hover:bg-neutral-50 pointer-fine:active:bg-neutral-200 dark:pointer-fine:hover:bg-neutral-600 dark:pointer-fine:active:bg-neutral-800',
|
|
923
|
-
// user-invalid styles
|
|
924
|
-
'user-invalid:border-ui-red user-invalid:bg-[color-mix(in_oklab,var(--color-ui-red)_20%,var(--color-neutral-100))] user-invalid:focus-visible:bg-[color-mix(in_oklab,var(--color-ui-red)_1%,var(--color-neutral-100))] user-invalid:active:bg-[color-mix(in_oklab,var(--color-ui-red)_25%,var(--color-neutral-100))] dark:user-invalid:bg-[color-mix(in_oklab,var(--color-ui-red)_20%,var(--color-neutral-800))] dark:user-invalid:focus-visible:bg-[color-mix(in_oklab,var(--color-ui-red)_1%,var(--color-neutral-800))] dark:user-invalid:active:bg-[color-mix(in_oklab,var(--color-ui-red)_25%,var(--color-neutral-800))] user-invalid:pointer-fine:hover:bg-[color-mix(in_oklab,var(--color-ui-red)_10%,var(--color-neutral-100))] user-invalid:pointer-fine:focus-visible:bg-[color-mix(in_oklab,var(--color-ui-red)_1%,var(--color-neutral-100))] user-invalid:pointer-fine:active:bg-[color-mix(in_oklab,var(--color-ui-red)_25%,var(--color-neutral-100))] dark:user-invalid:pointer-fine:hover:bg-[color-mix(in_oklab,var(--color-ui-red)_10%,var(--color-neutral-800))] dark:user-invalid:pointer-fine:focus-visible:bg-[color-mix(in_oklab,var(--color-ui-red)_1%,var(--color-neutral-800))] dark:user-invalid:pointer-fine:active:bg-[color-mix(in_oklab,var(--color-ui-red)_25%,var(--color-neutral-800))]',
|
|
925
|
-
// Custom styles
|
|
926
|
-
typeof className === 'function' ? className(bag) : className), id: fieldContext?.id, invalid: invalid, onBlur: handleBlur, onChange: handleChange, placeholder: placeholder, ref: ref, required: required, type: type, value: fieldContext?.value }), description && (jsx(Description, { ...restDescriptionProps, className: bag => twMerge('text-xs', typeof descriptionProps?.className === 'function'
|
|
927
|
-
? descriptionProps?.className(bag)
|
|
928
|
-
: descriptionProps?.className), children: description }))] }));
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
function SubmitButton({ children, className, error, incomplete, loading, success, theme, type = 'submit', ref, ...props }) {
|
|
932
|
-
const [formStatus] = useFormStatus();
|
|
933
|
-
const getFormStatusButtonClasses = () => {
|
|
934
|
-
switch (formStatus) {
|
|
935
|
-
case 'loading':
|
|
936
|
-
return twSort('animate-pulse cursor-wait text-lg leading-6 font-black tracking-widest');
|
|
937
|
-
case 'error':
|
|
938
|
-
case 'success':
|
|
939
|
-
return 'cursor-not-allowed';
|
|
940
|
-
default:
|
|
941
|
-
return undefined;
|
|
942
|
-
}
|
|
943
|
-
};
|
|
944
|
-
const formStatusButtonClasses = getFormStatusButtonClasses();
|
|
945
|
-
const getFormStatusButtonTheme = () => {
|
|
946
|
-
switch (formStatus) {
|
|
947
|
-
case 'incomplete':
|
|
948
|
-
return 'grey';
|
|
949
|
-
case 'loading':
|
|
950
|
-
return 'blue';
|
|
951
|
-
case 'error':
|
|
952
|
-
return 'red';
|
|
953
|
-
case 'success':
|
|
954
|
-
return 'green';
|
|
955
|
-
default:
|
|
956
|
-
return theme;
|
|
957
|
-
}
|
|
958
|
-
};
|
|
959
|
-
const formStatusButtonTheme = getFormStatusButtonTheme();
|
|
960
|
-
const getButtonText = () => {
|
|
961
|
-
switch (formStatus) {
|
|
962
|
-
case 'incomplete':
|
|
963
|
-
return incomplete || 'Complete Form';
|
|
964
|
-
case 'loading':
|
|
965
|
-
return (loading || (jsxs(Fragment$1, { children: [jsx("span", { className: 'inline-block animate-wave animation-delay-300', children: "\u2022" }), jsx("span", { className: 'inline-block animate-wave animation-delay-150', children: "\u2022" }), jsx("span", { className: 'inline-block animate-wave', children: "\u2022" })] })));
|
|
966
|
-
case 'error':
|
|
967
|
-
return (jsxs(Fragment$1, { children: [error || 'Error', ' ', jsx("span", { className: 'absolute top-1/2 ml-1.5 translate-y-[calc(-50%-1.5px)] text-2xl', children: "\u00D7" })] }));
|
|
968
|
-
case 'success':
|
|
969
|
-
return success || 'Successfully Submitted';
|
|
970
|
-
default:
|
|
971
|
-
return children || 'Submit';
|
|
972
|
-
}
|
|
973
|
-
};
|
|
974
|
-
const buttonText = getButtonText();
|
|
975
|
-
return (jsx(Button, { ...props, className: twMerge([formStatusButtonClasses, 'w-full', className]), ref: ref, theme: formStatusButtonTheme, type: type, children: buttonText }));
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
function validateField(value, { required }) {
|
|
979
|
-
const noValue = !value || value === '';
|
|
980
|
-
if (!required && noValue)
|
|
981
|
-
return true;
|
|
982
|
-
if (noValue)
|
|
983
|
-
return false;
|
|
984
|
-
return true;
|
|
985
|
-
}
|
|
986
|
-
function Textarea({ className, defaultValue, description, descriptionProps, disabled, fieldProps, invalid = true, label, labelProps, name, onBlur, onChange, placeholder, ref, required = true, value, ...props }) {
|
|
987
|
-
const [formContext, setFormContext] = useFormContext();
|
|
988
|
-
if (placeholder === '*')
|
|
989
|
-
placeholder = name + (required && !label ? '*' : '');
|
|
990
|
-
if (label === '*')
|
|
991
|
-
label = name;
|
|
992
|
-
const uniqueID = useId(), fieldContextID = toLowerCase(name, [, '_']) + '§' + uniqueID;
|
|
993
|
-
if (Boolean(formContext?.find(field => field.id === fieldContextID)?.invalid))
|
|
994
|
-
invalid = true;
|
|
995
|
-
const initialFieldContext = defineField({
|
|
996
|
-
type: 'textarea',
|
|
997
|
-
id: fieldContextID,
|
|
998
|
-
invalid,
|
|
999
|
-
name,
|
|
1000
|
-
required,
|
|
1001
|
-
value: value ? `${value}` : defaultValue ? `${defaultValue}` : '',
|
|
1002
|
-
});
|
|
1003
|
-
useEffect(() => {
|
|
1004
|
-
if (!setFormContext)
|
|
1005
|
-
return;
|
|
1006
|
-
setFormContext(prevContext => {
|
|
1007
|
-
const otherFields = (prevContext || []).filter(field => field.id !== initialFieldContext.id);
|
|
1008
|
-
return [...otherFields, initialFieldContext];
|
|
1009
|
-
});
|
|
1010
|
-
return () => {
|
|
1011
|
-
setFormContext(prevContext => (prevContext || []).filter(field => field.id !== initialFieldContext.id));
|
|
1012
|
-
};
|
|
1013
|
-
}, [setFormContext]);
|
|
1014
|
-
const fieldContext = formContext?.find(({ id: fieldID }) => fieldID === initialFieldContext.id) || initialFieldContext;
|
|
1015
|
-
const debounceTimerRef = useRef(undefined);
|
|
1016
|
-
const handleChange = e => {
|
|
1017
|
-
if (disabled) {
|
|
1018
|
-
e.preventDefault();
|
|
1019
|
-
return;
|
|
1020
|
-
}
|
|
1021
|
-
clearTimeout(debounceTimerRef.current);
|
|
1022
|
-
const { currentTarget } = e, { value: newValue } = currentTarget;
|
|
1023
|
-
setFormContext?.(prevContext => {
|
|
1024
|
-
if (!prevContext)
|
|
1025
|
-
return [];
|
|
1026
|
-
const field = prevContext.find(({ id: fieldID }) => fieldID === initialFieldContext.id);
|
|
1027
|
-
if (!field)
|
|
1028
|
-
throw new Error(`Field with id "${initialFieldContext.id}" not found in form context.`);
|
|
1029
|
-
const otherFields = prevContext.filter(({ id: fieldID }) => fieldID !== initialFieldContext.id);
|
|
1030
|
-
const updatedField = { ...field, value: newValue };
|
|
1031
|
-
return [...otherFields, updatedField];
|
|
1032
|
-
});
|
|
1033
|
-
debounceTimerRef.current = setTimeout(() => {
|
|
1034
|
-
const field = formContext?.find(({ id: fieldID }) => fieldID === initialFieldContext.id);
|
|
1035
|
-
if (!field)
|
|
1036
|
-
return;
|
|
1037
|
-
const invalid = validateField(newValue, field) === false;
|
|
1038
|
-
if (invalid !== field.invalid)
|
|
1039
|
-
setFormContext?.(prevContext => {
|
|
1040
|
-
if (!prevContext)
|
|
1041
|
-
return [];
|
|
1042
|
-
const field = prevContext.find(({ id: fieldID }) => fieldID === initialFieldContext.id);
|
|
1043
|
-
if (!field)
|
|
1044
|
-
throw new Error(`Field with id "${initialFieldContext.id}" not found in form context.`);
|
|
1045
|
-
const otherFields = prevContext.filter(({ id: fieldID }) => fieldID !== initialFieldContext.id);
|
|
1046
|
-
const updatedField = { ...field, invalid };
|
|
1047
|
-
return [...otherFields, updatedField];
|
|
1048
|
-
});
|
|
1049
|
-
}, 500);
|
|
1050
|
-
onChange?.(e);
|
|
1051
|
-
};
|
|
1052
|
-
const restFieldProps = fieldProps
|
|
1053
|
-
? Object.fromEntries(Object.entries(fieldProps).filter(([key]) => key !== 'className'))
|
|
1054
|
-
: {};
|
|
1055
|
-
const restLabelProps = labelProps
|
|
1056
|
-
? Object.fromEntries(Object.entries(labelProps).filter(([key]) => key !== 'className'))
|
|
1057
|
-
: {};
|
|
1058
|
-
const restDescriptionProps = descriptionProps
|
|
1059
|
-
? Object.fromEntries(Object.entries(descriptionProps).filter(([key]) => key !== 'className'))
|
|
1060
|
-
: {};
|
|
1061
|
-
return (jsxs(Field, { ...restFieldProps, className: bag => twMerge('grid gap-1', typeof fieldProps?.className === 'function' ? fieldProps?.className(bag) : fieldProps?.className), disabled: disabled, children: [label && (jsx(Label, { ...restLabelProps, className: bag => twMerge('text-sm font-medium', required ? 'after:text-ui-red after:content-["_*"]' : '', typeof labelProps?.className === 'function' ? labelProps?.className(bag) : labelProps?.className), children: label })), jsx(Textarea$1, { ...props, className: bag => twMerge(
|
|
1062
|
-
// Base styles
|
|
1063
|
-
'field-sizing-content resize-none rounded-xl border-1 border-neutral-500/50 bg-neutral-100 py-1 pl-2 text-neutral-950 outline-offset-1 outline-ui-sky-blue/95 transition-[background-color] duration-300 ease-exponential dark:bg-neutral-700 dark:text-neutral-50',
|
|
1064
|
-
// Pseudo styles
|
|
1065
|
-
'focus-visible:bg-neutral-50 focus-visible:outline-3 active:bg-neutral-200 dark:focus-visible:bg-neutral-600 dark:active:bg-neutral-800 pointer-fine:hover:bg-neutral-50 pointer-fine:active:bg-neutral-200 dark:pointer-fine:hover:bg-neutral-600 dark:pointer-fine:active:bg-neutral-800',
|
|
1066
|
-
// user-invalid styles
|
|
1067
|
-
'user-invalid:border-ui-red user-invalid:bg-[color-mix(in_oklab,var(--color-ui-red)_20%,var(--color-neutral-100))] user-invalid:focus-visible:bg-[color-mix(in_oklab,var(--color-ui-red)_1%,var(--color-neutral-100))] user-invalid:active:bg-[color-mix(in_oklab,var(--color-ui-red)_25%,var(--color-neutral-100))] dark:user-invalid:bg-[color-mix(in_oklab,var(--color-ui-red)_20%,var(--color-neutral-800))] dark:user-invalid:focus-visible:bg-[color-mix(in_oklab,var(--color-ui-red)_1%,var(--color-neutral-800))] dark:user-invalid:active:bg-[color-mix(in_oklab,var(--color-ui-red)_25%,var(--color-neutral-800))] user-invalid:pointer-fine:hover:bg-[color-mix(in_oklab,var(--color-ui-red)_10%,var(--color-neutral-100))] user-invalid:pointer-fine:focus-visible:bg-[color-mix(in_oklab,var(--color-ui-red)_1%,var(--color-neutral-100))] user-invalid:pointer-fine:active:bg-[color-mix(in_oklab,var(--color-ui-red)_25%,var(--color-neutral-100))] dark:user-invalid:pointer-fine:hover:bg-[color-mix(in_oklab,var(--color-ui-red)_10%,var(--color-neutral-800))] dark:user-invalid:pointer-fine:focus-visible:bg-[color-mix(in_oklab,var(--color-ui-red)_1%,var(--color-neutral-800))] dark:user-invalid:pointer-fine:active:bg-[color-mix(in_oklab,var(--color-ui-red)_25%,var(--color-neutral-800))]',
|
|
1068
|
-
// Custom styles
|
|
1069
|
-
typeof className === 'function' ? className(bag) : className), id: fieldContext?.id, invalid: invalid, onChange: handleChange, placeholder: placeholder, ref: ref, required: required, value: fieldContext?.value }), description && (jsx(Description, { ...restDescriptionProps, className: bag => twMerge('text-xs', typeof descriptionProps?.className === 'function'
|
|
1070
|
-
? descriptionProps?.className(bag)
|
|
1071
|
-
: descriptionProps?.className), children: description }))] }));
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
// import { findComponentByType } from '../../utils'
|
|
1075
|
-
function FormComponent({ as, children, className, handleSubmit, onError, onSubmit, onSuccess, ...props }) {
|
|
1076
|
-
const [formContext] = useFormContext(), [formStatus, setFormStatus] = useFormStatus();
|
|
1077
|
-
// const submitButton = findComponentByType(children, SubmitButton)
|
|
1078
|
-
useEffect(() => {
|
|
1079
|
-
if (!formContext)
|
|
1080
|
-
return;
|
|
1081
|
-
if (formStatus !== 'incomplete' && formContext.find(({ invalid }) => invalid))
|
|
1082
|
-
setFormStatus?.('incomplete');
|
|
1083
|
-
if (formStatus !== 'ready' && formContext.every(({ invalid }) => !invalid))
|
|
1084
|
-
setFormStatus?.('ready');
|
|
1085
|
-
}, [formContext]);
|
|
1086
|
-
const processSubmit = handleSubmit ||
|
|
1087
|
-
(async (e) => {
|
|
1088
|
-
e.preventDefault();
|
|
1089
|
-
e.stopPropagation();
|
|
1090
|
-
setFormStatus?.('loading');
|
|
1091
|
-
const response = await onSubmit?.({ event: e, formContext });
|
|
1092
|
-
if (response && ('error' in response || response.status === 'error')) {
|
|
1093
|
-
setFormStatus?.('error');
|
|
1094
|
-
onError?.({ event: e, error: response.error || 'An error occurred when submitting the form.' });
|
|
1095
|
-
return;
|
|
1096
|
-
}
|
|
1097
|
-
if ((response && response.status === 'success') || !response) {
|
|
1098
|
-
setFormStatus?.('success');
|
|
1099
|
-
onSuccess?.({ event: e });
|
|
1100
|
-
}
|
|
1101
|
-
});
|
|
1102
|
-
const FormElement = as || 'form';
|
|
1103
|
-
return (jsx(FormElement, { ...props, className: twMerge(className, 'grid gap-3'), onSubmit: processSubmit, children: children }));
|
|
1104
|
-
}
|
|
1105
|
-
function Form({ controlled = 'auto', initialStatus = 'incomplete', ...props }) {
|
|
1106
|
-
const FormContextOrNotProvider = controlled === 'auto' ? FormContextProvider : Fragment;
|
|
1107
|
-
return (jsx(FormStatusProvider, { initialStatus: initialStatus, children: jsx(FormContextOrNotProvider, { children: jsx(FormComponent, { ...props }) }) }));
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
function Ghost({ children, className, ...props }) {
|
|
1111
|
-
return (jsx("div", { ...props, className: twMerge('block w-24 max-w-full animate-pulse rounded bg-white/50', className), children: children || jsx(Fragment$1, { children: "\u00A0" }) }));
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
function getTextFromChildren(children) {
|
|
1115
|
-
let text = '';
|
|
1116
|
-
Children.forEach(children, child => {
|
|
1117
|
-
if (typeof child === 'string' || typeof child === 'number') {
|
|
1118
|
-
text += child;
|
|
1119
|
-
}
|
|
1120
|
-
else if (isValidElement(child)) {
|
|
1121
|
-
text += getTextFromChildren(child.props.children);
|
|
1122
|
-
}
|
|
1123
|
-
});
|
|
1124
|
-
return text;
|
|
1125
|
-
}
|
|
1126
|
-
/**
|
|
1127
|
-
* # Heading
|
|
1128
|
-
* A heading component that renders HTML heading elements (h1-h6) with appropriate styling.
|
|
1129
|
-
* Automatically generates an ID for the heading based on its content if none is provided.
|
|
1130
|
-
*/
|
|
1131
|
-
function Heading({ as = 'h2', children, customize, className, id, ref, ...props }) {
|
|
1132
|
-
const H = as;
|
|
1133
|
-
const targetableID = id || getTextFromChildren(children).replace(/\s+/g, '-').toLowerCase();
|
|
1134
|
-
const getBaseClasses = () => {
|
|
1135
|
-
switch (as) {
|
|
1136
|
-
case 'h1':
|
|
1137
|
-
return customize?.h1 || twSort('pb-2.5 text-6xl font-black last:pb-0');
|
|
1138
|
-
case 'h3':
|
|
1139
|
-
return customize?.h3 || twSort('pb-2 text-4xl font-extralight last:pb-0');
|
|
1140
|
-
case 'h4':
|
|
1141
|
-
return customize?.h4 || twSort('pb-2 text-3xl font-extrabold last:pb-0');
|
|
1142
|
-
case 'h5':
|
|
1143
|
-
return customize?.h5 || twSort('pb-1.5 text-2xl font-semibold last:pb-0');
|
|
1144
|
-
case 'h6':
|
|
1145
|
-
return customize?.h6 || twSort('pb-1 text-xl font-bold last:pb-0');
|
|
1146
|
-
default:
|
|
1147
|
-
return customize?.h2 || twSort('pb-2.5 text-5xl font-medium last:pb-0');
|
|
1148
|
-
}
|
|
1149
|
-
};
|
|
1150
|
-
const baseClasses = getBaseClasses();
|
|
1151
|
-
return (jsx(H, { ref: ref, id: targetableID, ...props, className: twMerge(baseClasses, className), children: children }));
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
function Airplane(props) {
|
|
1155
|
-
return (jsx("svg", { viewBox: '0 0 64 63.9', ...props, children: jsx("path", { d: 'M62.7,1.3c-0.9-0.9-2-1.3-3.4-1.2c-1.4,0.1-3,0.5-4.5,1.2c-1.6,0.8-3.2,1.9-4.6,3.4L41,13.7c-0.7,0.7-1.2,1.1-1.6,1.2 c-0.5,0.2-1.1,0.3-1.9,0.2L5.5,13.8c-1.1-0.1-1.9,0.3-2.6,0.9l-2.6,2.6C0.1,17.6,0,18,0,18.4c0.1,0.4,0.3,0.7,0.9,0.8l25.3,9.5 L15.9,41.5L4.3,38.1c-0.9-0.3-1.6,0-2.4,0.7l-1,1c-0.3,0.3-0.5,0.6-0.5,1c0,0.4,0.1,0.7,0.5,1l21.3,21.3c0.3,0.3,0.6,0.5,1,0.4 c0.4-0.1,0.7-0.1,1-0.5l1-1c0.7-0.7,1-1.5,0.7-2.4L22.5,48l12.8-10.2l9.5,25.3c0.2,0.5,0.5,0.7,0.8,0.9c0.4,0.1,0.7,0,1-0.3l2.6-2.6 c0.7-0.7,1-1.5,0.9-2.6l-1.4-31.9c-0.1-0.8,0-1.4,0.2-1.9c0.2-0.5,0.6-1,1.2-1.6l9.1-9.1c1.4-1.4,2.6-3,3.4-4.6 C63.5,7.6,64,6.1,64,4.7S63.5,2.2,62.7,1.3z' }) }));
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
function ArrowTriangle2CirclepathCircle(props) {
|
|
1159
|
-
return (jsxs("svg", { viewBox: '0 0 64 64', ...props, children: [jsx("path", { d: 'M61.5,19.6c-1.7-3.9-4-7.3-6.9-10.2c-3-3-6.4-5.3-10.2-6.9C40.5,0.8,36.3,0,31.9,0c-4.4,0-8.5,0.8-12.3,2.5 c-3.9,1.7-7.3,4-10.2,6.9c-2.9,3-5.2,6.4-6.9,10.2C0.8,23.5,0,27.6,0,32c0,4.4,0.8,8.5,2.5,12.3c1.7,3.9,4,7.3,6.9,10.2 c2.9,3,6.3,5.3,10.2,6.9c3.9,1.7,8,2.5,12.3,2.5c4.4,0,8.5-0.8,12.4-2.5c3.9-1.7,7.3-4,10.2-6.9c2.9-3,5.3-6.4,6.9-10.2 S64,36.3,64,32C64,27.6,63.2,23.5,61.5,19.6z M56.6,42.4c-1.4,3.2-3.3,6.1-5.7,8.5c-2.4,2.4-5.3,4.4-8.5,5.7 c-3.2,1.4-6.7,2.1-10.4,2.1c-3.7,0-7.1-0.7-10.4-2.1c-3.2-1.4-6-3.3-8.5-5.7c-2.4-2.4-4.3-5.3-5.7-8.5C6.1,39.1,5.4,35.7,5.4,32 s0.7-7.1,2-10.4s3.3-6.1,5.7-8.5c2.4-2.4,5.3-4.4,8.5-5.7c3.2-1.4,6.7-2.1,10.4-2.1c3.7,0,7.2,0.7,10.4,2.1c3.2,1.4,6.1,3.3,8.5,5.7 c2.4,2.4,4.4,5.3,5.7,8.5s2.1,6.7,2.1,10.4S58,39.1,56.6,42.4z' }), jsx("path", { d: 'M32.1,49.5c2,0,3.9-0.3,5.7-1c1.9-0.6,3.5-1.5,4.8-2.6c0.7-0.6,1.2-1.3,1.3-2c0.2-0.7,0-1.4-0.6-2c-0.6-0.6-1.2-0.9-1.9-0.8 c-0.7,0-1.3,0.3-1.9,0.7c-1.1,0.9-2.3,1.6-3.5,2c-1.2,0.5-2.6,0.7-4.1,0.7c-2.1,0-4-0.4-5.8-1.3s-3.3-2-4.5-3.5 c-1.2-1.5-2.1-3.1-2.5-5h3.3c0.7,0,1.2-0.3,1.3-0.8c0.2-0.6,0-1.1-0.3-1.7l-5.1-7.1c-0.4-0.6-1-0.9-1.6-0.9c-0.6,0-1.2,0.3-1.6,0.9 l-5,7.1c-0.4,0.6-0.5,1.1-0.4,1.7s0.6,0.8,1.3,0.8h3.3c0.5,2.9,1.6,5.4,3.2,7.7c1.6,2.2,3.7,3.9,6.1,5.2 C26.4,48.9,29.1,49.5,32.1,49.5z' }), jsx("path", { d: 'M32,14.4c-2,0-3.9,0.3-5.7,1c-1.9,0.6-3.5,1.5-4.8,2.7c-0.8,0.6-1.2,1.2-1.4,2c-0.1,0.7,0.1,1.4,0.6,2 c0.5,0.6,1.1,0.9,1.8,0.8c0.7,0,1.3-0.3,1.9-0.8c1.1-0.9,2.3-1.5,3.5-2c1.2-0.5,2.6-0.7,4.1-0.7c2.1,0,4,0.4,5.8,1.3 c1.8,0.9,3.3,2,4.5,3.5c1.2,1.5,2.1,3.1,2.6,5h-3.5c-0.7,0-1.2,0.3-1.3,0.8c-0.2,0.6-0.1,1.1,0.4,1.7l5.1,7.1 c0.4,0.6,0.9,0.9,1.6,0.9c0.6,0,1.2-0.3,1.6-0.9l5-7.1c0.4-0.6,0.5-1.1,0.4-1.7c-0.2-0.6-0.6-0.8-1.3-0.8h-3.1 c-0.5-2.9-1.6-5.5-3.2-7.7s-3.7-3.9-6.2-5.2C37.8,15,35,14.4,32,14.4z' })] }));
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
function ArrowTriangle2CirclepathCircleFill(props) {
|
|
1163
|
-
return (jsx("svg", { viewBox: '0 0 64 64', ...props, children: jsx("path", { d: 'M61.5,19.6c-1.7-3.9-4-7.3-6.9-10.2c-3-3-6.4-5.3-10.2-6.9C40.5,0.8,36.3,0,31.9,0c-4.4,0-8.5,0.8-12.3,2.5 c-3.9,1.7-7.3,4-10.2,6.9c-2.9,3-5.2,6.4-6.9,10.2C0.8,23.5,0,27.6,0,32s0.8,8.5,2.5,12.3c1.7,3.9,4,7.3,6.9,10.2 c2.9,3,6.3,5.3,10.2,6.9c3.9,1.7,8,2.5,12.3,2.5c4.4,0,8.5-0.8,12.4-2.5c3.9-1.7,7.3-4,10.2-6.9c2.9-3,5.3-6.4,6.9-10.2 S64,36.3,64,32S63.2,23.5,61.5,19.6z M44.5,44.2c-0.2,0.8-0.6,1.5-1.4,2.1c-1.4,1.1-3,2-4.9,2.7c-1.9,0.7-3.9,1-5.9,1 c-3.1,0-5.9-0.6-8.4-1.9c-2.5-1.3-4.6-3.1-6.3-5.3c-1.7-2.3-2.8-4.9-3.3-7.9h-3.4c-0.8,0-1.2-0.3-1.4-0.9c-0.2-0.6,0-1.2,0.4-1.7 l5.1-7.3c0.5-0.6,1-0.9,1.7-0.9c0.7,0,1.2,0.3,1.6,0.9l5.2,7.3c0.4,0.6,0.6,1.2,0.4,1.7s-0.6,0.9-1.4,0.9H19 c0.7,2.9,2.3,5.3,4.7,7.2c2.4,1.9,5.3,2.9,8.5,2.9c1.6,0,3-0.2,4.2-0.7s2.4-1.2,3.6-2.1c0.6-0.5,1.3-0.7,2-0.8 c0.7-0.1,1.3,0.2,1.9,0.8C44.4,42.8,44.6,43.5,44.5,44.2z M54.4,31.6l-5.2,7.3c-0.5,0.7-1,1-1.7,0.9c-0.7,0-1.2-0.3-1.6-0.9 l-5.3-7.3c-0.4-0.6-0.5-1.2-0.4-1.7c0.2-0.6,0.6-0.9,1.4-0.9h3.6c-0.7-2.9-2.3-5.3-4.7-7.2c-2.4-1.9-5.2-2.9-8.4-2.9 c-1.6,0-3,0.2-4.2,0.7s-2.4,1.2-3.6,2.1c-0.6,0.5-1.3,0.7-2,0.8c-0.7,0-1.3-0.2-1.9-0.8c-0.6-0.6-0.8-1.3-0.6-2 c0.2-0.8,0.6-1.5,1.4-2.1c1.4-1.1,3-2,4.9-2.7c1.9-0.7,3.9-1,5.9-1c3.1,0,5.9,0.6,8.4,1.9c2.5,1.3,4.6,3.1,6.3,5.3s2.8,4.9,3.3,7.9 h3.2c0.8,0,1.2,0.3,1.4,0.9S54.8,31,54.4,31.6z' }) }));
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
function BagFill(props) {
|
|
1167
|
-
return (jsx("svg", { viewBox: '0 0 55.6 64', ...props, children: jsx("path", { d: 'M53.1,14.6c-1.6-1.6-4.1-2.4-7.4-2.4h-5c-0.1-2.2-0.7-4.2-1.9-6s-2.7-3.3-4.7-4.4C32.3,0.6,30.1,0,27.8,0 c-2.3,0-4.5,0.6-6.4,1.7c-1.9,1.1-3.5,2.6-4.7,4.4c-1.2,1.8-1.8,3.9-1.9,6h-5c-3.3,0-5.7,0.8-7.4,2.4C0.8,16.2,0,18.7,0,21.9v32.4 c0,3.2,0.8,5.7,2.5,7.3S6.6,64,9.8,64h36.8c2.8,0,5-0.8,6.6-2.4c1.6-1.6,2.3-4.1,2.3-7.3V21.9C55.6,18.7,54.7,16.2,53.1,14.6z M19.8,12.2c0-1.4,0.4-2.6,1.1-3.7c0.7-1.1,1.6-2,2.8-2.7c1.2-0.7,2.5-1,4-1c1.5,0,2.8,0.3,4,1c1.2,0.7,2.1,1.6,2.8,2.7 c0.7,1.1,1.1,2.4,1.1,3.7H19.8z' }) }));
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
function Banknote(props) {
|
|
1171
|
-
return (jsxs("svg", { viewBox: '0 0 64 40.1', ...props, children: [jsx("path", { d: 'M62.1,0H1.9C0.8,0,0,0.8,0,1.9v36.2c0,1.2,0.8,2,1.9,2h60.1c1.2,0,1.9-0.8,1.9-2V1.9C64,0.8,63.2,0,62.1,0z M60.1,35.5 c0,0.5-0.2,0.7-0.7,0.7H4.6c-0.5,0-0.7-0.2-0.7-0.7V4.6c0-0.5,0.2-0.7,0.7-0.7h54.8c0.5,0,0.7,0.2,0.7,0.7V35.5z' }), jsx("path", { d: 'M56.1,6.5H7.9C7,6.5,6.5,7,6.5,7.9v24.2c0,0.9,0.5,1.4,1.4,1.4h48.2c0.9,0,1.4-0.5,1.4-1.4V7.9C57.5,7,57,6.5,56.1,6.5z M55,30.5c0,0.4-0.2,0.6-0.5,0.6h-45c-0.4,0-0.5-0.2-0.5-0.6v-21c0-0.4,0.2-0.6,0.5-0.6h45c0.4,0,0.5,0.2,0.5,0.6V30.5z' }), jsx("path", { d: 'M31.9,6.5c-5.1,0-9.2,5.2-9.2,13.5c0,8.3,4.1,13.5,9.2,13.5c5.2,0,9.4-5.2,9.4-13.5C41.3,11.7,37.1,6.5,31.9,6.5z M31.9,30.7c-3.5,0-6.4-4.1-6.4-10.7c0-6.6,2.9-10.6,6.4-10.6c3.6,0,6.6,4.1,6.6,10.6C38.5,26.6,35.5,30.7,31.9,30.7z' })] }));
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
function BellFill(props) {
|
|
1175
|
-
return (jsxs("svg", { viewBox: '0 0 57.4 64', ...props, children: [jsx("path", { d: 'M4.6,51.9h48.2c1.4,0,2.6-0.3,3.4-1c0.8-0.7,1.2-1.6,1.2-2.7c0-1.5-0.6-3-1.9-4.4c-1.3-1.4-2.5-2.8-3.8-4.1 c-0.7-0.7-1.2-1.6-1.6-2.7c-0.4-1.1-0.7-2.3-0.8-3.6s-0.3-2.5-0.4-3.6c-0.1-5.8-1-10.7-2.7-14.6c-1.7-3.9-4.6-6.6-8.7-8.1 c-0.6-2-1.6-3.6-3.1-5C32.8,0.7,31,0,28.7,0c-2.2,0-4.1,0.7-5.7,2.1c-1.5,1.4-2.6,3-3.1,5c-4.1,1.5-6.9,4.2-8.7,8.1 C9.5,19,8.6,23.9,8.5,29.7c-0.1,1.2-0.2,2.4-0.4,3.6c-0.2,1.3-0.5,2.4-0.8,3.6c-0.4,1.1-0.9,2-1.6,2.7c-1.3,1.3-2.6,2.7-3.9,4.1 C0.6,45.2,0,46.6,0,48.1c0,1.1,0.4,2,1.2,2.7C2,51.5,3.2,51.9,4.6,51.9z' }), jsx("path", { d: 'M28.7,64c2.6,0,4.7-0.8,6.4-2.4c1.7-1.6,2.7-3.5,2.9-5.6H19.4c0.2,2.1,1.1,4,2.9,5.6C24,63.2,26.1,64,28.7,64z' })] }));
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
function BoltCar(props) {
|
|
1179
|
-
return (jsxs("svg", { viewBox: '0 0 64 50.1', ...props, children: [jsx("path", { d: 'M60.5,20.6l-2.3-3c-1-4.9-2.8-10-3.7-12c-1.4-3-4.3-4.9-7.8-5.3C44.9,0.1,39-0.1,32-0.1S19.1,0.1,17.3,0.3 c-3.6,0.4-6.4,2.3-7.8,5.3c-0.9,2-2.7,7.1-3.7,12l-2.3,3C1,23.8,0.1,26.5,0.1,31.1v4.8c0,3.5,2.1,5.5,5.7,5.9c4.9,0.6,17,1,26.1,1 s21.2-0.4,26.3-1c3.7-0.4,5.7-2.4,5.7-5.9v-4.8C63.9,26.5,63,24,60.5,20.6z M60.4,34.9c0,2.1-0.8,3.3-3.1,3.5 c-4.4,0.5-16.2,0.9-25.4,0.9s-21-0.4-25.3-0.9c-2.3-0.3-3.1-1.5-3.1-3.5v-3.7c0-3.7,0.6-5.4,2.7-8.2L9,19.4 c0.7-3.9,2.5-9.4,3.6-11.9c0.9-1.9,2.6-3,5.1-3.3C19.4,4,24.9,3.7,32,3.7c7.1,0,12.7,0.3,14.2,0.5c2.6,0.3,4.2,1.5,5.1,3.3 c1.2,2.5,2.9,8,3.6,11.9l2.8,3.6c2.1,2.7,2.7,4.5,2.7,8.2V34.9z' }), jsx("path", { d: 'M4.8,50.2H8c2,0,3.6-1.5,3.6-3.5v-6.4L1.2,38.8v7.9C1.3,48.7,2.8,50.2,4.8,50.2z' }), jsx("path", { d: 'M55.7,50.2h3.2c2,0,3.6-1.5,3.6-3.5v-7.9l-10.4,1.5v6.4C52.1,48.7,53.7,50.2,55.7,50.2z' }), jsx("path", { d: 'M23.3,23.1c0,0.5,0.4,0.9,0.9,0.9h6.7l-3.6,9.6c-0.5,1.3,0.9,2,1.7,0.9l10.8-13.6c0.2-0.2,0.4-0.5,0.4-0.8 c0-0.5-0.4-0.9-0.9-0.9h-6.7l3.5-9.6c0.5-1.3-0.9-2-1.7-0.9L23.6,22.3C23.4,22.6,23.3,22.8,23.3,23.1z' })] }));
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
function BoltFill(props) {
|
|
1183
|
-
return (jsx("svg", { viewBox: '0 0 40.3 64', ...props, children: jsx("path", { d: 'M0,35.6c0,0.5,0.2,1,0.6,1.4C1,37.3,1.5,37.5,2,37.5h16.2L9.7,60.7c-0.4,1-0.3,1.8,0.1,2.4c0.4,0.6,1,0.9,1.7,0.9 c0.7,0,1.4-0.4,2.1-1.2l26-32.5c0.5-0.6,0.7-1.3,0.7-1.8c0-0.5-0.2-1-0.6-1.4c-0.4-0.4-0.9-0.6-1.5-0.6H22.1l8.6-23.2 c0.4-1,0.3-1.8-0.1-2.4c-0.4-0.6-1-0.9-1.7-0.9c-0.8,0-1.5,0.4-2.1,1.2l-26,32.5C0.2,34.4,0,35,0,35.6z' }) }));
|
|
767
|
+
|
|
768
|
+
function BoltFill(props) {
|
|
769
|
+
return (jsx("svg", { viewBox: '0 0 40.3 64', ...props, children: jsx("path", { d: 'M0,35.6c0,0.5,0.2,1,0.6,1.4C1,37.3,1.5,37.5,2,37.5h16.2L9.7,60.7c-0.4,1-0.3,1.8,0.1,2.4c0.4,0.6,1,0.9,1.7,0.9 c0.7,0,1.4-0.4,2.1-1.2l26-32.5c0.5-0.6,0.7-1.3,0.7-1.8c0-0.5-0.2-1-0.6-1.4c-0.4-0.4-0.9-0.6-1.5-0.6H22.1l8.6-23.2 c0.4-1,0.3-1.8-0.1-2.4c-0.4-0.6-1-0.9-1.7-0.9c-0.8,0-1.5,0.4-2.1,1.2l-26,32.5C0.2,34.4,0,35,0,35.6z' }) }));
|
|
1184
770
|
}
|
|
1185
771
|
|
|
1186
772
|
function BoltRingClosed(props) {
|
|
@@ -1563,31 +1149,2714 @@ function xmark(props) {
|
|
|
1563
1149
|
return (jsx("svg", { viewBox: '0 0 64 64', ...props, children: jsx("path", { d: 'M1,63c0.7,0.7,1.6,1,2.6,1s1.9-0.3,2.6-1L32,37.1L57.8,63c0.7,0.7,1.5,1,2.5,1c1,0,1.9-0.3,2.6-1c0.7-0.7,1-1.6,1-2.6 c0-1-0.3-1.8-1-2.5L37.1,32L63,6.2c0.7-0.7,1-1.6,1-2.6S63.7,1.7,63,1c-0.7-0.7-1.6-1-2.6-1c-1,0-1.8,0.3-2.5,1L32,26.9L6.2,1 C5.5,0.3,4.6,0,3.6,0C2.6,0,1.7,0.3,1,1C0.3,1.7,0,2.6,0,3.6c0,1,0.3,1.9,1,2.6L26.9,32L1,57.8c-0.7,0.7-1,1.5-1,2.6 C0,61.4,0.3,62.3,1,63z' }) }));
|
|
1564
1150
|
}
|
|
1565
1151
|
|
|
1566
|
-
function
|
|
1567
|
-
|
|
1568
|
-
|
|
1152
|
+
function DetailsSummary({ arrow = true, as, children, className, ...props }) {
|
|
1153
|
+
return (
|
|
1154
|
+
// @ts-expect-error Button has some extra props
|
|
1155
|
+
jsx(DisclosureButton, { ...props, as: as || (Button), className: twMerge('w-full', className, Boolean(arrow) && 'grid grid-cols-[1fr_1rem] gap-2'), role: 'summary', children: bag => (jsxs(Fragment$1, { children: [typeof children === 'function' ? children(bag) : children, arrow &&
|
|
1156
|
+
(typeof arrow === 'boolean' ? (jsx(ChevronDown, { className: 'absolute top-1/2 right-3 block w-4 -translate-y-1/2' })) : (arrow))] })) }));
|
|
1569
1157
|
}
|
|
1570
|
-
function
|
|
1571
|
-
return jsx("div", {
|
|
1158
|
+
function DetailsBody({ children, className, ...props }) {
|
|
1159
|
+
return (jsx(DisclosurePanel, { ...props, className: twMerge('grid grid-rows-1fr transition-rows duration-500 ease-exponential data-closed:grid-rows-0fr', className), transition: true, children: bag => (jsx("div", { className: 'overflow-y-hidden px-2 pt-3 pb-1', children: typeof children === 'function' ? children(bag) : children })) }));
|
|
1572
1160
|
}
|
|
1573
|
-
function
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1161
|
+
function Details({ as = 'div', className, ...props }) {
|
|
1162
|
+
return (jsx(Disclosure, { ...props, as: as, className: twMerge('rounded-2xl bg-neutral-50/20 p-2 backdrop-blur-md backdrop-brightness-150', className), role: 'details' }));
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
function DropDownButton({ arrow = true, as, children, className, ...props }) {
|
|
1166
|
+
return (jsxs(MenuButton, { ...props, as: as || 'button', className: twJoin('group/button', className), children: [children, arrow &&
|
|
1167
|
+
(typeof arrow === 'boolean' ? (jsx(ChevronDown, { className: '-top-px -mr-1 ml-2 w-4 animate-flip-again group-data-open/button:animate-flip' })) : (arrow))] }));
|
|
1168
|
+
}
|
|
1169
|
+
function DropDownItem({ as, ...props }) {
|
|
1170
|
+
return jsx(MenuItem, { as: as || 'div', ...props });
|
|
1171
|
+
}
|
|
1172
|
+
function DropDownItems({ anchor, children, className, style, ...props }) {
|
|
1173
|
+
const getAnchorProps = () => {
|
|
1174
|
+
let initialAnchor = { gap: '1rem', padding: '1rem', to: 'bottom start' };
|
|
1175
|
+
if (anchor) {
|
|
1176
|
+
if (typeof anchor === 'string')
|
|
1177
|
+
initialAnchor.to = anchor;
|
|
1178
|
+
if (typeof anchor === 'object')
|
|
1179
|
+
initialAnchor = { ...initialAnchor, ...anchor };
|
|
1180
|
+
}
|
|
1181
|
+
return initialAnchor;
|
|
1588
1182
|
};
|
|
1589
|
-
const
|
|
1590
|
-
|
|
1183
|
+
const anchorProps = getAnchorProps();
|
|
1184
|
+
return (jsx(MenuItems, { ...props, anchor: anchorProps, className: 'grid grid-rows-1fr rounded-xl shadow-xl transition-rows duration-500 ease-exponential data-closed:grid-rows-0fr', transition: true, style: { ...style, minWidth: 'var(--button-width)' }, children: bag => (jsx("div", { className: 'overflow-y-hidden', children: jsx("div", { className: twMerge('bg-neutral-50/20 px-6 py-5 backdrop-blur-md backdrop-brightness-150', className), children: typeof children === 'function' ? children(bag) : children }) })) }));
|
|
1185
|
+
}
|
|
1186
|
+
function DropDownSection({ children, label, labelProps, separatorAbove, separatorBelow, ...props }) {
|
|
1187
|
+
const { labelClassName, ...restLabelProps } = { labelClassName: labelProps?.className || '', ...labelProps };
|
|
1188
|
+
return (jsx(MenuSection, { ...props, children: sectionBag => (jsxs(Fragment$1, { children: [separatorAbove && jsx(DropDownSeparator, {}), jsx(MenuHeading, { ...restLabelProps, className: headingBag => twMerge('text-[size:larger] font-bold', typeof labelClassName === 'function' ? labelClassName(headingBag) : labelClassName), children: label }), typeof children === 'function' ? children(sectionBag) : children, separatorBelow && jsx(DropDownSeparator, {})] })) }));
|
|
1189
|
+
}
|
|
1190
|
+
function DropDownSeparator({ className, ...props }) {
|
|
1191
|
+
return (jsx(MenuSeparator, { ...props, className: bag => twMerge('my-4 block h-px rounded-full bg-neutral-950/20', typeof className === 'function' ? className(bag) : className) }));
|
|
1192
|
+
}
|
|
1193
|
+
function DropDown(props) {
|
|
1194
|
+
return jsx(Menu, { ...props });
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
function createFastContext(defaultInitialState) {
|
|
1198
|
+
function useStoreData(initialState = defaultInitialState) {
|
|
1199
|
+
const store = useRef(initialState), get = () => store.current, subscribers = useRef(new Set());
|
|
1200
|
+
const set = (value) => {
|
|
1201
|
+
if (typeof value === 'function') {
|
|
1202
|
+
store.current = value(store.current);
|
|
1203
|
+
}
|
|
1204
|
+
else {
|
|
1205
|
+
store.current = value;
|
|
1206
|
+
}
|
|
1207
|
+
subscribers.current.forEach(callback => callback());
|
|
1208
|
+
};
|
|
1209
|
+
const subscribe = (callback) => {
|
|
1210
|
+
subscribers.current.add(callback);
|
|
1211
|
+
return () => subscribers.current.delete(callback);
|
|
1212
|
+
};
|
|
1213
|
+
return {
|
|
1214
|
+
get,
|
|
1215
|
+
set,
|
|
1216
|
+
subscribe,
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1219
|
+
const StoreContext = createContext(null);
|
|
1220
|
+
function Provider({ initialValue = defaultInitialState, ...props }) {
|
|
1221
|
+
return jsx(StoreContext.Provider, { value: useStoreData(initialValue), ...props });
|
|
1222
|
+
}
|
|
1223
|
+
function useStore(selector, initialValue) {
|
|
1224
|
+
const store = useContext(StoreContext);
|
|
1225
|
+
if (!store) {
|
|
1226
|
+
const localStoreValue = initialValue !== undefined ? initialValue : defaultInitialState;
|
|
1227
|
+
const selectedValue = selector(localStoreValue);
|
|
1228
|
+
const noOpSet = () => console.warn('Attempting to set store value outside of Provider');
|
|
1229
|
+
return [selectedValue, noOpSet];
|
|
1230
|
+
}
|
|
1231
|
+
const state = useSyncExternalStore(store.subscribe, () => selector(store.get()), () => selector(initialValue !== undefined ? initialValue : defaultInitialState));
|
|
1232
|
+
return [state, store.set];
|
|
1233
|
+
}
|
|
1234
|
+
return {
|
|
1235
|
+
Provider,
|
|
1236
|
+
useStore,
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* # Define Field
|
|
1242
|
+
*
|
|
1243
|
+
* This is a helper function to define a field in a form context with type safety.
|
|
1244
|
+
*/
|
|
1245
|
+
function defineField(fieldDefinition) {
|
|
1246
|
+
return fieldDefinition;
|
|
1247
|
+
}
|
|
1248
|
+
const { Provider: Provider$1, useStore: useStore$1 } = createFastContext([]);
|
|
1249
|
+
function FormContextProvider({ children }) {
|
|
1250
|
+
return jsx(Provider$1, { children: children });
|
|
1251
|
+
}
|
|
1252
|
+
function useFormContext() {
|
|
1253
|
+
return useStore$1(store => store);
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
const DEFAULT_STATUS = 'incomplete';
|
|
1257
|
+
const { Provider, useStore } = createFastContext(DEFAULT_STATUS);
|
|
1258
|
+
function FormStatusProvider({ children, initialStatus = DEFAULT_STATUS, }) {
|
|
1259
|
+
return (jsx(Suspense, { children: jsx(Provider, { initialValue: initialStatus, children: children }) }));
|
|
1260
|
+
}
|
|
1261
|
+
function useFormStatus() {
|
|
1262
|
+
return useStore(store => store);
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
function Fieldset({ children, className, legend, legendProps, ...props }) {
|
|
1266
|
+
const { className: legendClassName, ...restLegendProps } = legendProps || {};
|
|
1267
|
+
return (jsx(Fieldset$1, { ...props, className: bag => twMerge('contents', typeof className === 'function' ? className(bag) : className), children: bag => (jsxs(Fragment$1, { children: [jsx(Legend, { ...restLegendProps, className: twMerge('text-lg font-bold sm:text-xl', typeof legendClassName === 'function' ? legendClassName(bag) : legendClassName), children: legend }), typeof children === 'function' ? children(bag) : children] })) }));
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
/**
|
|
1271
|
+
* Custom positioning reference element.
|
|
1272
|
+
* @see https://floating-ui.com/docs/virtual-elements
|
|
1273
|
+
*/
|
|
1274
|
+
|
|
1275
|
+
const min = Math.min;
|
|
1276
|
+
const max = Math.max;
|
|
1277
|
+
const round = Math.round;
|
|
1278
|
+
const floor = Math.floor;
|
|
1279
|
+
const createCoords = v => ({
|
|
1280
|
+
x: v,
|
|
1281
|
+
y: v
|
|
1282
|
+
});
|
|
1283
|
+
const oppositeSideMap = {
|
|
1284
|
+
left: 'right',
|
|
1285
|
+
right: 'left',
|
|
1286
|
+
bottom: 'top',
|
|
1287
|
+
top: 'bottom'
|
|
1288
|
+
};
|
|
1289
|
+
const oppositeAlignmentMap = {
|
|
1290
|
+
start: 'end',
|
|
1291
|
+
end: 'start'
|
|
1292
|
+
};
|
|
1293
|
+
function clamp(start, value, end) {
|
|
1294
|
+
return max(start, min(value, end));
|
|
1295
|
+
}
|
|
1296
|
+
function evaluate(value, param) {
|
|
1297
|
+
return typeof value === 'function' ? value(param) : value;
|
|
1298
|
+
}
|
|
1299
|
+
function getSide(placement) {
|
|
1300
|
+
return placement.split('-')[0];
|
|
1301
|
+
}
|
|
1302
|
+
function getAlignment(placement) {
|
|
1303
|
+
return placement.split('-')[1];
|
|
1304
|
+
}
|
|
1305
|
+
function getOppositeAxis(axis) {
|
|
1306
|
+
return axis === 'x' ? 'y' : 'x';
|
|
1307
|
+
}
|
|
1308
|
+
function getAxisLength(axis) {
|
|
1309
|
+
return axis === 'y' ? 'height' : 'width';
|
|
1310
|
+
}
|
|
1311
|
+
const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
|
|
1312
|
+
function getSideAxis(placement) {
|
|
1313
|
+
return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
|
|
1314
|
+
}
|
|
1315
|
+
function getAlignmentAxis(placement) {
|
|
1316
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
1317
|
+
}
|
|
1318
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
1319
|
+
if (rtl === void 0) {
|
|
1320
|
+
rtl = false;
|
|
1321
|
+
}
|
|
1322
|
+
const alignment = getAlignment(placement);
|
|
1323
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
1324
|
+
const length = getAxisLength(alignmentAxis);
|
|
1325
|
+
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
1326
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
1327
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
1328
|
+
}
|
|
1329
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
1330
|
+
}
|
|
1331
|
+
function getExpandedPlacements(placement) {
|
|
1332
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
1333
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
1334
|
+
}
|
|
1335
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
1336
|
+
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
1337
|
+
}
|
|
1338
|
+
const lrPlacement = ['left', 'right'];
|
|
1339
|
+
const rlPlacement = ['right', 'left'];
|
|
1340
|
+
const tbPlacement = ['top', 'bottom'];
|
|
1341
|
+
const btPlacement = ['bottom', 'top'];
|
|
1342
|
+
function getSideList(side, isStart, rtl) {
|
|
1343
|
+
switch (side) {
|
|
1344
|
+
case 'top':
|
|
1345
|
+
case 'bottom':
|
|
1346
|
+
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
|
1347
|
+
return isStart ? lrPlacement : rlPlacement;
|
|
1348
|
+
case 'left':
|
|
1349
|
+
case 'right':
|
|
1350
|
+
return isStart ? tbPlacement : btPlacement;
|
|
1351
|
+
default:
|
|
1352
|
+
return [];
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
1356
|
+
const alignment = getAlignment(placement);
|
|
1357
|
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
1358
|
+
if (alignment) {
|
|
1359
|
+
list = list.map(side => side + "-" + alignment);
|
|
1360
|
+
if (flipAlignment) {
|
|
1361
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
return list;
|
|
1365
|
+
}
|
|
1366
|
+
function getOppositePlacement(placement) {
|
|
1367
|
+
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
1368
|
+
}
|
|
1369
|
+
function expandPaddingObject(padding) {
|
|
1370
|
+
return {
|
|
1371
|
+
top: 0,
|
|
1372
|
+
right: 0,
|
|
1373
|
+
bottom: 0,
|
|
1374
|
+
left: 0,
|
|
1375
|
+
...padding
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
function getPaddingObject(padding) {
|
|
1379
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
1380
|
+
top: padding,
|
|
1381
|
+
right: padding,
|
|
1382
|
+
bottom: padding,
|
|
1383
|
+
left: padding
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
function rectToClientRect(rect) {
|
|
1387
|
+
const {
|
|
1388
|
+
x,
|
|
1389
|
+
y,
|
|
1390
|
+
width,
|
|
1391
|
+
height
|
|
1392
|
+
} = rect;
|
|
1393
|
+
return {
|
|
1394
|
+
width,
|
|
1395
|
+
height,
|
|
1396
|
+
top: y,
|
|
1397
|
+
left: x,
|
|
1398
|
+
right: x + width,
|
|
1399
|
+
bottom: y + height,
|
|
1400
|
+
x,
|
|
1401
|
+
y
|
|
1402
|
+
};
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
1406
|
+
let {
|
|
1407
|
+
reference,
|
|
1408
|
+
floating
|
|
1409
|
+
} = _ref;
|
|
1410
|
+
const sideAxis = getSideAxis(placement);
|
|
1411
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
1412
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
1413
|
+
const side = getSide(placement);
|
|
1414
|
+
const isVertical = sideAxis === 'y';
|
|
1415
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
1416
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
1417
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
1418
|
+
let coords;
|
|
1419
|
+
switch (side) {
|
|
1420
|
+
case 'top':
|
|
1421
|
+
coords = {
|
|
1422
|
+
x: commonX,
|
|
1423
|
+
y: reference.y - floating.height
|
|
1424
|
+
};
|
|
1425
|
+
break;
|
|
1426
|
+
case 'bottom':
|
|
1427
|
+
coords = {
|
|
1428
|
+
x: commonX,
|
|
1429
|
+
y: reference.y + reference.height
|
|
1430
|
+
};
|
|
1431
|
+
break;
|
|
1432
|
+
case 'right':
|
|
1433
|
+
coords = {
|
|
1434
|
+
x: reference.x + reference.width,
|
|
1435
|
+
y: commonY
|
|
1436
|
+
};
|
|
1437
|
+
break;
|
|
1438
|
+
case 'left':
|
|
1439
|
+
coords = {
|
|
1440
|
+
x: reference.x - floating.width,
|
|
1441
|
+
y: commonY
|
|
1442
|
+
};
|
|
1443
|
+
break;
|
|
1444
|
+
default:
|
|
1445
|
+
coords = {
|
|
1446
|
+
x: reference.x,
|
|
1447
|
+
y: reference.y
|
|
1448
|
+
};
|
|
1449
|
+
}
|
|
1450
|
+
switch (getAlignment(placement)) {
|
|
1451
|
+
case 'start':
|
|
1452
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
1453
|
+
break;
|
|
1454
|
+
case 'end':
|
|
1455
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
1456
|
+
break;
|
|
1457
|
+
}
|
|
1458
|
+
return coords;
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1463
|
+
* next to a given reference element.
|
|
1464
|
+
*
|
|
1465
|
+
* This export does not have any `platform` interface logic. You will need to
|
|
1466
|
+
* write one for the platform you are using Floating UI with.
|
|
1467
|
+
*/
|
|
1468
|
+
const computePosition$1 = async (reference, floating, config) => {
|
|
1469
|
+
const {
|
|
1470
|
+
placement = 'bottom',
|
|
1471
|
+
strategy = 'absolute',
|
|
1472
|
+
middleware = [],
|
|
1473
|
+
platform
|
|
1474
|
+
} = config;
|
|
1475
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
1476
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
1477
|
+
let rects = await platform.getElementRects({
|
|
1478
|
+
reference,
|
|
1479
|
+
floating,
|
|
1480
|
+
strategy
|
|
1481
|
+
});
|
|
1482
|
+
let {
|
|
1483
|
+
x,
|
|
1484
|
+
y
|
|
1485
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
1486
|
+
let statefulPlacement = placement;
|
|
1487
|
+
let middlewareData = {};
|
|
1488
|
+
let resetCount = 0;
|
|
1489
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
1490
|
+
const {
|
|
1491
|
+
name,
|
|
1492
|
+
fn
|
|
1493
|
+
} = validMiddleware[i];
|
|
1494
|
+
const {
|
|
1495
|
+
x: nextX,
|
|
1496
|
+
y: nextY,
|
|
1497
|
+
data,
|
|
1498
|
+
reset
|
|
1499
|
+
} = await fn({
|
|
1500
|
+
x,
|
|
1501
|
+
y,
|
|
1502
|
+
initialPlacement: placement,
|
|
1503
|
+
placement: statefulPlacement,
|
|
1504
|
+
strategy,
|
|
1505
|
+
middlewareData,
|
|
1506
|
+
rects,
|
|
1507
|
+
platform,
|
|
1508
|
+
elements: {
|
|
1509
|
+
reference,
|
|
1510
|
+
floating
|
|
1511
|
+
}
|
|
1512
|
+
});
|
|
1513
|
+
x = nextX != null ? nextX : x;
|
|
1514
|
+
y = nextY != null ? nextY : y;
|
|
1515
|
+
middlewareData = {
|
|
1516
|
+
...middlewareData,
|
|
1517
|
+
[name]: {
|
|
1518
|
+
...middlewareData[name],
|
|
1519
|
+
...data
|
|
1520
|
+
}
|
|
1521
|
+
};
|
|
1522
|
+
if (reset && resetCount <= 50) {
|
|
1523
|
+
resetCount++;
|
|
1524
|
+
if (typeof reset === 'object') {
|
|
1525
|
+
if (reset.placement) {
|
|
1526
|
+
statefulPlacement = reset.placement;
|
|
1527
|
+
}
|
|
1528
|
+
if (reset.rects) {
|
|
1529
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
|
1530
|
+
reference,
|
|
1531
|
+
floating,
|
|
1532
|
+
strategy
|
|
1533
|
+
}) : reset.rects;
|
|
1534
|
+
}
|
|
1535
|
+
({
|
|
1536
|
+
x,
|
|
1537
|
+
y
|
|
1538
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
1539
|
+
}
|
|
1540
|
+
i = -1;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
return {
|
|
1544
|
+
x,
|
|
1545
|
+
y,
|
|
1546
|
+
placement: statefulPlacement,
|
|
1547
|
+
strategy,
|
|
1548
|
+
middlewareData
|
|
1549
|
+
};
|
|
1550
|
+
};
|
|
1551
|
+
|
|
1552
|
+
/**
|
|
1553
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
|
1554
|
+
* element is overflowing a given clipping boundary on each side.
|
|
1555
|
+
* - positive = overflowing the boundary by that number of pixels
|
|
1556
|
+
* - negative = how many pixels left before it will overflow
|
|
1557
|
+
* - 0 = lies flush with the boundary
|
|
1558
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
|
1559
|
+
*/
|
|
1560
|
+
async function detectOverflow(state, options) {
|
|
1561
|
+
var _await$platform$isEle;
|
|
1562
|
+
if (options === void 0) {
|
|
1563
|
+
options = {};
|
|
1564
|
+
}
|
|
1565
|
+
const {
|
|
1566
|
+
x,
|
|
1567
|
+
y,
|
|
1568
|
+
platform,
|
|
1569
|
+
rects,
|
|
1570
|
+
elements,
|
|
1571
|
+
strategy
|
|
1572
|
+
} = state;
|
|
1573
|
+
const {
|
|
1574
|
+
boundary = 'clippingAncestors',
|
|
1575
|
+
rootBoundary = 'viewport',
|
|
1576
|
+
elementContext = 'floating',
|
|
1577
|
+
altBoundary = false,
|
|
1578
|
+
padding = 0
|
|
1579
|
+
} = evaluate(options, state);
|
|
1580
|
+
const paddingObject = getPaddingObject(padding);
|
|
1581
|
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
1582
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
1583
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
1584
|
+
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
|
1585
|
+
boundary,
|
|
1586
|
+
rootBoundary,
|
|
1587
|
+
strategy
|
|
1588
|
+
}));
|
|
1589
|
+
const rect = elementContext === 'floating' ? {
|
|
1590
|
+
x,
|
|
1591
|
+
y,
|
|
1592
|
+
width: rects.floating.width,
|
|
1593
|
+
height: rects.floating.height
|
|
1594
|
+
} : rects.reference;
|
|
1595
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
1596
|
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
1597
|
+
x: 1,
|
|
1598
|
+
y: 1
|
|
1599
|
+
} : {
|
|
1600
|
+
x: 1,
|
|
1601
|
+
y: 1
|
|
1602
|
+
};
|
|
1603
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
1604
|
+
elements,
|
|
1605
|
+
rect,
|
|
1606
|
+
offsetParent,
|
|
1607
|
+
strategy
|
|
1608
|
+
}) : rect);
|
|
1609
|
+
return {
|
|
1610
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
1611
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
1612
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
1613
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
1614
|
+
};
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
/**
|
|
1618
|
+
* Provides data to position an inner element of the floating element so that it
|
|
1619
|
+
* appears centered to the reference element.
|
|
1620
|
+
* @see https://floating-ui.com/docs/arrow
|
|
1621
|
+
*/
|
|
1622
|
+
const arrow$3 = options => ({
|
|
1623
|
+
name: 'arrow',
|
|
1624
|
+
options,
|
|
1625
|
+
async fn(state) {
|
|
1626
|
+
const {
|
|
1627
|
+
x,
|
|
1628
|
+
y,
|
|
1629
|
+
placement,
|
|
1630
|
+
rects,
|
|
1631
|
+
platform,
|
|
1632
|
+
elements,
|
|
1633
|
+
middlewareData
|
|
1634
|
+
} = state;
|
|
1635
|
+
// Since `element` is required, we don't Partial<> the type.
|
|
1636
|
+
const {
|
|
1637
|
+
element,
|
|
1638
|
+
padding = 0
|
|
1639
|
+
} = evaluate(options, state) || {};
|
|
1640
|
+
if (element == null) {
|
|
1641
|
+
return {};
|
|
1642
|
+
}
|
|
1643
|
+
const paddingObject = getPaddingObject(padding);
|
|
1644
|
+
const coords = {
|
|
1645
|
+
x,
|
|
1646
|
+
y
|
|
1647
|
+
};
|
|
1648
|
+
const axis = getAlignmentAxis(placement);
|
|
1649
|
+
const length = getAxisLength(axis);
|
|
1650
|
+
const arrowDimensions = await platform.getDimensions(element);
|
|
1651
|
+
const isYAxis = axis === 'y';
|
|
1652
|
+
const minProp = isYAxis ? 'top' : 'left';
|
|
1653
|
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
|
1654
|
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
|
1655
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
1656
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
1657
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
1658
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
1659
|
+
|
|
1660
|
+
// DOM platform can return `window` as the `offsetParent`.
|
|
1661
|
+
if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
|
|
1662
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
1663
|
+
}
|
|
1664
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
1665
|
+
|
|
1666
|
+
// If the padding is large enough that it causes the arrow to no longer be
|
|
1667
|
+
// centered, modify the padding so that it is centered.
|
|
1668
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
1669
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
1670
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
1671
|
+
|
|
1672
|
+
// Make sure the arrow doesn't overflow the floating element if the center
|
|
1673
|
+
// point is outside the floating element's bounds.
|
|
1674
|
+
const min$1 = minPadding;
|
|
1675
|
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
|
1676
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
1677
|
+
const offset = clamp(min$1, center, max);
|
|
1678
|
+
|
|
1679
|
+
// If the reference is small enough that the arrow's padding causes it to
|
|
1680
|
+
// to point to nothing for an aligned placement, adjust the offset of the
|
|
1681
|
+
// floating element itself. To ensure `shift()` continues to take action,
|
|
1682
|
+
// a single reset is performed when this is true.
|
|
1683
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
1684
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
|
|
1685
|
+
return {
|
|
1686
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
1687
|
+
data: {
|
|
1688
|
+
[axis]: offset,
|
|
1689
|
+
centerOffset: center - offset - alignmentOffset,
|
|
1690
|
+
...(shouldAddOffset && {
|
|
1691
|
+
alignmentOffset
|
|
1692
|
+
})
|
|
1693
|
+
},
|
|
1694
|
+
reset: shouldAddOffset
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
});
|
|
1698
|
+
|
|
1699
|
+
/**
|
|
1700
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
1701
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
1702
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
1703
|
+
* @see https://floating-ui.com/docs/flip
|
|
1704
|
+
*/
|
|
1705
|
+
const flip$2 = function (options) {
|
|
1706
|
+
if (options === void 0) {
|
|
1707
|
+
options = {};
|
|
1708
|
+
}
|
|
1709
|
+
return {
|
|
1710
|
+
name: 'flip',
|
|
1711
|
+
options,
|
|
1712
|
+
async fn(state) {
|
|
1713
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
1714
|
+
const {
|
|
1715
|
+
placement,
|
|
1716
|
+
middlewareData,
|
|
1717
|
+
rects,
|
|
1718
|
+
initialPlacement,
|
|
1719
|
+
platform,
|
|
1720
|
+
elements
|
|
1721
|
+
} = state;
|
|
1722
|
+
const {
|
|
1723
|
+
mainAxis: checkMainAxis = true,
|
|
1724
|
+
crossAxis: checkCrossAxis = true,
|
|
1725
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
1726
|
+
fallbackStrategy = 'bestFit',
|
|
1727
|
+
fallbackAxisSideDirection = 'none',
|
|
1728
|
+
flipAlignment = true,
|
|
1729
|
+
...detectOverflowOptions
|
|
1730
|
+
} = evaluate(options, state);
|
|
1731
|
+
|
|
1732
|
+
// If a reset by the arrow was caused due to an alignment offset being
|
|
1733
|
+
// added, we should skip any logic now since `flip()` has already done its
|
|
1734
|
+
// work.
|
|
1735
|
+
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
|
1736
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
1737
|
+
return {};
|
|
1738
|
+
}
|
|
1739
|
+
const side = getSide(placement);
|
|
1740
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
1741
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
1742
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
1743
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
1744
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
|
|
1745
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
1746
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
1747
|
+
}
|
|
1748
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
|
1749
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
1750
|
+
const overflows = [];
|
|
1751
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
1752
|
+
if (checkMainAxis) {
|
|
1753
|
+
overflows.push(overflow[side]);
|
|
1754
|
+
}
|
|
1755
|
+
if (checkCrossAxis) {
|
|
1756
|
+
const sides = getAlignmentSides(placement, rects, rtl);
|
|
1757
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
1758
|
+
}
|
|
1759
|
+
overflowsData = [...overflowsData, {
|
|
1760
|
+
placement,
|
|
1761
|
+
overflows
|
|
1762
|
+
}];
|
|
1763
|
+
|
|
1764
|
+
// One or more sides is overflowing.
|
|
1765
|
+
if (!overflows.every(side => side <= 0)) {
|
|
1766
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
1767
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
1768
|
+
const nextPlacement = placements[nextIndex];
|
|
1769
|
+
if (nextPlacement) {
|
|
1770
|
+
const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
|
1771
|
+
if (!ignoreCrossAxisOverflow ||
|
|
1772
|
+
// We leave the current main axis only if every placement on that axis
|
|
1773
|
+
// overflows the main axis.
|
|
1774
|
+
overflowsData.every(d => d.overflows[0] > 0 && getSideAxis(d.placement) === initialSideAxis)) {
|
|
1775
|
+
// Try next placement and re-run the lifecycle.
|
|
1776
|
+
return {
|
|
1777
|
+
data: {
|
|
1778
|
+
index: nextIndex,
|
|
1779
|
+
overflows: overflowsData
|
|
1780
|
+
},
|
|
1781
|
+
reset: {
|
|
1782
|
+
placement: nextPlacement
|
|
1783
|
+
}
|
|
1784
|
+
};
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
|
1789
|
+
// then find the placement that fits the best on the main crossAxis side.
|
|
1790
|
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
1791
|
+
|
|
1792
|
+
// Otherwise fallback.
|
|
1793
|
+
if (!resetPlacement) {
|
|
1794
|
+
switch (fallbackStrategy) {
|
|
1795
|
+
case 'bestFit':
|
|
1796
|
+
{
|
|
1797
|
+
var _overflowsData$filter2;
|
|
1798
|
+
const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
|
|
1799
|
+
if (hasFallbackAxisSideDirection) {
|
|
1800
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
1801
|
+
return currentSideAxis === initialSideAxis ||
|
|
1802
|
+
// Create a bias to the `y` side axis due to horizontal
|
|
1803
|
+
// reading directions favoring greater width.
|
|
1804
|
+
currentSideAxis === 'y';
|
|
1805
|
+
}
|
|
1806
|
+
return true;
|
|
1807
|
+
}).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
1808
|
+
if (placement) {
|
|
1809
|
+
resetPlacement = placement;
|
|
1810
|
+
}
|
|
1811
|
+
break;
|
|
1812
|
+
}
|
|
1813
|
+
case 'initialPlacement':
|
|
1814
|
+
resetPlacement = initialPlacement;
|
|
1815
|
+
break;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
if (placement !== resetPlacement) {
|
|
1819
|
+
return {
|
|
1820
|
+
reset: {
|
|
1821
|
+
placement: resetPlacement
|
|
1822
|
+
}
|
|
1823
|
+
};
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
return {};
|
|
1827
|
+
}
|
|
1828
|
+
};
|
|
1829
|
+
};
|
|
1830
|
+
|
|
1831
|
+
const originSides = /*#__PURE__*/new Set(['left', 'top']);
|
|
1832
|
+
|
|
1833
|
+
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
1834
|
+
// Derivable.
|
|
1835
|
+
|
|
1836
|
+
async function convertValueToCoords(state, options) {
|
|
1837
|
+
const {
|
|
1838
|
+
placement,
|
|
1839
|
+
platform,
|
|
1840
|
+
elements
|
|
1841
|
+
} = state;
|
|
1842
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
1843
|
+
const side = getSide(placement);
|
|
1844
|
+
const alignment = getAlignment(placement);
|
|
1845
|
+
const isVertical = getSideAxis(placement) === 'y';
|
|
1846
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
1847
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
1848
|
+
const rawValue = evaluate(options, state);
|
|
1849
|
+
|
|
1850
|
+
// eslint-disable-next-line prefer-const
|
|
1851
|
+
let {
|
|
1852
|
+
mainAxis,
|
|
1853
|
+
crossAxis,
|
|
1854
|
+
alignmentAxis
|
|
1855
|
+
} = typeof rawValue === 'number' ? {
|
|
1856
|
+
mainAxis: rawValue,
|
|
1857
|
+
crossAxis: 0,
|
|
1858
|
+
alignmentAxis: null
|
|
1859
|
+
} : {
|
|
1860
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
1861
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
1862
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
1863
|
+
};
|
|
1864
|
+
if (alignment && typeof alignmentAxis === 'number') {
|
|
1865
|
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
1866
|
+
}
|
|
1867
|
+
return isVertical ? {
|
|
1868
|
+
x: crossAxis * crossAxisMulti,
|
|
1869
|
+
y: mainAxis * mainAxisMulti
|
|
1870
|
+
} : {
|
|
1871
|
+
x: mainAxis * mainAxisMulti,
|
|
1872
|
+
y: crossAxis * crossAxisMulti
|
|
1873
|
+
};
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
/**
|
|
1877
|
+
* Modifies the placement by translating the floating element along the
|
|
1878
|
+
* specified axes.
|
|
1879
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
1880
|
+
* object may be passed.
|
|
1881
|
+
* @see https://floating-ui.com/docs/offset
|
|
1882
|
+
*/
|
|
1883
|
+
const offset$2 = function (options) {
|
|
1884
|
+
if (options === void 0) {
|
|
1885
|
+
options = 0;
|
|
1886
|
+
}
|
|
1887
|
+
return {
|
|
1888
|
+
name: 'offset',
|
|
1889
|
+
options,
|
|
1890
|
+
async fn(state) {
|
|
1891
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
1892
|
+
const {
|
|
1893
|
+
x,
|
|
1894
|
+
y,
|
|
1895
|
+
placement,
|
|
1896
|
+
middlewareData
|
|
1897
|
+
} = state;
|
|
1898
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
1899
|
+
|
|
1900
|
+
// If the placement is the same and the arrow caused an alignment offset
|
|
1901
|
+
// then we don't need to change the positioning coordinates.
|
|
1902
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
1903
|
+
return {};
|
|
1904
|
+
}
|
|
1905
|
+
return {
|
|
1906
|
+
x: x + diffCoords.x,
|
|
1907
|
+
y: y + diffCoords.y,
|
|
1908
|
+
data: {
|
|
1909
|
+
...diffCoords,
|
|
1910
|
+
placement
|
|
1911
|
+
}
|
|
1912
|
+
};
|
|
1913
|
+
}
|
|
1914
|
+
};
|
|
1915
|
+
};
|
|
1916
|
+
|
|
1917
|
+
/**
|
|
1918
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
1919
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
1920
|
+
* @see https://floating-ui.com/docs/shift
|
|
1921
|
+
*/
|
|
1922
|
+
const shift$2 = function (options) {
|
|
1923
|
+
if (options === void 0) {
|
|
1924
|
+
options = {};
|
|
1925
|
+
}
|
|
1926
|
+
return {
|
|
1927
|
+
name: 'shift',
|
|
1928
|
+
options,
|
|
1929
|
+
async fn(state) {
|
|
1930
|
+
const {
|
|
1931
|
+
x,
|
|
1932
|
+
y,
|
|
1933
|
+
placement
|
|
1934
|
+
} = state;
|
|
1935
|
+
const {
|
|
1936
|
+
mainAxis: checkMainAxis = true,
|
|
1937
|
+
crossAxis: checkCrossAxis = false,
|
|
1938
|
+
limiter = {
|
|
1939
|
+
fn: _ref => {
|
|
1940
|
+
let {
|
|
1941
|
+
x,
|
|
1942
|
+
y
|
|
1943
|
+
} = _ref;
|
|
1944
|
+
return {
|
|
1945
|
+
x,
|
|
1946
|
+
y
|
|
1947
|
+
};
|
|
1948
|
+
}
|
|
1949
|
+
},
|
|
1950
|
+
...detectOverflowOptions
|
|
1951
|
+
} = evaluate(options, state);
|
|
1952
|
+
const coords = {
|
|
1953
|
+
x,
|
|
1954
|
+
y
|
|
1955
|
+
};
|
|
1956
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
1957
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
1958
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
1959
|
+
let mainAxisCoord = coords[mainAxis];
|
|
1960
|
+
let crossAxisCoord = coords[crossAxis];
|
|
1961
|
+
if (checkMainAxis) {
|
|
1962
|
+
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
|
1963
|
+
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
1964
|
+
const min = mainAxisCoord + overflow[minSide];
|
|
1965
|
+
const max = mainAxisCoord - overflow[maxSide];
|
|
1966
|
+
mainAxisCoord = clamp(min, mainAxisCoord, max);
|
|
1967
|
+
}
|
|
1968
|
+
if (checkCrossAxis) {
|
|
1969
|
+
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
1970
|
+
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
1971
|
+
const min = crossAxisCoord + overflow[minSide];
|
|
1972
|
+
const max = crossAxisCoord - overflow[maxSide];
|
|
1973
|
+
crossAxisCoord = clamp(min, crossAxisCoord, max);
|
|
1974
|
+
}
|
|
1975
|
+
const limitedCoords = limiter.fn({
|
|
1976
|
+
...state,
|
|
1977
|
+
[mainAxis]: mainAxisCoord,
|
|
1978
|
+
[crossAxis]: crossAxisCoord
|
|
1979
|
+
});
|
|
1980
|
+
return {
|
|
1981
|
+
...limitedCoords,
|
|
1982
|
+
data: {
|
|
1983
|
+
x: limitedCoords.x - x,
|
|
1984
|
+
y: limitedCoords.y - y,
|
|
1985
|
+
enabled: {
|
|
1986
|
+
[mainAxis]: checkMainAxis,
|
|
1987
|
+
[crossAxis]: checkCrossAxis
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
};
|
|
1993
|
+
};
|
|
1994
|
+
|
|
1995
|
+
/**
|
|
1996
|
+
* Provides data that allows you to change the size of the floating element —
|
|
1997
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
1998
|
+
* width of the reference element.
|
|
1999
|
+
* @see https://floating-ui.com/docs/size
|
|
2000
|
+
*/
|
|
2001
|
+
const size$2 = function (options) {
|
|
2002
|
+
if (options === void 0) {
|
|
2003
|
+
options = {};
|
|
2004
|
+
}
|
|
2005
|
+
return {
|
|
2006
|
+
name: 'size',
|
|
2007
|
+
options,
|
|
2008
|
+
async fn(state) {
|
|
2009
|
+
var _state$middlewareData, _state$middlewareData2;
|
|
2010
|
+
const {
|
|
2011
|
+
placement,
|
|
2012
|
+
rects,
|
|
2013
|
+
platform,
|
|
2014
|
+
elements
|
|
2015
|
+
} = state;
|
|
2016
|
+
const {
|
|
2017
|
+
apply = () => {},
|
|
2018
|
+
...detectOverflowOptions
|
|
2019
|
+
} = evaluate(options, state);
|
|
2020
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
2021
|
+
const side = getSide(placement);
|
|
2022
|
+
const alignment = getAlignment(placement);
|
|
2023
|
+
const isYAxis = getSideAxis(placement) === 'y';
|
|
2024
|
+
const {
|
|
2025
|
+
width,
|
|
2026
|
+
height
|
|
2027
|
+
} = rects.floating;
|
|
2028
|
+
let heightSide;
|
|
2029
|
+
let widthSide;
|
|
2030
|
+
if (side === 'top' || side === 'bottom') {
|
|
2031
|
+
heightSide = side;
|
|
2032
|
+
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
|
|
2033
|
+
} else {
|
|
2034
|
+
widthSide = side;
|
|
2035
|
+
heightSide = alignment === 'end' ? 'top' : 'bottom';
|
|
2036
|
+
}
|
|
2037
|
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
2038
|
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
2039
|
+
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
|
|
2040
|
+
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
|
|
2041
|
+
const noShift = !state.middlewareData.shift;
|
|
2042
|
+
let availableHeight = overflowAvailableHeight;
|
|
2043
|
+
let availableWidth = overflowAvailableWidth;
|
|
2044
|
+
if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
|
|
2045
|
+
availableWidth = maximumClippingWidth;
|
|
2046
|
+
}
|
|
2047
|
+
if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
|
|
2048
|
+
availableHeight = maximumClippingHeight;
|
|
2049
|
+
}
|
|
2050
|
+
if (noShift && !alignment) {
|
|
2051
|
+
const xMin = max(overflow.left, 0);
|
|
2052
|
+
const xMax = max(overflow.right, 0);
|
|
2053
|
+
const yMin = max(overflow.top, 0);
|
|
2054
|
+
const yMax = max(overflow.bottom, 0);
|
|
2055
|
+
if (isYAxis) {
|
|
2056
|
+
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
|
|
2057
|
+
} else {
|
|
2058
|
+
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
await apply({
|
|
2062
|
+
...state,
|
|
2063
|
+
availableWidth,
|
|
2064
|
+
availableHeight
|
|
2065
|
+
});
|
|
2066
|
+
const nextDimensions = await platform.getDimensions(elements.floating);
|
|
2067
|
+
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
|
2068
|
+
return {
|
|
2069
|
+
reset: {
|
|
2070
|
+
rects: true
|
|
2071
|
+
}
|
|
2072
|
+
};
|
|
2073
|
+
}
|
|
2074
|
+
return {};
|
|
2075
|
+
}
|
|
2076
|
+
};
|
|
2077
|
+
};
|
|
2078
|
+
|
|
2079
|
+
function hasWindow() {
|
|
2080
|
+
return typeof window !== 'undefined';
|
|
2081
|
+
}
|
|
2082
|
+
function getNodeName(node) {
|
|
2083
|
+
if (isNode(node)) {
|
|
2084
|
+
return (node.nodeName || '').toLowerCase();
|
|
2085
|
+
}
|
|
2086
|
+
// Mocked nodes in testing environments may not be instances of Node. By
|
|
2087
|
+
// returning `#document` an infinite loop won't occur.
|
|
2088
|
+
// https://github.com/floating-ui/floating-ui/issues/2317
|
|
2089
|
+
return '#document';
|
|
2090
|
+
}
|
|
2091
|
+
function getWindow(node) {
|
|
2092
|
+
var _node$ownerDocument;
|
|
2093
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
2094
|
+
}
|
|
2095
|
+
function getDocumentElement(node) {
|
|
2096
|
+
var _ref;
|
|
2097
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
2098
|
+
}
|
|
2099
|
+
function isNode(value) {
|
|
2100
|
+
if (!hasWindow()) {
|
|
2101
|
+
return false;
|
|
2102
|
+
}
|
|
2103
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
2104
|
+
}
|
|
2105
|
+
function isElement(value) {
|
|
2106
|
+
if (!hasWindow()) {
|
|
2107
|
+
return false;
|
|
2108
|
+
}
|
|
2109
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
2110
|
+
}
|
|
2111
|
+
function isHTMLElement(value) {
|
|
2112
|
+
if (!hasWindow()) {
|
|
2113
|
+
return false;
|
|
2114
|
+
}
|
|
2115
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
2116
|
+
}
|
|
2117
|
+
function isShadowRoot(value) {
|
|
2118
|
+
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
|
2119
|
+
return false;
|
|
2120
|
+
}
|
|
2121
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
2122
|
+
}
|
|
2123
|
+
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
|
2124
|
+
function isOverflowElement(element) {
|
|
2125
|
+
const {
|
|
2126
|
+
overflow,
|
|
2127
|
+
overflowX,
|
|
2128
|
+
overflowY,
|
|
2129
|
+
display
|
|
2130
|
+
} = getComputedStyle(element);
|
|
2131
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
|
2132
|
+
}
|
|
2133
|
+
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
|
2134
|
+
function isTableElement(element) {
|
|
2135
|
+
return tableElements.has(getNodeName(element));
|
|
2136
|
+
}
|
|
2137
|
+
const topLayerSelectors = [':popover-open', ':modal'];
|
|
2138
|
+
function isTopLayer(element) {
|
|
2139
|
+
return topLayerSelectors.some(selector => {
|
|
2140
|
+
try {
|
|
2141
|
+
return element.matches(selector);
|
|
2142
|
+
} catch (_e) {
|
|
2143
|
+
return false;
|
|
2144
|
+
}
|
|
2145
|
+
});
|
|
2146
|
+
}
|
|
2147
|
+
const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
|
|
2148
|
+
const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
|
|
2149
|
+
const containValues = ['paint', 'layout', 'strict', 'content'];
|
|
2150
|
+
function isContainingBlock(elementOrCss) {
|
|
2151
|
+
const webkit = isWebKit();
|
|
2152
|
+
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
|
2153
|
+
|
|
2154
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
2155
|
+
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
|
2156
|
+
return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
|
|
2157
|
+
}
|
|
2158
|
+
function getContainingBlock(element) {
|
|
2159
|
+
let currentNode = getParentNode(element);
|
|
2160
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
2161
|
+
if (isContainingBlock(currentNode)) {
|
|
2162
|
+
return currentNode;
|
|
2163
|
+
} else if (isTopLayer(currentNode)) {
|
|
2164
|
+
return null;
|
|
2165
|
+
}
|
|
2166
|
+
currentNode = getParentNode(currentNode);
|
|
2167
|
+
}
|
|
2168
|
+
return null;
|
|
2169
|
+
}
|
|
2170
|
+
function isWebKit() {
|
|
2171
|
+
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
|
2172
|
+
return CSS.supports('-webkit-backdrop-filter', 'none');
|
|
2173
|
+
}
|
|
2174
|
+
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
|
2175
|
+
function isLastTraversableNode(node) {
|
|
2176
|
+
return lastTraversableNodeNames.has(getNodeName(node));
|
|
2177
|
+
}
|
|
2178
|
+
function getComputedStyle(element) {
|
|
2179
|
+
return getWindow(element).getComputedStyle(element);
|
|
2180
|
+
}
|
|
2181
|
+
function getNodeScroll(element) {
|
|
2182
|
+
if (isElement(element)) {
|
|
2183
|
+
return {
|
|
2184
|
+
scrollLeft: element.scrollLeft,
|
|
2185
|
+
scrollTop: element.scrollTop
|
|
2186
|
+
};
|
|
2187
|
+
}
|
|
2188
|
+
return {
|
|
2189
|
+
scrollLeft: element.scrollX,
|
|
2190
|
+
scrollTop: element.scrollY
|
|
2191
|
+
};
|
|
2192
|
+
}
|
|
2193
|
+
function getParentNode(node) {
|
|
2194
|
+
if (getNodeName(node) === 'html') {
|
|
2195
|
+
return node;
|
|
2196
|
+
}
|
|
2197
|
+
const result =
|
|
2198
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
2199
|
+
node.assignedSlot ||
|
|
2200
|
+
// DOM Element detected.
|
|
2201
|
+
node.parentNode ||
|
|
2202
|
+
// ShadowRoot detected.
|
|
2203
|
+
isShadowRoot(node) && node.host ||
|
|
2204
|
+
// Fallback.
|
|
2205
|
+
getDocumentElement(node);
|
|
2206
|
+
return isShadowRoot(result) ? result.host : result;
|
|
2207
|
+
}
|
|
2208
|
+
function getNearestOverflowAncestor(node) {
|
|
2209
|
+
const parentNode = getParentNode(node);
|
|
2210
|
+
if (isLastTraversableNode(parentNode)) {
|
|
2211
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
2212
|
+
}
|
|
2213
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
2214
|
+
return parentNode;
|
|
2215
|
+
}
|
|
2216
|
+
return getNearestOverflowAncestor(parentNode);
|
|
2217
|
+
}
|
|
2218
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
2219
|
+
var _node$ownerDocument2;
|
|
2220
|
+
if (list === void 0) {
|
|
2221
|
+
list = [];
|
|
2222
|
+
}
|
|
2223
|
+
if (traverseIframes === void 0) {
|
|
2224
|
+
traverseIframes = true;
|
|
2225
|
+
}
|
|
2226
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
2227
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
2228
|
+
const win = getWindow(scrollableAncestor);
|
|
2229
|
+
if (isBody) {
|
|
2230
|
+
const frameElement = getFrameElement(win);
|
|
2231
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
2232
|
+
}
|
|
2233
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
2234
|
+
}
|
|
2235
|
+
function getFrameElement(win) {
|
|
2236
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
function getCssDimensions(element) {
|
|
2240
|
+
const css = getComputedStyle(element);
|
|
2241
|
+
// In testing environments, the `width` and `height` properties are empty
|
|
2242
|
+
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
|
2243
|
+
let width = parseFloat(css.width) || 0;
|
|
2244
|
+
let height = parseFloat(css.height) || 0;
|
|
2245
|
+
const hasOffset = isHTMLElement(element);
|
|
2246
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
2247
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
2248
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
2249
|
+
if (shouldFallback) {
|
|
2250
|
+
width = offsetWidth;
|
|
2251
|
+
height = offsetHeight;
|
|
2252
|
+
}
|
|
2253
|
+
return {
|
|
2254
|
+
width,
|
|
2255
|
+
height,
|
|
2256
|
+
$: shouldFallback
|
|
2257
|
+
};
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
function unwrapElement(element) {
|
|
2261
|
+
return !isElement(element) ? element.contextElement : element;
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2264
|
+
function getScale(element) {
|
|
2265
|
+
const domElement = unwrapElement(element);
|
|
2266
|
+
if (!isHTMLElement(domElement)) {
|
|
2267
|
+
return createCoords(1);
|
|
2268
|
+
}
|
|
2269
|
+
const rect = domElement.getBoundingClientRect();
|
|
2270
|
+
const {
|
|
2271
|
+
width,
|
|
2272
|
+
height,
|
|
2273
|
+
$
|
|
2274
|
+
} = getCssDimensions(domElement);
|
|
2275
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
2276
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
2277
|
+
|
|
2278
|
+
// 0, NaN, or Infinity should always fallback to 1.
|
|
2279
|
+
|
|
2280
|
+
if (!x || !Number.isFinite(x)) {
|
|
2281
|
+
x = 1;
|
|
2282
|
+
}
|
|
2283
|
+
if (!y || !Number.isFinite(y)) {
|
|
2284
|
+
y = 1;
|
|
2285
|
+
}
|
|
2286
|
+
return {
|
|
2287
|
+
x,
|
|
2288
|
+
y
|
|
2289
|
+
};
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
const noOffsets = /*#__PURE__*/createCoords(0);
|
|
2293
|
+
function getVisualOffsets(element) {
|
|
2294
|
+
const win = getWindow(element);
|
|
2295
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
2296
|
+
return noOffsets;
|
|
2297
|
+
}
|
|
2298
|
+
return {
|
|
2299
|
+
x: win.visualViewport.offsetLeft,
|
|
2300
|
+
y: win.visualViewport.offsetTop
|
|
2301
|
+
};
|
|
2302
|
+
}
|
|
2303
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
2304
|
+
if (isFixed === void 0) {
|
|
2305
|
+
isFixed = false;
|
|
2306
|
+
}
|
|
2307
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
2308
|
+
return false;
|
|
2309
|
+
}
|
|
2310
|
+
return isFixed;
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
2314
|
+
if (includeScale === void 0) {
|
|
2315
|
+
includeScale = false;
|
|
2316
|
+
}
|
|
2317
|
+
if (isFixedStrategy === void 0) {
|
|
2318
|
+
isFixedStrategy = false;
|
|
2319
|
+
}
|
|
2320
|
+
const clientRect = element.getBoundingClientRect();
|
|
2321
|
+
const domElement = unwrapElement(element);
|
|
2322
|
+
let scale = createCoords(1);
|
|
2323
|
+
if (includeScale) {
|
|
2324
|
+
if (offsetParent) {
|
|
2325
|
+
if (isElement(offsetParent)) {
|
|
2326
|
+
scale = getScale(offsetParent);
|
|
2327
|
+
}
|
|
2328
|
+
} else {
|
|
2329
|
+
scale = getScale(element);
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
2333
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
2334
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
2335
|
+
let width = clientRect.width / scale.x;
|
|
2336
|
+
let height = clientRect.height / scale.y;
|
|
2337
|
+
if (domElement) {
|
|
2338
|
+
const win = getWindow(domElement);
|
|
2339
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
2340
|
+
let currentWin = win;
|
|
2341
|
+
let currentIFrame = getFrameElement(currentWin);
|
|
2342
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
2343
|
+
const iframeScale = getScale(currentIFrame);
|
|
2344
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
2345
|
+
const css = getComputedStyle(currentIFrame);
|
|
2346
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
2347
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
2348
|
+
x *= iframeScale.x;
|
|
2349
|
+
y *= iframeScale.y;
|
|
2350
|
+
width *= iframeScale.x;
|
|
2351
|
+
height *= iframeScale.y;
|
|
2352
|
+
x += left;
|
|
2353
|
+
y += top;
|
|
2354
|
+
currentWin = getWindow(currentIFrame);
|
|
2355
|
+
currentIFrame = getFrameElement(currentWin);
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
return rectToClientRect({
|
|
2359
|
+
width,
|
|
2360
|
+
height,
|
|
2361
|
+
x,
|
|
2362
|
+
y
|
|
2363
|
+
});
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
2367
|
+
// incorrect for RTL.
|
|
2368
|
+
function getWindowScrollBarX(element, rect) {
|
|
2369
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
2370
|
+
if (!rect) {
|
|
2371
|
+
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
2372
|
+
}
|
|
2373
|
+
return rect.left + leftScroll;
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
|
|
2377
|
+
if (ignoreScrollbarX === void 0) {
|
|
2378
|
+
ignoreScrollbarX = false;
|
|
2379
|
+
}
|
|
2380
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
2381
|
+
const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
|
|
2382
|
+
// RTL <body> scrollbar.
|
|
2383
|
+
getWindowScrollBarX(documentElement, htmlRect));
|
|
2384
|
+
const y = htmlRect.top + scroll.scrollTop;
|
|
2385
|
+
return {
|
|
2386
|
+
x,
|
|
2387
|
+
y
|
|
2388
|
+
};
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
2392
|
+
let {
|
|
2393
|
+
elements,
|
|
2394
|
+
rect,
|
|
2395
|
+
offsetParent,
|
|
2396
|
+
strategy
|
|
2397
|
+
} = _ref;
|
|
2398
|
+
const isFixed = strategy === 'fixed';
|
|
2399
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
2400
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
2401
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
2402
|
+
return rect;
|
|
2403
|
+
}
|
|
2404
|
+
let scroll = {
|
|
2405
|
+
scrollLeft: 0,
|
|
2406
|
+
scrollTop: 0
|
|
2407
|
+
};
|
|
2408
|
+
let scale = createCoords(1);
|
|
2409
|
+
const offsets = createCoords(0);
|
|
2410
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
2411
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
2412
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
2413
|
+
scroll = getNodeScroll(offsetParent);
|
|
2414
|
+
}
|
|
2415
|
+
if (isHTMLElement(offsetParent)) {
|
|
2416
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
2417
|
+
scale = getScale(offsetParent);
|
|
2418
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
2419
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
|
|
2423
|
+
return {
|
|
2424
|
+
width: rect.width * scale.x,
|
|
2425
|
+
height: rect.height * scale.y,
|
|
2426
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
2427
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
2428
|
+
};
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
function getClientRects(element) {
|
|
2432
|
+
return Array.from(element.getClientRects());
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
// Gets the entire size of the scrollable document area, even extending outside
|
|
2436
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
|
2437
|
+
function getDocumentRect(element) {
|
|
2438
|
+
const html = getDocumentElement(element);
|
|
2439
|
+
const scroll = getNodeScroll(element);
|
|
2440
|
+
const body = element.ownerDocument.body;
|
|
2441
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
2442
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
2443
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
2444
|
+
const y = -scroll.scrollTop;
|
|
2445
|
+
if (getComputedStyle(body).direction === 'rtl') {
|
|
2446
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
|
2447
|
+
}
|
|
2448
|
+
return {
|
|
2449
|
+
width,
|
|
2450
|
+
height,
|
|
2451
|
+
x,
|
|
2452
|
+
y
|
|
2453
|
+
};
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
function getViewportRect(element, strategy) {
|
|
2457
|
+
const win = getWindow(element);
|
|
2458
|
+
const html = getDocumentElement(element);
|
|
2459
|
+
const visualViewport = win.visualViewport;
|
|
2460
|
+
let width = html.clientWidth;
|
|
2461
|
+
let height = html.clientHeight;
|
|
2462
|
+
let x = 0;
|
|
2463
|
+
let y = 0;
|
|
2464
|
+
if (visualViewport) {
|
|
2465
|
+
width = visualViewport.width;
|
|
2466
|
+
height = visualViewport.height;
|
|
2467
|
+
const visualViewportBased = isWebKit();
|
|
2468
|
+
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
|
2469
|
+
x = visualViewport.offsetLeft;
|
|
2470
|
+
y = visualViewport.offsetTop;
|
|
2471
|
+
}
|
|
2472
|
+
}
|
|
2473
|
+
return {
|
|
2474
|
+
width,
|
|
2475
|
+
height,
|
|
2476
|
+
x,
|
|
2477
|
+
y
|
|
2478
|
+
};
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
|
|
2482
|
+
// Returns the inner client rect, subtracting scrollbars if present.
|
|
2483
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
2484
|
+
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
2485
|
+
const top = clientRect.top + element.clientTop;
|
|
2486
|
+
const left = clientRect.left + element.clientLeft;
|
|
2487
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
2488
|
+
const width = element.clientWidth * scale.x;
|
|
2489
|
+
const height = element.clientHeight * scale.y;
|
|
2490
|
+
const x = left * scale.x;
|
|
2491
|
+
const y = top * scale.y;
|
|
2492
|
+
return {
|
|
2493
|
+
width,
|
|
2494
|
+
height,
|
|
2495
|
+
x,
|
|
2496
|
+
y
|
|
2497
|
+
};
|
|
2498
|
+
}
|
|
2499
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
2500
|
+
let rect;
|
|
2501
|
+
if (clippingAncestor === 'viewport') {
|
|
2502
|
+
rect = getViewportRect(element, strategy);
|
|
2503
|
+
} else if (clippingAncestor === 'document') {
|
|
2504
|
+
rect = getDocumentRect(getDocumentElement(element));
|
|
2505
|
+
} else if (isElement(clippingAncestor)) {
|
|
2506
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
2507
|
+
} else {
|
|
2508
|
+
const visualOffsets = getVisualOffsets(element);
|
|
2509
|
+
rect = {
|
|
2510
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
2511
|
+
y: clippingAncestor.y - visualOffsets.y,
|
|
2512
|
+
width: clippingAncestor.width,
|
|
2513
|
+
height: clippingAncestor.height
|
|
2514
|
+
};
|
|
2515
|
+
}
|
|
2516
|
+
return rectToClientRect(rect);
|
|
2517
|
+
}
|
|
2518
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
2519
|
+
const parentNode = getParentNode(element);
|
|
2520
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
2521
|
+
return false;
|
|
2522
|
+
}
|
|
2523
|
+
return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
2527
|
+
// clipping (or hiding) child elements. This returns all clipping ancestors
|
|
2528
|
+
// of the given element up the tree.
|
|
2529
|
+
function getClippingElementAncestors(element, cache) {
|
|
2530
|
+
const cachedResult = cache.get(element);
|
|
2531
|
+
if (cachedResult) {
|
|
2532
|
+
return cachedResult;
|
|
2533
|
+
}
|
|
2534
|
+
let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
2535
|
+
let currentContainingBlockComputedStyle = null;
|
|
2536
|
+
const elementIsFixed = getComputedStyle(element).position === 'fixed';
|
|
2537
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
2538
|
+
|
|
2539
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
2540
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
2541
|
+
const computedStyle = getComputedStyle(currentNode);
|
|
2542
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
2543
|
+
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
|
2544
|
+
currentContainingBlockComputedStyle = null;
|
|
2545
|
+
}
|
|
2546
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
2547
|
+
if (shouldDropCurrentNode) {
|
|
2548
|
+
// Drop non-containing blocks.
|
|
2549
|
+
result = result.filter(ancestor => ancestor !== currentNode);
|
|
2550
|
+
} else {
|
|
2551
|
+
// Record last containing block for next iteration.
|
|
2552
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
2553
|
+
}
|
|
2554
|
+
currentNode = getParentNode(currentNode);
|
|
2555
|
+
}
|
|
2556
|
+
cache.set(element, result);
|
|
2557
|
+
return result;
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
// Gets the maximum area that the element is visible in due to any number of
|
|
2561
|
+
// clipping ancestors.
|
|
2562
|
+
function getClippingRect(_ref) {
|
|
2563
|
+
let {
|
|
2564
|
+
element,
|
|
2565
|
+
boundary,
|
|
2566
|
+
rootBoundary,
|
|
2567
|
+
strategy
|
|
2568
|
+
} = _ref;
|
|
2569
|
+
const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
2570
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
2571
|
+
const firstClippingAncestor = clippingAncestors[0];
|
|
2572
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
2573
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
2574
|
+
accRect.top = max(rect.top, accRect.top);
|
|
2575
|
+
accRect.right = min(rect.right, accRect.right);
|
|
2576
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
2577
|
+
accRect.left = max(rect.left, accRect.left);
|
|
2578
|
+
return accRect;
|
|
2579
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
2580
|
+
return {
|
|
2581
|
+
width: clippingRect.right - clippingRect.left,
|
|
2582
|
+
height: clippingRect.bottom - clippingRect.top,
|
|
2583
|
+
x: clippingRect.left,
|
|
2584
|
+
y: clippingRect.top
|
|
2585
|
+
};
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
function getDimensions(element) {
|
|
2589
|
+
const {
|
|
2590
|
+
width,
|
|
2591
|
+
height
|
|
2592
|
+
} = getCssDimensions(element);
|
|
2593
|
+
return {
|
|
2594
|
+
width,
|
|
2595
|
+
height
|
|
2596
|
+
};
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
2600
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
2601
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
2602
|
+
const isFixed = strategy === 'fixed';
|
|
2603
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
2604
|
+
let scroll = {
|
|
2605
|
+
scrollLeft: 0,
|
|
2606
|
+
scrollTop: 0
|
|
2607
|
+
};
|
|
2608
|
+
const offsets = createCoords(0);
|
|
2609
|
+
|
|
2610
|
+
// If the <body> scrollbar appears on the left (e.g. RTL systems). Use
|
|
2611
|
+
// Firefox with layout.scrollbar.side = 3 in about:config to test this.
|
|
2612
|
+
function setLeftRTLScrollbarOffset() {
|
|
2613
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
2614
|
+
}
|
|
2615
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
2616
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
2617
|
+
scroll = getNodeScroll(offsetParent);
|
|
2618
|
+
}
|
|
2619
|
+
if (isOffsetParentAnElement) {
|
|
2620
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
2621
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
2622
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2623
|
+
} else if (documentElement) {
|
|
2624
|
+
setLeftRTLScrollbarOffset();
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
|
2628
|
+
setLeftRTLScrollbarOffset();
|
|
2629
|
+
}
|
|
2630
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
2631
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
2632
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
2633
|
+
return {
|
|
2634
|
+
x,
|
|
2635
|
+
y,
|
|
2636
|
+
width: rect.width,
|
|
2637
|
+
height: rect.height
|
|
2638
|
+
};
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
function isStaticPositioned(element) {
|
|
2642
|
+
return getComputedStyle(element).position === 'static';
|
|
2643
|
+
}
|
|
2644
|
+
|
|
2645
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
2646
|
+
if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
|
|
2647
|
+
return null;
|
|
2648
|
+
}
|
|
2649
|
+
if (polyfill) {
|
|
2650
|
+
return polyfill(element);
|
|
2651
|
+
}
|
|
2652
|
+
let rawOffsetParent = element.offsetParent;
|
|
2653
|
+
|
|
2654
|
+
// Firefox returns the <html> element as the offsetParent if it's non-static,
|
|
2655
|
+
// while Chrome and Safari return the <body> element. The <body> element must
|
|
2656
|
+
// be used to perform the correct calculations even if the <html> element is
|
|
2657
|
+
// non-static.
|
|
2658
|
+
if (getDocumentElement(element) === rawOffsetParent) {
|
|
2659
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
2660
|
+
}
|
|
2661
|
+
return rawOffsetParent;
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2664
|
+
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
2665
|
+
// such as table ancestors and cross browser bugs.
|
|
2666
|
+
function getOffsetParent(element, polyfill) {
|
|
2667
|
+
const win = getWindow(element);
|
|
2668
|
+
if (isTopLayer(element)) {
|
|
2669
|
+
return win;
|
|
2670
|
+
}
|
|
2671
|
+
if (!isHTMLElement(element)) {
|
|
2672
|
+
let svgOffsetParent = getParentNode(element);
|
|
2673
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
2674
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
2675
|
+
return svgOffsetParent;
|
|
2676
|
+
}
|
|
2677
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
2678
|
+
}
|
|
2679
|
+
return win;
|
|
2680
|
+
}
|
|
2681
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
2682
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
2683
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
2684
|
+
}
|
|
2685
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
2686
|
+
return win;
|
|
2687
|
+
}
|
|
2688
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
2689
|
+
}
|
|
2690
|
+
|
|
2691
|
+
const getElementRects = async function (data) {
|
|
2692
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
2693
|
+
const getDimensionsFn = this.getDimensions;
|
|
2694
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
2695
|
+
return {
|
|
2696
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
2697
|
+
floating: {
|
|
2698
|
+
x: 0,
|
|
2699
|
+
y: 0,
|
|
2700
|
+
width: floatingDimensions.width,
|
|
2701
|
+
height: floatingDimensions.height
|
|
2702
|
+
}
|
|
2703
|
+
};
|
|
2704
|
+
};
|
|
2705
|
+
|
|
2706
|
+
function isRTL(element) {
|
|
2707
|
+
return getComputedStyle(element).direction === 'rtl';
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2710
|
+
const platform = {
|
|
2711
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
2712
|
+
getDocumentElement,
|
|
2713
|
+
getClippingRect,
|
|
2714
|
+
getOffsetParent,
|
|
2715
|
+
getElementRects,
|
|
2716
|
+
getClientRects,
|
|
2717
|
+
getDimensions,
|
|
2718
|
+
getScale,
|
|
2719
|
+
isElement,
|
|
2720
|
+
isRTL
|
|
2721
|
+
};
|
|
2722
|
+
|
|
2723
|
+
function rectsAreEqual(a, b) {
|
|
2724
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
// https://samthor.au/2021/observing-dom/
|
|
2728
|
+
function observeMove(element, onMove) {
|
|
2729
|
+
let io = null;
|
|
2730
|
+
let timeoutId;
|
|
2731
|
+
const root = getDocumentElement(element);
|
|
2732
|
+
function cleanup() {
|
|
2733
|
+
var _io;
|
|
2734
|
+
clearTimeout(timeoutId);
|
|
2735
|
+
(_io = io) == null || _io.disconnect();
|
|
2736
|
+
io = null;
|
|
2737
|
+
}
|
|
2738
|
+
function refresh(skip, threshold) {
|
|
2739
|
+
if (skip === void 0) {
|
|
2740
|
+
skip = false;
|
|
2741
|
+
}
|
|
2742
|
+
if (threshold === void 0) {
|
|
2743
|
+
threshold = 1;
|
|
2744
|
+
}
|
|
2745
|
+
cleanup();
|
|
2746
|
+
const elementRectForRootMargin = element.getBoundingClientRect();
|
|
2747
|
+
const {
|
|
2748
|
+
left,
|
|
2749
|
+
top,
|
|
2750
|
+
width,
|
|
2751
|
+
height
|
|
2752
|
+
} = elementRectForRootMargin;
|
|
2753
|
+
if (!skip) {
|
|
2754
|
+
onMove();
|
|
2755
|
+
}
|
|
2756
|
+
if (!width || !height) {
|
|
2757
|
+
return;
|
|
2758
|
+
}
|
|
2759
|
+
const insetTop = floor(top);
|
|
2760
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
2761
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
2762
|
+
const insetLeft = floor(left);
|
|
2763
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
2764
|
+
const options = {
|
|
2765
|
+
rootMargin,
|
|
2766
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
2767
|
+
};
|
|
2768
|
+
let isFirstUpdate = true;
|
|
2769
|
+
function handleObserve(entries) {
|
|
2770
|
+
const ratio = entries[0].intersectionRatio;
|
|
2771
|
+
if (ratio !== threshold) {
|
|
2772
|
+
if (!isFirstUpdate) {
|
|
2773
|
+
return refresh();
|
|
2774
|
+
}
|
|
2775
|
+
if (!ratio) {
|
|
2776
|
+
// If the reference is clipped, the ratio is 0. Throttle the refresh
|
|
2777
|
+
// to prevent an infinite loop of updates.
|
|
2778
|
+
timeoutId = setTimeout(() => {
|
|
2779
|
+
refresh(false, 1e-7);
|
|
2780
|
+
}, 1000);
|
|
2781
|
+
} else {
|
|
2782
|
+
refresh(false, ratio);
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
|
|
2786
|
+
// It's possible that even though the ratio is reported as 1, the
|
|
2787
|
+
// element is not actually fully within the IntersectionObserver's root
|
|
2788
|
+
// area anymore. This can happen under performance constraints. This may
|
|
2789
|
+
// be a bug in the browser's IntersectionObserver implementation. To
|
|
2790
|
+
// work around this, we compare the element's bounding rect now with
|
|
2791
|
+
// what it was at the time we created the IntersectionObserver. If they
|
|
2792
|
+
// are not equal then the element moved, so we refresh.
|
|
2793
|
+
refresh();
|
|
2794
|
+
}
|
|
2795
|
+
isFirstUpdate = false;
|
|
2796
|
+
}
|
|
2797
|
+
|
|
2798
|
+
// Older browsers don't support a `document` as the root and will throw an
|
|
2799
|
+
// error.
|
|
2800
|
+
try {
|
|
2801
|
+
io = new IntersectionObserver(handleObserve, {
|
|
2802
|
+
...options,
|
|
2803
|
+
// Handle <iframe>s
|
|
2804
|
+
root: root.ownerDocument
|
|
2805
|
+
});
|
|
2806
|
+
} catch (_e) {
|
|
2807
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
2808
|
+
}
|
|
2809
|
+
io.observe(element);
|
|
2810
|
+
}
|
|
2811
|
+
refresh(true);
|
|
2812
|
+
return cleanup;
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
/**
|
|
2816
|
+
* Automatically updates the position of the floating element when necessary.
|
|
2817
|
+
* Should only be called when the floating element is mounted on the DOM or
|
|
2818
|
+
* visible on the screen.
|
|
2819
|
+
* @returns cleanup function that should be invoked when the floating element is
|
|
2820
|
+
* removed from the DOM or hidden from the screen.
|
|
2821
|
+
* @see https://floating-ui.com/docs/autoUpdate
|
|
2822
|
+
*/
|
|
2823
|
+
function autoUpdate(reference, floating, update, options) {
|
|
2824
|
+
if (options === void 0) {
|
|
2825
|
+
options = {};
|
|
2826
|
+
}
|
|
2827
|
+
const {
|
|
2828
|
+
ancestorScroll = true,
|
|
2829
|
+
ancestorResize = true,
|
|
2830
|
+
elementResize = typeof ResizeObserver === 'function',
|
|
2831
|
+
layoutShift = typeof IntersectionObserver === 'function',
|
|
2832
|
+
animationFrame = false
|
|
2833
|
+
} = options;
|
|
2834
|
+
const referenceEl = unwrapElement(reference);
|
|
2835
|
+
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
|
|
2836
|
+
ancestors.forEach(ancestor => {
|
|
2837
|
+
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
2838
|
+
passive: true
|
|
2839
|
+
});
|
|
2840
|
+
ancestorResize && ancestor.addEventListener('resize', update);
|
|
2841
|
+
});
|
|
2842
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
2843
|
+
let reobserveFrame = -1;
|
|
2844
|
+
let resizeObserver = null;
|
|
2845
|
+
if (elementResize) {
|
|
2846
|
+
resizeObserver = new ResizeObserver(_ref => {
|
|
2847
|
+
let [firstEntry] = _ref;
|
|
2848
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
2849
|
+
// Prevent update loops when using the `size` middleware.
|
|
2850
|
+
// https://github.com/floating-ui/floating-ui/issues/1740
|
|
2851
|
+
resizeObserver.unobserve(floating);
|
|
2852
|
+
cancelAnimationFrame(reobserveFrame);
|
|
2853
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
2854
|
+
var _resizeObserver;
|
|
2855
|
+
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
|
2856
|
+
});
|
|
2857
|
+
}
|
|
2858
|
+
update();
|
|
2859
|
+
});
|
|
2860
|
+
if (referenceEl && !animationFrame) {
|
|
2861
|
+
resizeObserver.observe(referenceEl);
|
|
2862
|
+
}
|
|
2863
|
+
resizeObserver.observe(floating);
|
|
2864
|
+
}
|
|
2865
|
+
let frameId;
|
|
2866
|
+
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
2867
|
+
if (animationFrame) {
|
|
2868
|
+
frameLoop();
|
|
2869
|
+
}
|
|
2870
|
+
function frameLoop() {
|
|
2871
|
+
const nextRefRect = getBoundingClientRect(reference);
|
|
2872
|
+
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
|
|
2873
|
+
update();
|
|
2874
|
+
}
|
|
2875
|
+
prevRefRect = nextRefRect;
|
|
2876
|
+
frameId = requestAnimationFrame(frameLoop);
|
|
2877
|
+
}
|
|
2878
|
+
update();
|
|
2879
|
+
return () => {
|
|
2880
|
+
var _resizeObserver2;
|
|
2881
|
+
ancestors.forEach(ancestor => {
|
|
2882
|
+
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
2883
|
+
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
2884
|
+
});
|
|
2885
|
+
cleanupIo == null || cleanupIo();
|
|
2886
|
+
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
|
2887
|
+
resizeObserver = null;
|
|
2888
|
+
if (animationFrame) {
|
|
2889
|
+
cancelAnimationFrame(frameId);
|
|
2890
|
+
}
|
|
2891
|
+
};
|
|
2892
|
+
}
|
|
2893
|
+
|
|
2894
|
+
/**
|
|
2895
|
+
* Modifies the placement by translating the floating element along the
|
|
2896
|
+
* specified axes.
|
|
2897
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
2898
|
+
* object may be passed.
|
|
2899
|
+
* @see https://floating-ui.com/docs/offset
|
|
2900
|
+
*/
|
|
2901
|
+
const offset$1 = offset$2;
|
|
2902
|
+
|
|
2903
|
+
/**
|
|
2904
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
2905
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
2906
|
+
* @see https://floating-ui.com/docs/shift
|
|
2907
|
+
*/
|
|
2908
|
+
const shift$1 = shift$2;
|
|
2909
|
+
|
|
2910
|
+
/**
|
|
2911
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
2912
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
2913
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
2914
|
+
* @see https://floating-ui.com/docs/flip
|
|
2915
|
+
*/
|
|
2916
|
+
const flip$1 = flip$2;
|
|
2917
|
+
|
|
2918
|
+
/**
|
|
2919
|
+
* Provides data that allows you to change the size of the floating element —
|
|
2920
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
2921
|
+
* width of the reference element.
|
|
2922
|
+
* @see https://floating-ui.com/docs/size
|
|
2923
|
+
*/
|
|
2924
|
+
const size$1 = size$2;
|
|
2925
|
+
|
|
2926
|
+
/**
|
|
2927
|
+
* Provides data to position an inner element of the floating element so that it
|
|
2928
|
+
* appears centered to the reference element.
|
|
2929
|
+
* @see https://floating-ui.com/docs/arrow
|
|
2930
|
+
*/
|
|
2931
|
+
const arrow$2 = arrow$3;
|
|
2932
|
+
|
|
2933
|
+
/**
|
|
2934
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
2935
|
+
* next to a given reference element.
|
|
2936
|
+
*/
|
|
2937
|
+
const computePosition = (reference, floating, options) => {
|
|
2938
|
+
// This caches the expensive `getClippingElementAncestors` function so that
|
|
2939
|
+
// multiple lifecycle resets re-use the same result. It only lives for a
|
|
2940
|
+
// single call. If other functions become expensive, we can add them as well.
|
|
2941
|
+
const cache = new Map();
|
|
2942
|
+
const mergedOptions = {
|
|
2943
|
+
platform,
|
|
2944
|
+
...options
|
|
2945
|
+
};
|
|
2946
|
+
const platformWithCache = {
|
|
2947
|
+
...mergedOptions.platform,
|
|
2948
|
+
_c: cache
|
|
2949
|
+
};
|
|
2950
|
+
return computePosition$1(reference, floating, {
|
|
2951
|
+
...mergedOptions,
|
|
2952
|
+
platform: platformWithCache
|
|
2953
|
+
});
|
|
2954
|
+
};
|
|
2955
|
+
|
|
2956
|
+
var isClient = typeof document !== 'undefined';
|
|
2957
|
+
|
|
2958
|
+
var noop = function noop() {};
|
|
2959
|
+
var index = isClient ? useLayoutEffect : noop;
|
|
2960
|
+
|
|
2961
|
+
// Fork of `fast-deep-equal` that only does the comparisons we need and compares
|
|
2962
|
+
// functions
|
|
2963
|
+
function deepEqual(a, b) {
|
|
2964
|
+
if (a === b) {
|
|
2965
|
+
return true;
|
|
2966
|
+
}
|
|
2967
|
+
if (typeof a !== typeof b) {
|
|
2968
|
+
return false;
|
|
2969
|
+
}
|
|
2970
|
+
if (typeof a === 'function' && a.toString() === b.toString()) {
|
|
2971
|
+
return true;
|
|
2972
|
+
}
|
|
2973
|
+
let length;
|
|
2974
|
+
let i;
|
|
2975
|
+
let keys;
|
|
2976
|
+
if (a && b && typeof a === 'object') {
|
|
2977
|
+
if (Array.isArray(a)) {
|
|
2978
|
+
length = a.length;
|
|
2979
|
+
if (length !== b.length) return false;
|
|
2980
|
+
for (i = length; i-- !== 0;) {
|
|
2981
|
+
if (!deepEqual(a[i], b[i])) {
|
|
2982
|
+
return false;
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
return true;
|
|
2986
|
+
}
|
|
2987
|
+
keys = Object.keys(a);
|
|
2988
|
+
length = keys.length;
|
|
2989
|
+
if (length !== Object.keys(b).length) {
|
|
2990
|
+
return false;
|
|
2991
|
+
}
|
|
2992
|
+
for (i = length; i-- !== 0;) {
|
|
2993
|
+
if (!{}.hasOwnProperty.call(b, keys[i])) {
|
|
2994
|
+
return false;
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
for (i = length; i-- !== 0;) {
|
|
2998
|
+
const key = keys[i];
|
|
2999
|
+
if (key === '_owner' && a.$$typeof) {
|
|
3000
|
+
continue;
|
|
3001
|
+
}
|
|
3002
|
+
if (!deepEqual(a[key], b[key])) {
|
|
3003
|
+
return false;
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
return true;
|
|
3007
|
+
}
|
|
3008
|
+
return a !== a && b !== b;
|
|
3009
|
+
}
|
|
3010
|
+
|
|
3011
|
+
function getDPR(element) {
|
|
3012
|
+
if (typeof window === 'undefined') {
|
|
3013
|
+
return 1;
|
|
3014
|
+
}
|
|
3015
|
+
const win = element.ownerDocument.defaultView || window;
|
|
3016
|
+
return win.devicePixelRatio || 1;
|
|
3017
|
+
}
|
|
3018
|
+
|
|
3019
|
+
function roundByDPR(element, value) {
|
|
3020
|
+
const dpr = getDPR(element);
|
|
3021
|
+
return Math.round(value * dpr) / dpr;
|
|
3022
|
+
}
|
|
3023
|
+
|
|
3024
|
+
function useLatestRef(value) {
|
|
3025
|
+
const ref = React.useRef(value);
|
|
3026
|
+
index(() => {
|
|
3027
|
+
ref.current = value;
|
|
3028
|
+
});
|
|
3029
|
+
return ref;
|
|
3030
|
+
}
|
|
3031
|
+
|
|
3032
|
+
/**
|
|
3033
|
+
* Provides data to position a floating element.
|
|
3034
|
+
* @see https://floating-ui.com/docs/useFloating
|
|
3035
|
+
*/
|
|
3036
|
+
function useFloating(options) {
|
|
3037
|
+
if (options === void 0) {
|
|
3038
|
+
options = {};
|
|
3039
|
+
}
|
|
3040
|
+
const {
|
|
3041
|
+
placement = 'bottom',
|
|
3042
|
+
strategy = 'absolute',
|
|
3043
|
+
middleware = [],
|
|
3044
|
+
platform,
|
|
3045
|
+
elements: {
|
|
3046
|
+
reference: externalReference,
|
|
3047
|
+
floating: externalFloating
|
|
3048
|
+
} = {},
|
|
3049
|
+
transform = true,
|
|
3050
|
+
whileElementsMounted,
|
|
3051
|
+
open
|
|
3052
|
+
} = options;
|
|
3053
|
+
const [data, setData] = React.useState({
|
|
3054
|
+
x: 0,
|
|
3055
|
+
y: 0,
|
|
3056
|
+
strategy,
|
|
3057
|
+
placement,
|
|
3058
|
+
middlewareData: {},
|
|
3059
|
+
isPositioned: false
|
|
3060
|
+
});
|
|
3061
|
+
const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
|
|
3062
|
+
if (!deepEqual(latestMiddleware, middleware)) {
|
|
3063
|
+
setLatestMiddleware(middleware);
|
|
3064
|
+
}
|
|
3065
|
+
const [_reference, _setReference] = React.useState(null);
|
|
3066
|
+
const [_floating, _setFloating] = React.useState(null);
|
|
3067
|
+
const setReference = React.useCallback(node => {
|
|
3068
|
+
if (node !== referenceRef.current) {
|
|
3069
|
+
referenceRef.current = node;
|
|
3070
|
+
_setReference(node);
|
|
3071
|
+
}
|
|
3072
|
+
}, []);
|
|
3073
|
+
const setFloating = React.useCallback(node => {
|
|
3074
|
+
if (node !== floatingRef.current) {
|
|
3075
|
+
floatingRef.current = node;
|
|
3076
|
+
_setFloating(node);
|
|
3077
|
+
}
|
|
3078
|
+
}, []);
|
|
3079
|
+
const referenceEl = externalReference || _reference;
|
|
3080
|
+
const floatingEl = externalFloating || _floating;
|
|
3081
|
+
const referenceRef = React.useRef(null);
|
|
3082
|
+
const floatingRef = React.useRef(null);
|
|
3083
|
+
const dataRef = React.useRef(data);
|
|
3084
|
+
const hasWhileElementsMounted = whileElementsMounted != null;
|
|
3085
|
+
const whileElementsMountedRef = useLatestRef(whileElementsMounted);
|
|
3086
|
+
const platformRef = useLatestRef(platform);
|
|
3087
|
+
const openRef = useLatestRef(open);
|
|
3088
|
+
const update = React.useCallback(() => {
|
|
3089
|
+
if (!referenceRef.current || !floatingRef.current) {
|
|
3090
|
+
return;
|
|
3091
|
+
}
|
|
3092
|
+
const config = {
|
|
3093
|
+
placement,
|
|
3094
|
+
strategy,
|
|
3095
|
+
middleware: latestMiddleware
|
|
3096
|
+
};
|
|
3097
|
+
if (platformRef.current) {
|
|
3098
|
+
config.platform = platformRef.current;
|
|
3099
|
+
}
|
|
3100
|
+
computePosition(referenceRef.current, floatingRef.current, config).then(data => {
|
|
3101
|
+
const fullData = {
|
|
3102
|
+
...data,
|
|
3103
|
+
// The floating element's position may be recomputed while it's closed
|
|
3104
|
+
// but still mounted (such as when transitioning out). To ensure
|
|
3105
|
+
// `isPositioned` will be `false` initially on the next open, avoid
|
|
3106
|
+
// setting it to `true` when `open === false` (must be specified).
|
|
3107
|
+
isPositioned: openRef.current !== false
|
|
3108
|
+
};
|
|
3109
|
+
if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
|
|
3110
|
+
dataRef.current = fullData;
|
|
3111
|
+
ReactDOM.flushSync(() => {
|
|
3112
|
+
setData(fullData);
|
|
3113
|
+
});
|
|
3114
|
+
}
|
|
3115
|
+
});
|
|
3116
|
+
}, [latestMiddleware, placement, strategy, platformRef, openRef]);
|
|
3117
|
+
index(() => {
|
|
3118
|
+
if (open === false && dataRef.current.isPositioned) {
|
|
3119
|
+
dataRef.current.isPositioned = false;
|
|
3120
|
+
setData(data => ({
|
|
3121
|
+
...data,
|
|
3122
|
+
isPositioned: false
|
|
3123
|
+
}));
|
|
3124
|
+
}
|
|
3125
|
+
}, [open]);
|
|
3126
|
+
const isMountedRef = React.useRef(false);
|
|
3127
|
+
index(() => {
|
|
3128
|
+
isMountedRef.current = true;
|
|
3129
|
+
return () => {
|
|
3130
|
+
isMountedRef.current = false;
|
|
3131
|
+
};
|
|
3132
|
+
}, []);
|
|
3133
|
+
index(() => {
|
|
3134
|
+
if (referenceEl) referenceRef.current = referenceEl;
|
|
3135
|
+
if (floatingEl) floatingRef.current = floatingEl;
|
|
3136
|
+
if (referenceEl && floatingEl) {
|
|
3137
|
+
if (whileElementsMountedRef.current) {
|
|
3138
|
+
return whileElementsMountedRef.current(referenceEl, floatingEl, update);
|
|
3139
|
+
}
|
|
3140
|
+
update();
|
|
3141
|
+
}
|
|
3142
|
+
}, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
|
|
3143
|
+
const refs = React.useMemo(() => ({
|
|
3144
|
+
reference: referenceRef,
|
|
3145
|
+
floating: floatingRef,
|
|
3146
|
+
setReference,
|
|
3147
|
+
setFloating
|
|
3148
|
+
}), [setReference, setFloating]);
|
|
3149
|
+
const elements = React.useMemo(() => ({
|
|
3150
|
+
reference: referenceEl,
|
|
3151
|
+
floating: floatingEl
|
|
3152
|
+
}), [referenceEl, floatingEl]);
|
|
3153
|
+
const floatingStyles = React.useMemo(() => {
|
|
3154
|
+
const initialStyles = {
|
|
3155
|
+
position: strategy,
|
|
3156
|
+
left: 0,
|
|
3157
|
+
top: 0
|
|
3158
|
+
};
|
|
3159
|
+
if (!elements.floating) {
|
|
3160
|
+
return initialStyles;
|
|
3161
|
+
}
|
|
3162
|
+
const x = roundByDPR(elements.floating, data.x);
|
|
3163
|
+
const y = roundByDPR(elements.floating, data.y);
|
|
3164
|
+
if (transform) {
|
|
3165
|
+
return {
|
|
3166
|
+
...initialStyles,
|
|
3167
|
+
transform: "translate(" + x + "px, " + y + "px)",
|
|
3168
|
+
...(getDPR(elements.floating) >= 1.5 && {
|
|
3169
|
+
willChange: 'transform'
|
|
3170
|
+
})
|
|
3171
|
+
};
|
|
3172
|
+
}
|
|
3173
|
+
return {
|
|
3174
|
+
position: strategy,
|
|
3175
|
+
left: x,
|
|
3176
|
+
top: y
|
|
3177
|
+
};
|
|
3178
|
+
}, [strategy, transform, elements.floating, data.x, data.y]);
|
|
3179
|
+
return React.useMemo(() => ({
|
|
3180
|
+
...data,
|
|
3181
|
+
update,
|
|
3182
|
+
refs,
|
|
3183
|
+
elements,
|
|
3184
|
+
floatingStyles
|
|
3185
|
+
}), [data, update, refs, elements, floatingStyles]);
|
|
3186
|
+
}
|
|
3187
|
+
|
|
3188
|
+
/**
|
|
3189
|
+
* Provides data to position an inner element of the floating element so that it
|
|
3190
|
+
* appears centered to the reference element.
|
|
3191
|
+
* This wraps the core `arrow` middleware to allow React refs as the element.
|
|
3192
|
+
* @see https://floating-ui.com/docs/arrow
|
|
3193
|
+
*/
|
|
3194
|
+
const arrow$1 = options => {
|
|
3195
|
+
function isRef(value) {
|
|
3196
|
+
return {}.hasOwnProperty.call(value, 'current');
|
|
3197
|
+
}
|
|
3198
|
+
return {
|
|
3199
|
+
name: 'arrow',
|
|
3200
|
+
options,
|
|
3201
|
+
fn(state) {
|
|
3202
|
+
const {
|
|
3203
|
+
element,
|
|
3204
|
+
padding
|
|
3205
|
+
} = typeof options === 'function' ? options(state) : options;
|
|
3206
|
+
if (element && isRef(element)) {
|
|
3207
|
+
if (element.current != null) {
|
|
3208
|
+
return arrow$2({
|
|
3209
|
+
element: element.current,
|
|
3210
|
+
padding
|
|
3211
|
+
}).fn(state);
|
|
3212
|
+
}
|
|
3213
|
+
return {};
|
|
3214
|
+
}
|
|
3215
|
+
if (element) {
|
|
3216
|
+
return arrow$2({
|
|
3217
|
+
element,
|
|
3218
|
+
padding
|
|
3219
|
+
}).fn(state);
|
|
3220
|
+
}
|
|
3221
|
+
return {};
|
|
3222
|
+
}
|
|
3223
|
+
};
|
|
3224
|
+
};
|
|
3225
|
+
|
|
3226
|
+
/**
|
|
3227
|
+
* Modifies the placement by translating the floating element along the
|
|
3228
|
+
* specified axes.
|
|
3229
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
3230
|
+
* object may be passed.
|
|
3231
|
+
* @see https://floating-ui.com/docs/offset
|
|
3232
|
+
*/
|
|
3233
|
+
const offset = (options, deps) => ({
|
|
3234
|
+
...offset$1(options),
|
|
3235
|
+
options: [options, deps]
|
|
3236
|
+
});
|
|
3237
|
+
|
|
3238
|
+
/**
|
|
3239
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
3240
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
3241
|
+
* @see https://floating-ui.com/docs/shift
|
|
3242
|
+
*/
|
|
3243
|
+
const shift = (options, deps) => ({
|
|
3244
|
+
...shift$1(options),
|
|
3245
|
+
options: [options, deps]
|
|
3246
|
+
});
|
|
3247
|
+
|
|
3248
|
+
/**
|
|
3249
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
3250
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
3251
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
3252
|
+
* @see https://floating-ui.com/docs/flip
|
|
3253
|
+
*/
|
|
3254
|
+
const flip = (options, deps) => ({
|
|
3255
|
+
...flip$1(options),
|
|
3256
|
+
options: [options, deps]
|
|
3257
|
+
});
|
|
3258
|
+
|
|
3259
|
+
/**
|
|
3260
|
+
* Provides data that allows you to change the size of the floating element —
|
|
3261
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
3262
|
+
* width of the reference element.
|
|
3263
|
+
* @see https://floating-ui.com/docs/size
|
|
3264
|
+
*/
|
|
3265
|
+
const size = (options, deps) => ({
|
|
3266
|
+
...size$1(options),
|
|
3267
|
+
options: [options, deps]
|
|
3268
|
+
});
|
|
3269
|
+
|
|
3270
|
+
/**
|
|
3271
|
+
* Provides data to position an inner element of the floating element so that it
|
|
3272
|
+
* appears centered to the reference element.
|
|
3273
|
+
* This wraps the core `arrow` middleware to allow React refs as the element.
|
|
3274
|
+
* @see https://floating-ui.com/docs/arrow
|
|
3275
|
+
*/
|
|
3276
|
+
const arrow = (options, deps) => ({
|
|
3277
|
+
...arrow$1(options),
|
|
3278
|
+
options: [options, deps]
|
|
3279
|
+
});
|
|
3280
|
+
|
|
3281
|
+
function TooltipTrigger({ as, asChild = false, children, ...props }) {
|
|
3282
|
+
const TooltipTriggerElement = as || Button$1;
|
|
3283
|
+
if (asChild && isValidElement(children))
|
|
3284
|
+
return cloneElement(children, props);
|
|
3285
|
+
return jsx(TooltipTriggerElement, { ...props, children: children });
|
|
3286
|
+
}
|
|
3287
|
+
function TooltipPanel({ as, children, className, style, ...props }) {
|
|
3288
|
+
const TooltipPanelElement = as || 'div';
|
|
3289
|
+
return (jsx(TooltipPanelElement, { ...props, className: twMerge('absolute top-0 left-0 z-50 w-max rounded-md bg-neutral-50 px-2 py-1 text-sm text-neutral-950 opacity-0 shadow-lg outline-1 outline-neutral-400 data-portal:fixed data-ready:animate-fade-in dark:bg-neutral-800 dark:text-neutral-50 dark:shadow-none dark:-outline-offset-1 dark:outline-neutral-600', className), style: style, children: children }));
|
|
3290
|
+
}
|
|
3291
|
+
function Tooltip({ anchor = 'top', arrow: arrow$1, arrowClassName, children, delay = 500, offset: offset$1 = 8, onClose, onOpen, portal, }) {
|
|
3292
|
+
const [isOpen, setIsOpen] = useState(false), timeoutRef = useRef(undefined), arrowRef = useRef(null);
|
|
3293
|
+
const [bodyElement, setBodyElement] = useState(() => typeof window !== 'undefined' ? document.body : null);
|
|
3294
|
+
useEffect(() => {
|
|
3295
|
+
if (typeof window !== 'undefined' && !bodyElement) {
|
|
3296
|
+
const documentBody = document.body;
|
|
3297
|
+
setBodyElement(documentBody);
|
|
3298
|
+
}
|
|
3299
|
+
}, [bodyElement, portal]);
|
|
3300
|
+
const { refs, floatingStyles, isPositioned, placement, middlewareData } = useFloating({
|
|
3301
|
+
middleware: [
|
|
3302
|
+
offset(offset$1),
|
|
3303
|
+
flip({ padding: 20 }),
|
|
3304
|
+
shift({ padding: 20 }),
|
|
3305
|
+
size({
|
|
3306
|
+
apply({ availableHeight, availableWidth, elements }) {
|
|
3307
|
+
const height = `${Math.max(0, availableHeight) / 16}rem`, width = `${Math.min(418, availableWidth) / 16}rem`;
|
|
3308
|
+
elements.floating.style.maxHeight = height;
|
|
3309
|
+
elements.floating.style.maxWidth = width;
|
|
3310
|
+
},
|
|
3311
|
+
}),
|
|
3312
|
+
...(arrowRef.current ? [arrow({ element: arrowRef.current })] : []),
|
|
3313
|
+
],
|
|
3314
|
+
placement: anchor,
|
|
3315
|
+
strategy: portal ? 'fixed' : 'absolute',
|
|
3316
|
+
whileElementsMounted: autoUpdate,
|
|
3317
|
+
open: isOpen,
|
|
3318
|
+
});
|
|
3319
|
+
const openTooltip = useCallback(() => {
|
|
3320
|
+
clearTimeout(timeoutRef.current);
|
|
3321
|
+
if (delay > 0) {
|
|
3322
|
+
timeoutRef.current = setTimeout(() => {
|
|
3323
|
+
setIsOpen(true);
|
|
3324
|
+
onOpen?.();
|
|
3325
|
+
}, delay);
|
|
3326
|
+
}
|
|
3327
|
+
else {
|
|
3328
|
+
setIsOpen(true);
|
|
3329
|
+
onOpen?.();
|
|
3330
|
+
}
|
|
3331
|
+
}, [delay, onOpen]);
|
|
3332
|
+
const closeTooltip = useCallback(() => {
|
|
3333
|
+
clearTimeout(timeoutRef.current);
|
|
3334
|
+
setIsOpen(false);
|
|
3335
|
+
onClose?.();
|
|
3336
|
+
}, [onClose]);
|
|
3337
|
+
useEffect(() => {
|
|
3338
|
+
return () => {
|
|
3339
|
+
clearTimeout(timeoutRef.current);
|
|
3340
|
+
};
|
|
3341
|
+
}, []);
|
|
3342
|
+
const content = typeof children === 'function' ? children({ openTooltip, closeTooltip }) : children;
|
|
3343
|
+
const triggerElement = findComponentByType(content, TooltipTrigger), contentElement = findComponentByType(content, TooltipPanel);
|
|
3344
|
+
if (!contentElement)
|
|
3345
|
+
throw new Error('TooltipPanel must be defined in Tooltip children');
|
|
3346
|
+
if (!triggerElement && typeof children !== 'function')
|
|
3347
|
+
throw new Error('TooltipTrigger must be provided when not using render prop pattern');
|
|
3348
|
+
const arrowStyles = {};
|
|
3349
|
+
const reversedAnchor = {
|
|
3350
|
+
top: 'bottom',
|
|
3351
|
+
right: 'left',
|
|
3352
|
+
bottom: 'top',
|
|
3353
|
+
left: 'right',
|
|
3354
|
+
'top-start': 'bottom left',
|
|
3355
|
+
'top-end': 'bottom right',
|
|
3356
|
+
'right-start': 'top left',
|
|
3357
|
+
'right-end': 'bottom left',
|
|
3358
|
+
'bottom-start': 'top left',
|
|
3359
|
+
'bottom-end': 'top right',
|
|
3360
|
+
'left-start': 'top right',
|
|
3361
|
+
'left-end': 'bottom right',
|
|
3362
|
+
}[placement];
|
|
3363
|
+
if (middlewareData.arrow && arrow$1) {
|
|
3364
|
+
const { x, y } = middlewareData.arrow;
|
|
3365
|
+
const staticSide = {
|
|
3366
|
+
top: 'bottom',
|
|
3367
|
+
right: 'left',
|
|
3368
|
+
bottom: 'top',
|
|
3369
|
+
left: 'right',
|
|
3370
|
+
}[placement.split('-')[0]];
|
|
3371
|
+
if (staticSide) {
|
|
3372
|
+
arrowStyles[staticSide] = '-4px';
|
|
3373
|
+
if (x != null)
|
|
3374
|
+
arrowStyles.left = `${x}px`;
|
|
3375
|
+
if (y != null)
|
|
3376
|
+
arrowStyles.top = `${y}px`;
|
|
3377
|
+
}
|
|
3378
|
+
}
|
|
3379
|
+
const getArrowLocationClasses = () => {
|
|
3380
|
+
switch (placement) {
|
|
3381
|
+
case 'bottom':
|
|
3382
|
+
case 'bottom-end':
|
|
3383
|
+
case 'bottom-start':
|
|
3384
|
+
return '-translate-y-1';
|
|
3385
|
+
case 'top':
|
|
3386
|
+
case 'top-end':
|
|
3387
|
+
case 'top-start':
|
|
3388
|
+
return 'rotate-180 translate-y-1';
|
|
3389
|
+
case 'left':
|
|
3390
|
+
case 'left-end':
|
|
3391
|
+
case 'left-start':
|
|
3392
|
+
return 'rotate-90 translate-x-2';
|
|
3393
|
+
case 'right':
|
|
3394
|
+
case 'right-end':
|
|
3395
|
+
case 'right-start':
|
|
3396
|
+
return '-rotate-90 -translate-x-2';
|
|
3397
|
+
}
|
|
3398
|
+
};
|
|
3399
|
+
const arrowLocationClasses = getArrowLocationClasses();
|
|
3400
|
+
const handleMouseEnter = e => {
|
|
3401
|
+
openTooltip();
|
|
3402
|
+
triggerElement?.props.onMouseEnter?.(e);
|
|
3403
|
+
};
|
|
3404
|
+
const handleMouseLeave = e => {
|
|
3405
|
+
triggerElement?.props.onMouseLeave?.(e);
|
|
3406
|
+
closeTooltip();
|
|
3407
|
+
};
|
|
3408
|
+
const handleTouchStart = e => {
|
|
3409
|
+
openTooltip();
|
|
3410
|
+
triggerElement?.props.onTouchStart?.(e);
|
|
3411
|
+
};
|
|
3412
|
+
const handleFocus = e => {
|
|
3413
|
+
triggerElement?.props.onFocus?.(e);
|
|
3414
|
+
openTooltip();
|
|
3415
|
+
};
|
|
3416
|
+
const handleBlur = e => {
|
|
3417
|
+
triggerElement?.props.onBlur?.(e);
|
|
3418
|
+
closeTooltip();
|
|
3419
|
+
};
|
|
3420
|
+
const tooltipContent = (jsx(Fragment$1, { children: isOpen &&
|
|
3421
|
+
contentElement &&
|
|
3422
|
+
cloneElement(contentElement, {
|
|
3423
|
+
children: (jsxs(Fragment$1, { children: [contentElement.props.children, arrow$1 && (jsx(ArrowSvg, { className: twMerge('absolute', arrowLocationClasses, arrowClassName), style: arrowStyles, "data-tooltip-arrow": true }))] })),
|
|
3424
|
+
...(portal ? { 'data-portal': true } : {}),
|
|
3425
|
+
...(isPositioned ? { 'data-ready': true } : {}),
|
|
3426
|
+
onMouseEnter: openTooltip,
|
|
3427
|
+
onMouseLeave: closeTooltip,
|
|
3428
|
+
onTouchStart: handleTouchStart,
|
|
3429
|
+
ref: (node) => {
|
|
3430
|
+
refs.setFloating(node);
|
|
3431
|
+
if (node && arrow$1) {
|
|
3432
|
+
const arrowElement = node.querySelector('[data-tooltip-arrow]');
|
|
3433
|
+
if (arrowElement)
|
|
3434
|
+
arrowRef.current = arrowElement;
|
|
3435
|
+
}
|
|
3436
|
+
},
|
|
3437
|
+
role: 'tooltip',
|
|
3438
|
+
style: {
|
|
3439
|
+
...contentElement.props.style,
|
|
3440
|
+
...floatingStyles,
|
|
3441
|
+
transformOrigin: reversedAnchor,
|
|
3442
|
+
pointerEvents: 'none',
|
|
3443
|
+
},
|
|
3444
|
+
}) }));
|
|
3445
|
+
return (jsxs(Fragment$1, { children: [triggerElement &&
|
|
3446
|
+
cloneElement(triggerElement, {
|
|
3447
|
+
ref: refs.setReference,
|
|
3448
|
+
onMouseEnter: handleMouseEnter,
|
|
3449
|
+
onMouseLeave: handleMouseLeave,
|
|
3450
|
+
onFocus: handleFocus,
|
|
3451
|
+
onBlur: handleBlur,
|
|
3452
|
+
'aria-describedby': isOpen ? 'tooltip' : undefined,
|
|
3453
|
+
}), portal ? bodyElement && createPortal(tooltipContent, bodyElement) : tooltipContent] }));
|
|
3454
|
+
}
|
|
3455
|
+
function ArrowSvg({ className, ...props }) {
|
|
3456
|
+
return (jsxs("svg", { viewBox: '0 0 20 10', className: twMerge('h-2.5 w-5 fill-none', className), ...props, children: [jsx("path", { d: 'M9.66437 2.60207L4.80758 6.97318C4.07308 7.63423 3.11989 8 2.13172 8H0V10H20V8H18.5349C17.5468 8 16.5936 7.63423 15.8591 6.97318L11.0023 2.60207C10.622 2.2598 10.0447 2.25979 9.66437 2.60207Z', className: 'fill-neutral-50 dark:fill-neutral-800' }), jsx("path", { d: 'M8.99542 1.85876C9.75604 1.17425 10.9106 1.17422 11.6713 1.85878L16.5281 6.22989C17.0789 6.72568 17.7938 7.00001 18.5349 7.00001L15.89 7L11.0023 2.60207C10.622 2.2598 10.0447 2.2598 9.66436 2.60207L4.77734 7L2.13171 7.00001C2.87284 7.00001 3.58774 6.72568 4.13861 6.22989L8.99542 1.85876Z', className: 'fill-neutral-400 dark:fill-none' }), jsx("path", { d: 'M10.3333 3.34539L5.47654 7.71648C4.55842 8.54279 3.36693 9 2.13172 9H0V8H2.13172C3.11989 8 4.07308 7.63423 4.80758 6.97318L9.66437 2.60207C10.0447 2.25979 10.622 2.2598 11.0023 2.60207L15.8591 6.97318C16.5936 7.63423 17.5468 8 18.5349 8H20V9H18.5349C17.2998 9 16.1083 8.54278 15.1901 7.71648L10.3333 3.34539Z', className: 'dark:fill-neutral-600' })] }));
|
|
3457
|
+
}
|
|
3458
|
+
|
|
3459
|
+
function Input({ checked, className, defaultValue, description, descriptionProps, disabled, fieldProps, invalid = true, label, labelProps, name, onBlur, onChange, placeholder, ref, required = true, type, value, ...props }) {
|
|
3460
|
+
const [formContext, setFormContext] = useFormContext(), [errorMessage, setErrorMessage] = useState(undefined);
|
|
3461
|
+
if (placeholder === '*')
|
|
3462
|
+
placeholder = name + (required && !label ? '*' : '');
|
|
3463
|
+
if (label === '*')
|
|
3464
|
+
label = name;
|
|
3465
|
+
const uniqueID = useId(), fieldContextID = toLowerCase(name, [, '_']) + '§' + uniqueID;
|
|
3466
|
+
if (Boolean(formContext?.find(field => field.id === fieldContextID)?.invalid))
|
|
3467
|
+
invalid = true;
|
|
3468
|
+
const getFieldContextType = () => {
|
|
3469
|
+
switch (type) {
|
|
3470
|
+
case 'email':
|
|
3471
|
+
return 'email';
|
|
3472
|
+
case 'file':
|
|
3473
|
+
return 'file';
|
|
3474
|
+
case 'number':
|
|
3475
|
+
return 'number';
|
|
3476
|
+
case 'tel':
|
|
3477
|
+
return 'tel';
|
|
3478
|
+
case 'url':
|
|
3479
|
+
return 'url';
|
|
3480
|
+
default:
|
|
3481
|
+
return 'string';
|
|
3482
|
+
}
|
|
3483
|
+
};
|
|
3484
|
+
const fieldContextType = getFieldContextType();
|
|
3485
|
+
const initialFieldContext = defineField({
|
|
3486
|
+
type: fieldContextType,
|
|
3487
|
+
id: fieldContextID,
|
|
3488
|
+
invalid,
|
|
3489
|
+
name,
|
|
3490
|
+
required,
|
|
3491
|
+
value: value ? `${value}` : defaultValue ? `${defaultValue}` : '',
|
|
3492
|
+
});
|
|
3493
|
+
useEffect(() => {
|
|
3494
|
+
if (!setFormContext)
|
|
3495
|
+
return;
|
|
3496
|
+
setFormContext(prevContext => {
|
|
3497
|
+
const otherFields = (prevContext || []).filter(field => field.id !== initialFieldContext.id);
|
|
3498
|
+
return [...otherFields, initialFieldContext];
|
|
3499
|
+
});
|
|
3500
|
+
return () => {
|
|
3501
|
+
setFormContext(prevContext => (prevContext || []).filter(field => field.id !== initialFieldContext.id));
|
|
3502
|
+
};
|
|
3503
|
+
}, [setFormContext]);
|
|
3504
|
+
const fieldContext = formContext?.find(({ id: fieldID }) => fieldID === initialFieldContext.id) || initialFieldContext;
|
|
3505
|
+
const validateField = (validValue) => {
|
|
3506
|
+
const noValue = !validValue || validValue === '';
|
|
3507
|
+
if (!required && noValue)
|
|
3508
|
+
return true;
|
|
3509
|
+
const errorMessageList = [];
|
|
3510
|
+
if (noValue) {
|
|
3511
|
+
errorMessageList.push('This field is required.');
|
|
3512
|
+
setErrorMessage(errorMessageList.join(' '));
|
|
3513
|
+
return false;
|
|
3514
|
+
}
|
|
3515
|
+
switch (type) {
|
|
3516
|
+
case 'email':
|
|
3517
|
+
if (!isEmail(validValue))
|
|
3518
|
+
errorMessageList.push('This is not a valid email.');
|
|
3519
|
+
break;
|
|
3520
|
+
case 'number':
|
|
3521
|
+
if (isNaN(Number(validValue)))
|
|
3522
|
+
errorMessageList.push('This is not a valid number.');
|
|
3523
|
+
break;
|
|
3524
|
+
case 'tel':
|
|
3525
|
+
if (!isPhoneNumber(validValue))
|
|
3526
|
+
errorMessageList.push('This is not a valid phone number.');
|
|
3527
|
+
break;
|
|
3528
|
+
}
|
|
3529
|
+
if (errorMessageList.length === 0)
|
|
3530
|
+
return true;
|
|
3531
|
+
setErrorMessage(errorMessageList.join(' '));
|
|
3532
|
+
return false;
|
|
3533
|
+
};
|
|
3534
|
+
const handleChange = e => {
|
|
3535
|
+
if (disabled) {
|
|
3536
|
+
e.preventDefault();
|
|
3537
|
+
return;
|
|
3538
|
+
}
|
|
3539
|
+
const { currentTarget } = e, { value: newValue } = currentTarget;
|
|
3540
|
+
setFormContext?.(prevContext => {
|
|
3541
|
+
if (!prevContext)
|
|
3542
|
+
return [];
|
|
3543
|
+
const field = prevContext.find(({ id: fieldID }) => fieldID === initialFieldContext.id);
|
|
3544
|
+
if (!field)
|
|
3545
|
+
throw new Error(`Field with id "${initialFieldContext.id}" not found in form context.`);
|
|
3546
|
+
const otherFields = prevContext.filter(({ id: fieldID }) => fieldID !== initialFieldContext.id);
|
|
3547
|
+
const updatedField = { ...field, value: newValue };
|
|
3548
|
+
const invalidField = validateField(newValue) === false;
|
|
3549
|
+
if (invalidField !== field.invalid)
|
|
3550
|
+
updatedField.invalid = invalidField;
|
|
3551
|
+
return [...otherFields, updatedField];
|
|
3552
|
+
});
|
|
3553
|
+
onChange?.(e);
|
|
3554
|
+
};
|
|
3555
|
+
const handleBlur = e => {
|
|
3556
|
+
if (disabled) {
|
|
3557
|
+
e.preventDefault();
|
|
3558
|
+
return;
|
|
3559
|
+
}
|
|
3560
|
+
const { currentTarget } = e, { value: newValue } = currentTarget;
|
|
3561
|
+
if (required)
|
|
3562
|
+
validateField(newValue);
|
|
3563
|
+
switch (type) {
|
|
3564
|
+
case 'email':
|
|
3565
|
+
setFormContext?.(prevContext => {
|
|
3566
|
+
if (!prevContext)
|
|
3567
|
+
return [];
|
|
3568
|
+
const field = prevContext.find(({ id: fieldID }) => fieldID === initialFieldContext.id);
|
|
3569
|
+
if (!field)
|
|
3570
|
+
throw new Error(`Field with id "${initialFieldContext.id}" not found in form context.`);
|
|
3571
|
+
const otherFields = prevContext.filter(({ id: fieldID }) => fieldID !== initialFieldContext.id);
|
|
3572
|
+
const updatedField = { ...field, value: newValue.toLowerCase() };
|
|
3573
|
+
return [...otherFields, updatedField];
|
|
3574
|
+
});
|
|
3575
|
+
break;
|
|
3576
|
+
case 'tel':
|
|
3577
|
+
setFormContext?.(prevContext => {
|
|
3578
|
+
if (!prevContext)
|
|
3579
|
+
return [];
|
|
3580
|
+
const field = prevContext.find(({ id: fieldID }) => fieldID === initialFieldContext.id);
|
|
3581
|
+
if (!field)
|
|
3582
|
+
throw new Error(`Field with id "${initialFieldContext.id}" not found in form context.`);
|
|
3583
|
+
const otherFields = prevContext.filter(({ id: fieldID }) => fieldID !== initialFieldContext.id);
|
|
3584
|
+
const updatedField = { ...field, value: formatPhoneNumber(newValue, '1') };
|
|
3585
|
+
return [...otherFields, updatedField];
|
|
3586
|
+
});
|
|
3587
|
+
break;
|
|
3588
|
+
}
|
|
3589
|
+
onBlur?.(e);
|
|
3590
|
+
};
|
|
3591
|
+
const restFieldProps = fieldProps
|
|
3592
|
+
? Object.fromEntries(Object.entries(fieldProps).filter(([key]) => key !== 'className'))
|
|
3593
|
+
: {};
|
|
3594
|
+
const restLabelProps = labelProps
|
|
3595
|
+
? Object.fromEntries(Object.entries(labelProps).filter(([key]) => key !== 'className'))
|
|
3596
|
+
: {};
|
|
3597
|
+
const restDescriptionProps = descriptionProps
|
|
3598
|
+
? Object.fromEntries(Object.entries(descriptionProps).filter(([key]) => key !== 'className'))
|
|
3599
|
+
: {};
|
|
3600
|
+
return (jsxs(Field, { ...restFieldProps, className: bag => twMerge('grid gap-1', typeof fieldProps?.className === 'function' ? fieldProps?.className(bag) : fieldProps?.className), disabled: disabled, children: [label && (jsx(Label, { ...restLabelProps, className: bag => twMerge('text-sm font-medium', required ? 'after:text-ui-red after:content-["_*"]' : '', typeof labelProps?.className === 'function' ? labelProps?.className(bag) : labelProps?.className), children: label })), jsxs("div", { children: [jsx(Input$1, { ...props, className: bag => twMerge(
|
|
3601
|
+
// Base styles
|
|
3602
|
+
'w-full rounded-xl border-1 border-neutral-500/50 bg-neutral-100 py-1 pl-2 text-neutral-950 outline-offset-1 outline-ui-sky-blue/95 transition-[background-color] duration-300 ease-exponential dark:bg-neutral-700 dark:text-neutral-50',
|
|
3603
|
+
// Pseudo styles
|
|
3604
|
+
'focus-visible:bg-neutral-50 focus-visible:outline-3 active:bg-neutral-200 dark:focus-visible:bg-neutral-600 dark:active:bg-neutral-800 pointer-fine:hover:bg-neutral-50 pointer-fine:active:bg-neutral-200 dark:pointer-fine:hover:bg-neutral-600 dark:pointer-fine:active:bg-neutral-800',
|
|
3605
|
+
// user-invalid styles
|
|
3606
|
+
'user-invalid:border-ui-red user-invalid:bg-[color-mix(in_oklab,var(--color-ui-red)_20%,var(--color-neutral-100))] user-invalid:focus-visible:bg-[color-mix(in_oklab,var(--color-ui-red)_1%,var(--color-neutral-100))] user-invalid:active:bg-[color-mix(in_oklab,var(--color-ui-red)_25%,var(--color-neutral-100))] dark:user-invalid:bg-[color-mix(in_oklab,var(--color-ui-red)_20%,var(--color-neutral-800))] dark:user-invalid:focus-visible:bg-[color-mix(in_oklab,var(--color-ui-red)_1%,var(--color-neutral-800))] dark:user-invalid:active:bg-[color-mix(in_oklab,var(--color-ui-red)_25%,var(--color-neutral-800))] user-invalid:pointer-fine:hover:bg-[color-mix(in_oklab,var(--color-ui-red)_10%,var(--color-neutral-100))] user-invalid:pointer-fine:focus-visible:bg-[color-mix(in_oklab,var(--color-ui-red)_1%,var(--color-neutral-100))] user-invalid:pointer-fine:active:bg-[color-mix(in_oklab,var(--color-ui-red)_25%,var(--color-neutral-100))] dark:user-invalid:pointer-fine:hover:bg-[color-mix(in_oklab,var(--color-ui-red)_10%,var(--color-neutral-800))] dark:user-invalid:pointer-fine:focus-visible:bg-[color-mix(in_oklab,var(--color-ui-red)_1%,var(--color-neutral-800))] dark:user-invalid:pointer-fine:active:bg-[color-mix(in_oklab,var(--color-ui-red)_25%,var(--color-neutral-800))]',
|
|
3607
|
+
// Custom styles
|
|
3608
|
+
typeof className === 'function' ? className(bag) : className), invalid: invalid, onBlur: handleBlur, onChange: handleChange, placeholder: placeholder, ref: ref, required: required, type: type, value: fieldContext?.value }), fieldContext.invalid && errorMessage && (jsxs(Tooltip, { anchor: 'top-end', arrow: true, portal: true, children: [jsx(TooltipTrigger, { as: Button, className: 'absolute top-1.25 right-1.25 z-10 size-6 min-w-0', padding: 'none', rounded: 'md', theme: 'red', children: jsx(ExclamationmarkOctagon, { className: 'absolute top-1/2 left-1/2 size-full -translate-x-1/2 -translate-y-1/2 scale-70' }) }), jsx(TooltipPanel, { children: errorMessage })] }))] }), description && (jsx(Description, { ...restDescriptionProps, className: bag => twMerge('text-xs', typeof descriptionProps?.className === 'function'
|
|
3609
|
+
? descriptionProps?.className(bag)
|
|
3610
|
+
: descriptionProps?.className), children: description }))] }));
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3613
|
+
function SubmitButton({ children, className, customTheme, error, incomplete, loading, success, type = 'submit', ...props }) {
|
|
3614
|
+
const [formStatus] = useFormStatus();
|
|
3615
|
+
const getFormStatusButtonClasses = () => {
|
|
3616
|
+
switch (formStatus) {
|
|
3617
|
+
case 'loading':
|
|
3618
|
+
return twSort('animate-pulse cursor-wait text-lg leading-6 font-black tracking-widest');
|
|
3619
|
+
case 'error':
|
|
3620
|
+
case 'success':
|
|
3621
|
+
return 'cursor-not-allowed';
|
|
3622
|
+
default:
|
|
3623
|
+
return undefined;
|
|
3624
|
+
}
|
|
3625
|
+
};
|
|
3626
|
+
const formStatusButtonClasses = getFormStatusButtonClasses();
|
|
3627
|
+
const getButtonText = () => {
|
|
3628
|
+
switch (formStatus) {
|
|
3629
|
+
case 'incomplete':
|
|
3630
|
+
return incomplete || 'Complete Form';
|
|
3631
|
+
case 'loading':
|
|
3632
|
+
return (loading || (jsxs(Fragment$1, { children: [jsx("span", { className: 'inline-block animate-wave animation-delay-300', children: "\u2022" }), jsx("span", { className: 'inline-block animate-wave animation-delay-150', children: "\u2022" }), jsx("span", { className: 'inline-block animate-wave', children: "\u2022" })] })));
|
|
3633
|
+
case 'error':
|
|
3634
|
+
return (jsxs(Fragment$1, { children: [error || 'Error', ' ', jsx("span", { className: 'absolute top-1/2 ml-1.5 translate-y-[calc(-50%-1.5px)] text-2xl', children: "\u00D7" })] }));
|
|
3635
|
+
case 'success':
|
|
3636
|
+
return success || 'Successfully Submitted';
|
|
3637
|
+
default:
|
|
3638
|
+
return children || 'Submit';
|
|
3639
|
+
}
|
|
3640
|
+
};
|
|
3641
|
+
const buttonText = getButtonText();
|
|
3642
|
+
const getDataFormState = () => {
|
|
3643
|
+
switch (formStatus) {
|
|
3644
|
+
case 'error':
|
|
3645
|
+
return { 'data-error': true };
|
|
3646
|
+
case 'incomplete':
|
|
3647
|
+
return { 'data-incomplete': true };
|
|
3648
|
+
case 'loading':
|
|
3649
|
+
return { 'data-loading': true };
|
|
3650
|
+
case 'readonly':
|
|
3651
|
+
return { 'data-readonly': true };
|
|
3652
|
+
case 'ready':
|
|
3653
|
+
return { 'data-ready': true };
|
|
3654
|
+
case 'success':
|
|
3655
|
+
return { 'data-success': true };
|
|
3656
|
+
default:
|
|
3657
|
+
return {};
|
|
3658
|
+
}
|
|
3659
|
+
};
|
|
3660
|
+
const dataFormState = getDataFormState();
|
|
3661
|
+
return (jsx(Button, { ...props, ...dataFormState, as: 'button', className: twMerge([formStatusButtonClasses, 'w-full text-white data-loading:text-black', className]), customTheme: {
|
|
3662
|
+
themeColor: twMerge('data-error:[--theme-color:var(--color-ui-red)] data-incomplete:[--theme-color:var(--color-ui-grey)] data-loading:[--theme-color:var(--color-ui-yellow)] data-readonly:[--theme-color:var(--color-ui-grey)] data-ready:[--theme-color:var(--color-ui-blue)] data-success:[--theme-color:var(--color-ui-green)]', customTheme?.themeColor),
|
|
3663
|
+
}, theme: 'custom', type: type, children: buttonText }));
|
|
3664
|
+
}
|
|
3665
|
+
|
|
3666
|
+
function Textarea({ className, defaultValue, description, descriptionProps, disabled, fieldProps, invalid = true, label, labelProps, name, onBlur, onChange, placeholder, ref, required = true, value, ...props }) {
|
|
3667
|
+
const [formContext, setFormContext] = useFormContext(), [errorMessage, setErrorMessage] = useState(undefined);
|
|
3668
|
+
if (placeholder === '*')
|
|
3669
|
+
placeholder = name + (required && !label ? '*' : '');
|
|
3670
|
+
if (label === '*')
|
|
3671
|
+
label = name;
|
|
3672
|
+
const uniqueID = useId(), fieldContextID = toLowerCase(name, [, '_']) + '§' + uniqueID;
|
|
3673
|
+
if (Boolean(formContext?.find(field => field.id === fieldContextID)?.invalid))
|
|
3674
|
+
invalid = true;
|
|
3675
|
+
const initialFieldContext = defineField({
|
|
3676
|
+
type: 'textarea',
|
|
3677
|
+
id: fieldContextID,
|
|
3678
|
+
invalid,
|
|
3679
|
+
name,
|
|
3680
|
+
required,
|
|
3681
|
+
value: value ? `${value}` : defaultValue ? `${defaultValue}` : '',
|
|
3682
|
+
});
|
|
3683
|
+
useEffect(() => {
|
|
3684
|
+
if (!setFormContext)
|
|
3685
|
+
return;
|
|
3686
|
+
setFormContext(prevContext => {
|
|
3687
|
+
const otherFields = (prevContext || []).filter(field => field.id !== initialFieldContext.id);
|
|
3688
|
+
return [...otherFields, initialFieldContext];
|
|
3689
|
+
});
|
|
3690
|
+
return () => {
|
|
3691
|
+
setFormContext(prevContext => (prevContext || []).filter(field => field.id !== initialFieldContext.id));
|
|
3692
|
+
};
|
|
3693
|
+
}, [setFormContext]);
|
|
3694
|
+
const fieldContext = formContext?.find(({ id: fieldID }) => fieldID === initialFieldContext.id) || initialFieldContext;
|
|
3695
|
+
const validateField = (validValue) => {
|
|
3696
|
+
const noValue = !validValue || validValue === '';
|
|
3697
|
+
if (!required && noValue)
|
|
3698
|
+
return true;
|
|
3699
|
+
const errorMessageList = [];
|
|
3700
|
+
if (noValue) {
|
|
3701
|
+
errorMessageList.push('This field is required.');
|
|
3702
|
+
setErrorMessage(errorMessageList.join(' '));
|
|
3703
|
+
return false;
|
|
3704
|
+
}
|
|
3705
|
+
if (errorMessageList.length === 0)
|
|
3706
|
+
return true;
|
|
3707
|
+
setErrorMessage(errorMessageList.join(' '));
|
|
3708
|
+
return false;
|
|
3709
|
+
};
|
|
3710
|
+
const handleChange = e => {
|
|
3711
|
+
if (disabled) {
|
|
3712
|
+
e.preventDefault();
|
|
3713
|
+
return;
|
|
3714
|
+
}
|
|
3715
|
+
const { currentTarget } = e, { value: newValue } = currentTarget;
|
|
3716
|
+
setFormContext?.(prevContext => {
|
|
3717
|
+
if (!prevContext)
|
|
3718
|
+
return [];
|
|
3719
|
+
const field = prevContext.find(({ id: fieldID }) => fieldID === initialFieldContext.id);
|
|
3720
|
+
if (!field)
|
|
3721
|
+
throw new Error(`Field with id "${initialFieldContext.id}" not found in form context.`);
|
|
3722
|
+
const otherFields = prevContext.filter(({ id: fieldID }) => fieldID !== initialFieldContext.id);
|
|
3723
|
+
const updatedField = { ...field, value: newValue };
|
|
3724
|
+
const invalidField = validateField(newValue) === false;
|
|
3725
|
+
if (invalidField !== field.invalid)
|
|
3726
|
+
updatedField.invalid = invalidField;
|
|
3727
|
+
return [...otherFields, updatedField];
|
|
3728
|
+
});
|
|
3729
|
+
onChange?.(e);
|
|
3730
|
+
};
|
|
3731
|
+
const restFieldProps = fieldProps
|
|
3732
|
+
? Object.fromEntries(Object.entries(fieldProps).filter(([key]) => key !== 'className'))
|
|
3733
|
+
: {};
|
|
3734
|
+
const restLabelProps = labelProps
|
|
3735
|
+
? Object.fromEntries(Object.entries(labelProps).filter(([key]) => key !== 'className'))
|
|
3736
|
+
: {};
|
|
3737
|
+
const restDescriptionProps = descriptionProps
|
|
3738
|
+
? Object.fromEntries(Object.entries(descriptionProps).filter(([key]) => key !== 'className'))
|
|
3739
|
+
: {};
|
|
3740
|
+
return (jsxs(Field, { ...restFieldProps, className: bag => twMerge('grid gap-1', typeof fieldProps?.className === 'function' ? fieldProps?.className(bag) : fieldProps?.className), disabled: disabled, children: [label && (jsx(Label, { ...restLabelProps, className: bag => twMerge('text-sm font-medium', required ? 'after:text-ui-red after:content-["_*"]' : '', typeof labelProps?.className === 'function' ? labelProps?.className(bag) : labelProps?.className), children: label })), jsxs("div", { className: 'z-10 -mb-1.5', children: [jsx(Textarea$1, { ...props, className: bag => twMerge(
|
|
3741
|
+
// Base styles
|
|
3742
|
+
'field-sizing-content w-full resize-none rounded-xl border-1 border-neutral-500/50 bg-neutral-100 py-1 pl-2 text-neutral-950 outline-offset-1 outline-ui-sky-blue/95 transition-[background-color] duration-300 ease-exponential dark:bg-neutral-700 dark:text-neutral-50',
|
|
3743
|
+
// Pseudo styles
|
|
3744
|
+
'focus-visible:bg-neutral-50 focus-visible:outline-3 active:bg-neutral-200 dark:focus-visible:bg-neutral-600 dark:active:bg-neutral-800 pointer-fine:hover:bg-neutral-50 pointer-fine:active:bg-neutral-200 dark:pointer-fine:hover:bg-neutral-600 dark:pointer-fine:active:bg-neutral-800',
|
|
3745
|
+
// user-invalid styles
|
|
3746
|
+
'user-invalid:border-ui-red user-invalid:bg-[color-mix(in_oklab,var(--color-ui-red)_20%,var(--color-neutral-100))] user-invalid:focus-visible:bg-[color-mix(in_oklab,var(--color-ui-red)_1%,var(--color-neutral-100))] user-invalid:active:bg-[color-mix(in_oklab,var(--color-ui-red)_25%,var(--color-neutral-100))] dark:user-invalid:bg-[color-mix(in_oklab,var(--color-ui-red)_20%,var(--color-neutral-800))] dark:user-invalid:focus-visible:bg-[color-mix(in_oklab,var(--color-ui-red)_1%,var(--color-neutral-800))] dark:user-invalid:active:bg-[color-mix(in_oklab,var(--color-ui-red)_25%,var(--color-neutral-800))] user-invalid:pointer-fine:hover:bg-[color-mix(in_oklab,var(--color-ui-red)_10%,var(--color-neutral-100))] user-invalid:pointer-fine:focus-visible:bg-[color-mix(in_oklab,var(--color-ui-red)_1%,var(--color-neutral-100))] user-invalid:pointer-fine:active:bg-[color-mix(in_oklab,var(--color-ui-red)_25%,var(--color-neutral-100))] dark:user-invalid:pointer-fine:hover:bg-[color-mix(in_oklab,var(--color-ui-red)_10%,var(--color-neutral-800))] dark:user-invalid:pointer-fine:focus-visible:bg-[color-mix(in_oklab,var(--color-ui-red)_1%,var(--color-neutral-800))] dark:user-invalid:pointer-fine:active:bg-[color-mix(in_oklab,var(--color-ui-red)_25%,var(--color-neutral-800))]',
|
|
3747
|
+
// Custom styles
|
|
3748
|
+
typeof className === 'function' ? className(bag) : className), id: fieldContext?.id, invalid: invalid, onChange: handleChange, placeholder: placeholder, ref: ref, required: required, value: fieldContext?.value }), fieldContext.invalid && errorMessage && (jsxs(Tooltip, { anchor: 'top-end', arrow: true, portal: true, children: [jsx(TooltipTrigger, { as: Button, className: 'absolute top-1.25 right-1.25 z-10 size-6 min-w-0', padding: 'none', rounded: 'md', theme: 'red', children: jsx(ExclamationmarkOctagon, { className: 'absolute top-1/2 left-1/2 size-full -translate-x-1/2 -translate-y-1/2 scale-70' }) }), jsx(TooltipPanel, { children: errorMessage })] }))] }), description && (jsx(Description, { ...restDescriptionProps, className: bag => twMerge('text-xs', typeof descriptionProps?.className === 'function'
|
|
3749
|
+
? descriptionProps?.className(bag)
|
|
3750
|
+
: descriptionProps?.className), children: description }))] }));
|
|
3751
|
+
}
|
|
3752
|
+
|
|
3753
|
+
// import { findComponentByType } from '../../utils'
|
|
3754
|
+
function FormComponent({ as, children, className, handleSubmit, onError, onSubmit, onSuccess, ...props }) {
|
|
3755
|
+
const [formContext] = useFormContext(), [formStatus, setFormStatus] = useFormStatus();
|
|
3756
|
+
// const submitButton = findComponentByType(children, SubmitButton)
|
|
3757
|
+
useEffect(() => {
|
|
3758
|
+
if (!formContext)
|
|
3759
|
+
return;
|
|
3760
|
+
if (formStatus !== 'incomplete' && formContext.find(({ invalid }) => invalid))
|
|
3761
|
+
setFormStatus?.('incomplete');
|
|
3762
|
+
if (formStatus !== 'ready' && formContext.every(({ invalid }) => !invalid))
|
|
3763
|
+
setFormStatus?.('ready');
|
|
3764
|
+
}, [formContext]);
|
|
3765
|
+
const processSubmit = handleSubmit ||
|
|
3766
|
+
(async (e) => {
|
|
3767
|
+
e.preventDefault();
|
|
3768
|
+
e.stopPropagation();
|
|
3769
|
+
setFormStatus?.('loading');
|
|
3770
|
+
const response = await onSubmit?.({ event: e, formContext });
|
|
3771
|
+
if (response && ('error' in response || response.status === 'error')) {
|
|
3772
|
+
setFormStatus?.('error');
|
|
3773
|
+
onError?.({ event: e, error: response.error || 'An error occurred when submitting the form.', formContext });
|
|
3774
|
+
return;
|
|
3775
|
+
}
|
|
3776
|
+
if ((response && response.status === 'success') || !response) {
|
|
3777
|
+
setFormStatus?.('success');
|
|
3778
|
+
onSuccess?.({ event: e, formContext });
|
|
3779
|
+
}
|
|
3780
|
+
});
|
|
3781
|
+
const FormElement = as || 'form';
|
|
3782
|
+
return (jsx(FormElement, { ...props, className: twMerge(className, 'grid gap-3'), onSubmit: processSubmit, children: children }));
|
|
3783
|
+
}
|
|
3784
|
+
function Form({ controlled = 'auto', initialStatus = 'incomplete', ...props }) {
|
|
3785
|
+
const FormContextOrNotProvider = controlled === 'auto' ? FormContextProvider : Fragment;
|
|
3786
|
+
return (jsx(FormStatusProvider, { initialStatus: initialStatus, children: jsx(FormContextOrNotProvider, { children: jsx(FormComponent, { ...props }) }) }));
|
|
3787
|
+
}
|
|
3788
|
+
|
|
3789
|
+
function Ghost({ children, className, ...props }) {
|
|
3790
|
+
return (jsx("div", { ...props, className: twMerge('block w-24 max-w-full animate-pulse rounded bg-white/50', className), children: children || jsx(Fragment$1, { children: "\u00A0" }) }));
|
|
3791
|
+
}
|
|
3792
|
+
|
|
3793
|
+
function getTextFromChildren(children) {
|
|
3794
|
+
let text = '';
|
|
3795
|
+
Children.forEach(children, child => {
|
|
3796
|
+
if (typeof child === 'string' || typeof child === 'number') {
|
|
3797
|
+
text += child;
|
|
3798
|
+
}
|
|
3799
|
+
else if (isValidElement(child)) {
|
|
3800
|
+
text += getTextFromChildren(child.props.children);
|
|
3801
|
+
}
|
|
3802
|
+
});
|
|
3803
|
+
return text;
|
|
3804
|
+
}
|
|
3805
|
+
/**
|
|
3806
|
+
* # Heading
|
|
3807
|
+
* A heading component that renders HTML heading elements (h1-h6) with appropriate styling.
|
|
3808
|
+
* Automatically generates an ID for the heading based on its content if none is provided.
|
|
3809
|
+
*/
|
|
3810
|
+
function Heading({ as = 'h2', children, customize, className, id, ref, ...props }) {
|
|
3811
|
+
const H = as;
|
|
3812
|
+
const targetableID = id || getTextFromChildren(children).replace(/\s+/g, '-').toLowerCase();
|
|
3813
|
+
const getBaseClasses = () => {
|
|
3814
|
+
switch (as) {
|
|
3815
|
+
case 'h1':
|
|
3816
|
+
return twMerge('pb-2.5 text-6xl font-black last:pb-0', customize?.h1);
|
|
3817
|
+
case 'h3':
|
|
3818
|
+
return twMerge('pb-2 text-4xl font-extralight last:pb-0', customize?.h3);
|
|
3819
|
+
case 'h4':
|
|
3820
|
+
return twMerge('pb-2 text-3xl font-extrabold last:pb-0', customize?.h4);
|
|
3821
|
+
case 'h5':
|
|
3822
|
+
return twMerge('pb-1.5 text-2xl font-semibold last:pb-0', customize?.h5);
|
|
3823
|
+
case 'h6':
|
|
3824
|
+
return twMerge('pb-1 text-xl font-bold last:pb-0', customize?.h6);
|
|
3825
|
+
default:
|
|
3826
|
+
return twMerge('pb-2.5 text-5xl font-medium last:pb-0', customize?.h2);
|
|
3827
|
+
}
|
|
3828
|
+
};
|
|
3829
|
+
const baseClasses = getBaseClasses();
|
|
3830
|
+
return (jsx(H, { ref: ref, id: targetableID, ...props, className: twMerge(baseClasses, className), children: children }));
|
|
3831
|
+
}
|
|
3832
|
+
|
|
3833
|
+
function ModalTrigger({ as, ...props }) {
|
|
3834
|
+
const Element = as || Button$1;
|
|
3835
|
+
return jsx(Element, { ...props });
|
|
3836
|
+
}
|
|
3837
|
+
function ModalDialog(props) {
|
|
3838
|
+
return jsx("div", { ...props });
|
|
3839
|
+
}
|
|
3840
|
+
function Modal({ children, className, onClose, onOpen, place = 'bottom' }) {
|
|
3841
|
+
const [bodyElement, setBodyElement] = useState(null);
|
|
3842
|
+
useEffect(() => {
|
|
3843
|
+
if (!bodyElement && typeof window !== 'undefined')
|
|
3844
|
+
setBodyElement(document.body);
|
|
3845
|
+
}, [bodyElement]);
|
|
3846
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
3847
|
+
const dialogPanelRef = useRef(null), dragMoveBoxRef = useRef(null),
|
|
3848
|
+
// lastTouchYRef = useRef(0),
|
|
3849
|
+
startDragCoords = useRef({ x: 0, y: 0 });
|
|
3850
|
+
const [allowDragClose, setAllowDragClose] = useState(false), [readyToClose, setReadyToClose] = useState(false);
|
|
3851
|
+
const openModal = () => {
|
|
3852
|
+
if (isOpen)
|
|
3853
|
+
return;
|
|
3854
|
+
setIsOpen(true);
|
|
3855
|
+
onOpen?.();
|
|
3856
|
+
};
|
|
3857
|
+
const closeModal = () => {
|
|
3858
|
+
if (!isOpen)
|
|
3859
|
+
return;
|
|
1591
3860
|
setIsOpen(false);
|
|
1592
3861
|
onClose?.();
|
|
1593
3862
|
};
|
|
@@ -1662,23 +3931,23 @@ function Modal({ children, className, onClose, onOpen, place = 'bottom' }) {
|
|
|
1662
3931
|
}
|
|
1663
3932
|
return (jsxs(Fragment$1, { children: [allowDragClose &&
|
|
1664
3933
|
bodyElement &&
|
|
1665
|
-
createPortal(jsx("div", { ref: dragMoveBoxRef, className: '
|
|
3934
|
+
createPortal(jsx("div", { ref: dragMoveBoxRef, className: 'fixed inset-0 z-99 h-dvh w-screen bg-transparent active:cursor-grabbing pointer-coarse:hidden', onMouseMove: handleMouseMove, onMouseUp: disableMouseDragClose }), bodyElement), triggerElement &&
|
|
1666
3935
|
cloneElement(triggerElement, { onClick: openModal }), jsxs(Dialog, { open: isOpen, onClose: closeModal, className: [
|
|
1667
3936
|
'isolate z-50',
|
|
1668
3937
|
place === 'bottom' &&
|
|
1669
3938
|
'after:fixed after:inset-x-0 after:bottom-0 after:-z-10 after:h-16 after:bg-neutral-50 sm:after:hidden',
|
|
1670
3939
|
].join(' '), children: [jsx(DialogBackdrop, { transition: true, className: [
|
|
1671
|
-
'
|
|
3940
|
+
'fixed inset-0 cursor-pointer transition-[opacity_background-color_backdrop-filter_-webkit-backdrop-filter] delay-100 duration-750 ease-exponential data-closed:opacity-0',
|
|
1672
3941
|
readyToClose
|
|
1673
3942
|
? 'bg-neutral-50/5 backdrop-blur-[1px] dark:bg-neutral-950/5'
|
|
1674
3943
|
: 'bg-neutral-50/25 backdrop-blur-sm dark:bg-neutral-950/25',
|
|
1675
|
-
].join(' '), children: jsx(Button, { theme: 'blue', padding: 'none', rounded: 'full', className: 'group/button
|
|
1676
|
-
? 'data-enter:translate-y-[calc(-50%+12rem)] data-leave:translate-y-[calc(-50%-8rem)]
|
|
1677
|
-
: 'rounded-t-4xl
|
|
1678
|
-
'
|
|
3944
|
+
].join(' '), children: jsx(Button, { theme: 'blue', padding: 'none', rounded: 'full', className: 'group/button fixed top-4 right-4 h-7 w-7 overflow-x-hidden transition-[scale_width_filter] pointer-fine:hover:w-20', children: jsxs("div", { className: 'absolute top-1 right-1 flex items-center gap-1 pt-px transition-transform duration-300 ease-exponential pointer-fine:group-hover/button:-translate-x-0.5', children: [jsxs("span", { className: 'block text-xs leading-none font-medium text-neutral-50 uppercase', children: ["Close", jsx("span", { className: 'sr-only', children: " Modal" })] }), jsx(xmark, { className: '-top-px block size-5 scale-75 rotate-90 fill-white stroke-white stroke-1 transition-transform duration-300 ease-in-out group-hover/button:rotate-0' })] }) }) }), jsxs(DialogPanel, { ref: dialogPanelRef, transition: true, className: twMerge('fixed left-1/2 -translate-x-1/2 overflow-y-scroll bg-neutral-50 p-4 shadow-[0_-15px_50px_-12px] shadow-neutral-950/25 transition-[transform_translate_opacity] duration-750 ease-exponential data-closed:scale-50 data-closed:opacity-0 sm:w-[calc(100vw-2rem)] sm:max-w-fit sm:p-6 sm:shadow-2xl lg:p-8 dark:bg-neutral-900', place === 'center'
|
|
3945
|
+
? 'top-1/2 -translate-y-1/2 rounded-2xl data-enter:translate-y-[calc(-50%+12rem)] data-leave:translate-y-[calc(-50%-8rem)]'
|
|
3946
|
+
: 'bottom-0 h-fit max-h-[calc(100dvh-4rem)] translate-y-0 rounded-t-4xl data-enter:translate-y-full data-leave:translate-y-full sm:top-1/2 sm:bottom-auto sm:rounded-t-2xl sm:rounded-b-2xl sm:data-enter:translate-y-[calc(-50%+12rem)] sm:data-leave:translate-y-[calc(-50%-8rem)] sm:data-open:-translate-y-1/2 pointer-fine:top-1/2 pointer-fine:bottom-auto pointer-fine:-translate-y-1/2 pointer-fine:rounded-2xl', className), children: [jsx("button", { onTouchStart: enableTouchClose, onMouseDown: enableMouseClose, className: [
|
|
3947
|
+
'absolute inset-x-0 top-0 z-10 flex h-6 cursor-grab items-center justify-center after:h-1 after:w-8 after:rounded-full after:transition-[transform_background-color] after:duration-500 after:ease-exponential active:cursor-grabbing',
|
|
1679
3948
|
readyToClose
|
|
1680
3949
|
? 'after:scale-x-200 after:scale-y-200 after:bg-ui-blue'
|
|
1681
|
-
: 'after:bg-ui-grey/50 active:after:bg-ui-grey pointer-fine:hover:after:scale-x-125 pointer-fine:hover:after:bg-neutral-500/75 pointer-fine:active:after:scale-x-150 pointer-fine:active:after:bg-ui-grey
|
|
3950
|
+
: 'after:bg-ui-grey/50 active:after:scale-x-150 active:after:scale-y-125 active:after:bg-ui-grey pointer-fine:hover:after:scale-x-125 pointer-fine:hover:after:bg-neutral-500/75 pointer-fine:active:after:scale-x-150 pointer-fine:active:after:bg-ui-grey',
|
|
1682
3951
|
].join(' '), children: jsx("span", { className: 'sr-only', children: "Drag down to close" }) }), dialogElement] })] })] }));
|
|
1683
3952
|
}
|
|
1684
3953
|
|
|
@@ -1733,5 +4002,5 @@ function Time({ children, dateObject, dateTime, day, hours, milliseconds, minute
|
|
|
1733
4002
|
return (jsx("time", { dateTime: dateAndTime, ref: ref, ...props, children: dateDisplay }));
|
|
1734
4003
|
}
|
|
1735
4004
|
|
|
1736
|
-
export { Airplane, Anchor, ArrowTriangle2CirclepathCircle, ArrowTriangle2CirclepathCircleFill, BagFill, Banknote, BellFill, BoltCar, BoltFill, BoltRingClosed, BoltTrianglebadgeExclamationmark, BookFill, BookmarkFill, BriefcaseFill, BubbleLeftFill, Building2Fill, Button, Calendar, CameraFill, CarFill, CartFill, ChartBarDocHorizontal, Checkmark, CheckmarkSeal, ChevronCompactDown, ChevronDown, ChevronLeft, ChevronLeftForwardslashChevronRight, ChevronRight, ChevronUpChevronDown, CircleFill, ClockBadgeCheckmark, ClockFill, CloudFill, CubeFill, CurvePointLeft, DialHigh, DocFill, DocOnClipboard, DocOnDoc, DocOnDocFill, DocOnMagnifyingglass as DocTextMagnifyingglass, DollarSign, EllipsisCircle, EllipsisCircleFill, Envelope, EnvelopeFill, ExclamationmarkOctagon, Eye, FigureWaterFitness, FlagFill, FlameFill, Folder, FolderFill, Form, FormContextProvider, FormStatusProvider, Gearshape, GearshapeFill, Ghost, GiftFill, GlobeAmericasFill, HareFill, Heading, House, HouseDeskclock, HouseFill, IPhoneHouse, Input, LightRibbon, LightbulbFill, LightbulbLed, Link, ListBulletClipboardFill, Magnifyingglass, MapPinEllipse, MinusPlusBatteryblock, Modal, ModalDialog, ModalTrigger, Network, NetworkShield, NewspaperFill, Number$1 as Number, PaperplaneFill, Person, PersonCropSquare, PersonFill, PersonFillQuestionmark, Phone, PhoneArrowUpRight, PhoneFill, PlayRectangleFill, Plus, Qrcode, RectanglePortraitAndArrowLeft, RectanglePortraitAndArrowLeftFill, Sensor, Signature, SolarPanel, SquareAndArrowDown, SquareAndArrowDownFill, SquareAndArrowUp, SquareAndArrowUpFill, SquareAndPencil, SquareAndPencilFill, SubmitButton, TextBubble, Textarea, ThreePeople, ThreeRectanglesDesktop, ThreeRectanglesDesktopFill, Time, Trash, TrashFill, Tree, UmbrellaFill, xmark as Xmark, defineField, useFormContext, useFormStatus };
|
|
4005
|
+
export { Airplane, Anchor, ArrowTriangle2CirclepathCircle, ArrowTriangle2CirclepathCircleFill, BagFill, Banknote, BellFill, BoltCar, BoltFill, BoltRingClosed, BoltTrianglebadgeExclamationmark, BookFill, BookmarkFill, BriefcaseFill, BubbleLeftFill, Building2Fill, Button, Calendar, CameraFill, CarFill, CartFill, ChartBarDocHorizontal, Checkmark, CheckmarkSeal, ChevronCompactDown, ChevronDown, ChevronLeft, ChevronLeftForwardslashChevronRight, ChevronRight, ChevronUpChevronDown, CircleFill, ClockBadgeCheckmark, ClockFill, CloudFill, CubeFill, CurvePointLeft, Details, DetailsBody, DetailsSummary, DialHigh, DocFill, DocOnClipboard, DocOnDoc, DocOnDocFill, DocOnMagnifyingglass as DocTextMagnifyingglass, DollarSign, DropDown, DropDownButton, DropDownItem, DropDownItems, DropDownSection, DropDownSeparator, EllipsisCircle, EllipsisCircleFill, Envelope, EnvelopeFill, ExclamationmarkOctagon, Eye, Fieldset, FigureWaterFitness, FlagFill, FlameFill, Folder, FolderFill, Form, FormContextProvider, FormStatusProvider, Gearshape, GearshapeFill, Ghost, GiftFill, GlobeAmericasFill, HareFill, Heading, House, HouseDeskclock, HouseFill, IPhoneHouse, Input, LightRibbon, LightbulbFill, LightbulbLed, Link, ListBulletClipboardFill, Magnifyingglass, MapPinEllipse, MinusPlusBatteryblock, Modal, ModalDialog, ModalTrigger, Network, NetworkShield, NewspaperFill, Number$1 as Number, PaperplaneFill, Person, PersonCropSquare, PersonFill, PersonFillQuestionmark, Phone, PhoneArrowUpRight, PhoneFill, PlayRectangleFill, Plus, Qrcode, RectanglePortraitAndArrowLeft, RectanglePortraitAndArrowLeftFill, Sensor, Signature, SolarPanel, SquareAndArrowDown, SquareAndArrowDownFill, SquareAndArrowUp, SquareAndArrowUpFill, SquareAndPencil, SquareAndPencilFill, SubmitButton, TextBubble, Textarea, ThreePeople, ThreeRectanglesDesktop, ThreeRectanglesDesktopFill, Time, Tooltip, TooltipPanel, TooltipTrigger, Trash, TrashFill, Tree, UmbrellaFill, xmark as Xmark, createFastContext, defineField, useFormContext, useFormStatus };
|
|
1737
4006
|
//# sourceMappingURL=index.esm.js.map
|