@saptanshuwanjari/react-component-library 0.1.6 → 0.1.9
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/index.d.mts +51 -22
- package/dist/index.d.ts +51 -22
- package/dist/index.js +1097 -845
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +870 -620
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -3
package/dist/index.mjs
CHANGED
|
@@ -3,14 +3,18 @@ import { createContext, memo, useState, useContext, useTransition, useEffect, us
|
|
|
3
3
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
4
4
|
import { Controller, useForm } from 'react-hook-form';
|
|
5
5
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
|
-
import
|
|
6
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
7
7
|
import { clsx } from 'clsx';
|
|
8
8
|
import { twMerge } from 'tailwind-merge';
|
|
9
|
-
import {
|
|
9
|
+
import { Lock, EyeOff, Eye, CalendarIcon, Upload, ChevronDownIcon, CheckIcon, ChevronLeftIcon, ChevronRightIcon, X, Pencil, Table as Table$1, LayoutGrid, ArrowUp, ArrowDown, ArrowUpDown, SlidersHorizontal, ChevronUpIcon } from 'lucide-react';
|
|
10
10
|
import { cva } from 'class-variance-authority';
|
|
11
11
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
12
|
-
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
13
12
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
13
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
14
|
+
import { getDefaultClassNames, DayPicker } from 'react-day-picker';
|
|
15
|
+
import { format } from 'date-fns';
|
|
16
|
+
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
17
|
+
import { useReactTable, getPaginationRowModel, getSortedRowModel, getFilteredRowModel, getCoreRowModel, flexRender } from '@tanstack/react-table';
|
|
14
18
|
|
|
15
19
|
// src/components/form/root.tsx
|
|
16
20
|
var FormContext = createContext(null);
|
|
@@ -71,17 +75,34 @@ function useFormCtx() {
|
|
|
71
75
|
if (!ctx) throw new Error("Form components must be used inside Form.Root");
|
|
72
76
|
return ctx;
|
|
73
77
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
function cn(...inputs) {
|
|
79
|
+
return twMerge(clsx(inputs));
|
|
80
|
+
}
|
|
81
|
+
function Label({
|
|
82
|
+
className,
|
|
83
|
+
...props
|
|
84
|
+
}) {
|
|
85
|
+
return /* @__PURE__ */ jsx(
|
|
86
|
+
LabelPrimitive.Root,
|
|
87
|
+
{
|
|
88
|
+
"data-slot": "label",
|
|
89
|
+
className: cn(
|
|
90
|
+
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
91
|
+
className
|
|
92
|
+
),
|
|
93
|
+
...props
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
}
|
|
77
97
|
function Field({
|
|
78
98
|
name,
|
|
79
99
|
label,
|
|
80
100
|
children
|
|
81
101
|
}) {
|
|
82
102
|
const form = useFormCtx();
|
|
83
|
-
|
|
84
|
-
|
|
103
|
+
const error = form.formState.errors[name];
|
|
104
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
105
|
+
label ? /* @__PURE__ */ jsx(Label, { htmlFor: String(name), children: label }) : null,
|
|
85
106
|
/* @__PURE__ */ jsx(
|
|
86
107
|
Controller,
|
|
87
108
|
{
|
|
@@ -90,17 +111,26 @@ function Field({
|
|
|
90
111
|
render: ({ field }) => /* @__PURE__ */ jsx(Fragment, { children: children(field) })
|
|
91
112
|
}
|
|
92
113
|
),
|
|
93
|
-
/* @__PURE__ */ jsx(
|
|
114
|
+
error?.message && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-destructive", children: error.message })
|
|
94
115
|
] });
|
|
95
116
|
}
|
|
96
117
|
var field_default = Field;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
118
|
+
function Input({ className, type, ...props }) {
|
|
119
|
+
return /* @__PURE__ */ jsx(
|
|
120
|
+
"input",
|
|
121
|
+
{
|
|
122
|
+
type,
|
|
123
|
+
"data-slot": "input",
|
|
124
|
+
className: cn(
|
|
125
|
+
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
126
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
127
|
+
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
128
|
+
className
|
|
129
|
+
),
|
|
130
|
+
...props
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
104
134
|
var InputField = memo(function InputField2({
|
|
105
135
|
name,
|
|
106
136
|
label,
|
|
@@ -126,6 +156,166 @@ var InputField = memo(function InputField2({
|
|
|
126
156
|
) });
|
|
127
157
|
});
|
|
128
158
|
var input_field_default = InputField;
|
|
159
|
+
function setRef(ref, value) {
|
|
160
|
+
if (typeof ref === "function") {
|
|
161
|
+
return ref(value);
|
|
162
|
+
} else if (ref !== null && ref !== void 0) {
|
|
163
|
+
ref.current = value;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function composeRefs(...refs) {
|
|
167
|
+
return (node) => {
|
|
168
|
+
let hasCleanup = false;
|
|
169
|
+
const cleanups = refs.map((ref) => {
|
|
170
|
+
const cleanup = setRef(ref, node);
|
|
171
|
+
if (!hasCleanup && typeof cleanup == "function") {
|
|
172
|
+
hasCleanup = true;
|
|
173
|
+
}
|
|
174
|
+
return cleanup;
|
|
175
|
+
});
|
|
176
|
+
if (hasCleanup) {
|
|
177
|
+
return () => {
|
|
178
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
179
|
+
const cleanup = cleanups[i];
|
|
180
|
+
if (typeof cleanup == "function") {
|
|
181
|
+
cleanup();
|
|
182
|
+
} else {
|
|
183
|
+
setRef(refs[i], null);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
// @__NO_SIDE_EFFECTS__
|
|
191
|
+
function createSlot(ownerName) {
|
|
192
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
193
|
+
const Slot2 = React2.forwardRef((props, forwardedRef) => {
|
|
194
|
+
const { children, ...slotProps } = props;
|
|
195
|
+
const childrenArray = React2.Children.toArray(children);
|
|
196
|
+
const slottable = childrenArray.find(isSlottable);
|
|
197
|
+
if (slottable) {
|
|
198
|
+
const newElement = slottable.props.children;
|
|
199
|
+
const newChildren = childrenArray.map((child) => {
|
|
200
|
+
if (child === slottable) {
|
|
201
|
+
if (React2.Children.count(newElement) > 1) return React2.Children.only(null);
|
|
202
|
+
return React2.isValidElement(newElement) ? newElement.props.children : null;
|
|
203
|
+
} else {
|
|
204
|
+
return child;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React2.isValidElement(newElement) ? React2.cloneElement(newElement, void 0, newChildren) : null });
|
|
208
|
+
}
|
|
209
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
210
|
+
});
|
|
211
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
212
|
+
return Slot2;
|
|
213
|
+
}
|
|
214
|
+
var Slot = /* @__PURE__ */ createSlot("Slot");
|
|
215
|
+
// @__NO_SIDE_EFFECTS__
|
|
216
|
+
function createSlotClone(ownerName) {
|
|
217
|
+
const SlotClone = React2.forwardRef((props, forwardedRef) => {
|
|
218
|
+
const { children, ...slotProps } = props;
|
|
219
|
+
if (React2.isValidElement(children)) {
|
|
220
|
+
const childrenRef = getElementRef(children);
|
|
221
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
222
|
+
if (children.type !== React2.Fragment) {
|
|
223
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
224
|
+
}
|
|
225
|
+
return React2.cloneElement(children, props2);
|
|
226
|
+
}
|
|
227
|
+
return React2.Children.count(children) > 1 ? React2.Children.only(null) : null;
|
|
228
|
+
});
|
|
229
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
230
|
+
return SlotClone;
|
|
231
|
+
}
|
|
232
|
+
var SLOTTABLE_IDENTIFIER = /* @__PURE__ */ Symbol("radix.slottable");
|
|
233
|
+
function isSlottable(child) {
|
|
234
|
+
return React2.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
235
|
+
}
|
|
236
|
+
function mergeProps(slotProps, childProps) {
|
|
237
|
+
const overrideProps = { ...childProps };
|
|
238
|
+
for (const propName in childProps) {
|
|
239
|
+
const slotPropValue = slotProps[propName];
|
|
240
|
+
const childPropValue = childProps[propName];
|
|
241
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
242
|
+
if (isHandler) {
|
|
243
|
+
if (slotPropValue && childPropValue) {
|
|
244
|
+
overrideProps[propName] = (...args) => {
|
|
245
|
+
const result = childPropValue(...args);
|
|
246
|
+
slotPropValue(...args);
|
|
247
|
+
return result;
|
|
248
|
+
};
|
|
249
|
+
} else if (slotPropValue) {
|
|
250
|
+
overrideProps[propName] = slotPropValue;
|
|
251
|
+
}
|
|
252
|
+
} else if (propName === "style") {
|
|
253
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
254
|
+
} else if (propName === "className") {
|
|
255
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return { ...slotProps, ...overrideProps };
|
|
259
|
+
}
|
|
260
|
+
function getElementRef(element) {
|
|
261
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
262
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
263
|
+
if (mayWarn) {
|
|
264
|
+
return element.ref;
|
|
265
|
+
}
|
|
266
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
267
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
268
|
+
if (mayWarn) {
|
|
269
|
+
return element.props.ref;
|
|
270
|
+
}
|
|
271
|
+
return element.props.ref || element.ref;
|
|
272
|
+
}
|
|
273
|
+
var buttonVariants = cva(
|
|
274
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
275
|
+
{
|
|
276
|
+
variants: {
|
|
277
|
+
variant: {
|
|
278
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
279
|
+
destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
280
|
+
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
281
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
282
|
+
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
283
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
284
|
+
},
|
|
285
|
+
size: {
|
|
286
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
287
|
+
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
288
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
289
|
+
icon: "size-9",
|
|
290
|
+
"icon-sm": "size-8",
|
|
291
|
+
"icon-lg": "size-10"
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
defaultVariants: {
|
|
295
|
+
variant: "default",
|
|
296
|
+
size: "default"
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
);
|
|
300
|
+
function Button({
|
|
301
|
+
className,
|
|
302
|
+
variant = "default",
|
|
303
|
+
size = "default",
|
|
304
|
+
asChild = false,
|
|
305
|
+
...props
|
|
306
|
+
}) {
|
|
307
|
+
const Comp = asChild ? Slot : "button";
|
|
308
|
+
return /* @__PURE__ */ jsx(
|
|
309
|
+
Comp,
|
|
310
|
+
{
|
|
311
|
+
"data-slot": "button",
|
|
312
|
+
"data-variant": variant,
|
|
313
|
+
"data-size": size,
|
|
314
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
315
|
+
...props
|
|
316
|
+
}
|
|
317
|
+
);
|
|
318
|
+
}
|
|
129
319
|
var PasswordField = memo(function PasswordField2({
|
|
130
320
|
name,
|
|
131
321
|
label,
|
|
@@ -133,37 +323,45 @@ var PasswordField = memo(function PasswordField2({
|
|
|
133
323
|
}) {
|
|
134
324
|
const [show, setShow] = useState(false);
|
|
135
325
|
return /* @__PURE__ */ jsx(field_default, { name, label, children: (field) => /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
136
|
-
/* @__PURE__ */ jsx("div", { className: "absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none", children: /* @__PURE__ */ jsx(Lock, { className: "h-4 w-4 text-muted-foreground" }) }),
|
|
326
|
+
/* @__PURE__ */ jsx("div", { className: "absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none z-10", children: /* @__PURE__ */ jsx(Lock, { className: "h-4 w-4 text-muted-foreground" }) }),
|
|
137
327
|
/* @__PURE__ */ jsx(
|
|
138
|
-
|
|
328
|
+
Input,
|
|
139
329
|
{
|
|
140
330
|
id: String(name),
|
|
141
331
|
type: show ? "text" : "password",
|
|
142
332
|
...field,
|
|
143
333
|
value: field.value ?? "",
|
|
144
334
|
placeholder,
|
|
145
|
-
className: "
|
|
335
|
+
className: "pl-10 pr-10"
|
|
146
336
|
}
|
|
147
337
|
),
|
|
148
338
|
/* @__PURE__ */ jsx(
|
|
149
|
-
|
|
339
|
+
Button,
|
|
150
340
|
{
|
|
341
|
+
variant: "ghost",
|
|
342
|
+
size: "sm",
|
|
151
343
|
type: "button",
|
|
152
344
|
onClick: () => setShow(!show),
|
|
153
|
-
className: "absolute right-
|
|
345
|
+
className: "absolute right-1 top-1/2 -translate-y-1/2 h-8 w-8 p-0 text-muted-foreground hover:text-foreground",
|
|
154
346
|
children: show ? /* @__PURE__ */ jsx(EyeOff, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(Eye, { className: "h-4 w-4" })
|
|
155
347
|
}
|
|
156
348
|
)
|
|
157
349
|
] }) });
|
|
158
350
|
});
|
|
159
351
|
var password_field_default = PasswordField;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
352
|
+
function Textarea({ className, ...props }) {
|
|
353
|
+
return /* @__PURE__ */ jsx(
|
|
354
|
+
"textarea",
|
|
355
|
+
{
|
|
356
|
+
"data-slot": "textarea",
|
|
357
|
+
className: cn(
|
|
358
|
+
"border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
359
|
+
className
|
|
360
|
+
),
|
|
361
|
+
...props
|
|
362
|
+
}
|
|
363
|
+
);
|
|
364
|
+
}
|
|
167
365
|
var TextareaField = memo(function TextareaField2({
|
|
168
366
|
name,
|
|
169
367
|
label,
|
|
@@ -185,66 +383,191 @@ var TextareaField = memo(function TextareaField2({
|
|
|
185
383
|
) });
|
|
186
384
|
});
|
|
187
385
|
var textarea_field_default = TextareaField;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
{
|
|
191
|
-
className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
192
|
-
onChange: (e) => onValueChange(e.target.value),
|
|
193
|
-
value,
|
|
194
|
-
children
|
|
195
|
-
}
|
|
196
|
-
);
|
|
197
|
-
var SelectValue = ({ placeholder }) => /* @__PURE__ */ jsx("option", { value: "", children: placeholder });
|
|
198
|
-
var SelectItem = ({ value, children }) => /* @__PURE__ */ jsx("option", { value, children });
|
|
199
|
-
var Input2 = ({ className = "", ...props }) => /* @__PURE__ */ jsx(
|
|
200
|
-
"input",
|
|
201
|
-
{
|
|
202
|
-
className: `flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ${className}`,
|
|
203
|
-
...props
|
|
204
|
-
}
|
|
205
|
-
);
|
|
206
|
-
var SelectField = memo(function SelectField2({
|
|
207
|
-
name,
|
|
208
|
-
label,
|
|
209
|
-
placeholder = "Select an option",
|
|
210
|
-
options
|
|
386
|
+
function Select({
|
|
387
|
+
...props
|
|
211
388
|
}) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
389
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Root, { "data-slot": "select", ...props });
|
|
390
|
+
}
|
|
391
|
+
function SelectValue({
|
|
392
|
+
...props
|
|
393
|
+
}) {
|
|
394
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Value, { "data-slot": "select-value", ...props });
|
|
395
|
+
}
|
|
396
|
+
function SelectTrigger({
|
|
397
|
+
className,
|
|
398
|
+
size = "default",
|
|
399
|
+
children,
|
|
400
|
+
...props
|
|
401
|
+
}) {
|
|
402
|
+
return /* @__PURE__ */ jsxs(
|
|
403
|
+
SelectPrimitive.Trigger,
|
|
215
404
|
{
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
405
|
+
"data-slot": "select-trigger",
|
|
406
|
+
"data-size": size,
|
|
407
|
+
className: cn(
|
|
408
|
+
"border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
409
|
+
className
|
|
410
|
+
),
|
|
411
|
+
...props,
|
|
412
|
+
children: [
|
|
413
|
+
children,
|
|
414
|
+
/* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-4 opacity-50" }) })
|
|
415
|
+
]
|
|
221
416
|
}
|
|
222
|
-
)
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
function SelectContent({
|
|
420
|
+
className,
|
|
421
|
+
children,
|
|
422
|
+
position = "item-aligned",
|
|
423
|
+
align = "center",
|
|
424
|
+
...props
|
|
425
|
+
}) {
|
|
426
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
|
|
427
|
+
SelectPrimitive.Content,
|
|
428
|
+
{
|
|
429
|
+
"data-slot": "select-content",
|
|
430
|
+
className: cn(
|
|
431
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
|
|
432
|
+
position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
433
|
+
className
|
|
434
|
+
),
|
|
435
|
+
position,
|
|
436
|
+
align,
|
|
437
|
+
...props,
|
|
438
|
+
children: [
|
|
439
|
+
/* @__PURE__ */ jsx(SelectScrollUpButton, {}),
|
|
440
|
+
/* @__PURE__ */ jsx(
|
|
441
|
+
SelectPrimitive.Viewport,
|
|
442
|
+
{
|
|
443
|
+
className: cn(
|
|
444
|
+
"p-1",
|
|
445
|
+
position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
|
|
446
|
+
),
|
|
447
|
+
children
|
|
448
|
+
}
|
|
449
|
+
),
|
|
450
|
+
/* @__PURE__ */ jsx(SelectScrollDownButton, {})
|
|
451
|
+
]
|
|
452
|
+
}
|
|
453
|
+
) });
|
|
454
|
+
}
|
|
455
|
+
function SelectItem({
|
|
456
|
+
className,
|
|
457
|
+
children,
|
|
458
|
+
...props
|
|
459
|
+
}) {
|
|
460
|
+
return /* @__PURE__ */ jsxs(
|
|
461
|
+
SelectPrimitive.Item,
|
|
462
|
+
{
|
|
463
|
+
"data-slot": "select-item",
|
|
464
|
+
className: cn(
|
|
465
|
+
"focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
|
466
|
+
className
|
|
467
|
+
),
|
|
468
|
+
...props,
|
|
469
|
+
children: [
|
|
470
|
+
/* @__PURE__ */ jsx(
|
|
471
|
+
"span",
|
|
472
|
+
{
|
|
473
|
+
"data-slot": "select-item-indicator",
|
|
474
|
+
className: "absolute right-2 flex size-3.5 items-center justify-center",
|
|
475
|
+
children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4" }) })
|
|
476
|
+
}
|
|
477
|
+
),
|
|
478
|
+
/* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children })
|
|
479
|
+
]
|
|
480
|
+
}
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
function SelectScrollUpButton({
|
|
484
|
+
className,
|
|
485
|
+
...props
|
|
486
|
+
}) {
|
|
487
|
+
return /* @__PURE__ */ jsx(
|
|
488
|
+
SelectPrimitive.ScrollUpButton,
|
|
489
|
+
{
|
|
490
|
+
"data-slot": "select-scroll-up-button",
|
|
491
|
+
className: cn(
|
|
492
|
+
"flex cursor-default items-center justify-center py-1",
|
|
493
|
+
className
|
|
494
|
+
),
|
|
495
|
+
...props,
|
|
496
|
+
children: /* @__PURE__ */ jsx(ChevronUpIcon, { className: "size-4" })
|
|
497
|
+
}
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
function SelectScrollDownButton({
|
|
501
|
+
className,
|
|
502
|
+
...props
|
|
503
|
+
}) {
|
|
504
|
+
return /* @__PURE__ */ jsx(
|
|
505
|
+
SelectPrimitive.ScrollDownButton,
|
|
506
|
+
{
|
|
507
|
+
"data-slot": "select-scroll-down-button",
|
|
508
|
+
className: cn(
|
|
509
|
+
"flex cursor-default items-center justify-center py-1",
|
|
510
|
+
className
|
|
511
|
+
),
|
|
512
|
+
...props,
|
|
513
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-4" })
|
|
514
|
+
}
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
var SelectField = memo(function SelectField2({
|
|
518
|
+
name,
|
|
519
|
+
label,
|
|
520
|
+
placeholder = "Select an option",
|
|
521
|
+
options
|
|
522
|
+
}) {
|
|
523
|
+
const { isEditing } = useFormCtx();
|
|
524
|
+
return /* @__PURE__ */ jsx(field_default, { name, label, children: (field) => !isEditing ? /* @__PURE__ */ jsx(
|
|
525
|
+
Input,
|
|
526
|
+
{
|
|
527
|
+
id: String(name),
|
|
528
|
+
value: options.find((opt) => opt.value === field.value)?.label ?? "",
|
|
529
|
+
placeholder,
|
|
530
|
+
readOnly: true,
|
|
531
|
+
disabled: true,
|
|
532
|
+
className: "bg-background/50 opacity-80"
|
|
533
|
+
}
|
|
534
|
+
) : /* @__PURE__ */ jsxs(Select, { onValueChange: field.onChange, value: field.value ?? "", children: [
|
|
535
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder }) }),
|
|
536
|
+
/* @__PURE__ */ jsx(SelectContent, { children: options.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label }, option.value)) })
|
|
537
|
+
] }) });
|
|
538
|
+
});
|
|
227
539
|
var select_field_default = SelectField;
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
540
|
+
function Checkbox({
|
|
541
|
+
className,
|
|
542
|
+
...props
|
|
543
|
+
}) {
|
|
544
|
+
return /* @__PURE__ */ jsx(
|
|
545
|
+
CheckboxPrimitive.Root,
|
|
546
|
+
{
|
|
547
|
+
"data-slot": "checkbox",
|
|
548
|
+
className: cn(
|
|
549
|
+
"peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
|
|
550
|
+
className
|
|
551
|
+
),
|
|
552
|
+
...props,
|
|
553
|
+
children: /* @__PURE__ */ jsx(
|
|
554
|
+
CheckboxPrimitive.Indicator,
|
|
555
|
+
{
|
|
556
|
+
"data-slot": "checkbox-indicator",
|
|
557
|
+
className: "grid place-content-center text-current transition-none",
|
|
558
|
+
children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-3.5" })
|
|
559
|
+
}
|
|
560
|
+
)
|
|
561
|
+
}
|
|
562
|
+
);
|
|
563
|
+
}
|
|
241
564
|
var CheckboxField = memo(function CheckboxField2({
|
|
242
565
|
name,
|
|
243
566
|
label,
|
|
244
567
|
description
|
|
245
568
|
}) {
|
|
246
569
|
const form = useFormCtx();
|
|
247
|
-
return /* @__PURE__ */ jsxs(
|
|
570
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
248
571
|
/* @__PURE__ */ jsx(
|
|
249
572
|
Controller,
|
|
250
573
|
{
|
|
@@ -262,10 +585,10 @@ var CheckboxField = memo(function CheckboxField2({
|
|
|
262
585
|
),
|
|
263
586
|
/* @__PURE__ */ jsxs("div", { className: "grid gap-1.5 leading-none", children: [
|
|
264
587
|
label && /* @__PURE__ */ jsx(
|
|
265
|
-
|
|
588
|
+
Label,
|
|
266
589
|
{
|
|
267
590
|
htmlFor: String(name),
|
|
268
|
-
className: "
|
|
591
|
+
className: "cursor-pointer",
|
|
269
592
|
children: label
|
|
270
593
|
}
|
|
271
594
|
),
|
|
@@ -274,59 +597,265 @@ var CheckboxField = memo(function CheckboxField2({
|
|
|
274
597
|
] })
|
|
275
598
|
}
|
|
276
599
|
),
|
|
277
|
-
/* @__PURE__ */ jsx(
|
|
600
|
+
form.formState.errors[name]?.message && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-destructive", children: form.formState.errors[name]?.message })
|
|
278
601
|
] });
|
|
279
602
|
});
|
|
280
603
|
var checkbox_field_default = CheckboxField;
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
)
|
|
604
|
+
function Popover({
|
|
605
|
+
...props
|
|
606
|
+
}) {
|
|
607
|
+
return /* @__PURE__ */ jsx(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
|
|
608
|
+
}
|
|
609
|
+
function PopoverTrigger({
|
|
610
|
+
...props
|
|
611
|
+
}) {
|
|
612
|
+
return /* @__PURE__ */ jsx(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
|
|
613
|
+
}
|
|
614
|
+
function PopoverContent({
|
|
615
|
+
className,
|
|
616
|
+
align = "center",
|
|
617
|
+
sideOffset = 4,
|
|
618
|
+
...props
|
|
619
|
+
}) {
|
|
620
|
+
return /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
621
|
+
PopoverPrimitive.Content,
|
|
622
|
+
{
|
|
623
|
+
"data-slot": "popover-content",
|
|
624
|
+
align,
|
|
625
|
+
sideOffset,
|
|
626
|
+
className: cn(
|
|
627
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
|
|
628
|
+
className
|
|
629
|
+
),
|
|
630
|
+
...props
|
|
631
|
+
}
|
|
632
|
+
) });
|
|
633
|
+
}
|
|
634
|
+
function Calendar({
|
|
635
|
+
className,
|
|
636
|
+
classNames,
|
|
637
|
+
showOutsideDays = true,
|
|
638
|
+
captionLayout = "label",
|
|
639
|
+
buttonVariant = "ghost",
|
|
640
|
+
formatters,
|
|
641
|
+
components,
|
|
642
|
+
...props
|
|
643
|
+
}) {
|
|
644
|
+
const defaultClassNames = getDefaultClassNames();
|
|
645
|
+
return /* @__PURE__ */ jsx(
|
|
646
|
+
DayPicker,
|
|
647
|
+
{
|
|
648
|
+
showOutsideDays,
|
|
649
|
+
className: cn(
|
|
650
|
+
"bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
|
|
651
|
+
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
|
652
|
+
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
|
653
|
+
className
|
|
654
|
+
),
|
|
655
|
+
captionLayout,
|
|
656
|
+
formatters: {
|
|
657
|
+
formatMonthDropdown: (date) => date.toLocaleString("default", { month: "short" }),
|
|
658
|
+
...formatters
|
|
659
|
+
},
|
|
660
|
+
classNames: {
|
|
661
|
+
root: cn("w-fit", defaultClassNames.root),
|
|
662
|
+
months: cn(
|
|
663
|
+
"flex gap-4 flex-col md:flex-row relative",
|
|
664
|
+
defaultClassNames.months
|
|
665
|
+
),
|
|
666
|
+
month: cn("flex flex-col w-full gap-4", defaultClassNames.month),
|
|
667
|
+
nav: cn(
|
|
668
|
+
"flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between",
|
|
669
|
+
defaultClassNames.nav
|
|
670
|
+
),
|
|
671
|
+
button_previous: cn(
|
|
672
|
+
buttonVariants({ variant: buttonVariant }),
|
|
673
|
+
"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
|
|
674
|
+
defaultClassNames.button_previous
|
|
675
|
+
),
|
|
676
|
+
button_next: cn(
|
|
677
|
+
buttonVariants({ variant: buttonVariant }),
|
|
678
|
+
"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
|
|
679
|
+
defaultClassNames.button_next
|
|
680
|
+
),
|
|
681
|
+
month_caption: cn(
|
|
682
|
+
"flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)",
|
|
683
|
+
defaultClassNames.month_caption
|
|
684
|
+
),
|
|
685
|
+
dropdowns: cn(
|
|
686
|
+
"w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5",
|
|
687
|
+
defaultClassNames.dropdowns
|
|
688
|
+
),
|
|
689
|
+
dropdown_root: cn(
|
|
690
|
+
"relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md",
|
|
691
|
+
defaultClassNames.dropdown_root
|
|
692
|
+
),
|
|
693
|
+
dropdown: cn(
|
|
694
|
+
"absolute bg-popover inset-0 opacity-0",
|
|
695
|
+
defaultClassNames.dropdown
|
|
696
|
+
),
|
|
697
|
+
caption_label: cn(
|
|
698
|
+
"select-none font-medium",
|
|
699
|
+
captionLayout === "label" ? "text-sm" : "rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5",
|
|
700
|
+
defaultClassNames.caption_label
|
|
701
|
+
),
|
|
702
|
+
table: "w-full border-collapse",
|
|
703
|
+
weekdays: cn("flex", defaultClassNames.weekdays),
|
|
704
|
+
weekday: cn(
|
|
705
|
+
"text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none",
|
|
706
|
+
defaultClassNames.weekday
|
|
707
|
+
),
|
|
708
|
+
week: cn("flex w-full mt-2", defaultClassNames.week),
|
|
709
|
+
week_number_header: cn(
|
|
710
|
+
"select-none w-(--cell-size)",
|
|
711
|
+
defaultClassNames.week_number_header
|
|
712
|
+
),
|
|
713
|
+
week_number: cn(
|
|
714
|
+
"text-[0.8rem] select-none text-muted-foreground",
|
|
715
|
+
defaultClassNames.week_number
|
|
716
|
+
),
|
|
717
|
+
day: cn(
|
|
718
|
+
"relative w-full h-full p-0 text-center [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none",
|
|
719
|
+
props.showWeekNumber ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-md" : "[&:first-child[data-selected=true]_button]:rounded-l-md",
|
|
720
|
+
defaultClassNames.day
|
|
721
|
+
),
|
|
722
|
+
range_start: cn(
|
|
723
|
+
"rounded-l-md bg-accent",
|
|
724
|
+
defaultClassNames.range_start
|
|
725
|
+
),
|
|
726
|
+
range_middle: cn("rounded-none", defaultClassNames.range_middle),
|
|
727
|
+
range_end: cn("rounded-r-md bg-accent", defaultClassNames.range_end),
|
|
728
|
+
today: cn(
|
|
729
|
+
"bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",
|
|
730
|
+
defaultClassNames.today
|
|
731
|
+
),
|
|
732
|
+
outside: cn(
|
|
733
|
+
"text-muted-foreground aria-selected:text-muted-foreground",
|
|
734
|
+
defaultClassNames.outside
|
|
735
|
+
),
|
|
736
|
+
disabled: cn(
|
|
737
|
+
"text-muted-foreground opacity-50",
|
|
738
|
+
defaultClassNames.disabled
|
|
739
|
+
),
|
|
740
|
+
hidden: cn("invisible", defaultClassNames.hidden),
|
|
741
|
+
...classNames
|
|
742
|
+
},
|
|
743
|
+
components: {
|
|
744
|
+
Root: ({ className: className2, rootRef, ...props2 }) => {
|
|
745
|
+
return /* @__PURE__ */ jsx(
|
|
746
|
+
"div",
|
|
747
|
+
{
|
|
748
|
+
"data-slot": "calendar",
|
|
749
|
+
ref: rootRef,
|
|
750
|
+
className: cn(className2),
|
|
751
|
+
...props2
|
|
752
|
+
}
|
|
753
|
+
);
|
|
754
|
+
},
|
|
755
|
+
Chevron: ({ className: className2, orientation, ...props2 }) => {
|
|
756
|
+
if (orientation === "left") {
|
|
757
|
+
return /* @__PURE__ */ jsx(ChevronLeftIcon, { className: cn("size-4", className2), ...props2 });
|
|
758
|
+
}
|
|
759
|
+
if (orientation === "right") {
|
|
760
|
+
return /* @__PURE__ */ jsx(
|
|
761
|
+
ChevronRightIcon,
|
|
762
|
+
{
|
|
763
|
+
className: cn("size-4", className2),
|
|
764
|
+
...props2
|
|
765
|
+
}
|
|
766
|
+
);
|
|
767
|
+
}
|
|
768
|
+
return /* @__PURE__ */ jsx(ChevronDownIcon, { className: cn("size-4", className2), ...props2 });
|
|
769
|
+
},
|
|
770
|
+
DayButton: CalendarDayButton,
|
|
771
|
+
WeekNumber: ({ children, ...props2 }) => {
|
|
772
|
+
return /* @__PURE__ */ jsx("td", { ...props2, children: /* @__PURE__ */ jsx("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children }) });
|
|
773
|
+
},
|
|
774
|
+
...components
|
|
775
|
+
},
|
|
776
|
+
...props
|
|
777
|
+
}
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
function CalendarDayButton({
|
|
781
|
+
className,
|
|
782
|
+
day,
|
|
783
|
+
modifiers,
|
|
784
|
+
...props
|
|
785
|
+
}) {
|
|
786
|
+
const defaultClassNames = getDefaultClassNames();
|
|
787
|
+
const ref = React2.useRef(null);
|
|
788
|
+
React2.useEffect(() => {
|
|
789
|
+
if (modifiers.focused) ref.current?.focus();
|
|
790
|
+
}, [modifiers.focused]);
|
|
791
|
+
return /* @__PURE__ */ jsx(
|
|
792
|
+
Button,
|
|
793
|
+
{
|
|
794
|
+
ref,
|
|
795
|
+
variant: "ghost",
|
|
796
|
+
size: "icon",
|
|
797
|
+
"data-day": day.date.toLocaleDateString(),
|
|
798
|
+
"data-selected-single": modifiers.selected && !modifiers.range_start && !modifiers.range_end && !modifiers.range_middle,
|
|
799
|
+
"data-range-start": modifiers.range_start,
|
|
800
|
+
"data-range-end": modifiers.range_end,
|
|
801
|
+
"data-range-middle": modifiers.range_middle,
|
|
802
|
+
className: cn(
|
|
803
|
+
"data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70",
|
|
804
|
+
defaultClassNames.day,
|
|
805
|
+
className
|
|
806
|
+
),
|
|
807
|
+
...props
|
|
808
|
+
}
|
|
809
|
+
);
|
|
810
|
+
}
|
|
289
811
|
var DateField = memo(function DateField2({
|
|
290
812
|
name,
|
|
291
813
|
label,
|
|
292
|
-
placeholder = "
|
|
814
|
+
placeholder = "Pick a date"
|
|
293
815
|
}) {
|
|
294
|
-
const [open, setOpen] = useState(false);
|
|
295
816
|
const { isEditing } = useFormCtx();
|
|
296
817
|
return /* @__PURE__ */ jsx(field_default, { name, label, children: (field) => !isEditing ? /* @__PURE__ */ jsxs(
|
|
297
818
|
Button,
|
|
298
819
|
{
|
|
299
820
|
type: "button",
|
|
300
|
-
|
|
301
|
-
className:
|
|
821
|
+
variant: "outline",
|
|
822
|
+
className: cn(
|
|
823
|
+
"w-full justify-start text-left font-normal bg-background/50",
|
|
824
|
+
!field.value && "text-muted-foreground"
|
|
825
|
+
),
|
|
302
826
|
disabled: true,
|
|
303
827
|
children: [
|
|
304
|
-
|
|
305
|
-
/* @__PURE__ */ jsx(
|
|
828
|
+
/* @__PURE__ */ jsx(CalendarIcon, { className: "mr-2 h-4 w-4" }),
|
|
829
|
+
field.value ? format(new Date(field.value), "PPP") : /* @__PURE__ */ jsx("span", { children: placeholder })
|
|
306
830
|
]
|
|
307
831
|
}
|
|
308
|
-
) : /* @__PURE__ */
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
832
|
+
) : /* @__PURE__ */ jsxs(Popover, { children: [
|
|
833
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
834
|
+
Button,
|
|
835
|
+
{
|
|
836
|
+
variant: "outline",
|
|
837
|
+
className: cn(
|
|
838
|
+
"w-full justify-start text-left font-normal",
|
|
839
|
+
!field.value && "text-muted-foreground"
|
|
840
|
+
),
|
|
841
|
+
children: [
|
|
842
|
+
/* @__PURE__ */ jsx(CalendarIcon, { className: "mr-2 h-4 w-4" }),
|
|
843
|
+
field.value ? format(new Date(field.value), "PPP") : /* @__PURE__ */ jsx("span", { children: placeholder })
|
|
844
|
+
]
|
|
845
|
+
}
|
|
846
|
+
) }),
|
|
847
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsx(
|
|
848
|
+
Calendar,
|
|
849
|
+
{
|
|
850
|
+
mode: "single",
|
|
851
|
+
selected: field.value ? new Date(field.value) : void 0,
|
|
852
|
+
onSelect: field.onChange,
|
|
853
|
+
initialFocus: true
|
|
854
|
+
}
|
|
855
|
+
) })
|
|
856
|
+
] }) });
|
|
318
857
|
});
|
|
319
858
|
var date_field_default = DateField;
|
|
320
|
-
var Input3 = ({ className = "", ...props }) => /* @__PURE__ */ jsx(
|
|
321
|
-
"input",
|
|
322
|
-
{
|
|
323
|
-
className: `flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ${className}`,
|
|
324
|
-
...props
|
|
325
|
-
}
|
|
326
|
-
);
|
|
327
|
-
var InputGroup = ({ children }) => /* @__PURE__ */ jsx("div", { className: "relative flex items-center", children });
|
|
328
|
-
var InputGroupAddon = ({ children }) => /* @__PURE__ */ jsx("div", { className: "absolute left-3 flex items-center", children });
|
|
329
|
-
var InputGroupInput = (props) => /* @__PURE__ */ jsx(Input3, { className: "pl-10", ...props });
|
|
330
859
|
var FileField = memo(function FileField2({
|
|
331
860
|
name,
|
|
332
861
|
label,
|
|
@@ -336,26 +865,28 @@ var FileField = memo(function FileField2({
|
|
|
336
865
|
const { isEditing } = useFormCtx();
|
|
337
866
|
return /* @__PURE__ */ jsx(field_default, { name, label, children: (field) => {
|
|
338
867
|
const files = field.value;
|
|
339
|
-
const filename = files && files.length ? files[0].name : "";
|
|
868
|
+
const filename = files && files.length ? multiple ? `${files.length} files` : files[0].name : "";
|
|
340
869
|
if (!isEditing) {
|
|
341
|
-
return /* @__PURE__ */ jsxs(
|
|
870
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative flex items-center", children: [
|
|
871
|
+
/* @__PURE__ */ jsx(Upload, { className: "absolute left-3 text-muted-foreground h-4 w-4 z-10" }),
|
|
342
872
|
/* @__PURE__ */ jsx(
|
|
343
|
-
|
|
873
|
+
Input,
|
|
344
874
|
{
|
|
345
875
|
id: `${String(name)}_display`,
|
|
346
876
|
type: "text",
|
|
347
877
|
value: filename,
|
|
348
878
|
placeholder: accept ? `Accepts ${accept}` : "No file selected",
|
|
879
|
+
readOnly: true,
|
|
349
880
|
disabled: true,
|
|
350
881
|
className: "bg-background/50 opacity-80 pl-10"
|
|
351
882
|
}
|
|
352
|
-
)
|
|
353
|
-
/* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Upload, { className: "text-muted-foreground h-4 w-4" }) })
|
|
883
|
+
)
|
|
354
884
|
] });
|
|
355
885
|
}
|
|
356
|
-
return /* @__PURE__ */ jsxs(
|
|
886
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative flex items-center", children: [
|
|
887
|
+
/* @__PURE__ */ jsx(Upload, { className: "absolute left-3 text-muted-foreground h-4 w-4 z-10 pointer-events-none" }),
|
|
357
888
|
/* @__PURE__ */ jsx(
|
|
358
|
-
|
|
889
|
+
Input,
|
|
359
890
|
{
|
|
360
891
|
id: String(name),
|
|
361
892
|
type: "file",
|
|
@@ -364,23 +895,59 @@ var FileField = memo(function FileField2({
|
|
|
364
895
|
onChange: (e) => field.onChange(e.target.files),
|
|
365
896
|
onBlur: field.onBlur,
|
|
366
897
|
name: field.name,
|
|
367
|
-
ref: field.ref
|
|
898
|
+
ref: field.ref,
|
|
899
|
+
className: "pl-10"
|
|
368
900
|
}
|
|
369
|
-
)
|
|
370
|
-
/* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Upload, { className: "text-muted-foreground h-4 w-4" }) })
|
|
901
|
+
)
|
|
371
902
|
] });
|
|
372
903
|
} });
|
|
373
904
|
});
|
|
374
905
|
var file_field_default = FileField;
|
|
375
|
-
function
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
906
|
+
function Avatar({
|
|
907
|
+
className,
|
|
908
|
+
...props
|
|
909
|
+
}) {
|
|
910
|
+
return /* @__PURE__ */ jsx(
|
|
911
|
+
AvatarPrimitive.Root,
|
|
912
|
+
{
|
|
913
|
+
"data-slot": "avatar",
|
|
914
|
+
className: cn(
|
|
915
|
+
"relative flex size-8 shrink-0 overflow-hidden rounded-full",
|
|
916
|
+
className
|
|
917
|
+
),
|
|
918
|
+
...props
|
|
919
|
+
}
|
|
920
|
+
);
|
|
921
|
+
}
|
|
922
|
+
function AvatarImage({
|
|
923
|
+
className,
|
|
924
|
+
...props
|
|
925
|
+
}) {
|
|
926
|
+
return /* @__PURE__ */ jsx(
|
|
927
|
+
AvatarPrimitive.Image,
|
|
928
|
+
{
|
|
929
|
+
"data-slot": "avatar-image",
|
|
930
|
+
className: cn("aspect-square size-full", className),
|
|
931
|
+
...props
|
|
932
|
+
}
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
function AvatarFallback({
|
|
936
|
+
className,
|
|
937
|
+
...props
|
|
938
|
+
}) {
|
|
939
|
+
return /* @__PURE__ */ jsx(
|
|
940
|
+
AvatarPrimitive.Fallback,
|
|
941
|
+
{
|
|
942
|
+
"data-slot": "avatar-fallback",
|
|
943
|
+
className: cn(
|
|
944
|
+
"bg-muted flex size-full items-center justify-center rounded-full",
|
|
945
|
+
className
|
|
946
|
+
),
|
|
947
|
+
...props
|
|
948
|
+
}
|
|
949
|
+
);
|
|
950
|
+
}
|
|
384
951
|
var ProfilePictureField = memo(function ProfilePictureField2({
|
|
385
952
|
name,
|
|
386
953
|
label,
|
|
@@ -411,7 +978,7 @@ var ProfilePictureField = memo(function ProfilePictureField2({
|
|
|
411
978
|
}
|
|
412
979
|
),
|
|
413
980
|
/* @__PURE__ */ jsx(
|
|
414
|
-
|
|
981
|
+
Input,
|
|
415
982
|
{
|
|
416
983
|
id: String(name),
|
|
417
984
|
type: "file",
|
|
@@ -434,8 +1001,10 @@ var ProfilePictureField = memo(function ProfilePictureField2({
|
|
|
434
1001
|
}
|
|
435
1002
|
),
|
|
436
1003
|
displayUrl && /* @__PURE__ */ jsx(
|
|
437
|
-
|
|
1004
|
+
Button,
|
|
438
1005
|
{
|
|
1006
|
+
variant: "ghost",
|
|
1007
|
+
size: "sm",
|
|
439
1008
|
type: "button",
|
|
440
1009
|
onClick: () => {
|
|
441
1010
|
field.onChange(null);
|
|
@@ -449,7 +1018,7 @@ var ProfilePictureField = memo(function ProfilePictureField2({
|
|
|
449
1018
|
} });
|
|
450
1019
|
});
|
|
451
1020
|
var profile_picture_field_default = ProfilePictureField;
|
|
452
|
-
var
|
|
1021
|
+
var Button2 = ({ children, ...props }) => /* @__PURE__ */ jsx(
|
|
453
1022
|
"button",
|
|
454
1023
|
{
|
|
455
1024
|
className: "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2",
|
|
@@ -462,23 +1031,15 @@ function Submit({ children, ...props }) {
|
|
|
462
1031
|
const isPending = form.isPending || form.formState.isSubmitting;
|
|
463
1032
|
const { isEditing } = form;
|
|
464
1033
|
if (!isEditing) return null;
|
|
465
|
-
return /* @__PURE__ */ jsx(
|
|
1034
|
+
return /* @__PURE__ */ jsx(Button2, { type: "submit", disabled: isPending || props.disabled, ...props, children: isPending ? "Submitting..." : children });
|
|
466
1035
|
}
|
|
467
1036
|
var submit_default = Submit;
|
|
468
|
-
var Button4 = ({ children, ...props }) => /* @__PURE__ */ jsx(
|
|
469
|
-
"button",
|
|
470
|
-
{
|
|
471
|
-
className: "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2",
|
|
472
|
-
...props,
|
|
473
|
-
children
|
|
474
|
-
}
|
|
475
|
-
);
|
|
476
1037
|
function EditButton({ children, formId, ...props }) {
|
|
477
1038
|
const ctx = useContext(FormContext);
|
|
478
1039
|
if (ctx) {
|
|
479
1040
|
const { isEditing, setIsEditing } = ctx;
|
|
480
1041
|
if (isEditing) return null;
|
|
481
|
-
return /* @__PURE__ */ jsx(
|
|
1042
|
+
return /* @__PURE__ */ jsx(Button, { type: "button", onClick: () => setIsEditing?.(true), ...props, children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
482
1043
|
/* @__PURE__ */ jsx(Pencil, { className: "h-4 w-4 mr-2" }),
|
|
483
1044
|
"Edit Profile"
|
|
484
1045
|
] }) });
|
|
@@ -500,27 +1061,20 @@ function EditButton({ children, formId, ...props }) {
|
|
|
500
1061
|
}
|
|
501
1062
|
}, 100);
|
|
502
1063
|
};
|
|
503
|
-
return /* @__PURE__ */ jsx(
|
|
1064
|
+
return /* @__PURE__ */ jsx(Button, { type: "button", onClick: handleClick, ...props, children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
504
1065
|
/* @__PURE__ */ jsx(Pencil, { className: "h-4 w-4 mr-2" }),
|
|
505
1066
|
"Edit Profile"
|
|
506
1067
|
] }) });
|
|
507
1068
|
}
|
|
508
1069
|
var edit_button_default = EditButton;
|
|
509
|
-
var Button5 = ({ children, className = "", ...props }) => /* @__PURE__ */ jsx(
|
|
510
|
-
"button",
|
|
511
|
-
{
|
|
512
|
-
className: `inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2 ${className}`,
|
|
513
|
-
...props,
|
|
514
|
-
children
|
|
515
|
-
}
|
|
516
|
-
);
|
|
517
1070
|
function CancelButton({ children, ...props }) {
|
|
518
1071
|
const { isEditing, setIsEditing, reset } = useFormCtx();
|
|
519
1072
|
if (!isEditing) return null;
|
|
520
1073
|
return /* @__PURE__ */ jsx(
|
|
521
|
-
|
|
1074
|
+
Button,
|
|
522
1075
|
{
|
|
523
1076
|
type: "button",
|
|
1077
|
+
variant: "outline",
|
|
524
1078
|
onClick: () => {
|
|
525
1079
|
reset();
|
|
526
1080
|
setIsEditing?.(false);
|
|
@@ -534,17 +1088,30 @@ function CancelButton({ children, ...props }) {
|
|
|
534
1088
|
);
|
|
535
1089
|
}
|
|
536
1090
|
var cancel_button_default = CancelButton;
|
|
537
|
-
function LinkField({ label, link, LinkComponent }) {
|
|
1091
|
+
function LinkField({ label, link, LinkComponent, className }) {
|
|
538
1092
|
const LinkTag = LinkComponent || "a";
|
|
539
|
-
const linkProps =
|
|
540
|
-
return /* @__PURE__ */ jsx(
|
|
1093
|
+
const linkProps = { href: link };
|
|
1094
|
+
return /* @__PURE__ */ jsx(
|
|
1095
|
+
LinkTag,
|
|
1096
|
+
{
|
|
1097
|
+
...linkProps,
|
|
1098
|
+
className: cn("text-sm text-primary hover:underline", className),
|
|
1099
|
+
children: label
|
|
1100
|
+
}
|
|
1101
|
+
);
|
|
541
1102
|
}
|
|
542
1103
|
var link_field_default = LinkField;
|
|
543
|
-
|
|
1104
|
+
function FieldGroup({ children, className, title }) {
|
|
1105
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("space-y-4", className), children: [
|
|
1106
|
+
title && /* @__PURE__ */ jsx("h3", { className: "text-lg font-medium", children: title }),
|
|
1107
|
+
children
|
|
1108
|
+
] });
|
|
1109
|
+
}
|
|
544
1110
|
var field_group_default = FieldGroup;
|
|
545
1111
|
|
|
546
1112
|
// src/components/form/index.ts
|
|
547
1113
|
var Form = Object.assign(root_default, {
|
|
1114
|
+
Root: root_default,
|
|
548
1115
|
Field: field_default,
|
|
549
1116
|
InputField: input_field_default,
|
|
550
1117
|
PasswordField: password_field_default,
|
|
@@ -569,21 +1136,26 @@ function useDataTable() {
|
|
|
569
1136
|
}
|
|
570
1137
|
return context;
|
|
571
1138
|
}
|
|
572
|
-
function
|
|
1139
|
+
function Root7({
|
|
573
1140
|
columns,
|
|
574
1141
|
data,
|
|
575
1142
|
filters = [],
|
|
576
1143
|
defaultViewMode = "table",
|
|
1144
|
+
viewMode: controlledViewMode,
|
|
1145
|
+
onViewModeChange: controlledOnViewModeChange,
|
|
577
1146
|
defaultPageSize = 10,
|
|
578
1147
|
children
|
|
579
1148
|
}) {
|
|
580
|
-
const [
|
|
1149
|
+
const [internalViewMode, setInternalViewMode] = useState(defaultViewMode);
|
|
581
1150
|
const [sorting, setSorting] = useState([]);
|
|
582
1151
|
const [columnFilters, setColumnFilters] = useState([]);
|
|
583
1152
|
const [columnVisibility, setColumnVisibility] = useState({});
|
|
584
1153
|
const [globalFilter, setGlobalFilter] = useState("");
|
|
585
1154
|
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: defaultPageSize });
|
|
586
1155
|
const [activeFilters, setActiveFilters] = useState({});
|
|
1156
|
+
const isControlled = controlledViewMode !== void 0 && controlledOnViewModeChange !== void 0;
|
|
1157
|
+
const viewMode = isControlled ? controlledViewMode : internalViewMode;
|
|
1158
|
+
const setViewMode = isControlled ? controlledOnViewModeChange : setInternalViewMode;
|
|
587
1159
|
const filteredData = useMemo(() => {
|
|
588
1160
|
if (Object.keys(activeFilters).length === 0) return data;
|
|
589
1161
|
return data.filter((row) => {
|
|
@@ -634,370 +1206,44 @@ function Root2({
|
|
|
634
1206
|
}
|
|
635
1207
|
);
|
|
636
1208
|
}
|
|
637
|
-
var root_default2 =
|
|
638
|
-
function
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
"data-slot": "input",
|
|
644
|
-
className: cn(
|
|
645
|
-
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
646
|
-
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
647
|
-
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
648
|
-
className
|
|
649
|
-
),
|
|
650
|
-
...props
|
|
651
|
-
}
|
|
652
|
-
);
|
|
653
|
-
}
|
|
654
|
-
function setRef(ref, value) {
|
|
655
|
-
if (typeof ref === "function") {
|
|
656
|
-
return ref(value);
|
|
657
|
-
} else if (ref !== null && ref !== void 0) {
|
|
658
|
-
ref.current = value;
|
|
1209
|
+
var root_default2 = Root7;
|
|
1210
|
+
function ViewOptions({ viewMode: propViewMode, onViewModeChange: propOnViewModeChange }) {
|
|
1211
|
+
let contextStr;
|
|
1212
|
+
try {
|
|
1213
|
+
contextStr = useDataTable();
|
|
1214
|
+
} catch (e) {
|
|
659
1215
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
return (node) => {
|
|
663
|
-
let hasCleanup = false;
|
|
664
|
-
const cleanups = refs.map((ref) => {
|
|
665
|
-
const cleanup = setRef(ref, node);
|
|
666
|
-
if (!hasCleanup && typeof cleanup == "function") {
|
|
667
|
-
hasCleanup = true;
|
|
668
|
-
}
|
|
669
|
-
return cleanup;
|
|
670
|
-
});
|
|
671
|
-
if (hasCleanup) {
|
|
672
|
-
return () => {
|
|
673
|
-
for (let i = 0; i < cleanups.length; i++) {
|
|
674
|
-
const cleanup = cleanups[i];
|
|
675
|
-
if (typeof cleanup == "function") {
|
|
676
|
-
cleanup();
|
|
677
|
-
} else {
|
|
678
|
-
setRef(refs[i], null);
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
};
|
|
682
|
-
}
|
|
683
|
-
};
|
|
684
|
-
}
|
|
685
|
-
// @__NO_SIDE_EFFECTS__
|
|
686
|
-
function createSlot(ownerName) {
|
|
687
|
-
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
688
|
-
const Slot2 = React2.forwardRef((props, forwardedRef) => {
|
|
689
|
-
const { children, ...slotProps } = props;
|
|
690
|
-
const childrenArray = React2.Children.toArray(children);
|
|
691
|
-
const slottable = childrenArray.find(isSlottable);
|
|
692
|
-
if (slottable) {
|
|
693
|
-
const newElement = slottable.props.children;
|
|
694
|
-
const newChildren = childrenArray.map((child) => {
|
|
695
|
-
if (child === slottable) {
|
|
696
|
-
if (React2.Children.count(newElement) > 1) return React2.Children.only(null);
|
|
697
|
-
return React2.isValidElement(newElement) ? newElement.props.children : null;
|
|
698
|
-
} else {
|
|
699
|
-
return child;
|
|
700
|
-
}
|
|
701
|
-
});
|
|
702
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React2.isValidElement(newElement) ? React2.cloneElement(newElement, void 0, newChildren) : null });
|
|
703
|
-
}
|
|
704
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
1216
|
+
const mode = propViewMode ?? contextStr?.viewMode ?? "table";
|
|
1217
|
+
const setMode = propOnViewModeChange ?? contextStr?.setViewMode ?? (() => {
|
|
705
1218
|
});
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
const props2 = mergeProps(slotProps, children.props);
|
|
717
|
-
if (children.type !== React2.Fragment) {
|
|
718
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
719
|
-
}
|
|
720
|
-
return React2.cloneElement(children, props2);
|
|
721
|
-
}
|
|
722
|
-
return React2.Children.count(children) > 1 ? React2.Children.only(null) : null;
|
|
723
|
-
});
|
|
724
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
725
|
-
return SlotClone;
|
|
726
|
-
}
|
|
727
|
-
var SLOTTABLE_IDENTIFIER = /* @__PURE__ */ Symbol("radix.slottable");
|
|
728
|
-
function isSlottable(child) {
|
|
729
|
-
return React2.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
730
|
-
}
|
|
731
|
-
function mergeProps(slotProps, childProps) {
|
|
732
|
-
const overrideProps = { ...childProps };
|
|
733
|
-
for (const propName in childProps) {
|
|
734
|
-
const slotPropValue = slotProps[propName];
|
|
735
|
-
const childPropValue = childProps[propName];
|
|
736
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
737
|
-
if (isHandler) {
|
|
738
|
-
if (slotPropValue && childPropValue) {
|
|
739
|
-
overrideProps[propName] = (...args) => {
|
|
740
|
-
const result = childPropValue(...args);
|
|
741
|
-
slotPropValue(...args);
|
|
742
|
-
return result;
|
|
743
|
-
};
|
|
744
|
-
} else if (slotPropValue) {
|
|
745
|
-
overrideProps[propName] = slotPropValue;
|
|
1219
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center border rounded-md bg-background", children: [
|
|
1220
|
+
/* @__PURE__ */ jsx(
|
|
1221
|
+
Button,
|
|
1222
|
+
{
|
|
1223
|
+
variant: mode === "table" ? "secondary" : "ghost",
|
|
1224
|
+
size: "sm",
|
|
1225
|
+
onClick: () => setMode("table"),
|
|
1226
|
+
className: "rounded-r-none h-8 px-2 lg:px-3",
|
|
1227
|
+
"aria-label": "Switch to table view",
|
|
1228
|
+
children: /* @__PURE__ */ jsx(Table$1, { className: "h-4 w-4" })
|
|
746
1229
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
758
|
-
if (mayWarn) {
|
|
759
|
-
return element.ref;
|
|
760
|
-
}
|
|
761
|
-
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
762
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
763
|
-
if (mayWarn) {
|
|
764
|
-
return element.props.ref;
|
|
765
|
-
}
|
|
766
|
-
return element.props.ref || element.ref;
|
|
767
|
-
}
|
|
768
|
-
var buttonVariants = cva(
|
|
769
|
-
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
770
|
-
{
|
|
771
|
-
variants: {
|
|
772
|
-
variant: {
|
|
773
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
774
|
-
destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
775
|
-
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
776
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
777
|
-
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
778
|
-
link: "text-primary underline-offset-4 hover:underline"
|
|
779
|
-
},
|
|
780
|
-
size: {
|
|
781
|
-
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
782
|
-
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
783
|
-
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
784
|
-
icon: "size-9",
|
|
785
|
-
"icon-sm": "size-8",
|
|
786
|
-
"icon-lg": "size-10"
|
|
1230
|
+
),
|
|
1231
|
+
/* @__PURE__ */ jsx(
|
|
1232
|
+
Button,
|
|
1233
|
+
{
|
|
1234
|
+
variant: mode === "grid" ? "secondary" : "ghost",
|
|
1235
|
+
size: "sm",
|
|
1236
|
+
onClick: () => setMode("grid"),
|
|
1237
|
+
className: "rounded-l-none h-8 px-2 lg:px-3",
|
|
1238
|
+
"aria-label": "Switch to grid view",
|
|
1239
|
+
children: /* @__PURE__ */ jsx(LayoutGrid, { className: "h-4 w-4" })
|
|
787
1240
|
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
variant: "default",
|
|
791
|
-
size: "default"
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
);
|
|
795
|
-
function Button6({
|
|
796
|
-
className,
|
|
797
|
-
variant = "default",
|
|
798
|
-
size = "default",
|
|
799
|
-
asChild = false,
|
|
800
|
-
...props
|
|
801
|
-
}) {
|
|
802
|
-
const Comp = asChild ? Slot : "button";
|
|
803
|
-
return /* @__PURE__ */ jsx(
|
|
804
|
-
Comp,
|
|
805
|
-
{
|
|
806
|
-
"data-slot": "button",
|
|
807
|
-
"data-variant": variant,
|
|
808
|
-
"data-size": size,
|
|
809
|
-
className: cn(buttonVariants({ variant, size, className })),
|
|
810
|
-
...props
|
|
811
|
-
}
|
|
812
|
-
);
|
|
813
|
-
}
|
|
814
|
-
function Select2({
|
|
815
|
-
...props
|
|
816
|
-
}) {
|
|
817
|
-
return /* @__PURE__ */ jsx(SelectPrimitive.Root, { "data-slot": "select", ...props });
|
|
818
|
-
}
|
|
819
|
-
function SelectValue2({
|
|
820
|
-
...props
|
|
821
|
-
}) {
|
|
822
|
-
return /* @__PURE__ */ jsx(SelectPrimitive.Value, { "data-slot": "select-value", ...props });
|
|
823
|
-
}
|
|
824
|
-
function SelectTrigger({
|
|
825
|
-
className,
|
|
826
|
-
size = "default",
|
|
827
|
-
children,
|
|
828
|
-
...props
|
|
829
|
-
}) {
|
|
830
|
-
return /* @__PURE__ */ jsxs(
|
|
831
|
-
SelectPrimitive.Trigger,
|
|
832
|
-
{
|
|
833
|
-
"data-slot": "select-trigger",
|
|
834
|
-
"data-size": size,
|
|
835
|
-
className: cn(
|
|
836
|
-
"border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
837
|
-
className
|
|
838
|
-
),
|
|
839
|
-
...props,
|
|
840
|
-
children: [
|
|
841
|
-
children,
|
|
842
|
-
/* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-4 opacity-50" }) })
|
|
843
|
-
]
|
|
844
|
-
}
|
|
845
|
-
);
|
|
846
|
-
}
|
|
847
|
-
function SelectContent({
|
|
848
|
-
className,
|
|
849
|
-
children,
|
|
850
|
-
position = "item-aligned",
|
|
851
|
-
align = "center",
|
|
852
|
-
...props
|
|
853
|
-
}) {
|
|
854
|
-
return /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
|
|
855
|
-
SelectPrimitive.Content,
|
|
856
|
-
{
|
|
857
|
-
"data-slot": "select-content",
|
|
858
|
-
className: cn(
|
|
859
|
-
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
|
|
860
|
-
position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
861
|
-
className
|
|
862
|
-
),
|
|
863
|
-
position,
|
|
864
|
-
align,
|
|
865
|
-
...props,
|
|
866
|
-
children: [
|
|
867
|
-
/* @__PURE__ */ jsx(SelectScrollUpButton, {}),
|
|
868
|
-
/* @__PURE__ */ jsx(
|
|
869
|
-
SelectPrimitive.Viewport,
|
|
870
|
-
{
|
|
871
|
-
className: cn(
|
|
872
|
-
"p-1",
|
|
873
|
-
position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
|
|
874
|
-
),
|
|
875
|
-
children
|
|
876
|
-
}
|
|
877
|
-
),
|
|
878
|
-
/* @__PURE__ */ jsx(SelectScrollDownButton, {})
|
|
879
|
-
]
|
|
880
|
-
}
|
|
881
|
-
) });
|
|
882
|
-
}
|
|
883
|
-
function SelectItem2({
|
|
884
|
-
className,
|
|
885
|
-
children,
|
|
886
|
-
...props
|
|
887
|
-
}) {
|
|
888
|
-
return /* @__PURE__ */ jsxs(
|
|
889
|
-
SelectPrimitive.Item,
|
|
890
|
-
{
|
|
891
|
-
"data-slot": "select-item",
|
|
892
|
-
className: cn(
|
|
893
|
-
"focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
|
894
|
-
className
|
|
895
|
-
),
|
|
896
|
-
...props,
|
|
897
|
-
children: [
|
|
898
|
-
/* @__PURE__ */ jsx(
|
|
899
|
-
"span",
|
|
900
|
-
{
|
|
901
|
-
"data-slot": "select-item-indicator",
|
|
902
|
-
className: "absolute right-2 flex size-3.5 items-center justify-center",
|
|
903
|
-
children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4" }) })
|
|
904
|
-
}
|
|
905
|
-
),
|
|
906
|
-
/* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children })
|
|
907
|
-
]
|
|
908
|
-
}
|
|
909
|
-
);
|
|
910
|
-
}
|
|
911
|
-
function SelectScrollUpButton({
|
|
912
|
-
className,
|
|
913
|
-
...props
|
|
914
|
-
}) {
|
|
915
|
-
return /* @__PURE__ */ jsx(
|
|
916
|
-
SelectPrimitive.ScrollUpButton,
|
|
917
|
-
{
|
|
918
|
-
"data-slot": "select-scroll-up-button",
|
|
919
|
-
className: cn(
|
|
920
|
-
"flex cursor-default items-center justify-center py-1",
|
|
921
|
-
className
|
|
922
|
-
),
|
|
923
|
-
...props,
|
|
924
|
-
children: /* @__PURE__ */ jsx(ChevronUpIcon, { className: "size-4" })
|
|
925
|
-
}
|
|
926
|
-
);
|
|
927
|
-
}
|
|
928
|
-
function SelectScrollDownButton({
|
|
929
|
-
className,
|
|
930
|
-
...props
|
|
931
|
-
}) {
|
|
932
|
-
return /* @__PURE__ */ jsx(
|
|
933
|
-
SelectPrimitive.ScrollDownButton,
|
|
934
|
-
{
|
|
935
|
-
"data-slot": "select-scroll-down-button",
|
|
936
|
-
className: cn(
|
|
937
|
-
"flex cursor-default items-center justify-center py-1",
|
|
938
|
-
className
|
|
939
|
-
),
|
|
940
|
-
...props,
|
|
941
|
-
children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-4" })
|
|
942
|
-
}
|
|
943
|
-
);
|
|
944
|
-
}
|
|
945
|
-
function Popover({
|
|
946
|
-
...props
|
|
947
|
-
}) {
|
|
948
|
-
return /* @__PURE__ */ jsx(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
|
|
949
|
-
}
|
|
950
|
-
function PopoverTrigger({
|
|
951
|
-
...props
|
|
952
|
-
}) {
|
|
953
|
-
return /* @__PURE__ */ jsx(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
|
|
954
|
-
}
|
|
955
|
-
function PopoverContent({
|
|
956
|
-
className,
|
|
957
|
-
align = "center",
|
|
958
|
-
sideOffset = 4,
|
|
959
|
-
...props
|
|
960
|
-
}) {
|
|
961
|
-
return /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
962
|
-
PopoverPrimitive.Content,
|
|
963
|
-
{
|
|
964
|
-
"data-slot": "popover-content",
|
|
965
|
-
align,
|
|
966
|
-
sideOffset,
|
|
967
|
-
className: cn(
|
|
968
|
-
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
|
|
969
|
-
className
|
|
970
|
-
),
|
|
971
|
-
...props
|
|
972
|
-
}
|
|
973
|
-
) });
|
|
974
|
-
}
|
|
975
|
-
function Checkbox2({
|
|
976
|
-
className,
|
|
977
|
-
...props
|
|
978
|
-
}) {
|
|
979
|
-
return /* @__PURE__ */ jsx(
|
|
980
|
-
CheckboxPrimitive.Root,
|
|
981
|
-
{
|
|
982
|
-
"data-slot": "checkbox",
|
|
983
|
-
className: cn(
|
|
984
|
-
"peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
|
|
985
|
-
className
|
|
986
|
-
),
|
|
987
|
-
...props,
|
|
988
|
-
children: /* @__PURE__ */ jsx(
|
|
989
|
-
CheckboxPrimitive.Indicator,
|
|
990
|
-
{
|
|
991
|
-
"data-slot": "checkbox-indicator",
|
|
992
|
-
className: "grid place-content-center text-current transition-none",
|
|
993
|
-
children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-3.5" })
|
|
994
|
-
}
|
|
995
|
-
)
|
|
996
|
-
}
|
|
997
|
-
);
|
|
1241
|
+
)
|
|
1242
|
+
] });
|
|
998
1243
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
1244
|
+
var view_options_default = ViewOptions;
|
|
1245
|
+
function Toolbar({ viewOptions } = {}) {
|
|
1246
|
+
const { table, filters, activeFilters, setActiveFilters } = useDataTable();
|
|
1001
1247
|
const handleFilterChange = (filterId, value) => {
|
|
1002
1248
|
setActiveFilters((prev) => ({
|
|
1003
1249
|
...prev,
|
|
@@ -1014,115 +1260,116 @@ function Toolbar() {
|
|
|
1014
1260
|
return { ...prev, [filterId]: newValues };
|
|
1015
1261
|
});
|
|
1016
1262
|
};
|
|
1017
|
-
return /* @__PURE__ */ jsxs("div", { className: "
|
|
1018
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
1019
|
-
|
|
1263
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-4 py-4", children: [
|
|
1264
|
+
/* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsx(
|
|
1265
|
+
Input,
|
|
1020
1266
|
{
|
|
1021
1267
|
placeholder: "Search...",
|
|
1022
1268
|
value: table.getState().globalFilter ?? "",
|
|
1023
1269
|
onChange: (e) => table.setGlobalFilter(e.target.value),
|
|
1024
|
-
className: "w-full"
|
|
1270
|
+
className: "w-full max-w-sm"
|
|
1025
1271
|
}
|
|
1026
1272
|
) }),
|
|
1027
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center
|
|
1028
|
-
|
|
1029
|
-
/* @__PURE__ */ jsx(
|
|
1030
|
-
/* @__PURE__ */ jsx(
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
/* @__PURE__ */
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1273
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4", children: [
|
|
1274
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-wrap flex-1", children: [
|
|
1275
|
+
filters.map((filter) => /* @__PURE__ */ jsx("div", { children: filter.multiSelect ? /* @__PURE__ */ jsxs(Popover, { children: [
|
|
1276
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", className: "h-8 border-dashed", children: [
|
|
1277
|
+
/* @__PURE__ */ jsx(SlidersHorizontal, { className: "h-4 w-4 mr-2" }),
|
|
1278
|
+
filter.label,
|
|
1279
|
+
activeFilters[filter.id] && (Array.isArray(activeFilters[filter.id]) ? activeFilters[filter.id].length > 0 : true) && /* @__PURE__ */ jsx("span", { className: "ml-1 rounded-sm bg-primary px-1 text-xs text-primary-foreground", children: Array.isArray(activeFilters[filter.id]) ? activeFilters[filter.id].length : 1 })
|
|
1280
|
+
] }) }),
|
|
1281
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-[200px] p-0", align: "start", children: /* @__PURE__ */ jsxs("div", { className: "p-1", children: [
|
|
1282
|
+
filter.options.map((option) => /* @__PURE__ */ jsxs(
|
|
1283
|
+
"div",
|
|
1284
|
+
{
|
|
1285
|
+
className: "flex items-center space-x-2 rounded-sm px-2 py-1.5 hover:bg-accent cursor-pointer",
|
|
1286
|
+
onClick: () => handleMultiFilterToggle(filter.id, option.value),
|
|
1287
|
+
children: [
|
|
1288
|
+
/* @__PURE__ */ jsx(
|
|
1289
|
+
Checkbox,
|
|
1290
|
+
{
|
|
1291
|
+
id: `${filter.id}-${option.value}`,
|
|
1292
|
+
checked: Array.isArray(activeFilters[filter.id]) && activeFilters[filter.id].includes(option.value)
|
|
1293
|
+
}
|
|
1294
|
+
),
|
|
1295
|
+
/* @__PURE__ */ jsx(
|
|
1296
|
+
"label",
|
|
1297
|
+
{
|
|
1298
|
+
htmlFor: `${filter.id}-${option.value}`,
|
|
1299
|
+
className: "text-sm cursor-pointer flex-1",
|
|
1300
|
+
children: option.label
|
|
1301
|
+
}
|
|
1302
|
+
)
|
|
1303
|
+
]
|
|
1304
|
+
},
|
|
1305
|
+
option.value
|
|
1306
|
+
)),
|
|
1307
|
+
activeFilters[filter.id] && (Array.isArray(activeFilters[filter.id]) ? activeFilters[filter.id].length > 0 : false) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1308
|
+
/* @__PURE__ */ jsx("div", { className: "h-px bg-border my-1" }),
|
|
1046
1309
|
/* @__PURE__ */ jsx(
|
|
1047
|
-
"
|
|
1310
|
+
"div",
|
|
1048
1311
|
{
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
children:
|
|
1312
|
+
className: "px-2 py-1.5 text-center text-sm cursor-pointer hover:bg-accent rounded-sm",
|
|
1313
|
+
onClick: () => setActiveFilters((prev) => ({ ...prev, [filter.id]: [] })),
|
|
1314
|
+
children: "Clear filters"
|
|
1052
1315
|
}
|
|
1053
1316
|
)
|
|
1054
|
-
] }
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
onValueChange: (value) => handleFilterChange(filter.id, value),
|
|
1059
|
-
children: [
|
|
1060
|
-
/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue2, { placeholder: filter.placeholder || "Select..." }) }),
|
|
1061
|
-
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
1062
|
-
/* @__PURE__ */ jsx(SelectItem2, { value: "all", children: "All" }),
|
|
1063
|
-
filter.options.map((option) => /* @__PURE__ */ jsx(SelectItem2, { value: option.value, children: option.label }, option.value))
|
|
1064
|
-
] })
|
|
1065
|
-
]
|
|
1066
|
-
}
|
|
1067
|
-
)
|
|
1068
|
-
] }, filter.id))
|
|
1069
|
-
] }) })
|
|
1070
|
-
] }),
|
|
1071
|
-
/* @__PURE__ */ jsxs(Popover, { children: [
|
|
1072
|
-
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button6, { variant: "outline", size: "sm", children: [
|
|
1073
|
-
/* @__PURE__ */ jsx(Eye, { className: "h-4 w-4 mr-2" }),
|
|
1074
|
-
"Columns"
|
|
1075
|
-
] }) }),
|
|
1076
|
-
/* @__PURE__ */ jsx(PopoverContent, { className: "w-56", children: /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
1077
|
-
/* @__PURE__ */ jsx("h4", { className: "font-medium text-sm", children: "Toggle Columns" }),
|
|
1078
|
-
table.getAllColumns().filter((column) => column.getCanHide()).map((column) => /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
1079
|
-
/* @__PURE__ */ jsx(
|
|
1080
|
-
Checkbox2,
|
|
1081
|
-
{
|
|
1082
|
-
id: column.id,
|
|
1083
|
-
checked: column.getIsVisible(),
|
|
1084
|
-
onCheckedChange: (value) => column.toggleVisibility(!!value)
|
|
1085
|
-
}
|
|
1086
|
-
),
|
|
1087
|
-
/* @__PURE__ */ jsx("label", { htmlFor: column.id, className: "text-sm cursor-pointer", children: column.id })
|
|
1088
|
-
] }, column.id))
|
|
1089
|
-
] }) })
|
|
1090
|
-
] }),
|
|
1091
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center border rounded-md", children: [
|
|
1092
|
-
/* @__PURE__ */ jsx(
|
|
1093
|
-
Button6,
|
|
1094
|
-
{
|
|
1095
|
-
variant: viewMode === "table" ? "default" : "ghost",
|
|
1096
|
-
size: "sm",
|
|
1097
|
-
onClick: () => setViewMode("table"),
|
|
1098
|
-
className: "rounded-r-none",
|
|
1099
|
-
children: /* @__PURE__ */ jsx(Table$1, { className: "h-4 w-4" })
|
|
1100
|
-
}
|
|
1101
|
-
),
|
|
1102
|
-
/* @__PURE__ */ jsx(
|
|
1103
|
-
Button6,
|
|
1104
|
-
{
|
|
1105
|
-
variant: viewMode === "grid" ? "default" : "ghost",
|
|
1106
|
-
size: "sm",
|
|
1107
|
-
onClick: () => setViewMode("grid"),
|
|
1108
|
-
className: "rounded-l-none",
|
|
1109
|
-
children: /* @__PURE__ */ jsx(LayoutGrid, { className: "h-4 w-4" })
|
|
1110
|
-
}
|
|
1111
|
-
)
|
|
1112
|
-
] }),
|
|
1113
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1114
|
-
/* @__PURE__ */ jsx("label", { className: "text-sm text-muted-foreground", children: "Rows" }),
|
|
1115
|
-
/* @__PURE__ */ jsxs(
|
|
1116
|
-
Select2,
|
|
1317
|
+
] })
|
|
1318
|
+
] }) })
|
|
1319
|
+
] }) : /* @__PURE__ */ jsxs(
|
|
1320
|
+
Select,
|
|
1117
1321
|
{
|
|
1118
|
-
value:
|
|
1119
|
-
onValueChange: (value) =>
|
|
1322
|
+
value: activeFilters[filter.id] || "all",
|
|
1323
|
+
onValueChange: (value) => handleFilterChange(filter.id, value),
|
|
1120
1324
|
children: [
|
|
1121
|
-
/* @__PURE__ */ jsx(SelectTrigger, { className: "w-
|
|
1122
|
-
/* @__PURE__ */
|
|
1325
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-8 w-[150px] border-dashed", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: filter.placeholder || filter.label }) }),
|
|
1326
|
+
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
1327
|
+
/* @__PURE__ */ jsxs(SelectItem, { value: "all", children: [
|
|
1328
|
+
"All ",
|
|
1329
|
+
filter.label
|
|
1330
|
+
] }),
|
|
1331
|
+
filter.options.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label }, option.value))
|
|
1332
|
+
] })
|
|
1123
1333
|
]
|
|
1124
1334
|
}
|
|
1125
|
-
)
|
|
1335
|
+
) }, filter.id)),
|
|
1336
|
+
/* @__PURE__ */ jsxs(Popover, { children: [
|
|
1337
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", className: "h-8 ml-auto sm:ml-0", children: [
|
|
1338
|
+
/* @__PURE__ */ jsx(Eye, { className: "h-4 w-4 mr-2" }),
|
|
1339
|
+
"Columns"
|
|
1340
|
+
] }) }),
|
|
1341
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-56", align: "end", children: /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
1342
|
+
/* @__PURE__ */ jsx("h4", { className: "font-medium text-sm", children: "Toggle Columns" }),
|
|
1343
|
+
table.getAllColumns().filter((column) => column.getCanHide()).map((column) => /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
1344
|
+
/* @__PURE__ */ jsx(
|
|
1345
|
+
Checkbox,
|
|
1346
|
+
{
|
|
1347
|
+
id: column.id,
|
|
1348
|
+
checked: column.getIsVisible(),
|
|
1349
|
+
onCheckedChange: (value) => column.toggleVisibility(!!value)
|
|
1350
|
+
}
|
|
1351
|
+
),
|
|
1352
|
+
/* @__PURE__ */ jsx("label", { htmlFor: column.id, className: "text-sm cursor-pointer", children: column.id })
|
|
1353
|
+
] }, column.id))
|
|
1354
|
+
] }) })
|
|
1355
|
+
] })
|
|
1356
|
+
] }),
|
|
1357
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1358
|
+
viewOptions ? viewOptions : /* @__PURE__ */ jsx(ViewOptions, {}),
|
|
1359
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1360
|
+
/* @__PURE__ */ jsx("label", { className: "text-sm text-muted-foreground whitespace-nowrap hidden sm:inline-block", children: "Rows" }),
|
|
1361
|
+
/* @__PURE__ */ jsxs(
|
|
1362
|
+
Select,
|
|
1363
|
+
{
|
|
1364
|
+
value: String(table.getState().pagination.pageSize),
|
|
1365
|
+
onValueChange: (value) => table.setPageSize(Number(value)),
|
|
1366
|
+
children: [
|
|
1367
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "w-16 h-8", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
1368
|
+
/* @__PURE__ */ jsx(SelectContent, { children: [10, 20, 30, 40, 50].map((size) => /* @__PURE__ */ jsx(SelectItem, { value: String(size), children: size }, size)) })
|
|
1369
|
+
]
|
|
1370
|
+
}
|
|
1371
|
+
)
|
|
1372
|
+
] })
|
|
1126
1373
|
] })
|
|
1127
1374
|
] })
|
|
1128
1375
|
] });
|
|
@@ -1248,6 +1495,7 @@ function GridView({ renderCard, columns = 3, gap = 16 }) {
|
|
|
1248
1495
|
);
|
|
1249
1496
|
}
|
|
1250
1497
|
function DefaultCard({ item }) {
|
|
1498
|
+
if (typeof item !== "object" || item === null) return null;
|
|
1251
1499
|
return /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(item).map(([key, value]) => /* @__PURE__ */ jsxs("div", { children: [
|
|
1252
1500
|
/* @__PURE__ */ jsxs("span", { className: "text-sm font-medium", children: [
|
|
1253
1501
|
key,
|
|
@@ -1284,7 +1532,7 @@ function Pagination() {
|
|
|
1284
1532
|
] }),
|
|
1285
1533
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1286
1534
|
/* @__PURE__ */ jsx(
|
|
1287
|
-
|
|
1535
|
+
Button,
|
|
1288
1536
|
{
|
|
1289
1537
|
variant: "outline",
|
|
1290
1538
|
size: "sm",
|
|
@@ -1300,7 +1548,7 @@ function Pagination() {
|
|
|
1300
1548
|
table.getPageCount()
|
|
1301
1549
|
] }),
|
|
1302
1550
|
/* @__PURE__ */ jsx(
|
|
1303
|
-
|
|
1551
|
+
Button,
|
|
1304
1552
|
{
|
|
1305
1553
|
variant: "outline",
|
|
1306
1554
|
size: "sm",
|
|
@@ -1316,11 +1564,13 @@ var pagination_default = Pagination;
|
|
|
1316
1564
|
|
|
1317
1565
|
// src/components/data-table/index.tsx
|
|
1318
1566
|
var DataTable = Object.assign(root_default2, {
|
|
1567
|
+
Root: root_default2,
|
|
1319
1568
|
Toolbar: toolbar_default,
|
|
1320
1569
|
Content: content_default,
|
|
1321
1570
|
TableView: table_view_default,
|
|
1322
1571
|
GridView: grid_view_default,
|
|
1323
|
-
Pagination: pagination_default
|
|
1572
|
+
Pagination: pagination_default,
|
|
1573
|
+
ViewOptions: view_options_default
|
|
1324
1574
|
});
|
|
1325
1575
|
var data_table_default = DataTable;
|
|
1326
1576
|
|