periplo-ui 4.22.3 → 4.23.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.
@@ -0,0 +1,13 @@
1
+ import { OTPInputProps } from 'input-otp';
2
+ import { ControlSize } from '../Button';
3
+ import * as React from 'react';
4
+ export type InputOTPProps = Pick<OTPInputProps, 'value' | 'onChange' | 'onComplete' | 'onBlur' | 'onPaste' | 'disabled' | 'name' | 'id' | 'autoFocus' | 'aria-invalid' | 'aria-describedby'> & {
5
+ className?: string;
6
+ /**
7
+ * Slot height, same as the other inputs: sm 32px, md 40px, lg 48px (the `--control-height-*` tokens).
8
+ * @default lg
9
+ */
10
+ size?: ControlSize;
11
+ };
12
+ declare const InputOTP: React.ForwardRefExoticComponent<Readonly<InputOTPProps> & React.RefAttributes<HTMLInputElement>>;
13
+ export { InputOTP };
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ "use client";
3
+ import { cn } from "../../../lib/utils.js";
4
+ import { isFieldInvalid } from "../shared/fieldInvalid.js";
5
+ import * as React$1 from "react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { OTPInput, REGEXP_ONLY_DIGITS } from "input-otp";
8
+ //#region src/components/inputs/InputOTP/InputOTP.tsx
9
+ var OTP_LENGTH = 6;
10
+ var keepDigits = (text) => text.replace(/\D/g, "");
11
+ var replaceWholeValueOnPaste = (event) => event.currentTarget.setSelectionRange(0, event.currentTarget.value.length);
12
+ function OTPSlot({ char, isActive, hasFakeCaret, size, invalid, disabled }) {
13
+ return /* @__PURE__ */ jsxs("div", {
14
+ "data-slot": "input-otp-slot",
15
+ "data-size": size,
16
+ "data-active": isActive ? "" : void 0,
17
+ "data-invalid": invalid ? "" : void 0,
18
+ "data-disabled": disabled ? "" : void 0,
19
+ className: "\n relative flex h-(--control-height) min-w-0 flex-1 items-center justify-center rounded-lg border\n border-neutral-200 bg-white text-(length:--control-text) leading-(--control-leading) text-neutral-950\n transition-colors control\n data-active:border-neutral-950\n data-disabled:bg-neutral-50\n data-invalid:border-error-400\n data-invalid:data-active:border-error-700\n ",
20
+ children: [char, hasFakeCaret && /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute h-1/2 w-px animate-pulse bg-neutral-950 motion-reduce:animate-none" })]
21
+ });
22
+ }
23
+ var InputOTP = React$1.forwardRef(({ className, size = "lg", disabled, "aria-invalid": ariaInvalid, ...props }, ref) => {
24
+ const invalid = isFieldInvalid(void 0, ariaInvalid);
25
+ return /* @__PURE__ */ jsx(OTPInput, {
26
+ ...props,
27
+ ref,
28
+ maxLength: OTP_LENGTH,
29
+ pattern: REGEXP_ONLY_DIGITS,
30
+ inputMode: "numeric",
31
+ autoComplete: "one-time-code",
32
+ pushPasswordManagerStrategy: "none",
33
+ pasteTransformer: keepDigits,
34
+ onPasteCapture: replaceWholeValueOnPaste,
35
+ disabled,
36
+ "aria-invalid": invalid || void 0,
37
+ containerClassName: cn("flex w-full items-center gap-2 has-disabled:opacity-50", className),
38
+ render: ({ slots }) => slots.map((slot, index) => /* @__PURE__ */ jsx(OTPSlot, {
39
+ ...slot,
40
+ size,
41
+ invalid,
42
+ disabled
43
+ }, index))
44
+ });
45
+ });
46
+ InputOTP.displayName = "InputOTP";
47
+ //#endregion
48
+ export { InputOTP };
49
+
50
+ //# sourceMappingURL=InputOTP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InputOTP.js","names":["React"],"sources":["../../../../src/components/inputs/InputOTP/InputOTP.tsx"],"sourcesContent":["'use client'\nimport { OTPInput, REGEXP_ONLY_DIGITS, type OTPInputProps, type SlotProps } from 'input-otp'\nimport * as React from 'react'\n\nimport { type ControlSize } from '../Button'\nimport { isFieldInvalid } from '../shared'\n\nimport { cn } from '@/lib/utils'\n\nconst OTP_LENGTH = 6\n\nconst keepDigits = (text: string) => text.replace(/\\D/g, '')\n\nconst replaceWholeValueOnPaste = (event: React.ClipboardEvent<HTMLInputElement>) =>\n event.currentTarget.setSelectionRange(0, event.currentTarget.value.length)\n\nexport type InputOTPProps = Pick<\n OTPInputProps,\n | 'value'\n | 'onChange'\n | 'onComplete'\n | 'onBlur'\n | 'onPaste'\n | 'disabled'\n | 'name'\n | 'id'\n | 'autoFocus'\n | 'aria-invalid'\n | 'aria-describedby'\n> & {\n className?: string\n /**\n * Slot height, same as the other inputs: sm 32px, md 40px, lg 48px (the `--control-height-*` tokens).\n * @default lg\n */\n size?: ControlSize\n}\n\ntype OTPSlotProps = SlotProps & {\n size: ControlSize\n invalid: boolean\n disabled?: boolean\n}\n\nfunction OTPSlot({ char, isActive, hasFakeCaret, size, invalid, disabled }: Readonly<OTPSlotProps>) {\n return (\n <div\n data-slot=\"input-otp-slot\"\n data-size={size}\n data-active={isActive ? '' : undefined}\n data-invalid={invalid ? '' : undefined}\n data-disabled={disabled ? '' : undefined}\n className=\"\n relative flex h-(--control-height) min-w-0 flex-1 items-center justify-center rounded-lg border\n border-neutral-200 bg-white text-(length:--control-text) leading-(--control-leading) text-neutral-950\n transition-colors control\n data-active:border-neutral-950\n data-disabled:bg-neutral-50\n data-invalid:border-error-400\n data-invalid:data-active:border-error-700\n \"\n >\n {char}\n {hasFakeCaret && (\n <div className=\"pointer-events-none absolute h-1/2 w-px animate-pulse bg-neutral-950 motion-reduce:animate-none\" />\n )}\n </div>\n )\n}\n\nconst InputOTP = React.forwardRef<HTMLInputElement, Readonly<InputOTPProps>>(\n ({ className, size = 'lg', disabled, 'aria-invalid': ariaInvalid, ...props }, ref) => {\n const invalid = isFieldInvalid(undefined, ariaInvalid)\n\n return (\n <OTPInput\n {...props}\n ref={ref}\n maxLength={OTP_LENGTH}\n pattern={REGEXP_ONLY_DIGITS}\n inputMode=\"numeric\"\n autoComplete=\"one-time-code\"\n pushPasswordManagerStrategy=\"none\"\n pasteTransformer={keepDigits}\n onPasteCapture={replaceWholeValueOnPaste}\n disabled={disabled}\n aria-invalid={invalid || undefined}\n containerClassName={cn('flex w-full items-center gap-2 has-disabled:opacity-50', className)}\n render={({ slots }) =>\n slots.map((slot, index) => (\n <OTPSlot key={index} {...slot} size={size} invalid={invalid} disabled={disabled} />\n ))\n }\n />\n )\n },\n)\nInputOTP.displayName = 'InputOTP'\n\nexport { InputOTP }\n"],"mappings":";;;;;;;;AASA,IAAA,aAAA;AAEA,IAAA,cAAA,SAAA,KAAA,QAAA,OAAA,EAAA;AAEA,IAAA,4BAAA,UAAA,MAAA,cAAA,kBAAA,GAAA,MAAA,cAAA,MAAA,MAAA;AA+BA,SAAA,QAAA,EAAA,MAAA,UAAA,cAAA,MAAA,SAAA,YAAA;CACE,OAAA,qBAAA,OAAA;EAEI,aAAA;EACA,aAAA;EACA,eAAA,WAAA,KAAA,KAAA;EACA,gBAAA,UAAA,KAAA,KAAA;EACA,iBAAA,WAAA,KAAA,KAAA;EACA,WAAA;EANF,UAAA,CAAA,MAAA,gBAAA,oBAAA,OAAA,EAAA,WAAA,kGAAA,CAAA,CAAA;;AAsBJ;AAEA,IAAA,WAAA,QAAA,YAAA,EAAA,WAAA,OAAA,MAAA,UAAA,gBAAA,aAAA,GAAA,SAAA,QAAA;CAEI,MAAA,UAAA,eAAA,KAAA,GAAA,WAAA;CAEA,OAAA,oBAAA,UAAA;EAEI,GAAA;EACK;EACL,WAAA;EACA,SAAA;EACA,WAAA;EACA,cAAA;EACA,6BAAA;EACA,kBAAA;EACA,gBAAA;EACU;EACV,gBAAA,WAAA,KAAA;EACA,oBAAA,GAAA,0DAAA,SAAA;EACA,SAAA,EAAA,YAAA,MAAA,KAAA,MAAA,UAAA,oBAAA,SAAA;GAEyB,GAAA;GAAgB;GAAe;GAAmB;EAAW,GAAA,KAAA,CAAA;CAGvF,CAAA;AAEL,CAAA;AAEF,SAAA,cAAA"}
@@ -0,0 +1 @@
1
+ export * from './InputOTP';
@@ -0,0 +1,2 @@
1
+ import { InputOTP } from "./InputOTP.js";
2
+ export { InputOTP };
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export * from './components/inputs/Form';
10
10
  export * from './components/inputs/InlineMultiSelect';
11
11
  export * from './components/inputs/Input';
12
12
  export * from './components/inputs/InputDate';
13
+ export * from './components/inputs/InputOTP';
13
14
  export * from './components/inputs/LazyDatePicker';
14
15
  export * from './components/inputs/MultiSelect';
15
16
  export * from './components/inputs/PhoneInput';
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, For
21
21
  import { InlineMultiSelect } from "./components/inputs/InlineMultiSelect/InlineMultiSelect.js";
22
22
  import { Input } from "./components/inputs/Input/Input.js";
23
23
  import { InputDate } from "./components/inputs/InputDate/InputDate.js";
24
+ import { InputOTP } from "./components/inputs/InputOTP/InputOTP.js";
24
25
  import { LazyDatePicker } from "./components/inputs/LazyDatePicker/LazyDatePicker.js";
25
26
  import { Chip, chipVariants } from "./components/data-display/Chip/Chip.js";
26
27
  import { MultiSelect } from "./components/inputs/MultiSelect/MultiSelect.js";
@@ -57,4 +58,4 @@ import { SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, Si
57
58
  import { SidebarInset, SidebarPageContent, SidebarPageHeader } from "./components/navigation/Sidebar/SidebarPage.js";
58
59
  import { SidebarUser, SidebarUserMenuContent, SidebarUserMenuItem, SidebarUserMenuLabel, SidebarUserMenuRadioGroup, SidebarUserMenuRadioItem, SidebarUserMenuSeparator, SidebarUserMenuSubContent, SidebarUserMenuSubTrigger } from "./components/navigation/Sidebar/SidebarUser.js";
59
60
  import { Tabs, TabsContent, TabsLink, TabsList, TabsTrigger } from "./components/navigation/Tabs/Tabs.js";
60
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Avatar, AvatarFallback, AvatarGroup, AvatarImage, Badge, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbRoot, BreadcrumbSeparator, Button, Calendar, Card, CardContent, CardMedia, Carousel, CarouselContent, CarouselContext, CarouselItem, CarouselNext, CarouselPrevious, Checkbox, Chip, CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, Combobox, ComboboxOptionWithTooltip, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CountrySelect, DataTable, DataTableToolbarButton, DatePicker, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Flag, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, InlineMultiSelect, Input, InputDate, Label, LazyDatePicker, Marquee, MultiSelect, NavigationBreadcrumb, NotificationBadge, PagesBreadcrumb, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PaginationRoot, PhoneInput, Popover, PopoverAnchor, PopoverContent, PopoverRoot, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectRoot, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetRoot, SheetTitle, SheetTrigger, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarHeaderTrigger, SidebarInput, SidebarInset, SidebarLogo, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuCollapsible, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarPageContent, SidebarPageHeader, SidebarProvider, SidebarRoot, SidebarSeparator, SidebarTrigger, SidebarUser, SidebarUserMenuContent, SidebarUserMenuItem, SidebarUserMenuLabel, SidebarUserMenuRadioGroup, SidebarUserMenuRadioItem, SidebarUserMenuSeparator, SidebarUserMenuSubContent, SidebarUserMenuSubTrigger, Skeleton, StarRating, StaticComboboxList, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsLink, TabsList, TabsTrigger, Textarea, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipPortal, TooltipProvider, TooltipRoot, TooltipTrigger, TruncatedTypographyWithTooltip, Typography, VirtualizedComboboxList, badgeVariants, buttonVariants, chipVariants, flagVariants, isValidPhone, isoFromDialCode, notificationBadgeVariants, sidebarGroupActionVariants, sidebarGroupLabelVariants, sidebarMenuActionVariants, sidebarMenuBadgeVariants, sidebarMenuButtonVariants, sidebarMenuSubButtonVariants, sidebarMenuSubVariants, splitE164, toast, toggleVariants, typographyVariants, useCombobox, useFormField, useSidebar };
61
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Avatar, AvatarFallback, AvatarGroup, AvatarImage, Badge, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbRoot, BreadcrumbSeparator, Button, Calendar, Card, CardContent, CardMedia, Carousel, CarouselContent, CarouselContext, CarouselItem, CarouselNext, CarouselPrevious, Checkbox, Chip, CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, Combobox, ComboboxOptionWithTooltip, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CountrySelect, DataTable, DataTableToolbarButton, DatePicker, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Flag, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, InlineMultiSelect, Input, InputDate, InputOTP, Label, LazyDatePicker, Marquee, MultiSelect, NavigationBreadcrumb, NotificationBadge, PagesBreadcrumb, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PaginationRoot, PhoneInput, Popover, PopoverAnchor, PopoverContent, PopoverRoot, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectRoot, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetRoot, SheetTitle, SheetTrigger, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarHeaderTrigger, SidebarInput, SidebarInset, SidebarLogo, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuCollapsible, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarPageContent, SidebarPageHeader, SidebarProvider, SidebarRoot, SidebarSeparator, SidebarTrigger, SidebarUser, SidebarUserMenuContent, SidebarUserMenuItem, SidebarUserMenuLabel, SidebarUserMenuRadioGroup, SidebarUserMenuRadioItem, SidebarUserMenuSeparator, SidebarUserMenuSubContent, SidebarUserMenuSubTrigger, Skeleton, StarRating, StaticComboboxList, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsLink, TabsList, TabsTrigger, Textarea, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipPortal, TooltipProvider, TooltipRoot, TooltipTrigger, TruncatedTypographyWithTooltip, Typography, VirtualizedComboboxList, badgeVariants, buttonVariants, chipVariants, flagVariants, isValidPhone, isoFromDialCode, notificationBadgeVariants, sidebarGroupActionVariants, sidebarGroupLabelVariants, sidebarMenuActionVariants, sidebarMenuBadgeVariants, sidebarMenuButtonVariants, sidebarMenuSubButtonVariants, sidebarMenuSubVariants, splitE164, toast, toggleVariants, typographyVariants, useCombobox, useFormField, useSidebar };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "periplo-ui",
3
3
  "description": "IATI UI library",
