mado-ui 0.5.4 → 0.5.7
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 +283 -8
- package/dist/components/drop-down.d.ts +12 -12
- package/dist/components/drop-down.d.ts.map +1 -1
- package/dist/components/form/human-verification.d.ts +15 -0
- package/dist/components/form/human-verification.d.ts.map +1 -0
- package/dist/components/form/input/date/views/calendar-view.d.ts +2 -0
- package/dist/components/form/input/date/views/calendar-view.d.ts.map +1 -0
- package/dist/components/form/input/date/views/clock-view.d.ts +2 -0
- package/dist/components/form/input/date/views/clock-view.d.ts.map +1 -0
- package/dist/components/form/input/date/views/dropdown-view.d.ts +2 -0
- package/dist/components/form/input/date/views/dropdown-view.d.ts.map +1 -0
- package/dist/components/form/input/date/views/rotary-view.d.ts +2 -0
- package/dist/components/form/input/date/views/rotary-view.d.ts.map +1 -0
- package/dist/components/form/input/date/views/view-handler.d.ts +21 -0
- package/dist/components/form/input/date/views/view-handler.d.ts.map +1 -0
- package/dist/components/form/input/index.d.ts +24 -24
- package/dist/components/form/input/index.d.ts.map +1 -1
- package/dist/components/form/input/input-types.d.ts +102 -0
- package/dist/components/form/input/input-types.d.ts.map +1 -0
- package/dist/components/form/input/number-input.d.ts +4 -0
- package/dist/components/form/input/number-input.d.ts.map +1 -0
- package/dist/components/form/input/text-input.d.ts +36 -0
- package/dist/components/form/input/text-input.d.ts.map +1 -0
- package/dist/components/form/select.d.ts +41 -0
- package/dist/components/form/select.d.ts.map +1 -0
- package/dist/components/link.d.ts +14 -13
- package/dist/components/link.d.ts.map +1 -1
- package/dist/components/tooltip.d.ts +7 -7
- package/dist/components/tooltip.d.ts.map +1 -1
- package/dist/components/video.d.ts +6 -6
- package/dist/components/video.d.ts.map +1 -1
- package/dist/components.d.ts +50 -49
- package/dist/components.esm.js +600 -459
- package/dist/components.esm.js.map +1 -1
- package/dist/components.js +598 -456
- package/dist/components.js.map +1 -1
- package/dist/graphics/index.d.ts +2 -0
- package/dist/graphics/index.d.ts.map +1 -0
- package/dist/graphics/social-media/facebook-logo.d.ts +33 -0
- package/dist/graphics/social-media/facebook-logo.d.ts.map +1 -0
- package/dist/graphics/social-media/google-logo.d.ts +13 -0
- package/dist/graphics/social-media/google-logo.d.ts.map +1 -0
- package/dist/graphics/social-media/index.d.ts +8 -0
- package/dist/graphics/social-media/index.d.ts.map +1 -0
- package/dist/graphics/social-media/instagram-logo.d.ts +13 -0
- package/dist/graphics/social-media/instagram-logo.d.ts.map +1 -0
- package/dist/graphics/social-media/linkedin-logo.d.ts +26 -0
- package/dist/graphics/social-media/linkedin-logo.d.ts.map +1 -0
- package/dist/graphics/social-media/tiktok-logo.d.ts +26 -0
- package/dist/graphics/social-media/tiktok-logo.d.ts.map +1 -0
- package/dist/graphics/social-media/x-logo.d.ts +6 -0
- package/dist/graphics/social-media/x-logo.d.ts.map +1 -0
- package/dist/graphics/social-media/youtube-logo.d.ts +26 -0
- package/dist/graphics/social-media/youtube-logo.d.ts.map +1 -0
- package/dist/graphics.d.ts +141 -0
- package/dist/graphics.d.ts.map +1 -0
- package/dist/graphics.esm.js +241 -0
- package/dist/graphics.esm.js.map +1 -0
- package/dist/graphics.js +249 -0
- package/dist/graphics.js.map +1 -0
- package/dist/icons/index.d.ts +142 -143
- package/dist/icons/index.d.ts.map +1 -1
- package/dist/icons/square-and-arrow-up-right.d.ts +3 -0
- package/dist/icons/square-and-arrow-up-right.d.ts.map +1 -0
- package/dist/icons/square-and-pencil.d.ts +2 -2
- package/dist/icons/square-and-pencil.d.ts.map +1 -1
- package/dist/icons.d.ts +2 -4
- package/dist/icons.esm.js +2 -6
- package/dist/icons.esm.js.map +1 -1
- package/dist/icons.js +1 -6
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +50 -49
- package/dist/index.esm.js +600 -459
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +598 -456
- package/dist/index.js.map +1 -1
- package/dist/utils/string-manipulation.d.ts +23 -1
- package/dist/utils/string-manipulation.d.ts.map +1 -1
- package/dist/utils.d.ts +24 -2
- package/dist/utils.esm.js +76 -18
- package/dist/utils.esm.js.map +1 -1
- package/dist/utils.js +78 -17
- package/dist/utils.js.map +1 -1
- package/package.json +24 -32
- package/dist/components/mado-ui-provider.d.ts +0 -1
- package/dist/hooks/use-anime-scope.d.ts +0 -15
- package/dist/icons/square-and-pencil-fill.d.ts +0 -3
- package/dist/icons/square-and-pencil-fill.d.ts.map +0 -1
- package/dist/types.esm.js +0 -2
- package/dist/types.esm.js.map +0 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
package/dist/components.esm.js
CHANGED
|
@@ -375,13 +375,14 @@ function isPhoneNumber(tel) {
|
|
|
375
375
|
* @returns {string} string formatted
|
|
376
376
|
*/
|
|
377
377
|
function formatPhoneNumber(phoneNumber, options) {
|
|
378
|
-
const format = options?.format ||
|
|
379
|
-
if (format !==
|
|
380
|
-
phoneNumber = phoneNumber.replace(/\D/g,
|
|
378
|
+
const format = options?.format || "standard";
|
|
379
|
+
if (format !== "none") {
|
|
380
|
+
phoneNumber = phoneNumber.replace(/\D/g, "").slice(-10);
|
|
381
|
+
}
|
|
381
382
|
switch (format) {
|
|
382
|
-
case
|
|
383
|
+
case "dot":
|
|
383
384
|
phoneNumber = phoneNumber
|
|
384
|
-
.split(
|
|
385
|
+
.split("")
|
|
385
386
|
.map((char, index) => {
|
|
386
387
|
if (index === 2)
|
|
387
388
|
return `${char}.`;
|
|
@@ -389,11 +390,11 @@ function formatPhoneNumber(phoneNumber, options) {
|
|
|
389
390
|
return `${char}.`;
|
|
390
391
|
return char;
|
|
391
392
|
})
|
|
392
|
-
.join(
|
|
393
|
+
.join("");
|
|
393
394
|
break;
|
|
394
|
-
case
|
|
395
|
+
case "hyphenated":
|
|
395
396
|
phoneNumber = phoneNumber
|
|
396
|
-
.split(
|
|
397
|
+
.split("")
|
|
397
398
|
.map((char, index) => {
|
|
398
399
|
if (index === 2)
|
|
399
400
|
return `${char}-`;
|
|
@@ -401,11 +402,11 @@ function formatPhoneNumber(phoneNumber, options) {
|
|
|
401
402
|
return `${char}-`;
|
|
402
403
|
return char;
|
|
403
404
|
})
|
|
404
|
-
.join(
|
|
405
|
+
.join("");
|
|
405
406
|
break;
|
|
406
|
-
case
|
|
407
|
+
case "space":
|
|
407
408
|
phoneNumber = phoneNumber
|
|
408
|
-
.split(
|
|
409
|
+
.split("")
|
|
409
410
|
.map((char, index) => {
|
|
410
411
|
if (index === 2)
|
|
411
412
|
return `${char} `;
|
|
@@ -413,11 +414,11 @@ function formatPhoneNumber(phoneNumber, options) {
|
|
|
413
414
|
return `${char} `;
|
|
414
415
|
return char;
|
|
415
416
|
})
|
|
416
|
-
.join(
|
|
417
|
+
.join("");
|
|
417
418
|
break;
|
|
418
|
-
case
|
|
419
|
+
case "standard":
|
|
419
420
|
phoneNumber = phoneNumber
|
|
420
|
-
.split(
|
|
421
|
+
.split("")
|
|
421
422
|
.map((char, index) => {
|
|
422
423
|
if (index === 0)
|
|
423
424
|
return `(${char}`;
|
|
@@ -427,9 +428,10 @@ function formatPhoneNumber(phoneNumber, options) {
|
|
|
427
428
|
return `${char}-`;
|
|
428
429
|
return char;
|
|
429
430
|
})
|
|
430
|
-
.join(
|
|
431
|
+
.join("");
|
|
431
432
|
}
|
|
432
|
-
return `${options?.countryCode ? `+${options?.countryCode} ` :
|
|
433
|
+
return `${options?.countryCode ? `+${options?.countryCode} ` : ""}` +
|
|
434
|
+
phoneNumber;
|
|
433
435
|
}
|
|
434
436
|
/**
|
|
435
437
|
* # To Lower Case
|
|
@@ -441,7 +443,7 @@ function formatPhoneNumber(phoneNumber, options) {
|
|
|
441
443
|
* @returns The lowercase version of the input string, with the replacements, if provided.
|
|
442
444
|
*/
|
|
443
445
|
function toLowerCase(str, [delimiter, joiner]) {
|
|
444
|
-
return str.toLowerCase().replaceAll(delimiter ||
|
|
446
|
+
return str.toLowerCase().replaceAll(delimiter || " ", joiner || " ");
|
|
445
447
|
}
|
|
446
448
|
|
|
447
449
|
function twSort(className) {
|
|
@@ -449,85 +451,93 @@ function twSort(className) {
|
|
|
449
451
|
}
|
|
450
452
|
|
|
451
453
|
function Anchor({ as, className, disabled, href, onClick, target, rel, ...props }) {
|
|
452
|
-
const isExternal = `${href}`.startsWith(
|
|
453
|
-
const handleClick = e => {
|
|
454
|
+
const isExternal = `${href}`.startsWith("http"), hasHash = `${href}`.includes("#");
|
|
455
|
+
const handleClick = (e) => {
|
|
454
456
|
if (disabled)
|
|
455
457
|
return e.preventDefault();
|
|
456
458
|
onClick?.(e);
|
|
457
459
|
setTimeout(() => history.replaceState({}, document.title, location.pathname), 100);
|
|
458
460
|
};
|
|
459
|
-
const AnchorElement = as ||
|
|
460
|
-
return (jsx(AnchorElement, { ...props, "aria-disabled": disabled, className: twMerge(className, disabled &&
|
|
461
|
-
? rel ===
|
|
462
|
-
? `${rel} noreferrer noopener`
|
|
463
|
-
: `${rel} prefetch`
|
|
461
|
+
const AnchorElement = as || "a";
|
|
462
|
+
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
|
|
463
|
+
? rel === "nofollow" ? `${rel} noreferrer noopener` : `${rel} prefetch`
|
|
464
464
|
: isExternal
|
|
465
|
-
?
|
|
466
|
-
:
|
|
465
|
+
? "nofollow noreferrer noopener"
|
|
466
|
+
: "prefetch" }));
|
|
467
467
|
}
|
|
468
468
|
// * Styles
|
|
469
|
-
const baseClasses = twSort(
|
|
470
|
-
const lineStaticClasses = twJoin(baseClasses,
|
|
471
|
-
const lineClasses = twJoin(lineStaticClasses,
|
|
472
|
-
const scaleXClasses =
|
|
473
|
-
const scaleYClasses =
|
|
469
|
+
const baseClasses = twSort("isolate inline-block cursor-pointer duration-300 ease-exponential after:absolute after:left-1/2 after:-z-10 after:-translate-x-1/2 after:duration-500 active:scale-95 active:after:opacity-100");
|
|
470
|
+
const lineStaticClasses = twJoin(baseClasses, "whitespace-nowrap after:-bottom-0.5 after:w-[calc(100%+0.15rem)] after:rounded-full after:border-1 after:border-current");
|
|
471
|
+
const lineClasses = twJoin(lineStaticClasses, "whitespace-nowrap transition-transform after:transition-transform after:ease-exponential");
|
|
472
|
+
const scaleXClasses = "after:scale-x-0 pointer-fine:hover:after:scale-x-100 active:after:scale-x-100";
|
|
473
|
+
const scaleYClasses = "after:scale-y-0 pointer-fine:hover:after:scale-y-100 active:after:scale-y-100";
|
|
474
474
|
const lineNormalClasses = twJoin([
|
|
475
475
|
lineClasses,
|
|
476
476
|
scaleYClasses,
|
|
477
|
-
|
|
477
|
+
"after:origin-bottom after:translate-y-0.5 active:after:translate-y-0 pointer-fine:hover:after:translate-y-0",
|
|
478
|
+
]);
|
|
479
|
+
const lineLtrClasses = twJoin([
|
|
480
|
+
lineClasses,
|
|
481
|
+
scaleXClasses,
|
|
482
|
+
"after:origin-left",
|
|
483
|
+
]);
|
|
484
|
+
const lineRtlClasses = twJoin([
|
|
485
|
+
lineClasses,
|
|
486
|
+
scaleXClasses,
|
|
487
|
+
"after:origin-right",
|
|
478
488
|
]);
|
|
479
|
-
const lineLtrClasses = twJoin([lineClasses, scaleXClasses, 'after:origin-left']);
|
|
480
|
-
const lineRtlClasses = twJoin([lineClasses, scaleXClasses, 'after:origin-right']);
|
|
481
489
|
const lineCenterClasses = twJoin([lineClasses, scaleXClasses]);
|
|
482
490
|
const lineLiftClasses = twJoin([
|
|
483
491
|
lineClasses,
|
|
484
492
|
scaleYClasses,
|
|
485
|
-
|
|
493
|
+
"after:origin-bottom after:translate-y-1 after:scale-x-75 active:after:translate-y-0 active:after:scale-x-100 pointer-fine:hover:after:translate-y-0 pointer-fine:hover:after:scale-x-100",
|
|
486
494
|
]);
|
|
487
|
-
const fillClasses = twJoin(baseClasses,
|
|
495
|
+
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");
|
|
488
496
|
// Define theme-specific fill color transition classes
|
|
489
|
-
const getFillColorTransitionClasses = (theme =
|
|
490
|
-
let fillColorTransitionClasses = twJoin(fillClasses,
|
|
497
|
+
const getFillColorTransitionClasses = (theme = "blue", customTheme) => {
|
|
498
|
+
let fillColorTransitionClasses = twJoin(fillClasses, "transition-transform after:bg-(--theme-color)");
|
|
491
499
|
switch (theme) {
|
|
492
|
-
case
|
|
493
|
-
fillColorTransitionClasses = twJoin(fillColorTransitionClasses,
|
|
500
|
+
case "blue":
|
|
501
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, "after:[--theme-color:var(--color-ui-blue)]");
|
|
494
502
|
break;
|
|
495
|
-
case
|
|
496
|
-
fillColorTransitionClasses = twJoin(fillColorTransitionClasses,
|
|
503
|
+
case "brown":
|
|
504
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, "after:[--theme-color:var(--color-ui-brow)]");
|
|
497
505
|
break;
|
|
498
|
-
case
|
|
499
|
-
fillColorTransitionClasses = twJoin(fillColorTransitionClasses,
|
|
506
|
+
case "green":
|
|
507
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, "after:[--theme-color:var(--color-ui-green)]");
|
|
500
508
|
break;
|
|
501
|
-
case
|
|
502
|
-
fillColorTransitionClasses = twJoin(fillColorTransitionClasses,
|
|
509
|
+
case "grey":
|
|
510
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, "after:[--theme-color:var(--color-ui-grey)]");
|
|
503
511
|
break;
|
|
504
|
-
case
|
|
505
|
-
fillColorTransitionClasses = twJoin(fillColorTransitionClasses,
|
|
512
|
+
case "sky-blue":
|
|
513
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, "after:[--theme-color:var(--color-ui-sky-blue)]");
|
|
506
514
|
break;
|
|
507
|
-
case
|
|
508
|
-
fillColorTransitionClasses = twJoin(fillColorTransitionClasses,
|
|
515
|
+
case "magenta":
|
|
516
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, "after:[--theme-color:var(--color-ui-magenta)]");
|
|
509
517
|
break;
|
|
510
|
-
case
|
|
511
|
-
fillColorTransitionClasses = twJoin(fillColorTransitionClasses,
|
|
518
|
+
case "orange":
|
|
519
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, "after:[--theme-color:var(--color-ui-orange)]");
|
|
512
520
|
break;
|
|
513
|
-
case
|
|
514
|
-
fillColorTransitionClasses = twJoin(fillColorTransitionClasses,
|
|
521
|
+
case "pink":
|
|
522
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, "after:[--theme-color:var(--color-ui-pink)]");
|
|
515
523
|
break;
|
|
516
|
-
case
|
|
517
|
-
fillColorTransitionClasses = twJoin(fillColorTransitionClasses,
|
|
524
|
+
case "purple":
|
|
525
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, "after:[--theme-color:var(--color-ui-purple)]");
|
|
518
526
|
break;
|
|
519
|
-
case
|
|
520
|
-
fillColorTransitionClasses = twJoin(fillColorTransitionClasses,
|
|
527
|
+
case "red":
|
|
528
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, "after:[--theme-color:var(--color-ui-red)]");
|
|
521
529
|
break;
|
|
522
|
-
case
|
|
523
|
-
fillColorTransitionClasses = twJoin(fillColorTransitionClasses,
|
|
530
|
+
case "violet":
|
|
531
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, "after:[--theme-color:var(--color-ui-violet)]");
|
|
524
532
|
break;
|
|
525
|
-
case
|
|
526
|
-
fillColorTransitionClasses = twJoin(fillColorTransitionClasses,
|
|
533
|
+
case "yellow":
|
|
534
|
+
fillColorTransitionClasses = twJoin(fillColorTransitionClasses, "after:[--theme-color:var(--color-ui-yellow)]");
|
|
527
535
|
break;
|
|
528
|
-
case
|
|
529
|
-
if (customTheme && customTheme.themeColor &&
|
|
530
|
-
|
|
536
|
+
case "custom":
|
|
537
|
+
if (customTheme && customTheme.themeColor &&
|
|
538
|
+
!customTheme.themeColor.includes("after:[--theme-color:")) {
|
|
539
|
+
throw new Error("`customTheme.themeColor` must modify the `--theme-color` variable on the ::after pseudo element. Otherwise, please use `customTheme.classes`.");
|
|
540
|
+
}
|
|
531
541
|
fillColorTransitionClasses = customTheme.themeColor
|
|
532
542
|
? twMerge(fillColorTransitionClasses, customTheme.themeColor)
|
|
533
543
|
: twMerge(fillClasses, customTheme.classes);
|
|
@@ -536,48 +546,50 @@ const getFillColorTransitionClasses = (theme = 'blue', customTheme) => {
|
|
|
536
546
|
return fillColorTransitionClasses;
|
|
537
547
|
};
|
|
538
548
|
// Define theme-specific fill center classes
|
|
539
|
-
const getFillCenterClasses = (theme =
|
|
540
|
-
let fillCenterColorClasses = twJoin(fillClasses,
|
|
549
|
+
const getFillCenterClasses = (theme = "blue", customTheme) => {
|
|
550
|
+
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)");
|
|
541
551
|
switch (theme) {
|
|
542
|
-
case
|
|
543
|
-
fillCenterColorClasses = twJoin(fillCenterColorClasses,
|
|
552
|
+
case "blue":
|
|
553
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, "after:[--theme-color:var(--color-ui-blue)]");
|
|
544
554
|
break;
|
|
545
|
-
case
|
|
546
|
-
fillCenterColorClasses = twJoin(fillCenterColorClasses,
|
|
555
|
+
case "brown":
|
|
556
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, "after:[--theme-color:var(--color-ui-brown)]");
|
|
547
557
|
break;
|
|
548
|
-
case
|
|
549
|
-
fillCenterColorClasses = twJoin(fillCenterColorClasses,
|
|
558
|
+
case "green":
|
|
559
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, "after:[--theme-color:var(--color-ui-green)]");
|
|
550
560
|
break;
|
|
551
|
-
case
|
|
552
|
-
fillCenterColorClasses = twJoin(fillCenterColorClasses,
|
|
561
|
+
case "grey":
|
|
562
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, "after:[--theme-color:var(--color-ui-grey)]");
|
|
553
563
|
break;
|
|
554
|
-
case
|
|
555
|
-
fillCenterColorClasses = twJoin(fillCenterColorClasses,
|
|
564
|
+
case "sky-blue":
|
|
565
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, "after:[--theme-color:var(--color-ui-sky-blue)]");
|
|
556
566
|
break;
|
|
557
|
-
case
|
|
558
|
-
fillCenterColorClasses = twJoin(fillCenterColorClasses,
|
|
567
|
+
case "magenta":
|
|
568
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, "after:[--theme-color:var(--color-ui-magenta)]");
|
|
559
569
|
break;
|
|
560
|
-
case
|
|
561
|
-
fillCenterColorClasses = twJoin(fillCenterColorClasses,
|
|
570
|
+
case "orange":
|
|
571
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, "after:[--theme-color:var(--color-ui-orange)]");
|
|
562
572
|
break;
|
|
563
|
-
case
|
|
564
|
-
fillCenterColorClasses = twJoin(fillCenterColorClasses,
|
|
573
|
+
case "pink":
|
|
574
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, "after:[--theme-color:var(--color-ui-pink)]");
|
|
565
575
|
break;
|
|
566
|
-
case
|
|
567
|
-
fillCenterColorClasses = twJoin(fillCenterColorClasses,
|
|
576
|
+
case "purple":
|
|
577
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, "after:[--theme-color:var(--color-ui-purple)]");
|
|
568
578
|
break;
|
|
569
|
-
case
|
|
570
|
-
fillCenterColorClasses = twJoin(fillCenterColorClasses,
|
|
579
|
+
case "red":
|
|
580
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, "after:[--theme-color:var(--color-ui-red)]");
|
|
571
581
|
break;
|
|
572
|
-
case
|
|
573
|
-
fillCenterColorClasses = twJoin(fillCenterColorClasses,
|
|
582
|
+
case "violet":
|
|
583
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, "after:[--theme-color:var(--color-ui-violet)]");
|
|
574
584
|
break;
|
|
575
|
-
case
|
|
576
|
-
fillCenterColorClasses = twJoin(fillCenterColorClasses,
|
|
585
|
+
case "yellow":
|
|
586
|
+
fillCenterColorClasses = twJoin(fillCenterColorClasses, "after:[--theme-color:var(--color-ui-yellow)]");
|
|
577
587
|
break;
|
|
578
|
-
case
|
|
579
|
-
if (customTheme && customTheme.themeColor &&
|
|
580
|
-
|
|
588
|
+
case "custom":
|
|
589
|
+
if (customTheme && customTheme.themeColor &&
|
|
590
|
+
!customTheme.themeColor.includes("after:[--theme-color:")) {
|
|
591
|
+
throw new Error("`customTheme.themeColor` must modify the `--theme-color` variable on the ::after pseudo element. Otherwise, please use `customTheme.classes`.");
|
|
592
|
+
}
|
|
581
593
|
fillCenterColorClasses = customTheme.themeColor
|
|
582
594
|
? twMerge(fillCenterColorClasses, customTheme.themeColor)
|
|
583
595
|
: twMerge(fillClasses, customTheme.classes);
|
|
@@ -585,58 +597,66 @@ const getFillCenterClasses = (theme = 'blue', customTheme) => {
|
|
|
585
597
|
}
|
|
586
598
|
return fillCenterColorClasses;
|
|
587
599
|
};
|
|
588
|
-
const multilineBaseClasses = twSort(
|
|
589
|
-
const multilineLineStaticClasses =
|
|
590
|
-
const multilineNormalClasses = twSort(
|
|
591
|
-
const multilineClasses = twJoin(multilineBaseClasses,
|
|
592
|
-
const multilineLineClasses = twJoin(multilineClasses,
|
|
593
|
-
const multilineXClasses = twJoin(multilineLineClasses,
|
|
594
|
-
const multilineLineRtlClasses = twJoin([
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
const
|
|
599
|
-
|
|
600
|
+
const multilineBaseClasses = twSort("bg-linear-to-r from-current to-current bg-no-repeat active:scale-95");
|
|
601
|
+
const multilineLineStaticClasses = "underline";
|
|
602
|
+
const multilineNormalClasses = twSort("underline-offset-1 active:underline pointer-fine:hover:underline");
|
|
603
|
+
const multilineClasses = twJoin(multilineBaseClasses, "duration-500 ease-exponential");
|
|
604
|
+
const multilineLineClasses = twJoin(multilineClasses, "bg-[position:0%_100%] px-px pb-px transition-[background-size]");
|
|
605
|
+
const multilineXClasses = twJoin(multilineLineClasses, "bg-[size:0%_2px] focus-visible:bg-[size:100%_2px] active:bg-[size:100%_2px] pointer-fine:hover:bg-[size:100%_2px]");
|
|
606
|
+
const multilineLineRtlClasses = twJoin([
|
|
607
|
+
multilineXClasses,
|
|
608
|
+
"bg-[position:100%_100%]",
|
|
609
|
+
]);
|
|
610
|
+
const multilineLineCenterClasses = twJoin([
|
|
611
|
+
multilineXClasses,
|
|
612
|
+
"bg-[position:50%_100%]",
|
|
613
|
+
]);
|
|
614
|
+
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]");
|
|
615
|
+
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");
|
|
616
|
+
const getMultilineFillColorClasses = (theme = "blue", customTheme) => {
|
|
617
|
+
let multilineFillColorClasses = twJoin(multilineFillBaseClasses, "from-(--theme-color) to-(--theme-color) transition-[background-size,color]");
|
|
600
618
|
switch (theme) {
|
|
601
|
-
case
|
|
602
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
619
|
+
case "blue":
|
|
620
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-blue)]");
|
|
603
621
|
break;
|
|
604
|
-
case
|
|
605
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
622
|
+
case "brown":
|
|
623
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-brown)]");
|
|
606
624
|
break;
|
|
607
|
-
case
|
|
608
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
625
|
+
case "green":
|
|
626
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-green)]");
|
|
609
627
|
break;
|
|
610
|
-
case
|
|
611
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
628
|
+
case "grey":
|
|
629
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-grey)]");
|
|
612
630
|
break;
|
|
613
|
-
case
|
|
614
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
631
|
+
case "sky-blue":
|
|
632
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-sky-blue)]");
|
|
615
633
|
break;
|
|
616
|
-
case
|
|
617
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
634
|
+
case "magenta":
|
|
635
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-magenta)]");
|
|
618
636
|
break;
|
|
619
|
-
case
|
|
620
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
637
|
+
case "orange":
|
|
638
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-orange)]");
|
|
621
639
|
break;
|
|
622
|
-
case
|
|
623
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
640
|
+
case "pink":
|
|
641
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-pink)]");
|
|
624
642
|
break;
|
|
625
|
-
case
|
|
626
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
643
|
+
case "purple":
|
|
644
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-purple)]");
|
|
627
645
|
break;
|
|
628
|
-
case
|
|
629
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
646
|
+
case "red":
|
|
647
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-red)]");
|
|
630
648
|
break;
|
|
631
|
-
case
|
|
632
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
649
|
+
case "violet":
|
|
650
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-violet)]");
|
|
633
651
|
break;
|
|
634
|
-
case
|
|
635
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
652
|
+
case "yellow":
|
|
653
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-yellow)]");
|
|
636
654
|
break;
|
|
637
|
-
case
|
|
638
|
-
if (customTheme && customTheme.themeColor &&
|
|
639
|
-
|
|
655
|
+
case "custom":
|
|
656
|
+
if (customTheme && customTheme.themeColor &&
|
|
657
|
+
!customTheme.themeColor.includes("[--theme-color:")) {
|
|
658
|
+
throw new Error("`customTheme.themeColor` must modify the `--theme-color` variable. Otherwise, please use `customTheme.classes`.");
|
|
659
|
+
}
|
|
640
660
|
multilineFillColorClasses = customTheme.themeColor
|
|
641
661
|
? twMerge(multilineFillColorClasses, customTheme.themeColor)
|
|
642
662
|
: twMerge(multilineFillBaseClasses, customTheme.classes);
|
|
@@ -644,48 +664,50 @@ const getMultilineFillColorClasses = (theme = 'blue', customTheme) => {
|
|
|
644
664
|
}
|
|
645
665
|
return multilineFillColorClasses;
|
|
646
666
|
};
|
|
647
|
-
const getMultilineFillClasses = (theme =
|
|
648
|
-
let multilineFillColorClasses = twJoin(multilineFillBaseClasses,
|
|
667
|
+
const getMultilineFillClasses = (theme = "blue", customTheme) => {
|
|
668
|
+
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%]");
|
|
649
669
|
switch (theme) {
|
|
650
|
-
case
|
|
651
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
670
|
+
case "blue":
|
|
671
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-blue)]");
|
|
652
672
|
break;
|
|
653
|
-
case
|
|
654
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
673
|
+
case "brown":
|
|
674
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-brown)]");
|
|
655
675
|
break;
|
|
656
|
-
case
|
|
657
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
676
|
+
case "green":
|
|
677
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-green)]");
|
|
658
678
|
break;
|
|
659
|
-
case
|
|
660
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
679
|
+
case "grey":
|
|
680
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-grey)]");
|
|
661
681
|
break;
|
|
662
|
-
case
|
|
663
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
682
|
+
case "sky-blue":
|
|
683
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-sky-blue)]");
|
|
664
684
|
break;
|
|
665
|
-
case
|
|
666
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
685
|
+
case "magenta":
|
|
686
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-magenta)]");
|
|
667
687
|
break;
|
|
668
|
-
case
|
|
669
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
688
|
+
case "orange":
|
|
689
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-orange)]");
|
|
670
690
|
break;
|
|
671
|
-
case
|
|
672
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
691
|
+
case "pink":
|
|
692
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-pink)]");
|
|
673
693
|
break;
|
|
674
|
-
case
|
|
675
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
694
|
+
case "purple":
|
|
695
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-purple)]");
|
|
676
696
|
break;
|
|
677
|
-
case
|
|
678
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
697
|
+
case "red":
|
|
698
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-red)]");
|
|
679
699
|
break;
|
|
680
|
-
case
|
|
681
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
700
|
+
case "violet":
|
|
701
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-violet)]");
|
|
682
702
|
break;
|
|
683
|
-
case
|
|
684
|
-
multilineFillColorClasses = twJoin(multilineFillColorClasses,
|
|
703
|
+
case "yellow":
|
|
704
|
+
multilineFillColorClasses = twJoin(multilineFillColorClasses, "[--theme-color:var(--color-ui-yellow)]");
|
|
685
705
|
break;
|
|
686
|
-
case
|
|
687
|
-
if (customTheme && customTheme.themeColor &&
|
|
688
|
-
|
|
706
|
+
case "custom":
|
|
707
|
+
if (customTheme && customTheme.themeColor &&
|
|
708
|
+
!customTheme.themeColor.includes("[--theme-color:")) {
|
|
709
|
+
throw new Error("`customTheme.themeColor` must modify the `--theme-color` variable. Otherwise, please use `customTheme.classes`.");
|
|
710
|
+
}
|
|
689
711
|
multilineFillColorClasses = customTheme.themeColor
|
|
690
712
|
? twMerge(multilineFillColorClasses, customTheme.themeColor)
|
|
691
713
|
: twMerge(multilineFillBaseClasses, customTheme.classes);
|
|
@@ -693,18 +715,76 @@ const getMultilineFillClasses = (theme = 'blue', customTheme) => {
|
|
|
693
715
|
}
|
|
694
716
|
return multilineFillColorClasses;
|
|
695
717
|
};
|
|
696
|
-
const getMultilineFillLiftClasses = (theme =
|
|
697
|
-
return twJoin(getMultilineFillColorClasses(theme, customTheme),
|
|
718
|
+
const getMultilineFillLiftClasses = (theme = "blue", customTheme) => {
|
|
719
|
+
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%]");
|
|
698
720
|
};
|
|
699
|
-
const getMultilineFillXClasses = (theme =
|
|
700
|
-
return twJoin(getMultilineFillColorClasses(theme, customTheme),
|
|
721
|
+
const getMultilineFillXClasses = (theme = "blue", customTheme) => {
|
|
722
|
+
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%]");
|
|
701
723
|
};
|
|
702
|
-
const getMultilineFillRtlClasses = (theme =
|
|
703
|
-
return twJoin(getMultilineFillXClasses(theme, customTheme),
|
|
724
|
+
const getMultilineFillRtlClasses = (theme = "blue", customTheme) => {
|
|
725
|
+
return twJoin(getMultilineFillXClasses(theme, customTheme), "bg-[position:100%_auto]");
|
|
704
726
|
};
|
|
705
|
-
const getMultilineFillCenterClasses = (theme =
|
|
706
|
-
return twJoin(getMultilineFillXClasses(theme, customTheme),
|
|
727
|
+
const getMultilineFillCenterClasses = (theme = "blue", customTheme) => {
|
|
728
|
+
return twJoin(getMultilineFillXClasses(theme, customTheme), "bg-[position:50%_auto]");
|
|
707
729
|
};
|
|
730
|
+
function getLinkClasses({ customTheme, theme, type }) {
|
|
731
|
+
switch (type) {
|
|
732
|
+
case "static":
|
|
733
|
+
return lineStaticClasses;
|
|
734
|
+
case "ltr":
|
|
735
|
+
return lineLtrClasses;
|
|
736
|
+
case "rtl":
|
|
737
|
+
return lineRtlClasses;
|
|
738
|
+
case "center":
|
|
739
|
+
return lineCenterClasses;
|
|
740
|
+
case "lift":
|
|
741
|
+
return lineLiftClasses;
|
|
742
|
+
case "fill":
|
|
743
|
+
return getFillCenterClasses(theme, customTheme);
|
|
744
|
+
case "fill-ltr":
|
|
745
|
+
return twJoin([
|
|
746
|
+
getFillColorTransitionClasses(theme, customTheme),
|
|
747
|
+
scaleXClasses,
|
|
748
|
+
"after:origin-left",
|
|
749
|
+
]);
|
|
750
|
+
case "fill-rtl":
|
|
751
|
+
return twJoin([
|
|
752
|
+
getFillColorTransitionClasses(theme, customTheme),
|
|
753
|
+
scaleXClasses,
|
|
754
|
+
"after:origin-right",
|
|
755
|
+
]);
|
|
756
|
+
case "fill-lift":
|
|
757
|
+
return twJoin([
|
|
758
|
+
getFillColorTransitionClasses(theme, customTheme),
|
|
759
|
+
scaleYClasses,
|
|
760
|
+
"after:origin-bottom",
|
|
761
|
+
]);
|
|
762
|
+
case "multiline":
|
|
763
|
+
return multilineNormalClasses;
|
|
764
|
+
case "multiline-static":
|
|
765
|
+
return multilineLineStaticClasses;
|
|
766
|
+
case "multiline-ltr":
|
|
767
|
+
return multilineXClasses;
|
|
768
|
+
case "multiline-rtl":
|
|
769
|
+
return multilineLineRtlClasses;
|
|
770
|
+
case "multiline-center":
|
|
771
|
+
return multilineLineCenterClasses;
|
|
772
|
+
case "multiline-lift":
|
|
773
|
+
return multilineLineLiftClasses;
|
|
774
|
+
case "multiline-fill":
|
|
775
|
+
return getMultilineFillClasses(theme, customTheme);
|
|
776
|
+
case "multiline-fill-ltr":
|
|
777
|
+
return getMultilineFillXClasses(theme, customTheme);
|
|
778
|
+
case "multiline-fill-rtl":
|
|
779
|
+
return getMultilineFillRtlClasses(theme, customTheme);
|
|
780
|
+
case "multiline-fill-center":
|
|
781
|
+
return getMultilineFillCenterClasses(theme, customTheme);
|
|
782
|
+
case "multiline-fill-lift":
|
|
783
|
+
return getMultilineFillLiftClasses(theme, customTheme);
|
|
784
|
+
default:
|
|
785
|
+
return lineNormalClasses;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
708
788
|
/**
|
|
709
789
|
* # Link
|
|
710
790
|
*
|
|
@@ -734,54 +814,8 @@ const getMultilineFillCenterClasses = (theme = 'blue', customTheme) => {
|
|
|
734
814
|
* @example
|
|
735
815
|
* <Link href='/about' type='fill-ltr' theme='red' title='About Us'>Learn more about our company</Link>
|
|
736
816
|
*/
|
|
737
|
-
function Link({ as, className, customTheme, theme =
|
|
738
|
-
const
|
|
739
|
-
switch (type) {
|
|
740
|
-
case 'static':
|
|
741
|
-
return lineStaticClasses;
|
|
742
|
-
case 'ltr':
|
|
743
|
-
return lineLtrClasses;
|
|
744
|
-
case 'rtl':
|
|
745
|
-
return lineRtlClasses;
|
|
746
|
-
case 'center':
|
|
747
|
-
return lineCenterClasses;
|
|
748
|
-
case 'lift':
|
|
749
|
-
return lineLiftClasses;
|
|
750
|
-
case 'fill':
|
|
751
|
-
return getFillCenterClasses(theme, customTheme);
|
|
752
|
-
case 'fill-ltr':
|
|
753
|
-
return twJoin([getFillColorTransitionClasses(theme, customTheme), scaleXClasses, 'after:origin-left']);
|
|
754
|
-
case 'fill-rtl':
|
|
755
|
-
return twJoin([getFillColorTransitionClasses(theme, customTheme), scaleXClasses, 'after:origin-right']);
|
|
756
|
-
case 'fill-lift':
|
|
757
|
-
return twJoin([getFillColorTransitionClasses(theme, customTheme), scaleYClasses, 'after:origin-bottom']);
|
|
758
|
-
case 'multiline':
|
|
759
|
-
return multilineNormalClasses;
|
|
760
|
-
case 'multiline-static':
|
|
761
|
-
return multilineLineStaticClasses;
|
|
762
|
-
case 'multiline-ltr':
|
|
763
|
-
return multilineXClasses;
|
|
764
|
-
case 'multiline-rtl':
|
|
765
|
-
return multilineLineRtlClasses;
|
|
766
|
-
case 'multiline-center':
|
|
767
|
-
return multilineLineCenterClasses;
|
|
768
|
-
case 'multiline-lift':
|
|
769
|
-
return multilineLineLiftClasses;
|
|
770
|
-
case 'multiline-fill':
|
|
771
|
-
return getMultilineFillClasses(theme, customTheme);
|
|
772
|
-
case 'multiline-fill-ltr':
|
|
773
|
-
return getMultilineFillXClasses(theme, customTheme);
|
|
774
|
-
case 'multiline-fill-rtl':
|
|
775
|
-
return getMultilineFillRtlClasses(theme, customTheme);
|
|
776
|
-
case 'multiline-fill-center':
|
|
777
|
-
return getMultilineFillCenterClasses(theme, customTheme);
|
|
778
|
-
case 'multiline-fill-lift':
|
|
779
|
-
return getMultilineFillLiftClasses(theme, customTheme);
|
|
780
|
-
default:
|
|
781
|
-
return lineNormalClasses;
|
|
782
|
-
}
|
|
783
|
-
};
|
|
784
|
-
const linkClasses = getLinkClasses();
|
|
817
|
+
function Link({ as, className, customTheme, theme = "blue", type, ...props }) {
|
|
818
|
+
const linkClasses = getLinkClasses({ customTheme, theme, type });
|
|
785
819
|
const LinkElement = as || Anchor;
|
|
786
820
|
return jsx(LinkElement, { ...props, className: twMerge(linkClasses, className) });
|
|
787
821
|
}
|
|
@@ -812,7 +846,9 @@ function Link({ as, className, customTheme, theme = 'blue', type, ...props }) {
|
|
|
812
846
|
*/
|
|
813
847
|
function createLink(config) {
|
|
814
848
|
return function ExtendedLink({ theme, className, customTheme, type, as, ...props }) {
|
|
815
|
-
const finalType = type !== undefined
|
|
849
|
+
const finalType = type !== undefined
|
|
850
|
+
? type
|
|
851
|
+
: config.type, finalTheme = theme !== undefined ? theme : config.defaultTheme;
|
|
816
852
|
const configClassName = config.className;
|
|
817
853
|
const shouldOverrideElement = !Boolean(as) && Boolean(config.as);
|
|
818
854
|
const linkProps = {
|
|
@@ -827,13 +863,17 @@ function createLink(config) {
|
|
|
827
863
|
else if (as) {
|
|
828
864
|
linkProps.as = as;
|
|
829
865
|
}
|
|
830
|
-
if (finalTheme && typeof finalTheme ===
|
|
866
|
+
if (finalTheme && typeof finalTheme === "string" && config.theme &&
|
|
867
|
+
finalTheme in config.theme) {
|
|
831
868
|
const extendedTheme = config.theme[finalTheme];
|
|
832
|
-
if (customTheme)
|
|
833
|
-
return (jsx(Link, { ...linkProps, theme:
|
|
869
|
+
if (customTheme) {
|
|
870
|
+
return (jsx(Link, { ...linkProps, theme: "custom", customTheme: customTheme, className: twMerge(configClassName, extendedTheme.className, className) }));
|
|
871
|
+
}
|
|
834
872
|
let resolvedCustomTheme;
|
|
835
873
|
if (extendedTheme.customTheme.themeColor) {
|
|
836
|
-
const isMultilineType = finalType
|
|
874
|
+
const isMultilineType = finalType
|
|
875
|
+
? finalType.includes("multiline")
|
|
876
|
+
: false;
|
|
837
877
|
resolvedCustomTheme = {
|
|
838
878
|
themeColor: isMultilineType
|
|
839
879
|
? extendedTheme.customTheme.themeColor.multilineFill
|
|
@@ -845,7 +885,7 @@ function createLink(config) {
|
|
|
845
885
|
classes: extendedTheme.customTheme.classes,
|
|
846
886
|
};
|
|
847
887
|
}
|
|
848
|
-
return (jsx(Link, { ...linkProps, theme:
|
|
888
|
+
return (jsx(Link, { ...linkProps, theme: "custom", customTheme: resolvedCustomTheme, className: twMerge(configClassName, extendedTheme.className, className) }));
|
|
849
889
|
}
|
|
850
890
|
return (jsx(Link, { ...linkProps, theme: finalTheme, className: twMerge(configClassName, className), customTheme: customTheme }));
|
|
851
891
|
};
|
|
@@ -1119,32 +1159,44 @@ function Details({ as = 'div', className, ...props }) {
|
|
|
1119
1159
|
}
|
|
1120
1160
|
|
|
1121
1161
|
function DropDownButton({ arrow = true, as, children, className, ...props }) {
|
|
1122
|
-
return (jsxs(MenuButton, { ...props, as: as ||
|
|
1123
|
-
(typeof arrow ===
|
|
1162
|
+
return (jsxs(MenuButton, { ...props, as: as || "button", className: twJoin("group/button", className), children: [children, arrow &&
|
|
1163
|
+
(typeof arrow === "boolean"
|
|
1164
|
+
? (jsx(ChevronDown, { className: "-top-px -mr-1 ml-2 w-4 animate-flip-again group-data-open/button:animate-flip" }))
|
|
1165
|
+
: arrow)] }));
|
|
1124
1166
|
}
|
|
1125
1167
|
function DropDownItem({ as, ...props }) {
|
|
1126
|
-
return jsx(MenuItem, { ...props, as: as ||
|
|
1168
|
+
return jsx(MenuItem, { ...props, as: as || "div" });
|
|
1127
1169
|
}
|
|
1128
1170
|
function DropDownItems({ anchor, children, className, containerClassName, style, ...props }) {
|
|
1129
1171
|
const getAnchorProps = () => {
|
|
1130
|
-
let initialAnchor = {
|
|
1172
|
+
let initialAnchor = {
|
|
1173
|
+
gap: "1rem",
|
|
1174
|
+
padding: "1rem",
|
|
1175
|
+
to: "bottom start",
|
|
1176
|
+
};
|
|
1131
1177
|
if (anchor) {
|
|
1132
|
-
if (typeof anchor ===
|
|
1178
|
+
if (typeof anchor === "string")
|
|
1133
1179
|
initialAnchor.to = anchor;
|
|
1134
|
-
if (typeof anchor ===
|
|
1180
|
+
if (typeof anchor === "object") {
|
|
1135
1181
|
initialAnchor = { ...initialAnchor, ...anchor };
|
|
1182
|
+
}
|
|
1136
1183
|
}
|
|
1137
1184
|
return initialAnchor;
|
|
1138
1185
|
};
|
|
1139
1186
|
const anchorProps = getAnchorProps();
|
|
1140
|
-
return (jsx(MenuItems, { ...props, anchor: anchorProps, className: twMerge(
|
|
1187
|
+
return (jsx(MenuItems, { ...props, anchor: anchorProps, className: twMerge("grid grid-rows-1fr rounded-xl shadow-xl transition-rows duration-500 ease-exponential not-data-open:not-data-enter:not-data-leave:grid-rows-0fr data-closed:grid-rows-0fr", containerClassName), static: props.static, style: { ...style, minWidth: "var(--button-width)" }, transition: true, children: (bag) => (jsx("div", { className: "overflow-y-scroll", children: jsx("div", { className: twMerge("rounded-xl bg-neutral-50/20 px-6 py-5 backdrop-blur-md backdrop-brightness-150", className), children: typeof children === "function" ? children(bag) : children }) })) }));
|
|
1141
1188
|
}
|
|
1142
1189
|
function DropDownSection({ children, label, labelProps, separatorAbove, separatorBelow, ...props }) {
|
|
1143
|
-
const { labelClassName, ...restLabelProps } = {
|
|
1144
|
-
|
|
1190
|
+
const { labelClassName, ...restLabelProps } = {
|
|
1191
|
+
labelClassName: labelProps?.className || "",
|
|
1192
|
+
...labelProps,
|
|
1193
|
+
};
|
|
1194
|
+
return (jsx(MenuSection, { ...props, children: (sectionBag) => (jsxs(Fragment$1, { children: [separatorAbove && jsx(DropDownSeparator, {}), label && (jsx(MenuHeading, { ...restLabelProps, className: (headingBag) => twMerge("text-[larger] font-bold text-current/80", typeof labelClassName === "function"
|
|
1195
|
+
? labelClassName(headingBag)
|
|
1196
|
+
: labelClassName), children: label })), typeof children === "function" ? children(sectionBag) : children, separatorBelow && jsx(DropDownSeparator, {})] })) }));
|
|
1145
1197
|
}
|
|
1146
1198
|
function DropDownSeparator({ as, className, ...props }) {
|
|
1147
|
-
return (jsx(MenuSeparator, { ...props, as: as ||
|
|
1199
|
+
return (jsx(MenuSeparator, { ...props, as: as || "div", className: (bag) => twMerge("my-4 block h-px rounded-full bg-neutral-950/20", typeof className === "function" ? className(bag) : className) }));
|
|
1148
1200
|
}
|
|
1149
1201
|
function DropDown(props) {
|
|
1150
1202
|
return jsx(Menu, { ...props });
|
|
@@ -2288,7 +2340,7 @@ function isOverflowElement(element) {
|
|
|
2288
2340
|
overflowX,
|
|
2289
2341
|
overflowY,
|
|
2290
2342
|
display
|
|
2291
|
-
} = getComputedStyle(element);
|
|
2343
|
+
} = getComputedStyle$1(element);
|
|
2292
2344
|
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
|
2293
2345
|
}
|
|
2294
2346
|
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
|
@@ -2310,7 +2362,7 @@ const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspect
|
|
|
2310
2362
|
const containValues = ['paint', 'layout', 'strict', 'content'];
|
|
2311
2363
|
function isContainingBlock(elementOrCss) {
|
|
2312
2364
|
const webkit = isWebKit();
|
|
2313
|
-
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
|
2365
|
+
const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
|
|
2314
2366
|
|
|
2315
2367
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
2316
2368
|
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
|
@@ -2336,7 +2388,7 @@ const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#documen
|
|
|
2336
2388
|
function isLastTraversableNode(node) {
|
|
2337
2389
|
return lastTraversableNodeNames.has(getNodeName(node));
|
|
2338
2390
|
}
|
|
2339
|
-
function getComputedStyle(element) {
|
|
2391
|
+
function getComputedStyle$1(element) {
|
|
2340
2392
|
return getWindow(element).getComputedStyle(element);
|
|
2341
2393
|
}
|
|
2342
2394
|
function getNodeScroll(element) {
|
|
@@ -2398,7 +2450,7 @@ function getFrameElement(win) {
|
|
|
2398
2450
|
}
|
|
2399
2451
|
|
|
2400
2452
|
function getCssDimensions(element) {
|
|
2401
|
-
const css = getComputedStyle(element);
|
|
2453
|
+
const css = getComputedStyle$1(element);
|
|
2402
2454
|
// In testing environments, the `width` and `height` properties are empty
|
|
2403
2455
|
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
|
2404
2456
|
let width = parseFloat(css.width) || 0;
|
|
@@ -2503,7 +2555,7 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
2503
2555
|
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
2504
2556
|
const iframeScale = getScale(currentIFrame);
|
|
2505
2557
|
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
2506
|
-
const css = getComputedStyle(currentIFrame);
|
|
2558
|
+
const css = getComputedStyle$1(currentIFrame);
|
|
2507
2559
|
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
2508
2560
|
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
2509
2561
|
x *= iframeScale.x;
|
|
@@ -2534,14 +2586,9 @@ function getWindowScrollBarX(element, rect) {
|
|
|
2534
2586
|
return rect.left + leftScroll;
|
|
2535
2587
|
}
|
|
2536
2588
|
|
|
2537
|
-
function getHTMLOffset(documentElement, scroll
|
|
2538
|
-
if (ignoreScrollbarX === void 0) {
|
|
2539
|
-
ignoreScrollbarX = false;
|
|
2540
|
-
}
|
|
2589
|
+
function getHTMLOffset(documentElement, scroll) {
|
|
2541
2590
|
const htmlRect = documentElement.getBoundingClientRect();
|
|
2542
|
-
const x = htmlRect.left + scroll.scrollLeft - (
|
|
2543
|
-
// RTL <body> scrollbar.
|
|
2544
|
-
getWindowScrollBarX(documentElement, htmlRect));
|
|
2591
|
+
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
|
2545
2592
|
const y = htmlRect.top + scroll.scrollTop;
|
|
2546
2593
|
return {
|
|
2547
2594
|
x,
|
|
@@ -2580,7 +2627,7 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
|
2580
2627
|
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2581
2628
|
}
|
|
2582
2629
|
}
|
|
2583
|
-
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll
|
|
2630
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
2584
2631
|
return {
|
|
2585
2632
|
width: rect.width * scale.x,
|
|
2586
2633
|
height: rect.height * scale.y,
|
|
@@ -2603,7 +2650,7 @@ function getDocumentRect(element) {
|
|
|
2603
2650
|
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
2604
2651
|
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
2605
2652
|
const y = -scroll.scrollTop;
|
|
2606
|
-
if (getComputedStyle(body).direction === 'rtl') {
|
|
2653
|
+
if (getComputedStyle$1(body).direction === 'rtl') {
|
|
2607
2654
|
x += max(html.clientWidth, body.clientWidth) - width;
|
|
2608
2655
|
}
|
|
2609
2656
|
return {
|
|
@@ -2614,6 +2661,10 @@ function getDocumentRect(element) {
|
|
|
2614
2661
|
};
|
|
2615
2662
|
}
|
|
2616
2663
|
|
|
2664
|
+
// Safety check: ensure the scrollbar space is reasonable in case this
|
|
2665
|
+
// calculation is affected by unusual styles.
|
|
2666
|
+
// Most scrollbars leave 15-18px of space.
|
|
2667
|
+
const SCROLLBAR_MAX = 25;
|
|
2617
2668
|
function getViewportRect(element, strategy) {
|
|
2618
2669
|
const win = getWindow(element);
|
|
2619
2670
|
const html = getDocumentElement(element);
|
|
@@ -2631,6 +2682,24 @@ function getViewportRect(element, strategy) {
|
|
|
2631
2682
|
y = visualViewport.offsetTop;
|
|
2632
2683
|
}
|
|
2633
2684
|
}
|
|
2685
|
+
const windowScrollbarX = getWindowScrollBarX(html);
|
|
2686
|
+
// <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
|
|
2687
|
+
// visual width of the <html> but this is not considered in the size
|
|
2688
|
+
// of `html.clientWidth`.
|
|
2689
|
+
if (windowScrollbarX <= 0) {
|
|
2690
|
+
const doc = html.ownerDocument;
|
|
2691
|
+
const body = doc.body;
|
|
2692
|
+
const bodyStyles = getComputedStyle(body);
|
|
2693
|
+
const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
|
2694
|
+
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
|
2695
|
+
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
|
|
2696
|
+
width -= clippingStableScrollbarWidth;
|
|
2697
|
+
}
|
|
2698
|
+
} else if (windowScrollbarX <= SCROLLBAR_MAX) {
|
|
2699
|
+
// If the <body> scrollbar is on the left, the width needs to be extended
|
|
2700
|
+
// by the scrollbar amount so there isn't extra space on the right.
|
|
2701
|
+
width += windowScrollbarX;
|
|
2702
|
+
}
|
|
2634
2703
|
return {
|
|
2635
2704
|
width,
|
|
2636
2705
|
height,
|
|
@@ -2681,7 +2750,7 @@ function hasFixedPositionAncestor(element, stopNode) {
|
|
|
2681
2750
|
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
2682
2751
|
return false;
|
|
2683
2752
|
}
|
|
2684
|
-
return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
|
2753
|
+
return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
|
2685
2754
|
}
|
|
2686
2755
|
|
|
2687
2756
|
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
@@ -2694,12 +2763,12 @@ function getClippingElementAncestors(element, cache) {
|
|
|
2694
2763
|
}
|
|
2695
2764
|
let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
2696
2765
|
let currentContainingBlockComputedStyle = null;
|
|
2697
|
-
const elementIsFixed = getComputedStyle(element).position === 'fixed';
|
|
2766
|
+
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
|
2698
2767
|
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
2699
2768
|
|
|
2700
2769
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
2701
2770
|
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
2702
|
-
const computedStyle = getComputedStyle(currentNode);
|
|
2771
|
+
const computedStyle = getComputedStyle$1(currentNode);
|
|
2703
2772
|
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
2704
2773
|
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
|
2705
2774
|
currentContainingBlockComputedStyle = null;
|
|
@@ -2800,11 +2869,11 @@ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
|
2800
2869
|
}
|
|
2801
2870
|
|
|
2802
2871
|
function isStaticPositioned(element) {
|
|
2803
|
-
return getComputedStyle(element).position === 'static';
|
|
2872
|
+
return getComputedStyle$1(element).position === 'static';
|
|
2804
2873
|
}
|
|
2805
2874
|
|
|
2806
2875
|
function getTrueOffsetParent(element, polyfill) {
|
|
2807
|
-
if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
|
|
2876
|
+
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
|
2808
2877
|
return null;
|
|
2809
2878
|
}
|
|
2810
2879
|
if (polyfill) {
|
|
@@ -2865,7 +2934,7 @@ const getElementRects = async function (data) {
|
|
|
2865
2934
|
};
|
|
2866
2935
|
|
|
2867
2936
|
function isRTL(element) {
|
|
2868
|
-
return getComputedStyle(element).direction === 'rtl';
|
|
2937
|
+
return getComputedStyle$1(element).direction === 'rtl';
|
|
2869
2938
|
}
|
|
2870
2939
|
|
|
2871
2940
|
const platform = {
|
|
@@ -3441,19 +3510,20 @@ const arrow = (options, deps) => ({
|
|
|
3441
3510
|
|
|
3442
3511
|
function TooltipTrigger({ as, asChild = false, children, ...props }) {
|
|
3443
3512
|
const TooltipTriggerElement = as || Button$1;
|
|
3444
|
-
if (asChild && isValidElement(children))
|
|
3513
|
+
if (asChild && isValidElement(children)) {
|
|
3445
3514
|
return cloneElement(children, props);
|
|
3515
|
+
}
|
|
3446
3516
|
return jsx(TooltipTriggerElement, { ...props, children: children });
|
|
3447
3517
|
}
|
|
3448
3518
|
function TooltipPanel({ as, children, className, style, ...props }) {
|
|
3449
|
-
const TooltipPanelElement = as ||
|
|
3450
|
-
return (jsx(TooltipPanelElement, { ...props, className: twMerge(
|
|
3519
|
+
const TooltipPanelElement = as || "div";
|
|
3520
|
+
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 }));
|
|
3451
3521
|
}
|
|
3452
|
-
function Tooltip({ anchor =
|
|
3522
|
+
function Tooltip({ anchor = "top", arrow: arrow$1, arrowClassName, children, delay = 500, offset: offset$1 = 8, onClose, onOpen, portal, }) {
|
|
3453
3523
|
const [isOpen, setIsOpen] = useState(false), timeoutRef = useRef(undefined), arrowRef = useRef(null);
|
|
3454
|
-
const [bodyElement, setBodyElement] = useState(() => typeof window !==
|
|
3524
|
+
const [bodyElement, setBodyElement] = useState(() => typeof window !== "undefined" ? document.body : null);
|
|
3455
3525
|
useEffect(() => {
|
|
3456
|
-
if (typeof window !==
|
|
3526
|
+
if (typeof window !== "undefined" && !bodyElement) {
|
|
3457
3527
|
const documentBody = document.body;
|
|
3458
3528
|
setBodyElement(documentBody);
|
|
3459
3529
|
}
|
|
@@ -3470,10 +3540,12 @@ function Tooltip({ anchor = 'top', arrow: arrow$1, arrowClassName, children, del
|
|
|
3470
3540
|
elements.floating.style.maxWidth = width;
|
|
3471
3541
|
},
|
|
3472
3542
|
}),
|
|
3473
|
-
...(arrowRef.current
|
|
3543
|
+
...(arrowRef.current
|
|
3544
|
+
? [arrow({ element: arrowRef.current })]
|
|
3545
|
+
: []),
|
|
3474
3546
|
],
|
|
3475
3547
|
placement: anchor,
|
|
3476
|
-
strategy: portal ?
|
|
3548
|
+
strategy: portal ? "fixed" : "absolute",
|
|
3477
3549
|
whileElementsMounted: autoUpdate,
|
|
3478
3550
|
open: isOpen,
|
|
3479
3551
|
});
|
|
@@ -3500,37 +3572,41 @@ function Tooltip({ anchor = 'top', arrow: arrow$1, arrowClassName, children, del
|
|
|
3500
3572
|
clearTimeout(timeoutRef.current);
|
|
3501
3573
|
};
|
|
3502
3574
|
}, []);
|
|
3503
|
-
const content = typeof children ===
|
|
3575
|
+
const content = typeof children === "function"
|
|
3576
|
+
? children({ openTooltip, closeTooltip })
|
|
3577
|
+
: children;
|
|
3504
3578
|
const triggerElement = findComponentByType(content, TooltipTrigger), contentElement = findComponentByType(content, TooltipPanel);
|
|
3505
|
-
if (!contentElement)
|
|
3506
|
-
throw new Error(
|
|
3507
|
-
|
|
3508
|
-
|
|
3579
|
+
if (!contentElement) {
|
|
3580
|
+
throw new Error("TooltipPanel must be defined in Tooltip children");
|
|
3581
|
+
}
|
|
3582
|
+
if (!triggerElement && typeof children !== "function") {
|
|
3583
|
+
throw new Error("TooltipTrigger must be provided when not using render prop pattern");
|
|
3584
|
+
}
|
|
3509
3585
|
const arrowStyles = {};
|
|
3510
3586
|
const reversedAnchor = {
|
|
3511
|
-
top:
|
|
3512
|
-
right:
|
|
3513
|
-
bottom:
|
|
3514
|
-
left:
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3587
|
+
top: "bottom",
|
|
3588
|
+
right: "left",
|
|
3589
|
+
bottom: "top",
|
|
3590
|
+
left: "right",
|
|
3591
|
+
"top-start": "bottom left",
|
|
3592
|
+
"top-end": "bottom right",
|
|
3593
|
+
"right-start": "top left",
|
|
3594
|
+
"right-end": "bottom left",
|
|
3595
|
+
"bottom-start": "top left",
|
|
3596
|
+
"bottom-end": "top right",
|
|
3597
|
+
"left-start": "top right",
|
|
3598
|
+
"left-end": "bottom right",
|
|
3523
3599
|
}[placement];
|
|
3524
3600
|
if (middlewareData.arrow && arrow$1) {
|
|
3525
3601
|
const { x, y } = middlewareData.arrow;
|
|
3526
3602
|
const staticSide = {
|
|
3527
|
-
top:
|
|
3528
|
-
right:
|
|
3529
|
-
bottom:
|
|
3530
|
-
left:
|
|
3531
|
-
}[placement.split(
|
|
3603
|
+
top: "bottom",
|
|
3604
|
+
right: "left",
|
|
3605
|
+
bottom: "top",
|
|
3606
|
+
left: "right",
|
|
3607
|
+
}[placement.split("-")[0]];
|
|
3532
3608
|
if (staticSide) {
|
|
3533
|
-
arrowStyles[staticSide] =
|
|
3609
|
+
arrowStyles[staticSide] = "-4px";
|
|
3534
3610
|
if (x != null)
|
|
3535
3611
|
arrowStyles.left = `${x}px`;
|
|
3536
3612
|
if (y != null)
|
|
@@ -3539,68 +3615,68 @@ function Tooltip({ anchor = 'top', arrow: arrow$1, arrowClassName, children, del
|
|
|
3539
3615
|
}
|
|
3540
3616
|
const getArrowLocationClasses = () => {
|
|
3541
3617
|
switch (placement) {
|
|
3542
|
-
case
|
|
3543
|
-
case
|
|
3544
|
-
case
|
|
3545
|
-
return
|
|
3546
|
-
case
|
|
3547
|
-
case
|
|
3548
|
-
case
|
|
3549
|
-
return
|
|
3550
|
-
case
|
|
3551
|
-
case
|
|
3552
|
-
case
|
|
3553
|
-
return
|
|
3554
|
-
case
|
|
3555
|
-
case
|
|
3556
|
-
case
|
|
3557
|
-
return
|
|
3618
|
+
case "bottom":
|
|
3619
|
+
case "bottom-end":
|
|
3620
|
+
case "bottom-start":
|
|
3621
|
+
return "-translate-y-1";
|
|
3622
|
+
case "top":
|
|
3623
|
+
case "top-end":
|
|
3624
|
+
case "top-start":
|
|
3625
|
+
return "rotate-180 translate-y-1";
|
|
3626
|
+
case "left":
|
|
3627
|
+
case "left-end":
|
|
3628
|
+
case "left-start":
|
|
3629
|
+
return "rotate-90 translate-x-2";
|
|
3630
|
+
case "right":
|
|
3631
|
+
case "right-end":
|
|
3632
|
+
case "right-start":
|
|
3633
|
+
return "-rotate-90 -translate-x-2";
|
|
3558
3634
|
}
|
|
3559
3635
|
};
|
|
3560
3636
|
const arrowLocationClasses = getArrowLocationClasses();
|
|
3561
|
-
const handleMouseEnter = e => {
|
|
3637
|
+
const handleMouseEnter = (e) => {
|
|
3562
3638
|
openTooltip();
|
|
3563
3639
|
triggerElement?.props.onMouseEnter?.(e);
|
|
3564
3640
|
};
|
|
3565
|
-
const handleMouseLeave = e => {
|
|
3641
|
+
const handleMouseLeave = (e) => {
|
|
3566
3642
|
triggerElement?.props.onMouseLeave?.(e);
|
|
3567
3643
|
closeTooltip();
|
|
3568
3644
|
};
|
|
3569
|
-
const handleTouchStart = e => {
|
|
3645
|
+
const handleTouchStart = (e) => {
|
|
3570
3646
|
openTooltip();
|
|
3571
3647
|
triggerElement?.props.onTouchStart?.(e);
|
|
3572
3648
|
};
|
|
3573
|
-
const handleFocus = e => {
|
|
3649
|
+
const handleFocus = (e) => {
|
|
3574
3650
|
triggerElement?.props.onFocus?.(e);
|
|
3575
3651
|
openTooltip();
|
|
3576
3652
|
};
|
|
3577
|
-
const handleBlur = e => {
|
|
3653
|
+
const handleBlur = (e) => {
|
|
3578
3654
|
triggerElement?.props.onBlur?.(e);
|
|
3579
3655
|
closeTooltip();
|
|
3580
3656
|
};
|
|
3581
3657
|
const tooltipContent = (jsx(Fragment$1, { children: isOpen &&
|
|
3582
3658
|
contentElement &&
|
|
3583
3659
|
cloneElement(contentElement, {
|
|
3584
|
-
children: (jsxs(Fragment$1, { children: [contentElement.props.children, arrow$1 && (jsx(ArrowSvg, { className: twMerge(
|
|
3585
|
-
...(portal ? {
|
|
3586
|
-
...(isPositioned ? {
|
|
3660
|
+
children: (jsxs(Fragment$1, { children: [contentElement.props.children, arrow$1 && (jsx(ArrowSvg, { className: twMerge("absolute", arrowLocationClasses, arrowClassName), style: arrowStyles, "data-tooltip-arrow": true }))] })),
|
|
3661
|
+
...(portal ? { "data-portal": true } : {}),
|
|
3662
|
+
...(isPositioned ? { "data-ready": true } : {}),
|
|
3587
3663
|
onMouseEnter: openTooltip,
|
|
3588
3664
|
onMouseLeave: closeTooltip,
|
|
3589
3665
|
onTouchStart: handleTouchStart,
|
|
3590
3666
|
ref: (node) => {
|
|
3591
3667
|
refs.setFloating(node);
|
|
3592
3668
|
if (node && arrow$1) {
|
|
3593
|
-
const arrowElement = node.querySelector(
|
|
3669
|
+
const arrowElement = node.querySelector("[data-tooltip-arrow]");
|
|
3594
3670
|
if (arrowElement)
|
|
3595
3671
|
arrowRef.current = arrowElement;
|
|
3596
3672
|
}
|
|
3597
3673
|
},
|
|
3598
|
-
role:
|
|
3674
|
+
role: "tooltip",
|
|
3599
3675
|
style: {
|
|
3600
3676
|
...contentElement.props.style,
|
|
3601
3677
|
...floatingStyles,
|
|
3602
3678
|
transformOrigin: reversedAnchor,
|
|
3603
|
-
pointerEvents:
|
|
3679
|
+
pointerEvents: "none",
|
|
3604
3680
|
},
|
|
3605
3681
|
}) }));
|
|
3606
3682
|
return (jsxs(Fragment$1, { children: [triggerElement &&
|
|
@@ -3610,42 +3686,46 @@ function Tooltip({ anchor = 'top', arrow: arrow$1, arrowClassName, children, del
|
|
|
3610
3686
|
onMouseLeave: handleMouseLeave,
|
|
3611
3687
|
onFocus: handleFocus,
|
|
3612
3688
|
onBlur: handleBlur,
|
|
3613
|
-
|
|
3614
|
-
}), portal
|
|
3689
|
+
"aria-describedby": isOpen ? "tooltip" : undefined,
|
|
3690
|
+
}), portal
|
|
3691
|
+
? bodyElement && createPortal(tooltipContent, bodyElement)
|
|
3692
|
+
: tooltipContent] }));
|
|
3615
3693
|
}
|
|
3616
3694
|
function ArrowSvg({ className, ...props }) {
|
|
3617
|
-
return (jsxs("svg", { viewBox:
|
|
3695
|
+
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" })] }));
|
|
3618
3696
|
}
|
|
3619
3697
|
|
|
3620
3698
|
const specialCharacterRegex = new RegExp(/[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~€‚ƒ„…†‡‰‹‘’“”•–—™›¡¢£¥§©«¬®°±¶º»¿×÷]/);
|
|
3621
3699
|
function Input({ checked, className, defaultValue, description, descriptionProps, disabled, fieldProps, invalid = true, label, labelProps, max, min, name, onBlur, onChange, options, placeholder, ref, required = true, type, value, ...props }) {
|
|
3622
3700
|
const [formContext, formContextFunctions] = useFormContext(), [fieldsetContext, fieldsetContextFunctions] = useFieldsetContext(), [errorMessage, setErrorMessage] = useState(undefined);
|
|
3623
|
-
if (type ===
|
|
3624
|
-
placeholder =
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3701
|
+
if (type === "password" && !placeholder) {
|
|
3702
|
+
placeholder = "••••••••" + (required && !label ? "*" : "");
|
|
3703
|
+
}
|
|
3704
|
+
if (placeholder === "*")
|
|
3705
|
+
placeholder = name + (required && !label ? "*" : "");
|
|
3706
|
+
if (label === "*")
|
|
3628
3707
|
label = name;
|
|
3629
|
-
const uniqueID = useId(), fieldContextID = toLowerCase(name, [,
|
|
3708
|
+
const uniqueID = useId(), fieldContextID = toLowerCase(name, [, "_"]) + "§" + uniqueID;
|
|
3630
3709
|
const isInFieldset = fieldsetContext && !fieldsetContext.decorative;
|
|
3631
3710
|
const getFieldContextType = () => {
|
|
3632
3711
|
switch (type) {
|
|
3633
|
-
case
|
|
3634
|
-
return
|
|
3635
|
-
case
|
|
3636
|
-
return
|
|
3637
|
-
case
|
|
3638
|
-
return
|
|
3639
|
-
case
|
|
3640
|
-
return
|
|
3641
|
-
case
|
|
3642
|
-
return
|
|
3712
|
+
case "email":
|
|
3713
|
+
return "email";
|
|
3714
|
+
case "file":
|
|
3715
|
+
return "file";
|
|
3716
|
+
case "number":
|
|
3717
|
+
return "number";
|
|
3718
|
+
case "tel":
|
|
3719
|
+
return "tel";
|
|
3720
|
+
case "url":
|
|
3721
|
+
return "url";
|
|
3643
3722
|
default:
|
|
3644
|
-
return
|
|
3723
|
+
return "string";
|
|
3645
3724
|
}
|
|
3646
3725
|
};
|
|
3647
3726
|
const fieldContextType = getFieldContextType();
|
|
3648
|
-
const fieldContext = (isInFieldset ? fieldsetContext.fieldList : formContext)
|
|
3727
|
+
const fieldContext = (isInFieldset ? fieldsetContext.fieldList : formContext)
|
|
3728
|
+
?.find(({ id: fieldID }) => fieldID === fieldContextID);
|
|
3649
3729
|
useEffect(() => {
|
|
3650
3730
|
const initialFieldContext = defineField({
|
|
3651
3731
|
type: fieldContextType,
|
|
@@ -3653,7 +3733,7 @@ function Input({ checked, className, defaultValue, description, descriptionProps
|
|
|
3653
3733
|
invalid,
|
|
3654
3734
|
name,
|
|
3655
3735
|
required,
|
|
3656
|
-
value: value ? `${value}` : defaultValue ? `${defaultValue}` :
|
|
3736
|
+
value: value ? `${value}` : defaultValue ? `${defaultValue}` : "",
|
|
3657
3737
|
});
|
|
3658
3738
|
if (isInFieldset) {
|
|
3659
3739
|
fieldsetContextFunctions.registerField(initialFieldContext);
|
|
@@ -3667,57 +3747,71 @@ function Input({ checked, className, defaultValue, description, descriptionProps
|
|
|
3667
3747
|
};
|
|
3668
3748
|
}, [isInFieldset]);
|
|
3669
3749
|
const validateField = (validValue) => {
|
|
3670
|
-
const noValue = !validValue || validValue ===
|
|
3750
|
+
const noValue = !validValue || validValue === "";
|
|
3671
3751
|
if (!required && noValue)
|
|
3672
3752
|
return true;
|
|
3673
3753
|
const errorMessageList = [];
|
|
3674
3754
|
if (noValue) {
|
|
3675
|
-
errorMessageList.push(
|
|
3676
|
-
setErrorMessage(errorMessageList.join(
|
|
3755
|
+
errorMessageList.push("This field is required.");
|
|
3756
|
+
setErrorMessage(errorMessageList.join(" "));
|
|
3677
3757
|
return false;
|
|
3678
3758
|
}
|
|
3679
3759
|
switch (type) {
|
|
3680
|
-
case
|
|
3681
|
-
if (!isEmail(validValue))
|
|
3682
|
-
errorMessageList.push(
|
|
3760
|
+
case "email":
|
|
3761
|
+
if (!isEmail(validValue)) {
|
|
3762
|
+
errorMessageList.push("This is not a valid email.");
|
|
3763
|
+
}
|
|
3683
3764
|
break;
|
|
3684
|
-
case
|
|
3765
|
+
case "date":
|
|
3685
3766
|
const valueAsTime = new Date().getTime();
|
|
3686
|
-
if (min && !(min instanceof Date) && typeof min !==
|
|
3767
|
+
if (min && !(min instanceof Date) && typeof min !== "number") {
|
|
3687
3768
|
if (Array.isArray(min)) {
|
|
3688
|
-
const monthIndex = typeof min[1] ===
|
|
3769
|
+
const monthIndex = typeof min[1] === "number"
|
|
3770
|
+
? min[1] - 1
|
|
3771
|
+
: getMonthIndexFromName(min[1]);
|
|
3689
3772
|
min = new Date(min[0], monthIndex, min[2]);
|
|
3690
3773
|
}
|
|
3691
|
-
else if (
|
|
3692
|
-
const monthIndex = typeof min.month ===
|
|
3774
|
+
else if ("year" in min && "month" in min && "day" in min) {
|
|
3775
|
+
const monthIndex = typeof min.month === "number"
|
|
3776
|
+
? min.month - 1
|
|
3777
|
+
: getMonthIndexFromName(min.month);
|
|
3693
3778
|
min = new Date(min.year, monthIndex, min.day);
|
|
3694
3779
|
}
|
|
3695
|
-
if (valueAsTime < min.getTime())
|
|
3780
|
+
if (valueAsTime < min.getTime()) {
|
|
3696
3781
|
errorMessageList.push(`Value cannot be lower than ${getUserReadableDate(min)}.`);
|
|
3782
|
+
}
|
|
3697
3783
|
}
|
|
3698
|
-
if (max && !(max instanceof Date) && typeof max !==
|
|
3784
|
+
if (max && !(max instanceof Date) && typeof max !== "number") {
|
|
3699
3785
|
if (Array.isArray(max)) {
|
|
3700
|
-
const monthIndex = typeof max[1] ===
|
|
3786
|
+
const monthIndex = typeof max[1] === "number"
|
|
3787
|
+
? max[1] - 1
|
|
3788
|
+
: getMonthIndexFromName(max[1]);
|
|
3701
3789
|
max = new Date(max[0], monthIndex, max[2]);
|
|
3702
3790
|
}
|
|
3703
|
-
else if (
|
|
3704
|
-
const monthIndex = typeof max.month ===
|
|
3791
|
+
else if ("year" in max && "month" in max && "day" in max) {
|
|
3792
|
+
const monthIndex = typeof max.month === "number"
|
|
3793
|
+
? max.month - 1
|
|
3794
|
+
: getMonthIndexFromName(max.month);
|
|
3705
3795
|
max = new Date(max.year, monthIndex, max.day);
|
|
3706
3796
|
}
|
|
3707
|
-
if (valueAsTime > max.getTime())
|
|
3797
|
+
if (valueAsTime > max.getTime()) {
|
|
3708
3798
|
errorMessageList.push(`Value cannot be higher than ${getUserReadableDate(max)}.`);
|
|
3799
|
+
}
|
|
3709
3800
|
}
|
|
3710
3801
|
break;
|
|
3711
|
-
case
|
|
3802
|
+
case "number":
|
|
3712
3803
|
const valueAsNumber = Number(validValue);
|
|
3713
|
-
if (isNaN(valueAsNumber))
|
|
3714
|
-
errorMessageList.push(
|
|
3715
|
-
|
|
3804
|
+
if (isNaN(valueAsNumber)) {
|
|
3805
|
+
errorMessageList.push("This is not a valid number.");
|
|
3806
|
+
}
|
|
3807
|
+
if (typeof max === "number" && valueAsNumber > max) {
|
|
3716
3808
|
errorMessageList.push(`Value cannot be higher than ${max}.`);
|
|
3717
|
-
|
|
3809
|
+
}
|
|
3810
|
+
if (typeof min === "number" && valueAsNumber < min) {
|
|
3718
3811
|
errorMessageList.push(`Value cannot be lower than ${min}.`);
|
|
3812
|
+
}
|
|
3719
3813
|
break;
|
|
3720
|
-
case
|
|
3814
|
+
case "password":
|
|
3721
3815
|
if (options) {
|
|
3722
3816
|
const { matchPreviousInput, requireLowercaseCharacter, requireNumber, requireSpecialCharacter, requireUppercaseCharacter, } = options;
|
|
3723
3817
|
if (matchPreviousInput && formContext && formContext.length >= 2) {
|
|
@@ -3727,8 +3821,9 @@ function Input({ checked, className, defaultValue, description, descriptionProps
|
|
|
3727
3821
|
const previousInput = fieldsetContext.fieldList.find((_, index) => index === currentInputIndex - 1);
|
|
3728
3822
|
if (previousInput &&
|
|
3729
3823
|
isStringField(previousInput) &&
|
|
3730
|
-
previousInput.value !== validValue)
|
|
3731
|
-
errorMessageList.push(
|
|
3824
|
+
previousInput.value !== validValue) {
|
|
3825
|
+
errorMessageList.push("Passwords must match.");
|
|
3826
|
+
}
|
|
3732
3827
|
}
|
|
3733
3828
|
}
|
|
3734
3829
|
else {
|
|
@@ -3737,36 +3832,44 @@ function Input({ checked, className, defaultValue, description, descriptionProps
|
|
|
3737
3832
|
const previousInput = formContext.find((_, index) => index === currentInputIndex - 1);
|
|
3738
3833
|
if (previousInput &&
|
|
3739
3834
|
isStringField(previousInput) &&
|
|
3740
|
-
previousInput.value !== validValue)
|
|
3741
|
-
errorMessageList.push(
|
|
3835
|
+
previousInput.value !== validValue) {
|
|
3836
|
+
errorMessageList.push("Passwords must match.");
|
|
3837
|
+
}
|
|
3742
3838
|
}
|
|
3743
3839
|
}
|
|
3744
3840
|
}
|
|
3745
|
-
if (requireLowercaseCharacter && !/[a-z]/g.test(validValue))
|
|
3746
|
-
errorMessageList.push(
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
if (
|
|
3752
|
-
errorMessageList.push(
|
|
3841
|
+
if (requireLowercaseCharacter && !/[a-z]/g.test(validValue)) {
|
|
3842
|
+
errorMessageList.push("You must include a lowercase character.");
|
|
3843
|
+
}
|
|
3844
|
+
if (requireNumber && !/[0-9]/g.test(validValue)) {
|
|
3845
|
+
errorMessageList.push("You must include a number.");
|
|
3846
|
+
}
|
|
3847
|
+
if (requireSpecialCharacter && !specialCharacterRegex.test(validValue)) {
|
|
3848
|
+
errorMessageList.push("You must include a special character.");
|
|
3849
|
+
}
|
|
3850
|
+
if (requireUppercaseCharacter && !/[A-Z]/g.test(validValue)) {
|
|
3851
|
+
errorMessageList.push("You must include an uppercase character.");
|
|
3852
|
+
}
|
|
3753
3853
|
}
|
|
3754
3854
|
break;
|
|
3755
|
-
case
|
|
3756
|
-
if (!isPhoneNumber(validValue))
|
|
3757
|
-
errorMessageList.push(
|
|
3855
|
+
case "tel":
|
|
3856
|
+
if (!isPhoneNumber(validValue)) {
|
|
3857
|
+
errorMessageList.push("This is not a valid phone number.");
|
|
3858
|
+
}
|
|
3758
3859
|
break;
|
|
3759
3860
|
}
|
|
3760
|
-
if (props.maxLength && validValue.length > Number(props.maxLength))
|
|
3861
|
+
if (props.maxLength && validValue.length > Number(props.maxLength)) {
|
|
3761
3862
|
errorMessageList.push(`This may not have more than ${props.maxLength} characters.`);
|
|
3762
|
-
|
|
3863
|
+
}
|
|
3864
|
+
if (props.minLength && validValue.length < Number(props.minLength)) {
|
|
3763
3865
|
errorMessageList.push(`This must have at least ${props.minLength} characters.`);
|
|
3866
|
+
}
|
|
3764
3867
|
if (errorMessageList.length === 0)
|
|
3765
3868
|
return true;
|
|
3766
|
-
setErrorMessage(errorMessageList.join(
|
|
3869
|
+
setErrorMessage(errorMessageList.join(" "));
|
|
3767
3870
|
return false;
|
|
3768
3871
|
};
|
|
3769
|
-
const handleChange = e => {
|
|
3872
|
+
const handleChange = (e) => {
|
|
3770
3873
|
if (disabled) {
|
|
3771
3874
|
e.preventDefault();
|
|
3772
3875
|
return;
|
|
@@ -3779,11 +3882,14 @@ function Input({ checked, className, defaultValue, description, descriptionProps
|
|
|
3779
3882
|
});
|
|
3780
3883
|
}
|
|
3781
3884
|
else {
|
|
3782
|
-
formContextFunctions.updateField(fieldContextID, {
|
|
3885
|
+
formContextFunctions.updateField(fieldContextID, {
|
|
3886
|
+
value: newValue,
|
|
3887
|
+
invalid: validateField(newValue) === false,
|
|
3888
|
+
});
|
|
3783
3889
|
}
|
|
3784
3890
|
onChange?.(e);
|
|
3785
3891
|
};
|
|
3786
|
-
const handleBlur = e => {
|
|
3892
|
+
const handleBlur = (e) => {
|
|
3787
3893
|
if (disabled) {
|
|
3788
3894
|
e.preventDefault();
|
|
3789
3895
|
return;
|
|
@@ -3793,39 +3899,47 @@ function Input({ checked, className, defaultValue, description, descriptionProps
|
|
|
3793
3899
|
validateField(newValue);
|
|
3794
3900
|
let processedValue = newValue;
|
|
3795
3901
|
switch (type) {
|
|
3796
|
-
case
|
|
3902
|
+
case "email":
|
|
3797
3903
|
processedValue = newValue.toLowerCase();
|
|
3798
3904
|
break;
|
|
3799
|
-
case
|
|
3905
|
+
case "tel":
|
|
3800
3906
|
processedValue = formatPhoneNumber(newValue, options);
|
|
3801
3907
|
break;
|
|
3802
3908
|
}
|
|
3803
3909
|
if (isInFieldset) {
|
|
3804
|
-
fieldsetContextFunctions.updateField(fieldContextID, {
|
|
3910
|
+
fieldsetContextFunctions.updateField(fieldContextID, {
|
|
3911
|
+
value: processedValue,
|
|
3912
|
+
});
|
|
3805
3913
|
}
|
|
3806
3914
|
else {
|
|
3807
|
-
formContextFunctions.updateField(fieldContextID, {
|
|
3915
|
+
formContextFunctions.updateField(fieldContextID, {
|
|
3916
|
+
value: processedValue,
|
|
3917
|
+
});
|
|
3808
3918
|
}
|
|
3809
3919
|
onBlur?.(e);
|
|
3810
3920
|
};
|
|
3811
3921
|
const restFieldProps = fieldProps
|
|
3812
|
-
? Object.fromEntries(Object.entries(fieldProps).filter(([key]) => key !==
|
|
3922
|
+
? Object.fromEntries(Object.entries(fieldProps).filter(([key]) => key !== "className"))
|
|
3813
3923
|
: {};
|
|
3814
3924
|
const restLabelProps = labelProps
|
|
3815
|
-
? Object.fromEntries(Object.entries(labelProps).filter(([key]) => key !==
|
|
3925
|
+
? Object.fromEntries(Object.entries(labelProps).filter(([key]) => key !== "className"))
|
|
3816
3926
|
: {};
|
|
3817
3927
|
const restDescriptionProps = descriptionProps
|
|
3818
|
-
? Object.fromEntries(Object.entries(descriptionProps).filter(([key]) => key !==
|
|
3928
|
+
? Object.fromEntries(Object.entries(descriptionProps).filter(([key]) => key !== "className"))
|
|
3819
3929
|
: {};
|
|
3820
|
-
return (jsxs(Field, { ...restFieldProps, className: bag => twMerge(
|
|
3930
|
+
return (jsxs(Field, { ...restFieldProps, className: (bag) => twMerge("grid gap-1", typeof fieldProps?.className === "function"
|
|
3931
|
+
? fieldProps?.className(bag)
|
|
3932
|
+
: 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"
|
|
3933
|
+
? labelProps?.className(bag)
|
|
3934
|
+
: labelProps?.className), children: label })), jsxs("div", { children: [jsx(Input$1, { ...props, className: (bag) => twMerge(
|
|
3821
3935
|
// Base styles
|
|
3822
|
-
|
|
3936
|
+
"w-full rounded-xl border 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",
|
|
3823
3937
|
// Pseudo styles
|
|
3824
|
-
|
|
3938
|
+
"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",
|
|
3825
3939
|
// user-invalid styles
|
|
3826
|
-
|
|
3940
|
+
"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))]",
|
|
3827
3941
|
// Custom styles
|
|
3828
|
-
typeof className ===
|
|
3942
|
+
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"
|
|
3829
3943
|
? descriptionProps?.className(bag)
|
|
3830
3944
|
: descriptionProps?.className), children: description }))] }));
|
|
3831
3945
|
}
|
|
@@ -4336,12 +4450,14 @@ const MAX_PROGRESS = 100;
|
|
|
4336
4450
|
function Video({ autoPlay, className, controls = true, poster, ref, srcSet, title, ...props }) {
|
|
4337
4451
|
// * General/Core
|
|
4338
4452
|
const uniqueID = useId(), figureRef = useRef(null), videoPlayerRef = useRef(null), sortedSrcSet = srcSet.sort((a, b) => a.width - b.width);
|
|
4339
|
-
const primaryPoster = poster
|
|
4340
|
-
|
|
4453
|
+
const primaryPoster = poster
|
|
4454
|
+
? poster.find(({ primary }) => primary)?.src || poster[0].src
|
|
4455
|
+
: "";
|
|
4456
|
+
const preventDefaultEvent = (e) => e.preventDefault();
|
|
4341
4457
|
// * Play/Pause Controls
|
|
4342
4458
|
const [isPlaying, setIsPlaying] = useState(autoPlay);
|
|
4343
4459
|
const togglePlay = useCallback(() => {
|
|
4344
|
-
setIsPlaying(previous => {
|
|
4460
|
+
setIsPlaying((previous) => {
|
|
4345
4461
|
if (!previous)
|
|
4346
4462
|
videoPlayerRef.current?.play();
|
|
4347
4463
|
if (previous)
|
|
@@ -4372,22 +4488,25 @@ function Video({ autoPlay, className, controls = true, poster, ref, srcSet, titl
|
|
|
4372
4488
|
}, []);
|
|
4373
4489
|
const enterPictureInPicture = () => videoPlayerRef.current?.requestPictureInPicture();
|
|
4374
4490
|
useEffect(() => {
|
|
4375
|
-
if (typeof window ===
|
|
4491
|
+
if (typeof window === "undefined")
|
|
4376
4492
|
return;
|
|
4377
|
-
document.addEventListener(
|
|
4493
|
+
document.addEventListener("fullscreenchange", updateFullscreenState);
|
|
4378
4494
|
return () => {
|
|
4379
|
-
document.removeEventListener(
|
|
4495
|
+
document.removeEventListener("fullscreenchange", updateFullscreenState);
|
|
4380
4496
|
};
|
|
4381
4497
|
}, []);
|
|
4382
4498
|
// * Progress/Seeking Controls
|
|
4383
|
-
const [progress, setProgress] = useState(0), trackProgressStartTimeRef = useRef(0), [seekIndicator, setSeekIndicator] = useState({
|
|
4499
|
+
const [progress, setProgress] = useState(0), trackProgressStartTimeRef = useRef(0), [seekIndicator, setSeekIndicator] = useState({
|
|
4500
|
+
isInPlayedArea: false,
|
|
4501
|
+
position: 0,
|
|
4502
|
+
}), seekIndicatorMouseDownPositionRef = useRef(0), scrubberRef = useRef(null), [timeRemaining, setTimeRemaining] = useState(0);
|
|
4384
4503
|
const handleTimeUpdate = () => {
|
|
4385
4504
|
const videoPlayer = videoPlayerRef.current;
|
|
4386
4505
|
if (!videoPlayer)
|
|
4387
4506
|
return;
|
|
4388
4507
|
const { currentTime, duration } = videoPlayer;
|
|
4389
4508
|
const newProgress = (currentTime / duration) * 100;
|
|
4390
|
-
setProgress(prev => (Math.abs(prev - newProgress) > 0.1 ? newProgress : prev));
|
|
4509
|
+
setProgress((prev) => (Math.abs(prev - newProgress) > 0.1 ? newProgress : prev));
|
|
4391
4510
|
setTimeRemaining(duration - currentTime);
|
|
4392
4511
|
};
|
|
4393
4512
|
const handleProgressSlider = ({ x }) => {
|
|
@@ -4397,7 +4516,9 @@ function Video({ autoPlay, className, controls = true, poster, ref, srcSet, titl
|
|
|
4397
4516
|
const { duration } = videoPlayer, { width } = scrubber.getBoundingClientRect();
|
|
4398
4517
|
videoPlayer.fastSeek(Math.max(Math.min(trackProgressStartTimeRef.current + x / (width / duration), duration - 1), 0));
|
|
4399
4518
|
};
|
|
4400
|
-
const { trackPointerMovement: trackProgress } = usePointerMovement({
|
|
4519
|
+
const { trackPointerMovement: trackProgress } = usePointerMovement({
|
|
4520
|
+
onChange: handleProgressSlider,
|
|
4521
|
+
});
|
|
4401
4522
|
const initiateTrackProgress = (e) => {
|
|
4402
4523
|
const videoPlayer = videoPlayerRef.current;
|
|
4403
4524
|
if (!videoPlayer)
|
|
@@ -4405,7 +4526,7 @@ function Video({ autoPlay, className, controls = true, poster, ref, srcSet, titl
|
|
|
4405
4526
|
trackProgress(e);
|
|
4406
4527
|
trackProgressStartTimeRef.current = videoPlayer.currentTime;
|
|
4407
4528
|
};
|
|
4408
|
-
const handleSeekIndicatorMovement = e => {
|
|
4529
|
+
const handleSeekIndicatorMovement = (e) => {
|
|
4409
4530
|
const videoPlayer = videoPlayerRef.current;
|
|
4410
4531
|
if (!videoPlayer)
|
|
4411
4532
|
return;
|
|
@@ -4416,30 +4537,33 @@ function Video({ autoPlay, className, controls = true, poster, ref, srcSet, titl
|
|
|
4416
4537
|
setSeekIndicator({ isInPlayedArea, position });
|
|
4417
4538
|
};
|
|
4418
4539
|
const initializeSeeking = () => (seekIndicatorMouseDownPositionRef.current = seekIndicator.position);
|
|
4419
|
-
const handleSeekRelease = e => {
|
|
4540
|
+
const handleSeekRelease = (e) => {
|
|
4420
4541
|
const videoPlayer = videoPlayerRef.current;
|
|
4421
4542
|
if (!videoPlayer)
|
|
4422
4543
|
return;
|
|
4423
4544
|
const { duration } = videoPlayer, { currentTarget } = e, { width } = currentTarget.getBoundingClientRect();
|
|
4424
|
-
if (seekIndicatorMouseDownPositionRef.current === seekIndicator.position)
|
|
4545
|
+
if (seekIndicatorMouseDownPositionRef.current === seekIndicator.position) {
|
|
4425
4546
|
videoPlayer.fastSeek(Math.min(duration / (width / seekIndicatorMouseDownPositionRef.current), duration - 1));
|
|
4547
|
+
}
|
|
4426
4548
|
};
|
|
4427
4549
|
// * Skip Controls
|
|
4428
4550
|
const [skipDuration, setSkipDuration] = useState(10);
|
|
4429
4551
|
const getSkipAmount = () => {
|
|
4430
4552
|
const modifierKeyList = pressedKeyListRef.current;
|
|
4431
4553
|
let skipAmount = 10;
|
|
4432
|
-
if (modifierKeyList.includes(
|
|
4554
|
+
if (modifierKeyList.includes("alt")) {
|
|
4433
4555
|
if (modifierKeyList.length === 1)
|
|
4434
4556
|
skipAmount = 15;
|
|
4435
|
-
if (modifierKeyList.includes(
|
|
4557
|
+
if (modifierKeyList.includes("shift"))
|
|
4436
4558
|
skipAmount = 30;
|
|
4437
|
-
if (modifierKeyList.includes(
|
|
4559
|
+
if (modifierKeyList.includes("meta"))
|
|
4438
4560
|
skipAmount = 5;
|
|
4439
|
-
if (modifierKeyList.includes(
|
|
4561
|
+
if (modifierKeyList.includes("shift") && modifierKeyList.includes("meta"))
|
|
4440
4562
|
skipAmount = 60;
|
|
4441
|
-
if (modifierKeyList.includes(
|
|
4563
|
+
if (modifierKeyList.includes("shift") && modifierKeyList.includes("meta") &&
|
|
4564
|
+
modifierKeyList.includes("ctrl")) {
|
|
4442
4565
|
skipAmount = 90;
|
|
4566
|
+
}
|
|
4443
4567
|
}
|
|
4444
4568
|
if (skipAmount !== skipDuration)
|
|
4445
4569
|
setSkipDuration(skipAmount);
|
|
@@ -4463,7 +4587,7 @@ function Video({ autoPlay, className, controls = true, poster, ref, srcSet, titl
|
|
|
4463
4587
|
}, []);
|
|
4464
4588
|
// * Volume Controls
|
|
4465
4589
|
const [volume, setVolume] = useState(1), trackVolumeStartRef = useRef(0);
|
|
4466
|
-
const handleVolumeChange = e => {
|
|
4590
|
+
const handleVolumeChange = (e) => {
|
|
4467
4591
|
const { currentTarget } = e, { volume } = currentTarget;
|
|
4468
4592
|
setVolume(volume);
|
|
4469
4593
|
};
|
|
@@ -4473,7 +4597,9 @@ function Video({ autoPlay, className, controls = true, poster, ref, srcSet, titl
|
|
|
4473
4597
|
return;
|
|
4474
4598
|
videoPlayer.volume = Math.max(Math.min(trackVolumeStartRef.current + (y / 96) * -1, 1), 0);
|
|
4475
4599
|
};
|
|
4476
|
-
const { trackPointerMovement: trackVolume } = usePointerMovement({
|
|
4600
|
+
const { trackPointerMovement: trackVolume } = usePointerMovement({
|
|
4601
|
+
onChange: handleVolumeSlider,
|
|
4602
|
+
});
|
|
4477
4603
|
const initiateTrackVolume = (e) => {
|
|
4478
4604
|
const videoPlayer = videoPlayerRef.current;
|
|
4479
4605
|
if (!videoPlayer)
|
|
@@ -4512,23 +4638,23 @@ function Video({ autoPlay, className, controls = true, poster, ref, srcSet, titl
|
|
|
4512
4638
|
// * Keyboard Controls
|
|
4513
4639
|
const pressedKeyListRef = useRef([]), [pressedKeyList, setPressedKeyList] = useState([]);
|
|
4514
4640
|
const updateModifierKeys = useCallback(({ metaKey, altKey, shiftKey, ctrlKey, }) => {
|
|
4515
|
-
if ((metaKey && !pressedKeyListRef.current.includes(
|
|
4516
|
-
(altKey && !pressedKeyListRef.current.includes(
|
|
4517
|
-
(shiftKey && !pressedKeyListRef.current.includes(
|
|
4518
|
-
(ctrlKey && !pressedKeyListRef.current.includes(
|
|
4519
|
-
(!metaKey && pressedKeyListRef.current.includes(
|
|
4520
|
-
(!altKey && pressedKeyListRef.current.includes(
|
|
4521
|
-
(!shiftKey && pressedKeyListRef.current.includes(
|
|
4522
|
-
(!ctrlKey && pressedKeyListRef.current.includes(
|
|
4641
|
+
if ((metaKey && !pressedKeyListRef.current.includes("meta")) ||
|
|
4642
|
+
(altKey && !pressedKeyListRef.current.includes("alt")) ||
|
|
4643
|
+
(shiftKey && !pressedKeyListRef.current.includes("shift")) ||
|
|
4644
|
+
(ctrlKey && !pressedKeyListRef.current.includes("ctrl")) ||
|
|
4645
|
+
(!metaKey && pressedKeyListRef.current.includes("meta")) ||
|
|
4646
|
+
(!altKey && pressedKeyListRef.current.includes("alt")) ||
|
|
4647
|
+
(!shiftKey && pressedKeyListRef.current.includes("shift")) ||
|
|
4648
|
+
(!ctrlKey && pressedKeyListRef.current.includes("ctrl"))) {
|
|
4523
4649
|
const newPressedKeyList = [];
|
|
4524
4650
|
if (metaKey)
|
|
4525
|
-
newPressedKeyList.push(
|
|
4651
|
+
newPressedKeyList.push("meta");
|
|
4526
4652
|
if (altKey)
|
|
4527
|
-
newPressedKeyList.push(
|
|
4653
|
+
newPressedKeyList.push("alt");
|
|
4528
4654
|
if (shiftKey)
|
|
4529
|
-
newPressedKeyList.push(
|
|
4655
|
+
newPressedKeyList.push("shift");
|
|
4530
4656
|
if (ctrlKey)
|
|
4531
|
-
newPressedKeyList.push(
|
|
4657
|
+
newPressedKeyList.push("ctrl");
|
|
4532
4658
|
setPressedKeyList(newPressedKeyList);
|
|
4533
4659
|
pressedKeyListRef.current = newPressedKeyList;
|
|
4534
4660
|
getSkipAmount();
|
|
@@ -4537,27 +4663,29 @@ function Video({ autoPlay, className, controls = true, poster, ref, srcSet, titl
|
|
|
4537
4663
|
const handleKeydown = useCallback((e) => {
|
|
4538
4664
|
const { key, metaKey, altKey, shiftKey, ctrlKey } = e;
|
|
4539
4665
|
updateModifierKeys({ metaKey, altKey, shiftKey, ctrlKey });
|
|
4540
|
-
if (![
|
|
4666
|
+
if (![" ", "ArrowRight", "ArrowLeft", "ArrowUp", "ArrowDown", "f"].includes(key))
|
|
4541
4667
|
return;
|
|
4542
|
-
if ([
|
|
4668
|
+
if ([" ", "ArrowUp", "ArrowDown", "f"].includes(key) && !metaKey &&
|
|
4669
|
+
!altKey && !shiftKey && !ctrlKey) {
|
|
4543
4670
|
e.preventDefault();
|
|
4671
|
+
}
|
|
4544
4672
|
switch (key) {
|
|
4545
|
-
case
|
|
4673
|
+
case " ":
|
|
4546
4674
|
togglePlay();
|
|
4547
4675
|
break;
|
|
4548
|
-
case
|
|
4676
|
+
case "ArrowRight":
|
|
4549
4677
|
skipForward();
|
|
4550
4678
|
break;
|
|
4551
|
-
case
|
|
4679
|
+
case "ArrowLeft":
|
|
4552
4680
|
skipBack();
|
|
4553
4681
|
break;
|
|
4554
|
-
case
|
|
4682
|
+
case "ArrowUp":
|
|
4555
4683
|
increaseVolume();
|
|
4556
4684
|
break;
|
|
4557
|
-
case
|
|
4685
|
+
case "ArrowDown":
|
|
4558
4686
|
decreaseVolume();
|
|
4559
4687
|
break;
|
|
4560
|
-
case
|
|
4688
|
+
case "f":
|
|
4561
4689
|
requestFullscreen();
|
|
4562
4690
|
break;
|
|
4563
4691
|
}
|
|
@@ -4567,11 +4695,11 @@ function Video({ autoPlay, className, controls = true, poster, ref, srcSet, titl
|
|
|
4567
4695
|
updateModifierKeys({ metaKey, altKey, shiftKey, ctrlKey });
|
|
4568
4696
|
}, [updateModifierKeys]);
|
|
4569
4697
|
useEffect(() => {
|
|
4570
|
-
if (typeof window ===
|
|
4698
|
+
if (typeof window === "undefined")
|
|
4571
4699
|
return;
|
|
4572
4700
|
const controller = new AbortController(), signal = controller.signal;
|
|
4573
|
-
document.addEventListener(
|
|
4574
|
-
document.addEventListener(
|
|
4701
|
+
document.addEventListener("keydown", handleKeydown, { signal });
|
|
4702
|
+
document.addEventListener("keyup", handleKeyup, { signal });
|
|
4575
4703
|
return () => {
|
|
4576
4704
|
controller.abort();
|
|
4577
4705
|
};
|
|
@@ -4581,22 +4709,25 @@ function Video({ autoPlay, className, controls = true, poster, ref, srcSet, titl
|
|
|
4581
4709
|
// * Progressive Enhancement
|
|
4582
4710
|
const progressiveEnhancementSourceLengthRef = useRef(1);
|
|
4583
4711
|
const [progressiveEnhancementList, setProgressiveEnhancementList] = useState(sortedSrcSet.filter((_, index) => index < progressiveEnhancementSourceLengthRef.current));
|
|
4584
|
-
const handleProEnhance = e => {
|
|
4712
|
+
const handleProEnhance = (e) => {
|
|
4585
4713
|
const { currentTarget } = e, { currentSrc, currentTime } = currentTarget;
|
|
4586
|
-
const proEnhanceSrcLength = progressiveEnhancementSourceLengthRef.current +
|
|
4714
|
+
const proEnhanceSrcLength = progressiveEnhancementSourceLengthRef.current +
|
|
4715
|
+
1, updatedProEnhanceList = sortedSrcSet.filter((_, index) => index < proEnhanceSrcLength);
|
|
4587
4716
|
console.log(updatedProEnhanceList);
|
|
4588
4717
|
setProgressiveEnhancementList(updatedProEnhanceList);
|
|
4589
4718
|
progressiveEnhancementSourceLengthRef.current = proEnhanceSrcLength;
|
|
4590
|
-
const srcToCompare = typeof updatedProEnhanceList.at(-1)?.src ===
|
|
4719
|
+
const srcToCompare = typeof updatedProEnhanceList.at(-1)?.src === "string"
|
|
4591
4720
|
? updatedProEnhanceList.at(-1)?.src
|
|
4592
4721
|
: updatedProEnhanceList.at(-1)?.srcGroup;
|
|
4593
4722
|
if (!srcToCompare)
|
|
4594
4723
|
return;
|
|
4595
|
-
if ((Array.isArray(srcToCompare) &&
|
|
4724
|
+
if ((Array.isArray(srcToCompare) &&
|
|
4725
|
+
srcToCompare.every(({ src }) => src !== currentSrc)) ||
|
|
4596
4726
|
(!Array.isArray(srcToCompare) && srcToCompare !== currentSrc)) {
|
|
4597
|
-
const srcType = currentSrc.split(
|
|
4727
|
+
const srcType = currentSrc.split(".").at(-1);
|
|
4598
4728
|
const src = Array.isArray(srcToCompare)
|
|
4599
|
-
? srcToCompare.find(({ src }) => src.split(
|
|
4729
|
+
? srcToCompare.find(({ src }) => src.split(".").at(-1) === srcType)
|
|
4730
|
+
?.src || srcToCompare[0].src
|
|
4600
4731
|
: srcToCompare;
|
|
4601
4732
|
if (!src)
|
|
4602
4733
|
return;
|
|
@@ -4611,50 +4742,60 @@ function Video({ autoPlay, className, controls = true, poster, ref, srcSet, titl
|
|
|
4611
4742
|
if (!videoPlayer)
|
|
4612
4743
|
return;
|
|
4613
4744
|
const { videoHeight, videoWidth } = videoPlayer;
|
|
4614
|
-
const canvas = document.createElement(
|
|
4745
|
+
const canvas = document.createElement("canvas"), canvasContext = canvas.getContext("2d");
|
|
4615
4746
|
if (!canvasContext)
|
|
4616
4747
|
return;
|
|
4617
4748
|
canvas.width = videoWidth;
|
|
4618
4749
|
canvas.height = videoHeight;
|
|
4619
4750
|
canvasContext.drawImage(videoPlayer, 0, 0, canvas.width, canvas.height);
|
|
4620
|
-
canvas.toBlob(blob => {
|
|
4751
|
+
canvas.toBlob((blob) => {
|
|
4621
4752
|
if (!blob)
|
|
4622
4753
|
return;
|
|
4623
|
-
const url = URL.createObjectURL(blob), link = document.createElement(
|
|
4754
|
+
const url = URL.createObjectURL(blob), link = document.createElement("a");
|
|
4624
4755
|
link.href = url;
|
|
4625
4756
|
link.download = `${title}-frame-${Date.now()}.jpg`;
|
|
4626
4757
|
document.body.appendChild(link);
|
|
4627
4758
|
link.click();
|
|
4628
4759
|
document.body.removeChild(link);
|
|
4629
4760
|
URL.revokeObjectURL(url);
|
|
4630
|
-
},
|
|
4761
|
+
}, "image/jpeg", 0.9);
|
|
4631
4762
|
};
|
|
4632
|
-
return (jsxs("figure", { ...(showControls ? {
|
|
4763
|
+
return (jsxs("figure", { ...(showControls ? { "data-controls": true } : {}), ...(isFullscreen ? { "data-fullscreen": true } : {}), ...(isPlaying ? { "data-playing": true } : {}), ...Object.fromEntries(pressedKeyList.map((key) => [`data-${key}`, true])), className: twMerge("group/video isolate aspect-video w-full overflow-clip", className), onMouseEnter: displayControls, onMouseLeave: hideControls, ref: figureRef, children: [jsx("video", { ...props, className: "size-full object-cover", onLoad: handleProEnhance, onTimeUpdate: handleTimeUpdate, onVolumeChange: handleVolumeChange, poster: primaryPoster, ref: videoPlayerRef || ref, title: title, children: progressiveEnhancementList.map(({ width, ...source }) => {
|
|
4633
4764
|
if (source.srcGroup) {
|
|
4634
4765
|
const { srcGroup } = source;
|
|
4635
4766
|
return srcGroup.map(({ src, type }) => (jsx("source", { src: src, type: type }, `${title}${type}${width}${uniqueID}`)));
|
|
4636
4767
|
}
|
|
4637
4768
|
const { src, type } = source;
|
|
4638
|
-
return jsx("source", { src: src, type: type }, `${title}${type}${width}${uniqueID}`);
|
|
4639
|
-
}) }), controls && (jsxs("div", { className:
|
|
4769
|
+
return (jsx("source", { src: src, type: type }, `${title}${type}${width}${uniqueID}`));
|
|
4770
|
+
}) }), controls && (jsxs("div", { className: "absolute inset-0 isolate text-neutral-50 opacity-0 transition-opacity duration-1000 ease-exponential select-none group-data-controls/video:opacity-100", children: [jsxs("div", { className: "grid-flow-cols absolute top-1/2 left-1/2 grid -translate-x-1/2 -translate-y-1/2 place-items-center gap-2", children: [jsxs("button", { className: "col-start-1 col-end-2 row-start-0 row-end-1 grid size-16 rounded-full backdrop-blur-[1px] backdrop-brightness-101 transition-[scale,-webkit-backdrop-filter,backdrop-filter] duration-300 ease-exponential active:scale-95 active:backdrop-blur-[2px] active:backdrop-brightness-125 pointer-fine:hover:scale-105 pointer-fine:hover:backdrop-blur-xs pointer-fine:hover:backdrop-brightness-110 pointer-fine:active:scale-95 pointer-fine:active:backdrop-blur-[2px] pointer-fine:active:backdrop-brightness-125", onClick: togglePlay, onContextMenu: preventDefaultEvent, title: isPlaying ? "Pause" : "Play", children: [jsx(PauseFill, { className: "col-start-0 col-end-1 row-start-0 row-end-1 size-full scale-0 opacity-0 drop-shadow-[0_.25rem_2rem] drop-shadow-neutral-950/75 transition-[scale,opacity] duration-500 ease-exponential group-data-playing/video:scale-60 group-data-playing/video:opacity-100" }), jsx(PlayFill, { className: "-right-0.5 col-start-0 col-end-1 row-start-0 row-end-1 size-full scale-60 drop-shadow-[0_.25rem_2rem] drop-shadow-neutral-950/75 transition-[scale,opacity] duration-500 ease-exponential group-data-playing/video:scale-0 group-data-playing/video:opacity-0" })] }), jsxs("button", { className: "col-start-0 col-end-1 row-start-0 row-end-1 grid size-12 rounded-full backdrop-blur-[1px] backdrop-brightness-101 transition-[scale,-webkit-backdrop-filter,backdrop-filter] duration-300 ease-exponential active:scale-95 active:backdrop-blur-[2px] active:backdrop-brightness-125 pointer-fine:hover:scale-105 pointer-fine:hover:backdrop-blur-xs pointer-fine:hover:backdrop-brightness-110 pointer-fine:active:scale-95 pointer-fine:active:backdrop-blur-[2px] pointer-fine:active:backdrop-brightness-125", onClick: skipBack, onContextMenu: preventDefaultEvent, title: `Skip Back ${skipDuration} Seconds`, children: [jsx(FiveArrowTriangleheadCounterclockwise, { className: "col-start-0 col-end-1 row-start-0 row-end-1 size-full scale-60 opacity-0 drop-shadow-[0_.25rem_2rem] drop-shadow-neutral-950/75 group-data-alt/video:group-data-meta/video:opacity-100 group-data-alt/video:group-data-meta/video:group-data-ctrl/video:opacity-0 group-data-alt/video:group-data-meta/video:group-data-shift/video:opacity-0" }), jsx(TenArrowTriangleheadCounterclockwise, { className: "col-start-0 col-end-1 row-start-0 row-end-1 size-full scale-60 drop-shadow-[0_.25rem_2rem] drop-shadow-neutral-950/75 group-data-alt/video:opacity-0 group-data-alt/video:group-data-ctrl/video:opacity-100 group-data-alt/video:group-data-shift/video:group-data-meta/video:group-data-ctrl/video:opacity-0" }), jsx(FifteenArrowTriangleheadCounterclockwise, { className: "col-start-0 col-end-1 row-start-0 row-end-1 size-full scale-60 opacity-0 drop-shadow-[0_.25rem_2rem] drop-shadow-neutral-950/75 group-data-alt/video:opacity-100 group-data-ctrl/video:opacity-0 group-data-meta/video:opacity-0 group-data-shift/video:opacity-0" }), jsx(ThirtyArrowTriangleheadCounterclockwise, { className: "col-start-0 col-end-1 row-start-0 row-end-1 size-full scale-60 opacity-0 drop-shadow-[0_.25rem_2rem] drop-shadow-neutral-950/75 group-data-alt/video:group-data-shift/video:opacity-100 group-data-alt/video:group-data-ctrl/video:group-data-shift/video:opacity-0 group-data-alt/video:group-data-meta/video:group-data-shift/video:opacity-0" }), jsx(SixtyArrowTriangleheadCounterclockwise, { className: "col-start-0 col-end-1 row-start-0 row-end-1 size-full scale-60 opacity-0 drop-shadow-[0_.25rem_2rem] drop-shadow-neutral-950/75 group-data-alt/video:group-data-shift/video:group-data-meta/video:opacity-100 group-data-alt/video:group-data-shift/video:group-data-meta/video:group-data-ctrl/video:opacity-0" }), jsx(NinetyArrowTriangleheadCounterclockwise, { className: "col-start-0 col-end-1 row-start-0 row-end-1 size-full scale-60 opacity-0 drop-shadow-[0_.25rem_2rem] drop-shadow-neutral-950/75 group-data-alt/video:group-data-shift/video:group-data-meta/video:group-data-ctrl/video:opacity-100" })] }), jsxs("button", { className: "col-start-2 col-end-3 row-start-0 row-end-1 grid size-12 rounded-full backdrop-blur-[1px] backdrop-brightness-101 transition-[scale,-webkit-backdrop-filter,backdrop-filter] duration-300 ease-exponential active:scale-95 active:backdrop-blur-[2px] active:backdrop-brightness-125 pointer-fine:hover:scale-105 pointer-fine:hover:backdrop-blur-xs pointer-fine:hover:backdrop-brightness-110 pointer-fine:active:scale-95 pointer-fine:active:backdrop-blur-[2px] pointer-fine:active:backdrop-brightness-125", onClick: skipForward, onContextMenu: preventDefaultEvent, title: `Skip Forward ${skipDuration} Seconds`, children: [jsx(FiveArrowTriangleheadClockwise, { className: "col-start-0 col-end-1 row-start-0 row-end-1 size-full scale-60 opacity-0 drop-shadow-[0_.25rem_2rem] drop-shadow-neutral-950/75 group-data-alt/video:group-data-meta/video:opacity-100 group-data-alt/video:group-data-meta/video:group-data-ctrl/video:opacity-0 group-data-alt/video:group-data-meta/video:group-data-shift/video:opacity-0" }), jsx(TenArrowTriangleheadClockwise, { className: "col-start-0 col-end-1 row-start-0 row-end-1 size-full scale-60 drop-shadow-[0_.25rem_2rem] drop-shadow-neutral-950/75 group-data-alt/video:opacity-0 group-data-alt/video:group-data-ctrl/video:opacity-100 group-data-alt/video:group-data-shift/video:group-data-meta/video:group-data-ctrl/video:opacity-0" }), jsx(FifteenArrowTriangleheadClockwise, { className: "col-start-0 col-end-1 row-start-0 row-end-1 size-full scale-60 opacity-0 drop-shadow-[0_.25rem_2rem] drop-shadow-neutral-950/75 group-data-alt/video:opacity-100 group-data-ctrl/video:opacity-0 group-data-meta/video:opacity-0 group-data-shift/video:opacity-0" }), jsx(ThirtyArrowTriangleheadClockwise, { className: "col-start-0 col-end-1 row-start-0 row-end-1 size-full scale-60 opacity-0 drop-shadow-[0_.25rem_2rem] drop-shadow-neutral-950/75 group-data-alt/video:group-data-shift/video:opacity-100 group-data-alt/video:group-data-ctrl/video:group-data-shift/video:opacity-0 group-data-alt/video:group-data-meta/video:group-data-shift/video:opacity-0" }), jsx(SixtyArrowTriangleheadClockwise, { className: "col-start-0 col-end-1 row-start-0 row-end-1 size-full scale-60 opacity-0 drop-shadow-[0_.25rem_2rem] drop-shadow-neutral-950/75 group-data-alt/video:group-data-shift/video:group-data-meta/video:opacity-100 group-data-alt/video:group-data-shift/video:group-data-meta/video:group-data-ctrl/video:opacity-0" }), jsx(NinetyArrowTriangleheadClockwise, { className: "col-start-0 col-end-1 row-start-0 row-end-1 size-full scale-60 opacity-0 drop-shadow-[0_.25rem_2rem] drop-shadow-neutral-950/75 group-data-alt/video:group-data-shift/video:group-data-meta/video:group-data-ctrl/video:opacity-100" })] })] }), jsxs("div", { className: "absolute inset-x-2 bottom-2 flex items-center gap-2 rounded-xl bg-neutral-900/50 px-2 py-1 shadow-2xl backdrop-blur-xs backdrop-brightness-110", children: [jsxs("div", { className: "group/scrubber h-2 w-max grow cursor-grab overflow-clip rounded-md bg-neutral-50/50 backdrop-blur-xs backdrop-brightness-110 transition-[height] duration-300 ease-exponential active:h-4 pointer-fine:hover:h-4 pointer-fine:active:h-4", onMouseDown: (e) => {
|
|
4640
4771
|
initiateTrackProgress(e);
|
|
4641
4772
|
initializeSeeking();
|
|
4642
|
-
}, onMouseMove: handleSeekIndicatorMovement, onMouseUp: handleSeekRelease, onTouchStart: initiateTrackProgress, ref: scrubberRef, children: [jsx("div", { "aria-hidden":
|
|
4773
|
+
}, onMouseMove: handleSeekIndicatorMovement, onMouseUp: handleSeekRelease, onTouchStart: initiateTrackProgress, ref: scrubberRef, children: [jsx("div", { "aria-hidden": "true", className: "absolute inset-0 grid transition-cols duration-100 ease-linear", style: { gridTemplateColumns: `${progress / MAX_PROGRESS}fr` }, children: jsx("div", { className: "overflow-hidden", children: jsxs("div", { className: "h-full bg-neutral-50/70 text-[1px] text-transparent backdrop-blur-xs backdrop-brightness-125", children: [progress, "/", MAX_PROGRESS] }) }) }), jsx("div", { ...(seekIndicator.isInPlayedArea
|
|
4774
|
+
? { "data-in-played-area": true }
|
|
4775
|
+
: {}), "aria-hidden": "true", className: "absolute inset-y-0 w-1 cursor-grab bg-neutral-50 opacity-0 transition-opacity duration-300 ease-exponential group-hover/scrubber:opacity-100 data-in-played-area:bg-neutral-500 pointer-coarse:hidden", style: { transform: `translateX(${seekIndicator.position}px)` }, children: "\u00A0" }), jsx("progress", { className: "sr-only", max: MAX_PROGRESS, value: progress })] }), jsx("span", { className: "block text-xs", children: timeRemaining / 60 >= 1
|
|
4643
4776
|
? `${Math.round(timeRemaining / 60)}:${Math.round((timeRemaining / 60 - Math.round(timeRemaining / 60)) * 60)
|
|
4644
4777
|
.toString()
|
|
4645
|
-
.padStart(2,
|
|
4778
|
+
.padStart(2, "0")}`
|
|
4646
4779
|
: Math.round(timeRemaining) === 60
|
|
4647
4780
|
? `1:00`
|
|
4648
|
-
: `0:${Math.round(timeRemaining).toString().padStart(2,
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4781
|
+
: `0:${Math.round(timeRemaining).toString().padStart(2, "0")}` }), jsxs(DropDown, { children: [jsx(DropDownButton, { arrow: false, className: "group/button flex size-6 items-center justify-center rounded-xs transition-transform duration-300 ease-exponential active:scale-95 pointer-fine:hover:scale-105 pointer-fine:active:scale-95", title: "Volume", children: jsxs("svg", { viewBox: "0 0 64 47", className: "size-full scale-80 drop-shadow-[0_.125rem_1rem] drop-shadow-neutral-950/75 transition-transform duration-300 ease-exponential", style: {
|
|
4782
|
+
translate: `${volume > 0.66
|
|
4783
|
+
? "0"
|
|
4784
|
+
: volume > 0.33
|
|
4785
|
+
? "2px"
|
|
4786
|
+
: volume > 0
|
|
4787
|
+
? "4px"
|
|
4788
|
+
: "6px"} 0`,
|
|
4789
|
+
}, children: [jsx("path", { d: "M25.707,44.076C27.257,44.076 28.39,42.947 28.39,41.387L28.39,4.841C28.39,3.307 27.257,2.025 25.656,2.025C24.542,2.025 23.767,2.512 22.558,3.666L12.393,13.203C12.251,13.345 12.047,13.436 11.818,13.436L4.99,13.436C1.759,13.436 0,15.195 0,18.654L0,27.525C0,30.953 1.759,32.737 4.99,32.737L11.818,32.737C12.047,32.737 12.251,32.808 12.393,32.95L22.558,42.583C23.666,43.615 24.593,44.076 25.707,44.076Z" }), jsx("path", { className: "transition-opacity duration-300 ease-exponential", d: "M36.874,33.192C37.684,33.728 38.797,33.566 39.439,32.64C41.265,30.222 42.371,26.683 42.371,23.026C42.371,19.368 41.265,15.855 39.439,13.411C38.797,12.485 37.684,12.323 36.874,12.885C35.923,13.553 35.761,14.721 36.505,15.713C37.901,17.607 38.662,20.249 38.662,23.026C38.662,25.802 37.876,28.419 36.505,30.338C35.786,31.355 35.923,32.498 36.874,33.192Z", style: { opacity: volume > 0 ? 1 : 0 } }), jsx("path", { className: "transition-opacity duration-300 ease-exponential", d: "M45.738,39.394C46.624,39.981 47.712,39.799 48.354,38.868C51.402,34.69 53.208,28.904 53.208,23.026C53.208,17.148 51.427,11.31 48.354,7.183C47.712,6.252 46.624,6.07 45.738,6.657C44.858,7.249 44.701,8.362 45.399,9.354C48.023,13.032 49.499,17.952 49.499,23.026C49.499,28.099 47.972,32.994 45.399,36.697C44.726,37.689 44.858,38.802 45.738,39.394Z", style: { opacity: volume > 0.33 ? 1 : 0 } }), jsx("path", { className: "transition-opacity duration-300 ease-exponential", d: "M54.679,45.708C55.514,46.32 56.683,46.082 57.315,45.121C61.498,39.091 64,31.447 64,23.026C64,14.604 61.422,6.986 57.315,0.93C56.683,-0.056 55.514,-0.269 54.679,0.343C53.804,0.956 53.668,2.079 54.33,3.071C58.012,8.514 60.342,15.379 60.342,23.026C60.342,30.647 58.012,37.562 54.33,42.98C53.668,43.972 53.804,45.095 54.679,45.708Z", style: { opacity: volume > 0.66 ? 1 : 0 } })] }) }), jsxs(DropDownItems, { anchor: {
|
|
4790
|
+
gap: ".5rem",
|
|
4791
|
+
padding: ".375rem",
|
|
4792
|
+
to: "top",
|
|
4793
|
+
}, className: "bg-neutral-900/50 px-1.5 py-1.5 text-neutral-50 backdrop-blur-xs backdrop-brightness-110", children: [jsx(DropDownItem, { as: "button", className: "flex size-6 items-center justify-center rounded-xs transition-transform duration-300 ease-exponential active:scale-95 pointer-fine:hover:scale-105 pointer-fine:active:scale-95", onClick: increaseVolume, title: "Increase volume", children: jsx(SpeakerPlusFill, { className: "size-full scale-80 drop-shadow-[0_.125rem_1rem] drop-shadow-neutral-950/75" }) }), jsx(DropDownSeparator, { "aria-label": "Volume slider", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": volume * 100, className: "mx-auto my-2 h-24 w-2 cursor-grab overflow-clip rounded-md bg-neutral-50/50 backdrop-blur-xs backdrop-brightness-110 transition-[width] duration-300 ease-exponential active:w-4 pointer-fine:hover:w-4 pointer-fine:active:w-4", onMouseDown: initiateTrackVolume, onTouchStart: initiateTrackVolume, role: "slider", children: jsx("div", { "aria-hidden": "true", className: "grid size-full rotate-180 transition-rows duration-300 ease-exponential", style: { gridTemplateRows: `${volume}fr` }, children: jsx("div", { className: "overflow-y-hidden", children: jsxs("div", { className: "size-full bg-neutral-50/70 text-[1px] text-transparent backdrop-blur-xs backdrop-brightness-125", children: [volume * 100, "%"] }) }) }) }), jsx(DropDownItem, { as: "button", className: "flex size-6 items-center justify-center rounded-xs transition-transform duration-300 ease-exponential active:scale-95 pointer-fine:hover:scale-105 pointer-fine:active:scale-95", onClick: decreaseVolume, title: "Decrease volume", children: jsx(SpeakerMinusFill, { className: "size-full scale-80 drop-shadow-[0_.125rem_1rem] drop-shadow-neutral-950/75" }) })] })] }), jsx("button", { className: "flex size-6 items-center justify-center rounded-xs transition-transform duration-300 ease-exponential active:scale-95 pointer-fine:hover:scale-105 pointer-fine:active:scale-95", onClick: enterPictureInPicture, title: "Enter Picture-in-Picture", children: jsx(RectangleFillOnArrowDownForwardTopleadingRectangle, { className: "size-full scale-80 drop-shadow-[0_.125rem_1rem] drop-shadow-neutral-950/75" }) }), jsx("button", { className: "flex size-6 items-center justify-center rounded-xs transition-transform duration-300 ease-exponential active:scale-95 pointer-fine:hover:scale-105 pointer-fine:active:scale-95", onClick: handleRemotePlayback, title: "Remote Playback", children: jsx(RectangleTriangleUp, { className: "size-full scale-80 drop-shadow-[0_.125rem_1rem] drop-shadow-neutral-950/75" }) }), jsxs(DropDown, { children: [jsx(DropDownButton, { arrow: false, className: "flex size-6 items-center justify-center rounded-xs transition-transform duration-300 ease-exponential active:scale-95 pointer-fine:hover:scale-105 pointer-fine:active:scale-95", title: "Other Settings", children: jsx(GearshapeFill, { className: "size-full scale-80 drop-shadow-[0_.125rem_1rem] drop-shadow-neutral-950/75" }) }), jsx(DropDownItems, { anchor: {
|
|
4794
|
+
gap: ".5rem",
|
|
4795
|
+
padding: ".375rem",
|
|
4796
|
+
to: "top end",
|
|
4797
|
+
}, className: "bg-neutral-900/50 px-1.5 py-1.5 text-neutral-50 backdrop-blur-xs backdrop-brightness-110", children: jsxs(DropDownItem, { as: "button", className: "flex items-center gap-2 rounded-lg px-1.5 py-0.5 text-sm drop-shadow-[0_.125rem_1rem] drop-shadow-neutral-950/75 transition-[scale,background-color,color] duration-300 ease-exponential active:scale-95 data-active:bg-neutral-50/90 data-active:text-neutral-950 pointer-fine:hover:scale-105 pointer-fine:active:scale-95", onClick: captureCurrentFrame, children: [jsx(PhotoBadgeArrowDownFill, { className: "size-5" }), "Capture Current Frame"] }) })] }), jsxs("button", { className: "grid size-6 rounded-xs transition-transform duration-300 ease-exponential active:scale-95 pointer-fine:hover:scale-105 pointer-fine:active:scale-95", onClick: toggleFullscreen, title: `${isFullscreen ? "Exit" : "Enter"} Fullscreen`, children: [jsx(ArrowUpForwardAndArrowDownBackwardRectangle, { className: "col-start-0 col-end-1 row-start-0 row-end-1 size-full scale-0 opacity-0 drop-shadow-[0_.125rem_1rem] drop-shadow-neutral-950/75 transition-[scale,opacity] duration-500 ease-exponential group-data-fullscreen/video:scale-80 group-data-fullscreen/video:opacity-100" }), jsx(ArrowDownBackwardAndArrowUpForwardRectangle, { className: "-right-0.5 col-start-0 col-end-1 row-start-0 row-end-1 size-full scale-80 drop-shadow-[0_.125rem_1rem] drop-shadow-neutral-950/75 transition-[scale,opacity] duration-500 ease-exponential group-data-fullscreen/video:scale-0 group-data-fullscreen/video:opacity-0" })] })] }), jsx("div", { "aria-hidden": "true", className: "absolute inset-0 -z-10 text-[1px] text-transparent", onClick: togglePlay, onMouseMove: handleMouseMoveControls, onMouseLeave: clearMouseMoveControlsTimeout, children: isPlaying ? "Pause" : "Play" })] }))] }));
|
|
4798
|
+
}
|
|
4799
|
+
|
|
4800
|
+
export { Anchor, Button, Details, DetailsBody, DetailsSummary, DropDown, DropDownButton, DropDownItem, DropDownItems, DropDownSection, DropDownSeparator, Fieldset, Form, Ghost, Heading, IFrame, Input, Link, Modal, ModalClose, ModalDialog, ModalTitle, ModalTrigger, SubmitButton, Textarea, Time, Tooltip, TooltipPanel, TooltipTrigger, Video, createButton, createLink, getLinkClasses };
|
|
4660
4801
|
//# sourceMappingURL=components.esm.js.map
|