@brightlocal/ui-components 0.1.4 → 0.3.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.
Files changed (105) hide show
  1. package/README.md +2 -1
  2. package/dist/alert.cjs +1 -1
  3. package/dist/alert.d.ts +10 -1
  4. package/dist/alert.d.ts.map +1 -1
  5. package/dist/alert.js +6 -2
  6. package/dist/card.cjs +1 -1
  7. package/dist/card.d.ts +6 -2
  8. package/dist/card.d.ts.map +1 -1
  9. package/dist/card.js +89 -73
  10. package/dist/centred-layout.cjs +1 -1
  11. package/dist/centred-layout.d.ts +49 -25
  12. package/dist/centred-layout.d.ts.map +1 -1
  13. package/dist/centred-layout.js +57 -32
  14. package/dist/checkbox.cjs +1 -1
  15. package/dist/checkbox.d.ts.map +1 -1
  16. package/dist/checkbox.js +19 -19
  17. package/dist/chip.cjs +1 -0
  18. package/dist/chip.d.ts +61 -0
  19. package/dist/chip.d.ts.map +1 -0
  20. package/dist/chip.js +165 -0
  21. package/dist/combobox.cjs +1 -1
  22. package/dist/combobox.d.ts +75 -59
  23. package/dist/combobox.d.ts.map +1 -1
  24. package/dist/combobox.js +244 -191
  25. package/dist/date-picker.cjs +1 -1
  26. package/dist/date-picker.d.ts +89 -52
  27. package/dist/date-picker.d.ts.map +1 -1
  28. package/dist/date-picker.js +228 -210
  29. package/dist/dropdown-menu.d.ts.map +1 -1
  30. package/dist/header.cjs +1 -0
  31. package/dist/header.d.ts +42 -0
  32. package/dist/header.d.ts.map +1 -0
  33. package/dist/header.js +22 -0
  34. package/dist/index.cjs +1 -1
  35. package/dist/index.d.ts +3 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +428 -388
  38. package/dist/input-chip.cjs +1 -0
  39. package/dist/input-chip.d.ts +117 -0
  40. package/dist/input-chip.d.ts.map +1 -0
  41. package/dist/input-chip.js +284 -0
  42. package/dist/input-group.cjs +1 -1
  43. package/dist/input-group.d.ts +5 -0
  44. package/dist/input-group.d.ts.map +1 -1
  45. package/dist/input-group.js +47 -39
  46. package/dist/input-otp.cjs +1 -1
  47. package/dist/input-otp.d.ts +45 -32
  48. package/dist/input-otp.d.ts.map +1 -1
  49. package/dist/input-otp.js +138 -114
  50. package/dist/input-password.cjs +1 -1
  51. package/dist/input-password.d.ts +151 -19
  52. package/dist/input-password.d.ts.map +1 -1
  53. package/dist/input-password.js +197 -91
  54. package/dist/input.cjs +1 -1
  55. package/dist/input.d.ts +4 -0
  56. package/dist/input.d.ts.map +1 -1
  57. package/dist/input.js +26 -24
  58. package/dist/logo.cjs +1 -1
  59. package/dist/logo.js +13 -13
  60. package/dist/progress.cjs +1 -1
  61. package/dist/progress.d.ts +10 -0
  62. package/dist/progress.d.ts.map +1 -1
  63. package/dist/progress.js +45 -36
  64. package/dist/radio-group.cjs +1 -1
  65. package/dist/radio-group.d.ts +4 -0
  66. package/dist/radio-group.d.ts.map +1 -1
  67. package/dist/radio-group.js +49 -47
  68. package/dist/select.cjs +1 -1
  69. package/dist/select.d.ts +3 -1
  70. package/dist/select.d.ts.map +1 -1
  71. package/dist/select.js +57 -56
  72. package/dist/slider.cjs +1 -1
  73. package/dist/slider.d.ts +31 -3
  74. package/dist/slider.d.ts.map +1 -1
  75. package/dist/slider.js +53 -43
  76. package/dist/textarea.cjs +1 -1
  77. package/dist/textarea.d.ts +4 -0
  78. package/dist/textarea.d.ts.map +1 -1
  79. package/dist/textarea.js +19 -18
  80. package/dist/toggle.cjs +1 -1
  81. package/dist/toggle.d.ts.map +1 -1
  82. package/dist/toggle.js +17 -17
  83. package/package.json +1 -1
  84. package/src/components/alert.tsx +10 -1
  85. package/src/components/card.tsx +66 -38
  86. package/src/components/centred-layout.tsx +115 -38
  87. package/src/components/checkbox.tsx +2 -3
  88. package/src/components/chip.tsx +249 -0
  89. package/src/components/combobox.tsx +490 -298
  90. package/src/components/date-picker.tsx +410 -266
  91. package/src/components/dropdown-menu.tsx +6 -1
  92. package/src/components/header.tsx +69 -0
  93. package/src/components/input-chip.tsx +548 -0
  94. package/src/components/input-group.tsx +17 -2
  95. package/src/components/input-otp.tsx +161 -78
  96. package/src/components/input-password.tsx +473 -128
  97. package/src/components/input.tsx +11 -3
  98. package/src/components/logo.tsx +1 -1
  99. package/src/components/progress.tsx +21 -2
  100. package/src/components/radio-group.tsx +11 -0
  101. package/src/components/select.tsx +5 -2
  102. package/src/components/slider.tsx +85 -15
  103. package/src/components/textarea.tsx +15 -5
  104. package/src/components/toggle.tsx +13 -15
  105. package/src/index.ts +3 -0
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react/jsx-runtime"),F=require("react"),q=require("class-variance-authority"),D=require("@brightlocal/ui-components/lib/utils"),E=require("@brightlocal/ui-components/chip");function N(s){const f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(f,n,a.get?a:{enumerable:!0,get:()=>s[n]})}}return f.default=s,Object.freeze(f)}const u=N(F),S=u.createContext(null);function V(){const s=u.useContext(S);if(!s)throw new Error("InputChip components must be used within an <InputChip>");return s}function O({value:s,defaultValue:f=[],onValueChange:n,disabled:a=!1,allowDuplicates:h=!1,children:d}){const[o,i]=u.useState(f),[l,v]=u.useState(""),[b,m]=u.useState(-1),t=u.useRef(null),e=u.useRef([]),c=s!==void 0,r=c?s:o;u.useEffect(()=>{e.current.length>r.length&&(e.current.length=r.length),b>=r.length&&m(-1)},[r.length,b]);const g=u.useCallback(C=>{c||i(C),n?.(C)},[c,n]),R=u.useCallback(C=>{if(a)return;const I=C.trim();I&&(h||!r.includes(I))&&(g([...r,I]),v(""))},[r,g,h,a]),k=u.useCallback(C=>{a||g(r.filter((I,p)=>p!==C))},[r,g,a]),x=u.useMemo(()=>({value:r,onValueChange:g,inputValue:l,setInputValue:v,disabled:a,addItem:R,removeItem:k,inputRef:t,focusedChipIndex:b,setFocusedChipIndex:m,chipRefs:e}),[r,g,l,v,a,R,k,t,b,m,e]);return w.jsx(S.Provider,{value:x,children:d})}const j=q.cva(["relative flex w-full flex-wrap items-center gap-1","min-h-9 rounded-sm border border-input bg-background","px-3 py-2","has-[:focus-visible]:border-ring has-[:focus-visible]:bg-background","has-[:focus-visible]:shadow-default","has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50","transition-[color,box-shadow,border-color]","duration-150","ease-in-out"],{variants:{error:{true:["border-red-600/40 dark:border-red-400/60","has-[:focus-visible]:border-destructive has-[:focus-visible]:shadow-destructive"],false:""}},defaultVariants:{error:!1}}),$=["flex-1 min-w-20","bg-transparent","border-0 outline-none","text-sm font-sans","text-foreground","placeholder:text-muted-foreground","focus:outline-none focus-visible:outline-none","disabled:cursor-not-allowed disabled:opacity-50"],A=u.forwardRef(({className:s,error:f=!1,dataHook:n,trackingEl:a,trackingLabel:h,placeholder:d,inputId:o,"aria-label":i,"aria-labelledby":l,children:v,...b},m)=>{const{value:t,inputValue:e,setInputValue:c,disabled:r,addItem:g,inputRef:R,setFocusedChipIndex:k,chipRefs:x}=V(),C=p=>{c(p.target.value)},I=p=>{if(p.key==="Enter"&&e.trim()&&(p.preventDefault(),g(e)),p.key==="ArrowLeft"&&!e&&t.length>0){p.preventDefault();const y=t.length-1;k(y),x.current[y]?.focus()}if(p.key==="Backspace"&&!e&&t.length>0){p.preventDefault();const y=t.length-1;k(y),x.current[y]?.focus()}};return w.jsxs("div",{ref:m,className:D.cn(j({error:f}),s),"data-hook":n,"data-slot":"input-chip","data-tracking-el":a,"data-tracking-label":h,...b,children:[v,w.jsx("input",{ref:R,"aria-label":i,"aria-labelledby":l,className:D.cn($),"data-slot":"input-chip-input",disabled:r,id:o,placeholder:d,type:"text",value:e,onChange:C,onKeyDown:I})]})});A.displayName="InputChipInput";function B({className:s,dataHookPrefix:f="chip"}){const{value:n,disabled:a,removeItem:h,inputRef:d,setFocusedChipIndex:o,chipRefs:i}=V(),l=u.useRef(null);u.useEffect(()=>{if(l.current!==null){if(l.current==="input")d.current?.focus();else{const t=l.current;t>=0&&t<n.length?i.current[t]?.focus():n.length>0?i.current[n.length-1]?.focus():d.current?.focus()}l.current=null}},[n.length,d,i]);const v=(t,e)=>{if(!a)switch(t.key){case"ArrowLeft":t.preventDefault(),e>0&&(o(e-1),i.current[e-1]?.focus());break;case"ArrowRight":t.preventDefault(),e<n.length-1?(o(e+1),i.current[e+1]?.focus()):(o(-1),d.current?.focus());break;case"Backspace":case"Delete":{t.preventDefault();const c=n.length-1;if(c===0)o(-1),l.current="input",h(e);else if(e>=c){const r=c-1;o(r),l.current=r,h(e)}else o(e),l.current=e,h(e);break}case"Home":t.preventDefault(),n.length>0&&(o(0),i.current[0]?.focus());break;case"End":t.preventDefault(),o(-1),d.current?.focus();break}},b=t=>{o(t)},m=t=>{const e=t.relatedTarget;!!e&&(e.closest('[data-slot="chip"]')!==null||e.dataset.slot==="input-chip-input")||o(-1)};return n.length===0?null:w.jsx("div",{className:D.cn("contents",s),"data-slot":"input-chip-items",children:n.map((t,e)=>w.jsx(E.Chip,{ref:c=>{i.current[e]=c},"aria-label":`${t}, press Delete to remove`,dataHook:`${f}-${e}`,disabled:a,role:"group",tabIndex:-1,onBlur:m,onFocus:()=>b(e),onKeyDown:c=>v(c,e),onRemove:()=>h(e),children:t},`${t}-${e}`))})}const K=j;exports.InputChip=O;exports.InputChipInput=A;exports.InputChipItems=B;exports.inputChipInputVariants=j;exports.inputChipVariants=K;exports.useInputChipContext=V;
@@ -0,0 +1,117 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ import * as React from "react";
3
+ interface InputChipContextValue {
4
+ value: string[];
5
+ onValueChange: (value: string[]) => void;
6
+ inputValue: string;
7
+ setInputValue: (value: string) => void;
8
+ disabled: boolean;
9
+ addItem: (item: string) => void;
10
+ removeItem: (index: number) => void;
11
+ /** Ref to the input element for focus management */
12
+ inputRef: React.RefObject<HTMLInputElement | null>;
13
+ /** Index of the currently focused chip (-1 means input is focused) */
14
+ focusedChipIndex: number;
15
+ /** Set the focused chip index */
16
+ setFocusedChipIndex: (index: number) => void;
17
+ /** Refs for chip elements for programmatic focus */
18
+ chipRefs: React.RefObject<(HTMLDivElement | null)[]>;
19
+ }
20
+ declare function useInputChipContext(): InputChipContextValue;
21
+ export interface InputChipProps {
22
+ /** Controlled value - array of chip values */
23
+ value?: string[];
24
+ /** Default value for uncontrolled mode */
25
+ defaultValue?: string[];
26
+ /** Callback when value changes */
27
+ onValueChange?: (value: string[]) => void;
28
+ /** Disabled state */
29
+ disabled?: boolean;
30
+ /** Allow duplicate values (default: false) */
31
+ allowDuplicates?: boolean;
32
+ /** Children */
33
+ children: React.ReactNode;
34
+ }
35
+ /**
36
+ * InputChip context provider.
37
+ * Manages state for chip values and input.
38
+ *
39
+ * @example Chips inside input
40
+ * ```tsx
41
+ * <InputChip defaultValue={["React", "TypeScript"]}>
42
+ * <InputChipInput dataHook="tags" placeholder="Add...">
43
+ * <InputChipItems />
44
+ * </InputChipInput>
45
+ * </InputChip>
46
+ * ```
47
+ *
48
+ * @example Chips outside input
49
+ * ```tsx
50
+ * <InputChip defaultValue={["React", "TypeScript"]}>
51
+ * <InputChipInput dataHook="tags" placeholder="Add..." />
52
+ * <InputChipItems />
53
+ * </InputChip>
54
+ * ```
55
+ */
56
+ declare function InputChip({ value: controlledValue, defaultValue, onValueChange: controlledOnValueChange, disabled, allowDuplicates, children, }: InputChipProps): import("react/jsx-runtime").JSX.Element;
57
+ declare const inputChipInputVariants: (props?: ({
58
+ error?: boolean | null | undefined;
59
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
60
+ /**
61
+ * Props for the InputChipInput component
62
+ */
63
+ export interface InputChipInputProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange">, VariantProps<typeof inputChipInputVariants> {
64
+ /**
65
+ * Data hook for automated testing (required)
66
+ */
67
+ dataHook: string;
68
+ /**
69
+ * Tracking element identifier for analytics
70
+ */
71
+ trackingEl?: string;
72
+ /**
73
+ * Tracking label for analytics context
74
+ */
75
+ trackingLabel?: string;
76
+ /**
77
+ * Placeholder text for the input
78
+ */
79
+ placeholder?: string;
80
+ /**
81
+ * Whether the input has an error state
82
+ */
83
+ error?: boolean;
84
+ /**
85
+ * ID for the input element (for label association)
86
+ */
87
+ inputId?: string;
88
+ /**
89
+ * Accessible label for the input
90
+ */
91
+ "aria-label"?: string;
92
+ /**
93
+ * ID of element that labels the input
94
+ */
95
+ "aria-labelledby"?: string;
96
+ }
97
+ /**
98
+ * Input container with bordered styling.
99
+ * Place Chip components or InputChipItems inside as children.
100
+ */
101
+ declare const InputChipInput: React.ForwardRefExoticComponent<InputChipInputProps & React.RefAttributes<HTMLDivElement>>;
102
+ export interface InputChipItemsProps {
103
+ /** Custom className for the container */
104
+ className?: string;
105
+ /** Data hook prefix for chips */
106
+ dataHookPrefix?: string;
107
+ }
108
+ /**
109
+ * Auto-renders chips from the InputChip value array.
110
+ * Must be used within an InputChip component.
111
+ */
112
+ declare function InputChipItems({ className, dataHookPrefix, }: InputChipItemsProps): import("react/jsx-runtime").JSX.Element | null;
113
+ declare const inputChipVariants: (props?: ({
114
+ error?: boolean | null | undefined;
115
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
116
+ export { InputChip, InputChipInput, InputChipItems, inputChipVariants, inputChipInputVariants, useInputChipContext, };
117
+ //# sourceMappingURL=input-chip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-chip.d.ts","sourceRoot":"","sources":["../../src/components/input-chip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AASlE,UAAU,qBAAqB;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE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,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,EACtD,YAAY,CAAC,OAAO,sBAAsB,CAAC;IAC7C;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,QAAA,MAAM,cAAc,4FAmFnB,CAAC;AAOF,MAAM,WAAW,mBAAmB;IAClC,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,iBAAS,cAAc,CAAC,EACtB,SAAS,EACT,cAAuB,GACxB,EAAE,mBAAmB,kDAwJrB;AAOD,QAAA,MAAM,iBAAiB;;8EAAyB,CAAC;AAEjD,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,GACpB,CAAC"}
@@ -0,0 +1,284 @@
1
+ import { jsx as D, jsxs as E } from "react/jsx-runtime";
2
+ import * as r from "react";
3
+ import { cva as $ } from "class-variance-authority";
4
+ import { cn as x } from "@brightlocal/ui-components/lib/utils";
5
+ import { Chip as B } from "@brightlocal/ui-components/chip";
6
+ const V = r.createContext(
7
+ null
8
+ );
9
+ function F() {
10
+ const f = r.useContext(V);
11
+ if (!f)
12
+ throw new Error("InputChip components must be used within an <InputChip>");
13
+ return f;
14
+ }
15
+ function T({
16
+ value: f,
17
+ defaultValue: I = [],
18
+ onValueChange: s,
19
+ disabled: l = !1,
20
+ allowDuplicates: p = !1,
21
+ children: h
22
+ }) {
23
+ const [o, c] = r.useState(I), [u, m] = r.useState(""), [d, v] = r.useState(-1), t = r.useRef(null), e = r.useRef([]), a = f !== void 0, n = a ? f : o;
24
+ r.useEffect(() => {
25
+ e.current.length > n.length && (e.current.length = n.length), d >= n.length && v(-1);
26
+ }, [n.length, d]);
27
+ const g = r.useCallback(
28
+ (b) => {
29
+ a || c(b), s?.(b);
30
+ },
31
+ [a, s]
32
+ ), y = r.useCallback(
33
+ (b) => {
34
+ if (l) return;
35
+ const C = b.trim();
36
+ C && (p || !n.includes(C)) && (g([...n, C]), m(""));
37
+ },
38
+ [n, g, p, l]
39
+ ), k = r.useCallback(
40
+ (b) => {
41
+ l || g(n.filter((C, i) => i !== b));
42
+ },
43
+ [n, g, l]
44
+ ), R = r.useMemo(
45
+ () => ({
46
+ value: n,
47
+ onValueChange: g,
48
+ inputValue: u,
49
+ setInputValue: m,
50
+ disabled: l,
51
+ addItem: y,
52
+ removeItem: k,
53
+ inputRef: t,
54
+ focusedChipIndex: d,
55
+ setFocusedChipIndex: v,
56
+ chipRefs: e
57
+ }),
58
+ [
59
+ n,
60
+ g,
61
+ u,
62
+ m,
63
+ l,
64
+ y,
65
+ k,
66
+ t,
67
+ d,
68
+ v,
69
+ e
70
+ ]
71
+ );
72
+ return /* @__PURE__ */ D(V.Provider, { value: R, children: h });
73
+ }
74
+ const A = $(
75
+ [
76
+ // Layout
77
+ "relative flex w-full flex-wrap items-center gap-1",
78
+ // Appearance
79
+ "min-h-9 rounded-sm border border-input bg-background",
80
+ "px-3 py-2",
81
+ // Focus-within state (when input inside is focused)
82
+ "has-[:focus-visible]:border-ring has-[:focus-visible]:bg-background",
83
+ "has-[:focus-visible]:shadow-default",
84
+ // Disabled state
85
+ "has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50",
86
+ // Transition
87
+ "transition-[color,box-shadow,border-color]",
88
+ "duration-150",
89
+ "ease-in-out"
90
+ ],
91
+ {
92
+ variants: {
93
+ error: {
94
+ true: [
95
+ "border-red-600/40 dark:border-red-400/60",
96
+ "has-[:focus-visible]:border-destructive has-[:focus-visible]:shadow-destructive"
97
+ ],
98
+ false: ""
99
+ }
100
+ },
101
+ defaultVariants: {
102
+ error: !1
103
+ }
104
+ }
105
+ ), K = [
106
+ // Reset and base
107
+ "flex-1 min-w-20",
108
+ "bg-transparent",
109
+ "border-0 outline-none",
110
+ // Typography
111
+ "text-sm font-sans",
112
+ "text-foreground",
113
+ // Placeholder
114
+ "placeholder:text-muted-foreground",
115
+ // Focus - no visible focus ring since container handles it
116
+ "focus:outline-none focus-visible:outline-none",
117
+ // Disabled
118
+ "disabled:cursor-not-allowed disabled:opacity-50"
119
+ ], N = r.forwardRef(
120
+ ({
121
+ className: f,
122
+ error: I = !1,
123
+ dataHook: s,
124
+ trackingEl: l,
125
+ trackingLabel: p,
126
+ placeholder: h,
127
+ inputId: o,
128
+ "aria-label": c,
129
+ "aria-labelledby": u,
130
+ children: m,
131
+ ...d
132
+ }, v) => {
133
+ const {
134
+ value: t,
135
+ inputValue: e,
136
+ setInputValue: a,
137
+ disabled: n,
138
+ addItem: g,
139
+ inputRef: y,
140
+ setFocusedChipIndex: k,
141
+ chipRefs: R
142
+ } = F(), b = (i) => {
143
+ a(i.target.value);
144
+ }, C = (i) => {
145
+ if (i.key === "Enter" && e.trim() && (i.preventDefault(), g(e)), i.key === "ArrowLeft" && !e && t.length > 0) {
146
+ i.preventDefault();
147
+ const w = t.length - 1;
148
+ k(w), R.current[w]?.focus();
149
+ }
150
+ if (i.key === "Backspace" && !e && t.length > 0) {
151
+ i.preventDefault();
152
+ const w = t.length - 1;
153
+ k(w), R.current[w]?.focus();
154
+ }
155
+ };
156
+ return /* @__PURE__ */ E(
157
+ "div",
158
+ {
159
+ ref: v,
160
+ className: x(A({ error: I }), f),
161
+ "data-hook": s,
162
+ "data-slot": "input-chip",
163
+ "data-tracking-el": l,
164
+ "data-tracking-label": p,
165
+ ...d,
166
+ children: [
167
+ m,
168
+ /* @__PURE__ */ D(
169
+ "input",
170
+ {
171
+ ref: y,
172
+ "aria-label": c,
173
+ "aria-labelledby": u,
174
+ className: x(K),
175
+ "data-slot": "input-chip-input",
176
+ disabled: n,
177
+ id: o,
178
+ placeholder: h,
179
+ type: "text",
180
+ value: e,
181
+ onChange: b,
182
+ onKeyDown: C
183
+ }
184
+ )
185
+ ]
186
+ }
187
+ );
188
+ }
189
+ );
190
+ N.displayName = "InputChipInput";
191
+ function W({
192
+ className: f,
193
+ dataHookPrefix: I = "chip"
194
+ }) {
195
+ const {
196
+ value: s,
197
+ disabled: l,
198
+ removeItem: p,
199
+ inputRef: h,
200
+ setFocusedChipIndex: o,
201
+ chipRefs: c
202
+ } = F(), u = r.useRef(null);
203
+ r.useEffect(() => {
204
+ if (u.current !== null) {
205
+ if (u.current === "input")
206
+ h.current?.focus();
207
+ else {
208
+ const t = u.current;
209
+ t >= 0 && t < s.length ? c.current[t]?.focus() : s.length > 0 ? c.current[s.length - 1]?.focus() : h.current?.focus();
210
+ }
211
+ u.current = null;
212
+ }
213
+ }, [s.length, h, c]);
214
+ const m = (t, e) => {
215
+ if (!l)
216
+ switch (t.key) {
217
+ case "ArrowLeft":
218
+ t.preventDefault(), e > 0 && (o(e - 1), c.current[e - 1]?.focus());
219
+ break;
220
+ case "ArrowRight":
221
+ t.preventDefault(), e < s.length - 1 ? (o(e + 1), c.current[e + 1]?.focus()) : (o(-1), h.current?.focus());
222
+ break;
223
+ case "Backspace":
224
+ case "Delete": {
225
+ t.preventDefault();
226
+ const a = s.length - 1;
227
+ if (a === 0)
228
+ o(-1), u.current = "input", p(e);
229
+ else if (e >= a) {
230
+ const n = a - 1;
231
+ o(n), u.current = n, p(e);
232
+ } else
233
+ o(e), u.current = e, p(e);
234
+ break;
235
+ }
236
+ case "Home":
237
+ t.preventDefault(), s.length > 0 && (o(0), c.current[0]?.focus());
238
+ break;
239
+ case "End":
240
+ t.preventDefault(), o(-1), h.current?.focus();
241
+ break;
242
+ }
243
+ }, d = (t) => {
244
+ o(t);
245
+ }, v = (t) => {
246
+ const e = t.relatedTarget;
247
+ !!e && (e.closest('[data-slot="chip"]') !== null || e.dataset.slot === "input-chip-input") || o(-1);
248
+ };
249
+ return s.length === 0 ? null : /* @__PURE__ */ D(
250
+ "div",
251
+ {
252
+ className: x("contents", f),
253
+ "data-slot": "input-chip-items",
254
+ children: s.map((t, e) => /* @__PURE__ */ D(
255
+ B,
256
+ {
257
+ ref: (a) => {
258
+ c.current[e] = a;
259
+ },
260
+ "aria-label": `${t}, press Delete to remove`,
261
+ dataHook: `${I}-${e}`,
262
+ disabled: l,
263
+ role: "group",
264
+ tabIndex: -1,
265
+ onBlur: v,
266
+ onFocus: () => d(e),
267
+ onKeyDown: (a) => m(a, e),
268
+ onRemove: () => p(e),
269
+ children: t
270
+ },
271
+ `${t}-${e}`
272
+ ))
273
+ }
274
+ );
275
+ }
276
+ const M = A;
277
+ export {
278
+ T as InputChip,
279
+ N as InputChipInput,
280
+ W as InputChipItems,
281
+ A as inputChipInputVariants,
282
+ M as inputChipVariants,
283
+ F as useInputChipContext
284
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),m=require("react"),h=require("@radix-ui/react-slot"),c=require("class-variance-authority"),a=require("@brightlocal/ui-components/lib/utils"),G=require("./input.cjs");function x(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,o.get?o:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const i=x(m),d=c.cva("relative flex w-full items-center overflow-hidden rounded-md border border-input bg-background transition-colors has-[:focus-visible]:border-ring has-[:focus-visible]:shadow-default has-[:disabled]:opacity-50",{variants:{size:{default:"h-9",sm:"h-8",lg:"h-10"}},defaultVariants:{size:"default"}}),p=i.forwardRef(({className:t,size:n,dataHook:e,trackingEl:o,trackingLabel:s,...u},l)=>r.jsx("div",{ref:l,className:a.cn(d({size:n}),t),"data-hook":e,"data-slot":"input-group","data-tracking-el":o,"data-tracking-label":s,...u}));p.displayName="InputGroup";const f=i.forwardRef(({className:t,...n},e)=>r.jsx(G.Input,{ref:e,className:a.cn("border-0 focus-visible:border-0 focus-visible:shadow-[none]","h-full",t),dataHook:"input-group-input",...n}));f.displayName="InputGroupInput";const I=c.cva("flex shrink-0 items-center text-muted-foreground",{variants:{align:{"inline-start":"","inline-end":"ml-auto","block-start":"self-start","block-end":"self-end"}},defaultVariants:{align:"inline-start"}}),g=i.forwardRef(({className:t,align:n,...e},o)=>r.jsx("div",{ref:o,className:a.cn(I({align:n}),t),"data-slot":"input-group-addon",...e}));g.displayName="InputGroupAddon";const b=c.cva(["inline-flex items-center justify-center gap-2","text-sm font-medium transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50","text-muted-foreground hover:text-foreground","[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0"],{variants:{variant:{default:"hover:bg-accent",ghost:""},size:{default:"h-9 px-3",sm:"h-8 px-2",lg:"h-10 px-4",icon:"h-9 w-9","icon-xs":"h-6 w-6","icon-sm":"h-8 w-8","icon-lg":"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),v=i.forwardRef(({className:t,variant:n,size:e,asChild:o=!1,...s},u)=>{const l=o?h.Slot:"button";return r.jsx(l,{ref:u,className:a.cn(b({variant:n,size:e,className:t})),"data-slot":"input-group-button",type:o?void 0:"button",...s})});v.displayName="InputGroupButton";exports.InputGroup=p;exports.InputGroupAddon=g;exports.InputGroupButton=v;exports.InputGroupInput=f;exports.inputGroupButtonVariants=b;exports.inputGroupVariants=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),h=require("react"),G=require("@radix-ui/react-slot"),l=require("class-variance-authority"),a=require("@brightlocal/ui-components/lib/utils"),x=require("./input.cjs");function I(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const s=I(h),c=l.cva("relative flex w-full items-center overflow-hidden rounded-md border border-input bg-background transition-colors has-[:focus-visible]:border-ring has-[:focus-visible]:shadow-default has-[:disabled]:opacity-50",{variants:{size:{default:"h-9",sm:"h-8",lg:"h-10"},error:{true:["border-red-600/40 dark:border-red-400/60","has-[:focus-visible]:border-destructive has-[:focus-visible]:shadow-destructive"],false:""}},defaultVariants:{size:"default",error:!1}}),p=s.forwardRef(({className:t,size:n,error:e,dataHook:r,trackingEl:i,trackingLabel:u,...d},m)=>o.jsx("div",{ref:m,className:a.cn(c({size:n,error:e}),t),"data-hook":r,"data-slot":"input-group","data-tracking-el":i,"data-tracking-label":u,...d}));p.displayName="InputGroup";const f=s.forwardRef(({className:t,...n},e)=>o.jsx(x.Input,{ref:e,className:a.cn("border-0 focus-visible:border-0 focus-visible:shadow-[none]","h-full",t),dataHook:"input-group-input",...n}));f.displayName="InputGroupInput";const w=l.cva("flex shrink-0 items-center text-muted-foreground",{variants:{align:{"inline-start":"","inline-end":"ml-auto","block-start":"self-start","block-end":"self-end"}},defaultVariants:{align:"inline-start"}}),b=s.forwardRef(({className:t,align:n,...e},r)=>o.jsx("div",{ref:r,className:a.cn(w({align:n}),t),"data-slot":"input-group-addon",...e}));b.displayName="InputGroupAddon";const g=l.cva(["inline-flex items-center justify-center gap-2","text-sm font-medium transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50","text-muted-foreground hover:text-foreground","[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0"],{variants:{variant:{default:"hover:bg-accent",ghost:""},size:{default:"h-9 px-3",sm:"h-8 px-2",lg:"h-10 px-4",icon:"h-9 w-9","icon-xs":"h-6 w-6","icon-sm":"h-8 w-8","icon-lg":"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),v=s.forwardRef(({className:t,variant:n,size:e,asChild:r=!1,...i},u)=>{const d=r?G.Slot:"button";return o.jsx(d,{ref:u,className:a.cn(g({variant:n,size:e,className:t})),"data-slot":"input-group-button",type:r?void 0:"button",...i})});v.displayName="InputGroupButton";exports.InputGroup=p;exports.InputGroupAddon=b;exports.InputGroupButton=v;exports.InputGroupInput=f;exports.inputGroupButtonVariants=g;exports.inputGroupVariants=c;
@@ -3,6 +3,7 @@ import { InputProps } from './input';
3
3
  import * as React from "react";
4
4
  declare const inputGroupVariants: (props?: ({
5
5
  size?: "default" | "sm" | "lg" | null | undefined;
6
+ error?: boolean | null | undefined;
6
7
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
7
8
  interface InputGroupProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof inputGroupVariants> {
8
9
  /**
@@ -17,6 +18,10 @@ interface InputGroupProps extends React.HTMLAttributes<HTMLDivElement>, VariantP
17
18
  * Tracking label for analytics context
18
19
  */
19
20
  trackingLabel?: string;
21
+ /**
22
+ * Whether the input group has an error state
23
+ */
24
+ error?: boolean;
20
25
  }
21
26
  declare const InputGroup: React.ForwardRefExoticComponent<InputGroupProps & React.RefAttributes<HTMLDivElement>>;
22
27
  type InputGroupInputProps = Omit<InputProps, "hasIcon" | "hasSecondaryIcon" | "dataHook">;
@@ -1 +1 @@
1
- {"version":3,"file":"input-group.d.ts","sourceRoot":"","sources":["../../src/components/input-group.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAS,KAAK,UAAU,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AO,EACL,UAAU,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,GACzB,CAAC;AACF,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,GACtB,CAAC"}
@@ -1,10 +1,10 @@
1
- import { jsx as r } from "react/jsx-runtime";
1
+ import { jsx as n } from "react/jsx-runtime";
2
2
  import * as a from "react";
3
- import { Slot as p } from "@radix-ui/react-slot";
3
+ import { Slot as f } from "@radix-ui/react-slot";
4
4
  import { cva as d } from "class-variance-authority";
5
- import { cn as i } from "@brightlocal/ui-components/lib/utils";
6
- import { Input as f } from "./input.js";
7
- const c = d(
5
+ import { cn as s } from "@brightlocal/ui-components/lib/utils";
6
+ import { Input as c } from "./input.js";
7
+ const m = d(
8
8
  "relative flex w-full items-center overflow-hidden rounded-md border border-input bg-background transition-colors has-[:focus-visible]:border-ring has-[:focus-visible]:shadow-default has-[:disabled]:opacity-50",
9
9
  {
10
10
  variants: {
@@ -12,43 +12,51 @@ const c = d(
12
12
  default: "h-9",
13
13
  sm: "h-8",
14
14
  lg: "h-10"
15
+ },
16
+ error: {
17
+ true: [
18
+ "border-red-600/40 dark:border-red-400/60",
19
+ "has-[:focus-visible]:border-destructive has-[:focus-visible]:shadow-destructive"
20
+ ],
21
+ false: ""
15
22
  }
16
23
  },
17
24
  defaultVariants: {
18
- size: "default"
25
+ size: "default",
26
+ error: !1
19
27
  }
20
28
  }
21
- ), m = a.forwardRef(
22
- ({ className: t, size: o, dataHook: n, trackingEl: e, trackingLabel: s, ...u }, l) => /* @__PURE__ */ r(
29
+ ), b = a.forwardRef(
30
+ ({ className: t, size: e, error: o, dataHook: r, trackingEl: i, trackingLabel: u, ...l }, p) => /* @__PURE__ */ n(
23
31
  "div",
24
32
  {
25
- ref: l,
26
- className: i(c({ size: o }), t),
27
- "data-hook": n,
33
+ ref: p,
34
+ className: s(m({ size: e, error: o }), t),
35
+ "data-hook": r,
28
36
  "data-slot": "input-group",
29
- "data-tracking-el": e,
30
- "data-tracking-label": s,
31
- ...u
37
+ "data-tracking-el": i,
38
+ "data-tracking-label": u,
39
+ ...l
32
40
  }
33
41
  )
34
42
  );
35
- m.displayName = "InputGroup";
36
- const g = a.forwardRef(({ className: t, ...o }, n) => /* @__PURE__ */ r(
37
- f,
43
+ b.displayName = "InputGroup";
44
+ const v = a.forwardRef(({ className: t, ...e }, o) => /* @__PURE__ */ n(
45
+ c,
38
46
  {
39
- ref: n,
40
- className: i(
47
+ ref: o,
48
+ className: s(
41
49
  // Override border and focus styles since InputGroup handles them
42
50
  "border-0 focus-visible:border-0 focus-visible:shadow-[none]",
43
51
  "h-full",
44
52
  t
45
53
  ),
46
54
  dataHook: "input-group-input",
47
- ...o
55
+ ...e
48
56
  }
49
57
  ));
50
- g.displayName = "InputGroupInput";
51
- const v = d(
58
+ v.displayName = "InputGroupInput";
59
+ const g = d(
52
60
  "flex shrink-0 items-center text-muted-foreground",
53
61
  {
54
62
  variants: {
@@ -63,19 +71,19 @@ const v = d(
63
71
  align: "inline-start"
64
72
  }
65
73
  }
66
- ), b = a.forwardRef(
67
- ({ className: t, align: o, ...n }, e) => /* @__PURE__ */ r(
74
+ ), h = a.forwardRef(
75
+ ({ className: t, align: e, ...o }, r) => /* @__PURE__ */ n(
68
76
  "div",
69
77
  {
70
- ref: e,
71
- className: i(v({ align: o }), t),
78
+ ref: r,
79
+ className: s(g({ align: e }), t),
72
80
  "data-slot": "input-group-addon",
73
- ...n
81
+ ...o
74
82
  }
75
83
  )
76
84
  );
77
- b.displayName = "InputGroupAddon";
78
- const h = d(
85
+ h.displayName = "InputGroupAddon";
86
+ const w = d(
79
87
  [
80
88
  "inline-flex items-center justify-center gap-2",
81
89
  "text-sm font-medium transition-colors",
@@ -105,22 +113,22 @@ const h = d(
105
113
  size: "default"
106
114
  }
107
115
  }
108
- ), x = a.forwardRef(({ className: t, variant: o, size: n, asChild: e = !1, ...s }, u) => /* @__PURE__ */ r(
109
- e ? p : "button",
116
+ ), x = a.forwardRef(({ className: t, variant: e, size: o, asChild: r = !1, ...i }, u) => /* @__PURE__ */ n(
117
+ r ? f : "button",
110
118
  {
111
119
  ref: u,
112
- className: i(h({ variant: o, size: n, className: t })),
120
+ className: s(w({ variant: e, size: o, className: t })),
113
121
  "data-slot": "input-group-button",
114
- type: e ? void 0 : "button",
115
- ...s
122
+ type: r ? void 0 : "button",
123
+ ...i
116
124
  }
117
125
  ));
118
126
  x.displayName = "InputGroupButton";
119
127
  export {
120
- m as InputGroup,
121
- b as InputGroupAddon,
128
+ b as InputGroup,
129
+ h as InputGroupAddon,
122
130
  x as InputGroupButton,
123
- g as InputGroupInput,
124
- h as inputGroupButtonVariants,
125
- c as inputGroupVariants
131
+ v as InputGroupInput,
132
+ w as inputGroupButtonVariants,
133
+ m as inputGroupVariants
126
134
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),y=require("react"),l=require("input-otp"),_=require("@brightlocal/icons"),O=require("@brightlocal/ui-components/lib/utils"),N=require("@brightlocal/ui-components/label");function R(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const d=R(y),x=d.forwardRef(({trackingEl:e,trackingLabel:n,dataHook:r,containerClassName:i,...a},o)=>{const c=a.id||a["aria-label"]?a["aria-label"]:"One-time password";return t.jsx(l.OTPInput,{ref:o,"aria-label":c,className:"disabled:cursor-not-allowed",containerClassName:O.cn("group flex items-center gap-2 has-disabled:opacity-50 w-fit",i),"data-hook":r,"data-slot":"input-otp","data-tracking-el":e,"data-tracking-label":n,...a})});x.displayName="InputOTP";function m({className:e,...n}){return t.jsx("div",{className:O.cn("flex items-center rounded-md shadow-xs",e),"data-slot":"input-otp-group",...n})}function p({index:e,className:n,...r}){const i=d.useContext(l.OTPInputContext),{char:a,hasFakeCaret:o,isActive:s}=i?.slots[e]??{};return t.jsxs("div",{className:O.cn("relative flex h-9 w-9 items-center justify-center","border-input bg-background border-y border-r","text-foreground text-sm font-normal transition-all outline-none","first:rounded-l-md first:border-l last:rounded-r-md","data-[active=true]:border-ring data-[active=true]:z-10","data-[active=true]:shadow-default","group-has-[input[aria-invalid=true]]:border-destructive","group-has-[input[aria-invalid=true]]:data-[active=true]:shadow-destructive","group-has-[input[aria-invalid=true]]:data-[active=true]:border-destructive","dark:bg-input/30",n),"data-active":s,"data-slot":"input-otp-slot",...r,children:[a,o&&t.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}function j({...e}){return t.jsx("div",{"data-slot":"input-otp-separator",role:"separator",...e,children:t.jsx(_.MinusIcon,{})})}const f=d.forwardRef(({label:e,id:n,dataHook:r,trackingEl:i,trackingLabel:a,containerClassName:o,children:s,"aria-label":c,...h},b)=>{const g=d.useId(),u=n||g,S=c||(e?void 0:"One-time password");return t.jsxs("div",{className:"w-fit",children:[e&&t.jsx(N.Label,{className:"mb-2","data-hook":r?`${r}-label`:void 0,htmlFor:u,children:e}),t.jsx(x,{ref:b,"aria-label":S,containerClassName:o,dataHook:r,id:e?u:void 0,trackingEl:i,trackingLabel:a,...h,children:s})]})});f.displayName="InputOTPField";const I=d.forwardRef(({maxLength:e=6,pattern:n=l.REGEXP_ONLY_DIGITS,...r},i)=>t.jsx(f,{ref:i,inputMode:"numeric",maxLength:e,pasteTransformer:a=>a.replace(/\D+/g,"").slice(0,e),pattern:n,...r,children:t.jsx(m,{children:Array.from({length:e},(a,o)=>t.jsx(p,{index:o},o))})}));I.displayName="InputOTPDigitsOnly";const P=d.forwardRef(({maxLength:e=4,...n},r)=>t.jsx(f,{ref:r,containerClassName:"gap-2",maxLength:e,...n,children:Array.from({length:e},(i,a)=>t.jsx(p,{className:"rounded-md border-l shadow-xs",index:a},a))}));P.displayName="InputOTPWithSpacing";const T=d.forwardRef(({maxLength:e=6,...n},r)=>{const i=Math.ceil(e/2),a=e-i;return t.jsxs(f,{ref:r,maxLength:e,...n,children:[t.jsx(m,{children:Array.from({length:i},(o,s)=>t.jsx(p,{index:s},s))}),t.jsx(j,{}),t.jsx(m,{children:Array.from({length:a},(o,s)=>t.jsx(p,{index:s+i},s+i))})]})});T.displayName="InputOTPSimple";const v=d.forwardRef(({maxLength:e=6,...n},r)=>{const a=Math.ceil(e/2);return t.jsx(f,{ref:r,maxLength:e,...n,children:Array.from({length:a},(o,s)=>{const c=s*2,b=Math.min(c+2,e)-c;return t.jsxs(d.Fragment,{children:[s>0&&t.jsx(j,{}),t.jsx(m,{children:Array.from({length:b},(g,u)=>t.jsx(p,{index:c+u},c+u))})]},s)})})});v.displayName="InputOTPWithSeparator";Object.defineProperty(exports,"REGEXP_ONLY_CHARS",{enumerable:!0,get:()=>l.REGEXP_ONLY_CHARS});Object.defineProperty(exports,"REGEXP_ONLY_DIGITS",{enumerable:!0,get:()=>l.REGEXP_ONLY_DIGITS});Object.defineProperty(exports,"REGEXP_ONLY_DIGITS_AND_CHARS",{enumerable:!0,get:()=>l.REGEXP_ONLY_DIGITS_AND_CHARS});exports.InputOTPDigitsOnly=I;exports.InputOTPSimple=T;exports.InputOTPWithSeparator=v;exports.InputOTPWithSpacing=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),_=require("react"),l=require("input-otp"),N=require("@brightlocal/icons"),I=require("@brightlocal/ui-components/lib/utils"),v=require("@brightlocal/ui-components/label");function w(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:()=>t[n]})}}return r.default=t,Object.freeze(r)}const i=w(_),h=i.createContext(null);function R(){const t=i.useContext(h);if(!t)throw new Error("InputOTP components must be used within an <InputOTP>");return t}const P=i.forwardRef(({dataHook:t,trackingEl:r,trackingLabel:n,containerClassName:a,error:o,disabled:c,children:s,...u},f)=>{const O=i.useMemo(()=>({error:o,disabled:c}),[o,c]);return e.jsx(h.Provider,{value:O,children:e.jsx(l.OTPInput,{ref:f,"aria-invalid":o?"true":void 0,className:"disabled:cursor-not-allowed",containerClassName:I.cn("group flex items-center gap-2 has-disabled:opacity-50 w-fit",a),"data-hook":t,"data-slot":"input-otp","data-tracking-el":r,"data-tracking-label":n,disabled:c,...u,children:s})})});P.displayName="InputOTP";function m({className:t,...r}){return e.jsx("div",{className:I.cn("flex items-center rounded-md shadow-xs",t),"data-slot":"input-otp-group",...r})}function d({index:t,className:r,...n}){const{error:a}=R(),o=i.useContext(l.OTPInputContext),{char:c,hasFakeCaret:s,isActive:u}=o?.slots[t]??{};return e.jsxs("div",{className:I.cn("relative flex h-9 w-9 items-center justify-center","border-input bg-background border-y border-r","text-foreground text-sm font-normal transition-all outline-none","first:rounded-l-md first:border-l last:rounded-r-md","data-[active=true]:border-ring data-[active=true]:z-10","data-[active=true]:shadow-default",a&&"border-destructive",a&&u&&"shadow-destructive","dark:bg-input/30",r),"data-active":u,"data-error":a,"data-slot":"input-otp-slot",...n,children:[c,s&&e.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}function x({...t}){return e.jsx("div",{"data-slot":"input-otp-separator",role:"separator",...t,children:e.jsx(N.MinusIcon,{})})}function j({dataHook:t,className:r,...n}){return e.jsx(v.Label,{className:I.cn("mb-2",r),"data-hook":t,"data-slot":"input-otp-label",...n})}const p=i.forwardRef(({label:t,id:r,dataHook:n,"aria-label":a,children:o,...c},s)=>{const u=i.useId(),f=r||u,O=a||(t?void 0:"One-time password");return e.jsxs("div",{className:"w-fit","data-slot":"input-otp-field",children:[t&&e.jsx(j,{dataHook:n?`${n}-label`:void 0,htmlFor:f,children:t}),e.jsx(P,{ref:s,"aria-label":O,dataHook:n,id:t?f:void 0,...c,children:o})]})});p.displayName="InputOTPField";const g=i.forwardRef(({maxLength:t=6,...r},n)=>e.jsx(p,{ref:n,inputMode:"numeric",maxLength:t,pasteTransformer:a=>a.replace(/\D+/g,"").slice(0,t),pattern:l.REGEXP_ONLY_DIGITS,...r,children:e.jsx(m,{children:Array.from({length:t},(a,o)=>e.jsx(d,{index:o},o))})}));g.displayName="InputOTPDigitsOnly";const b=i.forwardRef(({maxLength:t=4,...r},n)=>e.jsx(p,{ref:n,containerClassName:"gap-2",maxLength:t,...r,children:Array.from({length:t},(a,o)=>e.jsx(d,{className:"rounded-md border-l shadow-xs",index:o},o))}));b.displayName="InputOTPWithSpacing";const S=i.forwardRef(({maxLength:t=6,...r},n)=>{const a=Math.ceil(t/2),o=t-a;return e.jsxs(p,{ref:n,maxLength:t,...r,children:[e.jsx(m,{children:Array.from({length:a},(c,s)=>e.jsx(d,{index:s},s))}),e.jsx(x,{}),e.jsx(m,{children:Array.from({length:o},(c,s)=>e.jsx(d,{index:s+a},s+a))})]})});S.displayName="InputOTPSimple";const y=i.forwardRef(({maxLength:t=6,...r},n)=>{const o=Math.ceil(t/2);return e.jsx(p,{ref:n,maxLength:t,...r,children:Array.from({length:o},(c,s)=>{const u=s*2,O=Math.min(u+2,t)-u;return e.jsxs(i.Fragment,{children:[s>0&&e.jsx(x,{}),e.jsx(m,{children:Array.from({length:O},(G,T)=>e.jsx(d,{index:u+T},u+T))})]},s)})})});y.displayName="InputOTPWithSeparator";Object.defineProperty(exports,"REGEXP_ONLY_CHARS",{enumerable:!0,get:()=>l.REGEXP_ONLY_CHARS});Object.defineProperty(exports,"REGEXP_ONLY_DIGITS",{enumerable:!0,get:()=>l.REGEXP_ONLY_DIGITS});Object.defineProperty(exports,"REGEXP_ONLY_DIGITS_AND_CHARS",{enumerable:!0,get:()=>l.REGEXP_ONLY_DIGITS_AND_CHARS});exports.InputOTP=P;exports.InputOTPDigitsOnly=g;exports.InputOTPField=p;exports.InputOTPGroup=m;exports.InputOTPLabel=j;exports.InputOTPSeparator=x;exports.InputOTPSimple=S;exports.InputOTPSlot=d;exports.InputOTPWithSeparator=y;exports.InputOTPWithSpacing=b;