4
4
  "private": false,
5
- "version": "4.22.3",
5
+ "version": "4.23.0",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
@@ -108,6 +108,10 @@
108
108
  "types": "./dist/components/inputs/InputDate/index.d.ts",
109
109
  "import": "./dist/components/inputs/InputDate/index.js"
110
110
  },
111
+ "./input-otp": {
112
+ "types": "./dist/components/inputs/InputOTP/index.d.ts",
113
+ "import": "./dist/components/inputs/InputOTP/index.js"
114
+ },
111
115
  "./label": {
112
116
  "types": "./dist/components/data-display/Label/index.d.ts",
113
117
  "import": "./dist/components/data-display/Label/index.js"
@@ -333,6 +337,7 @@
333
337
  "eslint-plugin-testing-library": "7.16.2",
334
338
  "glob": "13.0.6",
335
339
  "husky": "9.1.7",
340
+ "input-otp": "1.5.0",
336
341
  "jsdom": "30.1.1",
337
342
  "lint-staged": "17.6.0",
338
343
  "postcss": "8.5.28",
@@ -384,6 +389,7 @@
384
389
  "country-flag-icons": "^1.6.20",
385
390
  "date-fns": "^4.4.0",
386
391
  "embla-carousel-react": "^8.6.0",
392
+ "input-otp": "^1.5.0",
387
393
  "libphonenumber-js": "^1.13.14",
388
394
  "react-aria": "^3.52.1",
389
395
  "react-aria-components": "^1.21.1",