@bizapps/ui 1.3.7 → 1.4.1

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/main.js CHANGED
@@ -1,15 +1,17 @@
1
1
  "use client";
2
- import { SearchIcon, BellIcon, CircleHelpIcon, ChevronDownIcon, ChevronLeftIcon, MoreHorizontalIcon, ChevronRightIcon, MinusIcon, CheckIcon, LoaderCircle, ChevronUpIcon, X, ChevronLeft, ChevronRight, ExternalLinkIcon, XIcon, ChevronsUpDownIcon, UploadIcon, Loader2Icon, LoaderIcon, PipetteIcon, CalendarIcon, MenuIcon, Pencil, Clock, Funnel, ArrowUp, ArrowDown, ArrowUpDown, Ellipsis, Rows2, Eye, Search, House, Plane, Wallet, LayoutDashboardIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon, CircleCheckIcon } from 'lucide-react';
2
+ import { SearchIcon, BellIcon, CircleHelpIcon, ChevronDownIcon, ChevronLeftIcon, MoreHorizontalIcon, ChevronRightIcon, MinusIcon, CheckIcon, LoaderCircle, ChevronUpIcon, X, ChevronLeft, ChevronRight, ExternalLinkIcon, ChevronsUpDownIcon, XIcon, UploadIcon, Loader2Icon, LoaderIcon, PipetteIcon, CalendarIcon, MenuIcon, Pencil, Clock, Funnel, ArrowUp, ArrowDown, ArrowUpDown, Ellipsis, Rows2, Eye, Search, House, Plane, Wallet, LayoutDashboardIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon, CircleCheckIcon } from 'lucide-react';
3
3
  import { cva } from 'class-variance-authority';
4
4
  import { clsx } from 'clsx';
5
5
  import { twMerge } from 'tailwind-merge';
6
6
  import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
7
7
  import { createContext, memo, useRef, useState, useMemo, useCallback, useEffect, forwardRef, Fragment, useId, useContext, useLayoutEffect } from 'react';
8
- import { Avatar as Avatar$1, Checkbox as Checkbox$1, Slot, Select as Select$1, Label as Label$1, Toggle as Toggle$1, ToggleGroup, Separator as Separator$1, Progress as Progress$1, Slider as Slider$1, Switch as Switch$1, Tabs as Tabs$1, Tooltip as Tooltip$1, Popover as Popover$1, Dialog as Dialog$1, AlertDialog as AlertDialog$1, Accordion as Accordion$1, DropdownMenu as DropdownMenu$1, RadioGroup as RadioGroup$1, NavigationMenu as NavigationMenu$1 } from 'radix-ui';
8
+ import { Avatar as Avatar$1, Checkbox as Checkbox$1, Slot, Select as Select$1, Label as Label$1, Popover as Popover$1, Toggle as Toggle$1, ToggleGroup, Separator as Separator$1, Progress as Progress$1, Slider as Slider$1, Switch as Switch$1, Tabs as Tabs$1, Tooltip as Tooltip$1, Dialog as Dialog$1, AlertDialog as AlertDialog$1, Accordion as Accordion$1, DropdownMenu as DropdownMenu$1, RadioGroup as RadioGroup$1, NavigationMenu as NavigationMenu$1 } from 'radix-ui';
9
9
  import { isSameDay, isToday, format, addDays } from 'date-fns';
10
10
  import useEmblaCarousel from 'embla-carousel-react';
11
- import { motion, AnimatePresence } from 'motion/react';
11
+ import { parsePhoneNumberFromString, AsYouType } from 'libphonenumber-js';
12
12
  import { Command } from 'cmdk';
13
+ import { VE, UY, US, SV, PY, PT, PE, PA, NI, MX, IT, IN, HN, GT, GB, FR, ES, EC, DO, DE, CU, CR, CO, CL, CA, BR, BO, AR } from 'country-flag-icons/react/3x2';
14
+ import { motion, AnimatePresence } from 'motion/react';
13
15
  import { useDropzone } from 'react-dropzone';
14
16
  import Color from 'color';
15
17
  import { getDefaultClassNames, DayPicker } from 'react-day-picker';
@@ -1047,6 +1049,410 @@ function Link({
1047
1049
  }
1048
1050
  );
1049
1051
  }
