@next-degree/pickle-shared-js 0.3.27 → 0.3.30
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/app/layout.css +30 -2
- package/dist/app/layout.css.map +1 -1
- package/dist/app/page.cjs +324 -114
- package/dist/app/page.cjs.map +1 -1
- package/dist/app/page.js +302 -92
- package/dist/app/page.js.map +1 -1
- package/dist/components/demos/ComboboxDemo.cjs +91 -52
- package/dist/components/demos/ComboboxDemo.cjs.map +1 -1
- package/dist/components/demos/ComboboxDemo.js +84 -45
- package/dist/components/demos/ComboboxDemo.js.map +1 -1
- package/dist/components/demos/CounterDemo.cjs +270 -0
- package/dist/components/demos/CounterDemo.cjs.map +1 -0
- package/dist/components/demos/CounterDemo.d.cts +5 -0
- package/dist/components/demos/CounterDemo.d.ts +5 -0
- package/dist/components/demos/CounterDemo.js +238 -0
- package/dist/components/demos/CounterDemo.js.map +1 -0
- package/dist/components/demos/InputDemo.cjs +74 -35
- package/dist/components/demos/InputDemo.cjs.map +1 -1
- package/dist/components/demos/InputDemo.js +59 -30
- package/dist/components/demos/InputDemo.js.map +1 -1
- package/dist/components/demos/SelectDemo.cjs +83 -53
- package/dist/components/demos/SelectDemo.cjs.map +1 -1
- package/dist/components/demos/SelectDemo.js +73 -43
- package/dist/components/demos/SelectDemo.js.map +1 -1
- package/dist/components/demos/index.cjs +322 -112
- package/dist/components/demos/index.cjs.map +1 -1
- package/dist/components/demos/index.js +300 -90
- package/dist/components/demos/index.js.map +1 -1
- package/dist/components/primitives/tooltip.cjs +75 -0
- package/dist/components/primitives/tooltip.cjs.map +1 -0
- package/dist/components/primitives/tooltip.d.cts +9 -0
- package/dist/components/primitives/tooltip.d.ts +9 -0
- package/dist/components/primitives/tooltip.js +38 -0
- package/dist/components/primitives/tooltip.js.map +1 -0
- package/dist/components/ui/Combobox.cjs +78 -40
- package/dist/components/ui/Combobox.cjs.map +1 -1
- package/dist/components/ui/Combobox.d.cts +5 -2
- package/dist/components/ui/Combobox.d.ts +5 -2
- package/dist/components/ui/Combobox.js +71 -33
- package/dist/components/ui/Combobox.js.map +1 -1
- package/dist/components/ui/Counter.cjs +248 -0
- package/dist/components/ui/Counter.cjs.map +1 -0
- package/dist/components/ui/Counter.d.cts +28 -0
- package/dist/components/ui/Counter.d.ts +28 -0
- package/dist/components/ui/Counter.js +214 -0
- package/dist/components/ui/Counter.js.map +1 -0
- package/dist/components/ui/Input.cjs +67 -28
- package/dist/components/ui/Input.cjs.map +1 -1
- package/dist/components/ui/Input.d.cts +2 -1
- package/dist/components/ui/Input.d.ts +2 -1
- package/dist/components/ui/Input.js +54 -25
- package/dist/components/ui/Input.js.map +1 -1
- package/dist/components/ui/Label.cjs +54 -16
- package/dist/components/ui/Label.cjs.map +1 -1
- package/dist/components/ui/Label.d.cts +2 -1
- package/dist/components/ui/Label.d.ts +2 -1
- package/dist/components/ui/Label.js +44 -16
- package/dist/components/ui/Label.js.map +1 -1
- package/dist/components/ui/Select.cjs +75 -46
- package/dist/components/ui/Select.cjs.map +1 -1
- package/dist/components/ui/Select.d.cts +3 -2
- package/dist/components/ui/Select.d.ts +3 -2
- package/dist/components/ui/Select.js +67 -38
- package/dist/components/ui/Select.js.map +1 -1
- package/dist/index.cjs +323 -138
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +295 -111
- package/dist/index.js.map +1 -1
- package/dist/styles/globals.css +30 -2
- package/dist/styles/globals.css.map +1 -1
- package/package.json +1 -1
|
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(SelectDemo_exports);
|
|
|
36
36
|
|
|
37
37
|
// src/components/ui/Select.tsx
|
|
38
38
|
var SelectPrimitive = __toESM(require("@radix-ui/react-select"), 1);
|
|
39
|
-
var
|
|
39
|
+
var import_lucide_react2 = require("lucide-react");
|
|
40
40
|
var import_react = require("react");
|
|
41
41
|
|
|
42
42
|
// src/lib/utils.ts
|
|
@@ -54,32 +54,60 @@ function ErrorMessage({ message, className, ...props }) {
|
|
|
54
54
|
}
|
|
55
55
|
var ErrorMessage_default = ErrorMessage;
|
|
56
56
|
|
|
57
|
-
// src/components/
|
|
57
|
+
// src/components/primitives/tooltip.tsx
|
|
58
|
+
var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"), 1);
|
|
59
|
+
var React = __toESM(require("react"), 1);
|
|
58
60
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
59
|
-
|
|
61
|
+
var TooltipProvider = TooltipPrimitive.Provider;
|
|
62
|
+
var Tooltip = TooltipPrimitive.Root;
|
|
63
|
+
var TooltipTrigger = TooltipPrimitive.Trigger;
|
|
64
|
+
var TooltipContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
65
|
+
TooltipPrimitive.Content,
|
|
66
|
+
{
|
|
67
|
+
ref,
|
|
68
|
+
sideOffset,
|
|
69
|
+
className: cn(
|
|
70
|
+
"z-50 overflow-hidden rounded-md border border-neutral-200 bg-white px-3 py-1.5 text-sm text-neutral-950 shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",
|
|
71
|
+
className
|
|
72
|
+
),
|
|
73
|
+
...props
|
|
74
|
+
}
|
|
75
|
+
));
|
|
76
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
77
|
+
|
|
78
|
+
// src/components/ui/Label.tsx
|
|
79
|
+
var import_lucide_react = require("lucide-react");
|
|
80
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
81
|
+
function Label({ text, required, description, className, ...props }) {
|
|
60
82
|
if (!text) return null;
|
|
61
|
-
return /* @__PURE__ */ (0,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
83
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex w-full flex-row gap-1", children: [
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
85
|
+
"label",
|
|
86
|
+
{
|
|
87
|
+
className: cn(
|
|
88
|
+
"text-xs text-grey-80 peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
89
|
+
className
|
|
90
|
+
),
|
|
91
|
+
...props,
|
|
92
|
+
children: [
|
|
93
|
+
text,
|
|
94
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-red-600", children: "\xA0*" })
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
!!description && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Tooltip, { children: [
|
|
99
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.InfoIcon, { className: "h-4 w-4" }) }),
|
|
100
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TooltipContent, { className: "max-w-48", children: description })
|
|
101
|
+
] }) })
|
|
102
|
+
] });
|
|
75
103
|
}
|
|
76
104
|
var Label_default = Label;
|
|
77
105
|
|
|
78
106
|
// src/components/ui/Chip.tsx
|
|
79
107
|
var import_cva = require("cva");
|
|
80
108
|
var import_tailwind_merge2 = require("tailwind-merge");
|
|
81
|
-
var
|
|
82
|
-
var Chip = ({ className, variant, size, ...props }) => /* @__PURE__ */ (0,
|
|
109
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
110
|
+
var Chip = ({ className, variant, size, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: (0, import_tailwind_merge2.twMerge)(chipVariants({ variant, size, className })), ...props });
|
|
83
111
|
var chipVariants = (0, import_cva.cva)(["flex", "items-center", "rounded-3xl", "border", "w-fit"], {
|
|
84
112
|
variants: {
|
|
85
113
|
variant: {
|
|
@@ -103,9 +131,9 @@ var Chip_default = Chip;
|
|
|
103
131
|
|
|
104
132
|
// src/components/primitives/separator.tsx
|
|
105
133
|
var SeparatorPrimitive = __toESM(require("@radix-ui/react-separator"), 1);
|
|
106
|
-
var
|
|
107
|
-
var
|
|
108
|
-
var Separator =
|
|
134
|
+
var React2 = __toESM(require("react"), 1);
|
|
135
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
136
|
+
var Separator = React2.forwardRef(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
109
137
|
SeparatorPrimitive.Root,
|
|
110
138
|
{
|
|
111
139
|
ref,
|
|
@@ -122,9 +150,9 @@ var Separator = React.forwardRef(({ className, orientation = "horizontal", decor
|
|
|
122
150
|
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
123
151
|
|
|
124
152
|
// src/components/ui/Select.tsx
|
|
125
|
-
var
|
|
153
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
126
154
|
var Select = (0, import_react.forwardRef)(
|
|
127
|
-
({ label, options, placeholder, multiselect, classNames, error, id, ...props }, ref) => {
|
|
155
|
+
({ label, options, placeholder, multiselect, description, classNames, error, id, ...props }, ref) => {
|
|
128
156
|
const { value, defaultValue, dir, className, onChange, ...rest } = props;
|
|
129
157
|
const [selected, setSelected] = (0, import_react.useState)([]);
|
|
130
158
|
const [open, setOpen] = (0, import_react.useState)(false);
|
|
@@ -154,23 +182,24 @@ var Select = (0, import_react.forwardRef)(
|
|
|
154
182
|
});
|
|
155
183
|
onChange?.(multiselect ? newSelected : newValue);
|
|
156
184
|
}
|
|
157
|
-
return /* @__PURE__ */ (0,
|
|
185
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
158
186
|
"div",
|
|
159
187
|
{
|
|
160
|
-
className: cn("flex flex-col gap-1", className),
|
|
188
|
+
className: cn("flex w-full flex-col gap-1", className),
|
|
161
189
|
ref: containerRef,
|
|
162
190
|
"data-testid": `${(label ?? id)?.toLowerCase()}-select-element`,
|
|
163
191
|
children: [
|
|
164
|
-
/* @__PURE__ */ (0,
|
|
192
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
165
193
|
Label_default,
|
|
166
194
|
{
|
|
167
195
|
text: label,
|
|
168
196
|
htmlFor: props.name,
|
|
169
197
|
required: props.required,
|
|
198
|
+
description,
|
|
170
199
|
className: classNames?.label
|
|
171
200
|
}
|
|
172
201
|
),
|
|
173
|
-
/* @__PURE__ */ (0,
|
|
202
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
174
203
|
SelectPrimitive.Root,
|
|
175
204
|
{
|
|
176
205
|
open,
|
|
@@ -181,16 +210,16 @@ var Select = (0, import_react.forwardRef)(
|
|
|
181
210
|
dir: dir === "rtl" ? "rtl" : "ltr",
|
|
182
211
|
...rest,
|
|
183
212
|
children: [
|
|
184
|
-
/* @__PURE__ */ (0,
|
|
213
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
185
214
|
SelectPrimitive.Trigger,
|
|
186
215
|
{
|
|
187
216
|
ref,
|
|
188
217
|
className: cn(
|
|
189
|
-
"group flex h-11
|
|
218
|
+
"group flex h-11 w-full flex-row items-center justify-between gap-3 rounded-lg border px-4 py-3 text-sm font-normal focus:outline-purple-100 disabled:bg-grey-5 data-[placeholder]:text-grey-50 data-[placeholder]:disabled:text-grey-40",
|
|
190
219
|
classNames?.trigger
|
|
191
220
|
),
|
|
192
221
|
children: [
|
|
193
|
-
/* @__PURE__ */ (0,
|
|
222
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "truncate", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
194
223
|
SelectPrimitive.Value,
|
|
195
224
|
{
|
|
196
225
|
placeholder: placeholder ?? "Select an option",
|
|
@@ -198,8 +227,8 @@ var Select = (0, import_react.forwardRef)(
|
|
|
198
227
|
children: handleLabels()
|
|
199
228
|
}
|
|
200
229
|
) }),
|
|
201
|
-
/* @__PURE__ */ (0,
|
|
202
|
-
|
|
230
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
231
|
+
import_lucide_react2.ChevronDownIcon,
|
|
203
232
|
{
|
|
204
233
|
className: "transform text-black group-data-[state=open]:rotate-180",
|
|
205
234
|
size: "16"
|
|
@@ -208,7 +237,7 @@ var Select = (0, import_react.forwardRef)(
|
|
|
208
237
|
]
|
|
209
238
|
}
|
|
210
239
|
),
|
|
211
|
-
/* @__PURE__ */ (0,
|
|
240
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectPrimitive.Portal, { container: containerRef.current, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
212
241
|
SelectPrimitive.Content,
|
|
213
242
|
{
|
|
214
243
|
hideWhenDetached: true,
|
|
@@ -217,17 +246,17 @@ var Select = (0, import_react.forwardRef)(
|
|
|
217
246
|
sideOffset: 4,
|
|
218
247
|
onPointerDownOutside: toggleOpen,
|
|
219
248
|
onKeyDown: closeOnEscape,
|
|
220
|
-
children: /* @__PURE__ */ (0,
|
|
221
|
-
multiselect && !!chipLabels?.length && /* @__PURE__ */ (0,
|
|
249
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(SelectPrimitive.Viewport, { children: [
|
|
250
|
+
multiselect && !!chipLabels?.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
222
251
|
SelectPrimitive.Group,
|
|
223
252
|
{
|
|
224
253
|
className: "mb-2 flex flex-row flex-wrap gap-1 px-2",
|
|
225
254
|
"data-testid": "selected-labels",
|
|
226
255
|
children: chipLabels?.map(
|
|
227
|
-
(chip) => chip && /* @__PURE__ */ (0,
|
|
228
|
-
/* @__PURE__ */ (0,
|
|
229
|
-
/* @__PURE__ */ (0,
|
|
230
|
-
|
|
256
|
+
(chip) => chip && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Chip_default, { size: "small", variant: "primary", children: [
|
|
257
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: chip.title }),
|
|
258
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
259
|
+
import_lucide_react2.X,
|
|
231
260
|
{
|
|
232
261
|
size: 18,
|
|
233
262
|
"data-testid": `chip-remove-${chip.value}`,
|
|
@@ -239,8 +268,8 @@ var Select = (0, import_react.forwardRef)(
|
|
|
239
268
|
)
|
|
240
269
|
}
|
|
241
270
|
),
|
|
242
|
-
/* @__PURE__ */ (0,
|
|
243
|
-
options?.map(({ id: id2, title, value: value2 }) => /* @__PURE__ */ (0,
|
|
271
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Separator, {}),
|
|
272
|
+
options?.map(({ id: id2, title, value: value2 }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
244
273
|
SelectPrimitive.Item,
|
|
245
274
|
{
|
|
246
275
|
value: value2,
|
|
@@ -249,9 +278,9 @@ var Select = (0, import_react.forwardRef)(
|
|
|
249
278
|
onKeyDown: (e) => setValueOnEnter(e, value2),
|
|
250
279
|
onClick: () => handleChange(value2),
|
|
251
280
|
children: [
|
|
252
|
-
/* @__PURE__ */ (0,
|
|
253
|
-
/* @__PURE__ */ (0,
|
|
254
|
-
|
|
281
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectPrimitive.ItemText, { children: title }),
|
|
282
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
283
|
+
import_lucide_react2.CheckIcon,
|
|
255
284
|
{
|
|
256
285
|
className: "absolute inset-y-0 right-3 my-auto hidden w-6 text-purple-100 group-data-[state=checked]:block",
|
|
257
286
|
size: 16
|
|
@@ -267,7 +296,7 @@ var Select = (0, import_react.forwardRef)(
|
|
|
267
296
|
]
|
|
268
297
|
}
|
|
269
298
|
),
|
|
270
|
-
/* @__PURE__ */ (0,
|
|
299
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ErrorMessage_default, { message: error })
|
|
271
300
|
]
|
|
272
301
|
}
|
|
273
302
|
);
|
|
@@ -277,12 +306,12 @@ Select.displayName = "Select";
|
|
|
277
306
|
var Select_default = Select;
|
|
278
307
|
|
|
279
308
|
// src/components/demos/SelectDemo.tsx
|
|
280
|
-
var
|
|
309
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
281
310
|
function SelectDemo() {
|
|
282
|
-
return /* @__PURE__ */ (0,
|
|
283
|
-
/* @__PURE__ */ (0,
|
|
284
|
-
/* @__PURE__ */ (0,
|
|
285
|
-
/* @__PURE__ */ (0,
|
|
311
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "m-4", children: [
|
|
312
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h3", { children: "Select" }),
|
|
313
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "mt-2 flex max-w-sm flex-col gap-4", children: [
|
|
314
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
286
315
|
Select_default,
|
|
287
316
|
{
|
|
288
317
|
required: true,
|
|
@@ -295,12 +324,13 @@ function SelectDemo() {
|
|
|
295
324
|
]
|
|
296
325
|
}
|
|
297
326
|
),
|
|
298
|
-
/* @__PURE__ */ (0,
|
|
327
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
299
328
|
Select_default,
|
|
300
329
|
{
|
|
301
330
|
multiselect: true,
|
|
302
331
|
label: "Label - Multiselect",
|
|
303
332
|
placeholder: "Select an option",
|
|
333
|
+
description: "This is a tooltip",
|
|
304
334
|
options: [
|
|
305
335
|
{ id: "1", value: "1", title: "Option 1" },
|
|
306
336
|
{ id: "2", value: "2", title: "Option 2" },
|
|
@@ -315,7 +345,7 @@ function SelectDemo() {
|
|
|
315
345
|
]
|
|
316
346
|
}
|
|
317
347
|
),
|
|
318
|
-
/* @__PURE__ */ (0,
|
|
348
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
319
349
|
Select_default,
|
|
320
350
|
{
|
|
321
351
|
disabled: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/demos/SelectDemo.tsx","../../../src/components/ui/Select.tsx","../../../src/lib/utils.ts","../../../src/components/ui/ErrorMessage.tsx","../../../src/components/ui/Label.tsx","../../../src/components/ui/Chip.tsx","../../../src/components/primitives/separator.tsx"],"sourcesContent":["import Select from '@/components/ui/Select'\n\nfunction SelectDemo() {\n return (\n <div className=\"m-4\">\n <h3>Select</h3>\n <div className=\"mt-2 flex max-w-sm flex-col gap-4\">\n <Select\n required\n label=\"Label - Singleselect\"\n placeholder=\"Select an option\"\n options={[\n { id: '1', value: '1', title: 'Option 1' },\n { id: '2', value: '2', title: 'Option 2' },\n { id: '3', value: '3', title: 'Option 3' },\n ]}\n />\n <Select\n multiselect\n label=\"Label - Multiselect\"\n placeholder=\"Select an option\"\n options={[\n { id: '1', value: '1', title: 'Option 1' },\n { id: '2', value: '2', title: 'Option 2' },\n { id: '3', value: '3', title: 'Option 3' },\n { id: '4', value: '4', title: 'Option 4' },\n { id: '5', value: '5', title: 'Option 5' },\n { id: '6', value: '6', title: 'Option 6' },\n { id: '7', value: '7', title: 'Option 7' },\n { id: '8', value: '8', title: 'Option 8' },\n { id: '9', value: '9', title: 'Option 9' },\n { id: '10', value: '10', title: 'Option 10' },\n ]}\n />\n <Select\n disabled\n label=\"Label - Disabled\"\n placeholder=\"Select an option\"\n options={[\n { id: '1', value: '1', title: 'Option 1' },\n { id: '2', value: '2', title: 'Option 2' },\n { id: '3', value: '3', title: 'Option 3' },\n ]}\n />\n </div>\n </div>\n )\n}\n\nexport default SelectDemo\n","'use client'\n\nimport * as SelectPrimitive from '@radix-ui/react-select'\nimport { CheckIcon, ChevronDownIcon, X } from 'lucide-react'\nimport {\n type ComponentPropsWithoutRef,\n forwardRef,\n type KeyboardEvent,\n useEffect,\n useRef,\n useState,\n} from 'react'\n\nimport ErrorMessage from '@/components/ui/ErrorMessage'\nimport Label from '@/components/ui/Label'\nimport Chip from '@/components/ui/Chip'\nimport { Separator } from '@/components/primitives/separator'\nimport { cn } from '@/lib/utils'\n\ninterface Props extends Omit<ComponentPropsWithoutRef<'select'>, 'value' | 'onChange'> {\n label?: string\n value?: string | string[]\n options?: { id: string | number; value: string; title: string }[]\n placeholder?: string\n multiselect?: boolean\n onChange?: (value: string | string[]) => void\n classNames?: { label?: string; trigger?: string }\n error?: string\n}\n\nconst Select = forwardRef<HTMLButtonElement, Props>(\n ({ label, options, placeholder, multiselect, classNames, error, id, ...props }, ref) => {\n const { value, defaultValue, dir, className, onChange, ...rest } = props\n const [selected, setSelected] = useState<string[]>([])\n const [open, setOpen] = useState(false)\n const containerRef = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!value) return setSelected([])\n setSelected(Array.isArray(value) ? value : [value])\n }, [value])\n\n const toggleOpen = () => setOpen((prev) => !prev)\n const closeOnEscape = (event: KeyboardEvent) => event.key === 'Escape' && setOpen(false)\n const setValueOnEnter = (event: KeyboardEvent, value: string) =>\n event.key === 'Enter' && handleChange(value)\n\n const chipLabels = selected\n ?.map((s) => options?.find(({ value }) => value === s))\n .filter(Boolean)\n\n function handleLabels() {\n if (multiselect) {\n return selected.map((o) => options?.find((option) => option.value === o)?.title).join(', ')\n }\n return options?.find((option) => option.value === selected.join())?.title\n }\n\n function handleOnOpenChange(isOpen: boolean) {\n if (!multiselect || isOpen) setOpen(isOpen)\n }\n\n function handleChange(newValue: string) {\n let newSelected: string[] = []\n setSelected((prev) => {\n newSelected = prev.includes(newValue)\n ? prev.filter((item) => item !== newValue)\n : [...prev, newValue]\n return multiselect ? newSelected : [newValue]\n })\n onChange?.(multiselect ? newSelected : newValue)\n }\n\n return (\n <div\n className={cn('flex flex-col gap-1', className)}\n ref={containerRef}\n data-testid={`${(label ?? id)?.toLowerCase()}-select-element`}\n >\n <Label\n text={label}\n htmlFor={props.name}\n required={props.required}\n className={classNames?.label}\n />\n\n <SelectPrimitive.Root\n open={open}\n value={selected.join(',')}\n onOpenChange={handleOnOpenChange}\n onValueChange={multiselect ? undefined : handleChange}\n defaultValue={typeof defaultValue === 'string' ? defaultValue : undefined}\n dir={dir === 'rtl' ? 'rtl' : 'ltr'}\n {...rest}\n >\n <SelectPrimitive.Trigger\n ref={ref}\n className={cn(\n 'group flex h-11 min-w-80 flex-row items-center justify-between gap-3 rounded-lg border px-4 py-3 text-sm font-normal focus:outline-purple-100 disabled:bg-grey-5 data-[placeholder]:text-grey-50 data-[placeholder]:disabled:text-grey-40',\n classNames?.trigger\n )}\n >\n <span className=\"truncate\">\n <SelectPrimitive.Value\n placeholder={placeholder ?? 'Select an option'}\n aria-label={handleLabels()}\n >\n {handleLabels()}\n </SelectPrimitive.Value>\n </span>\n\n <ChevronDownIcon\n className=\"transform text-black group-data-[state=open]:rotate-180\"\n size=\"16\"\n />\n </SelectPrimitive.Trigger>\n\n <SelectPrimitive.Portal container={containerRef.current}>\n <SelectPrimitive.Content\n hideWhenDetached\n className=\"z-10 max-h-[var(--radix-select-content-available-height)] w-[var(--radix-select-trigger-width)] overflow-hidden rounded-md bg-white py-2 shadow-lg\"\n position=\"popper\"\n sideOffset={4}\n onPointerDownOutside={toggleOpen}\n onKeyDown={closeOnEscape}\n >\n <SelectPrimitive.Viewport>\n {multiselect && !!chipLabels?.length && (\n <SelectPrimitive.Group\n className=\"mb-2 flex flex-row flex-wrap gap-1 px-2\"\n data-testid=\"selected-labels\"\n >\n {chipLabels?.map(\n (chip) =>\n chip && (\n <Chip key={chip.title} size=\"small\" variant=\"primary\">\n <span>{chip.title}</span>\n <X\n size={18}\n data-testid={`chip-remove-${chip.value}`}\n className=\"cursor-pointer\"\n onClick={() => handleChange(chip.value)}\n />\n </Chip>\n )\n )}\n </SelectPrimitive.Group>\n )}\n <Separator />\n {options?.map(({ id, title, value }) => (\n <SelectPrimitive.Item\n key={id}\n value={value}\n className=\"group relative cursor-pointer px-4 py-2 text-left text-sm hover:bg-purple-50 focus:bg-purple-50 focus:outline-none data-[state=checked]:bg-purple-50 data-[state=checked]:pr-10 data-[state=checked]:text-purple-100\"\n data-state={selected.includes(value) ? 'checked' : 'unchecked'}\n onKeyDown={(e) => setValueOnEnter(e, value)}\n onClick={() => handleChange(value)}\n >\n <SelectPrimitive.ItemText>{title}</SelectPrimitive.ItemText>\n <CheckIcon\n className=\"absolute inset-y-0 right-3 my-auto hidden w-6 text-purple-100 group-data-[state=checked]:block\"\n size={16}\n />\n </SelectPrimitive.Item>\n ))}\n </SelectPrimitive.Viewport>\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n </SelectPrimitive.Root>\n\n <ErrorMessage message={error} />\n </div>\n )\n }\n)\n\nSelect.displayName = 'Select'\n\nexport default Select\n","import { type ClassValue, clsx } from 'clsx'\nimport { twMerge } from 'tailwind-merge'\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n","import { type ComponentPropsWithoutRef } from 'react'\n\nimport { cn } from '@/lib/utils'\n\ninterface Props extends ComponentPropsWithoutRef<'p'> {\n message?: string\n}\n\nfunction ErrorMessage({ message, className, ...props }: Readonly<Props>) {\n if (!message) return null\n\n return (\n <p className={cn('px-1 text-xs text-red-600', className)} {...props}>\n {message}\n </p>\n )\n}\n\nexport default ErrorMessage\n","import { type ComponentPropsWithoutRef } from 'react'\n\nimport { cn } from '@/lib/utils'\n\ninterface Props extends ComponentPropsWithoutRef<'label'> {\n text?: string\n required?: boolean\n}\n\nfunction Label({ text, required, className, ...props }: Readonly<Props>) {\n if (!text) return null\n\n return (\n <label\n className={cn(\n 'text-xs text-grey-80 peer-disabled:cursor-not-allowed peer-disabled:opacity-70',\n className\n )}\n {...props}\n >\n {text}\n {required && <span className=\"text-red-600\"> *</span>}\n </label>\n )\n}\n\nexport default Label\n","import { cva, type VariantProps } from 'cva'\nimport React from 'react'\nimport { twMerge } from 'tailwind-merge'\n\ninterface ChipProps\n extends React.HTMLAttributes<HTMLDivElement>,\n VariantProps<typeof chipVariants> {}\n\nconst Chip = ({ className, variant, size, ...props }: ChipProps) => (\n <div className={twMerge(chipVariants({ variant, size, className }))} {...props} />\n)\n\nconst chipVariants = cva(['flex', 'items-center', 'rounded-3xl', 'border', 'w-fit'], {\n variants: {\n variant: {\n neutral: ['text-grey-80', 'border-grey-10'],\n primary: ['text-purple-100', 'border-purple-20'],\n danger: ['text-pumpkin-100', 'border-pumpkin-20'],\n onboarding: ['text-green-100', 'bg-green-10', 'cursor-pointer'],\n onboardingSelected: ['text-white', 'bg-green-90', 'cursor-pointer'],\n },\n size: {\n small: ['text-sm', 'leading-5', 'px-2', 'py-1', 'gap-1.5'],\n medium: ['text-base', 'leading-6', 'px-3', 'py-2', 'gap-2'],\n },\n },\n defaultVariants: {\n variant: 'neutral',\n size: 'medium',\n },\n})\n\nexport default Chip\n","'use client'\r\n\r\nimport * as SeparatorPrimitive from '@radix-ui/react-separator'\r\nimport * as React from 'react'\r\n\r\nimport { cn } from '@/lib/utils'\r\n\r\nconst Separator = React.forwardRef<\r\n React.ElementRef<typeof SeparatorPrimitive.Root>,\r\n React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>\r\n>(({ className, orientation = 'horizontal', decorative = true, ...props }, ref) => (\r\n <SeparatorPrimitive.Root\r\n ref={ref}\r\n decorative={decorative}\r\n orientation={orientation}\r\n className={cn(\r\n 'shrink-0 bg-grey-10',\r\n orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]',\r\n className\r\n )}\r\n {...props}\r\n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AAM;AAAA,UACN,aAAY;AAAA,UACZ,SAAS;AAAA,YACP,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,MAAM,OAAO,MAAM,OAAO,YAAY;AAAA,UAC9C;AAAA;AAAA,MACF;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,UAAQ;AAAA,UACR,OAAM;AAAA,UACN,aAAY;AAAA,UACZ,SAAS;AAAA,YACP,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,UAC3C;AAAA;AAAA,MACF;AAAA,OACF;AAAA,KACF;AAEJ;AAEA,IAAO,qBAAQ;","names":["import_jsx_runtime","import_tailwind_merge","import_jsx_runtime","import_jsx_runtime","import_jsx_runtime","value","id","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/demos/SelectDemo.tsx","../../../src/components/ui/Select.tsx","../../../src/lib/utils.ts","../../../src/components/ui/ErrorMessage.tsx","../../../src/components/primitives/tooltip.tsx","../../../src/components/ui/Label.tsx","../../../src/components/ui/Chip.tsx","../../../src/components/primitives/separator.tsx"],"sourcesContent":["import Select from '@/components/ui/Select'\n\nfunction SelectDemo() {\n return (\n <div className=\"m-4\">\n <h3>Select</h3>\n <div className=\"mt-2 flex max-w-sm flex-col gap-4\">\n <Select\n required\n label=\"Label - Singleselect\"\n placeholder=\"Select an option\"\n options={[\n { id: '1', value: '1', title: 'Option 1' },\n { id: '2', value: '2', title: 'Option 2' },\n { id: '3', value: '3', title: 'Option 3' },\n ]}\n />\n <Select\n multiselect\n label=\"Label - Multiselect\"\n placeholder=\"Select an option\"\n description=\"This is a tooltip\"\n options={[\n { id: '1', value: '1', title: 'Option 1' },\n { id: '2', value: '2', title: 'Option 2' },\n { id: '3', value: '3', title: 'Option 3' },\n { id: '4', value: '4', title: 'Option 4' },\n { id: '5', value: '5', title: 'Option 5' },\n { id: '6', value: '6', title: 'Option 6' },\n { id: '7', value: '7', title: 'Option 7' },\n { id: '8', value: '8', title: 'Option 8' },\n { id: '9', value: '9', title: 'Option 9' },\n { id: '10', value: '10', title: 'Option 10' },\n ]}\n />\n <Select\n disabled\n label=\"Label - Disabled\"\n placeholder=\"Select an option\"\n options={[\n { id: '1', value: '1', title: 'Option 1' },\n { id: '2', value: '2', title: 'Option 2' },\n { id: '3', value: '3', title: 'Option 3' },\n ]}\n />\n </div>\n </div>\n )\n}\n\nexport default SelectDemo\n","'use client'\n\nimport * as SelectPrimitive from '@radix-ui/react-select'\nimport { CheckIcon, ChevronDownIcon, X } from 'lucide-react'\nimport {\n type ComponentPropsWithoutRef,\n forwardRef,\n type KeyboardEvent,\n useEffect,\n useRef,\n useState,\n} from 'react'\n\nimport ErrorMessage from '@/components/ui/ErrorMessage'\nimport Label from '@/components/ui/Label'\nimport Chip from '@/components/ui/Chip'\nimport { Separator } from '@/components/primitives/separator'\nimport { cn } from '@/lib/utils'\n\ninterface Props extends Omit<ComponentPropsWithoutRef<'select'>, 'value' | 'onChange'> {\n label?: string\n value?: string | string[]\n options?: { id: string | number; value: string; title: string }[]\n placeholder?: string\n multiselect?: boolean\n description?: string\n error?: string\n classNames?: { label?: string; trigger?: string }\n onChange?: (value: string | string[]) => void\n}\n\nconst Select = forwardRef<HTMLButtonElement, Props>(\n (\n { label, options, placeholder, multiselect, description, classNames, error, id, ...props },\n ref\n ) => {\n const { value, defaultValue, dir, className, onChange, ...rest } = props\n const [selected, setSelected] = useState<string[]>([])\n const [open, setOpen] = useState(false)\n const containerRef = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!value) return setSelected([])\n setSelected(Array.isArray(value) ? value : [value])\n }, [value])\n\n const toggleOpen = () => setOpen((prev) => !prev)\n const closeOnEscape = (event: KeyboardEvent) => event.key === 'Escape' && setOpen(false)\n const setValueOnEnter = (event: KeyboardEvent, value: string) =>\n event.key === 'Enter' && handleChange(value)\n\n const chipLabels = selected\n ?.map((s) => options?.find(({ value }) => value === s))\n .filter(Boolean)\n\n function handleLabels() {\n if (multiselect) {\n return selected.map((o) => options?.find((option) => option.value === o)?.title).join(', ')\n }\n return options?.find((option) => option.value === selected.join())?.title\n }\n\n function handleOnOpenChange(isOpen: boolean) {\n if (!multiselect || isOpen) setOpen(isOpen)\n }\n\n function handleChange(newValue: string) {\n let newSelected: string[] = []\n setSelected((prev) => {\n newSelected = prev.includes(newValue)\n ? prev.filter((item) => item !== newValue)\n : [...prev, newValue]\n return multiselect ? newSelected : [newValue]\n })\n onChange?.(multiselect ? newSelected : newValue)\n }\n\n return (\n <div\n className={cn('flex w-full flex-col gap-1', className)}\n ref={containerRef}\n data-testid={`${(label ?? id)?.toLowerCase()}-select-element`}\n >\n <Label\n text={label}\n htmlFor={props.name}\n required={props.required}\n description={description}\n className={classNames?.label}\n />\n\n <SelectPrimitive.Root\n open={open}\n value={selected.join(',')}\n onOpenChange={handleOnOpenChange}\n onValueChange={multiselect ? undefined : handleChange}\n defaultValue={typeof defaultValue === 'string' ? defaultValue : undefined}\n dir={dir === 'rtl' ? 'rtl' : 'ltr'}\n {...rest}\n >\n <SelectPrimitive.Trigger\n ref={ref}\n className={cn(\n 'group flex h-11 w-full flex-row items-center justify-between gap-3 rounded-lg border px-4 py-3 text-sm font-normal focus:outline-purple-100 disabled:bg-grey-5 data-[placeholder]:text-grey-50 data-[placeholder]:disabled:text-grey-40',\n classNames?.trigger\n )}\n >\n <span className=\"truncate\">\n <SelectPrimitive.Value\n placeholder={placeholder ?? 'Select an option'}\n aria-label={handleLabels()}\n >\n {handleLabels()}\n </SelectPrimitive.Value>\n </span>\n\n <ChevronDownIcon\n className=\"transform text-black group-data-[state=open]:rotate-180\"\n size=\"16\"\n />\n </SelectPrimitive.Trigger>\n\n <SelectPrimitive.Portal container={containerRef.current}>\n <SelectPrimitive.Content\n hideWhenDetached\n className=\"z-10 max-h-[var(--radix-select-content-available-height)] w-[var(--radix-select-trigger-width)] overflow-hidden rounded-md bg-white py-2 shadow-lg\"\n position=\"popper\"\n sideOffset={4}\n onPointerDownOutside={toggleOpen}\n onKeyDown={closeOnEscape}\n >\n <SelectPrimitive.Viewport>\n {multiselect && !!chipLabels?.length && (\n <SelectPrimitive.Group\n className=\"mb-2 flex flex-row flex-wrap gap-1 px-2\"\n data-testid=\"selected-labels\"\n >\n {chipLabels?.map(\n (chip) =>\n chip && (\n <Chip key={chip.title} size=\"small\" variant=\"primary\">\n <span>{chip.title}</span>\n <X\n size={18}\n data-testid={`chip-remove-${chip.value}`}\n className=\"cursor-pointer\"\n onClick={() => handleChange(chip.value)}\n />\n </Chip>\n )\n )}\n </SelectPrimitive.Group>\n )}\n <Separator />\n {options?.map(({ id, title, value }) => (\n <SelectPrimitive.Item\n key={id}\n value={value}\n className=\"group relative cursor-pointer px-4 py-2 text-left text-sm hover:bg-purple-50 focus:bg-purple-50 focus:outline-none data-[state=checked]:bg-purple-50 data-[state=checked]:pr-10 data-[state=checked]:text-purple-100\"\n data-state={selected.includes(value) ? 'checked' : 'unchecked'}\n onKeyDown={(e) => setValueOnEnter(e, value)}\n onClick={() => handleChange(value)}\n >\n <SelectPrimitive.ItemText>{title}</SelectPrimitive.ItemText>\n <CheckIcon\n className=\"absolute inset-y-0 right-3 my-auto hidden w-6 text-purple-100 group-data-[state=checked]:block\"\n size={16}\n />\n </SelectPrimitive.Item>\n ))}\n </SelectPrimitive.Viewport>\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n </SelectPrimitive.Root>\n\n <ErrorMessage message={error} />\n </div>\n )\n }\n)\n\nSelect.displayName = 'Select'\n\nexport default Select\n","import { type ClassValue, clsx } from 'clsx'\nimport { twMerge } from 'tailwind-merge'\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n","import { type ComponentPropsWithoutRef } from 'react'\n\nimport { cn } from '@/lib/utils'\n\ninterface Props extends ComponentPropsWithoutRef<'p'> {\n message?: string\n}\n\nfunction ErrorMessage({ message, className, ...props }: Readonly<Props>) {\n if (!message) return null\n\n return (\n <p className={cn('px-1 text-xs text-red-600', className)} {...props}>\n {message}\n </p>\n )\n}\n\nexport default ErrorMessage\n","'use client'\n\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip'\nimport * as React from 'react'\n\nimport { cn } from '@/lib/utils'\n\nconst TooltipProvider = TooltipPrimitive.Provider\n\nconst Tooltip = TooltipPrimitive.Root\n\nconst TooltipTrigger = TooltipPrimitive.Trigger\n\nconst TooltipContent = React.forwardRef<\n React.ElementRef<typeof TooltipPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>\n>(({ className, sideOffset = 4, ...props }, ref) => (\n <TooltipPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n className={cn(\n 'z-50 overflow-hidden rounded-md border border-neutral-200 bg-white px-3 py-1.5 text-sm text-neutral-950 shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50',\n className\n )}\n {...props}\n />\n))\nTooltipContent.displayName = TooltipPrimitive.Content.displayName\n\nexport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger }\n","import { type ComponentPropsWithoutRef } from 'react'\n\nimport { cn } from '@/lib/utils'\nimport {\n Tooltip,\n TooltipContent,\n TooltipProvider,\n TooltipTrigger,\n} from '@/components/primitives/tooltip'\nimport { InfoIcon } from 'lucide-react'\n\ninterface Props extends ComponentPropsWithoutRef<'label'> {\n text?: string\n required?: boolean\n description?: string\n}\n\nfunction Label({ text, required, description, className, ...props }: Readonly<Props>) {\n if (!text) return null\n\n return (\n <div className=\"flex w-full flex-row gap-1\">\n <label\n className={cn(\n 'text-xs text-grey-80 peer-disabled:cursor-not-allowed peer-disabled:opacity-70',\n className\n )}\n {...props}\n >\n {text}\n {required && <span className=\"text-red-600\"> *</span>}\n </label>\n\n {!!description && (\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger asChild>\n <InfoIcon className=\"h-4 w-4\" />\n </TooltipTrigger>\n <TooltipContent className=\"max-w-48\">{description}</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n )}\n </div>\n )\n}\n\nexport default Label\n","import { cva, type VariantProps } from 'cva'\nimport React from 'react'\nimport { twMerge } from 'tailwind-merge'\n\ninterface ChipProps\n extends React.HTMLAttributes<HTMLDivElement>,\n VariantProps<typeof chipVariants> {}\n\nconst Chip = ({ className, variant, size, ...props }: ChipProps) => (\n <div className={twMerge(chipVariants({ variant, size, className }))} {...props} />\n)\n\nconst chipVariants = cva(['flex', 'items-center', 'rounded-3xl', 'border', 'w-fit'], {\n variants: {\n variant: {\n neutral: ['text-grey-80', 'border-grey-10'],\n primary: ['text-purple-100', 'border-purple-20'],\n danger: ['text-pumpkin-100', 'border-pumpkin-20'],\n onboarding: ['text-green-100', 'bg-green-10', 'cursor-pointer'],\n onboardingSelected: ['text-white', 'bg-green-90', 'cursor-pointer'],\n },\n size: {\n small: ['text-sm', 'leading-5', 'px-2', 'py-1', 'gap-1.5'],\n medium: ['text-base', 'leading-6', 'px-3', 'py-2', 'gap-2'],\n },\n },\n defaultVariants: {\n variant: 'neutral',\n size: 'medium',\n },\n})\n\nexport default Chip\n","'use client'\r\n\r\nimport * as SeparatorPrimitive from '@radix-ui/react-separator'\r\nimport * as React from 'react'\r\n\r\nimport { cn } from '@/lib/utils'\r\n\r\nconst Separator = React.forwardRef<\r\n React.ElementRef<typeof SeparatorPrimitive.Root>,\r\n React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>\r\n>(({ className, orientation = 'horizontal', decorative = true, ...props }, ref) => (\r\n <SeparatorPrimitive.Root\r\n ref={ref}\r\n decorative={decorative}\r\n orientation={orientation}\r\n className={cn(\r\n 'shrink-0 bg-grey-10',\r\n orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]',\r\n className\r\n )}\r\n {...props}\r\n />\r\n))\r\nSeparator.displayName = SeparatorPrimitive.Root.displayName\r\n\r\nexport { Separator }\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,sBAAiC;AACjC,IAAAA,uBAA8C;AAC9C,mBAOO;;;ACXP,kBAAsC;AACtC,4BAAwB;AAEjB,SAAS,MAAM,QAAsB;AAC1C,aAAO,mCAAQ,kBAAK,MAAM,CAAC;AAC7B;;;ACOI;AAJJ,SAAS,aAAa,EAAE,SAAS,WAAW,GAAG,MAAM,GAAoB;AACvE,MAAI,CAAC,QAAS,QAAO;AAErB,SACE,4CAAC,OAAE,WAAW,GAAG,6BAA6B,SAAS,GAAI,GAAG,OAC3D,mBACH;AAEJ;AAEA,IAAO,uBAAQ;;;AChBf,uBAAkC;AAClC,YAAuB;AAcrB,IAAAC,sBAAA;AAVF,IAAM,kBAAmC;AAEzC,IAAM,UAA2B;AAEjC,IAAM,iBAAkC;AAExC,IAAM,iBAAuB,iBAG3B,CAAC,EAAE,WAAW,aAAa,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AA,UACZ,SAAS;AAAA,YACP,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,MAAM,OAAO,MAAM,OAAO,YAAY;AAAA,UAC9C;AAAA;AAAA,MACF;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,UAAQ;AAAA,UACR,OAAM;AAAA,UACN,aAAY;AAAA,UACZ,SAAS;AAAA,YACP,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,YACzC,EAAE,IAAI,KAAK,OAAO,KAAK,OAAO,WAAW;AAAA,UAC3C;AAAA;AAAA,MACF;AAAA,OACF;AAAA,KACF;AAEJ;AAEA,IAAO,qBAAQ;","names":["import_lucide_react","import_jsx_runtime","import_jsx_runtime","import_tailwind_merge","import_jsx_runtime","React","import_jsx_runtime","import_jsx_runtime","value","id","import_jsx_runtime"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
3
3
|
import { CheckIcon, ChevronDownIcon, X } from "lucide-react";
|
|
4
4
|
import {
|
|
5
|
-
forwardRef as
|
|
5
|
+
forwardRef as forwardRef3,
|
|
6
6
|
useEffect,
|
|
7
7
|
useRef,
|
|
8
8
|
useState
|
|
@@ -23,32 +23,60 @@ function ErrorMessage({ message, className, ...props }) {
|
|
|
23
23
|
}
|
|
24
24
|
var ErrorMessage_default = ErrorMessage;
|
|
25
25
|
|
|
26
|
+
// src/components/primitives/tooltip.tsx
|
|
27
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
28
|
+
import * as React from "react";
|
|
29
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
30
|
+
var TooltipProvider = TooltipPrimitive.Provider;
|
|
31
|
+
var Tooltip = TooltipPrimitive.Root;
|
|
32
|
+
var TooltipTrigger = TooltipPrimitive.Trigger;
|
|
33
|
+
var TooltipContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx2(
|
|
34
|
+
TooltipPrimitive.Content,
|
|
35
|
+
{
|
|
36
|
+
ref,
|
|
37
|
+
sideOffset,
|
|
38
|
+
className: cn(
|
|
39
|
+
"z-50 overflow-hidden rounded-md border border-neutral-200 bg-white px-3 py-1.5 text-sm text-neutral-950 shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",
|
|
40
|
+
className
|
|
41
|
+
),
|
|
42
|
+
...props
|
|
43
|
+
}
|
|
44
|
+
));
|
|
45
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
46
|
+
|
|
26
47
|
// src/components/ui/Label.tsx
|
|
27
|
-
import {
|
|
28
|
-
|
|
48
|
+
import { InfoIcon } from "lucide-react";
|
|
49
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
50
|
+
function Label({ text, required, description, className, ...props }) {
|
|
29
51
|
if (!text) return null;
|
|
30
|
-
return /* @__PURE__ */ jsxs(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-row gap-1", children: [
|
|
53
|
+
/* @__PURE__ */ jsxs(
|
|
54
|
+
"label",
|
|
55
|
+
{
|
|
56
|
+
className: cn(
|
|
57
|
+
"text-xs text-grey-80 peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
58
|
+
className
|
|
59
|
+
),
|
|
60
|
+
...props,
|
|
61
|
+
children: [
|
|
62
|
+
text,
|
|
63
|
+
required && /* @__PURE__ */ jsx3("span", { className: "text-red-600", children: "\xA0*" })
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
!!description && /* @__PURE__ */ jsx3(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
68
|
+
/* @__PURE__ */ jsx3(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx3(InfoIcon, { className: "h-4 w-4" }) }),
|
|
69
|
+
/* @__PURE__ */ jsx3(TooltipContent, { className: "max-w-48", children: description })
|
|
70
|
+
] }) })
|
|
71
|
+
] });
|
|
44
72
|
}
|
|
45
73
|
var Label_default = Label;
|
|
46
74
|
|
|
47
75
|
// src/components/ui/Chip.tsx
|
|
48
76
|
import { cva } from "cva";
|
|
49
77
|
import { twMerge as twMerge2 } from "tailwind-merge";
|
|
50
|
-
import { jsx as
|
|
51
|
-
var Chip = ({ className, variant, size, ...props }) => /* @__PURE__ */
|
|
78
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
79
|
+
var Chip = ({ className, variant, size, ...props }) => /* @__PURE__ */ jsx4("div", { className: twMerge2(chipVariants({ variant, size, className })), ...props });
|
|
52
80
|
var chipVariants = cva(["flex", "items-center", "rounded-3xl", "border", "w-fit"], {
|
|
53
81
|
variants: {
|
|
54
82
|
variant: {
|
|
@@ -72,9 +100,9 @@ var Chip_default = Chip;
|
|
|
72
100
|
|
|
73
101
|
// src/components/primitives/separator.tsx
|
|
74
102
|
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
75
|
-
import * as
|
|
76
|
-
import { jsx as
|
|
77
|
-
var Separator =
|
|
103
|
+
import * as React2 from "react";
|
|
104
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
105
|
+
var Separator = React2.forwardRef(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ jsx5(
|
|
78
106
|
SeparatorPrimitive.Root,
|
|
79
107
|
{
|
|
80
108
|
ref,
|
|
@@ -91,9 +119,9 @@ var Separator = React.forwardRef(({ className, orientation = "horizontal", decor
|
|
|
91
119
|
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
92
120
|
|
|
93
121
|
// src/components/ui/Select.tsx
|
|
94
|
-
import { jsx as
|
|
95
|
-
var Select =
|
|
96
|
-
({ label, options, placeholder, multiselect, classNames, error, id, ...props }, ref) => {
|
|
122
|
+
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
123
|
+
var Select = forwardRef3(
|
|
124
|
+
({ label, options, placeholder, multiselect, description, classNames, error, id, ...props }, ref) => {
|
|
97
125
|
const { value, defaultValue, dir, className, onChange, ...rest } = props;
|
|
98
126
|
const [selected, setSelected] = useState([]);
|
|
99
127
|
const [open, setOpen] = useState(false);
|
|
@@ -126,16 +154,17 @@ var Select = forwardRef2(
|
|
|
126
154
|
return /* @__PURE__ */ jsxs2(
|
|
127
155
|
"div",
|
|
128
156
|
{
|
|
129
|
-
className: cn("flex flex-col gap-1", className),
|
|
157
|
+
className: cn("flex w-full flex-col gap-1", className),
|
|
130
158
|
ref: containerRef,
|
|
131
159
|
"data-testid": `${(label ?? id)?.toLowerCase()}-select-element`,
|
|
132
160
|
children: [
|
|
133
|
-
/* @__PURE__ */
|
|
161
|
+
/* @__PURE__ */ jsx6(
|
|
134
162
|
Label_default,
|
|
135
163
|
{
|
|
136
164
|
text: label,
|
|
137
165
|
htmlFor: props.name,
|
|
138
166
|
required: props.required,
|
|
167
|
+
description,
|
|
139
168
|
className: classNames?.label
|
|
140
169
|
}
|
|
141
170
|
),
|
|
@@ -155,11 +184,11 @@ var Select = forwardRef2(
|
|
|
155
184
|
{
|
|
156
185
|
ref,
|
|
157
186
|
className: cn(
|
|
158
|
-
"group flex h-11
|
|
187
|
+
"group flex h-11 w-full flex-row items-center justify-between gap-3 rounded-lg border px-4 py-3 text-sm font-normal focus:outline-purple-100 disabled:bg-grey-5 data-[placeholder]:text-grey-50 data-[placeholder]:disabled:text-grey-40",
|
|
159
188
|
classNames?.trigger
|
|
160
189
|
),
|
|
161
190
|
children: [
|
|
162
|
-
/* @__PURE__ */
|
|
191
|
+
/* @__PURE__ */ jsx6("span", { className: "truncate", children: /* @__PURE__ */ jsx6(
|
|
163
192
|
SelectPrimitive.Value,
|
|
164
193
|
{
|
|
165
194
|
placeholder: placeholder ?? "Select an option",
|
|
@@ -167,7 +196,7 @@ var Select = forwardRef2(
|
|
|
167
196
|
children: handleLabels()
|
|
168
197
|
}
|
|
169
198
|
) }),
|
|
170
|
-
/* @__PURE__ */
|
|
199
|
+
/* @__PURE__ */ jsx6(
|
|
171
200
|
ChevronDownIcon,
|
|
172
201
|
{
|
|
173
202
|
className: "transform text-black group-data-[state=open]:rotate-180",
|
|
@@ -177,7 +206,7 @@ var Select = forwardRef2(
|
|
|
177
206
|
]
|
|
178
207
|
}
|
|
179
208
|
),
|
|
180
|
-
/* @__PURE__ */
|
|
209
|
+
/* @__PURE__ */ jsx6(SelectPrimitive.Portal, { container: containerRef.current, children: /* @__PURE__ */ jsx6(
|
|
181
210
|
SelectPrimitive.Content,
|
|
182
211
|
{
|
|
183
212
|
hideWhenDetached: true,
|
|
@@ -187,15 +216,15 @@ var Select = forwardRef2(
|
|
|
187
216
|
onPointerDownOutside: toggleOpen,
|
|
188
217
|
onKeyDown: closeOnEscape,
|
|
189
218
|
children: /* @__PURE__ */ jsxs2(SelectPrimitive.Viewport, { children: [
|
|
190
|
-
multiselect && !!chipLabels?.length && /* @__PURE__ */
|
|
219
|
+
multiselect && !!chipLabels?.length && /* @__PURE__ */ jsx6(
|
|
191
220
|
SelectPrimitive.Group,
|
|
192
221
|
{
|
|
193
222
|
className: "mb-2 flex flex-row flex-wrap gap-1 px-2",
|
|
194
223
|
"data-testid": "selected-labels",
|
|
195
224
|
children: chipLabels?.map(
|
|
196
225
|
(chip) => chip && /* @__PURE__ */ jsxs2(Chip_default, { size: "small", variant: "primary", children: [
|
|
197
|
-
/* @__PURE__ */
|
|
198
|
-
/* @__PURE__ */
|
|
226
|
+
/* @__PURE__ */ jsx6("span", { children: chip.title }),
|
|
227
|
+
/* @__PURE__ */ jsx6(
|
|
199
228
|
X,
|
|
200
229
|
{
|
|
201
230
|
size: 18,
|
|
@@ -208,7 +237,7 @@ var Select = forwardRef2(
|
|
|
208
237
|
)
|
|
209
238
|
}
|
|
210
239
|
),
|
|
211
|
-
/* @__PURE__ */
|
|
240
|
+
/* @__PURE__ */ jsx6(Separator, {}),
|
|
212
241
|
options?.map(({ id: id2, title, value: value2 }) => /* @__PURE__ */ jsxs2(
|
|
213
242
|
SelectPrimitive.Item,
|
|
214
243
|
{
|
|
@@ -218,8 +247,8 @@ var Select = forwardRef2(
|
|
|
218
247
|
onKeyDown: (e) => setValueOnEnter(e, value2),
|
|
219
248
|
onClick: () => handleChange(value2),
|
|
220
249
|
children: [
|
|
221
|
-
/* @__PURE__ */
|
|
222
|
-
/* @__PURE__ */
|
|
250
|
+
/* @__PURE__ */ jsx6(SelectPrimitive.ItemText, { children: title }),
|
|
251
|
+
/* @__PURE__ */ jsx6(
|
|
223
252
|
CheckIcon,
|
|
224
253
|
{
|
|
225
254
|
className: "absolute inset-y-0 right-3 my-auto hidden w-6 text-purple-100 group-data-[state=checked]:block",
|
|
@@ -236,7 +265,7 @@ var Select = forwardRef2(
|
|
|
236
265
|
]
|
|
237
266
|
}
|
|
238
267
|
),
|
|
239
|
-
/* @__PURE__ */
|
|
268
|
+
/* @__PURE__ */ jsx6(ErrorMessage_default, { message: error })
|
|
240
269
|
]
|
|
241
270
|
}
|
|
242
271
|
);
|
|
@@ -246,12 +275,12 @@ Select.displayName = "Select";
|
|
|
246
275
|
var Select_default = Select;
|
|
247
276
|
|
|
248
277
|
// src/components/demos/SelectDemo.tsx
|
|
249
|
-
import { jsx as
|
|
278
|
+
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
250
279
|
function SelectDemo() {
|
|
251
280
|
return /* @__PURE__ */ jsxs3("div", { className: "m-4", children: [
|
|
252
|
-
/* @__PURE__ */
|
|
281
|
+
/* @__PURE__ */ jsx7("h3", { children: "Select" }),
|
|
253
282
|
/* @__PURE__ */ jsxs3("div", { className: "mt-2 flex max-w-sm flex-col gap-4", children: [
|
|
254
|
-
/* @__PURE__ */
|
|
283
|
+
/* @__PURE__ */ jsx7(
|
|
255
284
|
Select_default,
|
|
256
285
|
{
|
|
257
286
|
required: true,
|
|
@@ -264,12 +293,13 @@ function SelectDemo() {
|
|
|
264
293
|
]
|
|
265
294
|
}
|
|
266
295
|
),
|
|
267
|
-
/* @__PURE__ */
|
|
296
|
+
/* @__PURE__ */ jsx7(
|
|
268
297
|
Select_default,
|
|
269
298
|
{
|
|
270
299
|
multiselect: true,
|
|
271
300
|
label: "Label - Multiselect",
|
|
272
301
|
placeholder: "Select an option",
|
|
302
|
+
description: "This is a tooltip",
|
|
273
303
|
options: [
|
|
274
304
|
{ id: "1", value: "1", title: "Option 1" },
|
|
275
305
|
{ id: "2", value: "2", title: "Option 2" },
|
|
@@ -284,7 +314,7 @@ function SelectDemo() {
|
|
|
284
314
|
]
|
|
285
315
|
}
|
|
286
316
|
),
|
|
287
|
-
/* @__PURE__ */
|
|
317
|
+
/* @__PURE__ */ jsx7(
|
|
288
318
|
Select_default,
|
|
289
319
|
{
|
|
290
320
|
disabled: true,
|