@algenium/blocks 1.15.0 → 1.16.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/index.cjs CHANGED
@@ -19,6 +19,8 @@ var dateFns = require('date-fns');
19
19
  var reactDayPicker = require('react-day-picker');
20
20
  var cmdk = require('cmdk');
21
21
  var valid = require('card-validator');
22
+ var RPNInput = require('react-phone-number-input');
23
+ var flags = require('react-phone-number-input/flags');
22
24
 
23
25
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
24
26
 
@@ -49,6 +51,8 @@ var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitiv
49
51
  var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
50
52
  var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
51
53
  var valid__default = /*#__PURE__*/_interopDefault(valid);
54
+ var RPNInput__namespace = /*#__PURE__*/_interopNamespace(RPNInput);
55
+ var flags__default = /*#__PURE__*/_interopDefault(flags);
52
56
 
53
57
  var CalendarContext = React7.createContext(null);
54
58
  function useCalendarContext() {
@@ -10289,6 +10293,170 @@ function USAddressInput({
10289
10293
  ] })
10290
10294
  ] });
10291
10295
  }
10296
+ function Input({ className, type, ...props }) {
10297
+ return /* @__PURE__ */ jsxRuntime.jsx(
10298
+ "input",
10299
+ {
10300
+ type,
10301
+ "data-slot": "input",
10302
+ className: cn(
10303
+ "h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30",
10304
+ "focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
10305
+ "aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",
10306
+ className
10307
+ ),
10308
+ ...props
10309
+ }
10310
+ );
10311
+ }
10312
+ var phoneInputGroupClass = "flex h-9 w-full gap-0 overflow-hidden rounded-md border border-input bg-transparent shadow-xs transition-[color,box-shadow] [--PhoneInputCountrySelect-marginRight:0] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50 dark:bg-input/30 [&_.PhoneInputCountry]:mr-0";
10313
+ var PhoneInput = React7__namespace.forwardRef(
10314
+ ({ className, onChange, value, defaultCountry = "MX", ...props }, ref) => {
10315
+ return /* @__PURE__ */ jsxRuntime.jsx(
10316
+ RPNInput__namespace.default,
10317
+ {
10318
+ ref,
10319
+ className: cn(phoneInputGroupClass, className),
10320
+ flagComponent: FlagComponent,
10321
+ countrySelectComponent: CountrySelect,
10322
+ inputComponent: InputComponent,
10323
+ smartCaret: false,
10324
+ defaultCountry,
10325
+ value: value || void 0,
10326
+ onChange: (nextValue) => onChange?.(nextValue || ""),
10327
+ ...props
10328
+ }
10329
+ );
10330
+ }
10331
+ );
10332
+ PhoneInput.displayName = "PhoneInput";
10333
+ var InputComponent = React7__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
10334
+ Input,
10335
+ {
10336
+ className: cn(
10337
+ "h-9 min-h-0 rounded-none border-0 bg-transparent shadow-none focus-visible:border-transparent focus-visible:ring-0 dark:bg-transparent",
10338
+ className
10339
+ ),
10340
+ ...props,
10341
+ ref
10342
+ }
10343
+ ));
10344
+ InputComponent.displayName = "InputComponent";
10345
+ var CountrySelect = ({
10346
+ disabled,
10347
+ value: selectedCountry,
10348
+ options: countryList,
10349
+ onChange
10350
+ }) => {
10351
+ const scrollAreaRef = React7__namespace.useRef(null);
10352
+ const [searchValue, setSearchValue] = React7__namespace.useState("");
10353
+ const [isOpen, setIsOpen] = React7__namespace.useState(false);
10354
+ return /* @__PURE__ */ jsxRuntime.jsxs(
10355
+ Popover,
10356
+ {
10357
+ open: isOpen,
10358
+ modal: true,
10359
+ onOpenChange: (open) => {
10360
+ setIsOpen(open);
10361
+ if (open) setSearchValue("");
10362
+ },
10363
+ children: [
10364
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
10365
+ Button,
10366
+ {
10367
+ type: "button",
10368
+ variant: "ghost",
10369
+ className: "h-9 shrink-0 gap-1 rounded-none border-0 border-r border-input px-2.5 shadow-none hover:bg-muted/50 focus:z-10",
10370
+ disabled,
10371
+ children: [
10372
+ /* @__PURE__ */ jsxRuntime.jsx(
10373
+ FlagComponent,
10374
+ {
10375
+ country: selectedCountry,
10376
+ countryName: selectedCountry
10377
+ }
10378
+ ),
10379
+ /* @__PURE__ */ jsxRuntime.jsx(
10380
+ lucideReact.ChevronsUpDown,
10381
+ {
10382
+ className: cn(
10383
+ "-mr-2 size-4 opacity-50",
10384
+ disabled ? "hidden" : "opacity-100"
10385
+ )
10386
+ }
10387
+ )
10388
+ ]
10389
+ }
10390
+ ) }),
10391
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-[300px] p-0", children: /* @__PURE__ */ jsxRuntime.jsxs(Command, { children: [
10392
+ /* @__PURE__ */ jsxRuntime.jsx(
10393
+ CommandInput,
10394
+ {
10395
+ value: searchValue,
10396
+ onValueChange: (value) => {
10397
+ setSearchValue(value);
10398
+ setTimeout(() => {
10399
+ if (scrollAreaRef.current) {
10400
+ const viewportElement = scrollAreaRef.current.querySelector(
10401
+ "[data-radix-scroll-area-viewport]"
10402
+ );
10403
+ if (viewportElement) {
10404
+ viewportElement.scrollTop = 0;
10405
+ }
10406
+ }
10407
+ }, 0);
10408
+ },
10409
+ placeholder: "Search country..."
10410
+ }
10411
+ ),
10412
+ /* @__PURE__ */ jsxRuntime.jsx(CommandList, { children: /* @__PURE__ */ jsxRuntime.jsxs(ScrollArea, { ref: scrollAreaRef, className: "h-72", children: [
10413
+ /* @__PURE__ */ jsxRuntime.jsx(CommandEmpty, { children: "No country found." }),
10414
+ /* @__PURE__ */ jsxRuntime.jsx(CommandGroup, { children: countryList.map(
10415
+ ({ value, label }) => value ? /* @__PURE__ */ jsxRuntime.jsx(
10416
+ CountrySelectOption,
10417
+ {
10418
+ country: value,
10419
+ countryName: label,
10420
+ selectedCountry,
10421
+ onChange,
10422
+ onSelectComplete: () => setIsOpen(false)
10423
+ },
10424
+ value
10425
+ ) : null
10426
+ ) })
10427
+ ] }) })
10428
+ ] }) })
10429
+ ]
10430
+ }
10431
+ );
10432
+ };
10433
+ var CountrySelectOption = ({
10434
+ country,
10435
+ countryName,
10436
+ selectedCountry,
10437
+ onChange,
10438
+ onSelectComplete
10439
+ }) => {
10440
+ const handleSelect = () => {
10441
+ onChange(country);
10442
+ onSelectComplete();
10443
+ };
10444
+ return /* @__PURE__ */ jsxRuntime.jsxs(CommandItem, { className: "gap-2", onSelect: handleSelect, children: [
10445
+ /* @__PURE__ */ jsxRuntime.jsx(FlagComponent, { country, countryName }),
10446
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 text-sm", children: countryName }),
10447
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-foreground/50", children: `+${RPNInput__namespace.getCountryCallingCode(country)}` }),
10448
+ /* @__PURE__ */ jsxRuntime.jsx(
10449
+ lucideReact.CheckIcon,
10450
+ {
10451
+ className: `ml-auto size-4 ${country === selectedCountry ? "opacity-100" : "opacity-0"}`
10452
+ }
10453
+ )
10454
+ ] });
10455
+ };
10456
+ var FlagComponent = ({ country, countryName }) => {
10457
+ const Flag2 = flags__default.default[country];
10458
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-4 w-6 overflow-hidden rounded-sm bg-foreground/20 [&_svg:not([class*='size-'])]:size-full", children: Flag2 && /* @__PURE__ */ jsxRuntime.jsx(Flag2, { title: countryName }) });
10459
+ };
10292
10460
 
10293
10461
  // src/data/mexicoStates.ts
10294
10462
  var MEXICO_STATES = [
@@ -10547,6 +10715,7 @@ exports.MiniCalendar = MiniCalendar;
10547
10715
  exports.NotificationsContext = NotificationsContext;
10548
10716
  exports.NotificationsWidget = NotificationsWidget;
10549
10717
  exports.OrgSwitcher = OrgSwitcher;
10718
+ exports.PhoneInput = PhoneInput;
10550
10719
  exports.Popover = Popover;
10551
10720
  exports.PopoverAnchor = PopoverAnchor;
10552
10721
  exports.PopoverContent = PopoverContent;