hazo_ui 2.9.0 → 2.16.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/CHANGE_LOG.md +500 -0
- package/README.md +539 -0
- package/SETUP_CHECKLIST.md +418 -0
- package/dist/index.cjs +2522 -499
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +534 -1
- package/dist/index.d.ts +534 -1
- package/dist/index.js +2461 -468
- package/dist/index.js.map +1 -1
- package/dist/styles.css +40 -0
- package/package.json +5 -2
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var React25 = require('react');
|
|
5
5
|
var reactSlot = require('@radix-ui/react-slot');
|
|
6
6
|
var classVarianceAuthority = require('class-variance-authority');
|
|
7
7
|
var clsx = require('clsx');
|
|
@@ -14,7 +14,6 @@ var SelectPrimitive = require('@radix-ui/react-select');
|
|
|
14
14
|
var TooltipPrimitive = require('@radix-ui/react-tooltip');
|
|
15
15
|
var reactDayPicker = require('react-day-picker');
|
|
16
16
|
var dateFns = require('date-fns');
|
|
17
|
-
var SwitchPrimitives = require('@radix-ui/react-switch');
|
|
18
17
|
var core$1 = require('@dnd-kit/core');
|
|
19
18
|
var sortable = require('@dnd-kit/sortable');
|
|
20
19
|
var utilities = require('@dnd-kit/utilities');
|
|
@@ -62,12 +61,14 @@ var AccordionPrimitive = require('@radix-ui/react-accordion');
|
|
|
62
61
|
var CheckboxPrimitive = require('@radix-ui/react-checkbox');
|
|
63
62
|
var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
|
|
64
63
|
var HoverCardPrimitive = require('@radix-ui/react-hover-card');
|
|
64
|
+
var SwitchPrimitives = require('@radix-ui/react-switch');
|
|
65
65
|
var SeparatorPrimitive = require('@radix-ui/react-separator');
|
|
66
66
|
var CollapsiblePrimitive = require('@radix-ui/react-collapsible');
|
|
67
67
|
var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
|
|
68
68
|
var TogglePrimitive = require('@radix-ui/react-toggle');
|
|
69
69
|
var ToggleGroupPrimitive = require('@radix-ui/react-toggle-group');
|
|
70
70
|
var AlertDialogPrimitive = require('@radix-ui/react-alert-dialog');
|
|
71
|
+
var sonner = require('sonner');
|
|
71
72
|
|
|
72
73
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
73
74
|
|
|
@@ -89,12 +90,11 @@ function _interopNamespace(e) {
|
|
|
89
90
|
return Object.freeze(n);
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
var
|
|
93
|
+
var React25__namespace = /*#__PURE__*/_interopNamespace(React25);
|
|
93
94
|
var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
|
|
94
95
|
var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
|
|
95
96
|
var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
|
|
96
97
|
var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
|
|
97
|
-
var SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitives);
|
|
98
98
|
var RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(RadioGroupPrimitive);
|
|
99
99
|
var FaIcons__namespace = /*#__PURE__*/_interopNamespace(FaIcons);
|
|
100
100
|
var MdIcons__namespace = /*#__PURE__*/_interopNamespace(MdIcons);
|
|
@@ -130,6 +130,7 @@ var AccordionPrimitive__namespace = /*#__PURE__*/_interopNamespace(AccordionPrim
|
|
|
130
130
|
var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
|
|
131
131
|
var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
|
|
132
132
|
var HoverCardPrimitive__namespace = /*#__PURE__*/_interopNamespace(HoverCardPrimitive);
|
|
133
|
+
var SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitives);
|
|
133
134
|
var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
|
|
134
135
|
var CollapsiblePrimitive__namespace = /*#__PURE__*/_interopNamespace(CollapsiblePrimitive);
|
|
135
136
|
var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
|
|
@@ -255,26 +256,26 @@ var buttonVariants = classVarianceAuthority.cva(
|
|
|
255
256
|
);
|
|
256
257
|
var variant_styles = {
|
|
257
258
|
default: {
|
|
258
|
-
backgroundColor: "var(--primary)",
|
|
259
|
-
color: "var(--primary-foreground)",
|
|
260
|
-
border: "1px solid var(--primary)"
|
|
259
|
+
backgroundColor: "hsl(var(--primary))",
|
|
260
|
+
color: "hsl(var(--primary-foreground))",
|
|
261
|
+
border: "1px solid hsl(var(--primary))"
|
|
261
262
|
},
|
|
262
263
|
destructive: {
|
|
263
|
-
backgroundColor: "var(--destructive)",
|
|
264
|
-
color: "
|
|
265
|
-
border: "1px solid var(--destructive)"
|
|
264
|
+
backgroundColor: "hsl(var(--destructive))",
|
|
265
|
+
color: "hsl(var(--destructive-foreground))",
|
|
266
|
+
border: "1px solid hsl(var(--destructive))"
|
|
266
267
|
},
|
|
267
268
|
outline: {
|
|
268
|
-
backgroundColor: "var(--background)",
|
|
269
|
-
color: "var(--foreground)",
|
|
270
|
-
border: "1px solid var(--border)"
|
|
269
|
+
backgroundColor: "hsl(var(--background))",
|
|
270
|
+
color: "hsl(var(--foreground))",
|
|
271
|
+
border: "1px solid hsl(var(--border))"
|
|
271
272
|
},
|
|
272
273
|
secondary: {
|
|
273
|
-
backgroundColor: "var(--secondary)",
|
|
274
|
-
color: "var(--secondary-foreground)"
|
|
274
|
+
backgroundColor: "hsl(var(--secondary))",
|
|
275
|
+
color: "hsl(var(--secondary-foreground))"
|
|
275
276
|
}
|
|
276
277
|
};
|
|
277
|
-
var Button =
|
|
278
|
+
var Button = React25__namespace.forwardRef(
|
|
278
279
|
({ className, variant, size, asChild = false, style, ...props }, ref) => {
|
|
279
280
|
const Comp = asChild ? reactSlot.Slot : "button";
|
|
280
281
|
const fallback_styles = variant_styles[variant ?? "default"] ?? {};
|
|
@@ -294,7 +295,7 @@ var Dialog = DialogPrimitive__namespace.Root;
|
|
|
294
295
|
var DialogTrigger = DialogPrimitive__namespace.Trigger;
|
|
295
296
|
var DialogPortal = DialogPrimitive__namespace.Portal;
|
|
296
297
|
var DialogClose = DialogPrimitive__namespace.Close;
|
|
297
|
-
var DialogOverlay =
|
|
298
|
+
var DialogOverlay = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
298
299
|
DialogPrimitive__namespace.Overlay,
|
|
299
300
|
{
|
|
300
301
|
ref,
|
|
@@ -306,14 +307,14 @@ var DialogOverlay = React27__namespace.forwardRef(({ className, ...props }, ref)
|
|
|
306
307
|
}
|
|
307
308
|
));
|
|
308
309
|
DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
|
|
309
|
-
var DialogContent =
|
|
310
|
+
var DialogContent = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
|
|
310
311
|
/* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
|
|
311
312
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
312
313
|
DialogPrimitive__namespace.Content,
|
|
313
314
|
{
|
|
314
315
|
ref,
|
|
315
316
|
className: cn(
|
|
316
|
-
"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
|
|
317
|
+
"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 sm:rounded-lg",
|
|
317
318
|
className
|
|
318
319
|
),
|
|
319
320
|
...props,
|
|
@@ -356,7 +357,7 @@ var DialogFooter = ({
|
|
|
356
357
|
}
|
|
357
358
|
);
|
|
358
359
|
DialogFooter.displayName = "DialogFooter";
|
|
359
|
-
var DialogTitle =
|
|
360
|
+
var DialogTitle = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
360
361
|
DialogPrimitive__namespace.Title,
|
|
361
362
|
{
|
|
362
363
|
ref,
|
|
@@ -369,7 +370,7 @@ var DialogTitle = React27__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
369
370
|
}
|
|
370
371
|
));
|
|
371
372
|
DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
|
|
372
|
-
var DialogDescription =
|
|
373
|
+
var DialogDescription = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
373
374
|
DialogPrimitive__namespace.Description,
|
|
374
375
|
{
|
|
375
376
|
ref,
|
|
@@ -378,7 +379,7 @@ var DialogDescription = React27__namespace.forwardRef(({ className, ...props },
|
|
|
378
379
|
}
|
|
379
380
|
));
|
|
380
381
|
DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
|
|
381
|
-
var Command =
|
|
382
|
+
var Command = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
382
383
|
"div",
|
|
383
384
|
{
|
|
384
385
|
ref,
|
|
@@ -390,7 +391,7 @@ var Command = React27__namespace.forwardRef(({ className, ...props }, ref) => /*
|
|
|
390
391
|
}
|
|
391
392
|
));
|
|
392
393
|
Command.displayName = "Command";
|
|
393
|
-
var CommandInput =
|
|
394
|
+
var CommandInput = React25__namespace.forwardRef(({ className, onValueChange, onChange, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
394
395
|
"input",
|
|
395
396
|
{
|
|
396
397
|
ref,
|
|
@@ -406,7 +407,7 @@ var CommandInput = React27__namespace.forwardRef(({ className, onValueChange, on
|
|
|
406
407
|
}
|
|
407
408
|
));
|
|
408
409
|
CommandInput.displayName = "CommandInput";
|
|
409
|
-
var CommandList =
|
|
410
|
+
var CommandList = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
410
411
|
"div",
|
|
411
412
|
{
|
|
412
413
|
ref,
|
|
@@ -415,7 +416,7 @@ var CommandList = React27__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
415
416
|
}
|
|
416
417
|
));
|
|
417
418
|
CommandList.displayName = "CommandList";
|
|
418
|
-
var CommandEmpty =
|
|
419
|
+
var CommandEmpty = React25__namespace.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
419
420
|
"div",
|
|
420
421
|
{
|
|
421
422
|
ref,
|
|
@@ -424,7 +425,7 @@ var CommandEmpty = React27__namespace.forwardRef((props, ref) => /* @__PURE__ */
|
|
|
424
425
|
}
|
|
425
426
|
));
|
|
426
427
|
CommandEmpty.displayName = "CommandEmpty";
|
|
427
|
-
var CommandGroup =
|
|
428
|
+
var CommandGroup = React25__namespace.forwardRef(({ className, heading, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
428
429
|
"div",
|
|
429
430
|
{
|
|
430
431
|
ref,
|
|
@@ -440,7 +441,7 @@ var CommandGroup = React27__namespace.forwardRef(({ className, heading, children
|
|
|
440
441
|
}
|
|
441
442
|
));
|
|
442
443
|
CommandGroup.displayName = "CommandGroup";
|
|
443
|
-
var CommandItem =
|
|
444
|
+
var CommandItem = React25__namespace.forwardRef(({ className, onSelect, value, selected, style, ...props }, ref) => {
|
|
444
445
|
const handleClick = () => {
|
|
445
446
|
if (onSelect && value) {
|
|
446
447
|
onSelect(value);
|
|
@@ -471,7 +472,7 @@ var CommandItem = React27__namespace.forwardRef(({ className, onSelect, value, s
|
|
|
471
472
|
CommandItem.displayName = "CommandItem";
|
|
472
473
|
var Popover = PopoverPrimitive__namespace.Root;
|
|
473
474
|
var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
|
|
474
|
-
var PopoverContent =
|
|
475
|
+
var PopoverContent = React25__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
475
476
|
PopoverPrimitive__namespace.Content,
|
|
476
477
|
{
|
|
477
478
|
ref,
|
|
@@ -485,7 +486,7 @@ var PopoverContent = React27__namespace.forwardRef(({ className, align = "center
|
|
|
485
486
|
}
|
|
486
487
|
) }));
|
|
487
488
|
PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
|
|
488
|
-
var Input =
|
|
489
|
+
var Input = React25__namespace.forwardRef(
|
|
489
490
|
({ className, type, ...props }, ref) => {
|
|
490
491
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
491
492
|
"input",
|
|
@@ -505,7 +506,7 @@ Input.displayName = "Input";
|
|
|
505
506
|
var Select = SelectPrimitive__namespace.Root;
|
|
506
507
|
var SelectGroup = SelectPrimitive__namespace.Group;
|
|
507
508
|
var SelectValue = SelectPrimitive__namespace.Value;
|
|
508
|
-
var SelectTrigger =
|
|
509
|
+
var SelectTrigger = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
509
510
|
SelectPrimitive__namespace.Trigger,
|
|
510
511
|
{
|
|
511
512
|
ref,
|
|
@@ -521,7 +522,7 @@ var SelectTrigger = React27__namespace.forwardRef(({ className, children, ...pro
|
|
|
521
522
|
}
|
|
522
523
|
));
|
|
523
524
|
SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
|
|
524
|
-
var SelectScrollUpButton =
|
|
525
|
+
var SelectScrollUpButton = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
525
526
|
SelectPrimitive__namespace.ScrollUpButton,
|
|
526
527
|
{
|
|
527
528
|
ref,
|
|
@@ -534,7 +535,7 @@ var SelectScrollUpButton = React27__namespace.forwardRef(({ className, ...props
|
|
|
534
535
|
}
|
|
535
536
|
));
|
|
536
537
|
SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
|
|
537
|
-
var SelectScrollDownButton =
|
|
538
|
+
var SelectScrollDownButton = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
538
539
|
SelectPrimitive__namespace.ScrollDownButton,
|
|
539
540
|
{
|
|
540
541
|
ref,
|
|
@@ -547,7 +548,7 @@ var SelectScrollDownButton = React27__namespace.forwardRef(({ className, ...prop
|
|
|
547
548
|
}
|
|
548
549
|
));
|
|
549
550
|
SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
|
|
550
|
-
var SelectContent =
|
|
551
|
+
var SelectContent = React25__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
551
552
|
SelectPrimitive__namespace.Content,
|
|
552
553
|
{
|
|
553
554
|
ref,
|
|
@@ -575,7 +576,7 @@ var SelectContent = React27__namespace.forwardRef(({ className, children, positi
|
|
|
575
576
|
}
|
|
576
577
|
) }));
|
|
577
578
|
SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
|
|
578
|
-
var SelectLabel =
|
|
579
|
+
var SelectLabel = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
579
580
|
SelectPrimitive__namespace.Label,
|
|
580
581
|
{
|
|
581
582
|
ref,
|
|
@@ -584,7 +585,7 @@ var SelectLabel = React27__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
584
585
|
}
|
|
585
586
|
));
|
|
586
587
|
SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
|
|
587
|
-
var SelectItem =
|
|
588
|
+
var SelectItem = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
588
589
|
SelectPrimitive__namespace.Item,
|
|
589
590
|
{
|
|
590
591
|
ref,
|
|
@@ -600,7 +601,7 @@ var SelectItem = React27__namespace.forwardRef(({ className, children, ...props
|
|
|
600
601
|
}
|
|
601
602
|
));
|
|
602
603
|
SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
|
|
603
|
-
var SelectSeparator =
|
|
604
|
+
var SelectSeparator = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
604
605
|
SelectPrimitive__namespace.Separator,
|
|
605
606
|
{
|
|
606
607
|
ref,
|
|
@@ -612,7 +613,7 @@ SelectSeparator.displayName = SelectPrimitive__namespace.Separator.displayName;
|
|
|
612
613
|
var TooltipProvider = TooltipPrimitive__namespace.Provider;
|
|
613
614
|
var Tooltip = TooltipPrimitive__namespace.Root;
|
|
614
615
|
var TooltipTrigger = TooltipPrimitive__namespace.Trigger;
|
|
615
|
-
var TooltipContent =
|
|
616
|
+
var TooltipContent = React25__namespace.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
616
617
|
TooltipPrimitive__namespace.Content,
|
|
617
618
|
{
|
|
618
619
|
ref,
|
|
@@ -680,7 +681,7 @@ function FilterFieldItem({
|
|
|
680
681
|
onOperatorChange,
|
|
681
682
|
onDelete
|
|
682
683
|
}) {
|
|
683
|
-
const [isCalendarOpen, setIsCalendarOpen] =
|
|
684
|
+
const [isCalendarOpen, setIsCalendarOpen] = React25.useState(false);
|
|
684
685
|
const renderInput = () => {
|
|
685
686
|
switch (fieldConfig.type) {
|
|
686
687
|
case "text":
|
|
@@ -699,27 +700,27 @@ function FilterFieldItem({
|
|
|
699
700
|
placeholder: "Enter text...",
|
|
700
701
|
minLength: fieldConfig.textConfig?.minLength,
|
|
701
702
|
maxLength: fieldConfig.textConfig?.maxLength,
|
|
702
|
-
className: "cls_filter_text_input w-full min-w-0"
|
|
703
|
+
className: "cls_filter_text_input h-8 w-full min-w-0 text-sm"
|
|
703
704
|
}
|
|
704
705
|
);
|
|
705
|
-
case "number":
|
|
706
|
+
case "number": {
|
|
706
707
|
const numberOperators = [
|
|
707
|
-
{ value: "equals", label: "
|
|
708
|
-
{ value: "not_equals", label: "
|
|
709
|
-
{ value: "greater_than", label: "
|
|
710
|
-
{ value: "less_than", label: "
|
|
711
|
-
{ value: "greater_equal", label: "
|
|
712
|
-
{ value: "less_equal", label: "
|
|
708
|
+
{ value: "equals", label: "=" },
|
|
709
|
+
{ value: "not_equals", label: "\u2260" },
|
|
710
|
+
{ value: "greater_than", label: ">" },
|
|
711
|
+
{ value: "less_than", label: "<" },
|
|
712
|
+
{ value: "greater_equal", label: "\u2265" },
|
|
713
|
+
{ value: "less_equal", label: "\u2264" }
|
|
713
714
|
];
|
|
714
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_number_filter_container flex
|
|
715
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_number_filter_container flex w-full items-center gap-1.5", children: [
|
|
715
716
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
716
717
|
Select,
|
|
717
718
|
{
|
|
718
719
|
value: filterConfig.operator || "equals",
|
|
719
720
|
onValueChange: (value) => onOperatorChange?.(value),
|
|
720
721
|
children: [
|
|
721
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "cls_operator_select
|
|
722
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: numberOperators.map((op) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: op.value, children: op.label }, op.value)) })
|
|
722
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "cls_operator_select h-8 w-[60px] shrink-0 text-sm", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, {}) }),
|
|
723
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: numberOperators.map((op) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: op.value, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono", children: op.label }) }, op.value)) })
|
|
723
724
|
]
|
|
724
725
|
}
|
|
725
726
|
),
|
|
@@ -735,14 +736,10 @@ function FilterFieldItem({
|
|
|
735
736
|
return;
|
|
736
737
|
}
|
|
737
738
|
let numValue = fieldConfig.numberConfig?.allowDecimal ? parseFloat(value) : parseInt(value, 10);
|
|
738
|
-
if (isNaN(numValue))
|
|
739
|
-
return;
|
|
740
|
-
}
|
|
739
|
+
if (isNaN(numValue)) return;
|
|
741
740
|
if (fieldConfig.numberConfig?.allowDecimal && fieldConfig.numberConfig?.decimalLength) {
|
|
742
741
|
const decimalPlaces = value.split(".")[1]?.length || 0;
|
|
743
|
-
if (decimalPlaces > fieldConfig.numberConfig.decimalLength)
|
|
744
|
-
return;
|
|
745
|
-
}
|
|
742
|
+
if (decimalPlaces > fieldConfig.numberConfig.decimalLength) return;
|
|
746
743
|
}
|
|
747
744
|
if (fieldConfig.numberConfig?.min !== void 0 && numValue < fieldConfig.numberConfig.min) {
|
|
748
745
|
numValue = fieldConfig.numberConfig.min;
|
|
@@ -752,14 +749,15 @@ function FilterFieldItem({
|
|
|
752
749
|
}
|
|
753
750
|
onValueChange(numValue);
|
|
754
751
|
},
|
|
755
|
-
placeholder: "
|
|
752
|
+
placeholder: "Value",
|
|
756
753
|
min: fieldConfig.numberConfig?.min,
|
|
757
754
|
max: fieldConfig.numberConfig?.max,
|
|
758
755
|
step: fieldConfig.numberConfig?.allowDecimal ? 0.01 : 1,
|
|
759
|
-
className: "cls_filter_number_input flex-1 min-w-0"
|
|
756
|
+
className: "cls_filter_number_input h-8 flex-1 min-w-0 text-sm tabular-nums"
|
|
760
757
|
}
|
|
761
758
|
)
|
|
762
759
|
] });
|
|
760
|
+
}
|
|
763
761
|
case "combobox":
|
|
764
762
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
765
763
|
Select,
|
|
@@ -767,12 +765,12 @@ function FilterFieldItem({
|
|
|
767
765
|
value: filterConfig.value || "",
|
|
768
766
|
onValueChange: (value) => onValueChange(value),
|
|
769
767
|
children: [
|
|
770
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "cls_filter_combobox_select w-full min-w-0", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select option..." }) }),
|
|
768
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "cls_filter_combobox_select h-8 w-full min-w-0 text-sm", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select option..." }) }),
|
|
771
769
|
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: fieldConfig.comboboxOptions?.map((option) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: option.value, children: option.label }, option.value)) })
|
|
772
770
|
]
|
|
773
771
|
}
|
|
774
772
|
);
|
|
775
|
-
case "boolean":
|
|
773
|
+
case "boolean": {
|
|
776
774
|
const trueLabel = fieldConfig.booleanLabels?.trueLabel || "On";
|
|
777
775
|
const falseLabel = fieldConfig.booleanLabels?.falseLabel || "Off";
|
|
778
776
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -781,7 +779,7 @@ function FilterFieldItem({
|
|
|
781
779
|
value: filterConfig.value !== void 0 && filterConfig.value !== null ? String(filterConfig.value) : "",
|
|
782
780
|
onValueChange: (value) => onValueChange(value === "true"),
|
|
783
781
|
children: [
|
|
784
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "cls_filter_boolean_select w-full min-w-0", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select..." }) }),
|
|
782
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "cls_filter_boolean_select h-8 w-full min-w-0 text-sm", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select..." }) }),
|
|
785
783
|
/* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
|
|
786
784
|
/* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "true", children: trueLabel }),
|
|
787
785
|
/* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "false", children: falseLabel })
|
|
@@ -789,25 +787,26 @@ function FilterFieldItem({
|
|
|
789
787
|
]
|
|
790
788
|
}
|
|
791
789
|
);
|
|
792
|
-
|
|
790
|
+
}
|
|
791
|
+
case "date": {
|
|
793
792
|
const dateOperators = [
|
|
794
|
-
{ value: "equals", label: "
|
|
795
|
-
{ value: "not_equals", label: "
|
|
796
|
-
{ value: "greater_than", label: "
|
|
797
|
-
{ value: "less_than", label: "
|
|
798
|
-
{ value: "greater_equal", label: "
|
|
799
|
-
{ value: "less_equal", label: "
|
|
793
|
+
{ value: "equals", label: "=" },
|
|
794
|
+
{ value: "not_equals", label: "\u2260" },
|
|
795
|
+
{ value: "greater_than", label: ">" },
|
|
796
|
+
{ value: "less_than", label: "<" },
|
|
797
|
+
{ value: "greater_equal", label: "\u2265" },
|
|
798
|
+
{ value: "less_equal", label: "\u2264" }
|
|
800
799
|
];
|
|
801
800
|
const selectedDate = filterConfig.value ? typeof filterConfig.value === "string" ? new Date(filterConfig.value) : filterConfig.value : void 0;
|
|
802
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_date_filter_container flex
|
|
801
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_date_filter_container flex w-full items-center gap-1.5", children: [
|
|
803
802
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
804
803
|
Select,
|
|
805
804
|
{
|
|
806
805
|
value: filterConfig.operator || "equals",
|
|
807
806
|
onValueChange: (value) => onOperatorChange?.(value),
|
|
808
807
|
children: [
|
|
809
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "cls_operator_select
|
|
810
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: dateOperators.map((op) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: op.value, children: op.label }, op.value)) })
|
|
808
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "cls_operator_select h-8 w-[60px] shrink-0 text-sm", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, {}) }),
|
|
809
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: dateOperators.map((op) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: op.value, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono", children: op.label }) }, op.value)) })
|
|
811
810
|
]
|
|
812
811
|
}
|
|
813
812
|
),
|
|
@@ -817,11 +816,11 @@ function FilterFieldItem({
|
|
|
817
816
|
{
|
|
818
817
|
variant: "outline",
|
|
819
818
|
className: cn(
|
|
820
|
-
"cls_date_picker_trigger
|
|
819
|
+
"cls_date_picker_trigger h-8 flex-1 justify-start gap-2 px-2.5 text-left text-sm font-normal min-w-0",
|
|
821
820
|
!selectedDate && "text-muted-foreground"
|
|
822
821
|
),
|
|
823
822
|
children: [
|
|
824
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Calendar, { className: "cls_calendar_icon
|
|
823
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Calendar, { className: "cls_calendar_icon h-3.5 w-3.5 shrink-0" }),
|
|
825
824
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cls_date_text truncate", children: selectedDate ? dateFns.format(selectedDate, "MMM d, yyyy") : "Pick a date" })
|
|
826
825
|
]
|
|
827
826
|
}
|
|
@@ -840,24 +839,27 @@ function FilterFieldItem({
|
|
|
840
839
|
) })
|
|
841
840
|
] })
|
|
842
841
|
] });
|
|
842
|
+
}
|
|
843
843
|
default:
|
|
844
844
|
return null;
|
|
845
845
|
}
|
|
846
846
|
};
|
|
847
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_filter_field_item flex flex-col
|
|
848
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cls_field_label text-
|
|
849
|
-
/* @__PURE__ */ jsxRuntime.
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
847
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_filter_field_item group flex flex-col gap-2 rounded-lg border border-border/70 bg-card px-3 py-2.5 transition-colors hover:border-border sm:flex-row sm:items-center sm:gap-3", children: [
|
|
848
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cls_field_label w-full shrink-0 truncate text-xs font-semibold uppercase tracking-wide text-muted-foreground sm:w-[110px] sm:text-sm sm:normal-case sm:font-medium sm:text-foreground sm:tracking-normal", children: fieldConfig.label }),
|
|
849
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_field_input_container flex min-w-0 flex-1 items-center gap-2", children: [
|
|
850
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-0 flex-1", children: renderInput() }),
|
|
851
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
852
|
+
Button,
|
|
853
|
+
{
|
|
854
|
+
variant: "ghost",
|
|
855
|
+
size: "sm",
|
|
856
|
+
onClick: onDelete,
|
|
857
|
+
className: "cls_delete_btn h-7 w-7 shrink-0 p-0 text-muted-foreground/60 hover:bg-destructive/10 hover:text-destructive",
|
|
858
|
+
"aria-label": `Remove ${fieldConfig.label} filter`,
|
|
859
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "cls_delete_icon h-3.5 w-3.5" })
|
|
860
|
+
}
|
|
861
|
+
)
|
|
862
|
+
] })
|
|
861
863
|
] });
|
|
862
864
|
}
|
|
863
865
|
function HazoUiMultiFilterDialog({
|
|
@@ -865,7 +867,7 @@ function HazoUiMultiFilterDialog({
|
|
|
865
867
|
onFilterChange,
|
|
866
868
|
initialFilters = [],
|
|
867
869
|
title = "Filter",
|
|
868
|
-
description = "Add
|
|
870
|
+
description = "Add fields to filter by. Select a field and set its value.",
|
|
869
871
|
headerBackgroundColor,
|
|
870
872
|
headerTextColor,
|
|
871
873
|
submitButtonBackgroundColor,
|
|
@@ -906,22 +908,18 @@ function HazoUiMultiFilterDialog({
|
|
|
906
908
|
...finalHeaderBgColor && { backgroundColor: finalHeaderBgColor },
|
|
907
909
|
...finalHeaderTextColor && { color: finalHeaderTextColor }
|
|
908
910
|
};
|
|
909
|
-
const [isOpen, setIsOpen] =
|
|
910
|
-
const [filterFields, setFilterFields] =
|
|
911
|
-
const [isComboboxOpen, setIsComboboxOpen] =
|
|
912
|
-
|
|
911
|
+
const [isOpen, setIsOpen] = React25.useState(false);
|
|
912
|
+
const [filterFields, setFilterFields] = React25.useState(initialFilters);
|
|
913
|
+
const [isComboboxOpen, setIsComboboxOpen] = React25.useState(false);
|
|
914
|
+
React25.useEffect(() => {
|
|
913
915
|
if (isOpen) {
|
|
914
916
|
setFilterFields(initialFilters);
|
|
915
917
|
}
|
|
916
918
|
}, [isOpen, initialFilters]);
|
|
917
919
|
const handleAddField = (fieldValue) => {
|
|
918
|
-
if (filterFields.some((ff) => ff.field === fieldValue))
|
|
919
|
-
return;
|
|
920
|
-
}
|
|
920
|
+
if (filterFields.some((ff) => ff.field === fieldValue)) return;
|
|
921
921
|
const fieldConfig = availableFields.find((af) => af.value === fieldValue);
|
|
922
|
-
if (!fieldConfig)
|
|
923
|
-
return;
|
|
924
|
-
}
|
|
922
|
+
if (!fieldConfig) return;
|
|
925
923
|
let defaultValue = "";
|
|
926
924
|
if (fieldConfig.type === "boolean") {
|
|
927
925
|
defaultValue = false;
|
|
@@ -974,7 +972,7 @@ function HazoUiMultiFilterDialog({
|
|
|
974
972
|
};
|
|
975
973
|
const hasActiveFilters = initialFilters.length > 0;
|
|
976
974
|
const tooltipContent = hasActiveFilters ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_filter_tooltip_content space-y-1", children: [
|
|
977
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_tooltip_title text-xs font-semibold mb-1", children: "Active
|
|
975
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_tooltip_title text-xs font-semibold mb-1", children: "Active filters" }),
|
|
978
976
|
initialFilters.map((filterConfig) => {
|
|
979
977
|
const fieldConfig = getFieldConfig(filterConfig.field);
|
|
980
978
|
if (!fieldConfig) return null;
|
|
@@ -1018,152 +1016,114 @@ function HazoUiMultiFilterDialog({
|
|
|
1018
1016
|
)
|
|
1019
1017
|
}
|
|
1020
1018
|
),
|
|
1021
|
-
"Filter"
|
|
1019
|
+
"Filter",
|
|
1020
|
+
hasActiveFilters && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cls_filter_count ml-2 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-blue-600 px-1 text-[10px] font-semibold text-white", children: initialFilters.length })
|
|
1022
1021
|
]
|
|
1023
1022
|
}
|
|
1024
1023
|
) }) }),
|
|
1025
1024
|
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: tooltipContent })
|
|
1026
1025
|
] }) }),
|
|
1027
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "cls_filter_dialog_content max-w-lg
|
|
1028
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1026
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "cls_filter_dialog_content max-w-lg gap-0 p-0 sm:rounded-xl max-h-[90vh]", children: [
|
|
1027
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1028
|
+
DialogHeader,
|
|
1029
|
+
{
|
|
1030
|
+
className: "cls_filter_dialog_header space-y-1 border-b px-5 py-4 text-left",
|
|
1031
|
+
style: headerStyles,
|
|
1032
|
+
children: [
|
|
1033
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "text-base font-semibold", children: title }),
|
|
1034
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { className: "text-xs leading-relaxed text-muted-foreground", children: description })
|
|
1035
|
+
]
|
|
1036
|
+
}
|
|
1037
|
+
),
|
|
1038
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_filter_dialog_body space-y-3 overflow-y-auto px-5 py-4", children: [
|
|
1039
|
+
filterFields.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_filter_fields_list space-y-1.5", children: filterFields.map((filterConfig) => {
|
|
1040
|
+
const fieldConfig = getFieldConfig(filterConfig.field);
|
|
1041
|
+
if (!fieldConfig) return null;
|
|
1042
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1043
|
+
FilterFieldItem,
|
|
1044
|
+
{
|
|
1045
|
+
filterConfig,
|
|
1046
|
+
fieldConfig,
|
|
1047
|
+
onValueChange: (value) => handleValueChange(filterConfig.field, value),
|
|
1048
|
+
onOperatorChange: (operator) => handleOperatorChange(filterConfig.field, operator),
|
|
1049
|
+
onDelete: () => handleDeleteField(filterConfig.field)
|
|
1050
|
+
},
|
|
1051
|
+
filterConfig.field
|
|
1052
|
+
);
|
|
1053
|
+
}) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_empty_filter_fields rounded-lg border border-dashed border-border/70 bg-muted/20 px-4 py-6 text-center text-xs text-muted-foreground", children: "No filters yet. Add one below to narrow down the results." }),
|
|
1033
1054
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_add_field_section", children: /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: isComboboxOpen, onOpenChange: setIsComboboxOpen, children: [
|
|
1034
1055
|
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1035
1056
|
Button,
|
|
1036
1057
|
{
|
|
1037
|
-
variant: "
|
|
1058
|
+
variant: "ghost",
|
|
1038
1059
|
role: "combobox",
|
|
1039
1060
|
"aria-expanded": isComboboxOpen,
|
|
1040
|
-
|
|
1061
|
+
disabled: availableFieldsToAdd.length === 0,
|
|
1062
|
+
className: "cls_add_field_combobox w-full justify-start gap-2 border border-dashed border-border/70 text-sm font-medium text-muted-foreground hover:border-border hover:bg-muted/40 hover:text-foreground",
|
|
1041
1063
|
children: [
|
|
1042
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1043
|
-
|
|
1044
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Add field" })
|
|
1045
|
-
] }),
|
|
1046
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsUpDown, { className: "cls_chevron_icon ml-2 h-4 w-4 shrink-0 opacity-50" })
|
|
1064
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "cls_plus_icon h-4 w-4" }),
|
|
1065
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: availableFieldsToAdd.length === 0 ? "All fields added" : "Add filter field" })
|
|
1047
1066
|
]
|
|
1048
1067
|
}
|
|
1049
1068
|
) }),
|
|
1050
|
-
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "cls_combobox_popover w-
|
|
1069
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "cls_combobox_popover w-[var(--radix-popover-trigger-width)] p-0", align: "start", children: /* @__PURE__ */ jsxRuntime.jsxs(Command, { children: [
|
|
1051
1070
|
/* @__PURE__ */ jsxRuntime.jsx(CommandInput, { placeholder: "Search fields...", className: "cls_command_input" }),
|
|
1052
|
-
/* @__PURE__ */ jsxRuntime.jsx(CommandList, { children: availableFieldsToAdd.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(CommandEmpty, { children: "No fields
|
|
1071
|
+
/* @__PURE__ */ jsxRuntime.jsx(CommandList, { children: availableFieldsToAdd.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(CommandEmpty, { children: "No fields available." }) : /* @__PURE__ */ jsxRuntime.jsx(CommandGroup, { children: availableFieldsToAdd.map((field) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1053
1072
|
CommandItem,
|
|
1054
1073
|
{
|
|
1055
1074
|
value: field.label,
|
|
1056
1075
|
onSelect: () => handleAddField(field.value),
|
|
1057
1076
|
className: "cls_command_item",
|
|
1058
|
-
children:
|
|
1059
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1060
|
-
lucideReact.Check,
|
|
1061
|
-
{
|
|
1062
|
-
className: cn(
|
|
1063
|
-
"cls_check_icon mr-2 h-4 w-4",
|
|
1064
|
-
"opacity-0"
|
|
1065
|
-
)
|
|
1066
|
-
}
|
|
1067
|
-
),
|
|
1068
|
-
field.label
|
|
1069
|
-
]
|
|
1077
|
+
children: field.label
|
|
1070
1078
|
},
|
|
1071
1079
|
field.value
|
|
1072
1080
|
)) }) })
|
|
1073
1081
|
] }) })
|
|
1074
|
-
] }) })
|
|
1075
|
-
filterFields.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_filter_fields_list space-y-2", children: filterFields.map((filterConfig) => {
|
|
1076
|
-
const fieldConfig = getFieldConfig(filterConfig.field);
|
|
1077
|
-
if (!fieldConfig) return null;
|
|
1078
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1079
|
-
FilterFieldItem,
|
|
1080
|
-
{
|
|
1081
|
-
filterConfig,
|
|
1082
|
-
fieldConfig,
|
|
1083
|
-
onValueChange: (value) => handleValueChange(filterConfig.field, value),
|
|
1084
|
-
onOperatorChange: (operator) => handleOperatorChange(filterConfig.field, operator),
|
|
1085
|
-
onDelete: () => handleDeleteField(filterConfig.field)
|
|
1086
|
-
},
|
|
1087
|
-
filterConfig.field
|
|
1088
|
-
);
|
|
1089
|
-
}) }) : /* @__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.' })
|
|
1082
|
+
] }) })
|
|
1090
1083
|
] }),
|
|
1091
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogFooter, { children: [
|
|
1092
|
-
filterFields.length > 0 && /* @__PURE__ */ jsxRuntime.
|
|
1084
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogFooter, { className: "cls_filter_dialog_footer flex flex-row items-center justify-between gap-2 border-t bg-muted/20 px-5 py-3 sm:justify-between sm:space-x-0", children: [
|
|
1085
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_footer_left", children: filterFields.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1093
1086
|
Button,
|
|
1094
1087
|
{
|
|
1095
|
-
variant: "
|
|
1088
|
+
variant: "ghost",
|
|
1089
|
+
size: "sm",
|
|
1096
1090
|
onClick: handleClearAll,
|
|
1097
|
-
className: "cls_clear_all_btn",
|
|
1091
|
+
className: "cls_clear_all_btn text-muted-foreground hover:text-foreground",
|
|
1098
1092
|
style: clearButtonStyles,
|
|
1099
|
-
children:
|
|
1100
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "cls_clear_all_icon h-4 w-4 mr-2" }),
|
|
1101
|
-
"Clear All"
|
|
1102
|
-
]
|
|
1103
|
-
}
|
|
1104
|
-
),
|
|
1105
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1106
|
-
Button,
|
|
1107
|
-
{
|
|
1108
|
-
onClick: handleApply,
|
|
1109
|
-
className: "cls_apply_btn",
|
|
1110
|
-
style: submitButtonStyles,
|
|
1111
|
-
children: "Apply"
|
|
1112
|
-
}
|
|
1113
|
-
),
|
|
1114
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1115
|
-
Button,
|
|
1116
|
-
{
|
|
1117
|
-
variant: "outline",
|
|
1118
|
-
onClick: handleCancel,
|
|
1119
|
-
className: "cls_cancel_btn",
|
|
1120
|
-
style: cancelButtonStyles,
|
|
1121
|
-
children: "Cancel"
|
|
1093
|
+
children: "Clear all"
|
|
1122
1094
|
}
|
|
1123
|
-
)
|
|
1095
|
+
) }),
|
|
1096
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_footer_right flex items-center gap-2", children: [
|
|
1097
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1098
|
+
Button,
|
|
1099
|
+
{
|
|
1100
|
+
variant: "outline",
|
|
1101
|
+
size: "sm",
|
|
1102
|
+
onClick: handleCancel,
|
|
1103
|
+
className: "cls_cancel_btn",
|
|
1104
|
+
style: cancelButtonStyles,
|
|
1105
|
+
children: "Cancel"
|
|
1106
|
+
}
|
|
1107
|
+
),
|
|
1108
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1109
|
+
Button,
|
|
1110
|
+
{
|
|
1111
|
+
size: "sm",
|
|
1112
|
+
onClick: handleApply,
|
|
1113
|
+
className: "cls_apply_btn",
|
|
1114
|
+
style: submitButtonStyles,
|
|
1115
|
+
children: "Apply"
|
|
1116
|
+
}
|
|
1117
|
+
)
|
|
1118
|
+
] })
|
|
1124
1119
|
] })
|
|
1125
1120
|
] })
|
|
1126
1121
|
] });
|
|
1127
1122
|
}
|
|
1128
|
-
var Switch = React27__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1129
|
-
SwitchPrimitives__namespace.Root,
|
|
1130
|
-
{
|
|
1131
|
-
className: cn(
|
|
1132
|
-
"peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
|
1133
|
-
className
|
|
1134
|
-
),
|
|
1135
|
-
...props,
|
|
1136
|
-
ref,
|
|
1137
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1138
|
-
SwitchPrimitives__namespace.Thumb,
|
|
1139
|
-
{
|
|
1140
|
-
className: cn(
|
|
1141
|
-
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
|
|
1142
|
-
)
|
|
1143
|
-
}
|
|
1144
|
-
)
|
|
1145
|
-
}
|
|
1146
|
-
));
|
|
1147
|
-
Switch.displayName = SwitchPrimitives__namespace.Root.displayName;
|
|
1148
|
-
var Label2 = React27__namespace.forwardRef(
|
|
1149
|
-
({ className, ...props }, ref) => {
|
|
1150
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1151
|
-
"label",
|
|
1152
|
-
{
|
|
1153
|
-
ref,
|
|
1154
|
-
className: cn(
|
|
1155
|
-
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
1156
|
-
className
|
|
1157
|
-
),
|
|
1158
|
-
...props
|
|
1159
|
-
}
|
|
1160
|
-
);
|
|
1161
|
-
}
|
|
1162
|
-
);
|
|
1163
|
-
Label2.displayName = "Label";
|
|
1164
1123
|
function SortableSortFieldItem({
|
|
1165
1124
|
sortConfig,
|
|
1166
1125
|
fieldLabel,
|
|
1126
|
+
priority,
|
|
1167
1127
|
onDirectionChange,
|
|
1168
1128
|
onDelete
|
|
1169
1129
|
}) {
|
|
@@ -1178,46 +1138,88 @@ function SortableSortFieldItem({
|
|
|
1178
1138
|
const style = {
|
|
1179
1139
|
transform: utilities.CSS.Transform.toString(transform),
|
|
1180
1140
|
transition,
|
|
1181
|
-
opacity: isDragging ? 0.
|
|
1141
|
+
opacity: isDragging ? 0.6 : 1,
|
|
1142
|
+
zIndex: isDragging ? 10 : void 0
|
|
1182
1143
|
};
|
|
1183
1144
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1184
1145
|
"div",
|
|
1185
1146
|
{
|
|
1186
1147
|
ref: setNodeRef,
|
|
1187
1148
|
style,
|
|
1188
|
-
className:
|
|
1149
|
+
className: cn(
|
|
1150
|
+
"cls_sortable_sort_field_item group flex items-center gap-2.5 rounded-lg border border-border/70 bg-card pl-1.5 pr-2 py-2 transition-shadow",
|
|
1151
|
+
isDragging ? "shadow-md" : "hover:border-border"
|
|
1152
|
+
),
|
|
1189
1153
|
children: [
|
|
1190
1154
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1191
|
-
"
|
|
1155
|
+
"button",
|
|
1192
1156
|
{
|
|
1157
|
+
type: "button",
|
|
1193
1158
|
...attributes,
|
|
1194
1159
|
...listeners,
|
|
1195
|
-
className: "cls_drag_handle cursor-grab
|
|
1160
|
+
className: "cls_drag_handle flex h-7 w-5 shrink-0 cursor-grab items-center justify-center rounded text-muted-foreground/60 hover:text-foreground active:cursor-grabbing",
|
|
1161
|
+
"aria-label": `Reorder ${fieldLabel}`,
|
|
1196
1162
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GripVertical, { className: "cls_drag_icon h-4 w-4" })
|
|
1197
1163
|
}
|
|
1198
1164
|
),
|
|
1199
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1165
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1166
|
+
"span",
|
|
1167
|
+
{
|
|
1168
|
+
className: "cls_priority_badge inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-semibold tabular-nums text-muted-foreground",
|
|
1169
|
+
"aria-label": `Sort priority ${priority}`,
|
|
1170
|
+
children: priority
|
|
1171
|
+
}
|
|
1172
|
+
),
|
|
1173
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cls_field_label flex-1 truncate text-sm font-medium text-foreground", children: fieldLabel }),
|
|
1174
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1175
|
+
"div",
|
|
1176
|
+
{
|
|
1177
|
+
role: "radiogroup",
|
|
1178
|
+
"aria-label": `Sort direction for ${fieldLabel}`,
|
|
1179
|
+
className: "cls_direction_control inline-flex shrink-0 items-center rounded-md border border-border/70 bg-muted/40 p-0.5",
|
|
1180
|
+
children: [
|
|
1181
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1182
|
+
"button",
|
|
1183
|
+
{
|
|
1184
|
+
type: "button",
|
|
1185
|
+
role: "radio",
|
|
1186
|
+
"aria-checked": sortConfig.direction === "asc",
|
|
1187
|
+
"data-active": sortConfig.direction === "asc",
|
|
1188
|
+
onClick: () => onDirectionChange("asc"),
|
|
1189
|
+
className: "cls_dir_asc inline-flex items-center gap-1 rounded px-2 py-1 text-xs font-medium text-muted-foreground transition-colors data-[active=true]:bg-background data-[active=true]:text-foreground data-[active=true]:shadow-sm hover:text-foreground",
|
|
1190
|
+
children: [
|
|
1191
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, { className: "h-3 w-3" }),
|
|
1192
|
+
"Asc"
|
|
1193
|
+
]
|
|
1194
|
+
}
|
|
1195
|
+
),
|
|
1196
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1197
|
+
"button",
|
|
1198
|
+
{
|
|
1199
|
+
type: "button",
|
|
1200
|
+
role: "radio",
|
|
1201
|
+
"aria-checked": sortConfig.direction === "desc",
|
|
1202
|
+
"data-active": sortConfig.direction === "desc",
|
|
1203
|
+
onClick: () => onDirectionChange("desc"),
|
|
1204
|
+
className: "cls_dir_desc inline-flex items-center gap-1 rounded px-2 py-1 text-xs font-medium text-muted-foreground transition-colors data-[active=true]:bg-background data-[active=true]:text-foreground data-[active=true]:shadow-sm hover:text-foreground",
|
|
1205
|
+
children: [
|
|
1206
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDown, { className: "h-3 w-3" }),
|
|
1207
|
+
"Desc"
|
|
1208
|
+
]
|
|
1209
|
+
}
|
|
1210
|
+
)
|
|
1211
|
+
]
|
|
1212
|
+
}
|
|
1213
|
+
),
|
|
1212
1214
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1213
1215
|
Button,
|
|
1214
1216
|
{
|
|
1215
1217
|
variant: "ghost",
|
|
1216
1218
|
size: "sm",
|
|
1217
1219
|
onClick: onDelete,
|
|
1218
|
-
className: "cls_delete_btn h-
|
|
1220
|
+
className: "cls_delete_btn h-7 w-7 shrink-0 p-0 text-muted-foreground/60 hover:bg-destructive/10 hover:text-destructive",
|
|
1219
1221
|
"aria-label": `Remove ${fieldLabel} from sort`,
|
|
1220
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.
|
|
1222
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "cls_delete_icon h-3.5 w-3.5" })
|
|
1221
1223
|
}
|
|
1222
1224
|
)
|
|
1223
1225
|
]
|
|
@@ -1229,7 +1231,7 @@ function HazoUiMultiSortDialog({
|
|
|
1229
1231
|
onSortChange,
|
|
1230
1232
|
initialSortFields = [],
|
|
1231
1233
|
title = "Sort",
|
|
1232
|
-
description = "Add
|
|
1234
|
+
description = "Add fields to sort by, drag to reorder, toggle ascending or descending.",
|
|
1233
1235
|
headerBackgroundColor,
|
|
1234
1236
|
headerTextColor,
|
|
1235
1237
|
submitButtonBackgroundColor,
|
|
@@ -1270,16 +1272,16 @@ function HazoUiMultiSortDialog({
|
|
|
1270
1272
|
...finalHeaderBgColor && { backgroundColor: finalHeaderBgColor },
|
|
1271
1273
|
...finalHeaderTextColor && { color: finalHeaderTextColor }
|
|
1272
1274
|
};
|
|
1273
|
-
const [isOpen, setIsOpen] =
|
|
1274
|
-
const [sortFields, setSortFields] =
|
|
1275
|
-
const [isComboboxOpen, setIsComboboxOpen] =
|
|
1275
|
+
const [isOpen, setIsOpen] = React25.useState(false);
|
|
1276
|
+
const [sortFields, setSortFields] = React25.useState(initialSortFields);
|
|
1277
|
+
const [isComboboxOpen, setIsComboboxOpen] = React25.useState(false);
|
|
1276
1278
|
const sensors = core$1.useSensors(
|
|
1277
|
-
core$1.useSensor(core$1.PointerSensor),
|
|
1279
|
+
core$1.useSensor(core$1.PointerSensor, { activationConstraint: { distance: 4 } }),
|
|
1278
1280
|
core$1.useSensor(core$1.KeyboardSensor, {
|
|
1279
1281
|
coordinateGetter: sortable.sortableKeyboardCoordinates
|
|
1280
1282
|
})
|
|
1281
1283
|
);
|
|
1282
|
-
|
|
1284
|
+
React25.useEffect(() => {
|
|
1283
1285
|
if (isOpen) {
|
|
1284
1286
|
setSortFields(initialSortFields);
|
|
1285
1287
|
}
|
|
@@ -1288,11 +1290,7 @@ function HazoUiMultiSortDialog({
|
|
|
1288
1290
|
if (sortFields.some((sf) => sf.field === fieldValue)) {
|
|
1289
1291
|
return;
|
|
1290
1292
|
}
|
|
1291
|
-
|
|
1292
|
-
field: fieldValue,
|
|
1293
|
-
direction: "asc"
|
|
1294
|
-
};
|
|
1295
|
-
setSortFields([...sortFields, newField]);
|
|
1293
|
+
setSortFields([...sortFields, { field: fieldValue, direction: "asc" }]);
|
|
1296
1294
|
setIsComboboxOpen(false);
|
|
1297
1295
|
};
|
|
1298
1296
|
const handleDeleteField = (fieldValue) => {
|
|
@@ -1307,9 +1305,7 @@ function HazoUiMultiSortDialog({
|
|
|
1307
1305
|
};
|
|
1308
1306
|
const handleDragEnd = (event) => {
|
|
1309
1307
|
const { active, over } = event;
|
|
1310
|
-
if (!over || active.id === over.id)
|
|
1311
|
-
return;
|
|
1312
|
-
}
|
|
1308
|
+
if (!over || active.id === over.id) return;
|
|
1313
1309
|
const oldIndex = sortFields.findIndex((sf) => sf.field === active.id);
|
|
1314
1310
|
const newIndex = sortFields.findIndex((sf) => sf.field === over.id);
|
|
1315
1311
|
if (oldIndex !== -1 && newIndex !== -1) {
|
|
@@ -1335,7 +1331,7 @@ function HazoUiMultiSortDialog({
|
|
|
1335
1331
|
};
|
|
1336
1332
|
const hasActiveSorts = initialSortFields.length > 0;
|
|
1337
1333
|
const tooltipContent = hasActiveSorts ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_sort_tooltip_content space-y-1", children: [
|
|
1338
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_tooltip_title text-xs font-semibold mb-1", children: "Active
|
|
1334
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_tooltip_title text-xs font-semibold mb-1", children: "Active sorts" }),
|
|
1339
1335
|
initialSortFields.map((sortConfig, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_tooltip_item text-xs", children: [
|
|
1340
1336
|
index + 1,
|
|
1341
1337
|
". ",
|
|
@@ -1364,61 +1360,27 @@ function HazoUiMultiSortDialog({
|
|
|
1364
1360
|
)
|
|
1365
1361
|
}
|
|
1366
1362
|
),
|
|
1367
|
-
"Sort"
|
|
1363
|
+
"Sort",
|
|
1364
|
+
hasActiveSorts && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cls_sort_count ml-2 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-blue-600 px-1 text-[10px] font-semibold text-white", children: initialSortFields.length })
|
|
1368
1365
|
]
|
|
1369
1366
|
}
|
|
1370
1367
|
) }) }),
|
|
1371
1368
|
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: tooltipContent })
|
|
1372
1369
|
] }) }),
|
|
1373
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "cls_sort_dialog_content max-w-lg", children: [
|
|
1374
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
children: [
|
|
1388
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_combobox_content flex items-center", children: [
|
|
1389
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "cls_plus_icon h-4 w-4 mr-2" }),
|
|
1390
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Add field" })
|
|
1391
|
-
] }),
|
|
1392
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsUpDown, { className: "cls_chevron_icon ml-2 h-4 w-4 shrink-0 opacity-50" })
|
|
1393
|
-
]
|
|
1394
|
-
}
|
|
1395
|
-
) }),
|
|
1396
|
-
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "cls_combobox_popover w-full p-0", children: /* @__PURE__ */ jsxRuntime.jsxs(Command, { children: [
|
|
1397
|
-
/* @__PURE__ */ jsxRuntime.jsx(CommandInput, { placeholder: "Search fields...", className: "cls_command_input" }),
|
|
1398
|
-
/* @__PURE__ */ jsxRuntime.jsx(CommandList, { children: availableFieldsToAdd.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(CommandEmpty, { children: "No fields found." }) : /* @__PURE__ */ jsxRuntime.jsx(CommandGroup, { children: availableFieldsToAdd.map((field) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1399
|
-
CommandItem,
|
|
1400
|
-
{
|
|
1401
|
-
value: field.label,
|
|
1402
|
-
onSelect: () => handleAddField(field.value),
|
|
1403
|
-
className: "cls_command_item",
|
|
1404
|
-
children: [
|
|
1405
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1406
|
-
lucideReact.Check,
|
|
1407
|
-
{
|
|
1408
|
-
className: cn(
|
|
1409
|
-
"cls_check_icon mr-2 h-4 w-4",
|
|
1410
|
-
"opacity-0"
|
|
1411
|
-
)
|
|
1412
|
-
}
|
|
1413
|
-
),
|
|
1414
|
-
field.label
|
|
1415
|
-
]
|
|
1416
|
-
},
|
|
1417
|
-
field.value
|
|
1418
|
-
)) }) })
|
|
1419
|
-
] }) })
|
|
1420
|
-
] }) }),
|
|
1421
|
-
sortFields.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_sort_fields_list space-y-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1370
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "cls_sort_dialog_content max-w-lg gap-0 p-0 sm:rounded-xl", children: [
|
|
1371
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1372
|
+
DialogHeader,
|
|
1373
|
+
{
|
|
1374
|
+
className: "cls_sort_dialog_header space-y-1 border-b px-5 py-4 text-left",
|
|
1375
|
+
style: headerStyles,
|
|
1376
|
+
children: [
|
|
1377
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "text-base font-semibold", children: title }),
|
|
1378
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { className: "text-xs leading-relaxed text-muted-foreground", children: description })
|
|
1379
|
+
]
|
|
1380
|
+
}
|
|
1381
|
+
),
|
|
1382
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_sort_dialog_body space-y-3 px-5 py-4", children: [
|
|
1383
|
+
sortFields.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_sort_fields_list space-y-1.5", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1422
1384
|
core$1.DndContext,
|
|
1423
1385
|
{
|
|
1424
1386
|
sensors,
|
|
@@ -1429,11 +1391,12 @@ function HazoUiMultiSortDialog({
|
|
|
1429
1391
|
{
|
|
1430
1392
|
items: sortFields.map((sf) => sf.field),
|
|
1431
1393
|
strategy: sortable.verticalListSortingStrategy,
|
|
1432
|
-
children: sortFields.map((sortConfig) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1394
|
+
children: sortFields.map((sortConfig, idx) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1433
1395
|
SortableSortFieldItem,
|
|
1434
1396
|
{
|
|
1435
1397
|
sortConfig,
|
|
1436
1398
|
fieldLabel: getFieldLabel(sortConfig.field),
|
|
1399
|
+
priority: idx + 1,
|
|
1437
1400
|
onDirectionChange: (direction) => handleDirectionChange(sortConfig.field, direction),
|
|
1438
1401
|
onDelete: () => handleDeleteField(sortConfig.field)
|
|
1439
1402
|
},
|
|
@@ -1442,46 +1405,77 @@ function HazoUiMultiSortDialog({
|
|
|
1442
1405
|
}
|
|
1443
1406
|
)
|
|
1444
1407
|
}
|
|
1445
|
-
) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_empty_sort_fields
|
|
1408
|
+
) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_empty_sort_fields rounded-lg border border-dashed border-border/70 bg-muted/20 px-4 py-6 text-center text-xs text-muted-foreground", children: "No sort fields yet. Add one below to start ordering rows." }),
|
|
1409
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_add_field_section", children: /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: isComboboxOpen, onOpenChange: setIsComboboxOpen, children: [
|
|
1410
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1411
|
+
Button,
|
|
1412
|
+
{
|
|
1413
|
+
variant: "ghost",
|
|
1414
|
+
role: "combobox",
|
|
1415
|
+
"aria-expanded": isComboboxOpen,
|
|
1416
|
+
disabled: availableFieldsToAdd.length === 0,
|
|
1417
|
+
className: "cls_add_field_combobox w-full justify-start gap-2 border border-dashed border-border/70 text-sm font-medium text-muted-foreground hover:border-border hover:bg-muted/40 hover:text-foreground",
|
|
1418
|
+
children: [
|
|
1419
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "cls_plus_icon h-4 w-4" }),
|
|
1420
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: availableFieldsToAdd.length === 0 ? "All fields added" : "Add sort field" })
|
|
1421
|
+
]
|
|
1422
|
+
}
|
|
1423
|
+
) }),
|
|
1424
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "cls_combobox_popover w-[var(--radix-popover-trigger-width)] p-0", align: "start", children: /* @__PURE__ */ jsxRuntime.jsxs(Command, { children: [
|
|
1425
|
+
/* @__PURE__ */ jsxRuntime.jsx(CommandInput, { placeholder: "Search fields...", className: "cls_command_input" }),
|
|
1426
|
+
/* @__PURE__ */ jsxRuntime.jsx(CommandList, { children: availableFieldsToAdd.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(CommandEmpty, { children: "No fields available." }) : /* @__PURE__ */ jsxRuntime.jsx(CommandGroup, { children: availableFieldsToAdd.map((field) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1427
|
+
CommandItem,
|
|
1428
|
+
{
|
|
1429
|
+
value: field.label,
|
|
1430
|
+
onSelect: () => handleAddField(field.value),
|
|
1431
|
+
className: "cls_command_item",
|
|
1432
|
+
children: field.label
|
|
1433
|
+
},
|
|
1434
|
+
field.value
|
|
1435
|
+
)) }) })
|
|
1436
|
+
] }) })
|
|
1437
|
+
] }) })
|
|
1446
1438
|
] }),
|
|
1447
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogFooter, { children: [
|
|
1448
|
-
sortFields.length > 0 && /* @__PURE__ */ jsxRuntime.
|
|
1439
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogFooter, { className: "cls_sort_dialog_footer flex flex-row items-center justify-between gap-2 border-t bg-muted/20 px-5 py-3 sm:justify-between sm:space-x-0", children: [
|
|
1440
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_footer_left", children: sortFields.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1449
1441
|
Button,
|
|
1450
1442
|
{
|
|
1451
|
-
variant: "
|
|
1443
|
+
variant: "ghost",
|
|
1444
|
+
size: "sm",
|
|
1452
1445
|
onClick: handleClearAll,
|
|
1453
|
-
className: "cls_clear_all_btn",
|
|
1446
|
+
className: "cls_clear_all_btn text-muted-foreground hover:text-foreground",
|
|
1454
1447
|
style: clearButtonStyles,
|
|
1455
|
-
children:
|
|
1456
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "cls_clear_all_icon h-4 w-4 mr-2" }),
|
|
1457
|
-
"Clear All"
|
|
1458
|
-
]
|
|
1459
|
-
}
|
|
1460
|
-
),
|
|
1461
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1462
|
-
Button,
|
|
1463
|
-
{
|
|
1464
|
-
onClick: handleApply,
|
|
1465
|
-
className: "cls_apply_btn",
|
|
1466
|
-
style: submitButtonStyles,
|
|
1467
|
-
children: "Apply"
|
|
1468
|
-
}
|
|
1469
|
-
),
|
|
1470
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1471
|
-
Button,
|
|
1472
|
-
{
|
|
1473
|
-
variant: "outline",
|
|
1474
|
-
onClick: handleCancel,
|
|
1475
|
-
className: "cls_cancel_btn",
|
|
1476
|
-
style: cancelButtonStyles,
|
|
1477
|
-
children: "Cancel"
|
|
1448
|
+
children: "Clear all"
|
|
1478
1449
|
}
|
|
1479
|
-
)
|
|
1450
|
+
) }),
|
|
1451
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_footer_right flex items-center gap-2", children: [
|
|
1452
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1453
|
+
Button,
|
|
1454
|
+
{
|
|
1455
|
+
variant: "outline",
|
|
1456
|
+
size: "sm",
|
|
1457
|
+
onClick: handleCancel,
|
|
1458
|
+
className: "cls_cancel_btn",
|
|
1459
|
+
style: cancelButtonStyles,
|
|
1460
|
+
children: "Cancel"
|
|
1461
|
+
}
|
|
1462
|
+
),
|
|
1463
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1464
|
+
Button,
|
|
1465
|
+
{
|
|
1466
|
+
size: "sm",
|
|
1467
|
+
onClick: handleApply,
|
|
1468
|
+
className: "cls_apply_btn",
|
|
1469
|
+
style: submitButtonStyles,
|
|
1470
|
+
children: "Apply"
|
|
1471
|
+
}
|
|
1472
|
+
)
|
|
1473
|
+
] })
|
|
1480
1474
|
] })
|
|
1481
1475
|
] })
|
|
1482
1476
|
] });
|
|
1483
1477
|
}
|
|
1484
|
-
var RadioGroup =
|
|
1478
|
+
var RadioGroup = React25__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
1485
1479
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1486
1480
|
RadioGroupPrimitive__namespace.Root,
|
|
1487
1481
|
{
|
|
@@ -1492,7 +1486,7 @@ var RadioGroup = React27__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
1492
1486
|
);
|
|
1493
1487
|
});
|
|
1494
1488
|
RadioGroup.displayName = RadioGroupPrimitive__namespace.Root.displayName;
|
|
1495
|
-
var RadioGroupItem =
|
|
1489
|
+
var RadioGroupItem = React25__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
1496
1490
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1497
1491
|
RadioGroupPrimitive__namespace.Item,
|
|
1498
1492
|
{
|
|
@@ -1949,7 +1943,7 @@ function filterInputValue(value, input_type, num_decimals) {
|
|
|
1949
1943
|
}
|
|
1950
1944
|
}
|
|
1951
1945
|
}
|
|
1952
|
-
var HazoUiFlexInput =
|
|
1946
|
+
var HazoUiFlexInput = React25__namespace.forwardRef(
|
|
1953
1947
|
({
|
|
1954
1948
|
className,
|
|
1955
1949
|
input_type = "mixed",
|
|
@@ -1966,13 +1960,13 @@ var HazoUiFlexInput = React27__namespace.forwardRef(
|
|
|
1966
1960
|
onBlur,
|
|
1967
1961
|
...props
|
|
1968
1962
|
}, ref) => {
|
|
1969
|
-
const [internalValue, setInternalValue] =
|
|
1963
|
+
const [internalValue, setInternalValue] = React25__namespace.useState(
|
|
1970
1964
|
typeof controlledValue === "string" ? controlledValue : typeof controlledValue === "number" ? String(controlledValue) : ""
|
|
1971
1965
|
);
|
|
1972
|
-
const [errorMessage, setErrorMessage] =
|
|
1966
|
+
const [errorMessage, setErrorMessage] = React25__namespace.useState();
|
|
1973
1967
|
const isControlled = controlledValue !== void 0;
|
|
1974
1968
|
const currentValue = isControlled ? typeof controlledValue === "string" ? controlledValue : String(controlledValue || "") : internalValue;
|
|
1975
|
-
|
|
1969
|
+
React25__namespace.useEffect(() => {
|
|
1976
1970
|
if (isControlled) {
|
|
1977
1971
|
const newValue = typeof controlledValue === "string" ? controlledValue : String(controlledValue || "");
|
|
1978
1972
|
if (newValue !== internalValue) {
|
|
@@ -2052,7 +2046,7 @@ var HazoUiFlexInput = React27__namespace.forwardRef(
|
|
|
2052
2046
|
}
|
|
2053
2047
|
);
|
|
2054
2048
|
HazoUiFlexInput.displayName = "HazoUiFlexInput";
|
|
2055
|
-
var ToolbarButton =
|
|
2049
|
+
var ToolbarButton = React25__namespace.forwardRef(
|
|
2056
2050
|
({ onClick, is_active = false, disabled = false, tooltip, className, children }, ref) => {
|
|
2057
2051
|
const button = /* @__PURE__ */ jsxRuntime.jsx(
|
|
2058
2052
|
"button",
|
|
@@ -2339,11 +2333,11 @@ var validHex = (hex) => /^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
|
|
|
2339
2333
|
var import_extends2 = __toESM(require_extends());
|
|
2340
2334
|
var import_objectWithoutPropertiesLoose = __toESM(require_objectWithoutPropertiesLoose());
|
|
2341
2335
|
function useEventCallback(handler) {
|
|
2342
|
-
var callbackRef =
|
|
2343
|
-
|
|
2336
|
+
var callbackRef = React25.useRef(handler);
|
|
2337
|
+
React25.useEffect(() => {
|
|
2344
2338
|
callbackRef.current = handler;
|
|
2345
2339
|
});
|
|
2346
|
-
return
|
|
2340
|
+
return React25.useCallback((value, event) => callbackRef.current && callbackRef.current(value, event), []);
|
|
2347
2341
|
}
|
|
2348
2342
|
var isTouch = (event) => "touches" in event;
|
|
2349
2343
|
var preventDefaultMove = (event) => {
|
|
@@ -2371,16 +2365,16 @@ var getRelativePosition = (node, event) => {
|
|
|
2371
2365
|
};
|
|
2372
2366
|
};
|
|
2373
2367
|
var _excluded = ["prefixCls", "className", "onMove", "onDown"];
|
|
2374
|
-
var Interactive = /* @__PURE__ */
|
|
2368
|
+
var Interactive = /* @__PURE__ */ React25__namespace.default.forwardRef((props, ref) => {
|
|
2375
2369
|
var {
|
|
2376
2370
|
prefixCls = "w-color-interactive",
|
|
2377
2371
|
className,
|
|
2378
2372
|
onMove,
|
|
2379
2373
|
onDown
|
|
2380
2374
|
} = props, reset = (0, import_objectWithoutPropertiesLoose.default)(props, _excluded);
|
|
2381
|
-
var container =
|
|
2382
|
-
var hasTouched =
|
|
2383
|
-
var [isDragging, setDragging] =
|
|
2375
|
+
var container = React25.useRef(null);
|
|
2376
|
+
var hasTouched = React25.useRef(false);
|
|
2377
|
+
var [isDragging, setDragging] = React25.useState(false);
|
|
2384
2378
|
var onMoveCallback = useEventCallback(onMove);
|
|
2385
2379
|
var onKeyCallback = useEventCallback(onDown);
|
|
2386
2380
|
var isValid = (event) => {
|
|
@@ -2388,7 +2382,7 @@ var Interactive = /* @__PURE__ */ React27__namespace.default.forwardRef((props,
|
|
|
2388
2382
|
hasTouched.current = isTouch(event);
|
|
2389
2383
|
return true;
|
|
2390
2384
|
};
|
|
2391
|
-
var handleMove =
|
|
2385
|
+
var handleMove = React25.useCallback((event) => {
|
|
2392
2386
|
preventDefaultMove(event);
|
|
2393
2387
|
if (!container.current) return;
|
|
2394
2388
|
var isDown = isTouch(event) ? event.touches.length > 0 : event.buttons > 0;
|
|
@@ -2398,8 +2392,8 @@ var Interactive = /* @__PURE__ */ React27__namespace.default.forwardRef((props,
|
|
|
2398
2392
|
}
|
|
2399
2393
|
onMoveCallback == null || onMoveCallback(getRelativePosition(container.current, event), event);
|
|
2400
2394
|
}, [onMoveCallback]);
|
|
2401
|
-
var handleMoveEnd =
|
|
2402
|
-
var toggleDocumentEvents =
|
|
2395
|
+
var handleMoveEnd = React25.useCallback(() => setDragging(false), []);
|
|
2396
|
+
var toggleDocumentEvents = React25.useCallback((state) => {
|
|
2403
2397
|
if (state) {
|
|
2404
2398
|
window.addEventListener(hasTouched.current ? "touchmove" : "mousemove", handleMove);
|
|
2405
2399
|
window.addEventListener(hasTouched.current ? "touchend" : "mouseup", handleMoveEnd);
|
|
@@ -2410,13 +2404,13 @@ var Interactive = /* @__PURE__ */ React27__namespace.default.forwardRef((props,
|
|
|
2410
2404
|
window.removeEventListener("touchend", handleMoveEnd);
|
|
2411
2405
|
}
|
|
2412
2406
|
}, [handleMove, handleMoveEnd]);
|
|
2413
|
-
|
|
2407
|
+
React25.useEffect(() => {
|
|
2414
2408
|
toggleDocumentEvents(isDragging);
|
|
2415
2409
|
return () => {
|
|
2416
2410
|
toggleDocumentEvents(false);
|
|
2417
2411
|
};
|
|
2418
2412
|
}, [isDragging, handleMove, handleMoveEnd, toggleDocumentEvents]);
|
|
2419
|
-
var handleMoveStart =
|
|
2413
|
+
var handleMoveStart = React25.useCallback((event) => {
|
|
2420
2414
|
var activeEl = document.activeElement;
|
|
2421
2415
|
activeEl == null || activeEl.blur();
|
|
2422
2416
|
preventDefaultMove(event.nativeEvent);
|
|
@@ -2460,7 +2454,7 @@ var Pointer = (_ref) => {
|
|
|
2460
2454
|
borderRadius: "50%",
|
|
2461
2455
|
backgroundColor: color2
|
|
2462
2456
|
};
|
|
2463
|
-
return
|
|
2457
|
+
return React25.useMemo(() => /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
2464
2458
|
className: prefixCls + "-pointer " + (className || ""),
|
|
2465
2459
|
style,
|
|
2466
2460
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
@@ -2470,7 +2464,7 @@ var Pointer = (_ref) => {
|
|
|
2470
2464
|
}), [top, left, color2, className, prefixCls]);
|
|
2471
2465
|
};
|
|
2472
2466
|
var _excluded2 = ["prefixCls", "radius", "pointer", "className", "hue", "style", "hsva", "onChange"];
|
|
2473
|
-
var Saturation = /* @__PURE__ */
|
|
2467
|
+
var Saturation = /* @__PURE__ */ React25__namespace.default.forwardRef((props, ref) => {
|
|
2474
2468
|
var _hsva$h;
|
|
2475
2469
|
var {
|
|
2476
2470
|
prefixCls = "w-color-saturation",
|
|
@@ -2498,7 +2492,7 @@ var Saturation = /* @__PURE__ */ React27__namespace.default.forwardRef((props, r
|
|
|
2498
2492
|
// source: 'hsv',
|
|
2499
2493
|
});
|
|
2500
2494
|
};
|
|
2501
|
-
var handleKeyDown =
|
|
2495
|
+
var handleKeyDown = React25.useCallback((event) => {
|
|
2502
2496
|
if (!hsva || !onChange) return;
|
|
2503
2497
|
var step = 1;
|
|
2504
2498
|
var newS = hsva.s;
|
|
@@ -2537,7 +2531,7 @@ var Saturation = /* @__PURE__ */ React27__namespace.default.forwardRef((props, r
|
|
|
2537
2531
|
});
|
|
2538
2532
|
}
|
|
2539
2533
|
}, [hsva, onChange]);
|
|
2540
|
-
var pointerElement =
|
|
2534
|
+
var pointerElement = React25.useMemo(() => {
|
|
2541
2535
|
if (!hsva) return null;
|
|
2542
2536
|
var comProps = {
|
|
2543
2537
|
top: 100 - hsva.v + "%",
|
|
@@ -2553,7 +2547,7 @@ var Saturation = /* @__PURE__ */ React27__namespace.default.forwardRef((props, r
|
|
|
2553
2547
|
prefixCls
|
|
2554
2548
|
}, comProps));
|
|
2555
2549
|
}, [hsva, pointer, prefixCls]);
|
|
2556
|
-
var handleClick =
|
|
2550
|
+
var handleClick = React25.useCallback((event) => {
|
|
2557
2551
|
event.target.focus();
|
|
2558
2552
|
}, []);
|
|
2559
2553
|
return /* @__PURE__ */ jsxRuntime.jsx(esm_default, (0, import_extends3.default)({
|
|
@@ -2622,7 +2616,7 @@ var Pointer2 = (_ref) => {
|
|
|
2622
2616
|
};
|
|
2623
2617
|
var _excluded4 = ["prefixCls", "className", "hsva", "background", "bgProps", "innerProps", "pointerProps", "radius", "width", "height", "direction", "style", "onChange", "pointer"];
|
|
2624
2618
|
var BACKGROUND_IMG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==";
|
|
2625
|
-
var Alpha = /* @__PURE__ */
|
|
2619
|
+
var Alpha = /* @__PURE__ */ React25__namespace.default.forwardRef((props, ref) => {
|
|
2626
2620
|
var {
|
|
2627
2621
|
prefixCls = "w-color-alpha",
|
|
2628
2622
|
className,
|
|
@@ -2667,7 +2661,7 @@ var Alpha = /* @__PURE__ */ React27__namespace.default.forwardRef((props, ref) =
|
|
|
2667
2661
|
}, style, {
|
|
2668
2662
|
position: "relative"
|
|
2669
2663
|
});
|
|
2670
|
-
var handleKeyDown =
|
|
2664
|
+
var handleKeyDown = React25.useCallback((event) => {
|
|
2671
2665
|
var step = 0.01;
|
|
2672
2666
|
var currentAlpha = hsva.a;
|
|
2673
2667
|
var newAlpha = currentAlpha;
|
|
@@ -2713,7 +2707,7 @@ var Alpha = /* @__PURE__ */ React27__namespace.default.forwardRef((props, ref) =
|
|
|
2713
2707
|
}), syntheticOffset);
|
|
2714
2708
|
}
|
|
2715
2709
|
}, [hsva, direction, onChange]);
|
|
2716
|
-
var handleClick =
|
|
2710
|
+
var handleClick = React25.useCallback((event) => {
|
|
2717
2711
|
event.target.focus();
|
|
2718
2712
|
}, []);
|
|
2719
2713
|
var pointerElement = pointer && typeof pointer === "function" ? pointer((0, import_extends5.default)({
|
|
@@ -2756,7 +2750,7 @@ var import_objectWithoutPropertiesLoose5 = __toESM(require_objectWithoutProperti
|
|
|
2756
2750
|
var _excluded5 = ["prefixCls", "placement", "label", "value", "className", "style", "labelStyle", "inputStyle", "onChange", "onBlur", "renderInput"];
|
|
2757
2751
|
var validHex2 = (hex) => /^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
|
|
2758
2752
|
var getNumberValue = (value) => Number(String(value).replace(/%/g, ""));
|
|
2759
|
-
var EditableInput = /* @__PURE__ */
|
|
2753
|
+
var EditableInput = /* @__PURE__ */ React25__namespace.default.forwardRef((props, ref) => {
|
|
2760
2754
|
var {
|
|
2761
2755
|
prefixCls = "w-color-editable-input",
|
|
2762
2756
|
placement = "bottom",
|
|
@@ -2770,9 +2764,9 @@ var EditableInput = /* @__PURE__ */ React27__namespace.default.forwardRef((props
|
|
|
2770
2764
|
onBlur,
|
|
2771
2765
|
renderInput
|
|
2772
2766
|
} = props, other = (0, import_objectWithoutPropertiesLoose5.default)(props, _excluded5);
|
|
2773
|
-
var [value, setValue] =
|
|
2774
|
-
var isFocus =
|
|
2775
|
-
|
|
2767
|
+
var [value, setValue] = React25.useState(initValue);
|
|
2768
|
+
var isFocus = React25.useRef(false);
|
|
2769
|
+
React25.useEffect(() => {
|
|
2776
2770
|
if (props.value !== value) {
|
|
2777
2771
|
if (!isFocus.current) {
|
|
2778
2772
|
setValue(props.value);
|
|
@@ -2861,7 +2855,7 @@ var esm_default4 = EditableInput;
|
|
|
2861
2855
|
var import_extends7 = __toESM(require_extends());
|
|
2862
2856
|
var import_objectWithoutPropertiesLoose6 = __toESM(require_objectWithoutPropertiesLoose());
|
|
2863
2857
|
var _excluded6 = ["prefixCls", "hsva", "placement", "rProps", "gProps", "bProps", "aProps", "className", "style", "onChange"];
|
|
2864
|
-
var EditableInputRGBA = /* @__PURE__ */
|
|
2858
|
+
var EditableInputRGBA = /* @__PURE__ */ React25__namespace.default.forwardRef((props, ref) => {
|
|
2865
2859
|
var {
|
|
2866
2860
|
prefixCls = "w-color-editable-input-rgba",
|
|
2867
2861
|
hsva,
|
|
@@ -2984,7 +2978,7 @@ var esm_default5 = EditableInputRGBA;
|
|
|
2984
2978
|
var import_extends8 = __toESM(require_extends());
|
|
2985
2979
|
var import_objectWithoutPropertiesLoose7 = __toESM(require_objectWithoutPropertiesLoose());
|
|
2986
2980
|
var _excluded7 = ["prefixCls", "className", "hue", "onChange", "direction"];
|
|
2987
|
-
var Hue = /* @__PURE__ */
|
|
2981
|
+
var Hue = /* @__PURE__ */ React25__namespace.default.forwardRef((props, ref) => {
|
|
2988
2982
|
var {
|
|
2989
2983
|
prefixCls = "w-color-hue",
|
|
2990
2984
|
className,
|
|
@@ -3018,7 +3012,7 @@ var esm_default6 = Hue;
|
|
|
3018
3012
|
var import_extends9 = __toESM(require_extends());
|
|
3019
3013
|
var import_objectWithoutPropertiesLoose8 = __toESM(require_objectWithoutPropertiesLoose());
|
|
3020
3014
|
var _excluded8 = ["prefixCls", "className", "color", "colors", "style", "rectProps", "onChange", "addonAfter", "addonBefore", "rectRender"];
|
|
3021
|
-
var Swatch = /* @__PURE__ */
|
|
3015
|
+
var Swatch = /* @__PURE__ */ React25__namespace.default.forwardRef((props, ref) => {
|
|
3022
3016
|
var {
|
|
3023
3017
|
prefixCls = "w-color-swatch",
|
|
3024
3018
|
className,
|
|
@@ -3055,7 +3049,7 @@ var Swatch = /* @__PURE__ */ React27__namespace.default.forwardRef((props, ref)
|
|
|
3055
3049
|
flexWrap: "wrap",
|
|
3056
3050
|
position: "relative"
|
|
3057
3051
|
}, style),
|
|
3058
|
-
children: [addonBefore && /* @__PURE__ */
|
|
3052
|
+
children: [addonBefore && /* @__PURE__ */ React25__namespace.default.isValidElement(addonBefore) && addonBefore, colors && Array.isArray(colors) && colors.map((item, idx) => {
|
|
3059
3053
|
var title = "";
|
|
3060
3054
|
var background = "";
|
|
3061
3055
|
if (typeof item === "string") {
|
|
@@ -3077,11 +3071,11 @@ var Swatch = /* @__PURE__ */ React27__namespace.default.forwardRef((props, ref)
|
|
|
3077
3071
|
onClick: (evn) => handleClick(background, evn)
|
|
3078
3072
|
});
|
|
3079
3073
|
if (render) {
|
|
3080
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3074
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React25.Fragment, {
|
|
3081
3075
|
children: render
|
|
3082
3076
|
}, idx);
|
|
3083
3077
|
}
|
|
3084
|
-
var child = rectProps.children && /* @__PURE__ */
|
|
3078
|
+
var child = rectProps.children && /* @__PURE__ */ React25__namespace.default.isValidElement(rectProps.children) ? /* @__PURE__ */ React25__namespace.default.cloneElement(rectProps.children, {
|
|
3085
3079
|
color: background,
|
|
3086
3080
|
checked
|
|
3087
3081
|
}) : null;
|
|
@@ -3095,7 +3089,7 @@ var Swatch = /* @__PURE__ */ React27__namespace.default.forwardRef((props, ref)
|
|
|
3095
3089
|
background
|
|
3096
3090
|
})
|
|
3097
3091
|
}), idx);
|
|
3098
|
-
}), addonAfter && /* @__PURE__ */
|
|
3092
|
+
}), addonAfter && /* @__PURE__ */ React25__namespace.default.isValidElement(addonAfter) && addonAfter]
|
|
3099
3093
|
}));
|
|
3100
3094
|
});
|
|
3101
3095
|
Swatch.displayName = "Swatch";
|
|
@@ -3114,7 +3108,7 @@ var Bar = (props) => /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
|
3114
3108
|
backgroundColor: "#fff"
|
|
3115
3109
|
}
|
|
3116
3110
|
});
|
|
3117
|
-
var Sketch = /* @__PURE__ */
|
|
3111
|
+
var Sketch = /* @__PURE__ */ React25__namespace.default.forwardRef((props, ref) => {
|
|
3118
3112
|
var {
|
|
3119
3113
|
prefixCls = "w-color-sketch",
|
|
3120
3114
|
className,
|
|
@@ -3126,13 +3120,13 @@ var Sketch = /* @__PURE__ */ React27__namespace.default.forwardRef((props, ref)
|
|
|
3126
3120
|
disableAlpha = false,
|
|
3127
3121
|
style
|
|
3128
3122
|
} = props, other = (0, import_objectWithoutPropertiesLoose9.default)(props, _excluded9);
|
|
3129
|
-
var [hsva, setHsva] =
|
|
3123
|
+
var [hsva, setHsva] = React25.useState({
|
|
3130
3124
|
h: 209,
|
|
3131
3125
|
s: 36,
|
|
3132
3126
|
v: 90,
|
|
3133
3127
|
a: 1
|
|
3134
3128
|
});
|
|
3135
|
-
|
|
3129
|
+
React25.useEffect(() => {
|
|
3136
3130
|
if (typeof color2 === "string" && validHex(color2)) {
|
|
3137
3131
|
setHsva(hexToHsva(color2));
|
|
3138
3132
|
}
|
|
@@ -3250,7 +3244,7 @@ var Sketch = /* @__PURE__ */ React27__namespace.default.forwardRef((props, ref)
|
|
|
3250
3244
|
innerProps: {
|
|
3251
3245
|
style: styleAlpha
|
|
3252
3246
|
},
|
|
3253
|
-
pointer: () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3247
|
+
pointer: () => /* @__PURE__ */ jsxRuntime.jsx(React25.Fragment, {})
|
|
3254
3248
|
})]
|
|
3255
3249
|
})]
|
|
3256
3250
|
}), editableDisable && /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
@@ -3365,19 +3359,19 @@ var Toolbar = ({
|
|
|
3365
3359
|
on_attachments_change,
|
|
3366
3360
|
disabled = false
|
|
3367
3361
|
}) => {
|
|
3368
|
-
const [link_url, set_link_url] =
|
|
3369
|
-
const [link_popover_open, set_link_popover_open] =
|
|
3370
|
-
const [text_color_open, set_text_color_open] =
|
|
3371
|
-
const [highlight_color_open, set_highlight_color_open] =
|
|
3372
|
-
const [variables_menu_open, set_variables_menu_open] =
|
|
3373
|
-
const [table_menu_open, set_table_menu_open] =
|
|
3374
|
-
const [text_color, set_text_color] =
|
|
3375
|
-
const [highlight_color, set_highlight_color] =
|
|
3376
|
-
const [table_rows, set_table_rows] =
|
|
3377
|
-
const [table_cols, set_table_cols] =
|
|
3378
|
-
const [hovered_cell, set_hovered_cell] =
|
|
3379
|
-
const file_input_ref =
|
|
3380
|
-
const image_input_ref =
|
|
3362
|
+
const [link_url, set_link_url] = React25__namespace.useState("https://");
|
|
3363
|
+
const [link_popover_open, set_link_popover_open] = React25__namespace.useState(false);
|
|
3364
|
+
const [text_color_open, set_text_color_open] = React25__namespace.useState(false);
|
|
3365
|
+
const [highlight_color_open, set_highlight_color_open] = React25__namespace.useState(false);
|
|
3366
|
+
const [variables_menu_open, set_variables_menu_open] = React25__namespace.useState(false);
|
|
3367
|
+
const [table_menu_open, set_table_menu_open] = React25__namespace.useState(false);
|
|
3368
|
+
const [text_color, set_text_color] = React25__namespace.useState("#000000");
|
|
3369
|
+
const [highlight_color, set_highlight_color] = React25__namespace.useState("#ffff00");
|
|
3370
|
+
const [table_rows, set_table_rows] = React25__namespace.useState(3);
|
|
3371
|
+
const [table_cols, set_table_cols] = React25__namespace.useState(3);
|
|
3372
|
+
const [hovered_cell, set_hovered_cell] = React25__namespace.useState(null);
|
|
3373
|
+
const file_input_ref = React25__namespace.useRef(null);
|
|
3374
|
+
const image_input_ref = React25__namespace.useRef(null);
|
|
3381
3375
|
if (!editor) {
|
|
3382
3376
|
return null;
|
|
3383
3377
|
}
|
|
@@ -4310,7 +4304,7 @@ var VariableExtension = core.Node.create({
|
|
|
4310
4304
|
}
|
|
4311
4305
|
});
|
|
4312
4306
|
var Tabs = TabsPrimitive__namespace.Root;
|
|
4313
|
-
var TabsList =
|
|
4307
|
+
var TabsList = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4314
4308
|
TabsPrimitive__namespace.List,
|
|
4315
4309
|
{
|
|
4316
4310
|
ref,
|
|
@@ -4322,7 +4316,7 @@ var TabsList = React27__namespace.forwardRef(({ className, ...props }, ref) => /
|
|
|
4322
4316
|
}
|
|
4323
4317
|
));
|
|
4324
4318
|
TabsList.displayName = TabsPrimitive__namespace.List.displayName;
|
|
4325
|
-
var TabsTrigger =
|
|
4319
|
+
var TabsTrigger = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4326
4320
|
TabsPrimitive__namespace.Trigger,
|
|
4327
4321
|
{
|
|
4328
4322
|
ref,
|
|
@@ -4334,7 +4328,7 @@ var TabsTrigger = React27__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
4334
4328
|
}
|
|
4335
4329
|
));
|
|
4336
4330
|
TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
|
|
4337
|
-
var TabsContent =
|
|
4331
|
+
var TabsContent = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4338
4332
|
TabsPrimitive__namespace.Content,
|
|
4339
4333
|
{
|
|
4340
4334
|
ref,
|
|
@@ -4369,14 +4363,14 @@ var HazoUiRte = ({
|
|
|
4369
4363
|
className,
|
|
4370
4364
|
show_output_viewer = false
|
|
4371
4365
|
}) => {
|
|
4372
|
-
const [attachments, set_attachments] =
|
|
4366
|
+
const [attachments, set_attachments] = React25__namespace.useState(
|
|
4373
4367
|
initial_attachments
|
|
4374
4368
|
);
|
|
4375
|
-
const [active_tab, set_active_tab] =
|
|
4369
|
+
const [active_tab, set_active_tab] = React25__namespace.useState("html");
|
|
4376
4370
|
const is_view_only = active_tab !== "html";
|
|
4377
|
-
const attachments_ref =
|
|
4371
|
+
const attachments_ref = React25__namespace.useRef(attachments);
|
|
4378
4372
|
attachments_ref.current = attachments;
|
|
4379
|
-
const debounced_on_change =
|
|
4373
|
+
const debounced_on_change = React25__namespace.useMemo(
|
|
4380
4374
|
() => debounce_fn((output) => {
|
|
4381
4375
|
if (on_change) {
|
|
4382
4376
|
on_change(output);
|
|
@@ -4475,7 +4469,7 @@ var HazoUiRte = ({
|
|
|
4475
4469
|
debounced_on_change(output);
|
|
4476
4470
|
}
|
|
4477
4471
|
});
|
|
4478
|
-
|
|
4472
|
+
React25__namespace.useEffect(() => {
|
|
4479
4473
|
if (editor && html !== void 0) {
|
|
4480
4474
|
const current_html = editor.getHTML();
|
|
4481
4475
|
if (html !== current_html && !editor.isFocused) {
|
|
@@ -4483,21 +4477,21 @@ var HazoUiRte = ({
|
|
|
4483
4477
|
}
|
|
4484
4478
|
}
|
|
4485
4479
|
}, [html, editor]);
|
|
4486
|
-
|
|
4480
|
+
React25__namespace.useEffect(() => {
|
|
4487
4481
|
if (editor) {
|
|
4488
4482
|
editor.setEditable(!disabled);
|
|
4489
4483
|
}
|
|
4490
4484
|
}, [disabled, editor]);
|
|
4491
|
-
const attachments_from_props_ref =
|
|
4492
|
-
const prev_initial_attachments_ref =
|
|
4493
|
-
|
|
4485
|
+
const attachments_from_props_ref = React25__namespace.useRef(false);
|
|
4486
|
+
const prev_initial_attachments_ref = React25__namespace.useRef(initial_attachments);
|
|
4487
|
+
React25__namespace.useEffect(() => {
|
|
4494
4488
|
if (JSON.stringify(initial_attachments) !== JSON.stringify(prev_initial_attachments_ref.current)) {
|
|
4495
4489
|
prev_initial_attachments_ref.current = initial_attachments;
|
|
4496
4490
|
attachments_from_props_ref.current = true;
|
|
4497
4491
|
set_attachments(initial_attachments);
|
|
4498
4492
|
}
|
|
4499
4493
|
}, [initial_attachments]);
|
|
4500
|
-
|
|
4494
|
+
React25__namespace.useEffect(() => {
|
|
4501
4495
|
if (attachments_from_props_ref.current) {
|
|
4502
4496
|
attachments_from_props_ref.current = false;
|
|
4503
4497
|
return;
|
|
@@ -4999,12 +4993,12 @@ var CommandPopover = ({
|
|
|
4999
4993
|
on_selection_change: _on_selection_change,
|
|
5000
4994
|
prefix_color
|
|
5001
4995
|
}) => {
|
|
5002
|
-
const container_ref =
|
|
5003
|
-
const grouped_commands =
|
|
4996
|
+
const container_ref = React25__namespace.useRef(null);
|
|
4997
|
+
const grouped_commands = React25__namespace.useMemo(
|
|
5004
4998
|
() => group_commands(commands),
|
|
5005
4999
|
[commands]
|
|
5006
5000
|
);
|
|
5007
|
-
|
|
5001
|
+
React25__namespace.useEffect(() => {
|
|
5008
5002
|
const handle_click_outside = (e) => {
|
|
5009
5003
|
if (container_ref.current && !container_ref.current.contains(e.target)) {
|
|
5010
5004
|
on_close();
|
|
@@ -5017,8 +5011,8 @@ var CommandPopover = ({
|
|
|
5017
5011
|
};
|
|
5018
5012
|
}
|
|
5019
5013
|
}, [is_open, on_close]);
|
|
5020
|
-
const [mounted, set_mounted] =
|
|
5021
|
-
|
|
5014
|
+
const [mounted, set_mounted] = React25__namespace.useState(false);
|
|
5015
|
+
React25__namespace.useEffect(() => {
|
|
5022
5016
|
set_mounted(true);
|
|
5023
5017
|
}, []);
|
|
5024
5018
|
if (!is_open || !mounted) return null;
|
|
@@ -5328,21 +5322,21 @@ var HazoUiTextbox = ({
|
|
|
5328
5322
|
on_command_change,
|
|
5329
5323
|
on_command_remove
|
|
5330
5324
|
}) => {
|
|
5331
|
-
const generated_instance_id =
|
|
5325
|
+
const generated_instance_id = React25__namespace.useId();
|
|
5332
5326
|
const instance_id = provided_instance_id || generated_instance_id;
|
|
5333
|
-
const [suggestion_state, set_suggestion_state] =
|
|
5334
|
-
const [selected_index, set_selected_index] =
|
|
5335
|
-
const [popover_position, set_popover_position] =
|
|
5336
|
-
const [edit_context, set_edit_context] =
|
|
5337
|
-
const [edit_selected_index, set_edit_selected_index] =
|
|
5327
|
+
const [suggestion_state, set_suggestion_state] = React25__namespace.useState(null);
|
|
5328
|
+
const [selected_index, set_selected_index] = React25__namespace.useState(0);
|
|
5329
|
+
const [popover_position, set_popover_position] = React25__namespace.useState({ top: 0, left: 0 });
|
|
5330
|
+
const [edit_context, set_edit_context] = React25__namespace.useState(null);
|
|
5331
|
+
const [edit_selected_index, set_edit_selected_index] = React25__namespace.useState(0);
|
|
5338
5332
|
const is_controlled = value !== void 0;
|
|
5339
|
-
const editor_container_ref =
|
|
5340
|
-
const edit_popover_ref =
|
|
5341
|
-
const [mounted, set_mounted] =
|
|
5342
|
-
|
|
5333
|
+
const editor_container_ref = React25__namespace.useRef(null);
|
|
5334
|
+
const edit_popover_ref = React25__namespace.useRef(null);
|
|
5335
|
+
const [mounted, set_mounted] = React25__namespace.useState(false);
|
|
5336
|
+
React25__namespace.useEffect(() => {
|
|
5343
5337
|
set_mounted(true);
|
|
5344
5338
|
}, []);
|
|
5345
|
-
const suggestion_extensions =
|
|
5339
|
+
const suggestion_extensions = React25__namespace.useMemo(() => {
|
|
5346
5340
|
return create_command_suggestion_extension({
|
|
5347
5341
|
prefixes,
|
|
5348
5342
|
instance_id,
|
|
@@ -5393,7 +5387,7 @@ var HazoUiTextbox = ({
|
|
|
5393
5387
|
}
|
|
5394
5388
|
}
|
|
5395
5389
|
});
|
|
5396
|
-
|
|
5390
|
+
React25__namespace.useEffect(() => {
|
|
5397
5391
|
if (suggestion_state?.is_active && editor) {
|
|
5398
5392
|
requestAnimationFrame(() => {
|
|
5399
5393
|
const { from } = suggestion_state.range;
|
|
@@ -5417,7 +5411,7 @@ var HazoUiTextbox = ({
|
|
|
5417
5411
|
});
|
|
5418
5412
|
}
|
|
5419
5413
|
}, [suggestion_state, editor]);
|
|
5420
|
-
|
|
5414
|
+
React25__namespace.useEffect(() => {
|
|
5421
5415
|
if (is_controlled && editor && !editor.isFocused) {
|
|
5422
5416
|
const current_text = editor.getText();
|
|
5423
5417
|
if (value !== current_text) {
|
|
@@ -5426,12 +5420,12 @@ var HazoUiTextbox = ({
|
|
|
5426
5420
|
}
|
|
5427
5421
|
}
|
|
5428
5422
|
}, [value, editor, is_controlled, prefixes, pill_variant]);
|
|
5429
|
-
|
|
5423
|
+
React25__namespace.useEffect(() => {
|
|
5430
5424
|
if (editor) {
|
|
5431
5425
|
editor.setEditable(!disabled);
|
|
5432
5426
|
}
|
|
5433
5427
|
}, [disabled, editor]);
|
|
5434
|
-
const handle_command_select =
|
|
5428
|
+
const handle_command_select = React25__namespace.useCallback(
|
|
5435
5429
|
(command) => {
|
|
5436
5430
|
if (!editor || !suggestion_state) return;
|
|
5437
5431
|
const prefix_config = prefixes.find((p) => p.char === suggestion_state.prefix);
|
|
@@ -5451,15 +5445,15 @@ var HazoUiTextbox = ({
|
|
|
5451
5445
|
},
|
|
5452
5446
|
[editor, suggestion_state, pill_variant, on_command_insert, prefixes]
|
|
5453
5447
|
);
|
|
5454
|
-
const handle_popover_close =
|
|
5448
|
+
const handle_popover_close = React25__namespace.useCallback(() => {
|
|
5455
5449
|
set_suggestion_state(null);
|
|
5456
5450
|
editor?.commands.focus();
|
|
5457
5451
|
}, [editor]);
|
|
5458
|
-
const handle_edit_close =
|
|
5452
|
+
const handle_edit_close = React25__namespace.useCallback(() => {
|
|
5459
5453
|
set_edit_context(null);
|
|
5460
5454
|
editor?.commands.focus();
|
|
5461
5455
|
}, [editor]);
|
|
5462
|
-
const handle_command_update =
|
|
5456
|
+
const handle_command_update = React25__namespace.useCallback(
|
|
5463
5457
|
(new_command) => {
|
|
5464
5458
|
if (!editor || !edit_context) return;
|
|
5465
5459
|
const old_command = edit_context.command;
|
|
@@ -5475,7 +5469,7 @@ var HazoUiTextbox = ({
|
|
|
5475
5469
|
},
|
|
5476
5470
|
[editor, edit_context, on_command_change]
|
|
5477
5471
|
);
|
|
5478
|
-
const handle_command_remove =
|
|
5472
|
+
const handle_command_remove = React25__namespace.useCallback(() => {
|
|
5479
5473
|
if (!editor || !edit_context) return;
|
|
5480
5474
|
const command = edit_context.command;
|
|
5481
5475
|
editor.state.doc.descendants((node, pos) => {
|
|
@@ -5489,7 +5483,7 @@ var HazoUiTextbox = ({
|
|
|
5489
5483
|
}
|
|
5490
5484
|
set_edit_context(null);
|
|
5491
5485
|
}, [editor, edit_context, on_command_remove]);
|
|
5492
|
-
const filtered_commands =
|
|
5486
|
+
const filtered_commands = React25__namespace.useMemo(() => {
|
|
5493
5487
|
if (!suggestion_state) return [];
|
|
5494
5488
|
const query = suggestion_state.query.toLowerCase();
|
|
5495
5489
|
if (!query) return suggestion_state.commands;
|
|
@@ -5497,7 +5491,7 @@ var HazoUiTextbox = ({
|
|
|
5497
5491
|
(cmd) => cmd.action_label.toLowerCase().includes(query) || cmd.action.toLowerCase().includes(query) || cmd.action_description?.toLowerCase().includes(query)
|
|
5498
5492
|
);
|
|
5499
5493
|
}, [suggestion_state]);
|
|
5500
|
-
|
|
5494
|
+
React25__namespace.useEffect(() => {
|
|
5501
5495
|
if (!suggestion_state?.is_active) return;
|
|
5502
5496
|
const handle_keydown = (e) => {
|
|
5503
5497
|
switch (e.key) {
|
|
@@ -5532,7 +5526,7 @@ var HazoUiTextbox = ({
|
|
|
5532
5526
|
handle_command_select,
|
|
5533
5527
|
handle_popover_close
|
|
5534
5528
|
]);
|
|
5535
|
-
|
|
5529
|
+
React25__namespace.useEffect(() => {
|
|
5536
5530
|
if (!edit_context) return;
|
|
5537
5531
|
const handle_click_outside = (e) => {
|
|
5538
5532
|
if (edit_popover_ref.current && !edit_popover_ref.current.contains(e.target)) {
|
|
@@ -5547,12 +5541,12 @@ var HazoUiTextbox = ({
|
|
|
5547
5541
|
document.removeEventListener("mousedown", handle_click_outside);
|
|
5548
5542
|
};
|
|
5549
5543
|
}, [edit_context]);
|
|
5550
|
-
const edit_commands =
|
|
5544
|
+
const edit_commands = React25__namespace.useMemo(() => {
|
|
5551
5545
|
if (!edit_context) return [];
|
|
5552
5546
|
const prefix_config = prefixes.find((p) => p.char === edit_context.command.prefix);
|
|
5553
5547
|
return prefix_config?.commands || [];
|
|
5554
5548
|
}, [edit_context, prefixes]);
|
|
5555
|
-
|
|
5549
|
+
React25__namespace.useEffect(() => {
|
|
5556
5550
|
if (!edit_context) return;
|
|
5557
5551
|
const handle_keydown = (e) => {
|
|
5558
5552
|
switch (e.key) {
|
|
@@ -5590,7 +5584,7 @@ var HazoUiTextbox = ({
|
|
|
5590
5584
|
handle_command_remove,
|
|
5591
5585
|
handle_edit_close
|
|
5592
5586
|
]);
|
|
5593
|
-
|
|
5587
|
+
React25__namespace.useEffect(() => {
|
|
5594
5588
|
const handle_pill_click = (e) => {
|
|
5595
5589
|
const detail = e.detail;
|
|
5596
5590
|
const { id, prefix, action, action_label, node_pos } = detail;
|
|
@@ -5873,22 +5867,22 @@ var HazoUiTextarea = ({
|
|
|
5873
5867
|
on_command_change,
|
|
5874
5868
|
on_command_remove
|
|
5875
5869
|
}) => {
|
|
5876
|
-
const generated_instance_id =
|
|
5870
|
+
const generated_instance_id = React25__namespace.useId();
|
|
5877
5871
|
const instance_id = provided_instance_id || generated_instance_id;
|
|
5878
|
-
const [suggestion_state, set_suggestion_state] =
|
|
5879
|
-
const [selected_index, set_selected_index] =
|
|
5880
|
-
const [popover_position, set_popover_position] =
|
|
5881
|
-
const [edit_context, set_edit_context] =
|
|
5882
|
-
const [edit_selected_index, set_edit_selected_index] =
|
|
5872
|
+
const [suggestion_state, set_suggestion_state] = React25__namespace.useState(null);
|
|
5873
|
+
const [selected_index, set_selected_index] = React25__namespace.useState(0);
|
|
5874
|
+
const [popover_position, set_popover_position] = React25__namespace.useState({ top: 0, left: 0 });
|
|
5875
|
+
const [edit_context, set_edit_context] = React25__namespace.useState(null);
|
|
5876
|
+
const [edit_selected_index, set_edit_selected_index] = React25__namespace.useState(0);
|
|
5883
5877
|
const is_controlled = value !== void 0;
|
|
5884
|
-
const editor_container_ref =
|
|
5885
|
-
const edit_popover_ref =
|
|
5886
|
-
const [mounted, set_mounted] =
|
|
5887
|
-
|
|
5878
|
+
const editor_container_ref = React25__namespace.useRef(null);
|
|
5879
|
+
const edit_popover_ref = React25__namespace.useRef(null);
|
|
5880
|
+
const [mounted, set_mounted] = React25__namespace.useState(false);
|
|
5881
|
+
React25__namespace.useEffect(() => {
|
|
5888
5882
|
set_mounted(true);
|
|
5889
5883
|
}, []);
|
|
5890
5884
|
const calculated_min_height = rows ? `${rows * 1.5}em` : min_height;
|
|
5891
|
-
const suggestion_extensions =
|
|
5885
|
+
const suggestion_extensions = React25__namespace.useMemo(() => {
|
|
5892
5886
|
return create_command_suggestion_extension({
|
|
5893
5887
|
prefixes,
|
|
5894
5888
|
instance_id,
|
|
@@ -5937,7 +5931,7 @@ var HazoUiTextarea = ({
|
|
|
5937
5931
|
}
|
|
5938
5932
|
}
|
|
5939
5933
|
});
|
|
5940
|
-
|
|
5934
|
+
React25__namespace.useEffect(() => {
|
|
5941
5935
|
if (suggestion_state?.is_active && editor) {
|
|
5942
5936
|
requestAnimationFrame(() => {
|
|
5943
5937
|
const { from } = suggestion_state.range;
|
|
@@ -5961,7 +5955,7 @@ var HazoUiTextarea = ({
|
|
|
5961
5955
|
});
|
|
5962
5956
|
}
|
|
5963
5957
|
}, [suggestion_state, editor]);
|
|
5964
|
-
|
|
5958
|
+
React25__namespace.useEffect(() => {
|
|
5965
5959
|
if (is_controlled && editor && !editor.isFocused) {
|
|
5966
5960
|
const current_text = editor.getText();
|
|
5967
5961
|
if (value !== current_text) {
|
|
@@ -5974,12 +5968,12 @@ var HazoUiTextarea = ({
|
|
|
5974
5968
|
}
|
|
5975
5969
|
}
|
|
5976
5970
|
}, [value, editor, is_controlled, prefixes, pill_variant]);
|
|
5977
|
-
|
|
5971
|
+
React25__namespace.useEffect(() => {
|
|
5978
5972
|
if (editor) {
|
|
5979
5973
|
editor.setEditable(!disabled);
|
|
5980
5974
|
}
|
|
5981
5975
|
}, [disabled, editor]);
|
|
5982
|
-
const handle_command_select =
|
|
5976
|
+
const handle_command_select = React25__namespace.useCallback(
|
|
5983
5977
|
(command) => {
|
|
5984
5978
|
if (!editor || !suggestion_state) return;
|
|
5985
5979
|
const prefix_config = prefixes.find((p) => p.char === suggestion_state.prefix);
|
|
@@ -5999,15 +5993,15 @@ var HazoUiTextarea = ({
|
|
|
5999
5993
|
},
|
|
6000
5994
|
[editor, suggestion_state, pill_variant, on_command_insert, prefixes]
|
|
6001
5995
|
);
|
|
6002
|
-
const handle_popover_close =
|
|
5996
|
+
const handle_popover_close = React25__namespace.useCallback(() => {
|
|
6003
5997
|
set_suggestion_state(null);
|
|
6004
5998
|
editor?.commands.focus();
|
|
6005
5999
|
}, [editor]);
|
|
6006
|
-
const handle_edit_close =
|
|
6000
|
+
const handle_edit_close = React25__namespace.useCallback(() => {
|
|
6007
6001
|
set_edit_context(null);
|
|
6008
6002
|
editor?.commands.focus();
|
|
6009
6003
|
}, [editor]);
|
|
6010
|
-
const handle_command_update =
|
|
6004
|
+
const handle_command_update = React25__namespace.useCallback(
|
|
6011
6005
|
(new_command) => {
|
|
6012
6006
|
if (!editor || !edit_context) return;
|
|
6013
6007
|
const old_command = edit_context.command;
|
|
@@ -6023,7 +6017,7 @@ var HazoUiTextarea = ({
|
|
|
6023
6017
|
},
|
|
6024
6018
|
[editor, edit_context, on_command_change]
|
|
6025
6019
|
);
|
|
6026
|
-
const handle_command_remove =
|
|
6020
|
+
const handle_command_remove = React25__namespace.useCallback(() => {
|
|
6027
6021
|
if (!editor || !edit_context) return;
|
|
6028
6022
|
const command = edit_context.command;
|
|
6029
6023
|
editor.state.doc.descendants((node, pos) => {
|
|
@@ -6037,7 +6031,7 @@ var HazoUiTextarea = ({
|
|
|
6037
6031
|
}
|
|
6038
6032
|
set_edit_context(null);
|
|
6039
6033
|
}, [editor, edit_context, on_command_remove]);
|
|
6040
|
-
const filtered_commands =
|
|
6034
|
+
const filtered_commands = React25__namespace.useMemo(() => {
|
|
6041
6035
|
if (!suggestion_state) return [];
|
|
6042
6036
|
const query = suggestion_state.query.toLowerCase();
|
|
6043
6037
|
if (!query) return suggestion_state.commands;
|
|
@@ -6045,7 +6039,7 @@ var HazoUiTextarea = ({
|
|
|
6045
6039
|
(cmd) => cmd.action_label.toLowerCase().includes(query) || cmd.action.toLowerCase().includes(query) || cmd.action_description?.toLowerCase().includes(query)
|
|
6046
6040
|
);
|
|
6047
6041
|
}, [suggestion_state]);
|
|
6048
|
-
|
|
6042
|
+
React25__namespace.useEffect(() => {
|
|
6049
6043
|
if (!suggestion_state?.is_active) return;
|
|
6050
6044
|
const handle_keydown = (e) => {
|
|
6051
6045
|
switch (e.key) {
|
|
@@ -6080,7 +6074,7 @@ var HazoUiTextarea = ({
|
|
|
6080
6074
|
handle_command_select,
|
|
6081
6075
|
handle_popover_close
|
|
6082
6076
|
]);
|
|
6083
|
-
|
|
6077
|
+
React25__namespace.useEffect(() => {
|
|
6084
6078
|
if (!edit_context) return;
|
|
6085
6079
|
const handle_click_outside = (e) => {
|
|
6086
6080
|
if (edit_popover_ref.current && !edit_popover_ref.current.contains(e.target)) {
|
|
@@ -6095,12 +6089,12 @@ var HazoUiTextarea = ({
|
|
|
6095
6089
|
document.removeEventListener("mousedown", handle_click_outside);
|
|
6096
6090
|
};
|
|
6097
6091
|
}, [edit_context]);
|
|
6098
|
-
const edit_commands =
|
|
6092
|
+
const edit_commands = React25__namespace.useMemo(() => {
|
|
6099
6093
|
if (!edit_context) return [];
|
|
6100
6094
|
const prefix_config = prefixes.find((p) => p.char === edit_context.command.prefix);
|
|
6101
6095
|
return prefix_config?.commands || [];
|
|
6102
6096
|
}, [edit_context, prefixes]);
|
|
6103
|
-
|
|
6097
|
+
React25__namespace.useEffect(() => {
|
|
6104
6098
|
if (!edit_context) return;
|
|
6105
6099
|
const handle_keydown = (e) => {
|
|
6106
6100
|
switch (e.key) {
|
|
@@ -6138,7 +6132,7 @@ var HazoUiTextarea = ({
|
|
|
6138
6132
|
handle_command_remove,
|
|
6139
6133
|
handle_edit_close
|
|
6140
6134
|
]);
|
|
6141
|
-
|
|
6135
|
+
React25__namespace.useEffect(() => {
|
|
6142
6136
|
const handle_pill_click = (e) => {
|
|
6143
6137
|
const detail = e.detail;
|
|
6144
6138
|
const { id, prefix, action, action_label, node_pos } = detail;
|
|
@@ -6685,7 +6679,7 @@ function HazoUiConfirmDialog({
|
|
|
6685
6679
|
openAnimation = "zoom",
|
|
6686
6680
|
closeAnimation = "zoom"
|
|
6687
6681
|
}) {
|
|
6688
|
-
const [internal_loading, set_internal_loading] =
|
|
6682
|
+
const [internal_loading, set_internal_loading] = React25__namespace.useState(false);
|
|
6689
6683
|
const config = get_hazo_ui_config();
|
|
6690
6684
|
const variant_preset = variant !== "default" ? CONFIRM_VARIANT_PRESETS[variant] : void 0;
|
|
6691
6685
|
const is_loading = external_loading ?? internal_loading;
|
|
@@ -6722,7 +6716,7 @@ function HazoUiConfirmDialog({
|
|
|
6722
6716
|
onCancel?.();
|
|
6723
6717
|
onOpenChange(false);
|
|
6724
6718
|
};
|
|
6725
|
-
const cancel_ref =
|
|
6719
|
+
const cancel_ref = React25__namespace.useRef(null);
|
|
6726
6720
|
return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
|
|
6727
6721
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6728
6722
|
DialogOverlay,
|
|
@@ -6807,7 +6801,7 @@ Drawer.displayName = "Drawer";
|
|
|
6807
6801
|
var DrawerTrigger = vaul.Drawer.Trigger;
|
|
6808
6802
|
var DrawerPortal = vaul.Drawer.Portal;
|
|
6809
6803
|
var DrawerClose = vaul.Drawer.Close;
|
|
6810
|
-
var DrawerOverlay =
|
|
6804
|
+
var DrawerOverlay = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6811
6805
|
vaul.Drawer.Overlay,
|
|
6812
6806
|
{
|
|
6813
6807
|
ref,
|
|
@@ -6819,7 +6813,7 @@ var DrawerOverlay = React27__namespace.forwardRef(({ className, ...props }, ref)
|
|
|
6819
6813
|
}
|
|
6820
6814
|
));
|
|
6821
6815
|
DrawerOverlay.displayName = "DrawerOverlay";
|
|
6822
|
-
var DrawerContent =
|
|
6816
|
+
var DrawerContent = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DrawerPortal, { children: [
|
|
6823
6817
|
/* @__PURE__ */ jsxRuntime.jsx(DrawerOverlay, {}),
|
|
6824
6818
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
6825
6819
|
vaul.Drawer.Content,
|
|
@@ -6860,7 +6854,7 @@ var DrawerFooter = ({
|
|
|
6860
6854
|
}
|
|
6861
6855
|
);
|
|
6862
6856
|
DrawerFooter.displayName = "DrawerFooter";
|
|
6863
|
-
var DrawerTitle =
|
|
6857
|
+
var DrawerTitle = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6864
6858
|
vaul.Drawer.Title,
|
|
6865
6859
|
{
|
|
6866
6860
|
ref,
|
|
@@ -6872,7 +6866,7 @@ var DrawerTitle = React27__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
6872
6866
|
}
|
|
6873
6867
|
));
|
|
6874
6868
|
DrawerTitle.displayName = "DrawerTitle";
|
|
6875
|
-
var DrawerDescription =
|
|
6869
|
+
var DrawerDescription = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6876
6870
|
vaul.Drawer.Description,
|
|
6877
6871
|
{
|
|
6878
6872
|
ref,
|
|
@@ -6882,14 +6876,14 @@ var DrawerDescription = React27__namespace.forwardRef(({ className, ...props },
|
|
|
6882
6876
|
));
|
|
6883
6877
|
DrawerDescription.displayName = "DrawerDescription";
|
|
6884
6878
|
function useMediaQuery(query) {
|
|
6885
|
-
const get_match =
|
|
6879
|
+
const get_match = React25__namespace.useCallback(() => {
|
|
6886
6880
|
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
6887
6881
|
return false;
|
|
6888
6882
|
}
|
|
6889
6883
|
return window.matchMedia(query).matches;
|
|
6890
6884
|
}, [query]);
|
|
6891
|
-
const [matches, set_matches] =
|
|
6892
|
-
|
|
6885
|
+
const [matches, set_matches] = React25__namespace.useState(false);
|
|
6886
|
+
React25__namespace.useEffect(() => {
|
|
6893
6887
|
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
6894
6888
|
return;
|
|
6895
6889
|
}
|
|
@@ -6906,7 +6900,7 @@ function useMediaQuery(query) {
|
|
|
6906
6900
|
return matches;
|
|
6907
6901
|
}
|
|
6908
6902
|
var Accordion = AccordionPrimitive__namespace.Root;
|
|
6909
|
-
var AccordionItem =
|
|
6903
|
+
var AccordionItem = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6910
6904
|
AccordionPrimitive__namespace.Item,
|
|
6911
6905
|
{
|
|
6912
6906
|
ref,
|
|
@@ -6915,7 +6909,7 @@ var AccordionItem = React27__namespace.forwardRef(({ className, ...props }, ref)
|
|
|
6915
6909
|
}
|
|
6916
6910
|
));
|
|
6917
6911
|
AccordionItem.displayName = "AccordionItem";
|
|
6918
|
-
var AccordionTrigger =
|
|
6912
|
+
var AccordionTrigger = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(AccordionPrimitive__namespace.Header, { className: "flex", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6919
6913
|
AccordionPrimitive__namespace.Trigger,
|
|
6920
6914
|
{
|
|
6921
6915
|
ref,
|
|
@@ -6931,7 +6925,7 @@ var AccordionTrigger = React27__namespace.forwardRef(({ className, children, ...
|
|
|
6931
6925
|
}
|
|
6932
6926
|
) }));
|
|
6933
6927
|
AccordionTrigger.displayName = AccordionPrimitive__namespace.Trigger.displayName;
|
|
6934
|
-
var AccordionContent =
|
|
6928
|
+
var AccordionContent = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6935
6929
|
AccordionPrimitive__namespace.Content,
|
|
6936
6930
|
{
|
|
6937
6931
|
ref,
|
|
@@ -6941,7 +6935,7 @@ var AccordionContent = React27__namespace.forwardRef(({ className, children, ...
|
|
|
6941
6935
|
}
|
|
6942
6936
|
));
|
|
6943
6937
|
AccordionContent.displayName = AccordionPrimitive__namespace.Content.displayName;
|
|
6944
|
-
var Checkbox =
|
|
6938
|
+
var Checkbox = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6945
6939
|
CheckboxPrimitive__namespace.Root,
|
|
6946
6940
|
{
|
|
6947
6941
|
ref,
|
|
@@ -6966,7 +6960,7 @@ var DropdownMenuGroup = DropdownMenuPrimitive__namespace.Group;
|
|
|
6966
6960
|
var DropdownMenuPortal = DropdownMenuPrimitive__namespace.Portal;
|
|
6967
6961
|
var DropdownMenuSub = DropdownMenuPrimitive__namespace.Sub;
|
|
6968
6962
|
var DropdownMenuRadioGroup = DropdownMenuPrimitive__namespace.RadioGroup;
|
|
6969
|
-
var DropdownMenuSubTrigger =
|
|
6963
|
+
var DropdownMenuSubTrigger = React25__namespace.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6970
6964
|
DropdownMenuPrimitive__namespace.SubTrigger,
|
|
6971
6965
|
{
|
|
6972
6966
|
ref,
|
|
@@ -6983,7 +6977,7 @@ var DropdownMenuSubTrigger = React27__namespace.forwardRef(({ className, inset,
|
|
|
6983
6977
|
}
|
|
6984
6978
|
));
|
|
6985
6979
|
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive__namespace.SubTrigger.displayName;
|
|
6986
|
-
var DropdownMenuSubContent =
|
|
6980
|
+
var DropdownMenuSubContent = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6987
6981
|
DropdownMenuPrimitive__namespace.SubContent,
|
|
6988
6982
|
{
|
|
6989
6983
|
ref,
|
|
@@ -6995,7 +6989,7 @@ var DropdownMenuSubContent = React27__namespace.forwardRef(({ className, ...prop
|
|
|
6995
6989
|
}
|
|
6996
6990
|
));
|
|
6997
6991
|
DropdownMenuSubContent.displayName = DropdownMenuPrimitive__namespace.SubContent.displayName;
|
|
6998
|
-
var DropdownMenuContent =
|
|
6992
|
+
var DropdownMenuContent = React25__namespace.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6999
6993
|
DropdownMenuPrimitive__namespace.Content,
|
|
7000
6994
|
{
|
|
7001
6995
|
ref,
|
|
@@ -7008,7 +7002,7 @@ var DropdownMenuContent = React27__namespace.forwardRef(({ className, sideOffset
|
|
|
7008
7002
|
}
|
|
7009
7003
|
) }));
|
|
7010
7004
|
DropdownMenuContent.displayName = DropdownMenuPrimitive__namespace.Content.displayName;
|
|
7011
|
-
var DropdownMenuItem =
|
|
7005
|
+
var DropdownMenuItem = React25__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7012
7006
|
DropdownMenuPrimitive__namespace.Item,
|
|
7013
7007
|
{
|
|
7014
7008
|
ref,
|
|
@@ -7021,7 +7015,7 @@ var DropdownMenuItem = React27__namespace.forwardRef(({ className, inset, ...pro
|
|
|
7021
7015
|
}
|
|
7022
7016
|
));
|
|
7023
7017
|
DropdownMenuItem.displayName = DropdownMenuPrimitive__namespace.Item.displayName;
|
|
7024
|
-
var DropdownMenuCheckboxItem =
|
|
7018
|
+
var DropdownMenuCheckboxItem = React25__namespace.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7025
7019
|
DropdownMenuPrimitive__namespace.CheckboxItem,
|
|
7026
7020
|
{
|
|
7027
7021
|
ref,
|
|
@@ -7038,7 +7032,7 @@ var DropdownMenuCheckboxItem = React27__namespace.forwardRef(({ className, child
|
|
|
7038
7032
|
}
|
|
7039
7033
|
));
|
|
7040
7034
|
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive__namespace.CheckboxItem.displayName;
|
|
7041
|
-
var DropdownMenuRadioItem =
|
|
7035
|
+
var DropdownMenuRadioItem = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7042
7036
|
DropdownMenuPrimitive__namespace.RadioItem,
|
|
7043
7037
|
{
|
|
7044
7038
|
ref,
|
|
@@ -7054,7 +7048,7 @@ var DropdownMenuRadioItem = React27__namespace.forwardRef(({ className, children
|
|
|
7054
7048
|
}
|
|
7055
7049
|
));
|
|
7056
7050
|
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive__namespace.RadioItem.displayName;
|
|
7057
|
-
var DropdownMenuLabel =
|
|
7051
|
+
var DropdownMenuLabel = React25__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7058
7052
|
DropdownMenuPrimitive__namespace.Label,
|
|
7059
7053
|
{
|
|
7060
7054
|
ref,
|
|
@@ -7067,7 +7061,7 @@ var DropdownMenuLabel = React27__namespace.forwardRef(({ className, inset, ...pr
|
|
|
7067
7061
|
}
|
|
7068
7062
|
));
|
|
7069
7063
|
DropdownMenuLabel.displayName = DropdownMenuPrimitive__namespace.Label.displayName;
|
|
7070
|
-
var DropdownMenuSeparator =
|
|
7064
|
+
var DropdownMenuSeparator = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7071
7065
|
DropdownMenuPrimitive__namespace.Separator,
|
|
7072
7066
|
{
|
|
7073
7067
|
ref,
|
|
@@ -7091,7 +7085,7 @@ var DropdownMenuShortcut = ({
|
|
|
7091
7085
|
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
|
7092
7086
|
var HoverCard = HoverCardPrimitive__namespace.Root;
|
|
7093
7087
|
var HoverCardTrigger = HoverCardPrimitive__namespace.Trigger;
|
|
7094
|
-
var HoverCardContent =
|
|
7088
|
+
var HoverCardContent = React25__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7095
7089
|
HoverCardPrimitive__namespace.Content,
|
|
7096
7090
|
{
|
|
7097
7091
|
ref,
|
|
@@ -7105,31 +7099,67 @@ var HoverCardContent = React27__namespace.forwardRef(({ className, align = "cent
|
|
|
7105
7099
|
}
|
|
7106
7100
|
));
|
|
7107
7101
|
HoverCardContent.displayName = HoverCardPrimitive__namespace.Content.displayName;
|
|
7108
|
-
var
|
|
7102
|
+
var Label3 = React25__namespace.forwardRef(
|
|
7109
7103
|
({ className, ...props }, ref) => {
|
|
7110
7104
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7111
|
-
"
|
|
7105
|
+
"label",
|
|
7112
7106
|
{
|
|
7107
|
+
ref,
|
|
7113
7108
|
className: cn(
|
|
7114
|
-
"
|
|
7115
|
-
"text-sm ring-offset-background",
|
|
7116
|
-
"placeholder:text-muted-foreground",
|
|
7117
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
7118
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
7109
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
7119
7110
|
className
|
|
7120
7111
|
),
|
|
7121
|
-
ref,
|
|
7122
7112
|
...props
|
|
7123
7113
|
}
|
|
7124
7114
|
);
|
|
7125
7115
|
}
|
|
7126
7116
|
);
|
|
7127
|
-
|
|
7128
|
-
var
|
|
7129
|
-
|
|
7117
|
+
Label3.displayName = "Label";
|
|
7118
|
+
var Switch = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7119
|
+
SwitchPrimitives__namespace.Root,
|
|
7130
7120
|
{
|
|
7131
|
-
|
|
7132
|
-
|
|
7121
|
+
className: cn(
|
|
7122
|
+
"peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
|
7123
|
+
className
|
|
7124
|
+
),
|
|
7125
|
+
...props,
|
|
7126
|
+
ref,
|
|
7127
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7128
|
+
SwitchPrimitives__namespace.Thumb,
|
|
7129
|
+
{
|
|
7130
|
+
className: cn(
|
|
7131
|
+
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
|
|
7132
|
+
)
|
|
7133
|
+
}
|
|
7134
|
+
)
|
|
7135
|
+
}
|
|
7136
|
+
));
|
|
7137
|
+
Switch.displayName = SwitchPrimitives__namespace.Root.displayName;
|
|
7138
|
+
var Textarea = React25__namespace.forwardRef(
|
|
7139
|
+
({ className, ...props }, ref) => {
|
|
7140
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7141
|
+
"textarea",
|
|
7142
|
+
{
|
|
7143
|
+
className: cn(
|
|
7144
|
+
"flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2",
|
|
7145
|
+
"text-sm ring-offset-background",
|
|
7146
|
+
"placeholder:text-muted-foreground",
|
|
7147
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
7148
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
7149
|
+
className
|
|
7150
|
+
),
|
|
7151
|
+
ref,
|
|
7152
|
+
...props
|
|
7153
|
+
}
|
|
7154
|
+
);
|
|
7155
|
+
}
|
|
7156
|
+
);
|
|
7157
|
+
Textarea.displayName = "Textarea";
|
|
7158
|
+
var Separator3 = React25__namespace.forwardRef(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7159
|
+
SeparatorPrimitive__namespace.Root,
|
|
7160
|
+
{
|
|
7161
|
+
ref,
|
|
7162
|
+
decorative,
|
|
7133
7163
|
orientation,
|
|
7134
7164
|
className: cn(
|
|
7135
7165
|
"shrink-0 bg-border",
|
|
@@ -7143,7 +7173,7 @@ Separator3.displayName = SeparatorPrimitive__namespace.Root.displayName;
|
|
|
7143
7173
|
var Collapsible = CollapsiblePrimitive__namespace.Root;
|
|
7144
7174
|
var CollapsibleTrigger2 = CollapsiblePrimitive__namespace.CollapsibleTrigger;
|
|
7145
7175
|
var CollapsibleContent2 = CollapsiblePrimitive__namespace.CollapsibleContent;
|
|
7146
|
-
var ScrollArea =
|
|
7176
|
+
var ScrollArea = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7147
7177
|
ScrollAreaPrimitive__namespace.Root,
|
|
7148
7178
|
{
|
|
7149
7179
|
ref,
|
|
@@ -7157,7 +7187,7 @@ var ScrollArea = React27__namespace.forwardRef(({ className, children, ...props
|
|
|
7157
7187
|
}
|
|
7158
7188
|
));
|
|
7159
7189
|
ScrollArea.displayName = ScrollAreaPrimitive__namespace.Root.displayName;
|
|
7160
|
-
var ScrollBar =
|
|
7190
|
+
var ScrollBar = React25__namespace.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7161
7191
|
ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,
|
|
7162
7192
|
{
|
|
7163
7193
|
ref,
|
|
@@ -7173,27 +7203,27 @@ var ScrollBar = React27__namespace.forwardRef(({ className, orientation = "verti
|
|
|
7173
7203
|
}
|
|
7174
7204
|
));
|
|
7175
7205
|
ScrollBar.displayName = ScrollAreaPrimitive__namespace.ScrollAreaScrollbar.displayName;
|
|
7176
|
-
var Card =
|
|
7206
|
+
var Card = React25__namespace.forwardRef(
|
|
7177
7207
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("rounded-lg border bg-card text-card-foreground shadow-sm", className), ...props })
|
|
7178
7208
|
);
|
|
7179
7209
|
Card.displayName = "Card";
|
|
7180
|
-
var CardHeader =
|
|
7210
|
+
var CardHeader = React25__namespace.forwardRef(
|
|
7181
7211
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex flex-col space-y-1.5 p-6", className), ...props })
|
|
7182
7212
|
);
|
|
7183
7213
|
CardHeader.displayName = "CardHeader";
|
|
7184
|
-
var CardTitle =
|
|
7214
|
+
var CardTitle = React25__namespace.forwardRef(
|
|
7185
7215
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("h3", { ref, className: cn("text-2xl font-semibold leading-none tracking-tight", className), ...props })
|
|
7186
7216
|
);
|
|
7187
7217
|
CardTitle.displayName = "CardTitle";
|
|
7188
|
-
var CardDescription =
|
|
7218
|
+
var CardDescription = React25__namespace.forwardRef(
|
|
7189
7219
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("p", { ref, className: cn("text-sm text-muted-foreground", className), ...props })
|
|
7190
7220
|
);
|
|
7191
7221
|
CardDescription.displayName = "CardDescription";
|
|
7192
|
-
var CardContent =
|
|
7222
|
+
var CardContent = React25__namespace.forwardRef(
|
|
7193
7223
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("p-6 pt-0", className), ...props })
|
|
7194
7224
|
);
|
|
7195
7225
|
CardContent.displayName = "CardContent";
|
|
7196
|
-
var CardFooter =
|
|
7226
|
+
var CardFooter = React25__namespace.forwardRef(
|
|
7197
7227
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex items-center p-6 pt-0", className), ...props })
|
|
7198
7228
|
);
|
|
7199
7229
|
CardFooter.displayName = "CardFooter";
|
|
@@ -7226,16 +7256,16 @@ var toggleVariants = classVarianceAuthority.cva(
|
|
|
7226
7256
|
defaultVariants: { variant: "default", size: "default" }
|
|
7227
7257
|
}
|
|
7228
7258
|
);
|
|
7229
|
-
var Toggle =
|
|
7259
|
+
var Toggle = React25__namespace.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(TogglePrimitive__namespace.Root, { ref, className: cn(toggleVariants({ variant, size, className })), ...props }));
|
|
7230
7260
|
Toggle.displayName = TogglePrimitive__namespace.Root.displayName;
|
|
7231
|
-
var ToggleGroupContext =
|
|
7261
|
+
var ToggleGroupContext = React25__namespace.createContext({
|
|
7232
7262
|
size: "default",
|
|
7233
7263
|
variant: "default"
|
|
7234
7264
|
});
|
|
7235
|
-
var ToggleGroup =
|
|
7265
|
+
var ToggleGroup = React25__namespace.forwardRef(({ className, variant, size, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(ToggleGroupPrimitive__namespace.Root, { ref, className: cn("flex items-center justify-center gap-1", className), ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ToggleGroupContext.Provider, { value: { variant, size }, children }) }));
|
|
7236
7266
|
ToggleGroup.displayName = ToggleGroupPrimitive__namespace.Root.displayName;
|
|
7237
|
-
var ToggleGroupItem =
|
|
7238
|
-
const context =
|
|
7267
|
+
var ToggleGroupItem = React25__namespace.forwardRef(({ className, children, variant, size, ...props }, ref) => {
|
|
7268
|
+
const context = React25__namespace.useContext(ToggleGroupContext);
|
|
7239
7269
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7240
7270
|
ToggleGroupPrimitive__namespace.Item,
|
|
7241
7271
|
{
|
|
@@ -7250,7 +7280,7 @@ ToggleGroupItem.displayName = ToggleGroupPrimitive__namespace.Item.displayName;
|
|
|
7250
7280
|
var AlertDialog = AlertDialogPrimitive__namespace.Root;
|
|
7251
7281
|
var AlertDialogTrigger = AlertDialogPrimitive__namespace.Trigger;
|
|
7252
7282
|
var AlertDialogPortal = AlertDialogPrimitive__namespace.Portal;
|
|
7253
|
-
var AlertDialogOverlay =
|
|
7283
|
+
var AlertDialogOverlay = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7254
7284
|
AlertDialogPrimitive__namespace.Overlay,
|
|
7255
7285
|
{
|
|
7256
7286
|
ref,
|
|
@@ -7259,7 +7289,7 @@ var AlertDialogOverlay = React27__namespace.forwardRef(({ className, ...props },
|
|
|
7259
7289
|
}
|
|
7260
7290
|
));
|
|
7261
7291
|
AlertDialogOverlay.displayName = AlertDialogPrimitive__namespace.Overlay.displayName;
|
|
7262
|
-
var AlertDialogContent =
|
|
7292
|
+
var AlertDialogContent = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogPortal, { children: [
|
|
7263
7293
|
/* @__PURE__ */ jsxRuntime.jsx(AlertDialogOverlay, {}),
|
|
7264
7294
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7265
7295
|
AlertDialogPrimitive__namespace.Content,
|
|
@@ -7275,13 +7305,13 @@ var AlertDialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsxRuntime.
|
|
|
7275
7305
|
AlertDialogHeader.displayName = "AlertDialogHeader";
|
|
7276
7306
|
var AlertDialogFooter = ({ className, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className), ...props });
|
|
7277
7307
|
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
7278
|
-
var AlertDialogTitle =
|
|
7308
|
+
var AlertDialogTitle = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(AlertDialogPrimitive__namespace.Title, { ref, className: cn("text-lg font-semibold", className), ...props }));
|
|
7279
7309
|
AlertDialogTitle.displayName = AlertDialogPrimitive__namespace.Title.displayName;
|
|
7280
|
-
var AlertDialogDescription =
|
|
7310
|
+
var AlertDialogDescription = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(AlertDialogPrimitive__namespace.Description, { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
|
|
7281
7311
|
AlertDialogDescription.displayName = AlertDialogPrimitive__namespace.Description.displayName;
|
|
7282
|
-
var AlertDialogAction =
|
|
7312
|
+
var AlertDialogAction = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(AlertDialogPrimitive__namespace.Action, { ref, className: cn(buttonVariants(), className), ...props }));
|
|
7283
7313
|
AlertDialogAction.displayName = AlertDialogPrimitive__namespace.Action.displayName;
|
|
7284
|
-
var AlertDialogCancel =
|
|
7314
|
+
var AlertDialogCancel = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(AlertDialogPrimitive__namespace.Cancel, { ref, className: cn(buttonVariants({ variant: "outline" }), "mt-2 sm:mt-0", className), ...props }));
|
|
7285
7315
|
AlertDialogCancel.displayName = AlertDialogPrimitive__namespace.Cancel.displayName;
|
|
7286
7316
|
var buttonGroupVariants = classVarianceAuthority.cva(
|
|
7287
7317
|
"flex w-fit items-stretch [&>*]:focus-visible:relative [&>*]:focus-visible:z-10",
|
|
@@ -7309,7 +7339,1973 @@ function ButtonGroupText({ className, asChild = false, ...props }) {
|
|
|
7309
7339
|
function ButtonGroupSeparator({ className, orientation = "vertical", ...props }) {
|
|
7310
7340
|
return /* @__PURE__ */ jsxRuntime.jsx(Separator3, { orientation, className: cn("bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto", className), ...props });
|
|
7311
7341
|
}
|
|
7312
|
-
|
|
7342
|
+
var SkeletonBase = React25__namespace.forwardRef(
|
|
7343
|
+
({ className, ...rest }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7344
|
+
"div",
|
|
7345
|
+
{
|
|
7346
|
+
ref,
|
|
7347
|
+
"data-hazo-skeleton": "",
|
|
7348
|
+
"aria-hidden": "true",
|
|
7349
|
+
className: cn("hazo-shimmer rounded-md", className),
|
|
7350
|
+
...rest
|
|
7351
|
+
}
|
|
7352
|
+
)
|
|
7353
|
+
);
|
|
7354
|
+
SkeletonBase.displayName = "Skeleton";
|
|
7355
|
+
var Skeleton = SkeletonBase;
|
|
7356
|
+
function SkeletonCircle({ size = 40, className }) {
|
|
7357
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7358
|
+
SkeletonBase,
|
|
7359
|
+
{
|
|
7360
|
+
className: cn("rounded-full", className),
|
|
7361
|
+
style: { width: size, height: size }
|
|
7362
|
+
}
|
|
7363
|
+
);
|
|
7364
|
+
}
|
|
7365
|
+
function SkeletonBar({ width = "100%", height = 12, className }) {
|
|
7366
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7367
|
+
SkeletonBase,
|
|
7368
|
+
{
|
|
7369
|
+
className,
|
|
7370
|
+
style: { width, height }
|
|
7371
|
+
}
|
|
7372
|
+
);
|
|
7373
|
+
}
|
|
7374
|
+
function SkeletonRect({ width = "100%", height = 96, radius = 6, className }) {
|
|
7375
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7376
|
+
SkeletonBase,
|
|
7377
|
+
{
|
|
7378
|
+
className,
|
|
7379
|
+
style: { width, height, borderRadius: radius }
|
|
7380
|
+
}
|
|
7381
|
+
);
|
|
7382
|
+
}
|
|
7383
|
+
function SkeletonGroup({ label = "Loading content", children, className, ...rest }) {
|
|
7384
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7385
|
+
"div",
|
|
7386
|
+
{
|
|
7387
|
+
role: "status",
|
|
7388
|
+
"aria-busy": "true",
|
|
7389
|
+
"aria-label": label,
|
|
7390
|
+
className: cn("space-y-2", className),
|
|
7391
|
+
...rest,
|
|
7392
|
+
children: [
|
|
7393
|
+
children,
|
|
7394
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: label })
|
|
7395
|
+
]
|
|
7396
|
+
}
|
|
7397
|
+
);
|
|
7398
|
+
}
|
|
7399
|
+
function EmptyState({
|
|
7400
|
+
icon,
|
|
7401
|
+
title,
|
|
7402
|
+
description,
|
|
7403
|
+
action,
|
|
7404
|
+
size = "md",
|
|
7405
|
+
className
|
|
7406
|
+
}) {
|
|
7407
|
+
const sizing = {
|
|
7408
|
+
sm: { wrap: "py-6 gap-2", icon: "w-8 h-8 mb-1", title: "text-sm font-medium", desc: "text-xs" },
|
|
7409
|
+
md: { wrap: "py-10 gap-3", icon: "w-12 h-12 mb-2", title: "text-base font-semibold", desc: "text-sm" },
|
|
7410
|
+
lg: { wrap: "py-16 gap-4", icon: "w-16 h-16 mb-3", title: "text-lg font-semibold", desc: "text-base" }
|
|
7411
|
+
}[size];
|
|
7412
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7413
|
+
"div",
|
|
7414
|
+
{
|
|
7415
|
+
className: cn(
|
|
7416
|
+
"flex flex-col items-center justify-center text-center text-muted-foreground",
|
|
7417
|
+
sizing.wrap,
|
|
7418
|
+
className
|
|
7419
|
+
),
|
|
7420
|
+
children: [
|
|
7421
|
+
icon ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("text-muted-foreground/60", sizing.icon), children: icon }) : null,
|
|
7422
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("text-foreground", sizing.title), children: title }),
|
|
7423
|
+
description ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("max-w-md text-muted-foreground", sizing.desc), children: description }) : null,
|
|
7424
|
+
action ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 flex items-center gap-2", children: action }) : null
|
|
7425
|
+
]
|
|
7426
|
+
}
|
|
7427
|
+
);
|
|
7428
|
+
}
|
|
7429
|
+
function ErrorBanner({
|
|
7430
|
+
severity = "error",
|
|
7431
|
+
title,
|
|
7432
|
+
message,
|
|
7433
|
+
icon,
|
|
7434
|
+
action,
|
|
7435
|
+
onDismiss,
|
|
7436
|
+
className
|
|
7437
|
+
}) {
|
|
7438
|
+
const palette = severity === "warning" ? "border-amber-300 bg-amber-50 text-amber-900 dark:border-amber-700 dark:bg-amber-950 dark:text-amber-100" : "border-destructive/40 bg-destructive/10 text-destructive-foreground";
|
|
7439
|
+
const iconColor = severity === "warning" ? "text-amber-600" : "text-destructive";
|
|
7440
|
+
const resolvedIcon = icon ?? (severity === "warning" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangle, { className: cn("h-5 w-5", iconColor), "aria-hidden": "true" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.OctagonAlert, { className: cn("h-5 w-5", iconColor), "aria-hidden": "true" }));
|
|
7441
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7442
|
+
"div",
|
|
7443
|
+
{
|
|
7444
|
+
role: "alert",
|
|
7445
|
+
"aria-live": severity === "error" ? "assertive" : "polite",
|
|
7446
|
+
className: cn(
|
|
7447
|
+
"flex items-start gap-3 rounded-md border px-4 py-3 text-sm",
|
|
7448
|
+
palette,
|
|
7449
|
+
className
|
|
7450
|
+
),
|
|
7451
|
+
children: [
|
|
7452
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0 mt-0.5", children: resolvedIcon }),
|
|
7453
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
7454
|
+
title ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-semibold leading-tight", children: title }) : null,
|
|
7455
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("leading-snug", title ? "mt-1" : ""), children: message }),
|
|
7456
|
+
action ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 flex items-center gap-2", children: action }) : null
|
|
7457
|
+
] }),
|
|
7458
|
+
onDismiss ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
7459
|
+
"button",
|
|
7460
|
+
{
|
|
7461
|
+
type: "button",
|
|
7462
|
+
onClick: onDismiss,
|
|
7463
|
+
"aria-label": "Dismiss",
|
|
7464
|
+
className: "flex-shrink-0 rounded p-1 hover:bg-black/5 focus:outline-none focus:ring-2 focus:ring-offset-2 dark:hover:bg-white/5",
|
|
7465
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4", "aria-hidden": "true" })
|
|
7466
|
+
}
|
|
7467
|
+
) : null
|
|
7468
|
+
]
|
|
7469
|
+
}
|
|
7470
|
+
);
|
|
7471
|
+
}
|
|
7472
|
+
function ErrorPage({
|
|
7473
|
+
title = "Something went wrong",
|
|
7474
|
+
description,
|
|
7475
|
+
errorCode,
|
|
7476
|
+
correlationId,
|
|
7477
|
+
actions,
|
|
7478
|
+
illustration,
|
|
7479
|
+
className
|
|
7480
|
+
}) {
|
|
7481
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7482
|
+
"div",
|
|
7483
|
+
{
|
|
7484
|
+
role: "alert",
|
|
7485
|
+
"aria-live": "assertive",
|
|
7486
|
+
className: cn(
|
|
7487
|
+
"mx-auto flex max-w-md flex-col items-center justify-center gap-4 px-6 py-16 text-center",
|
|
7488
|
+
className
|
|
7489
|
+
),
|
|
7490
|
+
children: [
|
|
7491
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-destructive", children: illustration ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.OctagonAlert, { className: "h-16 w-16", "aria-hidden": "true" }) }),
|
|
7492
|
+
errorCode ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-full bg-muted px-3 py-1 text-xs font-mono uppercase tracking-wider text-muted-foreground", children: errorCode }) : null,
|
|
7493
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-2xl font-semibold text-foreground", children: title }),
|
|
7494
|
+
description ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-muted-foreground", children: description }) : null,
|
|
7495
|
+
correlationId ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full rounded-md border bg-muted/40 px-3 py-2 text-left", children: [
|
|
7496
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[10px] uppercase tracking-wider text-muted-foreground", children: "Correlation ID" }),
|
|
7497
|
+
/* @__PURE__ */ jsxRuntime.jsx("code", { className: "break-all text-xs", children: correlationId })
|
|
7498
|
+
] }) : null,
|
|
7499
|
+
actions ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 flex flex-wrap items-center justify-center gap-2", children: actions }) : null
|
|
7500
|
+
]
|
|
7501
|
+
}
|
|
7502
|
+
);
|
|
7503
|
+
}
|
|
7504
|
+
function LoadingTimeout({
|
|
7505
|
+
active,
|
|
7506
|
+
children,
|
|
7507
|
+
skeleton,
|
|
7508
|
+
onRetry,
|
|
7509
|
+
thresholds,
|
|
7510
|
+
label = "content",
|
|
7511
|
+
className
|
|
7512
|
+
}) {
|
|
7513
|
+
const t = {
|
|
7514
|
+
gentle: thresholds?.gentle ?? 5e3,
|
|
7515
|
+
firm: thresholds?.firm ?? 15e3,
|
|
7516
|
+
expired: thresholds?.expired ?? 3e4
|
|
7517
|
+
};
|
|
7518
|
+
const [phase, setPhase] = React25__namespace.useState(active ? "silent" : "idle");
|
|
7519
|
+
React25__namespace.useEffect(() => {
|
|
7520
|
+
if (!active) {
|
|
7521
|
+
setPhase("idle");
|
|
7522
|
+
return;
|
|
7523
|
+
}
|
|
7524
|
+
setPhase("silent");
|
|
7525
|
+
const gentleTimer = window.setTimeout(() => setPhase("gentle"), t.gentle);
|
|
7526
|
+
const firmTimer = window.setTimeout(() => setPhase("firm"), t.firm);
|
|
7527
|
+
const expiredTimer = window.setTimeout(() => setPhase("expired"), t.expired);
|
|
7528
|
+
return () => {
|
|
7529
|
+
window.clearTimeout(gentleTimer);
|
|
7530
|
+
window.clearTimeout(firmTimer);
|
|
7531
|
+
window.clearTimeout(expiredTimer);
|
|
7532
|
+
};
|
|
7533
|
+
}, [active, t.gentle, t.firm, t.expired]);
|
|
7534
|
+
if (!active) {
|
|
7535
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
7536
|
+
}
|
|
7537
|
+
if (phase === "expired") {
|
|
7538
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, role: "alert", "aria-busy": "false", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7539
|
+
ErrorBanner,
|
|
7540
|
+
{
|
|
7541
|
+
severity: "error",
|
|
7542
|
+
title: "This is taking longer than expected",
|
|
7543
|
+
message: `We're still trying to load the ${label}. The connection may be slow.`,
|
|
7544
|
+
action: onRetry ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
7545
|
+
"button",
|
|
7546
|
+
{
|
|
7547
|
+
type: "button",
|
|
7548
|
+
onClick: onRetry,
|
|
7549
|
+
className: "rounded bg-foreground/10 px-3 py-1.5 text-sm font-medium hover:bg-foreground/15",
|
|
7550
|
+
children: "Try again"
|
|
7551
|
+
}
|
|
7552
|
+
) : null
|
|
7553
|
+
}
|
|
7554
|
+
) });
|
|
7555
|
+
}
|
|
7556
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, role: "status", "aria-busy": "true", "aria-live": "polite", children: [
|
|
7557
|
+
skeleton,
|
|
7558
|
+
phase === "gentle" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 text-center text-sm text-muted-foreground", children: [
|
|
7559
|
+
"Loading ",
|
|
7560
|
+
label,
|
|
7561
|
+
"\u2026"
|
|
7562
|
+
] }) : null,
|
|
7563
|
+
phase === "firm" ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 text-center text-sm text-muted-foreground", children: "Still working on it \u2014 almost there." }) : null
|
|
7564
|
+
] });
|
|
7565
|
+
}
|
|
7566
|
+
function ProgressiveImage({
|
|
7567
|
+
src,
|
|
7568
|
+
alt,
|
|
7569
|
+
lqip,
|
|
7570
|
+
width,
|
|
7571
|
+
height,
|
|
7572
|
+
loading = "lazy",
|
|
7573
|
+
fit = "cover",
|
|
7574
|
+
className,
|
|
7575
|
+
onLoad,
|
|
7576
|
+
onError
|
|
7577
|
+
}) {
|
|
7578
|
+
const [loaded, setLoaded] = React25__namespace.useState(false);
|
|
7579
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7580
|
+
"div",
|
|
7581
|
+
{
|
|
7582
|
+
className: cn("relative overflow-hidden bg-muted", className),
|
|
7583
|
+
style: { width, height },
|
|
7584
|
+
children: [
|
|
7585
|
+
lqip ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
7586
|
+
"img",
|
|
7587
|
+
{
|
|
7588
|
+
src: lqip,
|
|
7589
|
+
alt: "",
|
|
7590
|
+
"aria-hidden": "true",
|
|
7591
|
+
className: cn(
|
|
7592
|
+
"absolute inset-0 h-full w-full object-cover blur-md scale-110 transition-opacity duration-300",
|
|
7593
|
+
loaded ? "opacity-0" : "opacity-100"
|
|
7594
|
+
)
|
|
7595
|
+
}
|
|
7596
|
+
) : null,
|
|
7597
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7598
|
+
"img",
|
|
7599
|
+
{
|
|
7600
|
+
src,
|
|
7601
|
+
alt,
|
|
7602
|
+
loading,
|
|
7603
|
+
onLoad: () => {
|
|
7604
|
+
setLoaded(true);
|
|
7605
|
+
onLoad?.();
|
|
7606
|
+
},
|
|
7607
|
+
onError,
|
|
7608
|
+
className: cn(
|
|
7609
|
+
"absolute inset-0 h-full w-full transition-opacity duration-300",
|
|
7610
|
+
`object-${fit}`,
|
|
7611
|
+
loaded ? "opacity-100" : "opacity-0"
|
|
7612
|
+
)
|
|
7613
|
+
}
|
|
7614
|
+
)
|
|
7615
|
+
]
|
|
7616
|
+
}
|
|
7617
|
+
);
|
|
7618
|
+
}
|
|
7619
|
+
function HazoUiToaster({
|
|
7620
|
+
position = "bottom-right",
|
|
7621
|
+
closeButton = true,
|
|
7622
|
+
visibleToasts = 5
|
|
7623
|
+
} = {}) {
|
|
7624
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7625
|
+
sonner.Toaster,
|
|
7626
|
+
{
|
|
7627
|
+
position,
|
|
7628
|
+
closeButton,
|
|
7629
|
+
visibleToasts,
|
|
7630
|
+
theme: "system",
|
|
7631
|
+
richColors: true,
|
|
7632
|
+
toastOptions: {
|
|
7633
|
+
classNames: {
|
|
7634
|
+
toast: "group rounded-md border bg-background text-foreground shadow-lg",
|
|
7635
|
+
title: "font-medium",
|
|
7636
|
+
description: "text-muted-foreground text-sm"
|
|
7637
|
+
}
|
|
7638
|
+
}
|
|
7639
|
+
}
|
|
7640
|
+
);
|
|
7641
|
+
}
|
|
7642
|
+
function successToast({ title, description, duration = 3e3, action }) {
|
|
7643
|
+
return sonner.toast.success(title, {
|
|
7644
|
+
description,
|
|
7645
|
+
duration,
|
|
7646
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckCircle2, { className: "h-4 w-4 text-emerald-600" }),
|
|
7647
|
+
action: action ? { label: action.label, onClick: action.onClick } : void 0
|
|
7648
|
+
});
|
|
7649
|
+
}
|
|
7650
|
+
function errorToast({ title, description, duration = 5e3, action }) {
|
|
7651
|
+
return sonner.toast.error(title, {
|
|
7652
|
+
description,
|
|
7653
|
+
duration,
|
|
7654
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.OctagonAlert, { className: "h-4 w-4 text-destructive" }),
|
|
7655
|
+
action: action ? { label: action.label, onClick: action.onClick } : void 0
|
|
7656
|
+
});
|
|
7657
|
+
}
|
|
7658
|
+
function useLoadingState(initial = false) {
|
|
7659
|
+
const [isLoading, setLoading] = React25.useState(initial);
|
|
7660
|
+
const withLoading = React25.useCallback(async (fn) => {
|
|
7661
|
+
setLoading(true);
|
|
7662
|
+
try {
|
|
7663
|
+
return await fn();
|
|
7664
|
+
} finally {
|
|
7665
|
+
setLoading(false);
|
|
7666
|
+
}
|
|
7667
|
+
}, []);
|
|
7668
|
+
return { isLoading, setLoading, withLoading };
|
|
7669
|
+
}
|
|
7670
|
+
function useErrorDisplay() {
|
|
7671
|
+
const [error, setRaw] = React25.useState(null);
|
|
7672
|
+
const setError = React25.useCallback((value) => {
|
|
7673
|
+
if (value == null) {
|
|
7674
|
+
setRaw(null);
|
|
7675
|
+
return;
|
|
7676
|
+
}
|
|
7677
|
+
if (typeof value === "string") {
|
|
7678
|
+
setRaw(value);
|
|
7679
|
+
return;
|
|
7680
|
+
}
|
|
7681
|
+
if (value instanceof Error) {
|
|
7682
|
+
setRaw(value.message);
|
|
7683
|
+
return;
|
|
7684
|
+
}
|
|
7685
|
+
setRaw(String(value));
|
|
7686
|
+
}, []);
|
|
7687
|
+
const clearError = React25.useCallback(() => setRaw(null), []);
|
|
7688
|
+
return { error, setError, clearError };
|
|
7689
|
+
}
|
|
7690
|
+
function KanbanCard({
|
|
7691
|
+
item,
|
|
7692
|
+
renderCard,
|
|
7693
|
+
dragging = false,
|
|
7694
|
+
cardClassName,
|
|
7695
|
+
showEdit = false,
|
|
7696
|
+
onEditRequest
|
|
7697
|
+
}) {
|
|
7698
|
+
const {
|
|
7699
|
+
attributes,
|
|
7700
|
+
listeners,
|
|
7701
|
+
setNodeRef,
|
|
7702
|
+
transform,
|
|
7703
|
+
transition,
|
|
7704
|
+
isDragging
|
|
7705
|
+
} = sortable.useSortable({ id: item.id, data: { columnKey: item.columnKey } });
|
|
7706
|
+
const priority_var = item.priority ? `--hazo-kanban-priority-${String(item.priority).toLowerCase()}` : null;
|
|
7707
|
+
const style = {
|
|
7708
|
+
transform: utilities.CSS.Transform.toString(transform),
|
|
7709
|
+
transition,
|
|
7710
|
+
backgroundColor: "hsl(var(--hazo-kanban-card-bg))",
|
|
7711
|
+
border: `1px solid hsl(var(--hazo-kanban-card-border))`,
|
|
7712
|
+
borderLeft: priority_var ? `4px solid hsl(var(${priority_var}))` : `1px solid hsl(var(--hazo-kanban-card-border))`,
|
|
7713
|
+
opacity: isDragging && !dragging ? 0.4 : 1,
|
|
7714
|
+
cursor: "grab"
|
|
7715
|
+
};
|
|
7716
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7717
|
+
"div",
|
|
7718
|
+
{
|
|
7719
|
+
ref: setNodeRef,
|
|
7720
|
+
style,
|
|
7721
|
+
className: cn(
|
|
7722
|
+
"cls_hazo_kanban_card group relative rounded-md p-3 mb-2 select-none",
|
|
7723
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
7724
|
+
dragging && "cls_hazo_kanban_card_overlay shadow-lg",
|
|
7725
|
+
cardClassName
|
|
7726
|
+
),
|
|
7727
|
+
...attributes,
|
|
7728
|
+
...listeners,
|
|
7729
|
+
role: "button",
|
|
7730
|
+
tabIndex: 0,
|
|
7731
|
+
"aria-roledescription": "draggable card",
|
|
7732
|
+
"aria-grabbed": isDragging,
|
|
7733
|
+
children: [
|
|
7734
|
+
showEdit && onEditRequest && !dragging && /* @__PURE__ */ jsxRuntime.jsx(
|
|
7735
|
+
"button",
|
|
7736
|
+
{
|
|
7737
|
+
type: "button",
|
|
7738
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
7739
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
7740
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
7741
|
+
onClick: (e) => {
|
|
7742
|
+
e.stopPropagation();
|
|
7743
|
+
onEditRequest(item);
|
|
7744
|
+
},
|
|
7745
|
+
"aria-label": `Edit ${item.id}`,
|
|
7746
|
+
className: cn(
|
|
7747
|
+
"cls_hazo_kanban_card_edit absolute top-1.5 right-1.5",
|
|
7748
|
+
"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent",
|
|
7749
|
+
"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100",
|
|
7750
|
+
"focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
7751
|
+
"transition-opacity duration-150"
|
|
7752
|
+
),
|
|
7753
|
+
tabIndex: 0,
|
|
7754
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pencil, { className: "h-3.5 w-3.5" })
|
|
7755
|
+
}
|
|
7756
|
+
),
|
|
7757
|
+
renderCard(item)
|
|
7758
|
+
]
|
|
7759
|
+
}
|
|
7760
|
+
);
|
|
7761
|
+
}
|
|
7762
|
+
function KanbanColumn({
|
|
7763
|
+
column,
|
|
7764
|
+
items,
|
|
7765
|
+
renderCard,
|
|
7766
|
+
emptyColumn,
|
|
7767
|
+
cardClassName,
|
|
7768
|
+
showEdit,
|
|
7769
|
+
onEditRequest
|
|
7770
|
+
}) {
|
|
7771
|
+
const { setNodeRef, isOver } = core$1.useDroppable({
|
|
7772
|
+
id: `column:${column.key}`,
|
|
7773
|
+
data: { columnKey: column.key, isColumn: true }
|
|
7774
|
+
});
|
|
7775
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7776
|
+
"div",
|
|
7777
|
+
{
|
|
7778
|
+
ref: setNodeRef,
|
|
7779
|
+
className: cn(
|
|
7780
|
+
"cls_hazo_kanban_column flex flex-col rounded-md p-2",
|
|
7781
|
+
isOver && "cls_hazo_kanban_column_over bg-accent/30 ring-2 ring-ring/40"
|
|
7782
|
+
),
|
|
7783
|
+
children: [
|
|
7784
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_hazo_kanban_column_head flex items-center justify-between mb-2 px-1 text-xs uppercase tracking-wider text-muted-foreground", children: [
|
|
7785
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cls_hazo_kanban_column_title", children: column.title }),
|
|
7786
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cls_hazo_kanban_column_count rounded-full bg-muted px-2 py-0.5 text-foreground", children: items.length })
|
|
7787
|
+
] }),
|
|
7788
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7789
|
+
sortable.SortableContext,
|
|
7790
|
+
{
|
|
7791
|
+
items: items.map((i) => i.id),
|
|
7792
|
+
strategy: sortable.verticalListSortingStrategy,
|
|
7793
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_hazo_kanban_column_body flex-1 min-h-[40px]", children: items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_hazo_kanban_column_empty text-xs text-muted-foreground py-2 px-1", children: emptyColumn }) : items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7794
|
+
KanbanCard,
|
|
7795
|
+
{
|
|
7796
|
+
item,
|
|
7797
|
+
renderCard,
|
|
7798
|
+
cardClassName,
|
|
7799
|
+
showEdit,
|
|
7800
|
+
onEditRequest
|
|
7801
|
+
},
|
|
7802
|
+
item.id
|
|
7803
|
+
)) })
|
|
7804
|
+
}
|
|
7805
|
+
)
|
|
7806
|
+
]
|
|
7807
|
+
}
|
|
7808
|
+
);
|
|
7809
|
+
}
|
|
7810
|
+
var DEFAULT_PRIORITIES = ["P0", "P1", "P2", "P3"];
|
|
7811
|
+
function humanize(key) {
|
|
7812
|
+
return key.replace(/[_\-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\s+/g, " ").trim().split(" ").map((w) => w ? w[0].toUpperCase() + w.slice(1) : w).join(" ");
|
|
7813
|
+
}
|
|
7814
|
+
function auto_detect_fields(item, columns) {
|
|
7815
|
+
const skip = /* @__PURE__ */ new Set(["id", "columnKey", "priority"]);
|
|
7816
|
+
const out = [];
|
|
7817
|
+
for (const [key, value] of Object.entries(item)) {
|
|
7818
|
+
if (skip.has(key)) continue;
|
|
7819
|
+
if (typeof value === "string") {
|
|
7820
|
+
out.push({ key, type: "text" });
|
|
7821
|
+
}
|
|
7822
|
+
}
|
|
7823
|
+
if (columns.length > 0) {
|
|
7824
|
+
out.push({ key: "columnKey", type: "status", label: "Status" });
|
|
7825
|
+
}
|
|
7826
|
+
return out;
|
|
7827
|
+
}
|
|
7828
|
+
function KanbanEditor({
|
|
7829
|
+
item,
|
|
7830
|
+
columns,
|
|
7831
|
+
fields,
|
|
7832
|
+
priorities,
|
|
7833
|
+
titleFn,
|
|
7834
|
+
renderBody,
|
|
7835
|
+
hideFooter = false,
|
|
7836
|
+
onSave,
|
|
7837
|
+
onClose
|
|
7838
|
+
}) {
|
|
7839
|
+
const [draft, set_draft] = React25__namespace.useState(item);
|
|
7840
|
+
const [saving, set_saving] = React25__namespace.useState(false);
|
|
7841
|
+
const [error, set_error] = React25__namespace.useState(null);
|
|
7842
|
+
const item_id = item?.id ?? null;
|
|
7843
|
+
React25__namespace.useEffect(() => {
|
|
7844
|
+
set_draft(item);
|
|
7845
|
+
set_error(null);
|
|
7846
|
+
set_saving(false);
|
|
7847
|
+
}, [item_id]);
|
|
7848
|
+
const resolved_columns = columns ?? [];
|
|
7849
|
+
const resolved_priorities = priorities ?? DEFAULT_PRIORITIES;
|
|
7850
|
+
const resolved_fields = React25__namespace.useMemo(() => {
|
|
7851
|
+
if (fields) return fields;
|
|
7852
|
+
if (!item) return [];
|
|
7853
|
+
return auto_detect_fields(item, resolved_columns);
|
|
7854
|
+
}, [fields, item, resolved_columns]);
|
|
7855
|
+
const required_keys = React25__namespace.useMemo(
|
|
7856
|
+
() => resolved_fields.filter(
|
|
7857
|
+
(f) => f.required && (f.type === "text" || f.type === "textarea" || f.type === "number")
|
|
7858
|
+
).map((f) => f.key),
|
|
7859
|
+
[resolved_fields]
|
|
7860
|
+
);
|
|
7861
|
+
const all_required_filled = React25__namespace.useMemo(() => {
|
|
7862
|
+
if (!draft) return false;
|
|
7863
|
+
for (const key of required_keys) {
|
|
7864
|
+
const v = draft[key];
|
|
7865
|
+
if (v === void 0 || v === null || v === "") return false;
|
|
7866
|
+
if (typeof v === "string" && v.trim() === "") return false;
|
|
7867
|
+
}
|
|
7868
|
+
return true;
|
|
7869
|
+
}, [draft, required_keys]);
|
|
7870
|
+
const is_dirty = React25__namespace.useMemo(() => {
|
|
7871
|
+
if (!draft || !item) return false;
|
|
7872
|
+
try {
|
|
7873
|
+
return JSON.stringify(draft) !== JSON.stringify(item);
|
|
7874
|
+
} catch {
|
|
7875
|
+
return draft !== item;
|
|
7876
|
+
}
|
|
7877
|
+
}, [draft, item]);
|
|
7878
|
+
const handle_save = React25__namespace.useCallback(async () => {
|
|
7879
|
+
if (!draft || !item) return;
|
|
7880
|
+
if (saving) return;
|
|
7881
|
+
set_error(null);
|
|
7882
|
+
if (!onSave) {
|
|
7883
|
+
onClose();
|
|
7884
|
+
return;
|
|
7885
|
+
}
|
|
7886
|
+
const result = onSave({ itemId: item.id, item, next: draft });
|
|
7887
|
+
if (result && typeof result.then === "function") {
|
|
7888
|
+
set_saving(true);
|
|
7889
|
+
try {
|
|
7890
|
+
await result;
|
|
7891
|
+
set_saving(false);
|
|
7892
|
+
onClose();
|
|
7893
|
+
} catch (err) {
|
|
7894
|
+
set_saving(false);
|
|
7895
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
7896
|
+
set_error(message);
|
|
7897
|
+
}
|
|
7898
|
+
} else {
|
|
7899
|
+
onClose();
|
|
7900
|
+
}
|
|
7901
|
+
}, [draft, item, onSave, onClose, saving]);
|
|
7902
|
+
const ctx = {
|
|
7903
|
+
draft: draft ?? item,
|
|
7904
|
+
setDraft: (next) => {
|
|
7905
|
+
set_draft((prev) => {
|
|
7906
|
+
const base = prev ?? item;
|
|
7907
|
+
if (!base) return prev;
|
|
7908
|
+
if (typeof next === "function") {
|
|
7909
|
+
return next(base);
|
|
7910
|
+
}
|
|
7911
|
+
return next;
|
|
7912
|
+
});
|
|
7913
|
+
},
|
|
7914
|
+
save: handle_save,
|
|
7915
|
+
close: onClose,
|
|
7916
|
+
saving,
|
|
7917
|
+
error,
|
|
7918
|
+
isDirty: is_dirty
|
|
7919
|
+
};
|
|
7920
|
+
const open = item !== null;
|
|
7921
|
+
const title = item && titleFn ? titleFn(item) : item ? `Edit ${item.id}` : "";
|
|
7922
|
+
const priority_var = item?.priority ? `--hazo-kanban-priority-${String(item.priority).toLowerCase()}` : null;
|
|
7923
|
+
const header_bar_color = priority_var ? `hsl(var(${priority_var}))` : void 0;
|
|
7924
|
+
const use_default_footer = !(renderBody && hideFooter);
|
|
7925
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7926
|
+
HazoUiDialog,
|
|
7927
|
+
{
|
|
7928
|
+
open,
|
|
7929
|
+
onOpenChange: (o) => {
|
|
7930
|
+
if (!o && !saving) onClose();
|
|
7931
|
+
},
|
|
7932
|
+
title,
|
|
7933
|
+
description: "Update card details below.",
|
|
7934
|
+
sizeWidth: "min(90vw, 480px)",
|
|
7935
|
+
openAnimation: "none",
|
|
7936
|
+
closeAnimation: "none",
|
|
7937
|
+
headerBar: !!priority_var,
|
|
7938
|
+
headerBarColor: header_bar_color,
|
|
7939
|
+
contentClassName: cn("cls_hazo_kanban_editor", priority_var && "pt-0"),
|
|
7940
|
+
actionButtonText: saving ? "Saving\u2026" : "Save",
|
|
7941
|
+
actionButtonIcon: saving ? void 0 : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4 mr-2" }),
|
|
7942
|
+
actionButtonLoading: saving,
|
|
7943
|
+
actionButtonDisabled: !is_dirty || !all_required_filled || saving,
|
|
7944
|
+
cancelButtonText: "Cancel",
|
|
7945
|
+
showCancelButton: true,
|
|
7946
|
+
onConfirm: handle_save,
|
|
7947
|
+
onCancel: onClose,
|
|
7948
|
+
footerContent: use_default_footer ? void 0 : /* @__PURE__ */ jsxRuntime.jsx("span", {}),
|
|
7949
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_hazo_kanban_editor_body flex flex-col gap-4", children: [
|
|
7950
|
+
item && draft && renderBody ? renderBody(item, ctx) : draft ? resolved_fields.map((field) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7951
|
+
KanbanEditorFieldRow,
|
|
7952
|
+
{
|
|
7953
|
+
field,
|
|
7954
|
+
draft,
|
|
7955
|
+
setDraft: (updater) => set_draft(
|
|
7956
|
+
(prev) => prev ? updater(prev) : prev
|
|
7957
|
+
),
|
|
7958
|
+
priorities: resolved_priorities,
|
|
7959
|
+
columns: resolved_columns
|
|
7960
|
+
},
|
|
7961
|
+
field.key
|
|
7962
|
+
)) : null,
|
|
7963
|
+
error && /* @__PURE__ */ jsxRuntime.jsx(
|
|
7964
|
+
"div",
|
|
7965
|
+
{
|
|
7966
|
+
className: "cls_hazo_kanban_editor_error mt-1 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",
|
|
7967
|
+
role: "alert",
|
|
7968
|
+
children: error
|
|
7969
|
+
}
|
|
7970
|
+
)
|
|
7971
|
+
] })
|
|
7972
|
+
}
|
|
7973
|
+
);
|
|
7974
|
+
}
|
|
7975
|
+
function KanbanEditorFieldRow({
|
|
7976
|
+
field,
|
|
7977
|
+
draft,
|
|
7978
|
+
setDraft,
|
|
7979
|
+
priorities,
|
|
7980
|
+
columns
|
|
7981
|
+
}) {
|
|
7982
|
+
const id = `kanban-editor-${field.key}`;
|
|
7983
|
+
const label = field.label ?? humanize(field.key);
|
|
7984
|
+
const value = draft[field.key];
|
|
7985
|
+
const set_value = (next_value) => {
|
|
7986
|
+
setDraft((prev) => ({ ...prev, [field.key]: next_value }));
|
|
7987
|
+
};
|
|
7988
|
+
const required_marker_shown = field.required && (field.type === "text" || field.type === "textarea" || field.type === "number");
|
|
7989
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("cls_hazo_kanban_editor_field flex flex-col gap-1.5"), children: [
|
|
7990
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Label3, { htmlFor: id, className: "text-xs font-medium text-muted-foreground", children: [
|
|
7991
|
+
label,
|
|
7992
|
+
required_marker_shown && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-destructive ml-0.5", children: "*" })
|
|
7993
|
+
] }),
|
|
7994
|
+
field.type === "text" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
7995
|
+
Input,
|
|
7996
|
+
{
|
|
7997
|
+
id,
|
|
7998
|
+
value: typeof value === "string" ? value : "",
|
|
7999
|
+
placeholder: field.placeholder,
|
|
8000
|
+
onChange: (e) => set_value(e.target.value)
|
|
8001
|
+
}
|
|
8002
|
+
),
|
|
8003
|
+
field.type === "textarea" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8004
|
+
Textarea,
|
|
8005
|
+
{
|
|
8006
|
+
id,
|
|
8007
|
+
value: typeof value === "string" ? value : "",
|
|
8008
|
+
placeholder: field.placeholder,
|
|
8009
|
+
rows: 3,
|
|
8010
|
+
onChange: (e) => set_value(e.target.value)
|
|
8011
|
+
}
|
|
8012
|
+
),
|
|
8013
|
+
field.type === "number" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8014
|
+
Input,
|
|
8015
|
+
{
|
|
8016
|
+
id,
|
|
8017
|
+
type: "number",
|
|
8018
|
+
value: typeof value === "number" ? value : value === "" || value == null ? "" : Number(value) || 0,
|
|
8019
|
+
placeholder: field.placeholder,
|
|
8020
|
+
onChange: (e) => set_value(e.target.value === "" ? void 0 : Number(e.target.value))
|
|
8021
|
+
}
|
|
8022
|
+
),
|
|
8023
|
+
field.type === "checkbox" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8024
|
+
Checkbox,
|
|
8025
|
+
{
|
|
8026
|
+
id,
|
|
8027
|
+
checked: !!value,
|
|
8028
|
+
onCheckedChange: (checked) => set_value(checked === true)
|
|
8029
|
+
}
|
|
8030
|
+
),
|
|
8031
|
+
field.type === "select" && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8032
|
+
Select,
|
|
8033
|
+
{
|
|
8034
|
+
value: typeof value === "string" ? value : "",
|
|
8035
|
+
onValueChange: set_value,
|
|
8036
|
+
children: [
|
|
8037
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { id, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8038
|
+
SelectValue,
|
|
8039
|
+
{
|
|
8040
|
+
placeholder: field.placeholder ?? `Select ${label}\u2026`
|
|
8041
|
+
}
|
|
8042
|
+
) }),
|
|
8043
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: (field.options ?? []).map((opt) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: opt, children: opt }, opt)) })
|
|
8044
|
+
]
|
|
8045
|
+
}
|
|
8046
|
+
),
|
|
8047
|
+
field.type === "priority" && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8048
|
+
Select,
|
|
8049
|
+
{
|
|
8050
|
+
value: typeof value === "string" ? value : "",
|
|
8051
|
+
onValueChange: set_value,
|
|
8052
|
+
children: [
|
|
8053
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { id, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8054
|
+
SelectValue,
|
|
8055
|
+
{
|
|
8056
|
+
placeholder: field.placeholder ?? "Select priority\u2026"
|
|
8057
|
+
}
|
|
8058
|
+
) }),
|
|
8059
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: priorities.map((p) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: p, children: p }, p)) })
|
|
8060
|
+
]
|
|
8061
|
+
}
|
|
8062
|
+
),
|
|
8063
|
+
field.type === "status" && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8064
|
+
Select,
|
|
8065
|
+
{
|
|
8066
|
+
value: typeof value === "string" ? value : "",
|
|
8067
|
+
onValueChange: set_value,
|
|
8068
|
+
children: [
|
|
8069
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { id, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8070
|
+
SelectValue,
|
|
8071
|
+
{
|
|
8072
|
+
placeholder: field.placeholder ?? "Select status\u2026"
|
|
8073
|
+
}
|
|
8074
|
+
) }),
|
|
8075
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: columns.map((col) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: col.key, children: col.title }, col.key)) })
|
|
8076
|
+
]
|
|
8077
|
+
}
|
|
8078
|
+
)
|
|
8079
|
+
] });
|
|
8080
|
+
}
|
|
8081
|
+
var EMPTY_FILTER = {
|
|
8082
|
+
search: "",
|
|
8083
|
+
categories: [],
|
|
8084
|
+
priority: null
|
|
8085
|
+
};
|
|
8086
|
+
function HazoUiKanbanFilter({
|
|
8087
|
+
search = true,
|
|
8088
|
+
searchPlaceholder = "Search...",
|
|
8089
|
+
categories,
|
|
8090
|
+
priorities,
|
|
8091
|
+
value,
|
|
8092
|
+
defaultValue,
|
|
8093
|
+
onChange,
|
|
8094
|
+
className
|
|
8095
|
+
}) {
|
|
8096
|
+
const is_controlled = value !== void 0;
|
|
8097
|
+
const [internal, set_internal] = React25__namespace.useState(
|
|
8098
|
+
defaultValue ?? EMPTY_FILTER
|
|
8099
|
+
);
|
|
8100
|
+
const current = is_controlled ? value : internal;
|
|
8101
|
+
const update = React25__namespace.useCallback(
|
|
8102
|
+
(next) => {
|
|
8103
|
+
if (!is_controlled) set_internal(next);
|
|
8104
|
+
onChange?.(next);
|
|
8105
|
+
},
|
|
8106
|
+
[is_controlled, onChange]
|
|
8107
|
+
);
|
|
8108
|
+
const has_active = current.search.length > 0 || current.categories.length > 0 || current.priority !== null;
|
|
8109
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8110
|
+
"div",
|
|
8111
|
+
{
|
|
8112
|
+
className: cn(
|
|
8113
|
+
"cls_hazo_kanban_filter flex flex-wrap items-center gap-3 p-2",
|
|
8114
|
+
className
|
|
8115
|
+
),
|
|
8116
|
+
children: [
|
|
8117
|
+
search && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8118
|
+
Input,
|
|
8119
|
+
{
|
|
8120
|
+
value: current.search,
|
|
8121
|
+
onChange: (e) => update({ ...current, search: e.target.value }),
|
|
8122
|
+
placeholder: searchPlaceholder,
|
|
8123
|
+
className: "cls_hazo_kanban_filter_search w-full sm:w-64"
|
|
8124
|
+
}
|
|
8125
|
+
),
|
|
8126
|
+
categories && categories.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8127
|
+
ToggleGroup,
|
|
8128
|
+
{
|
|
8129
|
+
type: "multiple",
|
|
8130
|
+
value: current.categories,
|
|
8131
|
+
onValueChange: (cats) => update({ ...current, categories: cats }),
|
|
8132
|
+
className: "cls_hazo_kanban_filter_categories flex flex-wrap gap-1",
|
|
8133
|
+
children: categories.map((cat) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
8134
|
+
ToggleGroupItem,
|
|
8135
|
+
{
|
|
8136
|
+
value: cat,
|
|
8137
|
+
size: "sm",
|
|
8138
|
+
className: "cls_hazo_kanban_filter_category_chip",
|
|
8139
|
+
children: cat
|
|
8140
|
+
},
|
|
8141
|
+
cat
|
|
8142
|
+
))
|
|
8143
|
+
}
|
|
8144
|
+
),
|
|
8145
|
+
priorities && priorities.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8146
|
+
ToggleGroup,
|
|
8147
|
+
{
|
|
8148
|
+
type: "single",
|
|
8149
|
+
value: current.priority ?? "",
|
|
8150
|
+
onValueChange: (p) => update({
|
|
8151
|
+
...current,
|
|
8152
|
+
priority: p ? p : null
|
|
8153
|
+
}),
|
|
8154
|
+
className: "cls_hazo_kanban_filter_priority flex gap-1",
|
|
8155
|
+
children: priorities.map((p) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
8156
|
+
ToggleGroupItem,
|
|
8157
|
+
{
|
|
8158
|
+
value: p,
|
|
8159
|
+
size: "sm",
|
|
8160
|
+
className: "cls_hazo_kanban_filter_priority_chip",
|
|
8161
|
+
children: p
|
|
8162
|
+
},
|
|
8163
|
+
p
|
|
8164
|
+
))
|
|
8165
|
+
}
|
|
8166
|
+
),
|
|
8167
|
+
has_active && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8168
|
+
Button,
|
|
8169
|
+
{
|
|
8170
|
+
variant: "ghost",
|
|
8171
|
+
size: "sm",
|
|
8172
|
+
onClick: () => update(EMPTY_FILTER),
|
|
8173
|
+
className: "cls_hazo_kanban_filter_clear",
|
|
8174
|
+
children: [
|
|
8175
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4 mr-1" }),
|
|
8176
|
+
"Clear"
|
|
8177
|
+
]
|
|
8178
|
+
}
|
|
8179
|
+
)
|
|
8180
|
+
]
|
|
8181
|
+
}
|
|
8182
|
+
);
|
|
8183
|
+
}
|
|
8184
|
+
|
|
8185
|
+
// src/components/hazo_ui_kanban/apply_kanban_filter.ts
|
|
8186
|
+
function applyKanbanFilter(items, filter) {
|
|
8187
|
+
const search = filter.search.trim().toLowerCase();
|
|
8188
|
+
return items.filter((item) => {
|
|
8189
|
+
if (filter.priority && item.priority !== filter.priority) {
|
|
8190
|
+
return false;
|
|
8191
|
+
}
|
|
8192
|
+
if (filter.categories.length > 0) {
|
|
8193
|
+
const cat = item.category;
|
|
8194
|
+
if (typeof cat !== "string" || !filter.categories.includes(cat)) {
|
|
8195
|
+
return false;
|
|
8196
|
+
}
|
|
8197
|
+
}
|
|
8198
|
+
if (search) {
|
|
8199
|
+
const haystack = Object.values(item).filter((v) => typeof v === "string").join(" ").toLowerCase();
|
|
8200
|
+
if (!haystack.includes(search)) {
|
|
8201
|
+
return false;
|
|
8202
|
+
}
|
|
8203
|
+
}
|
|
8204
|
+
return true;
|
|
8205
|
+
});
|
|
8206
|
+
}
|
|
8207
|
+
function default_announcements(itemLabel) {
|
|
8208
|
+
return {
|
|
8209
|
+
onDragStart: ({ item, fromColumn }) => `Picked up ${itemLabel(item)}. Currently in ${fromColumn}. Use arrow keys to choose a different column. Press space to drop, escape to cancel.`,
|
|
8210
|
+
onDragOver: ({ item, overColumn }) => overColumn ? `${itemLabel(item)} over ${overColumn}.` : "",
|
|
8211
|
+
onDragEnd: ({ item, fromColumn, toColumn, newIndex }) => fromColumn === toColumn ? `${itemLabel(item)} reordered to position ${newIndex + 1} in ${toColumn}.` : `${itemLabel(item)} dropped in ${toColumn}, position ${newIndex + 1}.`,
|
|
8212
|
+
onDragCancel: ({ item, fromColumn }) => `Movement cancelled. ${itemLabel(item)} returned to ${fromColumn}.`
|
|
8213
|
+
};
|
|
8214
|
+
}
|
|
8215
|
+
function group_items_by_column(items, overlay, columns) {
|
|
8216
|
+
const out = /* @__PURE__ */ new Map();
|
|
8217
|
+
for (const col of columns) out.set(col.key, []);
|
|
8218
|
+
const overlay_inserts = /* @__PURE__ */ new Map();
|
|
8219
|
+
for (const col of columns) overlay_inserts.set(col.key, []);
|
|
8220
|
+
for (const item of items) {
|
|
8221
|
+
const ov = overlay.get(item.id);
|
|
8222
|
+
if (ov) {
|
|
8223
|
+
const bucket = overlay_inserts.get(ov.columnKey);
|
|
8224
|
+
if (bucket) {
|
|
8225
|
+
bucket.push({ item, index: ov.index });
|
|
8226
|
+
}
|
|
8227
|
+
} else {
|
|
8228
|
+
const bucket = out.get(item.columnKey);
|
|
8229
|
+
if (bucket) bucket.push(item);
|
|
8230
|
+
}
|
|
8231
|
+
}
|
|
8232
|
+
for (const col of columns) {
|
|
8233
|
+
const inserts = overlay_inserts.get(col.key) ?? [];
|
|
8234
|
+
inserts.sort((a, b) => a.index - b.index);
|
|
8235
|
+
const arr = out.get(col.key) ?? [];
|
|
8236
|
+
for (const { item, index } of inserts) {
|
|
8237
|
+
const at = Math.max(0, Math.min(index, arr.length));
|
|
8238
|
+
arr.splice(at, 0, item);
|
|
8239
|
+
}
|
|
8240
|
+
out.set(col.key, arr);
|
|
8241
|
+
}
|
|
8242
|
+
return out;
|
|
8243
|
+
}
|
|
8244
|
+
function HazoUiKanban({
|
|
8245
|
+
columns,
|
|
8246
|
+
items,
|
|
8247
|
+
renderCard,
|
|
8248
|
+
onMove,
|
|
8249
|
+
onReorder,
|
|
8250
|
+
mobileBreakpoint = 640,
|
|
8251
|
+
announcements,
|
|
8252
|
+
emptyColumn = "\u2014",
|
|
8253
|
+
className,
|
|
8254
|
+
cardClassName,
|
|
8255
|
+
itemLabel,
|
|
8256
|
+
editorFields,
|
|
8257
|
+
editorPriorities,
|
|
8258
|
+
editorTitle,
|
|
8259
|
+
renderCardEditor,
|
|
8260
|
+
hideEditorFooter,
|
|
8261
|
+
onCardSave,
|
|
8262
|
+
disableEdit = false
|
|
8263
|
+
}) {
|
|
8264
|
+
const label_fn = React25__namespace.useCallback(
|
|
8265
|
+
(item) => itemLabel ? itemLabel(item) : item.id,
|
|
8266
|
+
[itemLabel]
|
|
8267
|
+
);
|
|
8268
|
+
const dnd_context_id = React25__namespace.useId();
|
|
8269
|
+
const [overlay, set_overlay] = React25__namespace.useState(
|
|
8270
|
+
/* @__PURE__ */ new Map()
|
|
8271
|
+
);
|
|
8272
|
+
const [active_id, set_active_id] = React25__namespace.useState(null);
|
|
8273
|
+
const [active_tab, set_active_tab] = React25__namespace.useState(columns[0]?.key ?? "");
|
|
8274
|
+
const [editing_item, set_editing_item] = React25__namespace.useState(null);
|
|
8275
|
+
const show_edit = !disableEdit && typeof onCardSave === "function";
|
|
8276
|
+
const handle_edit_request = React25__namespace.useCallback(
|
|
8277
|
+
(it) => {
|
|
8278
|
+
const typed = items.find((x) => x.id === it.id);
|
|
8279
|
+
if (typed) set_editing_item(typed);
|
|
8280
|
+
},
|
|
8281
|
+
[items]
|
|
8282
|
+
);
|
|
8283
|
+
const handle_editor_close = React25__namespace.useCallback(() => {
|
|
8284
|
+
set_editing_item(null);
|
|
8285
|
+
}, []);
|
|
8286
|
+
React25__namespace.useEffect(() => {
|
|
8287
|
+
if (overlay.size === 0) return;
|
|
8288
|
+
set_overlay((prev) => {
|
|
8289
|
+
let changed = false;
|
|
8290
|
+
const next = new Map(prev);
|
|
8291
|
+
for (const [item_id, pos] of prev.entries()) {
|
|
8292
|
+
const item = items.find((i) => i.id === item_id);
|
|
8293
|
+
if (item && item.columnKey === pos.columnKey) {
|
|
8294
|
+
next.delete(item_id);
|
|
8295
|
+
changed = true;
|
|
8296
|
+
}
|
|
8297
|
+
}
|
|
8298
|
+
return changed ? next : prev;
|
|
8299
|
+
});
|
|
8300
|
+
}, [items, overlay]);
|
|
8301
|
+
const grouped = React25__namespace.useMemo(
|
|
8302
|
+
() => group_items_by_column(items, overlay, columns),
|
|
8303
|
+
[items, overlay, columns]
|
|
8304
|
+
);
|
|
8305
|
+
const find_item = React25__namespace.useCallback(
|
|
8306
|
+
(id) => items.find((i) => i.id === id),
|
|
8307
|
+
[items]
|
|
8308
|
+
);
|
|
8309
|
+
const sensors = core$1.useSensors(
|
|
8310
|
+
core$1.useSensor(core$1.PointerSensor, { activationConstraint: { distance: 5 } }),
|
|
8311
|
+
core$1.useSensor(core$1.KeyboardSensor, { coordinateGetter: sortable.sortableKeyboardCoordinates })
|
|
8312
|
+
);
|
|
8313
|
+
const merged_announcements = React25__namespace.useMemo(() => {
|
|
8314
|
+
const defaults = default_announcements(label_fn);
|
|
8315
|
+
return {
|
|
8316
|
+
onDragStart: announcements?.onDragStart ?? defaults.onDragStart,
|
|
8317
|
+
onDragOver: announcements?.onDragOver ?? defaults.onDragOver,
|
|
8318
|
+
onDragEnd: announcements?.onDragEnd ?? defaults.onDragEnd,
|
|
8319
|
+
onDragCancel: announcements?.onDragCancel ?? defaults.onDragCancel
|
|
8320
|
+
};
|
|
8321
|
+
}, [announcements, label_fn]);
|
|
8322
|
+
const dnd_announcements = React25__namespace.useMemo(
|
|
8323
|
+
() => ({
|
|
8324
|
+
onDragStart({ active }) {
|
|
8325
|
+
const id = String(active.id);
|
|
8326
|
+
const item = find_item(id);
|
|
8327
|
+
if (!item) return "";
|
|
8328
|
+
const col = columns.find((c) => c.key === item.columnKey);
|
|
8329
|
+
return merged_announcements.onDragStart({
|
|
8330
|
+
item,
|
|
8331
|
+
fromColumn: col?.title ?? item.columnKey
|
|
8332
|
+
});
|
|
8333
|
+
},
|
|
8334
|
+
onDragOver({
|
|
8335
|
+
active,
|
|
8336
|
+
over
|
|
8337
|
+
}) {
|
|
8338
|
+
const id = String(active.id);
|
|
8339
|
+
const item = find_item(id);
|
|
8340
|
+
if (!item) return "";
|
|
8341
|
+
const over_col_key = over ? over.data?.current?.columnKey ?? String(over.id).replace(/^column:/, "") : null;
|
|
8342
|
+
const col = over_col_key ? columns.find((c) => c.key === over_col_key) : null;
|
|
8343
|
+
return merged_announcements.onDragOver({
|
|
8344
|
+
item,
|
|
8345
|
+
overColumn: col?.title ?? null
|
|
8346
|
+
});
|
|
8347
|
+
},
|
|
8348
|
+
onDragEnd({
|
|
8349
|
+
active,
|
|
8350
|
+
over
|
|
8351
|
+
}) {
|
|
8352
|
+
const id = String(active.id);
|
|
8353
|
+
const item = find_item(id);
|
|
8354
|
+
if (!item) return "";
|
|
8355
|
+
const from_col = columns.find((c) => c.key === item.columnKey);
|
|
8356
|
+
const over_col_key = over ? over.data?.current?.columnKey ?? String(over.id).replace(/^column:/, "") : null;
|
|
8357
|
+
const to_col = over_col_key ? columns.find((c) => c.key === over_col_key) ?? from_col : from_col;
|
|
8358
|
+
const target = over_col_key ? grouped.get(over_col_key) ?? [] : grouped.get(item.columnKey) ?? [];
|
|
8359
|
+
const new_index = over && String(over.id) !== `column:${over_col_key}` ? target.findIndex((it) => it.id === String(over.id)) : target.length;
|
|
8360
|
+
return merged_announcements.onDragEnd({
|
|
8361
|
+
item,
|
|
8362
|
+
fromColumn: from_col?.title ?? item.columnKey,
|
|
8363
|
+
toColumn: to_col?.title ?? item.columnKey,
|
|
8364
|
+
newIndex: Math.max(0, new_index)
|
|
8365
|
+
});
|
|
8366
|
+
},
|
|
8367
|
+
onDragCancel({ active }) {
|
|
8368
|
+
const id = String(active.id);
|
|
8369
|
+
const item = find_item(id);
|
|
8370
|
+
if (!item) return "";
|
|
8371
|
+
const col = columns.find((c) => c.key === item.columnKey);
|
|
8372
|
+
return merged_announcements.onDragCancel({
|
|
8373
|
+
item,
|
|
8374
|
+
fromColumn: col?.title ?? item.columnKey
|
|
8375
|
+
});
|
|
8376
|
+
}
|
|
8377
|
+
}),
|
|
8378
|
+
[find_item, columns, grouped, merged_announcements]
|
|
8379
|
+
);
|
|
8380
|
+
const handle_drag_start = React25__namespace.useCallback((event) => {
|
|
8381
|
+
set_active_id(String(event.active.id));
|
|
8382
|
+
}, []);
|
|
8383
|
+
const make_revert_handle = React25__namespace.useCallback(
|
|
8384
|
+
(item_id) => ({
|
|
8385
|
+
revert: () => {
|
|
8386
|
+
set_overlay((prev) => {
|
|
8387
|
+
if (!prev.has(item_id)) return prev;
|
|
8388
|
+
const next = new Map(prev);
|
|
8389
|
+
next.delete(item_id);
|
|
8390
|
+
return next;
|
|
8391
|
+
});
|
|
8392
|
+
}
|
|
8393
|
+
}),
|
|
8394
|
+
[]
|
|
8395
|
+
);
|
|
8396
|
+
const handle_drag_end = React25__namespace.useCallback(
|
|
8397
|
+
(event) => {
|
|
8398
|
+
const active_id_str = String(event.active.id);
|
|
8399
|
+
set_active_id(null);
|
|
8400
|
+
const item = find_item(active_id_str);
|
|
8401
|
+
if (!item) return;
|
|
8402
|
+
if (!event.over) return;
|
|
8403
|
+
const over_id = String(event.over.id);
|
|
8404
|
+
const over_data = event.over.data?.current;
|
|
8405
|
+
const dest_column_key = over_data?.columnKey ?? over_id.replace(/^column:/, "");
|
|
8406
|
+
const dest_column = columns.find((c) => c.key === dest_column_key);
|
|
8407
|
+
if (!dest_column) return;
|
|
8408
|
+
if (dest_column.accepts && !dest_column.accepts(item)) return;
|
|
8409
|
+
const dest_items_pre_overlay = grouped.get(dest_column_key) ?? [];
|
|
8410
|
+
let new_index;
|
|
8411
|
+
if (over_data?.isColumn) {
|
|
8412
|
+
new_index = dest_items_pre_overlay.length;
|
|
8413
|
+
} else {
|
|
8414
|
+
const idx = dest_items_pre_overlay.findIndex((i) => i.id === over_id);
|
|
8415
|
+
new_index = idx === -1 ? dest_items_pre_overlay.length : idx;
|
|
8416
|
+
}
|
|
8417
|
+
const handle = make_revert_handle(active_id_str);
|
|
8418
|
+
if (item.columnKey === dest_column_key) {
|
|
8419
|
+
if (active_id_str === over_id) return;
|
|
8420
|
+
set_overlay((prev) => {
|
|
8421
|
+
const next = new Map(prev);
|
|
8422
|
+
next.set(active_id_str, {
|
|
8423
|
+
columnKey: dest_column_key,
|
|
8424
|
+
index: new_index
|
|
8425
|
+
});
|
|
8426
|
+
return next;
|
|
8427
|
+
});
|
|
8428
|
+
const reorder_event = {
|
|
8429
|
+
itemId: active_id_str,
|
|
8430
|
+
item,
|
|
8431
|
+
columnKey: dest_column_key,
|
|
8432
|
+
newIndex: new_index,
|
|
8433
|
+
revert: handle.revert
|
|
8434
|
+
};
|
|
8435
|
+
onReorder?.(reorder_event);
|
|
8436
|
+
return;
|
|
8437
|
+
}
|
|
8438
|
+
set_overlay((prev) => {
|
|
8439
|
+
const next = new Map(prev);
|
|
8440
|
+
next.set(active_id_str, {
|
|
8441
|
+
columnKey: dest_column_key,
|
|
8442
|
+
index: new_index
|
|
8443
|
+
});
|
|
8444
|
+
return next;
|
|
8445
|
+
});
|
|
8446
|
+
const move_event = {
|
|
8447
|
+
itemId: active_id_str,
|
|
8448
|
+
item,
|
|
8449
|
+
fromColumn: item.columnKey,
|
|
8450
|
+
toColumn: dest_column_key,
|
|
8451
|
+
newIndex: new_index,
|
|
8452
|
+
revert: handle.revert
|
|
8453
|
+
};
|
|
8454
|
+
onMove?.(move_event);
|
|
8455
|
+
},
|
|
8456
|
+
[find_item, columns, grouped, onMove, onReorder, make_revert_handle]
|
|
8457
|
+
);
|
|
8458
|
+
const handle_drag_cancel = React25__namespace.useCallback(() => {
|
|
8459
|
+
set_active_id(null);
|
|
8460
|
+
}, []);
|
|
8461
|
+
const active_item = active_id ? find_item(active_id) : null;
|
|
8462
|
+
const is_custom_breakpoint = mobileBreakpoint !== 640;
|
|
8463
|
+
const is_mobile_via_query = useMediaQuery(
|
|
8464
|
+
`(max-width: ${Math.max(0, mobileBreakpoint - 1)}px)`
|
|
8465
|
+
);
|
|
8466
|
+
const mobile_classes = is_custom_breakpoint ? is_mobile_via_query ? "block" : "hidden" : "sm:hidden";
|
|
8467
|
+
const desktop_classes = is_custom_breakpoint ? is_mobile_via_query ? "hidden" : "grid" : "hidden sm:grid";
|
|
8468
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8469
|
+
core$1.DndContext,
|
|
8470
|
+
{
|
|
8471
|
+
id: dnd_context_id,
|
|
8472
|
+
sensors,
|
|
8473
|
+
collisionDetection: core$1.closestCorners,
|
|
8474
|
+
onDragStart: handle_drag_start,
|
|
8475
|
+
onDragEnd: handle_drag_end,
|
|
8476
|
+
onDragCancel: handle_drag_cancel,
|
|
8477
|
+
accessibility: { announcements: dnd_announcements },
|
|
8478
|
+
children: [
|
|
8479
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("cls_hazo_kanban w-full", className), children: [
|
|
8480
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("cls_hazo_kanban_mobile", mobile_classes), children: /* @__PURE__ */ jsxRuntime.jsxs(Tabs, { value: active_tab, onValueChange: set_active_tab, children: [
|
|
8481
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsList, { className: "grid w-full", style: { gridTemplateColumns: `repeat(${columns.length}, 1fr)` }, children: columns.map((col) => {
|
|
8482
|
+
const count = (grouped.get(col.key) ?? []).length;
|
|
8483
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(TabsTrigger, { value: col.key, className: "flex flex-col gap-0.5", children: [
|
|
8484
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", children: col.title }),
|
|
8485
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground", children: count })
|
|
8486
|
+
] }, col.key);
|
|
8487
|
+
}) }),
|
|
8488
|
+
columns.map((col) => /* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: col.key, className: "mt-3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8489
|
+
KanbanColumn,
|
|
8490
|
+
{
|
|
8491
|
+
column: col,
|
|
8492
|
+
items: grouped.get(col.key) ?? [],
|
|
8493
|
+
renderCard,
|
|
8494
|
+
emptyColumn,
|
|
8495
|
+
cardClassName,
|
|
8496
|
+
showEdit: show_edit,
|
|
8497
|
+
onEditRequest: handle_edit_request
|
|
8498
|
+
}
|
|
8499
|
+
) }, col.key))
|
|
8500
|
+
] }) }),
|
|
8501
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8502
|
+
"div",
|
|
8503
|
+
{
|
|
8504
|
+
className: cn("cls_hazo_kanban_desktop gap-3", desktop_classes),
|
|
8505
|
+
style: { gridTemplateColumns: `repeat(${columns.length}, minmax(0, 1fr))` },
|
|
8506
|
+
children: columns.map((col) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
8507
|
+
KanbanColumn,
|
|
8508
|
+
{
|
|
8509
|
+
column: col,
|
|
8510
|
+
items: grouped.get(col.key) ?? [],
|
|
8511
|
+
renderCard,
|
|
8512
|
+
emptyColumn,
|
|
8513
|
+
cardClassName,
|
|
8514
|
+
showEdit: show_edit,
|
|
8515
|
+
onEditRequest: handle_edit_request
|
|
8516
|
+
},
|
|
8517
|
+
col.key
|
|
8518
|
+
))
|
|
8519
|
+
}
|
|
8520
|
+
),
|
|
8521
|
+
/* @__PURE__ */ jsxRuntime.jsx(core$1.DragOverlay, { children: active_item ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
8522
|
+
KanbanCard,
|
|
8523
|
+
{
|
|
8524
|
+
item: active_item,
|
|
8525
|
+
renderCard,
|
|
8526
|
+
dragging: true,
|
|
8527
|
+
cardClassName
|
|
8528
|
+
}
|
|
8529
|
+
) : null })
|
|
8530
|
+
] }),
|
|
8531
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8532
|
+
KanbanEditor,
|
|
8533
|
+
{
|
|
8534
|
+
item: editing_item,
|
|
8535
|
+
columns,
|
|
8536
|
+
fields: editorFields,
|
|
8537
|
+
priorities: editorPriorities,
|
|
8538
|
+
titleFn: editorTitle,
|
|
8539
|
+
renderBody: renderCardEditor,
|
|
8540
|
+
hideFooter: hideEditorFooter,
|
|
8541
|
+
onSave: onCardSave,
|
|
8542
|
+
onClose: handle_editor_close
|
|
8543
|
+
}
|
|
8544
|
+
)
|
|
8545
|
+
]
|
|
8546
|
+
}
|
|
8547
|
+
);
|
|
8548
|
+
}
|
|
8549
|
+
var Table2 = React25__namespace.forwardRef(
|
|
8550
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_table_wrap relative w-full overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8551
|
+
"table",
|
|
8552
|
+
{
|
|
8553
|
+
ref,
|
|
8554
|
+
className: cn("w-full caption-bottom text-sm", className),
|
|
8555
|
+
...props
|
|
8556
|
+
}
|
|
8557
|
+
) })
|
|
8558
|
+
);
|
|
8559
|
+
Table2.displayName = "Table";
|
|
8560
|
+
var TableHeader2 = React25__namespace.forwardRef(
|
|
8561
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props })
|
|
8562
|
+
);
|
|
8563
|
+
TableHeader2.displayName = "TableHeader";
|
|
8564
|
+
var TableBody = React25__namespace.forwardRef(
|
|
8565
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
8566
|
+
"tbody",
|
|
8567
|
+
{
|
|
8568
|
+
ref,
|
|
8569
|
+
className: cn("[&_tr:last-child]:border-0", className),
|
|
8570
|
+
...props
|
|
8571
|
+
}
|
|
8572
|
+
)
|
|
8573
|
+
);
|
|
8574
|
+
TableBody.displayName = "TableBody";
|
|
8575
|
+
var TableFooter = React25__namespace.forwardRef(
|
|
8576
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
8577
|
+
"tfoot",
|
|
8578
|
+
{
|
|
8579
|
+
ref,
|
|
8580
|
+
className: cn("bg-muted/50 font-medium [&>tr]:last:border-b-0", className),
|
|
8581
|
+
...props
|
|
8582
|
+
}
|
|
8583
|
+
)
|
|
8584
|
+
);
|
|
8585
|
+
TableFooter.displayName = "TableFooter";
|
|
8586
|
+
var TableRow2 = React25__namespace.forwardRef(
|
|
8587
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
8588
|
+
"tr",
|
|
8589
|
+
{
|
|
8590
|
+
ref,
|
|
8591
|
+
className: cn(
|
|
8592
|
+
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
|
8593
|
+
className
|
|
8594
|
+
),
|
|
8595
|
+
...props
|
|
8596
|
+
}
|
|
8597
|
+
)
|
|
8598
|
+
);
|
|
8599
|
+
TableRow2.displayName = "TableRow";
|
|
8600
|
+
var TableHead = React25__namespace.forwardRef(
|
|
8601
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
8602
|
+
"th",
|
|
8603
|
+
{
|
|
8604
|
+
ref,
|
|
8605
|
+
className: cn(
|
|
8606
|
+
"h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
|
|
8607
|
+
className
|
|
8608
|
+
),
|
|
8609
|
+
...props
|
|
8610
|
+
}
|
|
8611
|
+
)
|
|
8612
|
+
);
|
|
8613
|
+
TableHead.displayName = "TableHead";
|
|
8614
|
+
var TableCell2 = React25__namespace.forwardRef(
|
|
8615
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
8616
|
+
"td",
|
|
8617
|
+
{
|
|
8618
|
+
ref,
|
|
8619
|
+
className: cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className),
|
|
8620
|
+
...props
|
|
8621
|
+
}
|
|
8622
|
+
)
|
|
8623
|
+
);
|
|
8624
|
+
TableCell2.displayName = "TableCell";
|
|
8625
|
+
var TableCaption = React25__namespace.forwardRef(
|
|
8626
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
8627
|
+
"caption",
|
|
8628
|
+
{
|
|
8629
|
+
ref,
|
|
8630
|
+
className: cn("mt-4 text-sm text-muted-foreground", className),
|
|
8631
|
+
...props
|
|
8632
|
+
}
|
|
8633
|
+
)
|
|
8634
|
+
);
|
|
8635
|
+
TableCaption.displayName = "TableCaption";
|
|
8636
|
+
function TableMobileCards(props) {
|
|
8637
|
+
const { columns, rows, getRowKey, onRowClick, renderCell: renderCell2 } = props;
|
|
8638
|
+
const [titleCol, ...restCols] = columns;
|
|
8639
|
+
if (!titleCol) return null;
|
|
8640
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_hazo_ui_table_mobile_cards flex flex-col gap-3", children: rows.map((row, i) => {
|
|
8641
|
+
const interactionProps = onRowClick ? {
|
|
8642
|
+
role: "button",
|
|
8643
|
+
tabIndex: 0,
|
|
8644
|
+
className: "cls_hazo_ui_table_mobile_card_clickable cursor-pointer",
|
|
8645
|
+
onClick: () => onRowClick(row, i),
|
|
8646
|
+
onKeyDown: (e) => {
|
|
8647
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
8648
|
+
e.preventDefault();
|
|
8649
|
+
onRowClick(row, i);
|
|
8650
|
+
}
|
|
8651
|
+
}
|
|
8652
|
+
} : {};
|
|
8653
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8654
|
+
Card,
|
|
8655
|
+
{
|
|
8656
|
+
...interactionProps,
|
|
8657
|
+
children: [
|
|
8658
|
+
/* @__PURE__ */ jsxRuntime.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntime.jsx(CardTitle, { className: "text-base", children: renderCell2(titleCol, row, i) }) }),
|
|
8659
|
+
/* @__PURE__ */ jsxRuntime.jsx(CardContent, { className: "pt-0 space-y-1.5", children: restCols.map((c) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8660
|
+
"div",
|
|
8661
|
+
{
|
|
8662
|
+
className: cn(
|
|
8663
|
+
"cls_hazo_ui_table_mobile_row flex items-center justify-between gap-3 text-sm"
|
|
8664
|
+
),
|
|
8665
|
+
children: [
|
|
8666
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cls_hazo_ui_table_mobile_label text-muted-foreground", children: c.label }),
|
|
8667
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("cls_hazo_ui_table_mobile_value", c.className), children: renderCell2(c, row, i) })
|
|
8668
|
+
]
|
|
8669
|
+
},
|
|
8670
|
+
c.key
|
|
8671
|
+
)) })
|
|
8672
|
+
]
|
|
8673
|
+
},
|
|
8674
|
+
getRowKey ? getRowKey(row, i) : i
|
|
8675
|
+
);
|
|
8676
|
+
}) });
|
|
8677
|
+
}
|
|
8678
|
+
var DEFAULT_DEBOUNCE_MS = 200;
|
|
8679
|
+
function useTableState(props) {
|
|
8680
|
+
const [sortInternal, setSortInternal] = React25.useState(
|
|
8681
|
+
() => normalizeSortProp(props.defaultSort)
|
|
8682
|
+
);
|
|
8683
|
+
const isSortControlled = props.sort !== void 0;
|
|
8684
|
+
const sort = isSortControlled ? normalizeSortProp(props.sort) : sortInternal;
|
|
8685
|
+
const setSort = React25.useCallback(
|
|
8686
|
+
(next) => {
|
|
8687
|
+
if (!isSortControlled) setSortInternal(next);
|
|
8688
|
+
props.onSortChange?.(next);
|
|
8689
|
+
},
|
|
8690
|
+
[isSortControlled, props.onSortChange]
|
|
8691
|
+
);
|
|
8692
|
+
const cycleHeaderSort = React25.useCallback(
|
|
8693
|
+
(key, append) => {
|
|
8694
|
+
const next = append ? cycleAppendColumn(sort, key) : cycleSingleColumn(sort, key);
|
|
8695
|
+
setSort(next);
|
|
8696
|
+
},
|
|
8697
|
+
[sort, setSort]
|
|
8698
|
+
);
|
|
8699
|
+
const [filterInternal, setFilterInternal] = React25.useState(
|
|
8700
|
+
() => props.defaultFilter ?? {}
|
|
8701
|
+
);
|
|
8702
|
+
const isFilterControlled = props.filter !== void 0;
|
|
8703
|
+
const filter = isFilterControlled ? props.filter : filterInternal;
|
|
8704
|
+
const setFilter = React25.useCallback(
|
|
8705
|
+
(next) => {
|
|
8706
|
+
if (!isFilterControlled) setFilterInternal(next);
|
|
8707
|
+
props.onFilterChange?.(next);
|
|
8708
|
+
},
|
|
8709
|
+
[isFilterControlled, props.onFilterChange]
|
|
8710
|
+
);
|
|
8711
|
+
const [searchDraft, setSearchDraft] = React25.useState(
|
|
8712
|
+
filter.search ?? ""
|
|
8713
|
+
);
|
|
8714
|
+
const debounceMs = props.searchDebounceMs ?? DEFAULT_DEBOUNCE_MS;
|
|
8715
|
+
React25.useEffect(() => {
|
|
8716
|
+
const handle = setTimeout(() => {
|
|
8717
|
+
if (searchDraft === (filter.search ?? "")) return;
|
|
8718
|
+
setFilter({ ...filter, search: searchDraft || void 0 });
|
|
8719
|
+
}, debounceMs);
|
|
8720
|
+
return () => clearTimeout(handle);
|
|
8721
|
+
}, [searchDraft, debounceMs]);
|
|
8722
|
+
const setSearch = React25.useCallback((s) => setSearchDraft(s), []);
|
|
8723
|
+
const [pageInternal, setPageInternal] = React25.useState(
|
|
8724
|
+
() => props.defaultPage ?? 0
|
|
8725
|
+
);
|
|
8726
|
+
const isPageControlled = props.page !== void 0;
|
|
8727
|
+
const page = isPageControlled ? props.page : pageInternal;
|
|
8728
|
+
const setPage = React25.useCallback(
|
|
8729
|
+
(next) => {
|
|
8730
|
+
if (!isPageControlled) setPageInternal(next);
|
|
8731
|
+
props.onPageChange?.(next);
|
|
8732
|
+
},
|
|
8733
|
+
[isPageControlled, props.onPageChange]
|
|
8734
|
+
);
|
|
8735
|
+
const prevSortKey = React25.useRef(serializeSort(sort));
|
|
8736
|
+
const prevFilterKey = React25.useRef(serializeFilter(filter));
|
|
8737
|
+
React25.useEffect(() => {
|
|
8738
|
+
const sk = serializeSort(sort);
|
|
8739
|
+
const fk = serializeFilter(filter);
|
|
8740
|
+
if (sk !== prevSortKey.current || fk !== prevFilterKey.current) {
|
|
8741
|
+
if (!isPageControlled) setPageInternal(0);
|
|
8742
|
+
prevSortKey.current = sk;
|
|
8743
|
+
prevFilterKey.current = fk;
|
|
8744
|
+
}
|
|
8745
|
+
}, [sort, filter, isPageControlled]);
|
|
8746
|
+
const pageSize = props.pagination && typeof props.pagination === "object" ? props.pagination.pageSize : 0;
|
|
8747
|
+
const isServerMode = typeof props.onLoad === "function";
|
|
8748
|
+
const filtered = React25.useMemo(
|
|
8749
|
+
() => isServerMode ? props.rows : applyFilter(props.rows, filter, props.columns),
|
|
8750
|
+
[props.rows, filter, props.columns, isServerMode]
|
|
8751
|
+
);
|
|
8752
|
+
const sorted = React25.useMemo(
|
|
8753
|
+
() => isServerMode ? filtered : applySort(filtered, sort),
|
|
8754
|
+
[filtered, sort, isServerMode]
|
|
8755
|
+
);
|
|
8756
|
+
const pagedInMemory = React25.useMemo(() => {
|
|
8757
|
+
if (isServerMode || pageSize <= 0) return sorted;
|
|
8758
|
+
const start = page * pageSize;
|
|
8759
|
+
return sorted.slice(start, start + pageSize);
|
|
8760
|
+
}, [sorted, page, pageSize, isServerMode]);
|
|
8761
|
+
const [serverRows, setServerRows] = React25.useState([]);
|
|
8762
|
+
const [serverTotal, setServerTotal] = React25.useState(0);
|
|
8763
|
+
const [serverError, setServerError] = React25.useState(null);
|
|
8764
|
+
const reqIdRef = React25.useRef(0);
|
|
8765
|
+
React25.useEffect(() => {
|
|
8766
|
+
if (!isServerMode) return;
|
|
8767
|
+
const myId = ++reqIdRef.current;
|
|
8768
|
+
let cancelled = false;
|
|
8769
|
+
setServerError(null);
|
|
8770
|
+
Promise.resolve(
|
|
8771
|
+
props.onLoad({ page, sort, filter })
|
|
8772
|
+
).then((res) => {
|
|
8773
|
+
if (cancelled || myId !== reqIdRef.current) return;
|
|
8774
|
+
setServerRows(res.rows);
|
|
8775
|
+
setServerTotal(res.total);
|
|
8776
|
+
}).catch((err) => {
|
|
8777
|
+
if (cancelled || myId !== reqIdRef.current) return;
|
|
8778
|
+
console.warn("[HazoUiTable] onLoad rejected:", err);
|
|
8779
|
+
setServerRows([]);
|
|
8780
|
+
setServerTotal(0);
|
|
8781
|
+
setServerError(err ?? new Error("onLoad rejected"));
|
|
8782
|
+
});
|
|
8783
|
+
return () => {
|
|
8784
|
+
cancelled = true;
|
|
8785
|
+
};
|
|
8786
|
+
}, [isServerMode, page, sort, filter, props.onLoad]);
|
|
8787
|
+
const displayed = isServerMode ? serverRows : pagedInMemory;
|
|
8788
|
+
const totalAfterFilter = isServerMode ? serverTotal : filtered.length;
|
|
8789
|
+
return {
|
|
8790
|
+
sort,
|
|
8791
|
+
setSort,
|
|
8792
|
+
cycleHeaderSort,
|
|
8793
|
+
filter,
|
|
8794
|
+
setFilter,
|
|
8795
|
+
setSearch,
|
|
8796
|
+
page,
|
|
8797
|
+
setPage,
|
|
8798
|
+
displayed,
|
|
8799
|
+
totalAfterFilter,
|
|
8800
|
+
pageSize,
|
|
8801
|
+
serverError: isServerMode ? serverError : null
|
|
8802
|
+
};
|
|
8803
|
+
}
|
|
8804
|
+
function normalizeSortProp(p) {
|
|
8805
|
+
if (!p) return [];
|
|
8806
|
+
if (Array.isArray(p)) return p;
|
|
8807
|
+
return [p];
|
|
8808
|
+
}
|
|
8809
|
+
function cycleSingleColumn(current, key) {
|
|
8810
|
+
if (current.length !== 1) return [{ key, dir: "asc" }];
|
|
8811
|
+
const only = current[0];
|
|
8812
|
+
if (only.key !== key) return [{ key, dir: "asc" }];
|
|
8813
|
+
if (only.dir === "asc") return [{ key, dir: "desc" }];
|
|
8814
|
+
return [];
|
|
8815
|
+
}
|
|
8816
|
+
function cycleAppendColumn(current, key) {
|
|
8817
|
+
const idx = current.findIndex((s) => s.key === key);
|
|
8818
|
+
if (idx === -1) return [...current, { key, dir: "asc" }];
|
|
8819
|
+
const entry = current[idx];
|
|
8820
|
+
if (entry.dir === "asc") {
|
|
8821
|
+
const next = current.slice();
|
|
8822
|
+
next[idx] = { key, dir: "desc" };
|
|
8823
|
+
return next;
|
|
8824
|
+
}
|
|
8825
|
+
return current.filter((_, i) => i !== idx);
|
|
8826
|
+
}
|
|
8827
|
+
function applyFilter(rows, filter, columns) {
|
|
8828
|
+
let result = rows;
|
|
8829
|
+
if (filter.fields && filter.fields.length > 0) {
|
|
8830
|
+
result = result.filter(
|
|
8831
|
+
(row) => filter.fields.every((f) => matchesFieldFilter(row, f, columns))
|
|
8832
|
+
);
|
|
8833
|
+
}
|
|
8834
|
+
const needle = (filter.search ?? "").trim().toLowerCase();
|
|
8835
|
+
if (needle.length > 0) {
|
|
8836
|
+
const searchKeys = columns.filter(isSearchable).map((c) => c.key);
|
|
8837
|
+
if (searchKeys.length > 0) {
|
|
8838
|
+
result = result.filter(
|
|
8839
|
+
(row) => searchKeys.some(
|
|
8840
|
+
(k) => String(row[k] ?? "").toLowerCase().includes(needle)
|
|
8841
|
+
)
|
|
8842
|
+
);
|
|
8843
|
+
}
|
|
8844
|
+
}
|
|
8845
|
+
return result;
|
|
8846
|
+
}
|
|
8847
|
+
function isSearchable(c) {
|
|
8848
|
+
if (c.searchable !== void 0) return c.searchable;
|
|
8849
|
+
switch (c.formatter) {
|
|
8850
|
+
case "number":
|
|
8851
|
+
case "currency":
|
|
8852
|
+
case "percent":
|
|
8853
|
+
case "date":
|
|
8854
|
+
return false;
|
|
8855
|
+
default:
|
|
8856
|
+
return true;
|
|
8857
|
+
}
|
|
8858
|
+
}
|
|
8859
|
+
function matchesFieldFilter(row, f, columns) {
|
|
8860
|
+
const col = columns.find((c) => c.key === f.field);
|
|
8861
|
+
if (!col || !col.filterType) return true;
|
|
8862
|
+
const value = row[f.field];
|
|
8863
|
+
const op = f.operator || "equals";
|
|
8864
|
+
switch (col.filterType) {
|
|
8865
|
+
case "text": {
|
|
8866
|
+
if (f.value === void 0 || f.value === "") return true;
|
|
8867
|
+
return String(value ?? "").toLowerCase().includes(String(f.value).toLowerCase());
|
|
8868
|
+
}
|
|
8869
|
+
case "number": {
|
|
8870
|
+
const v = Number(value);
|
|
8871
|
+
const fv = Number(f.value);
|
|
8872
|
+
if (Number.isNaN(v) || Number.isNaN(fv)) return false;
|
|
8873
|
+
return numberOp(v, fv, op);
|
|
8874
|
+
}
|
|
8875
|
+
case "date": {
|
|
8876
|
+
const v = value instanceof Date ? value : new Date(value);
|
|
8877
|
+
const fv = f.value instanceof Date ? f.value : new Date(f.value);
|
|
8878
|
+
if (Number.isNaN(v.getTime()) || Number.isNaN(fv.getTime())) return false;
|
|
8879
|
+
const ta = new Date(v).setHours(0, 0, 0, 0);
|
|
8880
|
+
const tb = new Date(fv).setHours(0, 0, 0, 0);
|
|
8881
|
+
return numberOp(ta, tb, op);
|
|
8882
|
+
}
|
|
8883
|
+
case "combobox":
|
|
8884
|
+
return String(value) === String(f.value);
|
|
8885
|
+
case "boolean":
|
|
8886
|
+
return Boolean(value) === Boolean(f.value);
|
|
8887
|
+
default:
|
|
8888
|
+
return true;
|
|
8889
|
+
}
|
|
8890
|
+
}
|
|
8891
|
+
function numberOp(a, b, op) {
|
|
8892
|
+
switch (op) {
|
|
8893
|
+
case "equals":
|
|
8894
|
+
return a === b;
|
|
8895
|
+
case "not_equals":
|
|
8896
|
+
return a !== b;
|
|
8897
|
+
case "greater_than":
|
|
8898
|
+
return a > b;
|
|
8899
|
+
case "less_than":
|
|
8900
|
+
return a < b;
|
|
8901
|
+
case "greater_equal":
|
|
8902
|
+
return a >= b;
|
|
8903
|
+
case "less_equal":
|
|
8904
|
+
return a <= b;
|
|
8905
|
+
default:
|
|
8906
|
+
return true;
|
|
8907
|
+
}
|
|
8908
|
+
}
|
|
8909
|
+
function applySort(rows, sort) {
|
|
8910
|
+
if (sort.length === 0) return rows;
|
|
8911
|
+
return [...rows].map((row, idx) => ({ row, idx })).sort((a, b) => {
|
|
8912
|
+
for (const entry of sort) {
|
|
8913
|
+
const va = a.row[entry.key];
|
|
8914
|
+
const vb = b.row[entry.key];
|
|
8915
|
+
const cmp = compareValues(va, vb);
|
|
8916
|
+
if (cmp !== 0) return entry.dir === "asc" ? cmp : -cmp;
|
|
8917
|
+
}
|
|
8918
|
+
return a.idx - b.idx;
|
|
8919
|
+
}).map((x) => x.row);
|
|
8920
|
+
}
|
|
8921
|
+
function compareValues(a, b) {
|
|
8922
|
+
if (a == null && b == null) return 0;
|
|
8923
|
+
if (a == null) return 1;
|
|
8924
|
+
if (b == null) return -1;
|
|
8925
|
+
if (a instanceof Date && b instanceof Date)
|
|
8926
|
+
return a.getTime() - b.getTime();
|
|
8927
|
+
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
8928
|
+
return String(a).localeCompare(String(b));
|
|
8929
|
+
}
|
|
8930
|
+
function serializeSort(sort) {
|
|
8931
|
+
return sort.map((s) => `${s.key}:${s.dir}`).join(",");
|
|
8932
|
+
}
|
|
8933
|
+
function serializeFilter(filter) {
|
|
8934
|
+
const fields = (filter.fields ?? []).map((f) => `${f.field}:${f.operator ?? ""}:${String(f.value)}`).join(",");
|
|
8935
|
+
return `${filter.search ?? ""}|${fields}`;
|
|
8936
|
+
}
|
|
8937
|
+
function HazoUiTable(props) {
|
|
8938
|
+
const state = useTableState(props);
|
|
8939
|
+
const { columns, rows, getRowKey, className, caption } = props;
|
|
8940
|
+
const mobileBreakpoint = props.mobileBreakpoint ?? 768;
|
|
8941
|
+
const mobileEnabled = props.mobileCardFallback !== false;
|
|
8942
|
+
const isNarrow = useMediaQuery(`(max-width: ${mobileBreakpoint - 1}px)`);
|
|
8943
|
+
const renderAsCards = mobileEnabled && isNarrow;
|
|
8944
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("cls_hazo_ui_table_root space-y-3", className), children: [
|
|
8945
|
+
(props.enableSearch || props.enableSortDialog || props.enableFilterDialog) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8946
|
+
Toolbar2,
|
|
8947
|
+
{
|
|
8948
|
+
columns,
|
|
8949
|
+
sort: state.sort,
|
|
8950
|
+
onSortChange: state.setSort,
|
|
8951
|
+
filter: state.filter,
|
|
8952
|
+
onSearchChange: state.setSearch,
|
|
8953
|
+
onFilterFieldsChange: (fields) => state.setFilter({ ...state.filter, fields }),
|
|
8954
|
+
enableSearch: props.enableSearch,
|
|
8955
|
+
enableSortDialog: props.enableSortDialog,
|
|
8956
|
+
enableFilterDialog: props.enableFilterDialog,
|
|
8957
|
+
searchPlaceholder: props.searchPlaceholder
|
|
8958
|
+
}
|
|
8959
|
+
),
|
|
8960
|
+
renderAsCards ? props.loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_hazo_ui_table_mobile_loading flex flex-col gap-3", children: Array.from({ length: Math.max(state.pageSize || 5, 3) }).map(
|
|
8961
|
+
(_, i) => /* @__PURE__ */ jsxRuntime.jsxs(Card, { children: [
|
|
8962
|
+
/* @__PURE__ */ jsxRuntime.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntime.jsx(SkeletonBar, { className: "w-2/3" }) }),
|
|
8963
|
+
/* @__PURE__ */ jsxRuntime.jsxs(CardContent, { className: "pt-0 space-y-2", children: [
|
|
8964
|
+
/* @__PURE__ */ jsxRuntime.jsx(SkeletonBar, { className: "w-full" }),
|
|
8965
|
+
/* @__PURE__ */ jsxRuntime.jsx(SkeletonBar, { className: "w-1/2" })
|
|
8966
|
+
] })
|
|
8967
|
+
] }, `mloader-${i}`)
|
|
8968
|
+
) }) : state.serverError != null ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_hazo_ui_table_mobile_error py-6", children: renderErrorState(props.error, state.serverError) }) : state.displayed.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_hazo_ui_table_mobile_empty py-6", children: noActiveFilters(state.filter) && rows.length === 0 ? typeof props.empty === "string" || props.empty === void 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
8969
|
+
EmptyState,
|
|
8970
|
+
{
|
|
8971
|
+
title: typeof props.empty === "string" && props.empty || "No items"
|
|
8972
|
+
}
|
|
8973
|
+
) : props.empty : typeof props.noResults === "string" || props.noResults === void 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
8974
|
+
EmptyState,
|
|
8975
|
+
{
|
|
8976
|
+
title: typeof props.noResults === "string" && props.noResults || "No matches \u2014 adjust your filters"
|
|
8977
|
+
}
|
|
8978
|
+
) : props.noResults }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
8979
|
+
TableMobileCards,
|
|
8980
|
+
{
|
|
8981
|
+
columns,
|
|
8982
|
+
rows: state.displayed,
|
|
8983
|
+
getRowKey,
|
|
8984
|
+
onRowClick: props.onRowClick,
|
|
8985
|
+
renderCell
|
|
8986
|
+
}
|
|
8987
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(Table2, { children: [
|
|
8988
|
+
caption && /* @__PURE__ */ jsxRuntime.jsx(TableCaption, { children: caption }),
|
|
8989
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHeader2, { children: /* @__PURE__ */ jsxRuntime.jsx(TableRow2, { children: columns.map((c) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
8990
|
+
TableHead,
|
|
8991
|
+
{
|
|
8992
|
+
className: cn(headerAlignClass(c), c.headerClassName),
|
|
8993
|
+
"aria-sort": ariaSortFor(state.sort, c.key),
|
|
8994
|
+
children: c.sortable ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8995
|
+
"button",
|
|
8996
|
+
{
|
|
8997
|
+
type: "button",
|
|
8998
|
+
onClick: (e) => state.cycleHeaderSort(c.key, e.shiftKey),
|
|
8999
|
+
title: "Click to sort; shift-click to append a secondary sort",
|
|
9000
|
+
className: "cls_hazo_ui_table_sort_btn inline-flex items-center gap-1 hover:text-foreground",
|
|
9001
|
+
children: [
|
|
9002
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: c.label }),
|
|
9003
|
+
/* @__PURE__ */ jsxRuntime.jsx(SortIndicator, { sort: state.sort, columnKey: c.key })
|
|
9004
|
+
]
|
|
9005
|
+
}
|
|
9006
|
+
) : c.label
|
|
9007
|
+
},
|
|
9008
|
+
c.key
|
|
9009
|
+
)) }) }),
|
|
9010
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: props.loading ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
9011
|
+
LoadingRows,
|
|
9012
|
+
{
|
|
9013
|
+
columns,
|
|
9014
|
+
count: Math.max(state.pageSize || 5, 3)
|
|
9015
|
+
}
|
|
9016
|
+
) : state.serverError != null ? /* @__PURE__ */ jsxRuntime.jsx(TableRow2, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9017
|
+
TableCell2,
|
|
9018
|
+
{
|
|
9019
|
+
colSpan: columns.length,
|
|
9020
|
+
className: "cls_hazo_ui_table_error_cell p-0",
|
|
9021
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_hazo_ui_table_error_wrap py-6", children: renderErrorState(props.error, state.serverError) })
|
|
9022
|
+
}
|
|
9023
|
+
) }) : state.displayed.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(TableRow2, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9024
|
+
TableCell2,
|
|
9025
|
+
{
|
|
9026
|
+
colSpan: columns.length,
|
|
9027
|
+
className: "cls_hazo_ui_table_empty_cell p-0",
|
|
9028
|
+
children: noActiveFilters(state.filter) && rows.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_hazo_ui_table_empty_wrap py-6", children: typeof props.empty === "string" || props.empty === void 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
9029
|
+
EmptyState,
|
|
9030
|
+
{
|
|
9031
|
+
title: typeof props.empty === "string" && props.empty || "No items"
|
|
9032
|
+
}
|
|
9033
|
+
) : props.empty }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_hazo_ui_table_no_results_wrap py-6", children: typeof props.noResults === "string" || props.noResults === void 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
9034
|
+
EmptyState,
|
|
9035
|
+
{
|
|
9036
|
+
title: typeof props.noResults === "string" && props.noResults || "No matches \u2014 adjust your filters"
|
|
9037
|
+
}
|
|
9038
|
+
) : props.noResults })
|
|
9039
|
+
}
|
|
9040
|
+
) }) : state.displayed.map((row, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
9041
|
+
TableRow2,
|
|
9042
|
+
{
|
|
9043
|
+
...buildRowProps(row, i, props.onRowClick),
|
|
9044
|
+
children: columns.map((c) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
9045
|
+
TableCell2,
|
|
9046
|
+
{
|
|
9047
|
+
className: cn(cellAlignClass(c), c.className),
|
|
9048
|
+
children: renderCell(c, row, i)
|
|
9049
|
+
},
|
|
9050
|
+
c.key
|
|
9051
|
+
))
|
|
9052
|
+
},
|
|
9053
|
+
getRowKey ? getRowKey(row, i) : i
|
|
9054
|
+
)) })
|
|
9055
|
+
] }),
|
|
9056
|
+
state.pageSize > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9057
|
+
PaginationFooter,
|
|
9058
|
+
{
|
|
9059
|
+
page: state.page,
|
|
9060
|
+
pageSize: state.pageSize,
|
|
9061
|
+
total: state.totalAfterFilter,
|
|
9062
|
+
onPageChange: state.setPage
|
|
9063
|
+
}
|
|
9064
|
+
)
|
|
9065
|
+
] });
|
|
9066
|
+
}
|
|
9067
|
+
function renderCell(c, row, i) {
|
|
9068
|
+
if (c.cell) return c.cell(row, i);
|
|
9069
|
+
const raw = row[c.key];
|
|
9070
|
+
return formatValue(raw, c.formatter, c.currency, c.locale);
|
|
9071
|
+
}
|
|
9072
|
+
var DEFAULT_NUMBER_LOCALE = "en-US";
|
|
9073
|
+
function formatValue(value, formatter, currency, locale) {
|
|
9074
|
+
if (value === null || value === void 0 || value === "") return "\u2014";
|
|
9075
|
+
const lc = locale ?? DEFAULT_NUMBER_LOCALE;
|
|
9076
|
+
switch (formatter) {
|
|
9077
|
+
case "date": {
|
|
9078
|
+
const d = value instanceof Date ? value : new Date(value);
|
|
9079
|
+
if (Number.isNaN(d.getTime())) return String(value);
|
|
9080
|
+
return dateFns.format(d, "MMM d, yyyy");
|
|
9081
|
+
}
|
|
9082
|
+
case "number":
|
|
9083
|
+
return new Intl.NumberFormat(lc).format(Number(value));
|
|
9084
|
+
case "currency":
|
|
9085
|
+
return new Intl.NumberFormat(lc, {
|
|
9086
|
+
style: "currency",
|
|
9087
|
+
currency: currency ?? "USD"
|
|
9088
|
+
}).format(Number(value));
|
|
9089
|
+
case "percent":
|
|
9090
|
+
return new Intl.NumberFormat(lc, {
|
|
9091
|
+
style: "percent",
|
|
9092
|
+
maximumFractionDigits: 2
|
|
9093
|
+
}).format(Number(value));
|
|
9094
|
+
default:
|
|
9095
|
+
return String(value);
|
|
9096
|
+
}
|
|
9097
|
+
}
|
|
9098
|
+
function headerAlignClass(c) {
|
|
9099
|
+
switch (c.align) {
|
|
9100
|
+
case "right":
|
|
9101
|
+
return "text-right";
|
|
9102
|
+
case "center":
|
|
9103
|
+
return "text-center";
|
|
9104
|
+
default:
|
|
9105
|
+
return "text-left";
|
|
9106
|
+
}
|
|
9107
|
+
}
|
|
9108
|
+
function cellAlignClass(c) {
|
|
9109
|
+
switch (c.align) {
|
|
9110
|
+
case "right":
|
|
9111
|
+
return "text-right";
|
|
9112
|
+
case "center":
|
|
9113
|
+
return "text-center";
|
|
9114
|
+
default:
|
|
9115
|
+
return "";
|
|
9116
|
+
}
|
|
9117
|
+
}
|
|
9118
|
+
function ariaSortFor(sort, key) {
|
|
9119
|
+
const entry = sort.find((s) => s.key === key);
|
|
9120
|
+
if (!entry) return "none";
|
|
9121
|
+
return entry.dir === "asc" ? "ascending" : "descending";
|
|
9122
|
+
}
|
|
9123
|
+
function deriveSortFields(columns) {
|
|
9124
|
+
return columns.filter((c) => c.sortable).map((c) => ({ value: c.key, label: c.label }));
|
|
9125
|
+
}
|
|
9126
|
+
function deriveFilterFields(columns) {
|
|
9127
|
+
return columns.filter((c) => c.filterType).map((c) => ({
|
|
9128
|
+
value: c.key,
|
|
9129
|
+
label: c.label,
|
|
9130
|
+
type: c.filterType,
|
|
9131
|
+
...c.filterConfig ?? {}
|
|
9132
|
+
}));
|
|
9133
|
+
}
|
|
9134
|
+
function sortToDialogConfig(sort) {
|
|
9135
|
+
return sort.map((s) => ({ field: s.key, direction: s.dir }));
|
|
9136
|
+
}
|
|
9137
|
+
function dialogConfigToSort(configs) {
|
|
9138
|
+
return configs.map((c) => ({ key: c.field, dir: c.direction }));
|
|
9139
|
+
}
|
|
9140
|
+
function PaginationFooter({
|
|
9141
|
+
page,
|
|
9142
|
+
pageSize,
|
|
9143
|
+
total,
|
|
9144
|
+
onPageChange
|
|
9145
|
+
}) {
|
|
9146
|
+
const start = total === 0 ? 0 : page * pageSize + 1;
|
|
9147
|
+
const end = Math.min((page + 1) * pageSize, total);
|
|
9148
|
+
const lastPage = Math.max(0, Math.ceil(total / pageSize) - 1);
|
|
9149
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_hazo_ui_table_pagination flex items-center justify-between gap-3 pt-2 text-sm", children: [
|
|
9150
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "cls_hazo_ui_table_page_counter text-muted-foreground", children: [
|
|
9151
|
+
"Showing ",
|
|
9152
|
+
start,
|
|
9153
|
+
"\u2013",
|
|
9154
|
+
end,
|
|
9155
|
+
" of ",
|
|
9156
|
+
total
|
|
9157
|
+
] }),
|
|
9158
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_hazo_ui_table_page_buttons flex items-center gap-2", children: [
|
|
9159
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9160
|
+
Button,
|
|
9161
|
+
{
|
|
9162
|
+
variant: "outline",
|
|
9163
|
+
size: "sm",
|
|
9164
|
+
onClick: () => onPageChange(Math.max(0, page - 1)),
|
|
9165
|
+
disabled: page === 0,
|
|
9166
|
+
"aria-label": "Previous page",
|
|
9167
|
+
children: "\u2039 Prev"
|
|
9168
|
+
}
|
|
9169
|
+
),
|
|
9170
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9171
|
+
Button,
|
|
9172
|
+
{
|
|
9173
|
+
variant: "outline",
|
|
9174
|
+
size: "sm",
|
|
9175
|
+
onClick: () => onPageChange(Math.min(lastPage, page + 1)),
|
|
9176
|
+
disabled: page >= lastPage,
|
|
9177
|
+
"aria-label": "Next page",
|
|
9178
|
+
children: "Next \u203A"
|
|
9179
|
+
}
|
|
9180
|
+
)
|
|
9181
|
+
] })
|
|
9182
|
+
] });
|
|
9183
|
+
}
|
|
9184
|
+
function Toolbar2(props) {
|
|
9185
|
+
const {
|
|
9186
|
+
columns,
|
|
9187
|
+
sort,
|
|
9188
|
+
onSortChange,
|
|
9189
|
+
filter,
|
|
9190
|
+
onSearchChange,
|
|
9191
|
+
onFilterFieldsChange,
|
|
9192
|
+
enableSearch,
|
|
9193
|
+
enableSortDialog,
|
|
9194
|
+
enableFilterDialog,
|
|
9195
|
+
searchPlaceholder
|
|
9196
|
+
} = props;
|
|
9197
|
+
const sortFields = React25__namespace.useMemo(
|
|
9198
|
+
() => deriveSortFields(columns),
|
|
9199
|
+
[columns]
|
|
9200
|
+
);
|
|
9201
|
+
const filterFields = React25__namespace.useMemo(
|
|
9202
|
+
() => deriveFilterFields(columns),
|
|
9203
|
+
[columns]
|
|
9204
|
+
);
|
|
9205
|
+
const [searchValue, setSearchValue] = React25__namespace.useState(
|
|
9206
|
+
filter.search ?? ""
|
|
9207
|
+
);
|
|
9208
|
+
React25__namespace.useEffect(() => {
|
|
9209
|
+
setSearchValue(filter.search ?? "");
|
|
9210
|
+
}, [filter.search]);
|
|
9211
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_hazo_ui_table_toolbar flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between", children: [
|
|
9212
|
+
enableSearch ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
9213
|
+
Input,
|
|
9214
|
+
{
|
|
9215
|
+
type: "text",
|
|
9216
|
+
value: searchValue,
|
|
9217
|
+
onChange: (e) => {
|
|
9218
|
+
const v = e.target.value;
|
|
9219
|
+
setSearchValue(v);
|
|
9220
|
+
onSearchChange(v);
|
|
9221
|
+
},
|
|
9222
|
+
placeholder: searchPlaceholder ?? "Search...",
|
|
9223
|
+
className: "cls_hazo_ui_table_search w-full sm:max-w-xs"
|
|
9224
|
+
}
|
|
9225
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", {}),
|
|
9226
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_hazo_ui_table_toolbar_right flex items-center gap-2", children: [
|
|
9227
|
+
enableFilterDialog && filterFields.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9228
|
+
HazoUiMultiFilterDialog,
|
|
9229
|
+
{
|
|
9230
|
+
availableFields: filterFields,
|
|
9231
|
+
initialFilters: filter.fields ?? [],
|
|
9232
|
+
onFilterChange: onFilterFieldsChange
|
|
9233
|
+
}
|
|
9234
|
+
),
|
|
9235
|
+
enableSortDialog && sortFields.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9236
|
+
HazoUiMultiSortDialog,
|
|
9237
|
+
{
|
|
9238
|
+
availableFields: sortFields,
|
|
9239
|
+
initialSortFields: sortToDialogConfig(sort),
|
|
9240
|
+
onSortChange: (configs) => onSortChange(dialogConfigToSort(configs))
|
|
9241
|
+
}
|
|
9242
|
+
)
|
|
9243
|
+
] })
|
|
9244
|
+
] });
|
|
9245
|
+
}
|
|
9246
|
+
function LoadingRows({
|
|
9247
|
+
columns,
|
|
9248
|
+
count
|
|
9249
|
+
}) {
|
|
9250
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: Array.from({ length: count }).map((_, rowIdx) => /* @__PURE__ */ jsxRuntime.jsx(TableRow2, { children: columns.map((c) => /* @__PURE__ */ jsxRuntime.jsx(TableCell2, { className: cellAlignClass(c), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9251
|
+
SkeletonBar,
|
|
9252
|
+
{
|
|
9253
|
+
className: cn(
|
|
9254
|
+
"cls_hazo_ui_table_skeleton",
|
|
9255
|
+
c.align === "right" ? "w-16 ml-auto" : "w-full"
|
|
9256
|
+
)
|
|
9257
|
+
}
|
|
9258
|
+
) }, c.key)) }, `skeleton-${rowIdx}`)) });
|
|
9259
|
+
}
|
|
9260
|
+
function noActiveFilters(filter) {
|
|
9261
|
+
return !filter.search && (!filter.fields || filter.fields.length === 0);
|
|
9262
|
+
}
|
|
9263
|
+
function renderErrorState(error, serverError) {
|
|
9264
|
+
if (typeof error === "function") return error(serverError);
|
|
9265
|
+
if (error !== void 0 && error !== null) return error;
|
|
9266
|
+
const msg = serverError instanceof Error ? serverError.message : String(serverError);
|
|
9267
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9268
|
+
EmptyState,
|
|
9269
|
+
{
|
|
9270
|
+
title: "Couldn't load data",
|
|
9271
|
+
description: msg || "The data source rejected the request."
|
|
9272
|
+
}
|
|
9273
|
+
);
|
|
9274
|
+
}
|
|
9275
|
+
function buildRowProps(row, index, onRowClick) {
|
|
9276
|
+
if (!onRowClick) return {};
|
|
9277
|
+
return {
|
|
9278
|
+
role: "button",
|
|
9279
|
+
tabIndex: 0,
|
|
9280
|
+
className: "cls_hazo_ui_table_row_clickable cursor-pointer",
|
|
9281
|
+
onClick: () => onRowClick(row, index),
|
|
9282
|
+
onKeyDown: (e) => {
|
|
9283
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
9284
|
+
e.preventDefault();
|
|
9285
|
+
onRowClick(row, index);
|
|
9286
|
+
}
|
|
9287
|
+
}
|
|
9288
|
+
};
|
|
9289
|
+
}
|
|
9290
|
+
function SortIndicator({
|
|
9291
|
+
sort,
|
|
9292
|
+
columnKey
|
|
9293
|
+
}) {
|
|
9294
|
+
const idx = sort.findIndex((s) => s.key === columnKey);
|
|
9295
|
+
if (idx === -1) {
|
|
9296
|
+
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsUpDown, { className: "cls_hazo_ui_table_sort_idle h-3.5 w-3.5 opacity-30" });
|
|
9297
|
+
}
|
|
9298
|
+
const entry = sort[idx];
|
|
9299
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "cls_hazo_ui_table_sort_active inline-flex items-center gap-0.5", children: [
|
|
9300
|
+
entry.dir === "asc" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-3.5 w-3.5" }),
|
|
9301
|
+
sort.length > 1 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] font-medium", children: idx + 1 })
|
|
9302
|
+
] });
|
|
9303
|
+
}
|
|
9304
|
+
|
|
9305
|
+
Object.defineProperty(exports, "rawToast", {
|
|
9306
|
+
enumerable: true,
|
|
9307
|
+
get: function () { return sonner.toast; }
|
|
9308
|
+
});
|
|
7313
9309
|
exports.ANIMATION_PRESETS = ANIMATION_PRESETS;
|
|
7314
9310
|
exports.Accordion = Accordion;
|
|
7315
9311
|
exports.AccordionContent = AccordionContent;
|
|
@@ -7369,6 +9365,9 @@ exports.DropdownMenuSub = DropdownMenuSub;
|
|
|
7369
9365
|
exports.DropdownMenuSubContent = DropdownMenuSubContent;
|
|
7370
9366
|
exports.DropdownMenuSubTrigger = DropdownMenuSubTrigger;
|
|
7371
9367
|
exports.DropdownMenuTrigger = DropdownMenuTrigger;
|
|
9368
|
+
exports.EmptyState = EmptyState;
|
|
9369
|
+
exports.ErrorBanner = ErrorBanner;
|
|
9370
|
+
exports.ErrorPage = ErrorPage;
|
|
7372
9371
|
exports.HazoUiConfirmDialog = HazoUiConfirmDialog;
|
|
7373
9372
|
exports.HazoUiDialog = HazoUiDialog;
|
|
7374
9373
|
exports.HazoUiDialogClose = DialogClose;
|
|
@@ -7383,20 +9382,26 @@ exports.HazoUiDialogTitle = DialogTitle;
|
|
|
7383
9382
|
exports.HazoUiDialogTrigger = DialogTrigger;
|
|
7384
9383
|
exports.HazoUiFlexInput = HazoUiFlexInput;
|
|
7385
9384
|
exports.HazoUiFlexRadio = HazoUiFlexRadio;
|
|
9385
|
+
exports.HazoUiKanban = HazoUiKanban;
|
|
9386
|
+
exports.HazoUiKanbanFilter = HazoUiKanbanFilter;
|
|
7386
9387
|
exports.HazoUiMultiFilterDialog = HazoUiMultiFilterDialog;
|
|
7387
9388
|
exports.HazoUiMultiSortDialog = HazoUiMultiSortDialog;
|
|
7388
9389
|
exports.HazoUiPillRadio = HazoUiPillRadio;
|
|
7389
9390
|
exports.HazoUiRte = HazoUiRte;
|
|
9391
|
+
exports.HazoUiTable = HazoUiTable;
|
|
7390
9392
|
exports.HazoUiTextarea = HazoUiTextarea;
|
|
7391
9393
|
exports.HazoUiTextbox = HazoUiTextbox;
|
|
9394
|
+
exports.HazoUiToaster = HazoUiToaster;
|
|
7392
9395
|
exports.HoverCard = HoverCard;
|
|
7393
9396
|
exports.HoverCardContent = HoverCardContent;
|
|
7394
9397
|
exports.HoverCardTrigger = HoverCardTrigger;
|
|
7395
9398
|
exports.Input = Input;
|
|
7396
|
-
exports.Label =
|
|
9399
|
+
exports.Label = Label3;
|
|
9400
|
+
exports.LoadingTimeout = LoadingTimeout;
|
|
7397
9401
|
exports.Popover = Popover;
|
|
7398
9402
|
exports.PopoverContent = PopoverContent;
|
|
7399
9403
|
exports.PopoverTrigger = PopoverTrigger;
|
|
9404
|
+
exports.ProgressiveImage = ProgressiveImage;
|
|
7400
9405
|
exports.RadioGroup = RadioGroup;
|
|
7401
9406
|
exports.RadioGroupItem = RadioGroupItem;
|
|
7402
9407
|
exports.ScrollArea = ScrollArea;
|
|
@@ -7418,8 +9423,21 @@ exports.ShadcnCommandGroup = CommandGroup;
|
|
|
7418
9423
|
exports.ShadcnCommandInput = CommandInput;
|
|
7419
9424
|
exports.ShadcnCommandItem = CommandItem;
|
|
7420
9425
|
exports.ShadcnCommandList = CommandList;
|
|
9426
|
+
exports.Skeleton = Skeleton;
|
|
9427
|
+
exports.SkeletonBar = SkeletonBar;
|
|
9428
|
+
exports.SkeletonCircle = SkeletonCircle;
|
|
9429
|
+
exports.SkeletonGroup = SkeletonGroup;
|
|
9430
|
+
exports.SkeletonRect = SkeletonRect;
|
|
7421
9431
|
exports.Spinner = Spinner;
|
|
7422
9432
|
exports.Switch = Switch;
|
|
9433
|
+
exports.Table = Table2;
|
|
9434
|
+
exports.TableBody = TableBody;
|
|
9435
|
+
exports.TableCaption = TableCaption;
|
|
9436
|
+
exports.TableCell = TableCell2;
|
|
9437
|
+
exports.TableFooter = TableFooter;
|
|
9438
|
+
exports.TableHead = TableHead;
|
|
9439
|
+
exports.TableHeader = TableHeader2;
|
|
9440
|
+
exports.TableRow = TableRow2;
|
|
7423
9441
|
exports.Tabs = Tabs;
|
|
7424
9442
|
exports.TabsContent = TabsContent;
|
|
7425
9443
|
exports.TabsList = TabsList;
|
|
@@ -7432,15 +9450,20 @@ exports.Tooltip = Tooltip;
|
|
|
7432
9450
|
exports.TooltipContent = TooltipContent;
|
|
7433
9451
|
exports.TooltipProvider = TooltipProvider;
|
|
7434
9452
|
exports.TooltipTrigger = TooltipTrigger;
|
|
9453
|
+
exports.applyKanbanFilter = applyKanbanFilter;
|
|
7435
9454
|
exports.buttonGroupVariants = buttonGroupVariants;
|
|
7436
9455
|
exports.create_command_suggestion_extension = create_command_suggestion_extension;
|
|
9456
|
+
exports.errorToast = errorToast;
|
|
7437
9457
|
exports.get_hazo_ui_config = get_hazo_ui_config;
|
|
7438
9458
|
exports.parse_commands_from_text = parse_commands_from_text;
|
|
7439
9459
|
exports.reset_hazo_ui_config = reset_hazo_ui_config;
|
|
7440
9460
|
exports.resolve_animation_classes = resolve_animation_classes;
|
|
7441
9461
|
exports.set_hazo_ui_config = set_hazo_ui_config;
|
|
9462
|
+
exports.successToast = successToast;
|
|
7442
9463
|
exports.text_to_tiptap_content = text_to_tiptap_content;
|
|
7443
9464
|
exports.toggleVariants = toggleVariants;
|
|
9465
|
+
exports.useErrorDisplay = useErrorDisplay;
|
|
9466
|
+
exports.useLoadingState = useLoadingState;
|
|
7444
9467
|
exports.useMediaQuery = useMediaQuery;
|
|
7445
9468
|
//# sourceMappingURL=index.cjs.map
|
|
7446
9469
|
//# sourceMappingURL=index.cjs.map
|