@brightlocal/ui-components 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/component-meta.json +10 -11
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts +105 -42
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +180 -157
- package/dist/index.cjs +1 -1
- package/dist/index.js +128 -124
- package/dist/list.cjs +1 -1
- package/dist/list.d.ts +5 -0
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +62 -60
- package/dist/text-reveal-motion.cjs +1 -1
- package/dist/text-reveal-motion.d.ts.map +1 -1
- package/dist/text-reveal-motion.js +259 -185
- package/package.json +1 -1
- package/src/blocks/input-list.tsx +342 -202
- package/src/components/list.tsx +32 -21
- package/src/components/text-reveal-motion.tsx +246 -82
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ pnpm add @brightlocal/tokens
|
|
|
24
24
|
|
|
25
25
|
## Components
|
|
26
26
|
|
|
27
|
-
This package includes 62 components built on Radix UI primitives and other React libraries. All components are fully typed with TypeScript and follow BrightLocal's design system patterns.
|
|
27
|
+
This package includes 62 components and 3 blocks built on Radix UI primitives and other React libraries. All components are fully typed with TypeScript and follow BrightLocal's design system patterns.
|
|
28
28
|
|
|
29
29
|
### Layout Components
|
|
30
30
|
|
|
@@ -89,6 +89,12 @@ This package includes 62 components built on Radix UI primitives and other React
|
|
|
89
89
|
- **Progress** - Progress indicators
|
|
90
90
|
- **Sonner** - Toast notifications
|
|
91
91
|
|
|
92
|
+
### Block Components
|
|
93
|
+
|
|
94
|
+
- **DataTable** - Complex data table with sorting, filtering, and pagination
|
|
95
|
+
- **InputList** - Editable list of text items with add/remove, paste support, and validation
|
|
96
|
+
- **Sidebar** - Complex sidebar navigation with collapsible support
|
|
97
|
+
|
|
92
98
|
### Display Components
|
|
93
99
|
|
|
94
100
|
- **Accordion** - Expandable/collapsible sections
|
package/component-meta.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightlocal/ui-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Machine-readable registry of all components in the BrightLocal Design System",
|
|
5
5
|
"components": [
|
|
6
6
|
{
|
|
@@ -1426,23 +1426,22 @@
|
|
|
1426
1426
|
"import": "@brightlocal/ui-components/blocks/input-list",
|
|
1427
1427
|
"category": "block",
|
|
1428
1428
|
"exports": [
|
|
1429
|
-
"InputList"
|
|
1429
|
+
"InputList",
|
|
1430
|
+
"InputListItems",
|
|
1431
|
+
"InputListInput",
|
|
1432
|
+
"InputListAddButton",
|
|
1433
|
+
"useInputListContext"
|
|
1430
1434
|
],
|
|
1431
|
-
"compound":
|
|
1435
|
+
"compound": true,
|
|
1432
1436
|
"dataHookRequired": true,
|
|
1433
1437
|
"variants": {},
|
|
1434
1438
|
"props": [
|
|
1435
1439
|
"value",
|
|
1436
1440
|
"onValueChange",
|
|
1437
|
-
"
|
|
1438
|
-
"
|
|
1439
|
-
"loading",
|
|
1440
|
-
"disabled",
|
|
1441
|
-
"error",
|
|
1442
|
-
"errorMessage",
|
|
1443
|
-
"description"
|
|
1441
|
+
"children",
|
|
1442
|
+
"className"
|
|
1444
1443
|
],
|
|
1445
|
-
"description": "Editable list of text items with add/remove"
|
|
1444
|
+
"description": "Editable list of text items with add/remove, paste support, and validation"
|
|
1446
1445
|
},
|
|
1447
1446
|
{
|
|
1448
1447
|
"name": "Sidebar",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`);
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),_=require("react"),k=require("framer-motion"),K=require("@brightlocal/icons"),x=require("@brightlocal/ui-components/lib/utils"),O=require("../button.cjs"),$=require("../input.cjs"),g=require("../list.cjs");function B(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const o=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(s,a,o.get?o:{enumerable:!0,get:()=>t[a]})}}return s.default=t,Object.freeze(s)}const r=B(_),A=r.createContext(null);function y(){const t=r.useContext(A);if(!t)throw new Error("InputList components must be used within an <InputList>");return t}function w({value:t,onValueChange:s,children:a,className:o,dataHook:c,trackingEl:u,trackingLabel:I}){const[m,d]=r.useState(""),l=r.useRef(t.length),i=r.useRef(t.length),[b,h]=r.useState(()=>t.map((p,n)=>n)),[N,q]=r.useState(0);r.useEffect(()=>{const p=l.current;l.current=t.length,t.length>p&&d(""),h(n=>n.length===t.length?n:t.length>n.length?[...n,...Array.from({length:t.length-n.length},()=>i.current++)]:t.length===p?n.slice(0,t.length):t.map(()=>i.current++))},[t,N]);const j=r.useCallback(p=>{const n=p.map(f=>f.trim()).filter(Boolean);n.length&&(h(f=>[...f,...n.map(()=>i.current++)]),s([...t,...n]),q(f=>f+1))},[t,s]),L=r.useCallback(p=>{h(n=>n.filter((f,S)=>S!==p)),s(t.filter((n,f)=>f!==p))},[t,s]),P=r.useMemo(()=>({value:t,inputValue:m,setInputValue:d,addItems:j,removeItem:L,stableKeys:b}),[t,m,j,L,b]);return e.jsx(A.Provider,{value:P,children:e.jsx("div",{className:x.cn("flex flex-col gap-4",o),"data-hook":c,"data-slot":"input-list","data-tracking-el":u,"data-tracking-label":I,children:a})})}w.displayName="InputList";function C({dataHook:t="input-list",loading:s=!1,skeletonCount:a=5,disabled:o=!1,className:c}){const{value:u,removeItem:I,stableKeys:m}=y();return s?e.jsx("ul",{className:x.cn("flex flex-col gap-2",c),"data-slot":"input-list-skeleton",children:Array.from({length:a}).map((d,l)=>e.jsx(g.Item,{variant:"loading"},l))}):e.jsx("ul",{className:x.cn("flex flex-col gap-2",c),"data-hook":`${t}-list`,"data-slot":"list",children:e.jsx(k.AnimatePresence,{initial:!1,children:u.map((d,l)=>e.jsx(k.motion.li,{layout:!0,animate:{opacity:1,scale:1},"data-hook":`${t}-item-${l}`,exit:{opacity:0,scale:.8,transition:{opacity:{duration:.15},scale:{duration:.12}}},initial:{opacity:0,scale:.8},transition:{opacity:{duration:.15},scale:{duration:.15},layout:{type:"spring",stiffness:500,damping:35}},children:e.jsx(g.Item,{asChild:!0,variant:"filled",children:e.jsxs("div",{children:[e.jsx(g.ItemContent,{children:e.jsx(g.ItemTitle,{children:d})}),e.jsx(g.ItemActions,{children:e.jsx("button",{"aria-label":`Remove ${d}`,className:x.cn("inline-flex size-9 cursor-pointer items-center justify-center rounded-full","text-muted-foreground","focus-visible:shadow-default outline-none","transition-colors duration-150 ease-in-out","disabled:pointer-events-none disabled:opacity-50"),"data-hook":`${t}-remove-${l}`,disabled:o,type:"button",onClick:()=>I(l),children:e.jsx(K.X,{})})})]})})},m[l]))})})}C.displayName="InputListItems";const R=r.forwardRef(({dataHook:t,error:s=!1,className:a,...o},c)=>{const{inputValue:u,setInputValue:I,addItems:m}=y(),d=i=>{i.key==="Enter"&&(i.preventDefault(),m([u])),o.onKeyDown?.(i)},l=i=>{const h=i.clipboardData.getData("text").split(`
|
|
2
|
+
`);h.length>1&&(i.preventDefault(),m(h)),o.onPaste?.(i)};return e.jsx($.Input,{ref:c,...o,className:x.cn("flex-1",a),dataHook:t,error:s,value:u,onChange:i=>{I(i.target.value),o.onChange?.(i)},onKeyDown:d,onPaste:l})});R.displayName="InputListInput";const D=r.forwardRef(({dataHook:t,children:s,...a},o)=>{const{inputValue:c,addItems:u}=y();return e.jsx(O.Button,{ref:o,...a,dataHook:t,onClick:()=>u([c]),children:s})});D.displayName="InputListAddButton";exports.InputList=w;exports.InputListAddButton=D;exports.InputListInput=R;exports.InputListItems=C;exports.useInputListContext=y;
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
import { ButtonProps } from '../button';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
interface InputListContextValue {
|
|
4
|
+
value: string[];
|
|
5
|
+
inputValue: string;
|
|
6
|
+
setInputValue: (value: string) => void;
|
|
7
|
+
addItems: (items: string[]) => void;
|
|
8
|
+
removeItem: (index: number) => void;
|
|
9
|
+
/** Stable keys for AnimatePresence tracking */
|
|
10
|
+
stableKeys: number[];
|
|
11
|
+
}
|
|
12
|
+
declare function useInputListContext(): InputListContextValue;
|
|
1
13
|
/**
|
|
2
|
-
* Props for the InputList
|
|
3
|
-
* Manages a list of text items with add
|
|
14
|
+
* Props for the InputList context provider.
|
|
15
|
+
* Manages a list of text items with add/remove logic and validation.
|
|
4
16
|
*/
|
|
5
17
|
export interface InputListProps {
|
|
6
18
|
/**
|
|
@@ -12,75 +24,126 @@ export interface InputListProps {
|
|
|
12
24
|
*/
|
|
13
25
|
onValueChange: (value: string[]) => void;
|
|
14
26
|
/**
|
|
15
|
-
*
|
|
16
|
-
* @default "Add item"
|
|
27
|
+
* Children — compose with InputListItems and InputListInput.
|
|
17
28
|
*/
|
|
18
|
-
|
|
29
|
+
children: React.ReactNode;
|
|
19
30
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @default "Add"
|
|
31
|
+
* Additional CSS classes applied to the root element.
|
|
22
32
|
*/
|
|
23
|
-
|
|
33
|
+
className?: string;
|
|
24
34
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @default 3
|
|
35
|
+
* Data hook for automated testing (required).
|
|
27
36
|
*/
|
|
28
|
-
|
|
37
|
+
dataHook: string;
|
|
29
38
|
/**
|
|
30
|
-
*
|
|
39
|
+
* Tracking element identifier for analytics.
|
|
31
40
|
*/
|
|
32
|
-
|
|
41
|
+
trackingEl?: string;
|
|
33
42
|
/**
|
|
34
|
-
*
|
|
43
|
+
* Tracking label for analytics context.
|
|
35
44
|
*/
|
|
36
|
-
|
|
45
|
+
trackingLabel?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* InputList context provider — manages state for a list of text items
|
|
49
|
+
* with add, remove, paste, and validation support.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* <InputList value={keywords} onValueChange={setKeywords} dataHook="keywords">
|
|
54
|
+
* <InputListItems />
|
|
55
|
+
* <InputListInput placeholder="Add keyword" />
|
|
56
|
+
* </InputList>
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
declare function InputList({ value, onValueChange, children, className, dataHook, trackingEl, trackingLabel, }: InputListProps): import("react/jsx-runtime").JSX.Element;
|
|
60
|
+
declare namespace InputList {
|
|
61
|
+
var displayName: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Props for the InputListItems sub-component.
|
|
65
|
+
*/
|
|
66
|
+
export interface InputListItemsProps {
|
|
37
67
|
/**
|
|
38
|
-
*
|
|
68
|
+
* Data hook prefix for item elements.
|
|
69
|
+
* @default "input-list"
|
|
39
70
|
*/
|
|
40
|
-
|
|
71
|
+
dataHook?: string;
|
|
41
72
|
/**
|
|
42
|
-
*
|
|
73
|
+
* Shows skeleton placeholder rows instead of the item list.
|
|
43
74
|
*/
|
|
44
|
-
|
|
75
|
+
loading?: boolean;
|
|
45
76
|
/**
|
|
46
|
-
*
|
|
77
|
+
* Number of skeleton rows to render in the loading state.
|
|
78
|
+
* @default 5
|
|
47
79
|
*/
|
|
48
|
-
|
|
80
|
+
skeletonCount?: number;
|
|
49
81
|
/**
|
|
50
|
-
*
|
|
82
|
+
* Disables all remove buttons in the list.
|
|
51
83
|
*/
|
|
52
|
-
|
|
84
|
+
disabled?: boolean;
|
|
53
85
|
/**
|
|
54
|
-
*
|
|
86
|
+
* Additional CSS classes applied to the list element.
|
|
55
87
|
*/
|
|
56
|
-
|
|
88
|
+
className?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Renders the animated item list or loading skeletons.
|
|
92
|
+
* Must be used within an `<InputList>` component.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```tsx
|
|
96
|
+
* <InputList value={items} onValueChange={setItems} dataHook="my-list">
|
|
97
|
+
* <InputListItems skeletonCount={5} />
|
|
98
|
+
* <InputListInput placeholder="Add item" />
|
|
99
|
+
* </InputList>
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
declare function InputListItems({ dataHook, loading, skeletonCount, disabled, className, }: InputListItemsProps): import("react/jsx-runtime").JSX.Element;
|
|
103
|
+
declare namespace InputListItems {
|
|
104
|
+
var displayName: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Props for the InputListInput sub-component.
|
|
108
|
+
*
|
|
109
|
+
* Inherits native input props except `value` and `type` (managed by InputList context).
|
|
110
|
+
* `onChange` fires as a notification only — the input value is controlled by context,
|
|
111
|
+
* so it cannot be used to filter or transform input.
|
|
112
|
+
*/
|
|
113
|
+
export interface InputListInputProps extends Omit<React.ComponentPropsWithoutRef<"input">, "value" | "type"> {
|
|
57
114
|
/**
|
|
58
|
-
*
|
|
115
|
+
* Data hook for the input element.
|
|
59
116
|
*/
|
|
60
|
-
|
|
117
|
+
dataHook: string;
|
|
61
118
|
/**
|
|
62
|
-
*
|
|
119
|
+
* Applies an error style to the input.
|
|
63
120
|
*/
|
|
64
|
-
|
|
121
|
+
error?: boolean;
|
|
65
122
|
}
|
|
66
123
|
/**
|
|
67
|
-
*
|
|
124
|
+
* Text input that adds items on Enter and supports multi-line paste.
|
|
125
|
+
* Must be used within an `<InputList>` component.
|
|
68
126
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```tsx
|
|
129
|
+
* <InputListInput dataHook="keywords-input" placeholder="Add keyword" />
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
declare const InputListInput: React.ForwardRefExoticComponent<InputListInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
133
|
+
/**
|
|
134
|
+
* Props for the InputListAddButton sub-component.
|
|
135
|
+
* Inherits all Button props except `onClick` (wired internally to add items).
|
|
136
|
+
*/
|
|
137
|
+
export type InputListAddButtonProps = Omit<ButtonProps, "onClick">;
|
|
138
|
+
/**
|
|
139
|
+
* Button that adds the current input value to the list.
|
|
140
|
+
* Must be used within an `<InputList>` component.
|
|
71
141
|
*
|
|
72
142
|
* @example
|
|
73
143
|
* ```tsx
|
|
74
|
-
* <
|
|
75
|
-
* value={keywords}
|
|
76
|
-
* onValueChange={setKeywords}
|
|
77
|
-
* dataHook="keywords"
|
|
78
|
-
* />
|
|
144
|
+
* <InputListAddButton dataHook="keywords-add">Add</InputListAddButton>
|
|
79
145
|
* ```
|
|
80
146
|
*/
|
|
81
|
-
declare
|
|
82
|
-
|
|
83
|
-
var displayName: string;
|
|
84
|
-
}
|
|
85
|
-
export { InputList };
|
|
147
|
+
declare const InputListAddButton: React.ForwardRefExoticComponent<Omit<InputListAddButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
148
|
+
export { InputList, InputListItems, InputListInput, InputListAddButton, useInputListContext, };
|
|
86
149
|
//# sourceMappingURL=input-list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-list.d.ts","sourceRoot":"","sources":["../../src/blocks/input-list.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"input-list.d.ts","sourceRoot":"","sources":["../../src/blocks/input-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAQhE,UAAU,qBAAqB;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACpC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,+CAA+C;IAC/C,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAMD,iBAAS,mBAAmB,0BAM3B;AAMD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;OAEG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACzC;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;GAWG;AACH,iBAAS,SAAS,CAAC,EACjB,KAAK,EACL,aAAa,EACb,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,UAAU,EACV,aAAa,GACd,EAAE,cAAc,2CA6FhB;kBArGQ,SAAS;;;AA6GlB;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,iBAAS,cAAc,CAAC,EACtB,QAAuB,EACvB,OAAe,EACf,aAAiB,EACjB,QAAgB,EAChB,SAAS,GACV,EAAE,mBAAmB,2CA8ErB;kBApFQ,cAAc;;;AA4FvB;;;;;;GAMG;AACH,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAC/C,KAAK,CAAC,wBAAwB,CAAC,OAAO,CAAC,EACvC,OAAO,GAAG,MAAM,CACjB;IACC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,QAAA,MAAM,cAAc,8FAuCnB,CAAC;AAOF;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AAEnE;;;;;;;;GAQG;AACH,QAAA,MAAM,kBAAkB,gHAgBtB,CAAC;AAOH,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,mBAAmB,GACpB,CAAC"}
|
|
@@ -1,176 +1,199 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as n, jsxs as D } from "react/jsx-runtime";
|
|
2
2
|
import * as s from "react";
|
|
3
|
-
import { AnimatePresence as
|
|
4
|
-
import { X as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { Button as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
import { AnimatePresence as K, motion as $ } from "framer-motion";
|
|
4
|
+
import { X as P } from "@brightlocal/icons";
|
|
5
|
+
import { cn as g } from "@brightlocal/ui-components/lib/utils";
|
|
6
|
+
import { Button as B } from "../button.js";
|
|
7
|
+
import { Input as S } from "../input.js";
|
|
8
|
+
import { Item as k, ItemContent as V, ItemTitle as _, ItemActions as j } from "../list.js";
|
|
9
|
+
const A = s.createContext(
|
|
10
|
+
null
|
|
11
|
+
);
|
|
12
|
+
function x() {
|
|
13
|
+
const t = s.useContext(A);
|
|
14
|
+
if (!t)
|
|
15
|
+
throw new Error("InputList components must be used within an <InputList>");
|
|
16
|
+
return t;
|
|
17
|
+
}
|
|
18
|
+
function E({
|
|
19
|
+
value: t,
|
|
20
|
+
onValueChange: a,
|
|
21
|
+
children: f,
|
|
22
|
+
className: r,
|
|
21
23
|
dataHook: l,
|
|
22
|
-
trackingEl:
|
|
23
|
-
trackingLabel:
|
|
24
|
-
className: A
|
|
24
|
+
trackingEl: c,
|
|
25
|
+
trackingLabel: I
|
|
25
26
|
}) {
|
|
26
|
-
const [
|
|
27
|
-
() =>
|
|
28
|
-
);
|
|
27
|
+
const [p, u] = s.useState(""), o = s.useRef(t.length), i = s.useRef(t.length), [y, h] = s.useState(
|
|
28
|
+
() => t.map((d, e) => e)
|
|
29
|
+
), [w, C] = s.useState(0);
|
|
29
30
|
s.useEffect(() => {
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
const d = o.current;
|
|
32
|
+
o.current = t.length, t.length > d && u(""), h((e) => e.length === t.length ? e : t.length > e.length ? [
|
|
33
|
+
...e,
|
|
32
34
|
...Array.from(
|
|
33
|
-
{ length:
|
|
34
|
-
() =>
|
|
35
|
+
{ length: t.length - e.length },
|
|
36
|
+
() => i.current++
|
|
35
37
|
)
|
|
36
|
-
] :
|
|
37
|
-
}, [
|
|
38
|
-
const
|
|
39
|
-
(
|
|
40
|
-
const e =
|
|
41
|
-
e.length && (
|
|
42
|
-
...
|
|
43
|
-
...e.map(() =>
|
|
44
|
-
]),
|
|
38
|
+
] : t.length === d ? e.slice(0, t.length) : t.map(() => i.current++));
|
|
39
|
+
}, [t, w]);
|
|
40
|
+
const b = s.useCallback(
|
|
41
|
+
(d) => {
|
|
42
|
+
const e = d.map((m) => m.trim()).filter(Boolean);
|
|
43
|
+
e.length && (h((m) => [
|
|
44
|
+
...m,
|
|
45
|
+
...e.map(() => i.current++)
|
|
46
|
+
]), a([...t, ...e]), C((m) => m + 1));
|
|
45
47
|
},
|
|
46
|
-
[
|
|
47
|
-
),
|
|
48
|
-
(
|
|
49
|
-
|
|
48
|
+
[t, a]
|
|
49
|
+
), L = s.useCallback(
|
|
50
|
+
(d) => {
|
|
51
|
+
h((e) => e.filter((m, R) => R !== d)), a(t.filter((e, m) => m !== d));
|
|
50
52
|
},
|
|
51
|
-
[
|
|
52
|
-
),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
[t, a]
|
|
54
|
+
), N = s.useMemo(
|
|
55
|
+
() => ({
|
|
56
|
+
value: t,
|
|
57
|
+
inputValue: p,
|
|
58
|
+
setInputValue: u,
|
|
59
|
+
addItems: b,
|
|
60
|
+
removeItem: L,
|
|
61
|
+
stableKeys: y
|
|
62
|
+
}),
|
|
63
|
+
[t, p, b, L, y]
|
|
64
|
+
);
|
|
65
|
+
return /* @__PURE__ */ n(A.Provider, { value: N, children: /* @__PURE__ */ n(
|
|
60
66
|
"div",
|
|
61
67
|
{
|
|
62
|
-
className:
|
|
68
|
+
className: g("flex flex-col gap-4", r),
|
|
63
69
|
"data-hook": l,
|
|
64
70
|
"data-slot": "input-list",
|
|
65
|
-
"data-tracking-el":
|
|
66
|
-
"data-tracking-label":
|
|
67
|
-
children:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
className: b(
|
|
106
|
-
"inline-flex size-9 cursor-pointer items-center justify-center rounded-full",
|
|
107
|
-
"text-muted-foreground",
|
|
108
|
-
"focus-visible:shadow-default outline-none",
|
|
109
|
-
"transition-colors duration-150 ease-in-out",
|
|
110
|
-
"disabled:pointer-events-none disabled:opacity-50"
|
|
111
|
-
),
|
|
112
|
-
"data-hook": `${l}-remove-${e}`,
|
|
113
|
-
disabled: c,
|
|
114
|
-
type: "button",
|
|
115
|
-
onClick: () => j(e),
|
|
116
|
-
children: /* @__PURE__ */ a(B, {})
|
|
117
|
-
}
|
|
118
|
-
) })
|
|
119
|
-
] })
|
|
120
|
-
},
|
|
121
|
-
K[e]
|
|
122
|
-
)) })
|
|
123
|
-
}
|
|
124
|
-
),
|
|
125
|
-
/* @__PURE__ */ r("div", { className: "flex flex-col gap-2", "data-slot": "input-list-input-area", children: [
|
|
126
|
-
/* @__PURE__ */ r("div", { className: "flex gap-2", children: [
|
|
127
|
-
/* @__PURE__ */ a(
|
|
128
|
-
T,
|
|
129
|
-
{
|
|
130
|
-
className: "flex-1",
|
|
131
|
-
dataHook: `${l}-input`,
|
|
132
|
-
disabled: R,
|
|
133
|
-
error: h,
|
|
134
|
-
placeholder: I,
|
|
135
|
-
value: m,
|
|
136
|
-
onChange: (t) => x(t.target.value),
|
|
137
|
-
onKeyDown: w,
|
|
138
|
-
onPaste: C
|
|
139
|
-
}
|
|
140
|
-
),
|
|
141
|
-
/* @__PURE__ */ a(
|
|
142
|
-
F,
|
|
143
|
-
{
|
|
144
|
-
dataHook: `${l}-add`,
|
|
145
|
-
disabled: _,
|
|
146
|
-
onClick: () => u([m]),
|
|
147
|
-
children: N
|
|
148
|
-
}
|
|
149
|
-
)
|
|
150
|
-
] }),
|
|
151
|
-
h && g ? /* @__PURE__ */ a(
|
|
152
|
-
L,
|
|
153
|
-
{
|
|
154
|
-
className: "text-left",
|
|
155
|
-
"data-slot": "input-list-error",
|
|
156
|
-
dataHook: `${l}-error`,
|
|
157
|
-
children: g
|
|
71
|
+
"data-tracking-el": c,
|
|
72
|
+
"data-tracking-label": I,
|
|
73
|
+
children: f
|
|
74
|
+
}
|
|
75
|
+
) });
|
|
76
|
+
}
|
|
77
|
+
E.displayName = "InputList";
|
|
78
|
+
function z({
|
|
79
|
+
dataHook: t = "input-list",
|
|
80
|
+
loading: a = !1,
|
|
81
|
+
skeletonCount: f = 5,
|
|
82
|
+
disabled: r = !1,
|
|
83
|
+
className: l
|
|
84
|
+
}) {
|
|
85
|
+
const { value: c, removeItem: I, stableKeys: p } = x();
|
|
86
|
+
return a ? /* @__PURE__ */ n(
|
|
87
|
+
"ul",
|
|
88
|
+
{
|
|
89
|
+
className: g("flex flex-col gap-2", l),
|
|
90
|
+
"data-slot": "input-list-skeleton",
|
|
91
|
+
children: Array.from({ length: f }).map((u, o) => /* @__PURE__ */ n(k, { variant: "loading" }, o))
|
|
92
|
+
}
|
|
93
|
+
) : /* @__PURE__ */ n(
|
|
94
|
+
"ul",
|
|
95
|
+
{
|
|
96
|
+
className: g("flex flex-col gap-2", l),
|
|
97
|
+
"data-hook": `${t}-list`,
|
|
98
|
+
"data-slot": "list",
|
|
99
|
+
children: /* @__PURE__ */ n(K, { initial: !1, children: c.map((u, o) => /* @__PURE__ */ n(
|
|
100
|
+
$.li,
|
|
101
|
+
{
|
|
102
|
+
layout: !0,
|
|
103
|
+
animate: { opacity: 1, scale: 1 },
|
|
104
|
+
"data-hook": `${t}-item-${o}`,
|
|
105
|
+
exit: {
|
|
106
|
+
opacity: 0,
|
|
107
|
+
scale: 0.8,
|
|
108
|
+
transition: {
|
|
109
|
+
opacity: { duration: 0.15 },
|
|
110
|
+
scale: { duration: 0.12 }
|
|
158
111
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
112
|
+
},
|
|
113
|
+
initial: { opacity: 0, scale: 0.8 },
|
|
114
|
+
transition: {
|
|
115
|
+
opacity: { duration: 0.15 },
|
|
116
|
+
scale: { duration: 0.15 },
|
|
117
|
+
layout: {
|
|
118
|
+
type: "spring",
|
|
119
|
+
stiffness: 500,
|
|
120
|
+
damping: 35
|
|
166
121
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
122
|
+
},
|
|
123
|
+
children: /* @__PURE__ */ n(k, { asChild: !0, variant: "filled", children: /* @__PURE__ */ D("div", { children: [
|
|
124
|
+
/* @__PURE__ */ n(V, { children: /* @__PURE__ */ n(_, { children: u }) }),
|
|
125
|
+
/* @__PURE__ */ n(j, { children: /* @__PURE__ */ n(
|
|
126
|
+
"button",
|
|
127
|
+
{
|
|
128
|
+
"aria-label": `Remove ${u}`,
|
|
129
|
+
className: g(
|
|
130
|
+
"inline-flex size-9 cursor-pointer items-center justify-center rounded-full",
|
|
131
|
+
"text-muted-foreground",
|
|
132
|
+
"focus-visible:shadow-default outline-none",
|
|
133
|
+
"transition-colors duration-150 ease-in-out",
|
|
134
|
+
"disabled:pointer-events-none disabled:opacity-50"
|
|
135
|
+
),
|
|
136
|
+
"data-hook": `${t}-remove-${o}`,
|
|
137
|
+
disabled: r,
|
|
138
|
+
type: "button",
|
|
139
|
+
onClick: () => I(o),
|
|
140
|
+
children: /* @__PURE__ */ n(P, {})
|
|
141
|
+
}
|
|
142
|
+
) })
|
|
143
|
+
] }) })
|
|
144
|
+
},
|
|
145
|
+
p[o]
|
|
146
|
+
)) })
|
|
170
147
|
}
|
|
171
148
|
);
|
|
172
149
|
}
|
|
173
|
-
|
|
150
|
+
z.displayName = "InputListItems";
|
|
151
|
+
const M = s.forwardRef(
|
|
152
|
+
({ dataHook: t, error: a = !1, className: f, ...r }, l) => {
|
|
153
|
+
const { inputValue: c, setInputValue: I, addItems: p } = x(), u = (i) => {
|
|
154
|
+
i.key === "Enter" && (i.preventDefault(), p([c])), r.onKeyDown?.(i);
|
|
155
|
+
}, o = (i) => {
|
|
156
|
+
const h = i.clipboardData.getData("text").split(`
|
|
157
|
+
`);
|
|
158
|
+
h.length > 1 && (i.preventDefault(), p(h)), r.onPaste?.(i);
|
|
159
|
+
};
|
|
160
|
+
return /* @__PURE__ */ n(
|
|
161
|
+
S,
|
|
162
|
+
{
|
|
163
|
+
ref: l,
|
|
164
|
+
...r,
|
|
165
|
+
className: g("flex-1", f),
|
|
166
|
+
dataHook: t,
|
|
167
|
+
error: a,
|
|
168
|
+
value: c,
|
|
169
|
+
onChange: (i) => {
|
|
170
|
+
I(i.target.value), r.onChange?.(i);
|
|
171
|
+
},
|
|
172
|
+
onKeyDown: u,
|
|
173
|
+
onPaste: o
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
M.displayName = "InputListInput";
|
|
179
|
+
const T = s.forwardRef(({ dataHook: t, children: a, ...f }, r) => {
|
|
180
|
+
const { inputValue: l, addItems: c } = x();
|
|
181
|
+
return /* @__PURE__ */ n(
|
|
182
|
+
B,
|
|
183
|
+
{
|
|
184
|
+
ref: r,
|
|
185
|
+
...f,
|
|
186
|
+
dataHook: t,
|
|
187
|
+
onClick: () => c([l]),
|
|
188
|
+
children: a
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
});
|
|
192
|
+
T.displayName = "InputListAddButton";
|
|
174
193
|
export {
|
|
175
|
-
|
|
194
|
+
E as InputList,
|
|
195
|
+
T as InputListAddButton,
|
|
196
|
+
M as InputListInput,
|
|
197
|
+
z as InputListItems,
|
|
198
|
+
x as useInputListContext
|
|
176
199
|
};
|