hazo_ui 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,849 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var React6 = require('react');
5
+ var reactSlot = require('@radix-ui/react-slot');
6
+ var classVarianceAuthority = require('class-variance-authority');
7
+ var clsx = require('clsx');
8
+ var tailwindMerge = require('tailwind-merge');
9
+ var DialogPrimitive = require('@radix-ui/react-dialog');
10
+ var lucideReact = require('lucide-react');
11
+ var PopoverPrimitive = require('@radix-ui/react-popover');
12
+ var SelectPrimitive = require('@radix-ui/react-select');
13
+ var TooltipPrimitive = require('@radix-ui/react-tooltip');
14
+ var reactDayPicker = require('react-day-picker');
15
+ var dateFns = require('date-fns');
16
+
17
+ function _interopNamespace(e) {
18
+ if (e && e.__esModule) return e;
19
+ var n = Object.create(null);
20
+ if (e) {
21
+ Object.keys(e).forEach(function (k) {
22
+ if (k !== 'default') {
23
+ var d = Object.getOwnPropertyDescriptor(e, k);
24
+ Object.defineProperty(n, k, d.get ? d : {
25
+ enumerable: true,
26
+ get: function () { return e[k]; }
27
+ });
28
+ }
29
+ });
30
+ }
31
+ n.default = e;
32
+ return Object.freeze(n);
33
+ }
34
+
35
+ var React6__namespace = /*#__PURE__*/_interopNamespace(React6);
36
+ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
37
+ var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
38
+ var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
39
+ var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
40
+
41
+ var ExampleComponent = ({ children, className = "" }) => {
42
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `cls_example_component ${className}`, children });
43
+ };
44
+ function cn(...inputs) {
45
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
46
+ }
47
+ var buttonVariants = classVarianceAuthority.cva(
48
+ "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",
49
+ {
50
+ variants: {
51
+ variant: {
52
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
53
+ destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
54
+ outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
55
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
56
+ ghost: "hover:bg-accent hover:text-accent-foreground",
57
+ link: "text-primary underline-offset-4 hover:underline"
58
+ },
59
+ size: {
60
+ default: "h-10 px-4 py-2",
61
+ sm: "h-9 rounded-md px-3",
62
+ lg: "h-11 rounded-md px-8",
63
+ icon: "h-10 w-10"
64
+ }
65
+ },
66
+ defaultVariants: {
67
+ variant: "default",
68
+ size: "default"
69
+ }
70
+ }
71
+ );
72
+ var Button = React6__namespace.forwardRef(
73
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
74
+ const Comp = asChild ? reactSlot.Slot : "button";
75
+ return /* @__PURE__ */ jsxRuntime.jsx(
76
+ Comp,
77
+ {
78
+ className: cn(buttonVariants({ variant, size, className })),
79
+ ref,
80
+ ...props
81
+ }
82
+ );
83
+ }
84
+ );
85
+ Button.displayName = "Button";
86
+ var Dialog = DialogPrimitive__namespace.Root;
87
+ var DialogTrigger = DialogPrimitive__namespace.Trigger;
88
+ var DialogPortal = DialogPrimitive__namespace.Portal;
89
+ var DialogOverlay = React6__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
90
+ DialogPrimitive__namespace.Overlay,
91
+ {
92
+ ref,
93
+ className: cn(
94
+ "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
95
+ className
96
+ ),
97
+ ...props
98
+ }
99
+ ));
100
+ DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
101
+ var DialogContent = React6__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
102
+ /* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
103
+ /* @__PURE__ */ jsxRuntime.jsxs(
104
+ DialogPrimitive__namespace.Content,
105
+ {
106
+ ref,
107
+ className: cn(
108
+ "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
109
+ className
110
+ ),
111
+ ...props,
112
+ children: [
113
+ children,
114
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogPrimitive__namespace.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
115
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4" }),
116
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close" })
117
+ ] })
118
+ ]
119
+ }
120
+ )
121
+ ] }));
122
+ DialogContent.displayName = DialogPrimitive__namespace.Content.displayName;
123
+ var DialogHeader = ({
124
+ className,
125
+ ...props
126
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
127
+ "div",
128
+ {
129
+ className: cn(
130
+ "flex flex-col space-y-1.5 text-center sm:text-left",
131
+ className
132
+ ),
133
+ ...props
134
+ }
135
+ );
136
+ DialogHeader.displayName = "DialogHeader";
137
+ var DialogFooter = ({
138
+ className,
139
+ ...props
140
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
141
+ "div",
142
+ {
143
+ className: cn(
144
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
145
+ className
146
+ ),
147
+ ...props
148
+ }
149
+ );
150
+ DialogFooter.displayName = "DialogFooter";
151
+ var DialogTitle = React6__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
152
+ DialogPrimitive__namespace.Title,
153
+ {
154
+ ref,
155
+ className: cn(
156
+ "text-lg font-semibold leading-none tracking-tight",
157
+ className
158
+ ),
159
+ ...props
160
+ }
161
+ ));
162
+ DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
163
+ var DialogDescription = React6__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
164
+ DialogPrimitive__namespace.Description,
165
+ {
166
+ ref,
167
+ className: cn("text-sm text-muted-foreground", className),
168
+ ...props
169
+ }
170
+ ));
171
+ DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
172
+ var Command = React6__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
173
+ "div",
174
+ {
175
+ ref,
176
+ className: cn(
177
+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
178
+ className
179
+ ),
180
+ ...props
181
+ }
182
+ ));
183
+ Command.displayName = "Command";
184
+ var CommandInput = React6__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
185
+ "input",
186
+ {
187
+ ref,
188
+ className: cn(
189
+ "flex h-11 w-full rounded-md border border-input bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50 px-3",
190
+ className
191
+ ),
192
+ ...props
193
+ }
194
+ ));
195
+ CommandInput.displayName = "CommandInput";
196
+ var CommandList = React6__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
197
+ "div",
198
+ {
199
+ ref,
200
+ className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className),
201
+ ...props
202
+ }
203
+ ));
204
+ CommandList.displayName = "CommandList";
205
+ var CommandEmpty = React6__namespace.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
206
+ "div",
207
+ {
208
+ ref,
209
+ className: "py-6 text-center text-sm",
210
+ ...props
211
+ }
212
+ ));
213
+ CommandEmpty.displayName = "CommandEmpty";
214
+ var CommandGroup = React6__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
215
+ "div",
216
+ {
217
+ ref,
218
+ className: cn(
219
+ "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
220
+ className
221
+ ),
222
+ ...props
223
+ }
224
+ ));
225
+ CommandGroup.displayName = "CommandGroup";
226
+ var CommandItem = React6__namespace.forwardRef(({ className, onSelect, value, ...props }, ref) => {
227
+ const handleClick = () => {
228
+ if (onSelect && value) {
229
+ onSelect(value);
230
+ }
231
+ };
232
+ return /* @__PURE__ */ jsxRuntime.jsx(
233
+ "div",
234
+ {
235
+ ref,
236
+ className: cn(
237
+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
238
+ className
239
+ ),
240
+ onClick: handleClick,
241
+ ...props
242
+ }
243
+ );
244
+ });
245
+ CommandItem.displayName = "CommandItem";
246
+ var Popover = PopoverPrimitive__namespace.Root;
247
+ var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
248
+ var PopoverContent = React6__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
249
+ PopoverPrimitive__namespace.Content,
250
+ {
251
+ ref,
252
+ align,
253
+ sideOffset,
254
+ className: cn(
255
+ "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",
256
+ className
257
+ ),
258
+ ...props
259
+ }
260
+ ) }));
261
+ PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
262
+ var Input = React6__namespace.forwardRef(
263
+ ({ className, type, ...props }, ref) => {
264
+ return /* @__PURE__ */ jsxRuntime.jsx(
265
+ "input",
266
+ {
267
+ type,
268
+ className: cn(
269
+ "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
270
+ className
271
+ ),
272
+ ref,
273
+ ...props
274
+ }
275
+ );
276
+ }
277
+ );
278
+ Input.displayName = "Input";
279
+ var Select = SelectPrimitive__namespace.Root;
280
+ var SelectValue = SelectPrimitive__namespace.Value;
281
+ var SelectTrigger = React6__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
282
+ SelectPrimitive__namespace.Trigger,
283
+ {
284
+ ref,
285
+ className: cn(
286
+ "flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
287
+ className
288
+ ),
289
+ ...props,
290
+ children: [
291
+ children,
292
+ /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Icon, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-4 w-4 opacity-50" }) })
293
+ ]
294
+ }
295
+ ));
296
+ SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
297
+ var SelectScrollUpButton = React6__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
298
+ SelectPrimitive__namespace.ScrollUpButton,
299
+ {
300
+ ref,
301
+ className: cn(
302
+ "flex cursor-default items-center justify-center py-1",
303
+ className
304
+ ),
305
+ ...props,
306
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { className: "h-4 w-4" })
307
+ }
308
+ ));
309
+ SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
310
+ var SelectScrollDownButton = React6__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
311
+ SelectPrimitive__namespace.ScrollDownButton,
312
+ {
313
+ ref,
314
+ className: cn(
315
+ "flex cursor-default items-center justify-center py-1",
316
+ className
317
+ ),
318
+ ...props,
319
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-4 w-4" })
320
+ }
321
+ ));
322
+ SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
323
+ var SelectContent = React6__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
324
+ SelectPrimitive__namespace.Content,
325
+ {
326
+ ref,
327
+ className: cn(
328
+ "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",
329
+ 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",
330
+ className
331
+ ),
332
+ position,
333
+ ...props,
334
+ children: [
335
+ /* @__PURE__ */ jsxRuntime.jsx(SelectScrollUpButton, {}),
336
+ /* @__PURE__ */ jsxRuntime.jsx(
337
+ SelectPrimitive__namespace.Viewport,
338
+ {
339
+ className: cn(
340
+ "p-1",
341
+ position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
342
+ ),
343
+ children
344
+ }
345
+ ),
346
+ /* @__PURE__ */ jsxRuntime.jsx(SelectScrollDownButton, {})
347
+ ]
348
+ }
349
+ ) }));
350
+ SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
351
+ var SelectLabel = React6__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
352
+ SelectPrimitive__namespace.Label,
353
+ {
354
+ ref,
355
+ className: cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className),
356
+ ...props
357
+ }
358
+ ));
359
+ SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
360
+ var SelectItem = React6__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
361
+ SelectPrimitive__namespace.Item,
362
+ {
363
+ ref,
364
+ className: cn(
365
+ "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
366
+ className
367
+ ),
368
+ ...props,
369
+ children: [
370
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" }) }) }),
371
+ /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemText, { children })
372
+ ]
373
+ }
374
+ ));
375
+ SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
376
+ var SelectSeparator = React6__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
377
+ SelectPrimitive__namespace.Separator,
378
+ {
379
+ ref,
380
+ className: cn("-mx-1 my-1 h-px bg-muted", className),
381
+ ...props
382
+ }
383
+ ));
384
+ SelectSeparator.displayName = SelectPrimitive__namespace.Separator.displayName;
385
+ var TooltipProvider = TooltipPrimitive__namespace.Provider;
386
+ var Tooltip = TooltipPrimitive__namespace.Root;
387
+ var TooltipTrigger = TooltipPrimitive__namespace.Trigger;
388
+ var TooltipContent = React6__namespace.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
389
+ TooltipPrimitive__namespace.Content,
390
+ {
391
+ ref,
392
+ sideOffset,
393
+ className: cn(
394
+ "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground 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",
395
+ className
396
+ ),
397
+ ...props
398
+ }
399
+ ));
400
+ TooltipContent.displayName = TooltipPrimitive__namespace.Content.displayName;
401
+ function Calendar({
402
+ className,
403
+ classNames,
404
+ showOutsideDays = true,
405
+ ...props
406
+ }) {
407
+ return /* @__PURE__ */ jsxRuntime.jsx(
408
+ reactDayPicker.DayPicker,
409
+ {
410
+ showOutsideDays,
411
+ className: cn("p-3", className),
412
+ classNames: {
413
+ months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
414
+ month: "space-y-4",
415
+ caption: "flex justify-center pt-1 relative items-center",
416
+ caption_label: "text-sm font-medium",
417
+ nav: "space-x-1 flex items-center",
418
+ nav_button: cn(
419
+ "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
420
+ ),
421
+ nav_button_previous: "absolute left-1",
422
+ nav_button_next: "absolute right-1",
423
+ table: "w-full border-collapse space-y-1",
424
+ head_row: "flex",
425
+ head_cell: "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
426
+ row: "flex w-full mt-2",
427
+ cell: "h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",
428
+ day: cn(
429
+ "h-9 w-9 p-0 font-normal aria-selected:opacity-100"
430
+ ),
431
+ day_range_end: "day-range-end",
432
+ day_selected: "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
433
+ day_today: "bg-accent text-accent-foreground",
434
+ day_outside: "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
435
+ day_disabled: "text-muted-foreground opacity-50",
436
+ day_range_middle: "aria-selected:bg-accent aria-selected:text-accent-foreground",
437
+ day_hidden: "invisible",
438
+ ...classNames
439
+ },
440
+ components: {
441
+ IconLeft: () => /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4" }),
442
+ IconRight: () => /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4" })
443
+ },
444
+ ...props
445
+ }
446
+ );
447
+ }
448
+ Calendar.displayName = "Calendar";
449
+ function FilterFieldItem({
450
+ filterConfig,
451
+ fieldConfig,
452
+ onValueChange,
453
+ onOperatorChange,
454
+ onDelete
455
+ }) {
456
+ const [isCalendarOpen, setIsCalendarOpen] = React6.useState(false);
457
+ const renderInput = () => {
458
+ switch (fieldConfig.type) {
459
+ case "text":
460
+ return /* @__PURE__ */ jsxRuntime.jsx(
461
+ Input,
462
+ {
463
+ type: "text",
464
+ value: filterConfig.value || "",
465
+ onChange: (e) => {
466
+ const value = e.target.value;
467
+ if (fieldConfig.textConfig?.maxLength && value.length > fieldConfig.textConfig.maxLength) {
468
+ return;
469
+ }
470
+ onValueChange(value);
471
+ },
472
+ placeholder: "Enter text...",
473
+ minLength: fieldConfig.textConfig?.minLength,
474
+ maxLength: fieldConfig.textConfig?.maxLength,
475
+ className: "cls_filter_text_input w-full min-w-0"
476
+ }
477
+ );
478
+ case "number":
479
+ const numberOperators = [
480
+ { value: "equals", label: "Equals" },
481
+ { value: "not_equals", label: "Not Equals" },
482
+ { value: "greater_than", label: "Greater Than" },
483
+ { value: "less_than", label: "Less Than" },
484
+ { value: "greater_equal", label: "Greater or Equal" },
485
+ { value: "less_equal", label: "Less or Equal" }
486
+ ];
487
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_number_filter_container flex flex-col sm:flex-row items-stretch sm:items-center gap-2 w-full", children: [
488
+ /* @__PURE__ */ jsxRuntime.jsxs(
489
+ Select,
490
+ {
491
+ value: filterConfig.operator || "equals",
492
+ onValueChange: (value) => onOperatorChange?.(value),
493
+ children: [
494
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "cls_operator_select w-full sm:w-[140px] shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, {}) }),
495
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: numberOperators.map((op) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: op.value, children: op.label }, op.value)) })
496
+ ]
497
+ }
498
+ ),
499
+ /* @__PURE__ */ jsxRuntime.jsx(
500
+ Input,
501
+ {
502
+ type: "number",
503
+ value: filterConfig.value !== void 0 && filterConfig.value !== null ? filterConfig.value : "",
504
+ onChange: (e) => {
505
+ const value = e.target.value;
506
+ if (value === "") {
507
+ onValueChange("");
508
+ return;
509
+ }
510
+ let numValue = fieldConfig.numberConfig?.allowDecimal ? parseFloat(value) : parseInt(value, 10);
511
+ if (isNaN(numValue)) {
512
+ return;
513
+ }
514
+ if (fieldConfig.numberConfig?.allowDecimal && fieldConfig.numberConfig?.decimalLength) {
515
+ const decimalPlaces = value.split(".")[1]?.length || 0;
516
+ if (decimalPlaces > fieldConfig.numberConfig.decimalLength) {
517
+ return;
518
+ }
519
+ }
520
+ if (fieldConfig.numberConfig?.min !== void 0 && numValue < fieldConfig.numberConfig.min) {
521
+ numValue = fieldConfig.numberConfig.min;
522
+ }
523
+ if (fieldConfig.numberConfig?.max !== void 0 && numValue > fieldConfig.numberConfig.max) {
524
+ numValue = fieldConfig.numberConfig.max;
525
+ }
526
+ onValueChange(numValue);
527
+ },
528
+ placeholder: "Enter number...",
529
+ min: fieldConfig.numberConfig?.min,
530
+ max: fieldConfig.numberConfig?.max,
531
+ step: fieldConfig.numberConfig?.allowDecimal ? 0.01 : 1,
532
+ className: "cls_filter_number_input flex-1 min-w-0"
533
+ }
534
+ )
535
+ ] });
536
+ case "combobox":
537
+ return /* @__PURE__ */ jsxRuntime.jsxs(
538
+ Select,
539
+ {
540
+ value: filterConfig.value || "",
541
+ onValueChange: (value) => onValueChange(value),
542
+ children: [
543
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "cls_filter_combobox_select w-full min-w-0", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select option..." }) }),
544
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: fieldConfig.comboboxOptions?.map((option) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: option.value, children: option.label }, option.value)) })
545
+ ]
546
+ }
547
+ );
548
+ case "boolean":
549
+ const trueLabel = fieldConfig.booleanLabels?.trueLabel || "On";
550
+ const falseLabel = fieldConfig.booleanLabels?.falseLabel || "Off";
551
+ return /* @__PURE__ */ jsxRuntime.jsxs(
552
+ Select,
553
+ {
554
+ value: filterConfig.value !== void 0 && filterConfig.value !== null ? String(filterConfig.value) : "",
555
+ onValueChange: (value) => onValueChange(value === "true"),
556
+ children: [
557
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "cls_filter_boolean_select w-full min-w-0", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select..." }) }),
558
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
559
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "true", children: trueLabel }),
560
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "false", children: falseLabel })
561
+ ] })
562
+ ]
563
+ }
564
+ );
565
+ case "date":
566
+ const dateOperators = [
567
+ { value: "equals", label: "Equals" },
568
+ { value: "not_equals", label: "Not Equals" },
569
+ { value: "greater_than", label: "Greater Than" },
570
+ { value: "less_than", label: "Less Than" },
571
+ { value: "greater_equal", label: "Greater or Equal" },
572
+ { value: "less_equal", label: "Less or Equal" }
573
+ ];
574
+ const selectedDate = filterConfig.value ? typeof filterConfig.value === "string" ? new Date(filterConfig.value) : filterConfig.value : void 0;
575
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_date_filter_container flex flex-col sm:flex-row items-stretch sm:items-center gap-2 w-full", children: [
576
+ /* @__PURE__ */ jsxRuntime.jsxs(
577
+ Select,
578
+ {
579
+ value: filterConfig.operator || "equals",
580
+ onValueChange: (value) => onOperatorChange?.(value),
581
+ children: [
582
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "cls_operator_select w-full sm:w-[140px] shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, {}) }),
583
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: dateOperators.map((op) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: op.value, children: op.label }, op.value)) })
584
+ ]
585
+ }
586
+ ),
587
+ /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: isCalendarOpen, onOpenChange: setIsCalendarOpen, children: [
588
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
589
+ Button,
590
+ {
591
+ variant: "outline",
592
+ className: cn(
593
+ "cls_date_picker_trigger w-full justify-start text-left font-normal min-w-0",
594
+ !selectedDate && "text-muted-foreground"
595
+ ),
596
+ children: [
597
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Calendar, { className: "cls_calendar_icon mr-2 h-4 w-4 shrink-0" }),
598
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cls_date_text truncate", children: selectedDate ? dateFns.format(selectedDate, "MMM d, yyyy") : "Pick a date" })
599
+ ]
600
+ }
601
+ ) }),
602
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "cls_calendar_popover w-auto p-0", align: "start", children: /* @__PURE__ */ jsxRuntime.jsx(
603
+ Calendar,
604
+ {
605
+ mode: "single",
606
+ selected: selectedDate,
607
+ onSelect: (date) => {
608
+ onValueChange(date);
609
+ setIsCalendarOpen(false);
610
+ },
611
+ initialFocus: true
612
+ }
613
+ ) })
614
+ ] })
615
+ ] });
616
+ default:
617
+ return null;
618
+ }
619
+ };
620
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_filter_field_item flex flex-col sm:flex-row items-start sm:items-center gap-3 p-3 border rounded-md bg-card", children: [
621
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cls_field_label text-sm font-medium min-w-[120px] sm:min-w-[100px] truncate", children: fieldConfig.label }),
622
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_field_input_container flex-1 min-w-0 w-full sm:w-auto", children: renderInput() }),
623
+ /* @__PURE__ */ jsxRuntime.jsx(
624
+ Button,
625
+ {
626
+ variant: "ghost",
627
+ size: "sm",
628
+ onClick: onDelete,
629
+ className: "cls_delete_btn h-8 w-8 p-0 text-destructive hover:text-destructive shrink-0",
630
+ "aria-label": `Remove ${fieldConfig.label} filter`,
631
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "cls_delete_icon h-4 w-4" })
632
+ }
633
+ )
634
+ ] });
635
+ }
636
+ function MultiFilterDialog({
637
+ availableFields,
638
+ onFilterChange,
639
+ initialFilters = []
640
+ }) {
641
+ const [isOpen, setIsOpen] = React6.useState(false);
642
+ const [filterFields, setFilterFields] = React6.useState(initialFilters);
643
+ const [isComboboxOpen, setIsComboboxOpen] = React6.useState(false);
644
+ React6.useEffect(() => {
645
+ if (isOpen) {
646
+ setFilterFields(initialFilters);
647
+ }
648
+ }, [isOpen, initialFilters]);
649
+ const handleAddField = (fieldValue) => {
650
+ if (filterFields.some((ff) => ff.field === fieldValue)) {
651
+ return;
652
+ }
653
+ const fieldConfig = availableFields.find((af) => af.value === fieldValue);
654
+ if (!fieldConfig) {
655
+ return;
656
+ }
657
+ let defaultValue = "";
658
+ if (fieldConfig.type === "boolean") {
659
+ defaultValue = false;
660
+ } else if (fieldConfig.type === "number") {
661
+ defaultValue = fieldConfig.numberConfig?.min || 0;
662
+ } else if (fieldConfig.type === "date") {
663
+ defaultValue = /* @__PURE__ */ new Date();
664
+ }
665
+ const newFilter = {
666
+ field: fieldValue,
667
+ operator: fieldConfig.type === "number" || fieldConfig.type === "date" ? "equals" : void 0,
668
+ value: defaultValue
669
+ };
670
+ setFilterFields([...filterFields, newFilter]);
671
+ setIsComboboxOpen(false);
672
+ };
673
+ const handleDeleteField = (fieldValue) => {
674
+ setFilterFields(filterFields.filter((ff) => ff.field !== fieldValue));
675
+ };
676
+ const handleValueChange = (fieldValue, value) => {
677
+ setFilterFields(
678
+ filterFields.map(
679
+ (ff) => ff.field === fieldValue ? { ...ff, value } : ff
680
+ )
681
+ );
682
+ };
683
+ const handleOperatorChange = (fieldValue, operator) => {
684
+ setFilterFields(
685
+ filterFields.map(
686
+ (ff) => ff.field === fieldValue ? { ...ff, operator } : ff
687
+ )
688
+ );
689
+ };
690
+ const handleApply = () => {
691
+ onFilterChange([...filterFields]);
692
+ setIsOpen(false);
693
+ };
694
+ const handleCancel = () => {
695
+ setFilterFields(initialFilters);
696
+ setIsOpen(false);
697
+ };
698
+ const availableFieldsToAdd = availableFields.filter(
699
+ (af) => !filterFields.some((ff) => ff.field === af.value)
700
+ );
701
+ const getFieldConfig = (fieldValue) => {
702
+ return availableFields.find((af) => af.value === fieldValue);
703
+ };
704
+ const hasActiveFilters = initialFilters.length > 0;
705
+ const tooltipContent = hasActiveFilters ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_filter_tooltip_content space-y-1", children: [
706
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_tooltip_title text-xs font-semibold mb-1", children: "Active Filters:" }),
707
+ initialFilters.map((filterConfig) => {
708
+ const fieldConfig = getFieldConfig(filterConfig.field);
709
+ if (!fieldConfig) return null;
710
+ let displayValue = String(filterConfig.value);
711
+ if (fieldConfig.type === "boolean") {
712
+ displayValue = filterConfig.value ? fieldConfig.booleanLabels?.trueLabel || "On" : fieldConfig.booleanLabels?.falseLabel || "Off";
713
+ } else if (fieldConfig.type === "combobox") {
714
+ const option = fieldConfig.comboboxOptions?.find((opt) => opt.value === filterConfig.value);
715
+ displayValue = option?.label || displayValue;
716
+ } else if (fieldConfig.type === "date") {
717
+ const dateValue = filterConfig.value instanceof Date ? filterConfig.value : new Date(filterConfig.value);
718
+ if (!isNaN(dateValue.getTime())) {
719
+ displayValue = dateFns.format(dateValue, "MMM d, yyyy");
720
+ }
721
+ }
722
+ const operatorLabel = filterConfig.operator ? filterConfig.operator.replace("_", " ").replace(/\b\w/g, (l) => l.toUpperCase()) + " " : "";
723
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_tooltip_item text-xs", children: [
724
+ fieldConfig.label,
725
+ ": ",
726
+ operatorLabel,
727
+ displayValue
728
+ ] }, filterConfig.field);
729
+ })
730
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_filter_tooltip_content text-xs", children: "No active filters" });
731
+ return /* @__PURE__ */ jsxRuntime.jsxs(Dialog, { open: isOpen, onOpenChange: setIsOpen, children: [
732
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
733
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(DialogTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
734
+ Button,
735
+ {
736
+ variant: "outline",
737
+ size: "sm",
738
+ className: "cls_filter_button",
739
+ "aria-label": "Open filter dialog",
740
+ children: [
741
+ /* @__PURE__ */ jsxRuntime.jsx(
742
+ lucideReact.Filter,
743
+ {
744
+ className: cn(
745
+ "cls_filter_icon h-4 w-4 mr-2",
746
+ hasActiveFilters && "text-blue-600"
747
+ )
748
+ }
749
+ ),
750
+ "Filter"
751
+ ]
752
+ }
753
+ ) }) }),
754
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: tooltipContent })
755
+ ] }) }),
756
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "cls_filter_dialog_content max-w-lg w-full max-h-[90vh] overflow-y-auto", children: [
757
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { children: [
758
+ /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: "Filter Images" }),
759
+ /* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { children: "Add multiple fields to filter by. Select a field and set its filter value." })
760
+ ] }),
761
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_filter_dialog_body space-y-4 py-4", children: [
762
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_add_field_section", children: /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: isComboboxOpen, onOpenChange: setIsComboboxOpen, children: [
763
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
764
+ Button,
765
+ {
766
+ variant: "outline",
767
+ role: "combobox",
768
+ "aria-expanded": isComboboxOpen,
769
+ className: "cls_add_field_combobox w-full justify-between",
770
+ children: [
771
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_combobox_content flex items-center", children: [
772
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "cls_plus_icon h-4 w-4 mr-2" }),
773
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Add field" })
774
+ ] }),
775
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsUpDown, { className: "cls_chevron_icon ml-2 h-4 w-4 shrink-0 opacity-50" })
776
+ ]
777
+ }
778
+ ) }),
779
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "cls_combobox_popover w-full p-0", children: /* @__PURE__ */ jsxRuntime.jsxs(Command, { children: [
780
+ /* @__PURE__ */ jsxRuntime.jsx(CommandInput, { placeholder: "Search fields...", className: "cls_command_input" }),
781
+ /* @__PURE__ */ jsxRuntime.jsxs(CommandList, { children: [
782
+ /* @__PURE__ */ jsxRuntime.jsx(CommandEmpty, { children: "No fields found." }),
783
+ /* @__PURE__ */ jsxRuntime.jsx(CommandGroup, { children: availableFieldsToAdd.map((field) => /* @__PURE__ */ jsxRuntime.jsxs(
784
+ CommandItem,
785
+ {
786
+ value: field.value,
787
+ onSelect: () => handleAddField(field.value),
788
+ className: "cls_command_item",
789
+ children: [
790
+ /* @__PURE__ */ jsxRuntime.jsx(
791
+ lucideReact.Check,
792
+ {
793
+ className: cn(
794
+ "cls_check_icon mr-2 h-4 w-4",
795
+ "opacity-0"
796
+ )
797
+ }
798
+ ),
799
+ field.label
800
+ ]
801
+ },
802
+ field.value
803
+ )) })
804
+ ] })
805
+ ] }) })
806
+ ] }) }),
807
+ filterFields.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_filter_fields_list space-y-2", children: filterFields.map((filterConfig) => {
808
+ const fieldConfig = getFieldConfig(filterConfig.field);
809
+ if (!fieldConfig) return null;
810
+ return /* @__PURE__ */ jsxRuntime.jsx(
811
+ FilterFieldItem,
812
+ {
813
+ filterConfig,
814
+ fieldConfig,
815
+ onValueChange: (value) => handleValueChange(filterConfig.field, value),
816
+ onOperatorChange: (operator) => handleOperatorChange(filterConfig.field, operator),
817
+ onDelete: () => handleDeleteField(filterConfig.field)
818
+ },
819
+ filterConfig.field
820
+ );
821
+ }) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_empty_filter_fields text-center py-8 text-sm text-muted-foreground", children: 'No filter fields added. Click "Add field" to add filtering criteria.' })
822
+ ] }),
823
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogFooter, { children: [
824
+ /* @__PURE__ */ jsxRuntime.jsx(
825
+ Button,
826
+ {
827
+ onClick: handleApply,
828
+ className: "cls_apply_btn",
829
+ children: "Apply"
830
+ }
831
+ ),
832
+ /* @__PURE__ */ jsxRuntime.jsx(
833
+ Button,
834
+ {
835
+ variant: "outline",
836
+ onClick: handleCancel,
837
+ className: "cls_cancel_btn",
838
+ children: "Cancel"
839
+ }
840
+ )
841
+ ] })
842
+ ] })
843
+ ] });
844
+ }
845
+
846
+ exports.ExampleComponent = ExampleComponent;
847
+ exports.MultiFilterDialog = MultiFilterDialog;
848
+ //# sourceMappingURL=index.cjs.map
849
+ //# sourceMappingURL=index.cjs.map