1052
+ function Popover({ ...props }) {
1053
+ return /* @__PURE__ */ jsx(Popover$1.Root, { "data-slot": "popover", ...props });
1054
+ }
1055
+ function PopoverTrigger({ ...props }) {
1056
+ return /* @__PURE__ */ jsx(Popover$1.Trigger, { "data-slot": "popover-trigger", ...props });
1057
+ }
1058
+ function PopoverContent({
1059
+ className,
1060
+ align = "center",
1061
+ sideOffset = 4,
1062
+ container,
1063
+ ...props
1064
+ }) {
1065
+ return /* @__PURE__ */ jsx(Popover$1.Portal, { container, children: /* @__PURE__ */ jsx(
1066
+ Popover$1.Content,
1067
+ {
1068
+ "data-slot": "popover-content",
1069
+ align,
1070
+ sideOffset,
1071
+ className: cn(
1072
+ "bg-popover text-popover-foreground ring-foreground/5 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 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-1 rounded-3xl p-4 text-sm shadow-lg ring-1 outline-hidden duration-100",
1073
+ className
1074
+ ),
1075
+ ...props
1076
+ }
1077
+ ) });
1078
+ }
1079
+ function PopoverAnchor({ ...props }) {
1080
+ return /* @__PURE__ */ jsx(Popover$1.Anchor, { "data-slot": "popover-anchor", ...props });
1081
+ }
1082
+ function PopoverHeader({ className, ...props }) {
1083
+ return /* @__PURE__ */ jsx(
1084
+ "div",
1085
+ {
1086
+ "data-slot": "popover-header",
1087
+ className: cn("flex flex-col gap-1 text-sm", className),
1088
+ ...props
1089
+ }
1090
+ );
1091
+ }
1092
+ function PopoverTitle({ className, ...props }) {
1093
+ return /* @__PURE__ */ jsx(
1094
+ "div",
1095
+ {
1096
+ "data-slot": "popover-title",
1097
+ className: cn("text-base font-medium", className),
1098
+ ...props
1099
+ }
1100
+ );
1101
+ }
1102
+ function PopoverDescription({ className, ...props }) {
1103
+ return /* @__PURE__ */ jsx(
1104
+ "p",
1105
+ {
1106
+ "data-slot": "popover-description",
1107
+ className: cn("text-muted-foreground", className),
1108
+ ...props
1109
+ }
1110
+ );
1111
+ }
1112
+ function stripLeadingDialCode(raw, dialCode) {
1113
+ if (!raw.startsWith("+")) {
1114
+ return raw.replace(/\D/g, "");
1115
+ }
1116
+ const parsed = parsePhoneNumberFromString(raw);
1117
+ if (parsed) {
1118
+ return parsed.nationalNumber;
1119
+ }
1120
+ const digits = raw.replace(/\D/g, "");
1121
+ const code = dialCode.replace(/\D/g, "");
1122
+ return code && digits.startsWith(code) ? digits.length > code.length ? digits.slice(code.length) : "" : digits;
1123
+ }
1124
+ var flagByCode = {
1125
+ AR: AR,
1126
+ BO: BO,
1127
+ BR: BR,
1128
+ CA: CA,
1129
+ CL: CL,
1130
+ CO: CO,
1131
+ CR: CR,
1132
+ CU: CU,
1133
+ DE: DE,
1134
+ DO: DO,
1135
+ EC: EC,
1136
+ ES: ES,
1137
+ FR: FR,
1138
+ GB: GB,
1139
+ GT: GT,
1140
+ HN: HN,
1141
+ IN: IN,
1142
+ IT: IT,
1143
+ MX: MX,
1144
+ NI: NI,
1145
+ PA: PA,
1146
+ PE: PE,
1147
+ PT: PT,
1148
+ PY: PY,
1149
+ SV: SV,
1150
+ US: US,
1151
+ UY: UY,
1152
+ VE: VE
1153
+ };
1154
+ function CountryFlag({
1155
+ code,
1156
+ flagUrl,
1157
+ className
1158
+ }) {
1159
+ if (flagUrl) {
1160
+ return /* @__PURE__ */ jsx(
1161
+ "img",
1162
+ {
1163
+ src: flagUrl,
1164
+ alt: "",
1165
+ "aria-hidden": "true",
1166
+ className: cn("size-4 shrink-0 rounded-[2px] object-cover", className)
1167
+ }
1168
+ );
1169
+ }
1170
+ const FlagComponent = flagByCode[(code || "").toUpperCase()];
1171
+ if (FlagComponent) {
1172
+ return /* @__PURE__ */ jsx(
1173
+ FlagComponent,
1174
+ {
1175
+ "aria-hidden": "true",
1176
+ className: cn("size-4 shrink-0 rounded-[2px]", className)
1177
+ }
1178
+ );
1179
+ }
1180
+ return /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn("bg-muted size-4 shrink-0 rounded-full", className) });
1181
+ }
1182
+ function PhoneField({
1183
+ countries,
1184
+ value,
1185
+ onValueChange,
1186
+ defaultCountry,
1187
+ placeholder = "Phone number",
1188
+ disabled = false,
1189
+ className,
1190
+ container,
1191
+ name,
1192
+ ...inputProps
1193
+ }) {
1194
+ const [open, setOpen] = useState(false);
1195
+ const [pickedCode, setPickedCode] = useState(
1196
+ (defaultCountry ?? countries[0]?.code)?.toUpperCase()
1197
+ );
1198
+ const [internalValue, setInternalValue] = useState("");
1199
+ const listRef = useRef(null);
1200
+ const inputRef = useRef(null);
1201
+ const caretRef = useRef(null);
1202
+ const listId = `${useId()}-countries-list`;
1203
+ const isControlled = value !== void 0;
1204
+ const currentValue = isControlled ? value : internalValue;
1205
+ const parsed = currentValue ? parsePhoneNumberFromString(currentValue) : void 0;
1206
+ const parsedCountry = parsed?.country;
1207
+ const parsedCallingCode = parsed?.countryCallingCode;
1208
+ const countryInList = parsedCountry !== void 0 && countries.some((country) => country.code.toUpperCase() === parsedCountry);
1209
+ const callingCodeInList = parsedCallingCode !== void 0 && countries.some(
1210
+ (country) => country.dialCode.replace(/\D/g, "") === parsedCallingCode
1211
+ );
1212
+ const representedCode = countryInList ? parsedCountry : callingCodeInList ? countries.find(
1213
+ (country) => country.dialCode.replace(/\D/g, "") === parsedCallingCode
1214
+ )?.code : void 0;
1215
+ const selectedCode = representedCode ?? pickedCode ?? defaultCountry ?? countries[0]?.code;
1216
+ const selectedCountry = countries.find(
1217
+ (country) => country.code.toUpperCase() === selectedCode?.toUpperCase()
1218
+ ) ?? countries[0];
1219
+ const dialCode = selectedCountry ? selectedCountry.dialCode.replace(/\D/g, "") : "";
1220
+ const emitDialCode = parsedCallingCode ?? dialCode;
1221
+ const nationalDigits = parsed ? parsed.nationalNumber : currentValue ? stripLeadingDialCode(currentValue, dialCode) : "";
1222
+ const canFormat = selectedCountry !== void 0 && (!parsed || countryInList || callingCodeInList);
1223
+ const inputValue = selectedCountry && canFormat && nationalDigits ? new AsYouType((selectedCountry.code || "").toUpperCase()).input(
1224
+ nationalDigits
1225
+ ) : nationalDigits;
1226
+ const isInvalid = inputProps["aria-invalid"] === true || inputProps["aria-invalid"] === "true";
1227
+ useLayoutEffect(() => {
1228
+ const input = inputRef.current;
1229
+ const caret = caretRef.current;
1230
+ if (!input || !caret || document.activeElement !== input) {
1231
+ return;
1232
+ }
1233
+ const digitsBefore = caret.raw.slice(0, caret.start).replace(/\D/g, "").length;
1234
+ let position = 0;
1235
+ if (digitsBefore > 0) {
1236
+ let digitsSeen = 0;
1237
+ for (let i = 0; i < inputValue.length; i++) {
1238
+ if (/\d/.test(inputValue[i])) {
1239
+ digitsSeen += 1;
1240
+ }
1241
+ position = i + 1;
1242
+ if (digitsSeen >= digitsBefore) {
1243
+ break;
1244
+ }
1245
+ }
1246
+ }
1247
+ input.setSelectionRange(position, position + (caret.end - caret.start));
1248
+ caretRef.current = null;
1249
+ }, [inputValue]);
1250
+ const handleSearchChange = () => {
1251
+ requestAnimationFrame(() => listRef.current?.scrollTo({ top: 0 }));
1252
+ };
1253
+ function handleCountrySelect(code) {
1254
+ setPickedCode(code);
1255
+ setOpen(false);
1256
+ const nextCountry = countries.find(
1257
+ (country) => country.code.toUpperCase() === code.toUpperCase()
1258
+ );
1259
+ if (nextCountry && nationalDigits) {
1260
+ const next = `+${nextCountry.dialCode.replace(/\D/g, "")}${nationalDigits}`;
1261
+ onValueChange?.(next);
1262
+ if (!isControlled) {
1263
+ setInternalValue(next);
1264
+ }
1265
+ }
1266
+ }
1267
+ function deriveFromE164(e164) {
1268
+ const parsed2 = parsePhoneNumberFromString(e164);
1269
+ if (!parsed2?.nationalNumber) {
1270
+ return void 0;
1271
+ }
1272
+ const countryMatch = parsed2.country ? countries.find((country) => country.code.toUpperCase() === parsed2.country) : void 0;
1273
+ const nextPickedCode = countryMatch ? countryMatch.code : parsed2.countryCallingCode ? countries.find(
1274
+ (country) => country.dialCode.replace(/\D/g, "") === parsed2.countryCallingCode
1275
+ )?.code : void 0;
1276
+ return {
1277
+ nationalNumber: parsed2.nationalNumber,
1278
+ emitCode: parsed2.countryCallingCode,
1279
+ nextPickedCode
1280
+ };
1281
+ }
1282
+ function handleInputChange(raw, nativeEvent) {
1283
+ const input = inputRef.current;
1284
+ if (input) {
1285
+ caretRef.current = {
1286
+ raw,
1287
+ start: input.selectionStart ?? raw.length,
1288
+ end: input.selectionEnd ?? raw.length
1289
+ };
1290
+ }
1291
+ if (!selectedCountry) return;
1292
+ let national = stripLeadingDialCode(raw, dialCode);
1293
+ let emitCode = emitDialCode;
1294
+ let nextPickedCode;
1295
+ const plusIndex = raw.indexOf("+");
1296
+ if (plusIndex === 0) {
1297
+ const derived = deriveFromE164(raw);
1298
+ if (derived) {
1299
+ emitCode = derived.emitCode || emitDialCode;
1300
+ nextPickedCode = derived.nextPickedCode;
1301
+ } else if (nativeEvent?.inputType === "insertFromPaste") {
1302
+ national = "";
1303
+ }
1304
+ } else if (plusIndex > 0) {
1305
+ const pasted = nativeEvent?.inputType === "insertFromPaste" && nativeEvent.data?.startsWith("+") ? nativeEvent.data : void 0;
1306
+ if (pasted) {
1307
+ const derived = deriveFromE164(pasted);
1308
+ const prefixDigits = raw.slice(0, plusIndex).replace(/\D/g, "");
1309
+ const suffixDigits = raw.slice(plusIndex + pasted.length).replace(/\D/g, "");
1310
+ if (derived) {
1311
+ national = prefixDigits + derived.nationalNumber + suffixDigits;
1312
+ emitCode = derived.emitCode || emitDialCode;
1313
+ nextPickedCode = derived.nextPickedCode;
1314
+ } else {
1315
+ national = prefixDigits + suffixDigits;
1316
+ }
1317
+ }
1318
+ }
1319
+ if (nextPickedCode) {
1320
+ setPickedCode(nextPickedCode);
1321
+ }
1322
+ if (!national) {
1323
+ onValueChange?.("");
1324
+ if (!isControlled) {
1325
+ setInternalValue("");
1326
+ }
1327
+ return;
1328
+ }
1329
+ const next = `+${emitCode}${national}`;
1330
+ onValueChange?.(next);
1331
+ if (!isControlled) {
1332
+ setInternalValue(next);
1333
+ }
1334
+ }
1335
+ return /* @__PURE__ */ jsxs(
1336
+ "div",
1337
+ {
1338
+ "data-slot": "phone-field",
1339
+ "data-invalid": isInvalid || void 0,
1340
+ className: cn(
1341
+ "border-input flex h-9 w-full min-w-0 items-center overflow-hidden rounded-md border bg-transparent shadow-xs transition-[color,box-shadow]",
1342
+ "focus-within:border-ring focus-within:ring-ring/30 focus-within:ring-3",
1343
+ "data-[invalid=true]:border-destructive data-[invalid=true]:ring-destructive/20 data-[invalid=true]:ring-3",
1344
+ "dark:data-[invalid=true]:border-destructive/50 dark:data-[invalid=true]:ring-destructive/40",
1345
+ className
1346
+ ),
1347
+ children: [
1348
+ /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
1349
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
1350
+ "button",
1351
+ {
1352
+ type: "button",
1353
+ "data-slot": "phone-field-country-select",
1354
+ disabled,
1355
+ "aria-expanded": open,
1356
+ "aria-haspopup": "listbox",
1357
+ "aria-controls": open ? listId : void 0,
1358
+ "aria-label": selectedCountry ? `${selectedCountry.name} ${selectedCountry.dialCode}` : void 0,
1359
+ className: cn(
1360
+ "flex h-full shrink-0 cursor-pointer items-center gap-1.5 border-r border-input px-2.5 text-sm font-medium outline-none select-none",
1361
+ "hover:bg-muted",
1362
+ "disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50"
1363
+ ),
1364
+ children: selectedCountry && /* @__PURE__ */ jsxs(Fragment$1, { children: [
1365
+ /* @__PURE__ */ jsx(
1366
+ CountryFlag,
1367
+ {
1368
+ code: selectedCountry.code,
1369
+ flagUrl: selectedCountry.flagUrl
1370
+ }
1371
+ ),
1372
+ /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: selectedCountry.dialCode }),
1373
+ /* @__PURE__ */ jsx(ChevronsUpDownIcon, { size: 14, className: "text-muted-foreground shrink-0" })
1374
+ ] })
1375
+ }
1376
+ ) }),
1377
+ /* @__PURE__ */ jsx(
1378
+ PopoverContent,
1379
+ {
1380
+ className: "w-72 rounded-xl p-0",
1381
+ align: "start",
1382
+ container,
1383
+ children: /* @__PURE__ */ jsxs(Command, { className: "rounded-xl", label: "Search countries", children: [
1384
+ /* @__PURE__ */ jsxs("div", { className: "border-border flex items-center gap-2 border-b px-3", children: [
1385
+ /* @__PURE__ */ jsx(SearchIcon, { size: 14, className: "text-muted-foreground shrink-0" }),
1386
+ /* @__PURE__ */ jsx(
1387
+ Command.Input,
1388
+ {
1389
+ placeholder: "Search country...",
1390
+ onValueChange: handleSearchChange,
1391
+ className: "placeholder:text-muted-foreground flex h-9 w-full bg-transparent py-2 text-sm outline-none"
1392
+ }
1393
+ )
1394
+ ] }),
1395
+ /* @__PURE__ */ jsx("div", { id: listId, children: /* @__PURE__ */ jsxs(Command.List, { ref: listRef, className: "max-h-56 overflow-y-auto p-1", children: [
1396
+ /* @__PURE__ */ jsx(Command.Empty, { className: "text-muted-foreground py-4 text-center text-sm", children: "No country found." }),
1397
+ countries.map((country) => /* @__PURE__ */ jsxs(
1398
+ Command.Item,
1399
+ {
1400
+ value: country.code,
1401
+ keywords: [country.name, country.dialCode],
1402
+ "data-slot": "phone-field-country-item",
1403
+ onSelect: () => handleCountrySelect(country.code),
1404
+ className: cn(
1405
+ "flex cursor-pointer items-center justify-between gap-2 rounded-md px-2 py-1.5 text-sm outline-none select-none",
1406
+ "data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground",
1407
+ "hover:bg-accent hover:text-accent-foreground"
1408
+ ),
1409
+ children: [
1410
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [
1411
+ /* @__PURE__ */ jsx(CountryFlag, { code: country.code, flagUrl: country.flagUrl }),
1412
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: country.name })
1413
+ ] }),
1414
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
1415
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground tabular-nums", children: country.dialCode }),
1416
+ selectedCode?.toUpperCase() === country.code.toUpperCase() && /* @__PURE__ */ jsx(
1417
+ CheckIcon,
1418
+ {
1419
+ size: 14,
1420
+ className: "text-[var(--color-main-blue-primary)] shrink-0"
1421
+ }
1422
+ )
1423
+ ] })
1424
+ ]
1425
+ },
1426
+ country.code
1427
+ ))
1428
+ ] }) })
1429
+ ] })
1430
+ }
1431
+ )
1432
+ ] }),
1433
+ /* @__PURE__ */ jsx(
1434
+ Input,
1435
+ {
1436
+ ref: inputRef,
1437
+ ...inputProps,
1438
+ "data-slot": "phone-field-input",
1439
+ type: "tel",
1440
+ value: inputValue,
1441
+ onChange: (event) => handleInputChange(event.target.value, event.nativeEvent),
1442
+ placeholder,
1443
+ disabled,
1444
+ autoComplete: inputProps.autoComplete ?? "tel",
1445
+ className: cn(
1446
+ "h-full flex-1 rounded-none border-0 bg-transparent shadow-none",
1447
+ "px-3 focus-visible:border-transparent focus-visible:ring-0"
1448
+ )
1449
+ }
1450
+ ),
1451
+ name !== void 0 && /* @__PURE__ */ jsx("input", { type: "hidden", name, value: currentValue, "data-slot": "phone-field-hidden-input" })
1452
+ ]
1453
+ }
1454
+ );
1455
+ }
1050
1456
  function PinInput({
1051
1457
  length = 6,
1052
1458
  value = "",
@@ -2111,66 +2517,6 @@ function TooltipContent({
2111
2517
  }
2112
2518
  ) });
