@brightlocal/ui-components 0.2.0 → 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.
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts +10 -1
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +6 -2
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +6 -2
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +89 -73
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.d.ts +49 -25
- package/dist/centred-layout.d.ts.map +1 -1
- package/dist/centred-layout.js +57 -32
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/chip.cjs +1 -0
- package/dist/chip.d.ts +61 -0
- package/dist/chip.d.ts.map +1 -0
- package/dist/chip.js +165 -0
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +5 -2
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts +89 -52
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +228 -210
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/header.cjs +1 -0
- package/dist/header.d.ts +42 -0
- package/dist/header.d.ts.map +1 -0
- package/dist/header.js +22 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +426 -396
- package/dist/input-chip.cjs +1 -0
- package/dist/input-chip.d.ts +117 -0
- package/dist/input-chip.d.ts.map +1 -0
- package/dist/input-chip.js +284 -0
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.d.ts +43 -36
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input-otp.js +140 -119
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +147 -19
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +197 -92
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +10 -0
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +45 -36
- package/dist/select.d.ts.map +1 -1
- package/dist/slider.cjs +1 -1
- package/dist/slider.d.ts +31 -3
- package/dist/slider.d.ts.map +1 -1
- package/dist/slider.js +53 -43
- package/dist/textarea.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/alert.tsx +10 -1
- package/src/components/card.tsx +66 -38
- package/src/components/centred-layout.tsx +115 -38
- package/src/components/checkbox.tsx +2 -2
- package/src/components/chip.tsx +249 -0
- package/src/components/combobox.tsx +17 -13
- package/src/components/date-picker.tsx +410 -266
- package/src/components/dropdown-menu.tsx +6 -1
- package/src/components/header.tsx +69 -0
- package/src/components/input-chip.tsx +548 -0
- package/src/components/input-group.tsx +4 -1
- package/src/components/input-otp.tsx +159 -91
- package/src/components/input-password.tsx +469 -129
- package/src/components/input.tsx +1 -1
- package/src/components/progress.tsx +21 -2
- package/src/components/select.tsx +1 -3
- package/src/components/slider.tsx +85 -15
- package/src/components/textarea.tsx +4 -1
- 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,CA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BACf,SACE,IAAI,CAAC,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
|
-
{"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,EAAE,MAAM,SAAS,CAAC;AAEjD,QAAA,MAAM,kBAAkB;;;8EAsBvB,CAAC;AAEF,UAAU,eACR,SACE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EACpC,YAAY,CAAC,OAAO,kBAAkB,CAAC;IACzC;;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,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,UAAU,
|
|
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,EAAE,MAAM,SAAS,CAAC;AAEjD,QAAA,MAAM,kBAAkB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|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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;
|
package/dist/input-otp.d.ts
CHANGED
|
@@ -1,51 +1,58 @@
|
|
|
1
1
|
import { OTPInput, REGEXP_ONLY_DIGITS, REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS_AND_CHARS } from 'input-otp';
|
|
2
|
+
import { Label } from '../label';
|
|
2
3
|
import * as React from "react";
|
|
3
|
-
|
|
4
|
+
interface InputOTPProps extends Omit<React.ComponentProps<typeof OTPInput>, "render"> {
|
|
5
|
+
/** Custom class for the container element */
|
|
4
6
|
containerClassName?: string;
|
|
5
|
-
|
|
7
|
+
/** Data hook for automated testing (REQUIRED) */
|
|
6
8
|
dataHook: string;
|
|
9
|
+
/** Tracking element identifier for analytics */
|
|
10
|
+
trackingEl?: string;
|
|
11
|
+
/** Tracking label for analytics context */
|
|
7
12
|
trackingLabel?: string;
|
|
8
13
|
/** Whether the input has an error state */
|
|
9
14
|
error?: boolean;
|
|
10
|
-
|
|
15
|
+
/** Children components */
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
declare const InputOTP: React.ForwardRefExoticComponent<Omit<InputOTPProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
11
19
|
type InputOTPGroupProps = React.ComponentProps<"div">;
|
|
12
|
-
|
|
20
|
+
declare function InputOTPGroup({ className, ...props }: InputOTPGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
interface InputOTPSlotProps extends React.ComponentProps<"div"> {
|
|
22
|
+
/** The index of the slot in the OTP input */
|
|
13
23
|
index: number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
}
|
|
25
|
+
declare function InputOTPSlot({ index, className, ...props }: InputOTPSlotProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
type InputOTPSeparatorProps = React.ComponentProps<"div">;
|
|
27
|
+
declare function InputOTPSeparator({ ...props }: InputOTPSeparatorProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
interface InputOTPLabelProps extends React.ComponentProps<typeof Label> {
|
|
29
|
+
/** Data hook for automated testing */
|
|
30
|
+
dataHook?: string;
|
|
31
|
+
}
|
|
32
|
+
declare function InputOTPLabel({ dataHook, className, ...props }: InputOTPLabelProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
interface InputOTPFieldProps extends Omit<InputOTPProps, "children"> {
|
|
34
|
+
/** Label text */
|
|
17
35
|
label?: string;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
children?: React.ReactNode;
|
|
22
|
-
maxLength: number;
|
|
23
|
-
containerClassName?: string;
|
|
24
|
-
inputMode?: "numeric" | "text" | "none" | "tel" | "url" | "email" | "decimal";
|
|
25
|
-
pasteTransformer?: (p: string) => string;
|
|
26
|
-
pattern?: string;
|
|
27
|
-
disabled?: boolean;
|
|
28
|
-
className?: string;
|
|
36
|
+
/** Custom ID for the input */
|
|
37
|
+
id?: string;
|
|
38
|
+
/** Accessible label when no visible label is provided */
|
|
29
39
|
"aria-label"?: string;
|
|
30
|
-
/**
|
|
31
|
-
|
|
40
|
+
/** Children components */
|
|
41
|
+
children: React.ReactNode;
|
|
32
42
|
}
|
|
33
|
-
|
|
43
|
+
declare const InputOTPField: React.ForwardRefExoticComponent<Omit<InputOTPFieldProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
44
|
+
interface InputOTPVariantProps extends Omit<InputOTPFieldProps, "children" | "maxLength"> {
|
|
45
|
+
/** Number of OTP digits */
|
|
34
46
|
maxLength?: number;
|
|
35
|
-
dataHook: string;
|
|
36
|
-
trackingEl?: string;
|
|
37
|
-
trackingLabel?: string;
|
|
38
|
-
disabled?: boolean;
|
|
39
|
-
autoFocus?: boolean;
|
|
40
|
-
pattern?: string;
|
|
41
|
-
"aria-label"?: string;
|
|
42
|
-
/** Whether the input has an error state */
|
|
43
|
-
error?: boolean;
|
|
44
47
|
}
|
|
45
|
-
|
|
46
|
-
declare const
|
|
47
|
-
|
|
48
|
-
declare const
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
/** Digits only OTP input with single group */
|
|
49
|
+
declare const InputOTPDigitsOnly: React.ForwardRefExoticComponent<Omit<InputOTPVariantProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
50
|
+
/** OTP input with spacing between slots */
|
|
51
|
+
declare const InputOTPWithSpacing: React.ForwardRefExoticComponent<Omit<InputOTPVariantProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
52
|
+
/** OTP input with two groups and a separator */
|
|
53
|
+
declare const InputOTPSimple: React.ForwardRefExoticComponent<Omit<InputOTPVariantProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
54
|
+
/** OTP input with separators between each pair of digits */
|
|
55
|
+
declare const InputOTPWithSeparator: React.ForwardRefExoticComponent<Omit<InputOTPVariantProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
56
|
+
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator, InputOTPLabel, InputOTPField, InputOTPDigitsOnly, InputOTPWithSpacing, InputOTPSimple, InputOTPWithSeparator, REGEXP_ONLY_DIGITS, REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS_AND_CHARS, };
|
|
57
|
+
export type { InputOTPProps, InputOTPGroupProps, InputOTPSlotProps, InputOTPSeparatorProps, InputOTPLabelProps, InputOTPFieldProps, InputOTPVariantProps, };
|
|
51
58
|
//# sourceMappingURL=input-otp.d.ts.map
|
package/dist/input-otp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-otp.d.ts","sourceRoot":"","sources":["../../src/components/input-otp.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,QAAQ,EAGR,kBAAkB,EAClB,iBAAiB,EACjB,4BAA4B,EAC7B,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"input-otp.d.ts","sourceRoot":"","sources":["../../src/components/input-otp.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,QAAQ,EAGR,kBAAkB,EAClB,iBAAiB,EACjB,4BAA4B,EAC7B,MAAM,WAAW,CAAC;AAInB,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAyBzD,UAAU,aAAc,SAAQ,IAAI,CAClC,KAAK,CAAC,cAAc,CAAC,OAAO,QAAQ,CAAC,EACrC,QAAQ,CACT;IACC,6CAA6C;IAC7C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,0BAA0B;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,QAAA,MAAM,QAAQ,qGAyCb,CAAC;AA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