@komensal/ui 0.6.4 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +95 -120
- package/dist/index.js +187 -342
- package/dist/index.js.map +1 -1
- package/dist/locales/index.d.ts +0 -3
- package/dist/locales/index.js +0 -3
- package/dist/locales/index.js.map +1 -1
- package/package.json +7 -8
package/dist/index.js
CHANGED
|
@@ -18,6 +18,9 @@ var inputBase = cn(
|
|
|
18
18
|
);
|
|
19
19
|
var inputPlaceholder = cn("text-icon-muted text-sm font-normal leading-none");
|
|
20
20
|
var inputDisabled = cn("cursor-not-allowed opacity-50");
|
|
21
|
+
var inputCompact = cn(
|
|
22
|
+
"border-border bg-surface text-foreground focus:border-primary focus:ring-ring h-9 w-full rounded-lg border px-2.5 text-sm focus:ring-2 focus:outline-none"
|
|
23
|
+
);
|
|
21
24
|
var inputFocus = cn(
|
|
22
25
|
"focus:outline-none focus-visible:outline-none",
|
|
23
26
|
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:border-primary",
|
|
@@ -28,7 +31,7 @@ var inputFocus = cn(
|
|
|
28
31
|
var emitToast = null;
|
|
29
32
|
var toast = {
|
|
30
33
|
error(options) {
|
|
31
|
-
emit("
|
|
34
|
+
emit("destructive", options);
|
|
32
35
|
},
|
|
33
36
|
info(options) {
|
|
34
37
|
emit("info", options);
|
|
@@ -58,20 +61,20 @@ function emit(type, options) {
|
|
|
58
61
|
// src/components/alert.tsx
|
|
59
62
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
60
63
|
var variantStyles = {
|
|
61
|
-
|
|
64
|
+
destructive: { container: "bg-destructive-subtle text-destructive", icon: "text-destructive" },
|
|
62
65
|
info: { container: "bg-info-subtle text-info", icon: "text-info" },
|
|
63
66
|
success: { container: "bg-success-subtle text-success", icon: "text-success" },
|
|
64
67
|
warning: { container: "bg-warning-subtle text-warning", icon: "text-warning" }
|
|
65
68
|
};
|
|
66
69
|
var variantIcons = {
|
|
67
|
-
|
|
70
|
+
destructive: WarningCircleIcon,
|
|
68
71
|
info: InfoIcon,
|
|
69
72
|
success: CheckCircleIcon,
|
|
70
73
|
warning: WarningIcon
|
|
71
74
|
};
|
|
72
|
-
var Alert = ({ children, className, variant = "
|
|
75
|
+
var Alert = ({ children, className, variant = "destructive", ...props }) => {
|
|
73
76
|
const styles = variantStyles[variant];
|
|
74
|
-
const
|
|
77
|
+
const Icon = variantIcons[variant];
|
|
75
78
|
return /* @__PURE__ */ jsxs(
|
|
76
79
|
"div",
|
|
77
80
|
{
|
|
@@ -84,7 +87,7 @@ var Alert = ({ children, className, variant = "error", ...props }) => {
|
|
|
84
87
|
role: "alert",
|
|
85
88
|
...props,
|
|
86
89
|
children: [
|
|
87
|
-
/* @__PURE__ */ jsx(
|
|
90
|
+
/* @__PURE__ */ jsx(Icon, { className: cn("h-5 w-5 shrink-0", styles.icon) }),
|
|
88
91
|
/* @__PURE__ */ jsx("span", { children })
|
|
89
92
|
]
|
|
90
93
|
}
|
|
@@ -93,13 +96,19 @@ var Alert = ({ children, className, variant = "error", ...props }) => {
|
|
|
93
96
|
|
|
94
97
|
// src/components/auth-header.tsx
|
|
95
98
|
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
96
|
-
var AuthHeader = ({
|
|
99
|
+
var AuthHeader = ({
|
|
100
|
+
children,
|
|
101
|
+
desktopLogoSrc = "/logo_color.svg",
|
|
102
|
+
logoAlt,
|
|
103
|
+
mobileClassName,
|
|
104
|
+
mobileLogoSrc = "/logotipo_color.svg"
|
|
105
|
+
}) => {
|
|
97
106
|
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
98
107
|
/* @__PURE__ */ jsxs2("div", { className: cn("flex min-h-0 shrink flex-col lg:hidden", mobileClassName), children: [
|
|
99
|
-
/* @__PURE__ */ jsx2("div", { className: "flex justify-center py-2", children: /* @__PURE__ */ jsx2("img", { alt: logoAlt, className: "h-11 md:h-12", src:
|
|
108
|
+
/* @__PURE__ */ jsx2("div", { className: "flex justify-center py-2", children: /* @__PURE__ */ jsx2("img", { alt: logoAlt, className: "h-11 md:h-12", src: mobileLogoSrc }) }),
|
|
100
109
|
children
|
|
101
110
|
] }),
|
|
102
|
-
/* @__PURE__ */ jsx2("div", { className: "absolute hidden p-10 lg:flex", children: /* @__PURE__ */ jsx2("img", { alt: logoAlt, className: "h-12.5 w-12.5", src:
|
|
111
|
+
/* @__PURE__ */ jsx2("div", { className: "absolute hidden p-10 lg:flex", children: /* @__PURE__ */ jsx2("img", { alt: logoAlt, className: "h-12.5 w-12.5", src: desktopLogoSrc }) })
|
|
103
112
|
] });
|
|
104
113
|
};
|
|
105
114
|
|
|
@@ -117,9 +126,6 @@ import { initReactI18next, useTranslation } from "react-i18next";
|
|
|
117
126
|
|
|
118
127
|
// src/locales/es/ui.json
|
|
119
128
|
var ui_default = {
|
|
120
|
-
otpField: {
|
|
121
|
-
description: "Se ha enviado un c\xF3digo OTP a tu correo . Revisa tu bandeja de entrada."
|
|
122
|
-
},
|
|
123
129
|
inputField: {
|
|
124
130
|
showPassword: "Mostrar contrase\xF1a",
|
|
125
131
|
hidePassword: "Ocultar contrase\xF1a",
|
|
@@ -477,30 +483,19 @@ CommandShortcut.displayName = "CommandShortcut";
|
|
|
477
483
|
|
|
478
484
|
// src/components/form.tsx
|
|
479
485
|
import { Slot as Slot2 } from "@radix-ui/react-slot";
|
|
480
|
-
import * as React6 from "react";
|
|
481
|
-
import { Controller, FormProvider, useFormContext } from "react-hook-form";
|
|
482
|
-
|
|
483
|
-
// src/components/label.tsx
|
|
484
|
-
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
485
|
-
import { cva as cva2 } from "class-variance-authority";
|
|
486
486
|
import * as React5 from "react";
|
|
487
|
+
import { Controller, FormProvider, useFormContext } from "react-hook-form";
|
|
487
488
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
488
|
-
var labelVariants = cva2("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
489
|
-
var Label = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx8(LabelPrimitive.Root, { className: cn(labelVariants(), className), ref, ...props }));
|
|
490
|
-
Label.displayName = LabelPrimitive.Root.displayName;
|
|
491
|
-
|
|
492
|
-
// src/components/form.tsx
|
|
493
|
-
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
494
489
|
var Form = FormProvider;
|
|
495
|
-
var FormFieldContext =
|
|
490
|
+
var FormFieldContext = React5.createContext(null);
|
|
496
491
|
var FormField = ({
|
|
497
492
|
...props
|
|
498
493
|
}) => {
|
|
499
|
-
return /* @__PURE__ */
|
|
494
|
+
return /* @__PURE__ */ jsx8(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx8(Controller, { ...props }) });
|
|
500
495
|
};
|
|
501
496
|
var useFormField = () => {
|
|
502
|
-
const fieldContext =
|
|
503
|
-
const itemContext =
|
|
497
|
+
const fieldContext = React5.useContext(FormFieldContext);
|
|
498
|
+
const itemContext = React5.useContext(FormItemContext);
|
|
504
499
|
const { formState, getFieldState } = useFormContext();
|
|
505
500
|
if (!fieldContext) {
|
|
506
501
|
throw new Error("useFormField must be used within <FormField>");
|
|
@@ -519,23 +514,18 @@ var useFormField = () => {
|
|
|
519
514
|
...fieldState
|
|
520
515
|
};
|
|
521
516
|
};
|
|
522
|
-
var FormItemContext =
|
|
523
|
-
var FormItem =
|
|
517
|
+
var FormItemContext = React5.createContext(null);
|
|
518
|
+
var FormItem = React5.forwardRef(
|
|
524
519
|
({ className, ...props }, ref) => {
|
|
525
|
-
const id =
|
|
526
|
-
return /* @__PURE__ */
|
|
520
|
+
const id = React5.useId();
|
|
521
|
+
return /* @__PURE__ */ jsx8(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx8("div", { className: cn("space-y-1", className), ref, ...props }) });
|
|
527
522
|
}
|
|
528
523
|
);
|
|
529
524
|
FormItem.displayName = "FormItem";
|
|
530
|
-
var
|
|
531
|
-
const { error, formItemId } = useFormField();
|
|
532
|
-
return /* @__PURE__ */ jsx9(Label, { className: cn(error && "text-destructive", className), htmlFor: formItemId, ref, ...props });
|
|
533
|
-
});
|
|
534
|
-
FormLabel.displayName = "FormLabel";
|
|
535
|
-
var FormControl = React6.forwardRef(
|
|
525
|
+
var FormControl = React5.forwardRef(
|
|
536
526
|
({ ...props }, ref) => {
|
|
537
527
|
const { error, formDescriptionId, formItemId, formMessageId } = useFormField();
|
|
538
|
-
return /* @__PURE__ */
|
|
528
|
+
return /* @__PURE__ */ jsx8(
|
|
539
529
|
Slot2,
|
|
540
530
|
{
|
|
541
531
|
"aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
|
|
@@ -548,21 +538,14 @@ var FormControl = React6.forwardRef(
|
|
|
548
538
|
}
|
|
549
539
|
);
|
|
550
540
|
FormControl.displayName = "FormControl";
|
|
551
|
-
var
|
|
552
|
-
({ className, ...props }, ref) => {
|
|
553
|
-
const { formDescriptionId } = useFormField();
|
|
554
|
-
return /* @__PURE__ */ jsx9("p", { className: cn("text-muted text-[0.8rem]", className), id: formDescriptionId, ref, ...props });
|
|
555
|
-
}
|
|
556
|
-
);
|
|
557
|
-
FormDescription.displayName = "FormDescription";
|
|
558
|
-
var FormMessage = React6.forwardRef(
|
|
541
|
+
var FormMessage = React5.forwardRef(
|
|
559
542
|
({ children, className, ...props }, ref) => {
|
|
560
543
|
const { error, formMessageId } = useFormField();
|
|
561
544
|
const body = error?.message ? String(error.message) : children;
|
|
562
545
|
if (!body) {
|
|
563
546
|
return null;
|
|
564
547
|
}
|
|
565
|
-
return /* @__PURE__ */
|
|
548
|
+
return /* @__PURE__ */ jsx8(
|
|
566
549
|
"p",
|
|
567
550
|
{
|
|
568
551
|
className: cn("text-destructive text-[0.8rem] font-medium", className),
|
|
@@ -581,10 +564,10 @@ import { useState } from "react";
|
|
|
581
564
|
import { EyeIcon, EyeSlashIcon, XIcon } from "@phosphor-icons/react";
|
|
582
565
|
|
|
583
566
|
// src/components/input.tsx
|
|
584
|
-
import * as
|
|
585
|
-
import { jsx as
|
|
586
|
-
var Input =
|
|
587
|
-
return /* @__PURE__ */
|
|
567
|
+
import * as React6 from "react";
|
|
568
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
569
|
+
var Input = React6.forwardRef(({ className, onKeyDown, type, ...props }, ref) => {
|
|
570
|
+
return /* @__PURE__ */ jsx9(
|
|
588
571
|
"input",
|
|
589
572
|
{
|
|
590
573
|
className: cn(
|
|
@@ -594,6 +577,8 @@ var Input = React7.forwardRef(({ className, type, ...props }, ref) => {
|
|
|
594
577
|
className
|
|
595
578
|
),
|
|
596
579
|
onKeyDown: (e) => {
|
|
580
|
+
onKeyDown?.(e);
|
|
581
|
+
if (e.defaultPrevented) return;
|
|
597
582
|
const key = e.key;
|
|
598
583
|
const allowedKeys = ["Backspace", "Tab", "Enter", "Escape", "ArrowLeft", "ArrowUp", "ArrowRight", "ArrowDown"];
|
|
599
584
|
if (allowedKeys.includes(key)) {
|
|
@@ -602,12 +587,6 @@ var Input = React7.forwardRef(({ className, type, ...props }, ref) => {
|
|
|
602
587
|
if (!(key >= "0" && key <= "9") && type === "number") {
|
|
603
588
|
e.preventDefault();
|
|
604
589
|
}
|
|
605
|
-
if (type === "onlyText") {
|
|
606
|
-
const regex = /^[a-zA-ZáéíóúÁÉÍÓÚñÑ ]*$/;
|
|
607
|
-
if (!regex.test(key)) {
|
|
608
|
-
e.preventDefault();
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
590
|
},
|
|
612
591
|
ref,
|
|
613
592
|
type,
|
|
@@ -617,6 +596,15 @@ var Input = React7.forwardRef(({ className, type, ...props }, ref) => {
|
|
|
617
596
|
});
|
|
618
597
|
Input.displayName = "Input";
|
|
619
598
|
|
|
599
|
+
// src/components/label.tsx
|
|
600
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
601
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
602
|
+
import * as React7 from "react";
|
|
603
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
604
|
+
var labelVariants = cva2("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
605
|
+
var Label = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx10(LabelPrimitive.Root, { className: cn(labelVariants(), className), ref, ...props }));
|
|
606
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
607
|
+
|
|
620
608
|
// src/components/form-fields/label-field.tsx
|
|
621
609
|
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
622
610
|
var LabelField = ({ label, labelClassName, name, visualRequired }) => {
|
|
@@ -659,8 +647,7 @@ var InputField = ({
|
|
|
659
647
|
setIsPasswordVisible((prev) => !prev);
|
|
660
648
|
};
|
|
661
649
|
const isPassword = type === "password";
|
|
662
|
-
const inputType = isPassword ? isPasswordVisible ? "text" : "password" : type
|
|
663
|
-
const isPlate = type === "plate";
|
|
650
|
+
const inputType = isPassword ? isPasswordVisible ? "text" : "password" : type;
|
|
664
651
|
return /* @__PURE__ */ jsx12(
|
|
665
652
|
FormField,
|
|
666
653
|
{
|
|
@@ -686,21 +673,12 @@ var InputField = ({
|
|
|
686
673
|
autoComplete: isPassword ? "current-password" : void 0,
|
|
687
674
|
className: cn(
|
|
688
675
|
inputClassName,
|
|
689
|
-
isPlate && "uppercase",
|
|
690
676
|
hasError && "border-destructive",
|
|
691
677
|
isPassword && "pr-10 [&::-ms-reveal]:hidden"
|
|
692
678
|
),
|
|
693
679
|
"data-no-password-toggle": true,
|
|
694
680
|
disabled,
|
|
695
|
-
maxLength: isPlate ? 6 : void 0,
|
|
696
681
|
min: type === "number" ? 0 : void 0,
|
|
697
|
-
onChange: (e) => {
|
|
698
|
-
let value = e.target.value;
|
|
699
|
-
if (isPlate) {
|
|
700
|
-
value = value.toUpperCase().replace(/[^A-Z0-9]/g, "").slice(0, 6);
|
|
701
|
-
}
|
|
702
|
-
field.onChange(value);
|
|
703
|
-
},
|
|
704
682
|
placeholder,
|
|
705
683
|
type: inputType,
|
|
706
684
|
value: field.value ?? ""
|
|
@@ -737,12 +715,14 @@ var InputField = ({
|
|
|
737
715
|
};
|
|
738
716
|
|
|
739
717
|
// src/components/google-map-picker.tsx
|
|
740
|
-
import { AdvancedMarker, APIProvider, Map as Map2
|
|
718
|
+
import { AdvancedMarker, APIProvider, Map as Map2 } from "@vis.gl/react-google-maps";
|
|
719
|
+
|
|
720
|
+
// src/components/use-google-map-picker.ts
|
|
721
|
+
import { useMap, useMapsLibrary } from "@vis.gl/react-google-maps";
|
|
741
722
|
import { useCallback, useEffect, useMemo, useRef, useState as useState2 } from "react";
|
|
742
|
-
import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
743
|
-
var DEFAULT_CENTER = { lat: 4.711, lng: -74.0721 };
|
|
744
723
|
var PICKER_MAP_ID = "komensal-restaurant-map";
|
|
745
724
|
var SELECTED_ZOOM = 15;
|
|
725
|
+
var CITY_ZOOM = 12;
|
|
746
726
|
var DEBOUNCE_MS = 300;
|
|
747
727
|
var parseComponents = (components) => {
|
|
748
728
|
const find = (type) => components.find((c) => c.types.includes(type));
|
|
@@ -756,19 +736,16 @@ var parseComponents = (components) => {
|
|
|
756
736
|
department: department?.long ?? null
|
|
757
737
|
};
|
|
758
738
|
};
|
|
759
|
-
|
|
760
|
-
var MapPickerContent = ({
|
|
739
|
+
function useGoogleMapPicker({
|
|
761
740
|
centerOn,
|
|
762
741
|
countryCode,
|
|
763
742
|
disabled,
|
|
764
|
-
hasError,
|
|
765
743
|
locationQuery,
|
|
766
744
|
locationZoom,
|
|
767
745
|
onAddressResolved,
|
|
768
746
|
onChange,
|
|
769
|
-
placeholder,
|
|
770
747
|
value
|
|
771
|
-
})
|
|
748
|
+
}) {
|
|
772
749
|
const placesLib = useMapsLibrary("places");
|
|
773
750
|
const geocodingLib = useMapsLibrary("geocoding");
|
|
774
751
|
const map = useMap(PICKER_MAP_ID);
|
|
@@ -917,6 +894,37 @@ var MapPickerContent = ({
|
|
|
917
894
|
},
|
|
918
895
|
[reverseGeocode]
|
|
919
896
|
);
|
|
897
|
+
return {
|
|
898
|
+
handleBlur,
|
|
899
|
+
handleInputChange,
|
|
900
|
+
handleMapClick,
|
|
901
|
+
handleMarkerDragEnd,
|
|
902
|
+
handleSelect,
|
|
903
|
+
inputValue,
|
|
904
|
+
position,
|
|
905
|
+
setShowDropdown,
|
|
906
|
+
showDropdown,
|
|
907
|
+
suggestions
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
// src/components/google-map-picker.tsx
|
|
912
|
+
import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
913
|
+
var DEFAULT_CENTER = { lat: 4.711, lng: -74.0721 };
|
|
914
|
+
var MapPickerContent = (props) => {
|
|
915
|
+
const { disabled, hasError, placeholder } = props;
|
|
916
|
+
const {
|
|
917
|
+
handleBlur,
|
|
918
|
+
handleInputChange,
|
|
919
|
+
handleMapClick,
|
|
920
|
+
handleMarkerDragEnd,
|
|
921
|
+
handleSelect,
|
|
922
|
+
inputValue,
|
|
923
|
+
position,
|
|
924
|
+
setShowDropdown,
|
|
925
|
+
showDropdown,
|
|
926
|
+
suggestions
|
|
927
|
+
} = useGoogleMapPicker(props);
|
|
920
928
|
return /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-3", children: [
|
|
921
929
|
/* @__PURE__ */ jsxs10("div", { className: "relative", children: [
|
|
922
930
|
/* @__PURE__ */ jsx13(
|
|
@@ -1095,7 +1103,7 @@ function OTPField({
|
|
|
1095
1103
|
|
|
1096
1104
|
// src/components/select-input.tsx
|
|
1097
1105
|
import { CaretDownIcon, CaretUpIcon, ClockIcon, XIcon as XIcon2 } from "@phosphor-icons/react";
|
|
1098
|
-
import { cloneElement, useCallback as useCallback2, useEffect as
|
|
1106
|
+
import { cloneElement, useCallback as useCallback2, useEffect as useEffect3, useMemo as useMemo3, useState as useState4 } from "react";
|
|
1099
1107
|
|
|
1100
1108
|
// src/components/popover.tsx
|
|
1101
1109
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
@@ -1103,7 +1111,6 @@ import * as React9 from "react";
|
|
|
1103
1111
|
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1104
1112
|
var Popover = PopoverPrimitive.Root;
|
|
1105
1113
|
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
1106
|
-
var PopoverAnchor = PopoverPrimitive.Anchor;
|
|
1107
1114
|
var PopoverContent = React9.forwardRef(({ align = "center", className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx17(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx17(
|
|
1108
1115
|
PopoverPrimitive.Content,
|
|
1109
1116
|
{
|
|
@@ -1119,6 +1126,41 @@ var PopoverContent = React9.forwardRef(({ align = "center", className, sideOffse
|
|
|
1119
1126
|
) }));
|
|
1120
1127
|
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
1121
1128
|
|
|
1129
|
+
// src/components/use-select-input.ts
|
|
1130
|
+
import { useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
|
|
1131
|
+
var normalizeString = (str) => str.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase();
|
|
1132
|
+
function useSelectFilter(items, labelKey, valueKey) {
|
|
1133
|
+
const [query, setQuery] = useState3("");
|
|
1134
|
+
const normalizedItems = useMemo2(() => {
|
|
1135
|
+
if (!items) return [];
|
|
1136
|
+
return items.map((it) => ({
|
|
1137
|
+
...it,
|
|
1138
|
+
[labelKey]: String(it[labelKey]),
|
|
1139
|
+
[valueKey]: String(it[valueKey])
|
|
1140
|
+
}));
|
|
1141
|
+
}, [items, labelKey, valueKey]);
|
|
1142
|
+
const filteredOptions = useMemo2(() => {
|
|
1143
|
+
if (!query) return normalizedItems;
|
|
1144
|
+
return normalizedItems.filter(
|
|
1145
|
+
(el) => normalizeString(el[labelKey]).includes(normalizeString(query))
|
|
1146
|
+
);
|
|
1147
|
+
}, [normalizedItems, labelKey, query]);
|
|
1148
|
+
return { filteredOptions, normalizedItems, query, setQuery };
|
|
1149
|
+
}
|
|
1150
|
+
function usePopoverWidth() {
|
|
1151
|
+
const ref = useRef2(null);
|
|
1152
|
+
const [width, setWidth] = useState3(0);
|
|
1153
|
+
useEffect2(() => {
|
|
1154
|
+
const updateWidth = () => {
|
|
1155
|
+
if (ref.current) setWidth(ref.current.getBoundingClientRect().width);
|
|
1156
|
+
};
|
|
1157
|
+
updateWidth();
|
|
1158
|
+
window.addEventListener("resize", updateWidth);
|
|
1159
|
+
return () => window.removeEventListener("resize", updateWidth);
|
|
1160
|
+
}, []);
|
|
1161
|
+
return { ref, width };
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1122
1164
|
// src/components/select-input.tsx
|
|
1123
1165
|
import { Fragment as Fragment3, jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1124
1166
|
var SelectInput = (props) => {
|
|
@@ -1146,26 +1188,14 @@ var SelectInput = (props) => {
|
|
|
1146
1188
|
valueKey = "value"
|
|
1147
1189
|
} = props;
|
|
1148
1190
|
const resolvedPlaceholder = placeholder ?? t("selectInput.placeholder");
|
|
1149
|
-
const
|
|
1150
|
-
const [
|
|
1151
|
-
const
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
return items.map((it) => ({
|
|
1158
|
-
...it,
|
|
1159
|
-
[labelKey]: String(it[labelKey]),
|
|
1160
|
-
[valueKey]: String(it[valueKey])
|
|
1161
|
-
}));
|
|
1162
|
-
}, [items, labelKey, valueKey]);
|
|
1163
|
-
const filteredOptions = useMemo2(() => {
|
|
1164
|
-
if (!query) return normalizedItems;
|
|
1165
|
-
return normalizedItems.filter(
|
|
1166
|
-
(el) => normalizeString(el[labelKey]).includes(normalizeString(query))
|
|
1167
|
-
);
|
|
1168
|
-
}, [normalizedItems, labelKey, query]);
|
|
1191
|
+
const [open, setOpen] = useState4(false);
|
|
1192
|
+
const [valueItem, setValueItem] = useState4(value);
|
|
1193
|
+
const { ref: divRef, width } = usePopoverWidth();
|
|
1194
|
+
const { filteredOptions, normalizedItems, query, setQuery } = useSelectFilter(
|
|
1195
|
+
items,
|
|
1196
|
+
labelKey,
|
|
1197
|
+
valueKey
|
|
1198
|
+
);
|
|
1169
1199
|
const onValueChange = useCallback2(
|
|
1170
1200
|
(val) => {
|
|
1171
1201
|
if (!normalizedItems.length) return;
|
|
@@ -1180,7 +1210,7 @@ var SelectInput = (props) => {
|
|
|
1180
1210
|
},
|
|
1181
1211
|
[normalizedItems, labelKey, valueKey, onValueChangeCallBack]
|
|
1182
1212
|
);
|
|
1183
|
-
const buttonClassName =
|
|
1213
|
+
const buttonClassName = useMemo3(
|
|
1184
1214
|
() => cn(
|
|
1185
1215
|
inputBase,
|
|
1186
1216
|
inputFocus,
|
|
@@ -1191,18 +1221,7 @@ var SelectInput = (props) => {
|
|
|
1191
1221
|
),
|
|
1192
1222
|
[disabled, error, className]
|
|
1193
1223
|
);
|
|
1194
|
-
|
|
1195
|
-
if (divRef.current) {
|
|
1196
|
-
const { width: width2 } = divRef.current.getBoundingClientRect();
|
|
1197
|
-
setWidth(width2);
|
|
1198
|
-
}
|
|
1199
|
-
};
|
|
1200
|
-
useEffect2(() => {
|
|
1201
|
-
updateWidth();
|
|
1202
|
-
window.addEventListener("resize", updateWidth);
|
|
1203
|
-
return () => window.removeEventListener("resize", updateWidth);
|
|
1204
|
-
}, []);
|
|
1205
|
-
useEffect2(() => {
|
|
1224
|
+
useEffect3(() => {
|
|
1206
1225
|
setValueItem(value);
|
|
1207
1226
|
}, [value]);
|
|
1208
1227
|
return /* @__PURE__ */ jsx18("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsx18("div", { className: "relative flex flex-col justify-center", children: /* @__PURE__ */ jsxs14(Popover, { onOpenChange: setOpen, open, children: [
|
|
@@ -1346,76 +1365,15 @@ var SelectField = ({
|
|
|
1346
1365
|
);
|
|
1347
1366
|
};
|
|
1348
1367
|
|
|
1349
|
-
// src/components/image.tsx
|
|
1350
|
-
import { useEffect as useEffect3, useRef as useRef3, useState as useState4 } from "react";
|
|
1351
|
-
import { jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1352
|
-
var Image = ({
|
|
1353
|
-
alt = "",
|
|
1354
|
-
aspectRatio,
|
|
1355
|
-
className,
|
|
1356
|
-
fallback,
|
|
1357
|
-
loading = "lazy",
|
|
1358
|
-
onError,
|
|
1359
|
-
onLoad,
|
|
1360
|
-
wrapperClassName,
|
|
1361
|
-
...props
|
|
1362
|
-
}) => {
|
|
1363
|
-
const ref = useRef3(null);
|
|
1364
|
-
const [loaded, setLoaded] = useState4(false);
|
|
1365
|
-
const [errored, setErrored] = useState4(false);
|
|
1366
|
-
useEffect3(() => {
|
|
1367
|
-
if (ref.current?.complete && ref.current.naturalWidth > 0) setLoaded(true);
|
|
1368
|
-
}, []);
|
|
1369
|
-
return /* @__PURE__ */ jsxs16(
|
|
1370
|
-
"div",
|
|
1371
|
-
{
|
|
1372
|
-
className: cn("bg-inactive relative overflow-hidden", wrapperClassName),
|
|
1373
|
-
style: aspectRatio ? { aspectRatio } : void 0,
|
|
1374
|
-
children: [
|
|
1375
|
-
!loaded && !errored && /* @__PURE__ */ jsx20("div", { className: "absolute inset-0 animate-pulse" }),
|
|
1376
|
-
errored ? fallback ?? null : /* @__PURE__ */ jsx20(
|
|
1377
|
-
"img",
|
|
1378
|
-
{
|
|
1379
|
-
alt,
|
|
1380
|
-
className: cn(
|
|
1381
|
-
"h-full w-full object-cover transition-opacity duration-300",
|
|
1382
|
-
loaded ? "opacity-100" : "opacity-0",
|
|
1383
|
-
className
|
|
1384
|
-
),
|
|
1385
|
-
decoding: "async",
|
|
1386
|
-
loading,
|
|
1387
|
-
onError: (e) => {
|
|
1388
|
-
setErrored(true);
|
|
1389
|
-
onError?.(e);
|
|
1390
|
-
},
|
|
1391
|
-
onLoad: (e) => {
|
|
1392
|
-
setLoaded(true);
|
|
1393
|
-
onLoad?.(e);
|
|
1394
|
-
},
|
|
1395
|
-
ref,
|
|
1396
|
-
...props
|
|
1397
|
-
}
|
|
1398
|
-
)
|
|
1399
|
-
]
|
|
1400
|
-
}
|
|
1401
|
-
);
|
|
1402
|
-
};
|
|
1403
|
-
|
|
1404
|
-
// src/components/loading.tsx
|
|
1405
|
-
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
1406
|
-
function Loading({ className = "", isSpinner = true }) {
|
|
1407
|
-
return /* @__PURE__ */ jsx21("div", { className: cn("relative flex min-h-screen items-center justify-center gap-6", className), children: isSpinner && /* @__PURE__ */ jsx21("div", { className: "absolute right-0 bottom-0 m-10", children: /* @__PURE__ */ jsx21(Spinner, {}) }) });
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
1368
|
// src/components/password-checklist.tsx
|
|
1411
1369
|
import { CheckCircleIcon as CheckCircleIcon2, XCircleIcon } from "@phosphor-icons/react";
|
|
1412
|
-
import { jsx as
|
|
1370
|
+
import { jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1413
1371
|
var PasswordChecklist = ({ className, rules, value }) => {
|
|
1414
1372
|
if (rules.length === 0) return null;
|
|
1415
|
-
return /* @__PURE__ */
|
|
1373
|
+
return /* @__PURE__ */ jsx20("ul", { className: cn("flex flex-col gap-1", className), children: rules.map((rule) => {
|
|
1416
1374
|
const isMet = rule.test(value);
|
|
1417
|
-
const
|
|
1418
|
-
return /* @__PURE__ */
|
|
1375
|
+
const Icon = isMet ? CheckCircleIcon2 : XCircleIcon;
|
|
1376
|
+
return /* @__PURE__ */ jsxs16(
|
|
1419
1377
|
"li",
|
|
1420
1378
|
{
|
|
1421
1379
|
className: cn(
|
|
@@ -1423,8 +1381,8 @@ var PasswordChecklist = ({ className, rules, value }) => {
|
|
|
1423
1381
|
isMet ? "text-success" : "text-inactive-text"
|
|
1424
1382
|
),
|
|
1425
1383
|
children: [
|
|
1426
|
-
/* @__PURE__ */
|
|
1427
|
-
/* @__PURE__ */
|
|
1384
|
+
/* @__PURE__ */ jsx20(Icon, { "aria-hidden": "true", className: "h-4 w-4 shrink-0" }),
|
|
1385
|
+
/* @__PURE__ */ jsx20("span", { children: rule.label })
|
|
1428
1386
|
]
|
|
1429
1387
|
},
|
|
1430
1388
|
rule.key
|
|
@@ -1432,116 +1390,23 @@ var PasswordChecklist = ({ className, rules, value }) => {
|
|
|
1432
1390
|
}) });
|
|
1433
1391
|
};
|
|
1434
1392
|
|
|
1435
|
-
// src/components/select.tsx
|
|
1436
|
-
import { CaretSortIcon, CheckIcon, ChevronDownIcon, ChevronUpIcon } from "@radix-ui/react-icons";
|
|
1437
|
-
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
1438
|
-
import * as React11 from "react";
|
|
1439
|
-
import { jsx as jsx23, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1440
|
-
var Select = SelectPrimitive.Root;
|
|
1441
|
-
var SelectGroup = SelectPrimitive.Group;
|
|
1442
|
-
var SelectValue = SelectPrimitive.Value;
|
|
1443
|
-
var SelectTrigger = React11.forwardRef(({ children, className, ...props }, ref) => /* @__PURE__ */ jsxs18(
|
|
1444
|
-
SelectPrimitive.Trigger,
|
|
1445
|
-
{
|
|
1446
|
-
className: cn(
|
|
1447
|
-
"placeholder:text-placeholder border-border ring-offset-surface focus:ring-ring flex h-9 w-full items-center justify-between rounded-xl border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-sm focus:ring-0 focus:outline-none disabled:cursor-not-allowed [&>span]:line-clamp-1",
|
|
1448
|
-
className
|
|
1449
|
-
),
|
|
1450
|
-
ref,
|
|
1451
|
-
...props,
|
|
1452
|
-
children: [
|
|
1453
|
-
children,
|
|
1454
|
-
/* @__PURE__ */ jsx23(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx23(CaretSortIcon, { className: "h-4 w-4 opacity-50" }) })
|
|
1455
|
-
]
|
|
1456
|
-
}
|
|
1457
|
-
));
|
|
1458
|
-
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
1459
|
-
var SelectScrollUpButton = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx23(
|
|
1460
|
-
SelectPrimitive.ScrollUpButton,
|
|
1461
|
-
{
|
|
1462
|
-
className: cn("flex cursor-default items-center justify-center py-1", className),
|
|
1463
|
-
ref,
|
|
1464
|
-
...props,
|
|
1465
|
-
children: /* @__PURE__ */ jsx23(ChevronUpIcon, {})
|
|
1466
|
-
}
|
|
1467
|
-
));
|
|
1468
|
-
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
1469
|
-
var SelectScrollDownButton = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx23(
|
|
1470
|
-
SelectPrimitive.ScrollDownButton,
|
|
1471
|
-
{
|
|
1472
|
-
className: cn("flex cursor-default items-center justify-center py-1", className),
|
|
1473
|
-
ref,
|
|
1474
|
-
...props,
|
|
1475
|
-
children: /* @__PURE__ */ jsx23(ChevronDownIcon, {})
|
|
1476
|
-
}
|
|
1477
|
-
));
|
|
1478
|
-
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
1479
|
-
var SelectContent = React11.forwardRef(({ children, className, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx23(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs18(
|
|
1480
|
-
SelectPrimitive.Content,
|
|
1481
|
-
{
|
|
1482
|
-
className: cn(
|
|
1483
|
-
"border-border text-foreground bg-surface data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-32 overflow-hidden rounded-lg border shadow-md",
|
|
1484
|
-
position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
1485
|
-
className
|
|
1486
|
-
),
|
|
1487
|
-
position,
|
|
1488
|
-
ref,
|
|
1489
|
-
...props,
|
|
1490
|
-
children: [
|
|
1491
|
-
/* @__PURE__ */ jsx23(SelectScrollUpButton, {}),
|
|
1492
|
-
/* @__PURE__ */ jsx23(
|
|
1493
|
-
SelectPrimitive.Viewport,
|
|
1494
|
-
{
|
|
1495
|
-
className: cn(
|
|
1496
|
-
"p-1",
|
|
1497
|
-
position === "popper" && "h-(--radix-select-trigger-height) w-full min-w-(--radix-select-trigger-width)"
|
|
1498
|
-
),
|
|
1499
|
-
children
|
|
1500
|
-
}
|
|
1501
|
-
),
|
|
1502
|
-
/* @__PURE__ */ jsx23(SelectScrollDownButton, {})
|
|
1503
|
-
]
|
|
1504
|
-
}
|
|
1505
|
-
) }));
|
|
1506
|
-
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
1507
|
-
var SelectLabel = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx23(SelectPrimitive.Label, { className: cn("px-2 py-1.5 text-sm font-semibold", className), ref, ...props }));
|
|
1508
|
-
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
1509
|
-
var SelectItem = React11.forwardRef(({ children, className, ...props }, ref) => /* @__PURE__ */ jsxs18(
|
|
1510
|
-
SelectPrimitive.Item,
|
|
1511
|
-
{
|
|
1512
|
-
className: cn(
|
|
1513
|
-
"focus:text-foreground focus:bg-hover relative flex w-full cursor-default items-center rounded-md py-1.5 pr-8 pl-2 text-sm outline-none select-none data-disabled:pointer-events-none data-disabled:opacity-50",
|
|
1514
|
-
className
|
|
1515
|
-
),
|
|
1516
|
-
ref,
|
|
1517
|
-
...props,
|
|
1518
|
-
children: [
|
|
1519
|
-
/* @__PURE__ */ jsx23("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx23(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx23(CheckIcon, { className: "h-4 w-4" }) }) }),
|
|
1520
|
-
/* @__PURE__ */ jsx23(SelectPrimitive.ItemText, { children: /* @__PURE__ */ jsx23("span", { children }) })
|
|
1521
|
-
]
|
|
1522
|
-
}
|
|
1523
|
-
));
|
|
1524
|
-
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
1525
|
-
var SelectSeparator = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx23(SelectPrimitive.Separator, { className: cn("bg-border -mx-1 my-1 h-px", className), ref, ...props }));
|
|
1526
|
-
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
1527
|
-
|
|
1528
1393
|
// src/components/step-header.tsx
|
|
1529
|
-
import { jsx as
|
|
1530
|
-
var StepHeader = ({ subtitle, subtitleClassName, title }) => /* @__PURE__ */
|
|
1531
|
-
/* @__PURE__ */
|
|
1532
|
-
subtitle !== void 0 && /* @__PURE__ */
|
|
1394
|
+
import { jsx as jsx21, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1395
|
+
var StepHeader = ({ subtitle, subtitleClassName, title }) => /* @__PURE__ */ jsxs17("div", { className: "flex flex-col gap-1", children: [
|
|
1396
|
+
/* @__PURE__ */ jsx21("h1", { className: "text-title text-2xl font-bold", children: title }),
|
|
1397
|
+
subtitle !== void 0 && /* @__PURE__ */ jsx21("p", { className: cn("text-subtitle text-sm", subtitleClassName), children: subtitle })
|
|
1533
1398
|
] });
|
|
1534
1399
|
|
|
1535
1400
|
// src/components/stepper.tsx
|
|
1536
|
-
import { CheckIcon
|
|
1537
|
-
import { jsx as
|
|
1401
|
+
import { CheckIcon } from "@phosphor-icons/react";
|
|
1402
|
+
import { jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1538
1403
|
var Stepper = ({ activeIndex, className, intermediate = false, steps }) => {
|
|
1539
|
-
return /* @__PURE__ */
|
|
1404
|
+
return /* @__PURE__ */ jsx22("div", { className: cn("flex w-full items-start", className), children: steps.map((step, index) => {
|
|
1540
1405
|
const isCompleted = intermediate ? index <= activeIndex : index < activeIndex;
|
|
1541
1406
|
const isActive = !intermediate && index === activeIndex;
|
|
1542
|
-
return /* @__PURE__ */
|
|
1543
|
-
/* @__PURE__ */
|
|
1544
|
-
/* @__PURE__ */
|
|
1407
|
+
return /* @__PURE__ */ jsxs18("div", { className: "flex flex-1 flex-col items-center", children: [
|
|
1408
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex w-full items-center", children: [
|
|
1409
|
+
/* @__PURE__ */ jsx22(
|
|
1545
1410
|
"div",
|
|
1546
1411
|
{
|
|
1547
1412
|
className: cn(
|
|
@@ -1551,7 +1416,7 @@ var Stepper = ({ activeIndex, className, intermediate = false, steps }) => {
|
|
|
1551
1416
|
)
|
|
1552
1417
|
}
|
|
1553
1418
|
),
|
|
1554
|
-
/* @__PURE__ */
|
|
1419
|
+
/* @__PURE__ */ jsx22(
|
|
1555
1420
|
"div",
|
|
1556
1421
|
{
|
|
1557
1422
|
"aria-current": isActive ? "step" : void 0,
|
|
@@ -1561,10 +1426,10 @@ var Stepper = ({ activeIndex, className, intermediate = false, steps }) => {
|
|
|
1561
1426
|
isActive && "bg-primary border-primary text-inverse",
|
|
1562
1427
|
!isCompleted && !isActive && "bg-inactive border-inactive text-surface"
|
|
1563
1428
|
),
|
|
1564
|
-
children: isCompleted ? /* @__PURE__ */
|
|
1429
|
+
children: isCompleted ? /* @__PURE__ */ jsx22(CheckIcon, { className: "h-4 w-4" }) : index + 1
|
|
1565
1430
|
}
|
|
1566
1431
|
),
|
|
1567
|
-
/* @__PURE__ */
|
|
1432
|
+
/* @__PURE__ */ jsx22(
|
|
1568
1433
|
"div",
|
|
1569
1434
|
{
|
|
1570
1435
|
className: cn(
|
|
@@ -1572,7 +1437,7 @@ var Stepper = ({ activeIndex, className, intermediate = false, steps }) => {
|
|
|
1572
1437
|
isCompleted ? "bg-primary" : "bg-inactive",
|
|
1573
1438
|
index === steps.length - 1 && "rounded-r-full"
|
|
1574
1439
|
),
|
|
1575
|
-
children: index === 0 && /* @__PURE__ */
|
|
1440
|
+
children: index === 0 && /* @__PURE__ */ jsx22(
|
|
1576
1441
|
"div",
|
|
1577
1442
|
{
|
|
1578
1443
|
className: cn(
|
|
@@ -1584,43 +1449,37 @@ var Stepper = ({ activeIndex, className, intermediate = false, steps }) => {
|
|
|
1584
1449
|
}
|
|
1585
1450
|
)
|
|
1586
1451
|
] }),
|
|
1587
|
-
/* @__PURE__ */
|
|
1452
|
+
/* @__PURE__ */ jsx22("span", { className: cn("mt-1 text-xs font-normal", isCompleted || isActive ? "text-primary" : "text-muted"), children: step.label })
|
|
1588
1453
|
] }, step.label);
|
|
1589
1454
|
}) });
|
|
1590
1455
|
};
|
|
1591
1456
|
|
|
1592
1457
|
// src/components/toast/toast.tsx
|
|
1593
|
-
import { CheckIcon as
|
|
1594
|
-
import { useEffect as useEffect4,
|
|
1595
|
-
import { jsx as
|
|
1458
|
+
import { CheckIcon as CheckIcon2, FileLockIcon, InfoIcon as InfoIcon2, WarningIcon as WarningIcon2, XIcon as XIcon3 } from "@phosphor-icons/react";
|
|
1459
|
+
import { useEffect as useEffect4, useRef as useRef3, useState as useState5 } from "react";
|
|
1460
|
+
import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
1596
1461
|
var EXIT_ANIMATION_MS = 200;
|
|
1462
|
+
var typeIcons = {
|
|
1463
|
+
destructive: XIcon3,
|
|
1464
|
+
info: InfoIcon2,
|
|
1465
|
+
success: CheckIcon2,
|
|
1466
|
+
wait: FileLockIcon,
|
|
1467
|
+
warning: WarningIcon2
|
|
1468
|
+
};
|
|
1469
|
+
var typeStyles = {
|
|
1470
|
+
destructive: { border: "border-destructive", icon: "text-destructive", iconBorder: "border-destructive" },
|
|
1471
|
+
info: { border: "border-info", icon: "text-info", iconBorder: "border-info" },
|
|
1472
|
+
success: { border: "border-success", icon: "text-success", iconBorder: "border-success" },
|
|
1473
|
+
wait: { border: "border-wait", icon: "text-wait", iconBorder: "border-wait" },
|
|
1474
|
+
warning: { border: "border-warning", icon: "text-warning", iconBorder: "border-warning" }
|
|
1475
|
+
};
|
|
1597
1476
|
function Toast({ duration = 2500, id, onClose, subtitle, title, type }) {
|
|
1598
1477
|
const [leaving, setLeaving] = useState5(false);
|
|
1599
|
-
const startedAtRef =
|
|
1600
|
-
const timeoutRef =
|
|
1601
|
-
const exitRef =
|
|
1602
|
-
const
|
|
1603
|
-
|
|
1604
|
-
if (type === "error") return XIcon3;
|
|
1605
|
-
if (type === "warning") return WarningIcon2;
|
|
1606
|
-
if (type === "info") return InfoIcon2;
|
|
1607
|
-
return FileLockIcon;
|
|
1608
|
-
}, [type]);
|
|
1609
|
-
const styles = useMemo3(() => {
|
|
1610
|
-
if (type === "success") {
|
|
1611
|
-
return { border: "border-success", icon: "text-success", iconBorder: "border-success" };
|
|
1612
|
-
}
|
|
1613
|
-
if (type === "error") {
|
|
1614
|
-
return { border: "border-destructive", icon: "text-destructive", iconBorder: "border-destructive" };
|
|
1615
|
-
}
|
|
1616
|
-
if (type === "warning") {
|
|
1617
|
-
return { border: "border-warning", icon: "text-warning", iconBorder: "border-warning" };
|
|
1618
|
-
}
|
|
1619
|
-
if (type === "info") {
|
|
1620
|
-
return { border: "border-info", icon: "text-info", iconBorder: "border-info" };
|
|
1621
|
-
}
|
|
1622
|
-
return { border: "border-wait", icon: "text-wait", iconBorder: "border-wait" };
|
|
1623
|
-
}, [type]);
|
|
1478
|
+
const startedAtRef = useRef3(Date.now());
|
|
1479
|
+
const timeoutRef = useRef3(null);
|
|
1480
|
+
const exitRef = useRef3(null);
|
|
1481
|
+
const Icon = typeIcons[type];
|
|
1482
|
+
const styles = typeStyles[type];
|
|
1624
1483
|
useEffect4(() => {
|
|
1625
1484
|
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
1626
1485
|
if (exitRef.current) clearTimeout(exitRef.current);
|
|
@@ -1635,7 +1494,7 @@ function Toast({ duration = 2500, id, onClose, subtitle, title, type }) {
|
|
|
1635
1494
|
if (exitRef.current) clearTimeout(exitRef.current);
|
|
1636
1495
|
};
|
|
1637
1496
|
}, [id, duration, onClose]);
|
|
1638
|
-
return /* @__PURE__ */
|
|
1497
|
+
return /* @__PURE__ */ jsxs19(
|
|
1639
1498
|
"div",
|
|
1640
1499
|
{
|
|
1641
1500
|
"aria-live": "polite",
|
|
@@ -1653,9 +1512,9 @@ function Toast({ duration = 2500, id, onClose, subtitle, title, type }) {
|
|
|
1653
1512
|
].join(" "),
|
|
1654
1513
|
role: "status",
|
|
1655
1514
|
children: [
|
|
1656
|
-
/* @__PURE__ */
|
|
1657
|
-
subtitle ? /* @__PURE__ */
|
|
1658
|
-
/* @__PURE__ */
|
|
1515
|
+
/* @__PURE__ */ jsx23("div", { className: "min-w-0 pr-4", children: /* @__PURE__ */ jsx23("h4", { className: ["text-[16px] leading-normal font-semibold", "text-foreground", "line-clamp-2"].join(" "), children: title }) }),
|
|
1516
|
+
subtitle ? /* @__PURE__ */ jsx23("div", { className: "shrink-0 pr-4 text-left", children: /* @__PURE__ */ jsx23("div", { className: ["max-w-28 text-[14px] leading-[19.5px] font-normal", "text-body"].join(" "), children: subtitle }) }) : null,
|
|
1517
|
+
/* @__PURE__ */ jsx23(
|
|
1659
1518
|
"div",
|
|
1660
1519
|
{
|
|
1661
1520
|
className: [
|
|
@@ -1663,7 +1522,7 @@ function Toast({ duration = 2500, id, onClose, subtitle, title, type }) {
|
|
|
1663
1522
|
"flex h-8 w-8 min-w-8 items-center justify-center rounded-full border-2",
|
|
1664
1523
|
styles.iconBorder
|
|
1665
1524
|
].join(" "),
|
|
1666
|
-
children: /* @__PURE__ */
|
|
1525
|
+
children: /* @__PURE__ */ jsx23(Icon, { className: ["h-5 w-5", styles.icon].join(" ") })
|
|
1667
1526
|
}
|
|
1668
1527
|
)
|
|
1669
1528
|
]
|
|
@@ -1672,12 +1531,12 @@ function Toast({ duration = 2500, id, onClose, subtitle, title, type }) {
|
|
|
1672
1531
|
}
|
|
1673
1532
|
|
|
1674
1533
|
// src/components/toast/toast-provider.tsx
|
|
1675
|
-
import { useCallback as useCallback3, useEffect as useEffect5, useLayoutEffect, useMemo as useMemo4, useRef as
|
|
1676
|
-
import { Fragment as Fragment4, jsx as
|
|
1534
|
+
import { useCallback as useCallback3, useEffect as useEffect5, useLayoutEffect, useMemo as useMemo4, useRef as useRef4, useState as useState6 } from "react";
|
|
1535
|
+
import { Fragment as Fragment4, jsx as jsx24 } from "react/jsx-runtime";
|
|
1677
1536
|
function ToastProvider() {
|
|
1678
1537
|
const [toasts, setToasts] = useState6([]);
|
|
1679
|
-
const itemRefs =
|
|
1680
|
-
const prevRects =
|
|
1538
|
+
const itemRefs = useRef4(/* @__PURE__ */ new Map());
|
|
1539
|
+
const prevRects = useRef4(/* @__PURE__ */ new Map());
|
|
1681
1540
|
const showToast = useCallback3((type, options) => {
|
|
1682
1541
|
setToasts((prev) => [
|
|
1683
1542
|
...prev,
|
|
@@ -1734,7 +1593,7 @@ function ToastProvider() {
|
|
|
1734
1593
|
itemRefs.current.set(id, el);
|
|
1735
1594
|
};
|
|
1736
1595
|
}, []);
|
|
1737
|
-
return /* @__PURE__ */
|
|
1596
|
+
return /* @__PURE__ */ jsx24(Fragment4, { children: Object.entries(grouped).map(([position, list]) => /* @__PURE__ */ jsx24("div", { className: `fixed z-4000 ${getPositionClass(position)}`, children: /* @__PURE__ */ jsx24("div", { className: "relative flex flex-col gap-3", children: list.map((toast2) => /* @__PURE__ */ jsx24("div", { ref: setItemRef(toast2.id), children: /* @__PURE__ */ jsx24(
|
|
1738
1597
|
Toast,
|
|
1739
1598
|
{
|
|
1740
1599
|
duration: toast2.duration,
|
|
@@ -1762,9 +1621,9 @@ function getPositionClass(position) {
|
|
|
1762
1621
|
}
|
|
1763
1622
|
|
|
1764
1623
|
// src/components/wrapper.tsx
|
|
1765
|
-
import { jsx as
|
|
1624
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
1766
1625
|
var Wrapper = ({ children, className }) => {
|
|
1767
|
-
return /* @__PURE__ */
|
|
1626
|
+
return /* @__PURE__ */ jsx25("div", { className: cn("mx-auto h-full w-full", className), children });
|
|
1768
1627
|
};
|
|
1769
1628
|
export {
|
|
1770
1629
|
Alert,
|
|
@@ -1791,13 +1650,10 @@ export {
|
|
|
1791
1650
|
DialogTrigger,
|
|
1792
1651
|
Form,
|
|
1793
1652
|
FormControl,
|
|
1794
|
-
FormDescription,
|
|
1795
1653
|
FormField,
|
|
1796
1654
|
FormItem,
|
|
1797
|
-
FormLabel,
|
|
1798
1655
|
FormMessage,
|
|
1799
1656
|
GoogleMapPicker,
|
|
1800
|
-
Image,
|
|
1801
1657
|
Input,
|
|
1802
1658
|
InputField,
|
|
1803
1659
|
InputOTP,
|
|
@@ -1805,26 +1661,14 @@ export {
|
|
|
1805
1661
|
InputOTPSlot,
|
|
1806
1662
|
Label,
|
|
1807
1663
|
LabelField,
|
|
1808
|
-
Loading,
|
|
1809
1664
|
MapPickerField,
|
|
1810
1665
|
OTPField,
|
|
1811
1666
|
PasswordChecklist,
|
|
1812
1667
|
Popover,
|
|
1813
|
-
PopoverAnchor,
|
|
1814
1668
|
PopoverContent,
|
|
1815
1669
|
PopoverTrigger,
|
|
1816
|
-
Select,
|
|
1817
|
-
SelectContent,
|
|
1818
1670
|
SelectField,
|
|
1819
|
-
SelectGroup,
|
|
1820
1671
|
SelectInput,
|
|
1821
|
-
SelectItem,
|
|
1822
|
-
SelectLabel,
|
|
1823
|
-
SelectScrollDownButton,
|
|
1824
|
-
SelectScrollUpButton,
|
|
1825
|
-
SelectSeparator,
|
|
1826
|
-
SelectTrigger,
|
|
1827
|
-
SelectValue,
|
|
1828
1672
|
Spinner,
|
|
1829
1673
|
StepHeader,
|
|
1830
1674
|
Stepper,
|
|
@@ -1835,6 +1679,7 @@ export {
|
|
|
1835
1679
|
buttonVariants,
|
|
1836
1680
|
cn,
|
|
1837
1681
|
inputBase,
|
|
1682
|
+
inputCompact,
|
|
1838
1683
|
inputDisabled,
|
|
1839
1684
|
inputFocus,
|
|
1840
1685
|
inputPlaceholder,
|