2113
2519
  }
2114
- function Popover({ ...props }) {
2115
- return /* @__PURE__ */ jsx(Popover$1.Root, { "data-slot": "popover", ...props });
2116
- }
2117
- function PopoverTrigger({ ...props }) {
2118
- return /* @__PURE__ */ jsx(Popover$1.Trigger, { "data-slot": "popover-trigger", ...props });
2119
- }
2120
- function PopoverContent({
2121
- className,
2122
- align = "center",
2123
- sideOffset = 4,
2124
- container,
2125
- ...props
2126
- }) {
2127
- return /* @__PURE__ */ jsx(Popover$1.Portal, { container, children: /* @__PURE__ */ jsx(
2128
- Popover$1.Content,
2129
- {
2130
- "data-slot": "popover-content",
2131
- align,
2132
- sideOffset,
2133
- className: cn(
2134
- "bg-popover text-popover-foreground ring-foreground/5 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 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-1 rounded-3xl p-4 text-sm shadow-lg ring-1 outline-hidden duration-100",
2135
- className
2136
- ),
2137
- ...props
2138
- }
2139
- ) });
2140
- }
2141
- function PopoverAnchor({ ...props }) {
2142
- return /* @__PURE__ */ jsx(Popover$1.Anchor, { "data-slot": "popover-anchor", ...props });
2143
- }
2144
- function PopoverHeader({ className, ...props }) {
2145
- return /* @__PURE__ */ jsx(
2146
- "div",
2147
- {
2148
- "data-slot": "popover-header",
2149
- className: cn("flex flex-col gap-1 text-sm", className),
2150
- ...props
2151
- }
2152
- );
2153
- }
2154
- function PopoverTitle({ className, ...props }) {
2155
- return /* @__PURE__ */ jsx(
2156
- "div",
2157
- {
2158
- "data-slot": "popover-title",
2159
- className: cn("text-base font-medium", className),
2160
- ...props
2161
- }
2162
- );
2163
- }
2164
- function PopoverDescription({ className, ...props }) {
2165
- return /* @__PURE__ */ jsx(
2166
- "p",
2167
- {
2168
- "data-slot": "popover-description",
2169
- className: cn("text-muted-foreground", className),
2170
- ...props
2171
- }
2172
- );
2173
- }
2174
2520
  var TEXT_SIZES = [12, 14, 16, 18, 20, 24, 28, 32, 40, 48];
