@komensal/ui 0.15.0 → 0.16.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/chunk-5VBG6IKL.js +649 -0
- package/dist/chunk-5VBG6IKL.js.map +1 -0
- package/dist/chunk-FDVY36KS.js +41 -0
- package/dist/chunk-FDVY36KS.js.map +1 -0
- package/dist/index.d.ts +27 -45
- package/dist/index.js +394 -849
- package/dist/index.js.map +1 -1
- package/dist/locales/index.d.ts +9 -0
- package/dist/locales/index.js +3 -27
- package/dist/locales/index.js.map +1 -1
- package/dist/maps.d.ts +46 -0
- package/dist/maps.js +9 -0
- package/dist/maps.js.map +1 -0
- package/dist/styles/index.css +1 -0
- package/dist/styles/theme.css +16 -0
- package/package.json +97 -81
package/dist/index.js
CHANGED
|
@@ -1,134 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}).format(value);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// src/utils/styles.ts
|
|
42
|
-
var inputSurface = cn(
|
|
43
|
-
"w-full rounded-[10px] px-3 text-base font-normal",
|
|
44
|
-
"border-border bg-surface text-foreground border",
|
|
45
|
-
"transition-all duration-200 ease-in-out",
|
|
46
|
-
"placeholder:text-icon-muted placeholder:text-sm placeholder:leading-none placeholder:font-normal",
|
|
47
|
-
"disabled:bg-inactive disabled:text-inactive-text disabled:border-inactive disabled:placeholder:text-inactive-text disabled:cursor-not-allowed"
|
|
48
|
-
);
|
|
49
|
-
var inputBase = cn("flex !h-[50px] items-center justify-between gap-[10px]", inputSurface);
|
|
50
|
-
var inputPlaceholder = cn("text-icon-muted text-sm leading-none font-normal");
|
|
51
|
-
var inputDisabled = cn("cursor-not-allowed opacity-50");
|
|
52
|
-
var inputCompact = cn(
|
|
53
|
-
"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"
|
|
54
|
-
);
|
|
55
|
-
var inputFocus = cn(
|
|
56
|
-
"focus:outline-none focus-visible:outline-none",
|
|
57
|
-
"focus-visible:ring-ring focus-visible:border-primary focus-visible:ring-2",
|
|
58
|
-
"data-[state=open]:ring-ring data-[state=open]:border-primary data-[state=open]:ring-2"
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
// src/utils/tag-emoji.ts
|
|
62
|
-
var TAG_EMOJI_RULES = [
|
|
63
|
-
{ emoji: "\u{1F336}\uFE0F", keywords: ["picante", "picoso", "spicy"] },
|
|
64
|
-
{ emoji: "\u{1F95C}", keywords: ["nuez", "nueces", "mani", "cacahuate", "frutos secos"] },
|
|
65
|
-
{ emoji: "\u{1F331}", keywords: ["vegano", "vegetariano", "vegan"] },
|
|
66
|
-
{ emoji: "\u{1F33E}", keywords: ["sin gluten", "gluten free"] },
|
|
67
|
-
{ emoji: "\u{1F95B}", keywords: ["lacteos", "leche", "lactosa"] },
|
|
68
|
-
{ emoji: "\u{1F990}", keywords: ["marisco", "camaron"] },
|
|
69
|
-
{ emoji: "\u{1F525}", keywords: ["popular", "top ventas"] },
|
|
70
|
-
{ emoji: "\u{1F195}", keywords: ["nuevo", "new"] },
|
|
71
|
-
{ emoji: "\u{1F36C}", keywords: ["dulce"] },
|
|
72
|
-
{ emoji: "\u{1F9CA}", keywords: ["frio", "helado"] }
|
|
73
|
-
];
|
|
74
|
-
function getTagEmoji(tag) {
|
|
75
|
-
const normalized = normalize(tag);
|
|
76
|
-
const match = TAG_EMOJI_RULES.find((rule) => rule.keywords.some((keyword) => normalized.includes(keyword)));
|
|
77
|
-
return match?.emoji ?? null;
|
|
78
|
-
}
|
|
79
|
-
function normalize(text) {
|
|
80
|
-
return text.toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, "");
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// src/utils/toast-emitter.ts
|
|
84
|
-
var emitToast = null;
|
|
85
|
-
var toast = {
|
|
86
|
-
error(options) {
|
|
87
|
-
emit("destructive", options);
|
|
88
|
-
},
|
|
89
|
-
info(options) {
|
|
90
|
-
emit("info", options);
|
|
91
|
-
},
|
|
92
|
-
success(options) {
|
|
93
|
-
emit("success", options);
|
|
94
|
-
},
|
|
95
|
-
wait(options) {
|
|
96
|
-
emit("wait", options);
|
|
97
|
-
},
|
|
98
|
-
warning(options) {
|
|
99
|
-
emit("warning", options);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
function registerToastEmitter(fn) {
|
|
103
|
-
emitToast = fn;
|
|
104
|
-
}
|
|
105
|
-
function emit(type, options) {
|
|
106
|
-
if (!emitToast) return;
|
|
107
|
-
if (typeof options === "string") {
|
|
108
|
-
emitToast(type, { title: options });
|
|
109
|
-
} else {
|
|
110
|
-
emitToast(type, options);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/utils/url.ts
|
|
115
|
-
function isSafeUrl(url) {
|
|
116
|
-
try {
|
|
117
|
-
const parsed = new URL(url, "https://placeholder.invalid");
|
|
118
|
-
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
119
|
-
} catch {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// src/utils/z-index.ts
|
|
125
|
-
var zPopover = "z-50";
|
|
126
|
-
var zDialogOverlay = "z-60";
|
|
127
|
-
var zDialogContent = "z-70";
|
|
128
|
-
var zPopoverAboveDialog = "z-100";
|
|
129
|
-
var zToast = "z-4000";
|
|
1
|
+
import {
|
|
2
|
+
Form,
|
|
3
|
+
FormControl,
|
|
4
|
+
FormField,
|
|
5
|
+
FormFieldShell,
|
|
6
|
+
FormItem,
|
|
7
|
+
FormMessage,
|
|
8
|
+
GoogleMapPicker,
|
|
9
|
+
Label,
|
|
10
|
+
LabelField,
|
|
11
|
+
MapPickerField,
|
|
12
|
+
capitalize,
|
|
13
|
+
cn,
|
|
14
|
+
focusRing,
|
|
15
|
+
formatNumber,
|
|
16
|
+
formatPrice,
|
|
17
|
+
getTagEmoji,
|
|
18
|
+
inputBase,
|
|
19
|
+
inputCompact,
|
|
20
|
+
inputDisabled,
|
|
21
|
+
inputFocus,
|
|
22
|
+
inputPlaceholder,
|
|
23
|
+
inputSurface,
|
|
24
|
+
isLightColor,
|
|
25
|
+
isSafeUrl,
|
|
26
|
+
registerToastEmitter,
|
|
27
|
+
toast,
|
|
28
|
+
useFormField,
|
|
29
|
+
zDialogContent,
|
|
30
|
+
zDialogOverlay,
|
|
31
|
+
zPopover,
|
|
32
|
+
zPopoverAboveDialog,
|
|
33
|
+
zToast
|
|
34
|
+
} from "./chunk-5VBG6IKL.js";
|
|
35
|
+
import {
|
|
36
|
+
ui_default
|
|
37
|
+
} from "./chunk-FDVY36KS.js";
|
|
130
38
|
|
|
131
39
|
// src/components/add-tile.tsx
|
|
40
|
+
import * as React from "react";
|
|
132
41
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
133
42
|
var AddTile = React.forwardRef(
|
|
134
43
|
({ className, icon, label, labelClassName, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
@@ -165,22 +74,27 @@ var variantIcons = {
|
|
|
165
74
|
success: CheckCircleIcon,
|
|
166
75
|
warning: WarningIcon
|
|
167
76
|
};
|
|
77
|
+
var variantRoles = {
|
|
78
|
+
destructive: "alert",
|
|
79
|
+
info: "status",
|
|
80
|
+
success: "status",
|
|
81
|
+
warning: "alert"
|
|
82
|
+
};
|
|
168
83
|
var Alert = ({ children, className, variant = "destructive", ...props }) => {
|
|
169
84
|
const styles = variantStyles[variant];
|
|
170
85
|
const Icon = variantIcons[variant];
|
|
171
86
|
return /* @__PURE__ */ jsxs2(
|
|
172
87
|
"div",
|
|
173
88
|
{
|
|
174
|
-
"aria-live": "polite",
|
|
175
89
|
className: cn(
|
|
176
90
|
"flex items-center justify-center gap-2 rounded-[10px] px-4 py-3 text-sm",
|
|
177
91
|
styles.container,
|
|
178
92
|
className
|
|
179
93
|
),
|
|
180
|
-
role:
|
|
94
|
+
role: variantRoles[variant],
|
|
181
95
|
...props,
|
|
182
96
|
children: [
|
|
183
|
-
/* @__PURE__ */ jsx2(Icon, { className: cn("h-5 w-5 shrink-0", styles.icon) }),
|
|
97
|
+
/* @__PURE__ */ jsx2(Icon, { "aria-hidden": true, className: cn("h-5 w-5 shrink-0", styles.icon) }),
|
|
184
98
|
/* @__PURE__ */ jsx2("span", { children })
|
|
185
99
|
]
|
|
186
100
|
}
|
|
@@ -208,64 +122,9 @@ var AuthHeader = ({
|
|
|
208
122
|
// src/components/breadcrumb.tsx
|
|
209
123
|
import * as React3 from "react";
|
|
210
124
|
|
|
211
|
-
// src/components/skeleton.tsx
|
|
212
|
-
import * as React2 from "react";
|
|
213
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
214
|
-
var Skeleton = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx4("div", { className: cn("bg-inactive animate-pulse rounded-md", className), ref, ...props }));
|
|
215
|
-
Skeleton.displayName = "Skeleton";
|
|
216
|
-
|
|
217
|
-
// src/components/breadcrumb.tsx
|
|
218
|
-
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
219
|
-
var Breadcrumb = React3.forwardRef(({ className, items, ...props }, ref) => /* @__PURE__ */ jsx5("div", { className: cn("flex items-center gap-1 text-sm", className), ref, ...props, children: items.map((item, index) => {
|
|
220
|
-
const isLast = index === items.length - 1;
|
|
221
|
-
return /* @__PURE__ */ jsxs4("span", { className: "flex items-center gap-1", children: [
|
|
222
|
-
index > 0 && /* @__PURE__ */ jsx5("span", { className: "text-muted", children: "\u203A" }),
|
|
223
|
-
item.loading ? /* @__PURE__ */ jsx5(Skeleton, { className: "h-4 w-20" }) : item.onClick && !isLast ? /* @__PURE__ */ jsx5("button", { className: "text-muted hover:text-foreground transition-colors", onClick: item.onClick, type: "button", children: item.label }) : /* @__PURE__ */ jsx5("span", { className: isLast ? "text-foreground font-semibold" : "text-muted font-normal", children: item.label })
|
|
224
|
-
] }, `${item.label}-${index}`);
|
|
225
|
-
}) }));
|
|
226
|
-
Breadcrumb.displayName = "Breadcrumb";
|
|
227
|
-
|
|
228
|
-
// src/components/button.tsx
|
|
229
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
230
|
-
import { cva } from "class-variance-authority";
|
|
231
|
-
import * as React5 from "react";
|
|
232
|
-
|
|
233
|
-
// src/components/spinner.tsx
|
|
234
|
-
import clsx2 from "clsx";
|
|
235
|
-
|
|
236
125
|
// src/lib/i18n.ts
|
|
237
126
|
import i18n from "i18next";
|
|
238
127
|
import { initReactI18next, useTranslation } from "react-i18next";
|
|
239
|
-
|
|
240
|
-
// src/locales/es/ui.json
|
|
241
|
-
var ui_default = {
|
|
242
|
-
inputField: {
|
|
243
|
-
showPassword: "Mostrar contrase\xF1a",
|
|
244
|
-
hidePassword: "Ocultar contrase\xF1a",
|
|
245
|
-
clear: "Limpiar"
|
|
246
|
-
},
|
|
247
|
-
dialog: {
|
|
248
|
-
close: "Cerrar"
|
|
249
|
-
},
|
|
250
|
-
selectInput: {
|
|
251
|
-
placeholder: "Selecciona...",
|
|
252
|
-
loading: "Cargando...",
|
|
253
|
-
search: "Buscar...",
|
|
254
|
-
noResults: "Sin resultados.",
|
|
255
|
-
clear: "Limpiar selecci\xF3n"
|
|
256
|
-
},
|
|
257
|
-
passwordChecklist: {
|
|
258
|
-
minLength: "M\xEDnimo {{min}} caracteres",
|
|
259
|
-
hasUpperAndLower: "Una may\xFAscula y min\xFAscula",
|
|
260
|
-
hasNumber: "Un n\xFAmero",
|
|
261
|
-
hasSpecialChar: "Un car\xE1cter especial"
|
|
262
|
-
},
|
|
263
|
-
spinner: {
|
|
264
|
-
loading: "Cargando..."
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
// src/lib/i18n.ts
|
|
269
128
|
var uiI18n = i18n.createInstance();
|
|
270
129
|
void uiI18n.use(initReactI18next).init({
|
|
271
130
|
defaultNS: "ui",
|
|
@@ -278,7 +137,48 @@ void uiI18n.use(initReactI18next).init({
|
|
|
278
137
|
var setUiLanguage = (lng) => uiI18n.changeLanguage(lng);
|
|
279
138
|
var useUiT = () => useTranslation("ui", { i18n: uiI18n }).t;
|
|
280
139
|
|
|
140
|
+
// src/components/skeleton.tsx
|
|
141
|
+
import * as React2 from "react";
|
|
142
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
143
|
+
var Skeleton = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx4("div", { className: cn("bg-inactive animate-pulse rounded-md", className), ref, ...props }));
|
|
144
|
+
Skeleton.displayName = "Skeleton";
|
|
145
|
+
|
|
146
|
+
// src/components/breadcrumb.tsx
|
|
147
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
148
|
+
var Breadcrumb = React3.forwardRef(({ className, items, ...props }, ref) => {
|
|
149
|
+
const t = useUiT();
|
|
150
|
+
return /* @__PURE__ */ jsx5("nav", { "aria-label": t("breadcrumb.label"), ref, ...props, children: /* @__PURE__ */ jsx5("ol", { className: cn("flex items-center gap-1 text-sm", className), children: items.map((item, index) => {
|
|
151
|
+
const isLast = index === items.length - 1;
|
|
152
|
+
return /* @__PURE__ */ jsxs4("li", { className: "flex items-center gap-1", children: [
|
|
153
|
+
index > 0 && /* @__PURE__ */ jsx5("span", { "aria-hidden": true, className: "text-muted", children: "\u203A" }),
|
|
154
|
+
item.loading ? /* @__PURE__ */ jsx5(Skeleton, { className: "h-4 w-20" }) : item.onClick && !isLast ? /* @__PURE__ */ jsx5(
|
|
155
|
+
"button",
|
|
156
|
+
{
|
|
157
|
+
className: cn("text-muted hover:text-foreground rounded-sm transition-colors", focusRing),
|
|
158
|
+
onClick: item.onClick,
|
|
159
|
+
type: "button",
|
|
160
|
+
children: item.label
|
|
161
|
+
}
|
|
162
|
+
) : /* @__PURE__ */ jsx5(
|
|
163
|
+
"span",
|
|
164
|
+
{
|
|
165
|
+
"aria-current": isLast ? "page" : void 0,
|
|
166
|
+
className: isLast ? "text-foreground font-semibold" : "text-muted font-normal",
|
|
167
|
+
children: item.label
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
] }, `${item.label}-${index}`);
|
|
171
|
+
}) }) });
|
|
172
|
+
});
|
|
173
|
+
Breadcrumb.displayName = "Breadcrumb";
|
|
174
|
+
|
|
175
|
+
// src/components/button.tsx
|
|
176
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
177
|
+
import { cva } from "class-variance-authority";
|
|
178
|
+
import * as React5 from "react";
|
|
179
|
+
|
|
281
180
|
// src/components/spinner.tsx
|
|
181
|
+
import clsx from "clsx";
|
|
282
182
|
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
283
183
|
var sizes = {
|
|
284
184
|
lg: "70",
|
|
@@ -298,13 +198,15 @@ var Spinner = ({ className = "", loadingLabel, size = "md", variant = "primary"
|
|
|
298
198
|
/* @__PURE__ */ jsx6(
|
|
299
199
|
"svg",
|
|
300
200
|
{
|
|
201
|
+
"aria-hidden": true,
|
|
301
202
|
fill: "currentColor",
|
|
203
|
+
focusable: "false",
|
|
302
204
|
height: sizes[size],
|
|
303
205
|
stroke: variants[variant],
|
|
304
206
|
viewBox: "0 0 100 100",
|
|
305
207
|
width: sizes[size],
|
|
306
208
|
xmlns: "http://www.w3.org/2000/svg",
|
|
307
|
-
children: /* @__PURE__ */ jsxs5("g", { className:
|
|
209
|
+
children: /* @__PURE__ */ jsxs5("g", { className: clsx(className), children: [
|
|
308
210
|
/* @__PURE__ */ jsx6("circle", { cx: "50", cy: "50", fill: "none", opacity: "0.25", r: "35", stroke: "currentColor", strokeWidth: "10" }),
|
|
309
211
|
/* @__PURE__ */ jsx6(
|
|
310
212
|
"circle",
|
|
@@ -332,7 +234,7 @@ var Spinner = ({ className = "", loadingLabel, size = "md", variant = "primary"
|
|
|
332
234
|
] })
|
|
333
235
|
}
|
|
334
236
|
),
|
|
335
|
-
/* @__PURE__ */ jsx6("span", { className: "sr-only", children: loadingLabel ?? t("spinner.loading") })
|
|
237
|
+
/* @__PURE__ */ jsx6("span", { className: "sr-only", role: "status", children: loadingLabel ?? t("spinner.loading") })
|
|
336
238
|
] });
|
|
337
239
|
};
|
|
338
240
|
|
|
@@ -357,10 +259,10 @@ var TooltipContent = React4.forwardRef(({ className, sideOffset = 4, ...props },
|
|
|
357
259
|
) }));
|
|
358
260
|
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
359
261
|
var Tooltip = React4.forwardRef(
|
|
360
|
-
({ children, childrenClassName, className, message, sideTooltip = "top" }, ref) => {
|
|
262
|
+
({ asChild = false, children, childrenClassName, className, message, sideTooltip = "top" }, ref) => {
|
|
361
263
|
return /* @__PURE__ */ jsx7(TooltipProvider, { children: /* @__PURE__ */ jsxs6(TooltipRoot, { children: [
|
|
362
|
-
/* @__PURE__ */ jsx7(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx7("div", { className:
|
|
363
|
-
/* @__PURE__ */ jsx7(TooltipContent, { className
|
|
264
|
+
/* @__PURE__ */ jsx7(TooltipTrigger, { asChild: true, children: asChild ? children : /* @__PURE__ */ jsx7("div", { className: childrenClassName, ref, children }) }),
|
|
265
|
+
/* @__PURE__ */ jsx7(TooltipContent, { className, side: sideTooltip, children: /* @__PURE__ */ jsx7("p", { children: message }) })
|
|
364
266
|
] }) });
|
|
365
267
|
}
|
|
366
268
|
);
|
|
@@ -369,7 +271,10 @@ Tooltip.displayName = "Tooltip";
|
|
|
369
271
|
// src/components/button.tsx
|
|
370
272
|
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
371
273
|
var buttonVariants = cva(
|
|
372
|
-
|
|
274
|
+
[
|
|
275
|
+
"w-full inline-flex items-center justify-center gap-[10px] whitespace-nowrap rounded-[10px] border border-transparent text-base font-semibold transition-all duration-300 ease-in-out focus-visible:ring-offset-2 disabled:pointer-events-none disabled:bg-inactive disabled:text-inactive-text disabled:border-transparent cursor-pointer",
|
|
276
|
+
focusRing
|
|
277
|
+
],
|
|
373
278
|
{
|
|
374
279
|
defaultVariants: {
|
|
375
280
|
hoverStyle: "none",
|
|
@@ -387,7 +292,7 @@ var buttonVariants = cva(
|
|
|
387
292
|
hover:-translate-y-[1px] hover:shadow-lg
|
|
388
293
|
before:content-[''] before:absolute before:top-0 before:left-[-100%]
|
|
389
294
|
before:w-full before:h-full
|
|
390
|
-
before:bg-
|
|
295
|
+
before:bg-linear-to-r before:from-transparent before:via-inverse/15 before:to-transparent
|
|
391
296
|
before:transition-all before:duration-300
|
|
392
297
|
hover:before:left-[100%]
|
|
393
298
|
`
|
|
@@ -447,7 +352,7 @@ var Button = React5.forwardRef(
|
|
|
447
352
|
icon,
|
|
448
353
|
/* @__PURE__ */ jsx8("span", { className: cn("flex w-full items-center justify-center gap-2", childrenClassName), children }),
|
|
449
354
|
iconRight,
|
|
450
|
-
isLoading && /* @__PURE__ */ jsx8("div", { className: "absolute inset-0 flex items-center justify-center
|
|
355
|
+
isLoading && /* @__PURE__ */ jsx8("div", { className: "bg-foreground/10 absolute inset-0 flex items-center justify-center backdrop-blur-sm", children: /* @__PURE__ */ jsx8(Spinner, { size: "sm" }) })
|
|
451
356
|
]
|
|
452
357
|
}
|
|
453
358
|
);
|
|
@@ -461,7 +366,10 @@ import { cva as cva2 } from "class-variance-authority";
|
|
|
461
366
|
import * as React6 from "react";
|
|
462
367
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
463
368
|
var chipVariants = cva2(
|
|
464
|
-
|
|
369
|
+
[
|
|
370
|
+
"inline-flex cursor-pointer items-center justify-center rounded-full px-3 py-1.5 text-sm font-medium whitespace-nowrap transition-colors",
|
|
371
|
+
focusRing
|
|
372
|
+
],
|
|
465
373
|
{
|
|
466
374
|
defaultVariants: {
|
|
467
375
|
active: false
|
|
@@ -474,7 +382,16 @@ var chipVariants = cva2(
|
|
|
474
382
|
}
|
|
475
383
|
}
|
|
476
384
|
);
|
|
477
|
-
var Chip = React6.forwardRef(({ active, className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
385
|
+
var Chip = React6.forwardRef(({ active, className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
386
|
+
"button",
|
|
387
|
+
{
|
|
388
|
+
"aria-pressed": active ?? void 0,
|
|
389
|
+
className: cn(chipVariants({ active }), className),
|
|
390
|
+
ref,
|
|
391
|
+
type: "button",
|
|
392
|
+
...props
|
|
393
|
+
}
|
|
394
|
+
));
|
|
478
395
|
Chip.displayName = "Chip";
|
|
479
396
|
|
|
480
397
|
// src/components/command.tsx
|
|
@@ -513,7 +430,7 @@ var DialogContent = React7.forwardRef(
|
|
|
513
430
|
DialogPrimitive.Content,
|
|
514
431
|
{
|
|
515
432
|
className: cn(
|
|
516
|
-
`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
|
|
433
|
+
`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 ${zDialogContent} grid w-[calc(100%-2rem)] max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 rounded-2xl p-6 shadow-lg duration-200 outline-none`,
|
|
517
434
|
isAbsolute ? "absolute top-[50%] left-[50%]" : "fixed top-[50%] left-[50%]",
|
|
518
435
|
className
|
|
519
436
|
),
|
|
@@ -521,10 +438,19 @@ var DialogContent = React7.forwardRef(
|
|
|
521
438
|
...props,
|
|
522
439
|
children: [
|
|
523
440
|
children,
|
|
524
|
-
isCloseIcon && /* @__PURE__ */ jsxs8(
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
441
|
+
isCloseIcon && /* @__PURE__ */ jsxs8(
|
|
442
|
+
DialogPrimitive.Close,
|
|
443
|
+
{
|
|
444
|
+
className: cn(
|
|
445
|
+
"data-[state=open]:text-muted ring-offset-surface data-[state=open]:bg-hover hover:bg-hover absolute top-5 right-5 flex h-8 w-8 min-w-8 cursor-pointer items-center justify-center rounded-full bg-transparent opacity-70 transition-all hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-offset-2 disabled:pointer-events-none",
|
|
446
|
+
focusRing
|
|
447
|
+
),
|
|
448
|
+
children: [
|
|
449
|
+
/* @__PURE__ */ jsx10(XIcon, { "aria-hidden": true, className: "text-body h-4 w-4" }),
|
|
450
|
+
/* @__PURE__ */ jsx10("span", { className: "sr-only", children: closeLabel ?? t("dialog.close") })
|
|
451
|
+
]
|
|
452
|
+
}
|
|
453
|
+
)
|
|
528
454
|
]
|
|
529
455
|
}
|
|
530
456
|
)
|
|
@@ -541,12 +467,11 @@ var DialogTitle = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
541
467
|
{
|
|
542
468
|
className: cn("text-lg leading-none font-semibold tracking-tight", className),
|
|
543
469
|
ref,
|
|
544
|
-
...props
|
|
545
|
-
children: /* @__PURE__ */ jsx10("span", { children: props.children })
|
|
470
|
+
...props
|
|
546
471
|
}
|
|
547
472
|
));
|
|
548
473
|
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
549
|
-
var DialogDescription = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx10(DialogPrimitive.Description, { className: cn("text-muted text-sm", className), ref, ...props
|
|
474
|
+
var DialogDescription = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx10(DialogPrimitive.Description, { className: cn("text-muted text-sm", className), ref, ...props }));
|
|
550
475
|
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
551
476
|
|
|
552
477
|
// src/components/command.tsx
|
|
@@ -563,8 +488,8 @@ Command.displayName = CommandPrimitive.displayName;
|
|
|
563
488
|
var CommandDialog = ({ children, ...props }) => {
|
|
564
489
|
return /* @__PURE__ */ jsx11(Dialog, { ...props, children: /* @__PURE__ */ jsx11(DialogContent, { className: "overflow-hidden p-0", children: /* @__PURE__ */ jsx11(Command, { className: "**:[[cmdk-group-heading]]:text-muted [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5 **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group]]:px-2 **:[[cmdk-input]]:h-12 **:[[cmdk-item]]:px-2 **:[[cmdk-item]]:py-3", children }) }) });
|
|
565
490
|
};
|
|
566
|
-
var CommandInput = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs9("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "", children: [
|
|
567
|
-
/* @__PURE__ */ jsx11(MagnifyingGlassIcon, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
|
|
491
|
+
var CommandInput = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs9("div", { className: "border-border flex items-center border-b px-3", "cmdk-input-wrapper": "", children: [
|
|
492
|
+
/* @__PURE__ */ jsx11(MagnifyingGlassIcon, { "aria-hidden": true, className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
|
|
568
493
|
/* @__PURE__ */ jsx11(
|
|
569
494
|
CommandPrimitive.Input,
|
|
570
495
|
{
|
|
@@ -613,93 +538,29 @@ var CommandShortcut = ({ className, ...props }) => {
|
|
|
613
538
|
};
|
|
614
539
|
CommandShortcut.displayName = "CommandShortcut";
|
|
615
540
|
|
|
616
|
-
// src/components/form.tsx
|
|
617
|
-
import { Slot as Slot2 } from "@radix-ui/react-slot";
|
|
618
|
-
import * as React9 from "react";
|
|
619
|
-
import { Controller, FormProvider, useFormContext } from "react-hook-form";
|
|
620
|
-
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
621
|
-
var Form = FormProvider;
|
|
622
|
-
var FormFieldContext = React9.createContext(null);
|
|
623
|
-
var FormField = ({
|
|
624
|
-
...props
|
|
625
|
-
}) => {
|
|
626
|
-
return /* @__PURE__ */ jsx12(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx12(Controller, { ...props }) });
|
|
627
|
-
};
|
|
628
|
-
var useFormField = () => {
|
|
629
|
-
const fieldContext = React9.useContext(FormFieldContext);
|
|
630
|
-
const itemContext = React9.useContext(FormItemContext);
|
|
631
|
-
const { formState, getFieldState } = useFormContext();
|
|
632
|
-
if (!fieldContext) {
|
|
633
|
-
throw new Error("useFormField must be used within <FormField>");
|
|
634
|
-
}
|
|
635
|
-
if (!itemContext) {
|
|
636
|
-
throw new Error("useFormField must be used within <FormItem>");
|
|
637
|
-
}
|
|
638
|
-
const fieldState = getFieldState(fieldContext.name, formState);
|
|
639
|
-
const { id } = itemContext;
|
|
640
|
-
return {
|
|
641
|
-
formDescriptionId: `${id}-form-item-description`,
|
|
642
|
-
formItemId: `${id}-form-item`,
|
|
643
|
-
formMessageId: `${id}-form-item-message`,
|
|
644
|
-
id,
|
|
645
|
-
name: fieldContext.name,
|
|
646
|
-
...fieldState
|
|
647
|
-
};
|
|
648
|
-
};
|
|
649
|
-
var FormItemContext = React9.createContext(null);
|
|
650
|
-
var FormItem = React9.forwardRef(
|
|
651
|
-
({ className, ...props }, ref) => {
|
|
652
|
-
const id = React9.useId();
|
|
653
|
-
return /* @__PURE__ */ jsx12(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx12("div", { className: cn("space-y-1", className), ref, ...props }) });
|
|
654
|
-
}
|
|
655
|
-
);
|
|
656
|
-
FormItem.displayName = "FormItem";
|
|
657
|
-
var FormControl = React9.forwardRef(
|
|
658
|
-
({ ...props }, ref) => {
|
|
659
|
-
const { error, formDescriptionId, formItemId, formMessageId } = useFormField();
|
|
660
|
-
return /* @__PURE__ */ jsx12(
|
|
661
|
-
Slot2,
|
|
662
|
-
{
|
|
663
|
-
"aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
|
|
664
|
-
"aria-invalid": !!error,
|
|
665
|
-
id: formItemId,
|
|
666
|
-
ref,
|
|
667
|
-
...props
|
|
668
|
-
}
|
|
669
|
-
);
|
|
670
|
-
}
|
|
671
|
-
);
|
|
672
|
-
FormControl.displayName = "FormControl";
|
|
673
|
-
var FormMessage = React9.forwardRef(
|
|
674
|
-
({ children, className, ...props }, ref) => {
|
|
675
|
-
const { error, formMessageId } = useFormField();
|
|
676
|
-
const body = error?.message ? String(error.message) : children;
|
|
677
|
-
if (!body) {
|
|
678
|
-
return null;
|
|
679
|
-
}
|
|
680
|
-
return /* @__PURE__ */ jsx12(
|
|
681
|
-
"p",
|
|
682
|
-
{
|
|
683
|
-
className: cn("text-destructive text-[0.8rem] font-medium", className),
|
|
684
|
-
id: formMessageId,
|
|
685
|
-
ref,
|
|
686
|
-
...props,
|
|
687
|
-
children: body
|
|
688
|
-
}
|
|
689
|
-
);
|
|
690
|
-
}
|
|
691
|
-
);
|
|
692
|
-
FormMessage.displayName = "FormMessage";
|
|
693
|
-
|
|
694
541
|
// src/components/form-fields/input-field.tsx
|
|
695
542
|
import { EyeIcon, EyeSlashIcon, XIcon as XIcon2 } from "@phosphor-icons/react";
|
|
696
543
|
import { useState } from "react";
|
|
697
544
|
|
|
698
545
|
// src/components/input.tsx
|
|
699
|
-
import * as
|
|
700
|
-
import { jsx as
|
|
701
|
-
var
|
|
702
|
-
|
|
546
|
+
import * as React9 from "react";
|
|
547
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
548
|
+
var NUMBER_ALLOWED_KEYS = /* @__PURE__ */ new Set([
|
|
549
|
+
"ArrowDown",
|
|
550
|
+
"ArrowLeft",
|
|
551
|
+
"ArrowRight",
|
|
552
|
+
"ArrowUp",
|
|
553
|
+
"Backspace",
|
|
554
|
+
"Delete",
|
|
555
|
+
"End",
|
|
556
|
+
"Enter",
|
|
557
|
+
"Escape",
|
|
558
|
+
"Home",
|
|
559
|
+
"Tab"
|
|
560
|
+
]);
|
|
561
|
+
var isAllowedNumberKey = (event) => event.ctrlKey || event.metaKey || event.altKey || NUMBER_ALLOWED_KEYS.has(event.key) || /^[0-9]$/.test(event.key);
|
|
562
|
+
var Input = React9.forwardRef(({ className, onKeyDown, type, ...props }, ref) => {
|
|
563
|
+
return /* @__PURE__ */ jsx12(
|
|
703
564
|
"input",
|
|
704
565
|
{
|
|
705
566
|
className: cn(
|
|
@@ -710,15 +571,8 @@ var Input = React10.forwardRef(({ className, onKeyDown, type, ...props }, ref) =
|
|
|
710
571
|
),
|
|
711
572
|
onKeyDown: (e) => {
|
|
712
573
|
onKeyDown?.(e);
|
|
713
|
-
if (e.defaultPrevented) return;
|
|
714
|
-
|
|
715
|
-
const allowedKeys = ["Backspace", "Tab", "Enter", "Escape", "ArrowLeft", "ArrowUp", "ArrowRight", "ArrowDown"];
|
|
716
|
-
if (allowedKeys.includes(key)) {
|
|
717
|
-
return;
|
|
718
|
-
}
|
|
719
|
-
if (!(key >= "0" && key <= "9") && type === "number") {
|
|
720
|
-
e.preventDefault();
|
|
721
|
-
}
|
|
574
|
+
if (e.defaultPrevented || type !== "number") return;
|
|
575
|
+
if (!isAllowedNumberKey(e)) e.preventDefault();
|
|
722
576
|
},
|
|
723
577
|
ref,
|
|
724
578
|
type,
|
|
@@ -728,69 +582,24 @@ var Input = React10.forwardRef(({ className, onKeyDown, type, ...props }, ref) =
|
|
|
728
582
|
});
|
|
729
583
|
Input.displayName = "Input";
|
|
730
584
|
|
|
731
|
-
// src/components/label.tsx
|
|
732
|
-
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
733
|
-
import { cva as cva3 } from "class-variance-authority";
|
|
734
|
-
import * as React11 from "react";
|
|
735
|
-
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
736
|
-
var labelVariants = cva3("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
737
|
-
var Label = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx14(LabelPrimitive.Root, { className: cn(labelVariants(), className), ref, ...props }));
|
|
738
|
-
Label.displayName = LabelPrimitive.Root.displayName;
|
|
739
|
-
|
|
740
|
-
// src/components/form-fields/label-field.tsx
|
|
741
|
-
import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
742
|
-
var LabelField = ({ label, labelClassName, name, visualRequired }) => {
|
|
743
|
-
return /* @__PURE__ */ jsxs10(
|
|
744
|
-
Label,
|
|
745
|
-
{
|
|
746
|
-
className: cn("text-body mb-2 text-start text-sm leading-none font-normal tracking-normal", labelClassName),
|
|
747
|
-
htmlFor: name,
|
|
748
|
-
children: [
|
|
749
|
-
/* @__PURE__ */ jsx15("span", { children: label }),
|
|
750
|
-
" ",
|
|
751
|
-
visualRequired && /* @__PURE__ */ jsx15("span", { className: "text-destructive", children: " *" })
|
|
752
|
-
]
|
|
753
|
-
}
|
|
754
|
-
);
|
|
755
|
-
};
|
|
756
|
-
|
|
757
|
-
// src/components/form-fields/form-field-shell.tsx
|
|
758
|
-
import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
759
|
-
var FormFieldShell = ({
|
|
760
|
-
children,
|
|
761
|
-
hasError,
|
|
762
|
-
label,
|
|
763
|
-
labelClassName,
|
|
764
|
-
mainClassName,
|
|
765
|
-
name,
|
|
766
|
-
visualRequired
|
|
767
|
-
}) => /* @__PURE__ */ jsxs11(FormItem, { className: cn("flex flex-col", mainClassName), children: [
|
|
768
|
-
/* @__PURE__ */ jsx16(
|
|
769
|
-
LabelField,
|
|
770
|
-
{
|
|
771
|
-
label,
|
|
772
|
-
labelClassName: cn(labelClassName, hasError && "text-destructive"),
|
|
773
|
-
name,
|
|
774
|
-
visualRequired
|
|
775
|
-
}
|
|
776
|
-
),
|
|
777
|
-
/* @__PURE__ */ jsx16(FormControl, { children }),
|
|
778
|
-
/* @__PURE__ */ jsx16(FormMessage, {})
|
|
779
|
-
] });
|
|
780
|
-
|
|
781
585
|
// src/components/form-fields/input-field.tsx
|
|
782
|
-
import { jsx as
|
|
586
|
+
import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
587
|
+
var iconButtonClassName = cn("flex items-center justify-center rounded-sm", focusRing);
|
|
783
588
|
var InputField = ({
|
|
589
|
+
autoComplete,
|
|
784
590
|
clearLabel,
|
|
785
591
|
control,
|
|
786
592
|
disabled,
|
|
787
593
|
hidePasswordLabel,
|
|
788
594
|
inputClassName,
|
|
595
|
+
inputMode,
|
|
789
596
|
isClearable,
|
|
790
597
|
label,
|
|
791
598
|
labelClassName,
|
|
792
599
|
mainClassName,
|
|
600
|
+
maxLength,
|
|
793
601
|
name,
|
|
602
|
+
onBlur,
|
|
794
603
|
onClear,
|
|
795
604
|
placeholder,
|
|
796
605
|
showPasswordLabel,
|
|
@@ -804,14 +613,16 @@ var InputField = ({
|
|
|
804
613
|
};
|
|
805
614
|
const isPassword = type === "password";
|
|
806
615
|
const inputType = isPassword ? isPasswordVisible ? "text" : "password" : type;
|
|
807
|
-
|
|
616
|
+
const resolvedClearLabel = clearLabel ?? t("inputField.clear");
|
|
617
|
+
const passwordToggleLabel = isPasswordVisible ? hidePasswordLabel ?? t("inputField.hidePassword") : showPasswordLabel ?? t("inputField.showPassword");
|
|
618
|
+
return /* @__PURE__ */ jsx13(
|
|
808
619
|
FormField,
|
|
809
620
|
{
|
|
810
621
|
control,
|
|
811
622
|
name,
|
|
812
623
|
render: ({ field, fieldState }) => {
|
|
813
624
|
const hasError = !!fieldState.error;
|
|
814
|
-
return /* @__PURE__ */
|
|
625
|
+
return /* @__PURE__ */ jsx13(
|
|
815
626
|
FormFieldShell,
|
|
816
627
|
{
|
|
817
628
|
hasError,
|
|
@@ -820,12 +631,13 @@ var InputField = ({
|
|
|
820
631
|
mainClassName,
|
|
821
632
|
name,
|
|
822
633
|
visualRequired,
|
|
823
|
-
children: /* @__PURE__ */
|
|
824
|
-
/* @__PURE__ */
|
|
634
|
+
children: (controlProps) => /* @__PURE__ */ jsxs10("div", { className: "relative", children: [
|
|
635
|
+
/* @__PURE__ */ jsx13(
|
|
825
636
|
Input,
|
|
826
637
|
{
|
|
827
638
|
...field,
|
|
828
|
-
|
|
639
|
+
...controlProps,
|
|
640
|
+
autoComplete: autoComplete ?? (isPassword ? "current-password" : void 0),
|
|
829
641
|
className: cn(
|
|
830
642
|
inputClassName,
|
|
831
643
|
hasError && "border-destructive",
|
|
@@ -835,31 +647,39 @@ var InputField = ({
|
|
|
835
647
|
"data-bwignore": isPassword || void 0,
|
|
836
648
|
"data-lpignore": isPassword || void 0,
|
|
837
649
|
disabled,
|
|
650
|
+
inputMode,
|
|
651
|
+
maxLength,
|
|
838
652
|
min: type === "number" ? 0 : void 0,
|
|
653
|
+
onBlur: (event) => {
|
|
654
|
+
field.onBlur();
|
|
655
|
+
onBlur?.(event);
|
|
656
|
+
},
|
|
839
657
|
placeholder,
|
|
840
658
|
type: inputType,
|
|
841
659
|
value: field.value ?? ""
|
|
842
660
|
}
|
|
843
661
|
),
|
|
844
|
-
/* @__PURE__ */
|
|
845
|
-
field.value && isClearable && /* @__PURE__ */
|
|
662
|
+
/* @__PURE__ */ jsxs10("div", { className: "absolute inset-y-0 right-0 flex items-center space-x-2 pr-2", children: [
|
|
663
|
+
field.value && isClearable && /* @__PURE__ */ jsx13(
|
|
846
664
|
"button",
|
|
847
665
|
{
|
|
848
|
-
|
|
666
|
+
"aria-label": resolvedClearLabel,
|
|
667
|
+
className: iconButtonClassName,
|
|
849
668
|
onClick: onClear,
|
|
850
|
-
title:
|
|
669
|
+
title: resolvedClearLabel,
|
|
851
670
|
type: "button",
|
|
852
|
-
children: /* @__PURE__ */
|
|
671
|
+
children: /* @__PURE__ */ jsx13(XIcon2, { "aria-hidden": true, size: 18 })
|
|
853
672
|
}
|
|
854
673
|
),
|
|
855
|
-
|
|
674
|
+
isPassword && /* @__PURE__ */ jsx13(
|
|
856
675
|
"button",
|
|
857
676
|
{
|
|
858
|
-
|
|
677
|
+
"aria-label": passwordToggleLabel,
|
|
678
|
+
className: iconButtonClassName,
|
|
859
679
|
onClick: togglePasswordVisibility,
|
|
860
|
-
title:
|
|
680
|
+
title: passwordToggleLabel,
|
|
861
681
|
type: "button",
|
|
862
|
-
children: isPasswordVisible ? /* @__PURE__ */
|
|
682
|
+
children: isPasswordVisible ? /* @__PURE__ */ jsx13(EyeIcon, { "aria-hidden": true, size: 18 }) : /* @__PURE__ */ jsx13(EyeSlashIcon, { "aria-hidden": true, size: 20 })
|
|
863
683
|
}
|
|
864
684
|
)
|
|
865
685
|
] })
|
|
@@ -871,340 +691,16 @@ var InputField = ({
|
|
|
871
691
|
);
|
|
872
692
|
};
|
|
873
693
|
|
|
874
|
-
// src/components/google-map-picker.tsx
|
|
875
|
-
import { AdvancedMarker, APIProvider, Map as Map2 } from "@vis.gl/react-google-maps";
|
|
876
|
-
|
|
877
|
-
// src/components/use-google-map-picker.ts
|
|
878
|
-
import { useMap, useMapsLibrary } from "@vis.gl/react-google-maps";
|
|
879
|
-
import { useCallback, useEffect, useMemo, useRef, useState as useState2 } from "react";
|
|
880
|
-
var PICKER_MAP_ID = "komensal-restaurant-map";
|
|
881
|
-
var SELECTED_ZOOM = 15;
|
|
882
|
-
var CITY_ZOOM = 12;
|
|
883
|
-
var DEBOUNCE_MS = 300;
|
|
884
|
-
var BLUR_CLOSE_DELAY_MS = 150;
|
|
885
|
-
var parseComponents = (components) => {
|
|
886
|
-
const find = (type) => components.find((c) => c.types.includes(type));
|
|
887
|
-
const country = find("country");
|
|
888
|
-
const department = find("administrative_area_level_1");
|
|
889
|
-
const city = find("locality") ?? find("administrative_area_level_2");
|
|
890
|
-
return {
|
|
891
|
-
city: city?.long ?? null,
|
|
892
|
-
country: country?.short ?? null,
|
|
893
|
-
countryName: country?.long ?? null,
|
|
894
|
-
department: department?.long ?? null
|
|
895
|
-
};
|
|
896
|
-
};
|
|
897
|
-
function useGoogleMapPicker({
|
|
898
|
-
centerOn,
|
|
899
|
-
countryCode,
|
|
900
|
-
disabled,
|
|
901
|
-
initialPosition,
|
|
902
|
-
locationQuery,
|
|
903
|
-
locationZoom,
|
|
904
|
-
onAddressResolved,
|
|
905
|
-
onChange,
|
|
906
|
-
onError,
|
|
907
|
-
value
|
|
908
|
-
}) {
|
|
909
|
-
const placesLib = useMapsLibrary("places");
|
|
910
|
-
const geocodingLib = useMapsLibrary("geocoding");
|
|
911
|
-
const map = useMap(PICKER_MAP_ID);
|
|
912
|
-
const onChangeRef = useRef(onChange);
|
|
913
|
-
const onResolvedRef = useRef(onAddressResolved);
|
|
914
|
-
const onErrorRef = useRef(onError);
|
|
915
|
-
const geocoder = useMemo(
|
|
916
|
-
() => geocodingLib ? new geocodingLib.Geocoder() : null,
|
|
917
|
-
[geocodingLib]
|
|
918
|
-
);
|
|
919
|
-
const debounceRef = useRef(null);
|
|
920
|
-
const blurTimeoutRef = useRef(null);
|
|
921
|
-
const [inputValue, setInputValue] = useState2(value);
|
|
922
|
-
const [suggestions, setSuggestions] = useState2([]);
|
|
923
|
-
const [showDropdown, setShowDropdown] = useState2(false);
|
|
924
|
-
const [sessionToken, setSessionToken] = useState2();
|
|
925
|
-
const [position, setPosition] = useState2(initialPosition ?? null);
|
|
926
|
-
useEffect(() => {
|
|
927
|
-
onChangeRef.current = onChange;
|
|
928
|
-
onResolvedRef.current = onAddressResolved;
|
|
929
|
-
onErrorRef.current = onError;
|
|
930
|
-
});
|
|
931
|
-
useEffect(
|
|
932
|
-
() => () => {
|
|
933
|
-
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
934
|
-
if (blurTimeoutRef.current) clearTimeout(blurTimeoutRef.current);
|
|
935
|
-
},
|
|
936
|
-
[]
|
|
937
|
-
);
|
|
938
|
-
const [prevValue, setPrevValue] = useState2(value);
|
|
939
|
-
if (prevValue !== value) {
|
|
940
|
-
setPrevValue(value);
|
|
941
|
-
setInputValue(value);
|
|
942
|
-
}
|
|
943
|
-
useEffect(() => {
|
|
944
|
-
if (map && centerOn) {
|
|
945
|
-
map.panTo(centerOn);
|
|
946
|
-
map.setZoom(CITY_ZOOM);
|
|
947
|
-
}
|
|
948
|
-
}, [map, centerOn]);
|
|
949
|
-
useEffect(() => {
|
|
950
|
-
if (map && position) {
|
|
951
|
-
map.panTo(position);
|
|
952
|
-
map.setZoom(SELECTED_ZOOM);
|
|
953
|
-
}
|
|
954
|
-
}, [map, position]);
|
|
955
|
-
const [prevPlacesLib, setPrevPlacesLib] = useState2(placesLib);
|
|
956
|
-
if (prevPlacesLib !== placesLib) {
|
|
957
|
-
setPrevPlacesLib(placesLib);
|
|
958
|
-
if (placesLib) setSessionToken(new placesLib.AutocompleteSessionToken());
|
|
959
|
-
}
|
|
960
|
-
useEffect(() => {
|
|
961
|
-
if (!geocoder || !locationQuery || !map || position) return;
|
|
962
|
-
const g = geocoder;
|
|
963
|
-
const ctrl = { cancelled: false };
|
|
964
|
-
void (async () => {
|
|
965
|
-
try {
|
|
966
|
-
const { results } = await g.geocode({ address: locationQuery });
|
|
967
|
-
if (ctrl.cancelled || results.length === 0) return;
|
|
968
|
-
const loc = results[0].geometry.location;
|
|
969
|
-
map.panTo({ lat: loc.lat(), lng: loc.lng() });
|
|
970
|
-
map.setZoom(locationZoom ?? CITY_ZOOM);
|
|
971
|
-
} catch (error) {
|
|
972
|
-
if (!ctrl.cancelled) {
|
|
973
|
-
console.error("[GoogleMapPicker] geocode by query failed", error);
|
|
974
|
-
onErrorRef.current?.(error);
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
})();
|
|
978
|
-
return () => {
|
|
979
|
-
ctrl.cancelled = true;
|
|
980
|
-
};
|
|
981
|
-
}, [geocoder, locationQuery, locationZoom, map, position]);
|
|
982
|
-
const fetchSuggestions = useCallback(
|
|
983
|
-
async (input) => {
|
|
984
|
-
if (!placesLib || input.length < 2) {
|
|
985
|
-
setSuggestions([]);
|
|
986
|
-
return;
|
|
987
|
-
}
|
|
988
|
-
try {
|
|
989
|
-
const result = await placesLib.AutocompleteSuggestion.fetchAutocompleteSuggestions({
|
|
990
|
-
includedRegionCodes: countryCode ? [countryCode.trim().toLowerCase()] : void 0,
|
|
991
|
-
input,
|
|
992
|
-
sessionToken
|
|
993
|
-
});
|
|
994
|
-
setSuggestions(result.suggestions);
|
|
995
|
-
setShowDropdown(true);
|
|
996
|
-
} catch (error) {
|
|
997
|
-
console.error("[GoogleMapPicker] fetchAutocompleteSuggestions failed", error);
|
|
998
|
-
onErrorRef.current?.(error);
|
|
999
|
-
setSuggestions([]);
|
|
1000
|
-
}
|
|
1001
|
-
},
|
|
1002
|
-
[placesLib, sessionToken, countryCode]
|
|
1003
|
-
);
|
|
1004
|
-
const reverseGeocode = useCallback(
|
|
1005
|
-
async (latLng) => {
|
|
1006
|
-
if (!geocoder) return;
|
|
1007
|
-
try {
|
|
1008
|
-
const { results } = await geocoder.geocode({ location: latLng });
|
|
1009
|
-
if (results.length > 0) {
|
|
1010
|
-
const result = results[0];
|
|
1011
|
-
const address = result.formatted_address;
|
|
1012
|
-
setInputValue(address);
|
|
1013
|
-
onChangeRef.current(address);
|
|
1014
|
-
const parts = parseComponents(
|
|
1015
|
-
result.address_components.map((c) => ({ long: c.long_name, short: c.short_name, types: c.types }))
|
|
1016
|
-
);
|
|
1017
|
-
onResolvedRef.current?.({ address, lat: latLng.lat, lng: latLng.lng, ...parts });
|
|
1018
|
-
}
|
|
1019
|
-
} catch (error) {
|
|
1020
|
-
console.error("[GoogleMapPicker] reverse geocode failed", error);
|
|
1021
|
-
onErrorRef.current?.(error);
|
|
1022
|
-
}
|
|
1023
|
-
},
|
|
1024
|
-
[geocoder]
|
|
1025
|
-
);
|
|
1026
|
-
const handleInputChange = (e) => {
|
|
1027
|
-
const val = e.target.value;
|
|
1028
|
-
setInputValue(val);
|
|
1029
|
-
onChangeRef.current(val);
|
|
1030
|
-
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
1031
|
-
debounceRef.current = setTimeout(() => void fetchSuggestions(val), DEBOUNCE_MS);
|
|
1032
|
-
};
|
|
1033
|
-
const handleSelect = async (suggestion) => {
|
|
1034
|
-
const prediction = suggestion.placePrediction;
|
|
1035
|
-
if (!prediction) return;
|
|
1036
|
-
const place = prediction.toPlace();
|
|
1037
|
-
await place.fetchFields({ fields: ["formattedAddress", "location", "addressComponents"] });
|
|
1038
|
-
const address = place.formattedAddress ?? prediction.text.text;
|
|
1039
|
-
setInputValue(address);
|
|
1040
|
-
onChangeRef.current(address);
|
|
1041
|
-
setSuggestions([]);
|
|
1042
|
-
setShowDropdown(false);
|
|
1043
|
-
const lat = place.location?.lat() ?? null;
|
|
1044
|
-
const lng = place.location?.lng() ?? null;
|
|
1045
|
-
if (place.location) {
|
|
1046
|
-
setPosition({ lat: place.location.lat(), lng: place.location.lng() });
|
|
1047
|
-
}
|
|
1048
|
-
const parts = parseComponents(
|
|
1049
|
-
(place.addressComponents ?? []).map((c) => ({ long: c.longText, short: c.shortText, types: c.types }))
|
|
1050
|
-
);
|
|
1051
|
-
onResolvedRef.current?.({ address, lat, lng, ...parts });
|
|
1052
|
-
if (placesLib) setSessionToken(new placesLib.AutocompleteSessionToken());
|
|
1053
|
-
};
|
|
1054
|
-
const handleBlur = () => {
|
|
1055
|
-
if (blurTimeoutRef.current) clearTimeout(blurTimeoutRef.current);
|
|
1056
|
-
blurTimeoutRef.current = setTimeout(() => setShowDropdown(false), BLUR_CLOSE_DELAY_MS);
|
|
1057
|
-
};
|
|
1058
|
-
const handleMapClick = useCallback(
|
|
1059
|
-
(e) => {
|
|
1060
|
-
if (disabled || !e.detail.latLng) return;
|
|
1061
|
-
const latLng = e.detail.latLng;
|
|
1062
|
-
setPosition(latLng);
|
|
1063
|
-
void reverseGeocode(latLng);
|
|
1064
|
-
},
|
|
1065
|
-
[disabled, reverseGeocode]
|
|
1066
|
-
);
|
|
1067
|
-
const handleMarkerDragEnd = useCallback(
|
|
1068
|
-
(e) => {
|
|
1069
|
-
const latLng = e.latLng;
|
|
1070
|
-
if (!latLng) return;
|
|
1071
|
-
const pos = { lat: latLng.lat(), lng: latLng.lng() };
|
|
1072
|
-
setPosition(pos);
|
|
1073
|
-
void reverseGeocode(pos);
|
|
1074
|
-
},
|
|
1075
|
-
[reverseGeocode]
|
|
1076
|
-
);
|
|
1077
|
-
return {
|
|
1078
|
-
handleBlur,
|
|
1079
|
-
handleInputChange,
|
|
1080
|
-
handleMapClick,
|
|
1081
|
-
handleMarkerDragEnd,
|
|
1082
|
-
handleSelect,
|
|
1083
|
-
inputValue,
|
|
1084
|
-
position,
|
|
1085
|
-
setShowDropdown,
|
|
1086
|
-
showDropdown,
|
|
1087
|
-
suggestions
|
|
1088
|
-
};
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
// src/components/google-map-picker.tsx
|
|
1092
|
-
import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1093
|
-
var DEFAULT_CENTER = { lat: 4.711, lng: -74.0721 };
|
|
1094
|
-
var MapPickerContent = (props) => {
|
|
1095
|
-
const { disabled, hasError, mapId, placeholder } = props;
|
|
1096
|
-
const {
|
|
1097
|
-
handleBlur,
|
|
1098
|
-
handleInputChange,
|
|
1099
|
-
handleMapClick,
|
|
1100
|
-
handleMarkerDragEnd,
|
|
1101
|
-
handleSelect,
|
|
1102
|
-
inputValue,
|
|
1103
|
-
position,
|
|
1104
|
-
setShowDropdown,
|
|
1105
|
-
showDropdown,
|
|
1106
|
-
suggestions
|
|
1107
|
-
} = useGoogleMapPicker(props);
|
|
1108
|
-
return /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-3", children: [
|
|
1109
|
-
/* @__PURE__ */ jsxs13("div", { className: "relative", children: [
|
|
1110
|
-
/* @__PURE__ */ jsx18(
|
|
1111
|
-
"input",
|
|
1112
|
-
{
|
|
1113
|
-
className: cn(inputBase, inputFocus, hasError && "border-destructive"),
|
|
1114
|
-
disabled,
|
|
1115
|
-
onBlur: handleBlur,
|
|
1116
|
-
onChange: handleInputChange,
|
|
1117
|
-
onFocus: () => suggestions.length > 0 && setShowDropdown(true),
|
|
1118
|
-
placeholder,
|
|
1119
|
-
type: "text",
|
|
1120
|
-
value: inputValue
|
|
1121
|
-
}
|
|
1122
|
-
),
|
|
1123
|
-
showDropdown && suggestions.length > 0 && /* @__PURE__ */ jsx18(
|
|
1124
|
-
"ul",
|
|
1125
|
-
{
|
|
1126
|
-
className: cn(
|
|
1127
|
-
"border-border bg-surface absolute mt-1 w-full overflow-hidden rounded-[10px] border shadow-md",
|
|
1128
|
-
zPopover
|
|
1129
|
-
),
|
|
1130
|
-
children: suggestions.map((suggestion) => /* @__PURE__ */ jsx18("li", { children: /* @__PURE__ */ jsx18(
|
|
1131
|
-
"button",
|
|
1132
|
-
{
|
|
1133
|
-
className: "text-foreground hover:bg-hover w-full px-4 py-3 text-left text-sm transition-colors",
|
|
1134
|
-
onClick: () => void handleSelect(suggestion),
|
|
1135
|
-
type: "button",
|
|
1136
|
-
children: suggestion.placePrediction?.text.text ?? ""
|
|
1137
|
-
}
|
|
1138
|
-
) }, suggestion.placePrediction?.placeId ?? suggestion.placePrediction?.text.text))
|
|
1139
|
-
}
|
|
1140
|
-
)
|
|
1141
|
-
] }),
|
|
1142
|
-
/* @__PURE__ */ jsx18("div", { className: "border-border h-59 overflow-hidden rounded-[10px] border md:h-87.5", children: /* @__PURE__ */ jsx18(
|
|
1143
|
-
Map2,
|
|
1144
|
-
{
|
|
1145
|
-
defaultCenter: DEFAULT_CENTER,
|
|
1146
|
-
defaultZoom: 5,
|
|
1147
|
-
disableDefaultUI: true,
|
|
1148
|
-
gestureHandling: "cooperative",
|
|
1149
|
-
id: PICKER_MAP_ID,
|
|
1150
|
-
mapId: mapId ?? import.meta.env.VITE_GOOGLE_MAPS_MAP_ID ?? "DEMO_MAP_ID",
|
|
1151
|
-
onClick: handleMapClick,
|
|
1152
|
-
style: { height: "100%", width: "100%" },
|
|
1153
|
-
children: position && /* @__PURE__ */ jsx18(AdvancedMarker, { draggable: !disabled, onDragEnd: handleMarkerDragEnd, position })
|
|
1154
|
-
}
|
|
1155
|
-
) })
|
|
1156
|
-
] });
|
|
1157
|
-
};
|
|
1158
|
-
var GoogleMapPicker = (props) => /* @__PURE__ */ jsx18(APIProvider, { apiKey: props.apiKey ?? import.meta.env.VITE_GOOGLE_MAPS_API_KEY ?? "", language: "es", region: "CO", children: /* @__PURE__ */ jsx18(MapPickerContent, { ...props }) });
|
|
1159
|
-
|
|
1160
|
-
// src/components/form-fields/map-picker-field.tsx
|
|
1161
|
-
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
1162
|
-
var MapPickerField = ({
|
|
1163
|
-
control,
|
|
1164
|
-
label,
|
|
1165
|
-
labelClassName,
|
|
1166
|
-
mainClassName,
|
|
1167
|
-
name,
|
|
1168
|
-
visualRequired,
|
|
1169
|
-
...pickerProps
|
|
1170
|
-
}) => /* @__PURE__ */ jsx19(
|
|
1171
|
-
FormField,
|
|
1172
|
-
{
|
|
1173
|
-
control,
|
|
1174
|
-
name,
|
|
1175
|
-
render: ({ field, fieldState }) => /* @__PURE__ */ jsx19(
|
|
1176
|
-
FormFieldShell,
|
|
1177
|
-
{
|
|
1178
|
-
hasError: !!fieldState.error,
|
|
1179
|
-
label,
|
|
1180
|
-
labelClassName,
|
|
1181
|
-
mainClassName,
|
|
1182
|
-
name,
|
|
1183
|
-
visualRequired,
|
|
1184
|
-
children: /* @__PURE__ */ jsx19(
|
|
1185
|
-
GoogleMapPicker,
|
|
1186
|
-
{
|
|
1187
|
-
...pickerProps,
|
|
1188
|
-
hasError: !!fieldState.error,
|
|
1189
|
-
onChange: field.onChange,
|
|
1190
|
-
value: field.value ?? ""
|
|
1191
|
-
}
|
|
1192
|
-
)
|
|
1193
|
-
}
|
|
1194
|
-
)
|
|
1195
|
-
}
|
|
1196
|
-
);
|
|
1197
|
-
|
|
1198
694
|
// src/components/otp-input.tsx
|
|
1199
695
|
import { OTPInput, OTPInputContext } from "input-otp";
|
|
1200
|
-
import
|
|
1201
|
-
import { jsx as
|
|
696
|
+
import React10 from "react";
|
|
697
|
+
import { jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1202
698
|
function InputOTP({
|
|
1203
699
|
className,
|
|
1204
700
|
containerClassName,
|
|
1205
701
|
...props
|
|
1206
702
|
}) {
|
|
1207
|
-
return /* @__PURE__ */
|
|
703
|
+
return /* @__PURE__ */ jsx14(
|
|
1208
704
|
OTPInput,
|
|
1209
705
|
{
|
|
1210
706
|
className: cn("disabled:cursor-not-allowed", className),
|
|
@@ -1215,16 +711,16 @@ function InputOTP({
|
|
|
1215
711
|
);
|
|
1216
712
|
}
|
|
1217
713
|
function InputOTPGroup({ className, ...props }) {
|
|
1218
|
-
return /* @__PURE__ */
|
|
714
|
+
return /* @__PURE__ */ jsx14("div", { className: cn("flex items-center gap-2", className), "data-slot": "input-otp-group", ...props });
|
|
1219
715
|
}
|
|
1220
716
|
function InputOTPSlot({
|
|
1221
717
|
className,
|
|
1222
718
|
index,
|
|
1223
719
|
...props
|
|
1224
720
|
}) {
|
|
1225
|
-
const inputOTPContext =
|
|
721
|
+
const inputOTPContext = React10.useContext(OTPInputContext);
|
|
1226
722
|
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index] ?? {};
|
|
1227
|
-
return /* @__PURE__ */
|
|
723
|
+
return /* @__PURE__ */ jsxs11(
|
|
1228
724
|
"div",
|
|
1229
725
|
{
|
|
1230
726
|
className: cn(
|
|
@@ -1239,14 +735,14 @@ function InputOTPSlot({
|
|
|
1239
735
|
...props,
|
|
1240
736
|
children: [
|
|
1241
737
|
char,
|
|
1242
|
-
hasFakeCaret && /* @__PURE__ */
|
|
738
|
+
hasFakeCaret && /* @__PURE__ */ jsx14("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsx14("div", { className: "animate-caret-blink bg-foreground h-6 w-px duration-1000" }) })
|
|
1243
739
|
]
|
|
1244
740
|
}
|
|
1245
741
|
);
|
|
1246
742
|
}
|
|
1247
743
|
|
|
1248
744
|
// src/components/form-fields/otp-field.tsx
|
|
1249
|
-
import { jsx as
|
|
745
|
+
import { jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1250
746
|
function OTPField({
|
|
1251
747
|
autoFocus,
|
|
1252
748
|
className,
|
|
@@ -1259,13 +755,13 @@ function OTPField({
|
|
|
1259
755
|
otpLength = 6,
|
|
1260
756
|
visualRequired
|
|
1261
757
|
}) {
|
|
1262
|
-
return /* @__PURE__ */
|
|
758
|
+
return /* @__PURE__ */ jsx15(
|
|
1263
759
|
FormField,
|
|
1264
760
|
{
|
|
1265
761
|
control,
|
|
1266
762
|
name,
|
|
1267
|
-
render: ({ field, fieldState }) => /* @__PURE__ */
|
|
1268
|
-
label ? /* @__PURE__ */
|
|
763
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsxs12(FormItem, { className: cn("flex flex-col", className), children: [
|
|
764
|
+
label ? /* @__PURE__ */ jsx15(
|
|
1269
765
|
LabelField,
|
|
1270
766
|
{
|
|
1271
767
|
label,
|
|
@@ -1274,7 +770,7 @@ function OTPField({
|
|
|
1274
770
|
visualRequired
|
|
1275
771
|
}
|
|
1276
772
|
) : null,
|
|
1277
|
-
/* @__PURE__ */
|
|
773
|
+
/* @__PURE__ */ jsx15(FormControl, { children: /* @__PURE__ */ jsx15(
|
|
1278
774
|
InputOTP,
|
|
1279
775
|
{
|
|
1280
776
|
"aria-invalid": fieldState.invalid || void 0,
|
|
@@ -1282,17 +778,16 @@ function OTPField({
|
|
|
1282
778
|
autoFocus,
|
|
1283
779
|
containerClassName: cn("justify-center", containerClassName),
|
|
1284
780
|
disabled,
|
|
1285
|
-
id: name,
|
|
1286
781
|
inputMode: "numeric",
|
|
1287
782
|
maxLength: otpLength,
|
|
1288
783
|
onChange: (val) => field.onChange(val),
|
|
1289
784
|
onPaste: (e) => field.onChange(e.clipboardData.getData("text")),
|
|
1290
785
|
pattern: "[0-9]*",
|
|
1291
786
|
value: field.value ?? "",
|
|
1292
|
-
children: /* @__PURE__ */
|
|
787
|
+
children: /* @__PURE__ */ jsx15(InputOTPGroup, { children: Array.from({ length: otpLength }).map((_, i) => /* @__PURE__ */ jsx15(InputOTPSlot, { "aria-invalid": fieldState.invalid || void 0, index: i }, i)) })
|
|
1293
788
|
}
|
|
1294
789
|
) }),
|
|
1295
|
-
/* @__PURE__ */
|
|
790
|
+
/* @__PURE__ */ jsx15(FormMessage, {})
|
|
1296
791
|
] })
|
|
1297
792
|
}
|
|
1298
793
|
);
|
|
@@ -1300,15 +795,15 @@ function OTPField({
|
|
|
1300
795
|
|
|
1301
796
|
// src/components/select-input.tsx
|
|
1302
797
|
import { CaretDownIcon, CaretUpIcon, ClockIcon, XIcon as XIcon3 } from "@phosphor-icons/react";
|
|
1303
|
-
import { cloneElement, useCallback as
|
|
798
|
+
import { cloneElement, useCallback, useEffect as useEffect3, useId, useMemo as useMemo2, useRef as useRef3, useState as useState3 } from "react";
|
|
1304
799
|
|
|
1305
800
|
// src/components/popover.tsx
|
|
1306
801
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
1307
|
-
import * as
|
|
1308
|
-
import { jsx as
|
|
802
|
+
import * as React11 from "react";
|
|
803
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1309
804
|
var Popover = PopoverPrimitive.Root;
|
|
1310
805
|
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
1311
|
-
var PopoverContent =
|
|
806
|
+
var PopoverContent = React11.forwardRef(({ align = "center", className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx16(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx16(
|
|
1312
807
|
PopoverPrimitive.Content,
|
|
1313
808
|
{
|
|
1314
809
|
align,
|
|
@@ -1324,67 +819,90 @@ var PopoverContent = React13.forwardRef(({ align = "center", className, sideOffs
|
|
|
1324
819
|
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
1325
820
|
|
|
1326
821
|
// src/components/time-columns.tsx
|
|
1327
|
-
import * as
|
|
1328
|
-
import { jsx as
|
|
822
|
+
import * as React12 from "react";
|
|
823
|
+
import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
824
|
+
var optionClassName = cn(
|
|
825
|
+
"hover:bg-hover w-full cursor-pointer rounded-sm px-2 py-1.5 text-sm focus-visible:ring-inset",
|
|
826
|
+
focusRing
|
|
827
|
+
);
|
|
1329
828
|
var TimeColumns = ({ hours, minutes, onSelectHour, onSelectMinute, value }) => {
|
|
829
|
+
const t = useUiT();
|
|
1330
830
|
const [selectedHour, selectedMinute] = value ? value.split(":") : ["", ""];
|
|
1331
|
-
const hourListRef =
|
|
1332
|
-
const minuteListRef =
|
|
1333
|
-
|
|
831
|
+
const hourListRef = React12.useRef(null);
|
|
832
|
+
const minuteListRef = React12.useRef(null);
|
|
833
|
+
React12.useEffect(() => {
|
|
1334
834
|
hourListRef.current?.querySelector('[data-selected="true"]')?.scrollIntoView({ block: "center" });
|
|
1335
835
|
minuteListRef.current?.querySelector('[data-selected="true"]')?.scrollIntoView({ block: "center" });
|
|
1336
836
|
}, []);
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
837
|
+
const formatHour12 = (hour) => {
|
|
838
|
+
const hourNum = Number(hour);
|
|
839
|
+
const period = hourNum >= 12 ? t("timeColumns.pm") : t("timeColumns.am");
|
|
840
|
+
const hour12 = hourNum % 12 === 0 ? 12 : hourNum % 12;
|
|
841
|
+
return `${hour12} ${period}`;
|
|
842
|
+
};
|
|
843
|
+
return /* @__PURE__ */ jsxs13("div", { className: "divide-border flex divide-x", children: [
|
|
844
|
+
/* @__PURE__ */ jsx17(
|
|
845
|
+
"div",
|
|
846
|
+
{
|
|
847
|
+
"aria-label": t("timeColumns.hours"),
|
|
848
|
+
className: "max-h-60 flex-1 overflow-y-auto",
|
|
849
|
+
ref: hourListRef,
|
|
850
|
+
role: "group",
|
|
851
|
+
children: hours.map((hour) => {
|
|
852
|
+
const isSelected = hour === selectedHour;
|
|
853
|
+
return /* @__PURE__ */ jsx17(
|
|
854
|
+
"button",
|
|
855
|
+
{
|
|
856
|
+
"aria-pressed": isSelected,
|
|
857
|
+
className: cn(
|
|
858
|
+
optionClassName,
|
|
859
|
+
"flex items-center justify-center",
|
|
860
|
+
isSelected && "bg-inactive font-medium"
|
|
861
|
+
),
|
|
862
|
+
"data-selected": isSelected,
|
|
863
|
+
onClick: () => onSelectHour(hour),
|
|
864
|
+
type: "button",
|
|
865
|
+
children: formatHour12(hour)
|
|
866
|
+
},
|
|
867
|
+
hour
|
|
868
|
+
);
|
|
869
|
+
})
|
|
870
|
+
}
|
|
871
|
+
),
|
|
872
|
+
/* @__PURE__ */ jsx17(
|
|
873
|
+
"div",
|
|
874
|
+
{
|
|
875
|
+
"aria-label": t("timeColumns.minutes"),
|
|
876
|
+
className: "max-h-60 flex-1 overflow-y-auto",
|
|
877
|
+
ref: minuteListRef,
|
|
878
|
+
role: "group",
|
|
879
|
+
children: minutes.map((minute) => {
|
|
880
|
+
const isSelected = minute === selectedMinute;
|
|
881
|
+
return /* @__PURE__ */ jsx17(
|
|
882
|
+
"button",
|
|
883
|
+
{
|
|
884
|
+
"aria-pressed": isSelected,
|
|
885
|
+
className: cn(optionClassName, "text-center", isSelected && "bg-inactive font-medium"),
|
|
886
|
+
"data-selected": isSelected,
|
|
887
|
+
onClick: () => onSelectMinute(minute),
|
|
888
|
+
type: "button",
|
|
889
|
+
children: minute
|
|
890
|
+
},
|
|
891
|
+
minute
|
|
892
|
+
);
|
|
893
|
+
})
|
|
894
|
+
}
|
|
895
|
+
)
|
|
1372
896
|
] });
|
|
1373
897
|
};
|
|
1374
|
-
function formatHour12(hour) {
|
|
1375
|
-
const hourNum = Number(hour);
|
|
1376
|
-
const period = hourNum >= 12 ? "PM" : "AM";
|
|
1377
|
-
const hour12 = hourNum % 12 === 0 ? 12 : hourNum % 12;
|
|
1378
|
-
return `${hour12} ${period}`;
|
|
1379
|
-
}
|
|
1380
898
|
|
|
1381
899
|
// src/components/use-select-input.ts
|
|
1382
|
-
import { useEffect as
|
|
900
|
+
import { useEffect as useEffect2, useMemo, useRef as useRef2, useState as useState2 } from "react";
|
|
1383
901
|
var normalizeString = (str) => str.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase();
|
|
1384
902
|
function usePopoverWidth() {
|
|
1385
|
-
const ref =
|
|
1386
|
-
const [width, setWidth] =
|
|
1387
|
-
|
|
903
|
+
const ref = useRef2(null);
|
|
904
|
+
const [width, setWidth] = useState2(0);
|
|
905
|
+
useEffect2(() => {
|
|
1388
906
|
const el = ref.current;
|
|
1389
907
|
if (!el) return;
|
|
1390
908
|
const updateWidth = () => setWidth(el.getBoundingClientRect().width);
|
|
@@ -1396,8 +914,8 @@ function usePopoverWidth() {
|
|
|
1396
914
|
return { ref, width };
|
|
1397
915
|
}
|
|
1398
916
|
function useSelectFilter(items, labelKey, valueKey) {
|
|
1399
|
-
const [query, setQuery] =
|
|
1400
|
-
const normalizedItems =
|
|
917
|
+
const [query, setQuery] = useState2("");
|
|
918
|
+
const normalizedItems = useMemo(() => {
|
|
1401
919
|
if (!items) return [];
|
|
1402
920
|
return items.map((it) => ({
|
|
1403
921
|
...it,
|
|
@@ -1405,7 +923,7 @@ function useSelectFilter(items, labelKey, valueKey) {
|
|
|
1405
923
|
[valueKey]: String(it[valueKey])
|
|
1406
924
|
}));
|
|
1407
925
|
}, [items, labelKey, valueKey]);
|
|
1408
|
-
const filteredOptions =
|
|
926
|
+
const filteredOptions = useMemo(() => {
|
|
1409
927
|
if (!query) return normalizedItems;
|
|
1410
928
|
return normalizedItems.filter((el) => normalizeString(el[labelKey]).includes(normalizeString(query)));
|
|
1411
929
|
}, [normalizedItems, labelKey, query]);
|
|
@@ -1413,15 +931,20 @@ function useSelectFilter(items, labelKey, valueKey) {
|
|
|
1413
931
|
}
|
|
1414
932
|
|
|
1415
933
|
// src/components/select-input.tsx
|
|
1416
|
-
import { Fragment as Fragment3, jsx as
|
|
934
|
+
import { Fragment as Fragment3, jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1417
935
|
var QUERY_RESET_DELAY_MS = 100;
|
|
1418
936
|
var SelectInput = (props) => {
|
|
1419
937
|
const t = useUiT();
|
|
1420
938
|
const {
|
|
1421
939
|
ableDeleteOption,
|
|
940
|
+
"aria-describedby": ariaDescribedBy,
|
|
941
|
+
"aria-invalid": ariaInvalid,
|
|
942
|
+
"aria-label": ariaLabel,
|
|
943
|
+
"aria-labelledby": ariaLabelledBy,
|
|
1422
944
|
className,
|
|
1423
945
|
disabled = false,
|
|
1424
946
|
error,
|
|
947
|
+
id,
|
|
1425
948
|
items,
|
|
1426
949
|
labelKey = "label",
|
|
1427
950
|
leftIcon,
|
|
@@ -1440,12 +963,19 @@ var SelectInput = (props) => {
|
|
|
1440
963
|
valueKey = "value"
|
|
1441
964
|
} = props;
|
|
1442
965
|
const resolvedPlaceholder = placeholder ?? t("selectInput.placeholder");
|
|
1443
|
-
const listboxId =
|
|
1444
|
-
const [open, setOpen] =
|
|
1445
|
-
const [valueItem, setValueItem] =
|
|
966
|
+
const listboxId = useId();
|
|
967
|
+
const [open, setOpen] = useState3(false);
|
|
968
|
+
const [valueItem, setValueItem] = useState3(value);
|
|
969
|
+
const queryResetRef = useRef3(null);
|
|
970
|
+
useEffect3(
|
|
971
|
+
() => () => {
|
|
972
|
+
if (queryResetRef.current) clearTimeout(queryResetRef.current);
|
|
973
|
+
},
|
|
974
|
+
[]
|
|
975
|
+
);
|
|
1446
976
|
const { ref: divRef, width } = usePopoverWidth();
|
|
1447
977
|
const { filteredOptions, normalizedItems, query, setQuery } = useSelectFilter(items, labelKey, valueKey);
|
|
1448
|
-
const onValueChange =
|
|
978
|
+
const onValueChange = useCallback(
|
|
1449
979
|
(val) => {
|
|
1450
980
|
if (!normalizedItems.length) return;
|
|
1451
981
|
const item = normalizedItems.find((i) => i[valueKey] === val);
|
|
@@ -1459,13 +989,13 @@ var SelectInput = (props) => {
|
|
|
1459
989
|
},
|
|
1460
990
|
[normalizedItems, labelKey, valueKey, onValueChangeCallBack]
|
|
1461
991
|
);
|
|
1462
|
-
const timeHours =
|
|
992
|
+
const timeHours = useMemo2(
|
|
1463
993
|
() => Array.from(new Set(normalizedItems.map((i) => i[valueKey].split(":")[0]))).sort(
|
|
1464
994
|
(a, b) => a.localeCompare(b)
|
|
1465
995
|
),
|
|
1466
996
|
[normalizedItems, valueKey]
|
|
1467
997
|
);
|
|
1468
|
-
const timeMinutes =
|
|
998
|
+
const timeMinutes = useMemo2(
|
|
1469
999
|
() => Array.from(new Set(normalizedItems.map((i) => i[valueKey].split(":")[1]))).sort(
|
|
1470
1000
|
(a, b) => a.localeCompare(b)
|
|
1471
1001
|
),
|
|
@@ -1484,7 +1014,7 @@ var SelectInput = (props) => {
|
|
|
1484
1014
|
onValueChange(newValue);
|
|
1485
1015
|
setOpen(false);
|
|
1486
1016
|
};
|
|
1487
|
-
const buttonClassName =
|
|
1017
|
+
const buttonClassName = useMemo2(
|
|
1488
1018
|
() => cn(
|
|
1489
1019
|
inputBase,
|
|
1490
1020
|
inputFocus,
|
|
@@ -1495,53 +1025,58 @@ var SelectInput = (props) => {
|
|
|
1495
1025
|
),
|
|
1496
1026
|
[disabled, error, className]
|
|
1497
1027
|
);
|
|
1498
|
-
const [prevValue, setPrevValue] =
|
|
1028
|
+
const [prevValue, setPrevValue] = useState3(value);
|
|
1499
1029
|
if (prevValue !== value) {
|
|
1500
1030
|
setPrevValue(value);
|
|
1501
1031
|
setValueItem(value);
|
|
1502
1032
|
}
|
|
1503
|
-
return /* @__PURE__ */
|
|
1504
|
-
/* @__PURE__ */
|
|
1505
|
-
/* @__PURE__ */
|
|
1033
|
+
return /* @__PURE__ */ jsx18("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsxs14("div", { className: "relative flex flex-col justify-center", children: [
|
|
1034
|
+
/* @__PURE__ */ jsxs14(Popover, { onOpenChange: setOpen, open, children: [
|
|
1035
|
+
/* @__PURE__ */ jsx18(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx18(
|
|
1506
1036
|
Button,
|
|
1507
1037
|
{
|
|
1038
|
+
"aria-busy": loading || void 0,
|
|
1508
1039
|
"aria-controls": listboxId,
|
|
1040
|
+
"aria-describedby": ariaDescribedBy,
|
|
1509
1041
|
"aria-expanded": open,
|
|
1510
1042
|
"aria-haspopup": "listbox",
|
|
1043
|
+
"aria-invalid": ariaInvalid ?? (error ? true : void 0),
|
|
1044
|
+
"aria-label": ariaLabel,
|
|
1045
|
+
"aria-labelledby": ariaLabelledBy,
|
|
1511
1046
|
className: buttonClassName,
|
|
1512
|
-
disabled,
|
|
1513
|
-
|
|
1047
|
+
disabled: disabled || loading,
|
|
1048
|
+
id,
|
|
1514
1049
|
onBlur,
|
|
1515
1050
|
ref: divRef,
|
|
1516
1051
|
role: "combobox",
|
|
1517
1052
|
variant: "primary",
|
|
1518
|
-
children: loading ? /* @__PURE__ */
|
|
1053
|
+
children: loading ? /* @__PURE__ */ jsxs14(Fragment3, { children: [
|
|
1519
1054
|
loadingLabel ?? t("selectInput.loading"),
|
|
1520
1055
|
" ",
|
|
1521
|
-
/* @__PURE__ */
|
|
1522
|
-
] }) : /* @__PURE__ */
|
|
1523
|
-
valueItem ? filteredOptions.find((i) => i[valueKey] === valueItem)?.[labelKey] : /* @__PURE__ */
|
|
1524
|
-
/* @__PURE__ */
|
|
1525
|
-
] }) : /* @__PURE__ */
|
|
1526
|
-
/* @__PURE__ */
|
|
1527
|
-
leftIcon && /* @__PURE__ */
|
|
1528
|
-
valueItem ? filteredOptions.find((i) => i[valueKey] === valueItem)?.[labelKey] : /* @__PURE__ */
|
|
1056
|
+
/* @__PURE__ */ jsx18(Spinner, { size: "sm" })
|
|
1057
|
+
] }) : /* @__PURE__ */ jsx18("div", { className: "relative flex h-5 w-full items-center", children: timeField ? /* @__PURE__ */ jsxs14("div", { className: "text-title flex w-full items-center justify-center gap-2 truncate text-sm", children: [
|
|
1058
|
+
valueItem ? filteredOptions.find((i) => i[valueKey] === valueItem)?.[labelKey] : /* @__PURE__ */ jsx18("span", { className: cn(inputPlaceholder, placeholderClassName), children: resolvedPlaceholder }),
|
|
1059
|
+
/* @__PURE__ */ jsx18(ClockIcon, { "aria-hidden": true, className: "text-border h-3.5 w-3.5 shrink-0" })
|
|
1060
|
+
] }) : /* @__PURE__ */ jsxs14(Fragment3, { children: [
|
|
1061
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex w-full max-w-[90%] items-center truncate", children: [
|
|
1062
|
+
leftIcon && /* @__PURE__ */ jsx18("span", { className: "mr-2 shrink-0", children: cloneElement(leftIcon, { size: 20, strokeWidth: 1 }) }),
|
|
1063
|
+
valueItem ? filteredOptions.find((i) => i[valueKey] === valueItem)?.[labelKey] : /* @__PURE__ */ jsx18("span", { className: cn(inputPlaceholder, placeholderClassName), children: resolvedPlaceholder })
|
|
1529
1064
|
] }),
|
|
1530
|
-
/* @__PURE__ */
|
|
1531
|
-
ableDeleteOption && /* @__PURE__ */
|
|
1532
|
-
!open ? /* @__PURE__ */
|
|
1065
|
+
/* @__PURE__ */ jsxs14("div", { className: "absolute top-0.5 right-0 flex gap-2", children: [
|
|
1066
|
+
ableDeleteOption && /* @__PURE__ */ jsx18("div", { "aria-hidden": true, className: "h-4 w-4 shrink-0" }),
|
|
1067
|
+
!open ? /* @__PURE__ */ jsx18(CaretDownIcon, { "aria-hidden": true, className: "ml-2 h-4 w-4 shrink-0 opacity-50" }) : /* @__PURE__ */ jsx18(CaretUpIcon, { "aria-hidden": true, className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
|
|
1533
1068
|
] })
|
|
1534
1069
|
] }) })
|
|
1535
1070
|
}
|
|
1536
1071
|
) }),
|
|
1537
|
-
/* @__PURE__ */
|
|
1072
|
+
/* @__PURE__ */ jsx18(
|
|
1538
1073
|
PopoverContent,
|
|
1539
1074
|
{
|
|
1540
1075
|
className: cn("bg-surface border-border rounded-sm p-1", zPopoverAboveDialog),
|
|
1541
1076
|
id: listboxId,
|
|
1542
1077
|
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
1543
1078
|
style: timeField ? { maxWidth: "auto", width: "180px" } : width > 0 ? { maxWidth: "auto", minWidth: `${width}px`, width: `${width}px` } : void 0,
|
|
1544
|
-
children: timeField ? /* @__PURE__ */
|
|
1079
|
+
children: timeField ? /* @__PURE__ */ jsx18(
|
|
1545
1080
|
TimeColumns,
|
|
1546
1081
|
{
|
|
1547
1082
|
hours: timeHours,
|
|
@@ -1550,8 +1085,8 @@ var SelectInput = (props) => {
|
|
|
1550
1085
|
onSelectMinute: handleSelectMinute,
|
|
1551
1086
|
value: valueItem
|
|
1552
1087
|
}
|
|
1553
|
-
) : /* @__PURE__ */
|
|
1554
|
-
search && /* @__PURE__ */
|
|
1088
|
+
) : /* @__PURE__ */ jsxs14(Command, { className: "flex w-full flex-col gap-2", children: [
|
|
1089
|
+
search && /* @__PURE__ */ jsx18(
|
|
1555
1090
|
Input,
|
|
1556
1091
|
{
|
|
1557
1092
|
className: "mb-1 rounded-sm",
|
|
@@ -1560,11 +1095,11 @@ var SelectInput = (props) => {
|
|
|
1560
1095
|
value: query
|
|
1561
1096
|
}
|
|
1562
1097
|
),
|
|
1563
|
-
/* @__PURE__ */
|
|
1564
|
-
/* @__PURE__ */
|
|
1098
|
+
/* @__PURE__ */ jsx18(CommandEmpty, { className: "text-center", children: noResultsLabel ?? t("selectInput.noResults") }),
|
|
1099
|
+
/* @__PURE__ */ jsx18(CommandList, { children: /* @__PURE__ */ jsx18(CommandGroup, { className: "p-0", children: filteredOptions.map((item) => {
|
|
1565
1100
|
const labelValue = item[labelKey];
|
|
1566
1101
|
const valueValue = item[valueKey];
|
|
1567
|
-
return /* @__PURE__ */
|
|
1102
|
+
return /* @__PURE__ */ jsx18(
|
|
1568
1103
|
CommandItem,
|
|
1569
1104
|
{
|
|
1570
1105
|
className: cn(
|
|
@@ -1575,7 +1110,8 @@ var SelectInput = (props) => {
|
|
|
1575
1110
|
onChange?.(currentValue);
|
|
1576
1111
|
onValueChange(currentValue);
|
|
1577
1112
|
setOpen(false);
|
|
1578
|
-
|
|
1113
|
+
if (queryResetRef.current) clearTimeout(queryResetRef.current);
|
|
1114
|
+
queryResetRef.current = setTimeout(() => setQuery(""), QUERY_RESET_DELAY_MS);
|
|
1579
1115
|
},
|
|
1580
1116
|
value: valueValue,
|
|
1581
1117
|
children: labelValue.trim()
|
|
@@ -1587,11 +1123,14 @@ var SelectInput = (props) => {
|
|
|
1587
1123
|
}
|
|
1588
1124
|
)
|
|
1589
1125
|
] }),
|
|
1590
|
-
ableDeleteOption && !loading && !timeField && /* @__PURE__ */
|
|
1126
|
+
ableDeleteOption && !loading && !timeField && /* @__PURE__ */ jsx18(
|
|
1591
1127
|
"button",
|
|
1592
1128
|
{
|
|
1593
1129
|
"aria-label": t("selectInput.clear"),
|
|
1594
|
-
className:
|
|
1130
|
+
className: cn(
|
|
1131
|
+
"absolute top-1/2 right-7 z-10 flex h-8 w-8 -translate-y-1/2 items-center justify-center rounded-full",
|
|
1132
|
+
focusRing
|
|
1133
|
+
),
|
|
1595
1134
|
onClick: () => {
|
|
1596
1135
|
onChange?.("");
|
|
1597
1136
|
onValueChange("");
|
|
@@ -1600,14 +1139,14 @@ var SelectInput = (props) => {
|
|
|
1600
1139
|
setOpen(false);
|
|
1601
1140
|
},
|
|
1602
1141
|
type: "button",
|
|
1603
|
-
children: /* @__PURE__ */
|
|
1142
|
+
children: /* @__PURE__ */ jsx18(XIcon3, { "aria-hidden": true, className: "h-4 w-4 shrink-0 opacity-50" })
|
|
1604
1143
|
}
|
|
1605
1144
|
)
|
|
1606
1145
|
] }) });
|
|
1607
1146
|
};
|
|
1608
1147
|
|
|
1609
1148
|
// src/components/form-fields/select-field.tsx
|
|
1610
|
-
import { jsx as
|
|
1149
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
1611
1150
|
var SelectField = ({
|
|
1612
1151
|
ableDeleteOption,
|
|
1613
1152
|
className,
|
|
@@ -1623,14 +1162,14 @@ var SelectField = ({
|
|
|
1623
1162
|
search,
|
|
1624
1163
|
visualRequired
|
|
1625
1164
|
}) => {
|
|
1626
|
-
return /* @__PURE__ */
|
|
1165
|
+
return /* @__PURE__ */ jsx19(
|
|
1627
1166
|
FormField,
|
|
1628
1167
|
{
|
|
1629
1168
|
control,
|
|
1630
1169
|
name,
|
|
1631
1170
|
render: ({ field, fieldState }) => {
|
|
1632
1171
|
const hasError = !!fieldState.error;
|
|
1633
|
-
return /* @__PURE__ */
|
|
1172
|
+
return /* @__PURE__ */ jsx19(
|
|
1634
1173
|
FormFieldShell,
|
|
1635
1174
|
{
|
|
1636
1175
|
hasError,
|
|
@@ -1639,9 +1178,10 @@ var SelectField = ({
|
|
|
1639
1178
|
mainClassName,
|
|
1640
1179
|
name,
|
|
1641
1180
|
visualRequired,
|
|
1642
|
-
children: /* @__PURE__ */
|
|
1181
|
+
children: (controlProps) => /* @__PURE__ */ jsx19(
|
|
1643
1182
|
SelectInput,
|
|
1644
1183
|
{
|
|
1184
|
+
...controlProps,
|
|
1645
1185
|
ableDeleteOption,
|
|
1646
1186
|
className,
|
|
1647
1187
|
disabled,
|
|
@@ -1665,13 +1205,13 @@ var SelectField = ({
|
|
|
1665
1205
|
|
|
1666
1206
|
// src/components/password-checklist.tsx
|
|
1667
1207
|
import { CheckCircleIcon as CheckCircleIcon2, XCircleIcon } from "@phosphor-icons/react";
|
|
1668
|
-
import { jsx as
|
|
1208
|
+
import { jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1669
1209
|
var PasswordChecklist = ({ className, rules, value }) => {
|
|
1670
1210
|
if (rules.length === 0) return null;
|
|
1671
|
-
return /* @__PURE__ */
|
|
1211
|
+
return /* @__PURE__ */ jsx20("ul", { className: cn("flex flex-col gap-1", className), children: rules.map((rule) => {
|
|
1672
1212
|
const isMet = rule.test(value);
|
|
1673
1213
|
const Icon = isMet ? CheckCircleIcon2 : XCircleIcon;
|
|
1674
|
-
return /* @__PURE__ */
|
|
1214
|
+
return /* @__PURE__ */ jsxs15(
|
|
1675
1215
|
"li",
|
|
1676
1216
|
{
|
|
1677
1217
|
className: cn(
|
|
@@ -1679,8 +1219,8 @@ var PasswordChecklist = ({ className, rules, value }) => {
|
|
|
1679
1219
|
isMet ? "text-success" : "text-inactive-text"
|
|
1680
1220
|
),
|
|
1681
1221
|
children: [
|
|
1682
|
-
/* @__PURE__ */
|
|
1683
|
-
/* @__PURE__ */
|
|
1222
|
+
/* @__PURE__ */ jsx20(Icon, { "aria-hidden": "true", className: "h-4 w-4 shrink-0" }),
|
|
1223
|
+
/* @__PURE__ */ jsx20("span", { children: rule.label })
|
|
1684
1224
|
]
|
|
1685
1225
|
},
|
|
1686
1226
|
rule.key
|
|
@@ -1689,22 +1229,22 @@ var PasswordChecklist = ({ className, rules, value }) => {
|
|
|
1689
1229
|
};
|
|
1690
1230
|
|
|
1691
1231
|
// src/components/step-header.tsx
|
|
1692
|
-
import { jsx as
|
|
1693
|
-
var StepHeader = ({ subtitle, subtitleClassName, title }) => /* @__PURE__ */
|
|
1694
|
-
/* @__PURE__ */
|
|
1695
|
-
subtitle !== void 0 && /* @__PURE__ */
|
|
1232
|
+
import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1233
|
+
var StepHeader = ({ subtitle, subtitleClassName, title }) => /* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-1", children: [
|
|
1234
|
+
/* @__PURE__ */ jsx21("h1", { className: "text-title text-2xl font-bold", children: title }),
|
|
1235
|
+
subtitle !== void 0 && /* @__PURE__ */ jsx21("p", { className: cn("text-subtitle text-sm", subtitleClassName), children: subtitle })
|
|
1696
1236
|
] });
|
|
1697
1237
|
|
|
1698
1238
|
// src/components/stepper.tsx
|
|
1699
1239
|
import { CheckIcon } from "@phosphor-icons/react";
|
|
1700
|
-
import { jsx as
|
|
1240
|
+
import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1701
1241
|
var Stepper = ({ activeIndex, className, intermediate = false, steps }) => {
|
|
1702
|
-
return /* @__PURE__ */
|
|
1242
|
+
return /* @__PURE__ */ jsx22("div", { className: cn("flex w-full items-start", className), children: steps.map((step, index) => {
|
|
1703
1243
|
const isCompleted = intermediate ? index <= activeIndex : index < activeIndex;
|
|
1704
1244
|
const isActive = !intermediate && index === activeIndex;
|
|
1705
|
-
return /* @__PURE__ */
|
|
1706
|
-
/* @__PURE__ */
|
|
1707
|
-
/* @__PURE__ */
|
|
1245
|
+
return /* @__PURE__ */ jsxs17("div", { className: "flex flex-1 flex-col items-center", children: [
|
|
1246
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex w-full items-center", children: [
|
|
1247
|
+
/* @__PURE__ */ jsx22(
|
|
1708
1248
|
"div",
|
|
1709
1249
|
{
|
|
1710
1250
|
className: cn(
|
|
@@ -1714,7 +1254,7 @@ var Stepper = ({ activeIndex, className, intermediate = false, steps }) => {
|
|
|
1714
1254
|
)
|
|
1715
1255
|
}
|
|
1716
1256
|
),
|
|
1717
|
-
/* @__PURE__ */
|
|
1257
|
+
/* @__PURE__ */ jsx22(
|
|
1718
1258
|
"div",
|
|
1719
1259
|
{
|
|
1720
1260
|
"aria-current": isActive ? "step" : void 0,
|
|
@@ -1722,12 +1262,12 @@ var Stepper = ({ activeIndex, className, intermediate = false, steps }) => {
|
|
|
1722
1262
|
"flex h-5.5 w-5.5 shrink-0 items-center justify-center rounded-full border text-xs font-semibold transition-colors md:h-6.5 md:w-6.5",
|
|
1723
1263
|
isCompleted && "bg-primary border-primary text-inverse",
|
|
1724
1264
|
isActive && "bg-primary border-primary text-inverse",
|
|
1725
|
-
!isCompleted && !isActive && "bg-inactive border-inactive text-
|
|
1265
|
+
!isCompleted && !isActive && "bg-inactive border-inactive text-inverse"
|
|
1726
1266
|
),
|
|
1727
|
-
children: isCompleted ? /* @__PURE__ */
|
|
1267
|
+
children: isCompleted ? /* @__PURE__ */ jsx22(CheckIcon, { "aria-hidden": true, className: "h-4 w-4" }) : index + 1
|
|
1728
1268
|
}
|
|
1729
1269
|
),
|
|
1730
|
-
/* @__PURE__ */
|
|
1270
|
+
/* @__PURE__ */ jsx22(
|
|
1731
1271
|
"div",
|
|
1732
1272
|
{
|
|
1733
1273
|
className: cn(
|
|
@@ -1735,7 +1275,7 @@ var Stepper = ({ activeIndex, className, intermediate = false, steps }) => {
|
|
|
1735
1275
|
isCompleted ? "bg-primary" : "bg-inactive",
|
|
1736
1276
|
index === steps.length - 1 && "rounded-r-full"
|
|
1737
1277
|
),
|
|
1738
|
-
children: index === 0 && /* @__PURE__ */
|
|
1278
|
+
children: index === 0 && /* @__PURE__ */ jsx22(
|
|
1739
1279
|
"div",
|
|
1740
1280
|
{
|
|
1741
1281
|
className: cn(
|
|
@@ -1747,39 +1287,40 @@ var Stepper = ({ activeIndex, className, intermediate = false, steps }) => {
|
|
|
1747
1287
|
}
|
|
1748
1288
|
)
|
|
1749
1289
|
] }),
|
|
1750
|
-
/* @__PURE__ */
|
|
1290
|
+
/* @__PURE__ */ jsx22("span", { className: cn("mt-1 text-xs font-normal", isCompleted || isActive ? "text-primary" : "text-muted"), children: step.label })
|
|
1751
1291
|
] }, step.label);
|
|
1752
1292
|
}) });
|
|
1753
1293
|
};
|
|
1754
1294
|
|
|
1755
1295
|
// src/components/switch.tsx
|
|
1756
1296
|
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
|
1757
|
-
import * as
|
|
1758
|
-
import { jsx as
|
|
1759
|
-
var Switch =
|
|
1297
|
+
import * as React13 from "react";
|
|
1298
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
1299
|
+
var Switch = React13.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx23(
|
|
1760
1300
|
SwitchPrimitive.Root,
|
|
1761
1301
|
{
|
|
1762
1302
|
className: cn(
|
|
1763
|
-
"border-border
|
|
1303
|
+
"border-border data-[state=checked]:bg-success data-[state=unchecked]:bg-inactive relative inline-flex h-[26px] w-[50px] shrink-0 cursor-pointer items-center rounded-full border transition-colors disabled:cursor-not-allowed disabled:opacity-50",
|
|
1304
|
+
focusRing,
|
|
1764
1305
|
className
|
|
1765
1306
|
),
|
|
1766
1307
|
ref,
|
|
1767
1308
|
...props,
|
|
1768
|
-
children: /* @__PURE__ */
|
|
1309
|
+
children: /* @__PURE__ */ jsx23(SwitchPrimitive.Thumb, { className: "bg-surface pointer-events-none absolute top-[3px] left-[3px] block h-[18px] w-[18px] rounded-full shadow-lg transition-transform data-[state=checked]:translate-x-6" })
|
|
1769
1310
|
}
|
|
1770
1311
|
));
|
|
1771
1312
|
Switch.displayName = SwitchPrimitive.Root.displayName;
|
|
1772
1313
|
|
|
1773
1314
|
// src/components/textarea.tsx
|
|
1774
|
-
import * as
|
|
1775
|
-
import { jsx as
|
|
1776
|
-
var Textarea =
|
|
1315
|
+
import * as React14 from "react";
|
|
1316
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
1317
|
+
var Textarea = React14.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx24("textarea", { className: cn(inputSurface, inputFocus, "block h-28 resize-none py-3", className), ref, ...props }));
|
|
1777
1318
|
Textarea.displayName = "Textarea";
|
|
1778
1319
|
|
|
1779
1320
|
// src/components/toast/toast.tsx
|
|
1780
1321
|
import { CheckIcon as CheckIcon2, FileLockIcon, InfoIcon as InfoIcon2, WarningIcon as WarningIcon2, XIcon as XIcon4 } from "@phosphor-icons/react";
|
|
1781
|
-
import { useEffect as useEffect4, useRef as useRef4, useState as
|
|
1782
|
-
import { jsx as
|
|
1322
|
+
import { useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
|
|
1323
|
+
import { jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1783
1324
|
var EXIT_ANIMATION_MS = 200;
|
|
1784
1325
|
var typeIcons = {
|
|
1785
1326
|
destructive: XIcon4,
|
|
@@ -1796,7 +1337,7 @@ var typeStyles = {
|
|
|
1796
1337
|
warning: { border: "border-warning", icon: "text-warning", iconBorder: "border-warning" }
|
|
1797
1338
|
};
|
|
1798
1339
|
function Toast({ duration = 2500, id, onClose, subtitle, title, type }) {
|
|
1799
|
-
const [leaving, setLeaving] =
|
|
1340
|
+
const [leaving, setLeaving] = useState4(false);
|
|
1800
1341
|
const startedAtRef = useRef4(Date.now());
|
|
1801
1342
|
const timeoutRef = useRef4(null);
|
|
1802
1343
|
const exitRef = useRef4(null);
|
|
@@ -1816,10 +1357,9 @@ function Toast({ duration = 2500, id, onClose, subtitle, title, type }) {
|
|
|
1816
1357
|
if (exitRef.current) clearTimeout(exitRef.current);
|
|
1817
1358
|
};
|
|
1818
1359
|
}, [id, duration, onClose]);
|
|
1819
|
-
return /* @__PURE__ */
|
|
1360
|
+
return /* @__PURE__ */ jsxs18(
|
|
1820
1361
|
"div",
|
|
1821
1362
|
{
|
|
1822
|
-
"aria-live": "polite",
|
|
1823
1363
|
className: cn(
|
|
1824
1364
|
"relative",
|
|
1825
1365
|
leaving ? "absolute top-0 right-0 left-0" : "",
|
|
@@ -1832,19 +1372,19 @@ function Toast({ duration = 2500, id, onClose, subtitle, title, type }) {
|
|
|
1832
1372
|
styles.border,
|
|
1833
1373
|
leaving ? "translate-y-2 opacity-0" : "translate-y-0 opacity-100"
|
|
1834
1374
|
),
|
|
1835
|
-
role: "status",
|
|
1375
|
+
role: type === "destructive" ? "alert" : "status",
|
|
1836
1376
|
children: [
|
|
1837
|
-
/* @__PURE__ */
|
|
1838
|
-
subtitle ? /* @__PURE__ */
|
|
1839
|
-
/* @__PURE__ */
|
|
1377
|
+
/* @__PURE__ */ jsx25("div", { className: "min-w-0 pr-4", children: /* @__PURE__ */ jsx25("h4", { className: cn("text-base leading-normal font-semibold", "text-foreground", "line-clamp-2"), children: title }) }),
|
|
1378
|
+
subtitle ? /* @__PURE__ */ jsx25("div", { className: "shrink-0 pr-4 text-left", children: /* @__PURE__ */ jsx25("div", { className: cn("max-w-28 text-sm font-normal", "text-body"), children: subtitle }) }) : null,
|
|
1379
|
+
/* @__PURE__ */ jsx25(
|
|
1840
1380
|
"div",
|
|
1841
1381
|
{
|
|
1842
1382
|
className: cn(
|
|
1843
1383
|
"shrink-0",
|
|
1844
|
-
"flex
|
|
1384
|
+
"flex size-8 min-w-8 items-center justify-center rounded-full border-2",
|
|
1845
1385
|
styles.iconBorder
|
|
1846
1386
|
),
|
|
1847
|
-
children: /* @__PURE__ */
|
|
1387
|
+
children: /* @__PURE__ */ jsx25(Icon, { "aria-hidden": true, className: cn("h-5 w-5", styles.icon) })
|
|
1848
1388
|
}
|
|
1849
1389
|
)
|
|
1850
1390
|
]
|
|
@@ -1853,13 +1393,13 @@ function Toast({ duration = 2500, id, onClose, subtitle, title, type }) {
|
|
|
1853
1393
|
}
|
|
1854
1394
|
|
|
1855
1395
|
// src/components/toast/toast-provider.tsx
|
|
1856
|
-
import { useCallback as
|
|
1857
|
-
import { Fragment as Fragment4, jsx as
|
|
1396
|
+
import { useCallback as useCallback2, useEffect as useEffect5, useLayoutEffect, useMemo as useMemo3, useRef as useRef5, useState as useState5 } from "react";
|
|
1397
|
+
import { Fragment as Fragment4, jsx as jsx26 } from "react/jsx-runtime";
|
|
1858
1398
|
function ToastProvider() {
|
|
1859
|
-
const [toasts, setToasts] =
|
|
1399
|
+
const [toasts, setToasts] = useState5([]);
|
|
1860
1400
|
const itemRefs = useRef5(/* @__PURE__ */ new Map());
|
|
1861
1401
|
const prevRects = useRef5(/* @__PURE__ */ new Map());
|
|
1862
|
-
const showToast =
|
|
1402
|
+
const showToast = useCallback2((type, options) => {
|
|
1863
1403
|
setToasts((prev) => [
|
|
1864
1404
|
...prev,
|
|
1865
1405
|
{
|
|
@@ -1871,14 +1411,14 @@ function ToastProvider() {
|
|
|
1871
1411
|
}
|
|
1872
1412
|
]);
|
|
1873
1413
|
}, []);
|
|
1874
|
-
const removeToast =
|
|
1414
|
+
const removeToast = useCallback2((id) => {
|
|
1875
1415
|
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
1876
1416
|
}, []);
|
|
1877
1417
|
useEffect5(() => {
|
|
1878
1418
|
registerToastEmitter(showToast);
|
|
1879
1419
|
return () => registerToastEmitter(null);
|
|
1880
1420
|
}, [showToast]);
|
|
1881
|
-
const grouped =
|
|
1421
|
+
const grouped = useMemo3(() => {
|
|
1882
1422
|
return toasts.reduce((acc, toast2) => {
|
|
1883
1423
|
const pos = toast2.position ?? "top";
|
|
1884
1424
|
acc[pos] = [...acc[pos] ?? [], toast2];
|
|
@@ -1905,7 +1445,7 @@ function ToastProvider() {
|
|
|
1905
1445
|
});
|
|
1906
1446
|
prevRects.current = newRects;
|
|
1907
1447
|
}, [toasts]);
|
|
1908
|
-
const setItemRef =
|
|
1448
|
+
const setItemRef = useCallback2((id) => {
|
|
1909
1449
|
return (el) => {
|
|
1910
1450
|
if (!el) {
|
|
1911
1451
|
itemRefs.current.delete(id);
|
|
@@ -1915,7 +1455,7 @@ function ToastProvider() {
|
|
|
1915
1455
|
itemRefs.current.set(id, el);
|
|
1916
1456
|
};
|
|
1917
1457
|
}, []);
|
|
1918
|
-
return /* @__PURE__ */
|
|
1458
|
+
return /* @__PURE__ */ jsx26(Fragment4, { children: Object.entries(grouped).map(([position, list]) => /* @__PURE__ */ jsx26("div", { className: `fixed ${zToast} ${getPositionClass(position)}`, children: /* @__PURE__ */ jsx26("div", { className: "relative flex flex-col gap-3", children: list.map((toast2) => /* @__PURE__ */ jsx26("div", { ref: setItemRef(toast2.id), children: /* @__PURE__ */ jsx26(
|
|
1919
1459
|
Toast,
|
|
1920
1460
|
{
|
|
1921
1461
|
duration: toast2.duration,
|
|
@@ -1943,9 +1483,9 @@ function getPositionClass(position) {
|
|
|
1943
1483
|
}
|
|
1944
1484
|
|
|
1945
1485
|
// src/components/wrapper.tsx
|
|
1946
|
-
import { jsx as
|
|
1486
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
1947
1487
|
var Wrapper = ({ children, className }) => {
|
|
1948
|
-
return /* @__PURE__ */
|
|
1488
|
+
return /* @__PURE__ */ jsx27("div", { className: cn("mx-auto h-full w-full", className), children });
|
|
1949
1489
|
};
|
|
1950
1490
|
export {
|
|
1951
1491
|
AddTile,
|
|
@@ -2003,11 +1543,16 @@ export {
|
|
|
2003
1543
|
Toast,
|
|
2004
1544
|
ToastProvider,
|
|
2005
1545
|
Tooltip,
|
|
1546
|
+
TooltipContent,
|
|
1547
|
+
TooltipProvider,
|
|
1548
|
+
TooltipRoot,
|
|
1549
|
+
TooltipTrigger,
|
|
2006
1550
|
Wrapper,
|
|
2007
1551
|
buttonVariants,
|
|
2008
1552
|
capitalize,
|
|
2009
1553
|
chipVariants,
|
|
2010
1554
|
cn,
|
|
1555
|
+
focusRing,
|
|
2011
1556
|
formatNumber,
|
|
2012
1557
|
formatPrice,
|
|
2013
1558
|
getTagEmoji,
|