2175
2521
  var TEXT_WEIGHTS = [100, 200, 300, 400, 500, 700, 800, 900];
2176
2522
  function Text({
@@ -4196,22 +4542,52 @@ function DatePicker({
4196
4542
  disabled = false,
4197
4543
  className,
4198
4544
  fromDate,
4199
- toDate
4545
+ toDate,
4546
+ numberOfMonths = 1
4200
4547
  }) {
4201
4548
  const [open, setOpen] = useState(false);
4549
+ const [awaitingRangeEnd, setAwaitingRangeEnd] = useState(false);
4202
4550
  const label = useMemo(() => {
4203
4551
  if (mode === "range") {
4204
4552
  const range = selected;
4205
- if (range?.from && range?.to)
4206
- return `${format(range.from, "MMM d, yyyy")} \u2013 ${format(range.to, "MMM d, yyyy")}`;
4207
- if (range?.from) return `${format(range.from, "MMM d, yyyy")} \u2013 \u2026`;
4208
- return placeholder;
4553
+ if (!range?.from) return placeholder;
4554
+ if (!range.to) return `${format(range.from, "MMM d, yyyy")} \u2013 \u2026`;
4555
+ return `${format(range.from, "MMM d, yyyy")} \u2013 ${format(range.to, "MMM d, yyyy")}`;
4209
4556
  }
4210
4557
  const date = selected;
4211
4558
  return date ? format(date, "MMM d, yyyy") : placeholder;
4212
4559
  }, [mode, selected, placeholder]);
4560
+ const handleOpenChange = (nextOpen) => {
4561
+ setOpen(nextOpen);
4562
+ if (!nextOpen) setAwaitingRangeEnd(false);
4563
+ };
4564
+ const handleRangeSelect = (range, triggerDate) => {
4565
+ const emit = onSelect;
4566
+ if (!awaitingRangeEnd) {
4567
+ setAwaitingRangeEnd(true);
4568
+ emit?.({ from: triggerDate, to: void 0 });
4569
+ return;
4570
+ }
4571
+ emit?.(range);
4572
+ if (!range?.from || !range.to) {
4573
+ setAwaitingRangeEnd(!!range?.from);
4574
+ return;
4575
+ }
4576
+ setAwaitingRangeEnd(false);
4577
+ setOpen(false);
4578
+ };
4579
+ const dateConstraints = useMemo(() => {
4580
+ const disabledMatchers = [];
4581
+ if (fromDate) disabledMatchers.push({ before: fromDate });
4582
+ if (toDate) disabledMatchers.push({ after: toDate });
4583
+ return {
4584
+ ...disabledMatchers.length > 0 && { disabled: disabledMatchers },
4585
+ ...fromDate && { startMonth: fromDate },
4586
+ ...toDate && { endMonth: toDate }
4587
+ };
4588
+ }, [fromDate, toDate]);
4213
4589
  const hasValue = mode === "range" ? !!selected?.from : !!selected;
4214
- return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
4590
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: handleOpenChange, children: [
4215
4591
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
4216
4592
  Button,
4217
4593
  {
@@ -4235,14 +4611,10 @@ function DatePicker({
4235
4611
  ...{
4236
4612
  mode: "range",
4237
4613
  selected,
4238
- onSelect: (range) => {
4239
- onSelect?.(range);
4240
- if (range?.to) setOpen(false);
4241
- },
4242
- fromDate,
4243
- toDate,
4244
- numberOfMonths: 2,
4245
- initialFocus: true
4614
+ onSelect: handleRangeSelect,
4615
+ ...dateConstraints,
4616
+ numberOfMonths,
4617
+ autoFocus: true
4246
4618
  }
4247
4619
  }
4248
4620
  ) : /* @__PURE__ */ jsx(
@@ -4255,9 +4627,9 @@ function DatePicker({
4255
4627
  onSelect?.(date);
4256
4628
  setOpen(false);
4257
4629
  },
4258
- fromDate,
4259
- toDate,
4260
- initialFocus: true
4630
+ ...dateConstraints,
4631
+ numberOfMonths,
4632
+ autoFocus: true
4261
4633
  }
4262
4634
  }
4263
4635
  ) })
@@ -8771,6 +9143,6 @@ function TCCEProvider({
8771
9143
  return /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: tooltipDelayDuration, children: /* @__PURE__ */ jsx(AbilityProvider, { permissions, children: /* @__PURE__ */ jsx(Toaster, { position: toasterPosition, children }) }) });
8772
9144
  }
8773
9145
 
8774
- export { AbilityProvider, Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppShell, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge2 as Badge, BottomNav, BottomNavTabs, BottomNavTabsContent, BottomNavTabsList, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Can, CanNot, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, Checkbox, ColorPicker, ColorPickerAlpha, ColorPickerEyeDropper, ColorPickerFormat, ColorPickerHue, ColorPickerOutput, ColorPickerPresets, ColorPickerSelection, Combobox, DataTable, DataTableCardView, DataTableColumnFilter, DataTableFooter, DataTableHeaderCell, DataTableRowActions, DataTableSearch, DataTableSkeleton, DataTableToolbar, DatePicker, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Dropzone, DropzoneContent, DropzoneEmptyState, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, EventCalendar, Field, FieldDescription, FieldError, FieldGroup, FieldLabel, FilterOption, Input, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Label, Link, Logo, MiniCalendar, MiniCalendarDay, MiniCalendarDays, MiniCalendarNavigation, Navbar, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PinInput, Popover, PopoverAnchor, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, SegmentedControl, SegmentedControlItem, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, SpinnerDots, SpinnerLoader, Status, StatusIndicator, StatusLabel, Switch, TCCEProvider, TEXT_SIZES, TEXT_WEIGHTS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TablePagination, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Text, Textarea, Toaster, Toggle, ToggleGroup2 as ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, alertVariants, animation, avatarVariants, badgeVariants2 as badgeVariants, buttonVariants, columnFiltersToArrayQueryParams, columnFiltersToJsonString, columnFiltersToQueryParams, columnFiltersToRecord, createBackendParams, createBackendParamsWithFilters, duration, ease, fadeIn, getActiveFilterCount, getActiveFilterValues, getColumnValueCounts, getUniqueColumnValues, hasActiveFilters, linkVariants, logos, matchPermission, mergeFilters, multiSelectFilter, navigationMenuTriggerStyle, parseJsonToFilters, parseQueryParamsToFilters, progressIndicatorVariants, progressVariants, scaleIn, searchInArray, skeletonVariants, slideRight, slideUp, sortRecordToSortingState, sortingStateToJsonString, sortingStateToRecord, spinnerDotsVariants, spinnerLoaderVariants, spinnerVariants, spring, stagger, toggleVariants, tooltipContentVariants, transition, useAbility, useAppForm, useCan, useCarousel, useColorPicker, useColumnFilter, useSidebar, useTableContext, useTableData, useTableFiltering, useTableGlobalFilter, useTableSizing, useTableSorting, useTableVisibility, useToast };
9146
+ export { AbilityProvider, Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppShell, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge2 as Badge, BottomNav, BottomNavTabs, BottomNavTabsContent, BottomNavTabsList, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Can, CanNot, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, Checkbox, ColorPicker, ColorPickerAlpha, ColorPickerEyeDropper, ColorPickerFormat, ColorPickerHue, ColorPickerOutput, ColorPickerPresets, ColorPickerSelection, Combobox, DataTable, DataTableCardView, DataTableColumnFilter, DataTableFooter, DataTableHeaderCell, DataTableRowActions, DataTableSearch, DataTableSkeleton, DataTableToolbar, DatePicker, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Dropzone, DropzoneContent, DropzoneEmptyState, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, EventCalendar, Field, FieldDescription, FieldError, FieldGroup, FieldLabel, FilterOption, Input, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Label, Link, Logo, MiniCalendar, MiniCalendarDay, MiniCalendarDays, MiniCalendarNavigation, Navbar, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PhoneField, PinInput, Popover, PopoverAnchor, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, SegmentedControl, SegmentedControlItem, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, SpinnerDots, SpinnerLoader, Status, StatusIndicator, StatusLabel, Switch, TCCEProvider, TEXT_SIZES, TEXT_WEIGHTS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TablePagination, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Text, Textarea, Toaster, Toggle, ToggleGroup2 as ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, alertVariants, animation, avatarVariants, badgeVariants2 as badgeVariants, buttonVariants, columnFiltersToArrayQueryParams, columnFiltersToJsonString, columnFiltersToQueryParams, columnFiltersToRecord, createBackendParams, createBackendParamsWithFilters, duration, ease, fadeIn, getActiveFilterCount, getActiveFilterValues, getColumnValueCounts, getUniqueColumnValues, hasActiveFilters, linkVariants, logos, matchPermission, mergeFilters, multiSelectFilter, navigationMenuTriggerStyle, parseJsonToFilters, parseQueryParamsToFilters, progressIndicatorVariants, progressVariants, scaleIn, searchInArray, skeletonVariants, slideRight, slideUp, sortRecordToSortingState, sortingStateToJsonString, sortingStateToRecord, spinnerDotsVariants, spinnerLoaderVariants, spinnerVariants, spring, stagger, toggleVariants, tooltipContentVariants, transition, useAbility, useAppForm, useCan, useCarousel, useColorPicker, useColumnFilter, useSidebar, useTableContext, useTableData, useTableFiltering, useTableGlobalFilter, useTableSizing, useTableSorting, useTableVisibility, useToast };
8775
9147
  //# sourceMappingURL=main.js.map
8776
9148
  //# sourceMappingURL=main.js.map