hazo_ui 2.11.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 +181 -0
- package/README.md +244 -0
- package/dist/index.cjs +2149 -494
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +358 -1
- package/dist/index.d.ts +358 -1
- package/dist/index.js +2102 -459
- package/dist/index.js.map +1 -1
- package/dist/styles.css +8 -0
- package/package.json +1 -1
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,6 +61,7 @@ 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');
|
|
@@ -90,12 +90,11 @@ function _interopNamespace(e) {
|
|
|
90
90
|
return Object.freeze(n);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
var
|
|
93
|
+
var React25__namespace = /*#__PURE__*/_interopNamespace(React25);
|
|
94
94
|
var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
|
|
95
95
|
var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
|
|
96
96
|
var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
|
|
97
97
|
var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
|
|
98
|
-
var SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitives);
|
|
99
98
|
var RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(RadioGroupPrimitive);
|
|
100
99
|
var FaIcons__namespace = /*#__PURE__*/_interopNamespace(FaIcons);
|
|
101
100
|
var MdIcons__namespace = /*#__PURE__*/_interopNamespace(MdIcons);
|
|
@@ -131,6 +130,7 @@ var AccordionPrimitive__namespace = /*#__PURE__*/_interopNamespace(AccordionPrim
|
|
|
131
130
|
var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
|
|
132
131
|
var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
|
|
133
132
|
var HoverCardPrimitive__namespace = /*#__PURE__*/_interopNamespace(HoverCardPrimitive);
|
|
133
|
+
var SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitives);
|
|
134
134
|
var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
|
|
135
135
|
var CollapsiblePrimitive__namespace = /*#__PURE__*/_interopNamespace(CollapsiblePrimitive);
|
|
136
136
|
var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
|
|
@@ -275,7 +275,7 @@ var variant_styles = {
|
|
|
275
275
|
color: "hsl(var(--secondary-foreground))"
|
|
276
276
|
}
|
|
277
277
|
};
|
|
278
|
-
var Button =
|
|
278
|
+
var Button = React25__namespace.forwardRef(
|
|
279
279
|
({ className, variant, size, asChild = false, style, ...props }, ref) => {
|
|
280
280
|
const Comp = asChild ? reactSlot.Slot : "button";
|
|
281
281
|
const fallback_styles = variant_styles[variant ?? "default"] ?? {};
|
|
@@ -295,7 +295,7 @@ var Dialog = DialogPrimitive__namespace.Root;
|
|
|
295
295
|
var DialogTrigger = DialogPrimitive__namespace.Trigger;
|
|
296
296
|
var DialogPortal = DialogPrimitive__namespace.Portal;
|
|
297
297
|
var DialogClose = DialogPrimitive__namespace.Close;
|
|
298
|
-
var DialogOverlay =
|
|
298
|
+
var DialogOverlay = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
299
299
|
DialogPrimitive__namespace.Overlay,
|
|
300
300
|
{
|
|
301
301
|
ref,
|
|
@@ -307,14 +307,14 @@ var DialogOverlay = React27__namespace.forwardRef(({ className, ...props }, ref)
|
|
|
307
307
|
}
|
|
308
308
|
));
|
|
309
309
|
DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
|
|
310
|
-
var DialogContent =
|
|
310
|
+
var DialogContent = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
|
|
311
311
|
/* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
|
|
312
312
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
313
313
|
DialogPrimitive__namespace.Content,
|
|
314
314
|
{
|
|
315
315
|
ref,
|
|
316
316
|
className: cn(
|
|
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
|
|
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",
|
|
318
318
|
className
|
|
319
319
|
),
|
|
320
320
|
...props,
|
|
@@ -357,7 +357,7 @@ var DialogFooter = ({
|
|
|
357
357
|
}
|
|
358
358
|
);
|
|
359
359
|
DialogFooter.displayName = "DialogFooter";
|
|
360
|
-
var DialogTitle =
|
|
360
|
+
var DialogTitle = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
361
361
|
DialogPrimitive__namespace.Title,
|
|
362
362
|
{
|
|
363
363
|
ref,
|
|
@@ -370,7 +370,7 @@ var DialogTitle = React27__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
370
370
|
}
|
|
371
371
|
));
|
|
372
372
|
DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
|
|
373
|
-
var DialogDescription =
|
|
373
|
+
var DialogDescription = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
374
374
|
DialogPrimitive__namespace.Description,
|
|
375
375
|
{
|
|
376
376
|
ref,
|
|
@@ -379,7 +379,7 @@ var DialogDescription = React27__namespace.forwardRef(({ className, ...props },
|
|
|
379
379
|
}
|
|
380
380
|
));
|
|
381
381
|
DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
|
|
382
|
-
var Command =
|
|
382
|
+
var Command = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
383
383
|
"div",
|
|
384
384
|
{
|
|
385
385
|
ref,
|
|
@@ -391,7 +391,7 @@ var Command = React27__namespace.forwardRef(({ className, ...props }, ref) => /*
|
|
|
391
391
|
}
|
|
392
392
|
));
|
|
393
393
|
Command.displayName = "Command";
|
|
394
|
-
var CommandInput =
|
|
394
|
+
var CommandInput = React25__namespace.forwardRef(({ className, onValueChange, onChange, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
395
395
|
"input",
|
|
396
396
|
{
|
|
397
397
|
ref,
|
|
@@ -407,7 +407,7 @@ var CommandInput = React27__namespace.forwardRef(({ className, onValueChange, on
|
|
|
407
407
|
}
|
|
408
408
|
));
|
|
409
409
|
CommandInput.displayName = "CommandInput";
|
|
410
|
-
var CommandList =
|
|
410
|
+
var CommandList = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
411
411
|
"div",
|
|
412
412
|
{
|
|
413
413
|
ref,
|
|
@@ -416,7 +416,7 @@ var CommandList = React27__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
416
416
|
}
|
|
417
417
|
));
|
|
418
418
|
CommandList.displayName = "CommandList";
|
|
419
|
-
var CommandEmpty =
|
|
419
|
+
var CommandEmpty = React25__namespace.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
420
420
|
"div",
|
|
421
421
|
{
|
|
422
422
|
ref,
|
|
@@ -425,7 +425,7 @@ var CommandEmpty = React27__namespace.forwardRef((props, ref) => /* @__PURE__ */
|
|
|
425
425
|
}
|
|
426
426
|
));
|
|
427
427
|
CommandEmpty.displayName = "CommandEmpty";
|
|
428
|
-
var CommandGroup =
|
|
428
|
+
var CommandGroup = React25__namespace.forwardRef(({ className, heading, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
429
429
|
"div",
|
|
430
430
|
{
|
|
431
431
|
ref,
|
|
@@ -441,7 +441,7 @@ var CommandGroup = React27__namespace.forwardRef(({ className, heading, children
|
|
|
441
441
|
}
|
|
442
442
|
));
|
|
443
443
|
CommandGroup.displayName = "CommandGroup";
|
|
444
|
-
var CommandItem =
|
|
444
|
+
var CommandItem = React25__namespace.forwardRef(({ className, onSelect, value, selected, style, ...props }, ref) => {
|
|
445
445
|
const handleClick = () => {
|
|
446
446
|
if (onSelect && value) {
|
|
447
447
|
onSelect(value);
|
|
@@ -472,7 +472,7 @@ var CommandItem = React27__namespace.forwardRef(({ className, onSelect, value, s
|
|
|
472
472
|
CommandItem.displayName = "CommandItem";
|
|
473
473
|
var Popover = PopoverPrimitive__namespace.Root;
|
|
474
474
|
var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
|
|
475
|
-
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(
|
|
476
476
|
PopoverPrimitive__namespace.Content,
|
|
477
477
|
{
|
|
478
478
|
ref,
|
|
@@ -486,7 +486,7 @@ var PopoverContent = React27__namespace.forwardRef(({ className, align = "center
|
|
|
486
486
|
}
|
|
487
487
|
) }));
|
|
488
488
|
PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
|
|
489
|
-
var Input =
|
|
489
|
+
var Input = React25__namespace.forwardRef(
|
|
490
490
|
({ className, type, ...props }, ref) => {
|
|
491
491
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
492
492
|
"input",
|
|
@@ -506,7 +506,7 @@ Input.displayName = "Input";
|
|
|
506
506
|
var Select = SelectPrimitive__namespace.Root;
|
|
507
507
|
var SelectGroup = SelectPrimitive__namespace.Group;
|
|
508
508
|
var SelectValue = SelectPrimitive__namespace.Value;
|
|
509
|
-
var SelectTrigger =
|
|
509
|
+
var SelectTrigger = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
510
510
|
SelectPrimitive__namespace.Trigger,
|
|
511
511
|
{
|
|
512
512
|
ref,
|
|
@@ -522,7 +522,7 @@ var SelectTrigger = React27__namespace.forwardRef(({ className, children, ...pro
|
|
|
522
522
|
}
|
|
523
523
|
));
|
|
524
524
|
SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
|
|
525
|
-
var SelectScrollUpButton =
|
|
525
|
+
var SelectScrollUpButton = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
526
526
|
SelectPrimitive__namespace.ScrollUpButton,
|
|
527
527
|
{
|
|
528
528
|
ref,
|
|
@@ -535,7 +535,7 @@ var SelectScrollUpButton = React27__namespace.forwardRef(({ className, ...props
|
|
|
535
535
|
}
|
|
536
536
|
));
|
|
537
537
|
SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
|
|
538
|
-
var SelectScrollDownButton =
|
|
538
|
+
var SelectScrollDownButton = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
539
539
|
SelectPrimitive__namespace.ScrollDownButton,
|
|
540
540
|
{
|
|
541
541
|
ref,
|
|
@@ -548,7 +548,7 @@ var SelectScrollDownButton = React27__namespace.forwardRef(({ className, ...prop
|
|
|
548
548
|
}
|
|
549
549
|
));
|
|
550
550
|
SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
|
|
551
|
-
var SelectContent =
|
|
551
|
+
var SelectContent = React25__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
552
552
|
SelectPrimitive__namespace.Content,
|
|
553
553
|
{
|
|
554
554
|
ref,
|
|
@@ -576,7 +576,7 @@ var SelectContent = React27__namespace.forwardRef(({ className, children, positi
|
|
|
576
576
|
}
|
|
577
577
|
) }));
|
|
578
578
|
SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
|
|
579
|
-
var SelectLabel =
|
|
579
|
+
var SelectLabel = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
580
580
|
SelectPrimitive__namespace.Label,
|
|
581
581
|
{
|
|
582
582
|
ref,
|
|
@@ -585,7 +585,7 @@ var SelectLabel = React27__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
585
585
|
}
|
|
586
586
|
));
|
|
587
587
|
SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
|
|
588
|
-
var SelectItem =
|
|
588
|
+
var SelectItem = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
589
589
|
SelectPrimitive__namespace.Item,
|
|
590
590
|
{
|
|
591
591
|
ref,
|
|
@@ -601,7 +601,7 @@ var SelectItem = React27__namespace.forwardRef(({ className, children, ...props
|
|
|
601
601
|
}
|
|
602
602
|
));
|
|
603
603
|
SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
|
|
604
|
-
var SelectSeparator =
|
|
604
|
+
var SelectSeparator = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
605
605
|
SelectPrimitive__namespace.Separator,
|
|
606
606
|
{
|
|
607
607
|
ref,
|
|
@@ -613,7 +613,7 @@ SelectSeparator.displayName = SelectPrimitive__namespace.Separator.displayName;
|
|
|
613
613
|
var TooltipProvider = TooltipPrimitive__namespace.Provider;
|
|
614
614
|
var Tooltip = TooltipPrimitive__namespace.Root;
|
|
615
615
|
var TooltipTrigger = TooltipPrimitive__namespace.Trigger;
|
|
616
|
-
var TooltipContent =
|
|
616
|
+
var TooltipContent = React25__namespace.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
617
617
|
TooltipPrimitive__namespace.Content,
|
|
618
618
|
{
|
|
619
619
|
ref,
|
|
@@ -681,7 +681,7 @@ function FilterFieldItem({
|
|
|
681
681
|
onOperatorChange,
|
|
682
682
|
onDelete
|
|
683
683
|
}) {
|
|
684
|
-
const [isCalendarOpen, setIsCalendarOpen] =
|
|
684
|
+
const [isCalendarOpen, setIsCalendarOpen] = React25.useState(false);
|
|
685
685
|
const renderInput = () => {
|
|
686
686
|
switch (fieldConfig.type) {
|
|
687
687
|
case "text":
|
|
@@ -700,27 +700,27 @@ function FilterFieldItem({
|
|
|
700
700
|
placeholder: "Enter text...",
|
|
701
701
|
minLength: fieldConfig.textConfig?.minLength,
|
|
702
702
|
maxLength: fieldConfig.textConfig?.maxLength,
|
|
703
|
-
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"
|
|
704
704
|
}
|
|
705
705
|
);
|
|
706
|
-
case "number":
|
|
706
|
+
case "number": {
|
|
707
707
|
const numberOperators = [
|
|
708
|
-
{ value: "equals", label: "
|
|
709
|
-
{ value: "not_equals", label: "
|
|
710
|
-
{ value: "greater_than", label: "
|
|
711
|
-
{ value: "less_than", label: "
|
|
712
|
-
{ value: "greater_equal", label: "
|
|
713
|
-
{ 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" }
|
|
714
714
|
];
|
|
715
|
-
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: [
|
|
716
716
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
717
717
|
Select,
|
|
718
718
|
{
|
|
719
719
|
value: filterConfig.operator || "equals",
|
|
720
720
|
onValueChange: (value) => onOperatorChange?.(value),
|
|
721
721
|
children: [
|
|
722
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "cls_operator_select
|
|
723
|
-
/* @__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)) })
|
|
724
724
|
]
|
|
725
725
|
}
|
|
726
726
|
),
|
|
@@ -736,14 +736,10 @@ function FilterFieldItem({
|
|
|
736
736
|
return;
|
|
737
737
|
}
|
|
738
738
|
let numValue = fieldConfig.numberConfig?.allowDecimal ? parseFloat(value) : parseInt(value, 10);
|
|
739
|
-
if (isNaN(numValue))
|
|
740
|
-
return;
|
|
741
|
-
}
|
|
739
|
+
if (isNaN(numValue)) return;
|
|
742
740
|
if (fieldConfig.numberConfig?.allowDecimal && fieldConfig.numberConfig?.decimalLength) {
|
|
743
741
|
const decimalPlaces = value.split(".")[1]?.length || 0;
|
|
744
|
-
if (decimalPlaces > fieldConfig.numberConfig.decimalLength)
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
742
|
+
if (decimalPlaces > fieldConfig.numberConfig.decimalLength) return;
|
|
747
743
|
}
|
|
748
744
|
if (fieldConfig.numberConfig?.min !== void 0 && numValue < fieldConfig.numberConfig.min) {
|
|
749
745
|
numValue = fieldConfig.numberConfig.min;
|
|
@@ -753,14 +749,15 @@ function FilterFieldItem({
|
|
|
753
749
|
}
|
|
754
750
|
onValueChange(numValue);
|
|
755
751
|
},
|
|
756
|
-
placeholder: "
|
|
752
|
+
placeholder: "Value",
|
|
757
753
|
min: fieldConfig.numberConfig?.min,
|
|
758
754
|
max: fieldConfig.numberConfig?.max,
|
|
759
755
|
step: fieldConfig.numberConfig?.allowDecimal ? 0.01 : 1,
|
|
760
|
-
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"
|
|
761
757
|
}
|
|
762
758
|
)
|
|
763
759
|
] });
|
|
760
|
+
}
|
|
764
761
|
case "combobox":
|
|
765
762
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
766
763
|
Select,
|
|
@@ -768,12 +765,12 @@ function FilterFieldItem({
|
|
|
768
765
|
value: filterConfig.value || "",
|
|
769
766
|
onValueChange: (value) => onValueChange(value),
|
|
770
767
|
children: [
|
|
771
|
-
/* @__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..." }) }),
|
|
772
769
|
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: fieldConfig.comboboxOptions?.map((option) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: option.value, children: option.label }, option.value)) })
|
|
773
770
|
]
|
|
774
771
|
}
|
|
775
772
|
);
|
|
776
|
-
case "boolean":
|
|
773
|
+
case "boolean": {
|
|
777
774
|
const trueLabel = fieldConfig.booleanLabels?.trueLabel || "On";
|
|
778
775
|
const falseLabel = fieldConfig.booleanLabels?.falseLabel || "Off";
|
|
779
776
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -782,7 +779,7 @@ function FilterFieldItem({
|
|
|
782
779
|
value: filterConfig.value !== void 0 && filterConfig.value !== null ? String(filterConfig.value) : "",
|
|
783
780
|
onValueChange: (value) => onValueChange(value === "true"),
|
|
784
781
|
children: [
|
|
785
|
-
/* @__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..." }) }),
|
|
786
783
|
/* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
|
|
787
784
|
/* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "true", children: trueLabel }),
|
|
788
785
|
/* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "false", children: falseLabel })
|
|
@@ -790,25 +787,26 @@ function FilterFieldItem({
|
|
|
790
787
|
]
|
|
791
788
|
}
|
|
792
789
|
);
|
|
793
|
-
|
|
790
|
+
}
|
|
791
|
+
case "date": {
|
|
794
792
|
const dateOperators = [
|
|
795
|
-
{ value: "equals", label: "
|
|
796
|
-
{ value: "not_equals", label: "
|
|
797
|
-
{ value: "greater_than", label: "
|
|
798
|
-
{ value: "less_than", label: "
|
|
799
|
-
{ value: "greater_equal", label: "
|
|
800
|
-
{ 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" }
|
|
801
799
|
];
|
|
802
800
|
const selectedDate = filterConfig.value ? typeof filterConfig.value === "string" ? new Date(filterConfig.value) : filterConfig.value : void 0;
|
|
803
|
-
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: [
|
|
804
802
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
805
803
|
Select,
|
|
806
804
|
{
|
|
807
805
|
value: filterConfig.operator || "equals",
|
|
808
806
|
onValueChange: (value) => onOperatorChange?.(value),
|
|
809
807
|
children: [
|
|
810
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "cls_operator_select
|
|
811
|
-
/* @__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)) })
|
|
812
810
|
]
|
|
813
811
|
}
|
|
814
812
|
),
|
|
@@ -818,11 +816,11 @@ function FilterFieldItem({
|
|
|
818
816
|
{
|
|
819
817
|
variant: "outline",
|
|
820
818
|
className: cn(
|
|
821
|
-
"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",
|
|
822
820
|
!selectedDate && "text-muted-foreground"
|
|
823
821
|
),
|
|
824
822
|
children: [
|
|
825
|
-
/* @__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" }),
|
|
826
824
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cls_date_text truncate", children: selectedDate ? dateFns.format(selectedDate, "MMM d, yyyy") : "Pick a date" })
|
|
827
825
|
]
|
|
828
826
|
}
|
|
@@ -841,24 +839,27 @@ function FilterFieldItem({
|
|
|
841
839
|
) })
|
|
842
840
|
] })
|
|
843
841
|
] });
|
|
842
|
+
}
|
|
844
843
|
default:
|
|
845
844
|
return null;
|
|
846
845
|
}
|
|
847
846
|
};
|
|
848
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_filter_field_item flex flex-col
|
|
849
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cls_field_label text-
|
|
850
|
-
/* @__PURE__ */ jsxRuntime.
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
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
|
+
] })
|
|
862
863
|
] });
|
|
863
864
|
}
|
|
864
865
|
function HazoUiMultiFilterDialog({
|
|
@@ -866,7 +867,7 @@ function HazoUiMultiFilterDialog({
|
|
|
866
867
|
onFilterChange,
|
|
867
868
|
initialFilters = [],
|
|
868
869
|
title = "Filter",
|
|
869
|
-
description = "Add
|
|
870
|
+
description = "Add fields to filter by. Select a field and set its value.",
|
|
870
871
|
headerBackgroundColor,
|
|
871
872
|
headerTextColor,
|
|
872
873
|
submitButtonBackgroundColor,
|
|
@@ -907,22 +908,18 @@ function HazoUiMultiFilterDialog({
|
|
|
907
908
|
...finalHeaderBgColor && { backgroundColor: finalHeaderBgColor },
|
|
908
909
|
...finalHeaderTextColor && { color: finalHeaderTextColor }
|
|
909
910
|
};
|
|
910
|
-
const [isOpen, setIsOpen] =
|
|
911
|
-
const [filterFields, setFilterFields] =
|
|
912
|
-
const [isComboboxOpen, setIsComboboxOpen] =
|
|
913
|
-
|
|
911
|
+
const [isOpen, setIsOpen] = React25.useState(false);
|
|
912
|
+
const [filterFields, setFilterFields] = React25.useState(initialFilters);
|
|
913
|
+
const [isComboboxOpen, setIsComboboxOpen] = React25.useState(false);
|
|
914
|
+
React25.useEffect(() => {
|
|
914
915
|
if (isOpen) {
|
|
915
916
|
setFilterFields(initialFilters);
|
|
916
917
|
}
|
|
917
918
|
}, [isOpen, initialFilters]);
|
|
918
919
|
const handleAddField = (fieldValue) => {
|
|
919
|
-
if (filterFields.some((ff) => ff.field === fieldValue))
|
|
920
|
-
return;
|
|
921
|
-
}
|
|
920
|
+
if (filterFields.some((ff) => ff.field === fieldValue)) return;
|
|
922
921
|
const fieldConfig = availableFields.find((af) => af.value === fieldValue);
|
|
923
|
-
if (!fieldConfig)
|
|
924
|
-
return;
|
|
925
|
-
}
|
|
922
|
+
if (!fieldConfig) return;
|
|
926
923
|
let defaultValue = "";
|
|
927
924
|
if (fieldConfig.type === "boolean") {
|
|
928
925
|
defaultValue = false;
|
|
@@ -975,7 +972,7 @@ function HazoUiMultiFilterDialog({
|
|
|
975
972
|
};
|
|
976
973
|
const hasActiveFilters = initialFilters.length > 0;
|
|
977
974
|
const tooltipContent = hasActiveFilters ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_filter_tooltip_content space-y-1", children: [
|
|
978
|
-
/* @__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" }),
|
|
979
976
|
initialFilters.map((filterConfig) => {
|
|
980
977
|
const fieldConfig = getFieldConfig(filterConfig.field);
|
|
981
978
|
if (!fieldConfig) return null;
|
|
@@ -1019,152 +1016,114 @@ function HazoUiMultiFilterDialog({
|
|
|
1019
1016
|
)
|
|
1020
1017
|
}
|
|
1021
1018
|
),
|
|
1022
|
-
"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 })
|
|
1023
1021
|
]
|
|
1024
1022
|
}
|
|
1025
1023
|
) }) }),
|
|
1026
1024
|
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: tooltipContent })
|
|
1027
1025
|
] }) }),
|
|
1028
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "cls_filter_dialog_content max-w-lg
|
|
1029
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
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." }),
|
|
1034
1054
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_add_field_section", children: /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: isComboboxOpen, onOpenChange: setIsComboboxOpen, children: [
|
|
1035
1055
|
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1036
1056
|
Button,
|
|
1037
1057
|
{
|
|
1038
|
-
variant: "
|
|
1058
|
+
variant: "ghost",
|
|
1039
1059
|
role: "combobox",
|
|
1040
1060
|
"aria-expanded": isComboboxOpen,
|
|
1041
|
-
|
|
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",
|
|
1042
1063
|
children: [
|
|
1043
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1044
|
-
|
|
1045
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Add field" })
|
|
1046
|
-
] }),
|
|
1047
|
-
/* @__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" })
|
|
1048
1066
|
]
|
|
1049
1067
|
}
|
|
1050
1068
|
) }),
|
|
1051
|
-
/* @__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: [
|
|
1052
1070
|
/* @__PURE__ */ jsxRuntime.jsx(CommandInput, { placeholder: "Search fields...", className: "cls_command_input" }),
|
|
1053
|
-
/* @__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(
|
|
1054
1072
|
CommandItem,
|
|
1055
1073
|
{
|
|
1056
1074
|
value: field.label,
|
|
1057
1075
|
onSelect: () => handleAddField(field.value),
|
|
1058
1076
|
className: "cls_command_item",
|
|
1059
|
-
children:
|
|
1060
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1061
|
-
lucideReact.Check,
|
|
1062
|
-
{
|
|
1063
|
-
className: cn(
|
|
1064
|
-
"cls_check_icon mr-2 h-4 w-4",
|
|
1065
|
-
"opacity-0"
|
|
1066
|
-
)
|
|
1067
|
-
}
|
|
1068
|
-
),
|
|
1069
|
-
field.label
|
|
1070
|
-
]
|
|
1077
|
+
children: field.label
|
|
1071
1078
|
},
|
|
1072
1079
|
field.value
|
|
1073
1080
|
)) }) })
|
|
1074
1081
|
] }) })
|
|
1075
|
-
] }) })
|
|
1076
|
-
filterFields.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cls_filter_fields_list space-y-2", children: filterFields.map((filterConfig) => {
|
|
1077
|
-
const fieldConfig = getFieldConfig(filterConfig.field);
|
|
1078
|
-
if (!fieldConfig) return null;
|
|
1079
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1080
|
-
FilterFieldItem,
|
|
1081
|
-
{
|
|
1082
|
-
filterConfig,
|
|
1083
|
-
fieldConfig,
|
|
1084
|
-
onValueChange: (value) => handleValueChange(filterConfig.field, value),
|
|
1085
|
-
onOperatorChange: (operator) => handleOperatorChange(filterConfig.field, operator),
|
|
1086
|
-
onDelete: () => handleDeleteField(filterConfig.field)
|
|
1087
|
-
},
|
|
1088
|
-
filterConfig.field
|
|
1089
|
-
);
|
|
1090
|
-
}) }) : /* @__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
|
+
] }) })
|
|
1091
1083
|
] }),
|
|
1092
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogFooter, { children: [
|
|
1093
|
-
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(
|
|
1094
1086
|
Button,
|
|
1095
1087
|
{
|
|
1096
|
-
variant: "
|
|
1088
|
+
variant: "ghost",
|
|
1089
|
+
size: "sm",
|
|
1097
1090
|
onClick: handleClearAll,
|
|
1098
|
-
className: "cls_clear_all_btn",
|
|
1091
|
+
className: "cls_clear_all_btn text-muted-foreground hover:text-foreground",
|
|
1099
1092
|
style: clearButtonStyles,
|
|
1100
|
-
children:
|
|
1101
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "cls_clear_all_icon h-4 w-4 mr-2" }),
|
|
1102
|
-
"Clear All"
|
|
1103
|
-
]
|
|
1104
|
-
}
|
|
1105
|
-
),
|
|
1106
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1107
|
-
Button,
|
|
1108
|
-
{
|
|
1109
|
-
onClick: handleApply,
|
|
1110
|
-
className: "cls_apply_btn",
|
|
1111
|
-
style: submitButtonStyles,
|
|
1112
|
-
children: "Apply"
|
|
1113
|
-
}
|
|
1114
|
-
),
|
|
1115
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1116
|
-
Button,
|
|
1117
|
-
{
|
|
1118
|
-
variant: "outline",
|
|
1119
|
-
onClick: handleCancel,
|
|
1120
|
-
className: "cls_cancel_btn",
|
|
1121
|
-
style: cancelButtonStyles,
|
|
1122
|
-
children: "Cancel"
|
|
1093
|
+
children: "Clear all"
|
|
1123
1094
|
}
|
|
1124
|
-
)
|
|
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
|
+
] })
|
|
1125
1119
|
] })
|
|
1126
1120
|
] })
|
|
1127
1121
|
] });
|
|
1128
1122
|
}
|
|
1129
|
-
var Switch = React27__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1130
|
-
SwitchPrimitives__namespace.Root,
|
|
1131
|
-
{
|
|
1132
|
-
className: cn(
|
|
1133
|
-
"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",
|
|
1134
|
-
className
|
|
1135
|
-
),
|
|
1136
|
-
...props,
|
|
1137
|
-
ref,
|
|
1138
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1139
|
-
SwitchPrimitives__namespace.Thumb,
|
|
1140
|
-
{
|
|
1141
|
-
className: cn(
|
|
1142
|
-
"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"
|
|
1143
|
-
)
|
|
1144
|
-
}
|
|
1145
|
-
)
|
|
1146
|
-
}
|
|
1147
|
-
));
|
|
1148
|
-
Switch.displayName = SwitchPrimitives__namespace.Root.displayName;
|
|
1149
|
-
var Label2 = React27__namespace.forwardRef(
|
|
1150
|
-
({ className, ...props }, ref) => {
|
|
1151
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1152
|
-
"label",
|
|
1153
|
-
{
|
|
1154
|
-
ref,
|
|
1155
|
-
className: cn(
|
|
1156
|
-
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
1157
|
-
className
|
|
1158
|
-
),
|
|
1159
|
-
...props
|
|
1160
|
-
}
|
|
1161
|
-
);
|
|
1162
|
-
}
|
|
1163
|
-
);
|
|
1164
|
-
Label2.displayName = "Label";
|
|
1165
1123
|
function SortableSortFieldItem({
|
|
1166
1124
|
sortConfig,
|
|
1167
1125
|
fieldLabel,
|
|
1126
|
+
priority,
|
|
1168
1127
|
onDirectionChange,
|
|
1169
1128
|
onDelete
|
|
1170
1129
|
}) {
|
|
@@ -1179,46 +1138,88 @@ function SortableSortFieldItem({
|
|
|
1179
1138
|
const style = {
|
|
1180
1139
|
transform: utilities.CSS.Transform.toString(transform),
|
|
1181
1140
|
transition,
|
|
1182
|
-
opacity: isDragging ? 0.
|
|
1141
|
+
opacity: isDragging ? 0.6 : 1,
|
|
1142
|
+
zIndex: isDragging ? 10 : void 0
|
|
1183
1143
|
};
|
|
1184
1144
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1185
1145
|
"div",
|
|
1186
1146
|
{
|
|
1187
1147
|
ref: setNodeRef,
|
|
1188
1148
|
style,
|
|
1189
|
-
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
|
+
),
|
|
1190
1153
|
children: [
|
|
1191
1154
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1192
|
-
"
|
|
1155
|
+
"button",
|
|
1193
1156
|
{
|
|
1157
|
+
type: "button",
|
|
1194
1158
|
...attributes,
|
|
1195
1159
|
...listeners,
|
|
1196
|
-
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}`,
|
|
1197
1162
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GripVertical, { className: "cls_drag_icon h-4 w-4" })
|
|
1198
1163
|
}
|
|
1199
1164
|
),
|
|
1200
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
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
|
+
),
|
|
1213
1214
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1214
1215
|
Button,
|
|
1215
1216
|
{
|
|
1216
1217
|
variant: "ghost",
|
|
1217
1218
|
size: "sm",
|
|
1218
1219
|
onClick: onDelete,
|
|
1219
|
-
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",
|
|
1220
1221
|
"aria-label": `Remove ${fieldLabel} from sort`,
|
|
1221
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.
|
|
1222
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "cls_delete_icon h-3.5 w-3.5" })
|
|
1222
1223
|
}
|
|
1223
1224
|
)
|
|
1224
1225
|
]
|
|
@@ -1230,7 +1231,7 @@ function HazoUiMultiSortDialog({
|
|
|
1230
1231
|
onSortChange,
|
|
1231
1232
|
initialSortFields = [],
|
|
1232
1233
|
title = "Sort",
|
|
1233
|
-
description = "Add
|
|
1234
|
+
description = "Add fields to sort by, drag to reorder, toggle ascending or descending.",
|
|
1234
1235
|
headerBackgroundColor,
|
|
1235
1236
|
headerTextColor,
|
|
1236
1237
|
submitButtonBackgroundColor,
|
|
@@ -1271,16 +1272,16 @@ function HazoUiMultiSortDialog({
|
|
|
1271
1272
|
...finalHeaderBgColor && { backgroundColor: finalHeaderBgColor },
|
|
1272
1273
|
...finalHeaderTextColor && { color: finalHeaderTextColor }
|
|
1273
1274
|
};
|
|
1274
|
-
const [isOpen, setIsOpen] =
|
|
1275
|
-
const [sortFields, setSortFields] =
|
|
1276
|
-
const [isComboboxOpen, setIsComboboxOpen] =
|
|
1275
|
+
const [isOpen, setIsOpen] = React25.useState(false);
|
|
1276
|
+
const [sortFields, setSortFields] = React25.useState(initialSortFields);
|
|
1277
|
+
const [isComboboxOpen, setIsComboboxOpen] = React25.useState(false);
|
|
1277
1278
|
const sensors = core$1.useSensors(
|
|
1278
|
-
core$1.useSensor(core$1.PointerSensor),
|
|
1279
|
+
core$1.useSensor(core$1.PointerSensor, { activationConstraint: { distance: 4 } }),
|
|
1279
1280
|
core$1.useSensor(core$1.KeyboardSensor, {
|
|
1280
1281
|
coordinateGetter: sortable.sortableKeyboardCoordinates
|
|
1281
1282
|
})
|
|
1282
1283
|
);
|
|
1283
|
-
|
|
1284
|
+
React25.useEffect(() => {
|
|
1284
1285
|
if (isOpen) {
|
|
1285
1286
|
setSortFields(initialSortFields);
|
|
1286
1287
|
}
|
|
@@ -1289,11 +1290,7 @@ function HazoUiMultiSortDialog({
|
|
|
1289
1290
|
if (sortFields.some((sf) => sf.field === fieldValue)) {
|
|
1290
1291
|
return;
|
|
1291
1292
|
}
|
|
1292
|
-
|
|
1293
|
-
field: fieldValue,
|
|
1294
|
-
direction: "asc"
|
|
1295
|
-
};
|
|
1296
|
-
setSortFields([...sortFields, newField]);
|
|
1293
|
+
setSortFields([...sortFields, { field: fieldValue, direction: "asc" }]);
|
|
1297
1294
|
setIsComboboxOpen(false);
|
|
1298
1295
|
};
|
|
1299
1296
|
const handleDeleteField = (fieldValue) => {
|
|
@@ -1308,9 +1305,7 @@ function HazoUiMultiSortDialog({
|
|
|
1308
1305
|
};
|
|
1309
1306
|
const handleDragEnd = (event) => {
|
|
1310
1307
|
const { active, over } = event;
|
|
1311
|
-
if (!over || active.id === over.id)
|
|
1312
|
-
return;
|
|
1313
|
-
}
|
|
1308
|
+
if (!over || active.id === over.id) return;
|
|
1314
1309
|
const oldIndex = sortFields.findIndex((sf) => sf.field === active.id);
|
|
1315
1310
|
const newIndex = sortFields.findIndex((sf) => sf.field === over.id);
|
|
1316
1311
|
if (oldIndex !== -1 && newIndex !== -1) {
|
|
@@ -1336,7 +1331,7 @@ function HazoUiMultiSortDialog({
|
|
|
1336
1331
|
};
|
|
1337
1332
|
const hasActiveSorts = initialSortFields.length > 0;
|
|
1338
1333
|
const tooltipContent = hasActiveSorts ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_sort_tooltip_content space-y-1", children: [
|
|
1339
|
-
/* @__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" }),
|
|
1340
1335
|
initialSortFields.map((sortConfig, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_tooltip_item text-xs", children: [
|
|
1341
1336
|
index + 1,
|
|
1342
1337
|
". ",
|
|
@@ -1365,61 +1360,27 @@ function HazoUiMultiSortDialog({
|
|
|
1365
1360
|
)
|
|
1366
1361
|
}
|
|
1367
1362
|
),
|
|
1368
|
-
"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 })
|
|
1369
1365
|
]
|
|
1370
1366
|
}
|
|
1371
1367
|
) }) }),
|
|
1372
1368
|
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: tooltipContent })
|
|
1373
1369
|
] }) }),
|
|
1374
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "cls_sort_dialog_content max-w-lg", children: [
|
|
1375
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
children: [
|
|
1389
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cls_combobox_content flex items-center", children: [
|
|
1390
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "cls_plus_icon h-4 w-4 mr-2" }),
|
|
1391
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Add field" })
|
|
1392
|
-
] }),
|
|
1393
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsUpDown, { className: "cls_chevron_icon ml-2 h-4 w-4 shrink-0 opacity-50" })
|
|
1394
|
-
]
|
|
1395
|
-
}
|
|
1396
|
-
) }),
|
|
1397
|
-
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "cls_combobox_popover w-full p-0", children: /* @__PURE__ */ jsxRuntime.jsxs(Command, { children: [
|
|
1398
|
-
/* @__PURE__ */ jsxRuntime.jsx(CommandInput, { placeholder: "Search fields...", className: "cls_command_input" }),
|
|
1399
|
-
/* @__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(
|
|
1400
|
-
CommandItem,
|
|
1401
|
-
{
|
|
1402
|
-
value: field.label,
|
|
1403
|
-
onSelect: () => handleAddField(field.value),
|
|
1404
|
-
className: "cls_command_item",
|
|
1405
|
-
children: [
|
|
1406
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1407
|
-
lucideReact.Check,
|
|
1408
|
-
{
|
|
1409
|
-
className: cn(
|
|
1410
|
-
"cls_check_icon mr-2 h-4 w-4",
|
|
1411
|
-
"opacity-0"
|
|
1412
|
-
)
|
|
1413
|
-
}
|
|
1414
|
-
),
|
|
1415
|
-
field.label
|
|
1416
|
-
]
|
|
1417
|
-
},
|
|
1418
|
-
field.value
|
|
1419
|
-
)) }) })
|
|
1420
|
-
] }) })
|
|
1421
|
-
] }) }),
|
|
1422
|
-
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(
|
|
1423
1384
|
core$1.DndContext,
|
|
1424
1385
|
{
|
|
1425
1386
|
sensors,
|
|
@@ -1430,11 +1391,12 @@ function HazoUiMultiSortDialog({
|
|
|
1430
1391
|
{
|
|
1431
1392
|
items: sortFields.map((sf) => sf.field),
|
|
1432
1393
|
strategy: sortable.verticalListSortingStrategy,
|
|
1433
|
-
children: sortFields.map((sortConfig) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1394
|
+
children: sortFields.map((sortConfig, idx) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1434
1395
|
SortableSortFieldItem,
|
|
1435
1396
|
{
|
|
1436
1397
|
sortConfig,
|
|
1437
1398
|
fieldLabel: getFieldLabel(sortConfig.field),
|
|
1399
|
+
priority: idx + 1,
|
|
1438
1400
|
onDirectionChange: (direction) => handleDirectionChange(sortConfig.field, direction),
|
|
1439
1401
|
onDelete: () => handleDeleteField(sortConfig.field)
|
|
1440
1402
|
},
|
|
@@ -1443,46 +1405,77 @@ function HazoUiMultiSortDialog({
|
|
|
1443
1405
|
}
|
|
1444
1406
|
)
|
|
1445
1407
|
}
|
|
1446
|
-
) }) : /* @__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
|
+
] }) })
|
|
1447
1438
|
] }),
|
|
1448
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogFooter, { children: [
|
|
1449
|
-
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(
|
|
1450
1441
|
Button,
|
|
1451
1442
|
{
|
|
1452
|
-
variant: "
|
|
1443
|
+
variant: "ghost",
|
|
1444
|
+
size: "sm",
|
|
1453
1445
|
onClick: handleClearAll,
|
|
1454
|
-
className: "cls_clear_all_btn",
|
|
1446
|
+
className: "cls_clear_all_btn text-muted-foreground hover:text-foreground",
|
|
1455
1447
|
style: clearButtonStyles,
|
|
1456
|
-
children:
|
|
1457
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "cls_clear_all_icon h-4 w-4 mr-2" }),
|
|
1458
|
-
"Clear All"
|
|
1459
|
-
]
|
|
1460
|
-
}
|
|
1461
|
-
),
|
|
1462
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1463
|
-
Button,
|
|
1464
|
-
{
|
|
1465
|
-
onClick: handleApply,
|
|
1466
|
-
className: "cls_apply_btn",
|
|
1467
|
-
style: submitButtonStyles,
|
|
1468
|
-
children: "Apply"
|
|
1469
|
-
}
|
|
1470
|
-
),
|
|
1471
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1472
|
-
Button,
|
|
1473
|
-
{
|
|
1474
|
-
variant: "outline",
|
|
1475
|
-
onClick: handleCancel,
|
|
1476
|
-
className: "cls_cancel_btn",
|
|
1477
|
-
style: cancelButtonStyles,
|
|
1478
|
-
children: "Cancel"
|
|
1448
|
+
children: "Clear all"
|
|
1479
1449
|
}
|
|
1480
|
-
)
|
|
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
|
+
] })
|
|
1481
1474
|
] })
|
|
1482
1475
|
] })
|
|
1483
1476
|
] });
|
|
1484
1477
|
}
|
|
1485
|
-
var RadioGroup =
|
|
1478
|
+
var RadioGroup = React25__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
1486
1479
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1487
1480
|
RadioGroupPrimitive__namespace.Root,
|
|
1488
1481
|
{
|
|
@@ -1493,7 +1486,7 @@ var RadioGroup = React27__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
1493
1486
|
);
|
|
1494
1487
|
});
|
|
1495
1488
|
RadioGroup.displayName = RadioGroupPrimitive__namespace.Root.displayName;
|
|
1496
|
-
var RadioGroupItem =
|
|
1489
|
+
var RadioGroupItem = React25__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
1497
1490
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1498
1491
|
RadioGroupPrimitive__namespace.Item,
|
|
1499
1492
|
{
|
|
@@ -1950,7 +1943,7 @@ function filterInputValue(value, input_type, num_decimals) {
|
|
|
1950
1943
|
}
|
|
1951
1944
|
}
|
|
1952
1945
|
}
|
|
1953
|
-
var HazoUiFlexInput =
|
|
1946
|
+
var HazoUiFlexInput = React25__namespace.forwardRef(
|
|
1954
1947
|
({
|
|
1955
1948
|
className,
|
|
1956
1949
|
input_type = "mixed",
|
|
@@ -1967,13 +1960,13 @@ var HazoUiFlexInput = React27__namespace.forwardRef(
|
|
|
1967
1960
|
onBlur,
|
|
1968
1961
|
...props
|
|
1969
1962
|
}, ref) => {
|
|
1970
|
-
const [internalValue, setInternalValue] =
|
|
1963
|
+
const [internalValue, setInternalValue] = React25__namespace.useState(
|
|
1971
1964
|
typeof controlledValue === "string" ? controlledValue : typeof controlledValue === "number" ? String(controlledValue) : ""
|
|
1972
1965
|
);
|
|
1973
|
-
const [errorMessage, setErrorMessage] =
|
|
1966
|
+
const [errorMessage, setErrorMessage] = React25__namespace.useState();
|
|
1974
1967
|
const isControlled = controlledValue !== void 0;
|
|
1975
1968
|
const currentValue = isControlled ? typeof controlledValue === "string" ? controlledValue : String(controlledValue || "") : internalValue;
|
|
1976
|
-
|
|
1969
|
+
React25__namespace.useEffect(() => {
|
|
1977
1970
|
if (isControlled) {
|
|
1978
1971
|
const newValue = typeof controlledValue === "string" ? controlledValue : String(controlledValue || "");
|
|
1979
1972
|
if (newValue !== internalValue) {
|
|
@@ -2053,7 +2046,7 @@ var HazoUiFlexInput = React27__namespace.forwardRef(
|
|
|
2053
2046
|
}
|
|
2054
2047
|
);
|
|
2055
2048
|
HazoUiFlexInput.displayName = "HazoUiFlexInput";
|
|
2056
|
-
var ToolbarButton =
|
|
2049
|
+
var ToolbarButton = React25__namespace.forwardRef(
|
|
2057
2050
|
({ onClick, is_active = false, disabled = false, tooltip, className, children }, ref) => {
|
|
2058
2051
|
const button = /* @__PURE__ */ jsxRuntime.jsx(
|
|
2059
2052
|
"button",
|
|
@@ -2340,11 +2333,11 @@ var validHex = (hex) => /^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
|
|
|
2340
2333
|
var import_extends2 = __toESM(require_extends());
|
|
2341
2334
|
var import_objectWithoutPropertiesLoose = __toESM(require_objectWithoutPropertiesLoose());
|
|
2342
2335
|
function useEventCallback(handler) {
|
|
2343
|
-
var callbackRef =
|
|
2344
|
-
|
|
2336
|
+
var callbackRef = React25.useRef(handler);
|
|
2337
|
+
React25.useEffect(() => {
|
|
2345
2338
|
callbackRef.current = handler;
|
|
2346
2339
|
});
|
|
2347
|
-
return
|
|
2340
|
+
return React25.useCallback((value, event) => callbackRef.current && callbackRef.current(value, event), []);
|
|
2348
2341
|
}
|
|
2349
2342
|
var isTouch = (event) => "touches" in event;
|
|
2350
2343
|
var preventDefaultMove = (event) => {
|
|
@@ -2372,16 +2365,16 @@ var getRelativePosition = (node, event) => {
|
|
|
2372
2365
|
};
|
|
2373
2366
|
};
|
|
2374
2367
|
var _excluded = ["prefixCls", "className", "onMove", "onDown"];
|
|
2375
|
-
var Interactive = /* @__PURE__ */
|
|
2368
|
+
var Interactive = /* @__PURE__ */ React25__namespace.default.forwardRef((props, ref) => {
|
|
2376
2369
|
var {
|
|
2377
2370
|
prefixCls = "w-color-interactive",
|
|
2378
2371
|
className,
|
|
2379
2372
|
onMove,
|
|
2380
2373
|
onDown
|
|
2381
2374
|
} = props, reset = (0, import_objectWithoutPropertiesLoose.default)(props, _excluded);
|
|
2382
|
-
var container =
|
|
2383
|
-
var hasTouched =
|
|
2384
|
-
var [isDragging, setDragging] =
|
|
2375
|
+
var container = React25.useRef(null);
|
|
2376
|
+
var hasTouched = React25.useRef(false);
|
|
2377
|
+
var [isDragging, setDragging] = React25.useState(false);
|
|
2385
2378
|
var onMoveCallback = useEventCallback(onMove);
|
|
2386
2379
|
var onKeyCallback = useEventCallback(onDown);
|
|
2387
2380
|
var isValid = (event) => {
|
|
@@ -2389,7 +2382,7 @@ var Interactive = /* @__PURE__ */ React27__namespace.default.forwardRef((props,
|
|
|
2389
2382
|
hasTouched.current = isTouch(event);
|
|
2390
2383
|
return true;
|
|
2391
2384
|
};
|
|
2392
|
-
var handleMove =
|
|
2385
|
+
var handleMove = React25.useCallback((event) => {
|
|
2393
2386
|
preventDefaultMove(event);
|
|
2394
2387
|
if (!container.current) return;
|
|
2395
2388
|
var isDown = isTouch(event) ? event.touches.length > 0 : event.buttons > 0;
|
|
@@ -2399,8 +2392,8 @@ var Interactive = /* @__PURE__ */ React27__namespace.default.forwardRef((props,
|
|
|
2399
2392
|
}
|
|
2400
2393
|
onMoveCallback == null || onMoveCallback(getRelativePosition(container.current, event), event);
|
|
2401
2394
|
}, [onMoveCallback]);
|
|
2402
|
-
var handleMoveEnd =
|
|
2403
|
-
var toggleDocumentEvents =
|
|
2395
|
+
var handleMoveEnd = React25.useCallback(() => setDragging(false), []);
|
|
2396
|
+
var toggleDocumentEvents = React25.useCallback((state) => {
|
|
2404
2397
|
if (state) {
|
|
2405
2398
|
window.addEventListener(hasTouched.current ? "touchmove" : "mousemove", handleMove);
|
|
2406
2399
|
window.addEventListener(hasTouched.current ? "touchend" : "mouseup", handleMoveEnd);
|
|
@@ -2411,13 +2404,13 @@ var Interactive = /* @__PURE__ */ React27__namespace.default.forwardRef((props,
|
|
|
2411
2404
|
window.removeEventListener("touchend", handleMoveEnd);
|
|
2412
2405
|
}
|
|
2413
2406
|
}, [handleMove, handleMoveEnd]);
|
|
2414
|
-
|
|
2407
|
+
React25.useEffect(() => {
|
|
2415
2408
|
toggleDocumentEvents(isDragging);
|
|
2416
2409
|
return () => {
|
|
2417
2410
|
toggleDocumentEvents(false);
|
|
2418
2411
|
};
|
|
2419
2412
|
}, [isDragging, handleMove, handleMoveEnd, toggleDocumentEvents]);
|
|
2420
|
-
var handleMoveStart =
|
|
2413
|
+
var handleMoveStart = React25.useCallback((event) => {
|
|
2421
2414
|
var activeEl = document.activeElement;
|
|
2422
2415
|
activeEl == null || activeEl.blur();
|
|
2423
2416
|
preventDefaultMove(event.nativeEvent);
|
|
@@ -2461,7 +2454,7 @@ var Pointer = (_ref) => {
|
|
|
2461
2454
|
borderRadius: "50%",
|
|
2462
2455
|
backgroundColor: color2
|
|
2463
2456
|
};
|
|
2464
|
-
return
|
|
2457
|
+
return React25.useMemo(() => /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
2465
2458
|
className: prefixCls + "-pointer " + (className || ""),
|
|
2466
2459
|
style,
|
|
2467
2460
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
@@ -2471,7 +2464,7 @@ var Pointer = (_ref) => {
|
|
|
2471
2464
|
}), [top, left, color2, className, prefixCls]);
|
|
2472
2465
|
};
|
|
2473
2466
|
var _excluded2 = ["prefixCls", "radius", "pointer", "className", "hue", "style", "hsva", "onChange"];
|
|
2474
|
-
var Saturation = /* @__PURE__ */
|
|
2467
|
+
var Saturation = /* @__PURE__ */ React25__namespace.default.forwardRef((props, ref) => {
|
|
2475
2468
|
var _hsva$h;
|
|
2476
2469
|
var {
|
|
2477
2470
|
prefixCls = "w-color-saturation",
|
|
@@ -2499,7 +2492,7 @@ var Saturation = /* @__PURE__ */ React27__namespace.default.forwardRef((props, r
|
|
|
2499
2492
|
// source: 'hsv',
|
|
2500
2493
|
});
|
|
2501
2494
|
};
|
|
2502
|
-
var handleKeyDown =
|
|
2495
|
+
var handleKeyDown = React25.useCallback((event) => {
|
|
2503
2496
|
if (!hsva || !onChange) return;
|
|
2504
2497
|
var step = 1;
|
|
2505
2498
|
var newS = hsva.s;
|
|
@@ -2538,7 +2531,7 @@ var Saturation = /* @__PURE__ */ React27__namespace.default.forwardRef((props, r
|
|
|
2538
2531
|
});
|
|
2539
2532
|
}
|
|
2540
2533
|
}, [hsva, onChange]);
|
|
2541
|
-
var pointerElement =
|
|
2534
|
+
var pointerElement = React25.useMemo(() => {
|
|
2542
2535
|
if (!hsva) return null;
|
|
2543
2536
|
var comProps = {
|
|
2544
2537
|
top: 100 - hsva.v + "%",
|
|
@@ -2554,7 +2547,7 @@ var Saturation = /* @__PURE__ */ React27__namespace.default.forwardRef((props, r
|
|
|
2554
2547
|
prefixCls
|
|
2555
2548
|
}, comProps));
|
|
2556
2549
|
}, [hsva, pointer, prefixCls]);
|
|
2557
|
-
var handleClick =
|
|
2550
|
+
var handleClick = React25.useCallback((event) => {
|
|
2558
2551
|
event.target.focus();
|
|
2559
2552
|
}, []);
|
|
2560
2553
|
return /* @__PURE__ */ jsxRuntime.jsx(esm_default, (0, import_extends3.default)({
|
|
@@ -2623,7 +2616,7 @@ var Pointer2 = (_ref) => {
|
|
|
2623
2616
|
};
|
|
2624
2617
|
var _excluded4 = ["prefixCls", "className", "hsva", "background", "bgProps", "innerProps", "pointerProps", "radius", "width", "height", "direction", "style", "onChange", "pointer"];
|
|
2625
2618
|
var BACKGROUND_IMG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==";
|
|
2626
|
-
var Alpha = /* @__PURE__ */
|
|
2619
|
+
var Alpha = /* @__PURE__ */ React25__namespace.default.forwardRef((props, ref) => {
|
|
2627
2620
|
var {
|
|
2628
2621
|
prefixCls = "w-color-alpha",
|
|
2629
2622
|
className,
|
|
@@ -2668,7 +2661,7 @@ var Alpha = /* @__PURE__ */ React27__namespace.default.forwardRef((props, ref) =
|
|
|
2668
2661
|
}, style, {
|
|
2669
2662
|
position: "relative"
|
|
2670
2663
|
});
|
|
2671
|
-
var handleKeyDown =
|
|
2664
|
+
var handleKeyDown = React25.useCallback((event) => {
|
|
2672
2665
|
var step = 0.01;
|
|
2673
2666
|
var currentAlpha = hsva.a;
|
|
2674
2667
|
var newAlpha = currentAlpha;
|
|
@@ -2714,7 +2707,7 @@ var Alpha = /* @__PURE__ */ React27__namespace.default.forwardRef((props, ref) =
|
|
|
2714
2707
|
}), syntheticOffset);
|
|
2715
2708
|
}
|
|
2716
2709
|
}, [hsva, direction, onChange]);
|
|
2717
|
-
var handleClick =
|
|
2710
|
+
var handleClick = React25.useCallback((event) => {
|
|
2718
2711
|
event.target.focus();
|
|
2719
2712
|
}, []);
|
|
2720
2713
|
var pointerElement = pointer && typeof pointer === "function" ? pointer((0, import_extends5.default)({
|
|
@@ -2757,7 +2750,7 @@ var import_objectWithoutPropertiesLoose5 = __toESM(require_objectWithoutProperti
|
|
|
2757
2750
|
var _excluded5 = ["prefixCls", "placement", "label", "value", "className", "style", "labelStyle", "inputStyle", "onChange", "onBlur", "renderInput"];
|
|
2758
2751
|
var validHex2 = (hex) => /^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
|
|
2759
2752
|
var getNumberValue = (value) => Number(String(value).replace(/%/g, ""));
|
|
2760
|
-
var EditableInput = /* @__PURE__ */
|
|
2753
|
+
var EditableInput = /* @__PURE__ */ React25__namespace.default.forwardRef((props, ref) => {
|
|
2761
2754
|
var {
|
|
2762
2755
|
prefixCls = "w-color-editable-input",
|
|
2763
2756
|
placement = "bottom",
|
|
@@ -2771,9 +2764,9 @@ var EditableInput = /* @__PURE__ */ React27__namespace.default.forwardRef((props
|
|
|
2771
2764
|
onBlur,
|
|
2772
2765
|
renderInput
|
|
2773
2766
|
} = props, other = (0, import_objectWithoutPropertiesLoose5.default)(props, _excluded5);
|
|
2774
|
-
var [value, setValue] =
|
|
2775
|
-
var isFocus =
|
|
2776
|
-
|
|
2767
|
+
var [value, setValue] = React25.useState(initValue);
|
|
2768
|
+
var isFocus = React25.useRef(false);
|
|
2769
|
+
React25.useEffect(() => {
|
|
2777
2770
|
if (props.value !== value) {
|
|
2778
2771
|
if (!isFocus.current) {
|
|
2779
2772
|
setValue(props.value);
|
|
@@ -2862,7 +2855,7 @@ var esm_default4 = EditableInput;
|
|
|
2862
2855
|
var import_extends7 = __toESM(require_extends());
|
|
2863
2856
|
var import_objectWithoutPropertiesLoose6 = __toESM(require_objectWithoutPropertiesLoose());
|
|
2864
2857
|
var _excluded6 = ["prefixCls", "hsva", "placement", "rProps", "gProps", "bProps", "aProps", "className", "style", "onChange"];
|
|
2865
|
-
var EditableInputRGBA = /* @__PURE__ */
|
|
2858
|
+
var EditableInputRGBA = /* @__PURE__ */ React25__namespace.default.forwardRef((props, ref) => {
|
|
2866
2859
|
var {
|
|
2867
2860
|
prefixCls = "w-color-editable-input-rgba",
|
|
2868
2861
|
hsva,
|
|
@@ -2985,7 +2978,7 @@ var esm_default5 = EditableInputRGBA;
|
|
|
2985
2978
|
var import_extends8 = __toESM(require_extends());
|
|
2986
2979
|
var import_objectWithoutPropertiesLoose7 = __toESM(require_objectWithoutPropertiesLoose());
|
|
2987
2980
|
var _excluded7 = ["prefixCls", "className", "hue", "onChange", "direction"];
|
|
2988
|
-
var Hue = /* @__PURE__ */
|
|
2981
|
+
var Hue = /* @__PURE__ */ React25__namespace.default.forwardRef((props, ref) => {
|
|
2989
2982
|
var {
|
|
2990
2983
|
prefixCls = "w-color-hue",
|
|
2991
2984
|
className,
|
|
@@ -3019,7 +3012,7 @@ var esm_default6 = Hue;
|
|
|
3019
3012
|
var import_extends9 = __toESM(require_extends());
|
|
3020
3013
|
var import_objectWithoutPropertiesLoose8 = __toESM(require_objectWithoutPropertiesLoose());
|
|
3021
3014
|
var _excluded8 = ["prefixCls", "className", "color", "colors", "style", "rectProps", "onChange", "addonAfter", "addonBefore", "rectRender"];
|
|
3022
|
-
var Swatch = /* @__PURE__ */
|
|
3015
|
+
var Swatch = /* @__PURE__ */ React25__namespace.default.forwardRef((props, ref) => {
|
|
3023
3016
|
var {
|
|
3024
3017
|
prefixCls = "w-color-swatch",
|
|
3025
3018
|
className,
|
|
@@ -3056,7 +3049,7 @@ var Swatch = /* @__PURE__ */ React27__namespace.default.forwardRef((props, ref)
|
|
|
3056
3049
|
flexWrap: "wrap",
|
|
3057
3050
|
position: "relative"
|
|
3058
3051
|
}, style),
|
|
3059
|
-
children: [addonBefore && /* @__PURE__ */
|
|
3052
|
+
children: [addonBefore && /* @__PURE__ */ React25__namespace.default.isValidElement(addonBefore) && addonBefore, colors && Array.isArray(colors) && colors.map((item, idx) => {
|
|
3060
3053
|
var title = "";
|
|
3061
3054
|
var background = "";
|
|
3062
3055
|
if (typeof item === "string") {
|
|
@@ -3078,11 +3071,11 @@ var Swatch = /* @__PURE__ */ React27__namespace.default.forwardRef((props, ref)
|
|
|
3078
3071
|
onClick: (evn) => handleClick(background, evn)
|
|
3079
3072
|
});
|
|
3080
3073
|
if (render) {
|
|
3081
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3074
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React25.Fragment, {
|
|
3082
3075
|
children: render
|
|
3083
3076
|
}, idx);
|
|
3084
3077
|
}
|
|
3085
|
-
var child = rectProps.children && /* @__PURE__ */
|
|
3078
|
+
var child = rectProps.children && /* @__PURE__ */ React25__namespace.default.isValidElement(rectProps.children) ? /* @__PURE__ */ React25__namespace.default.cloneElement(rectProps.children, {
|
|
3086
3079
|
color: background,
|
|
3087
3080
|
checked
|
|
3088
3081
|
}) : null;
|
|
@@ -3096,7 +3089,7 @@ var Swatch = /* @__PURE__ */ React27__namespace.default.forwardRef((props, ref)
|
|
|
3096
3089
|
background
|
|
3097
3090
|
})
|
|
3098
3091
|
}), idx);
|
|
3099
|
-
}), addonAfter && /* @__PURE__ */
|
|
3092
|
+
}), addonAfter && /* @__PURE__ */ React25__namespace.default.isValidElement(addonAfter) && addonAfter]
|
|
3100
3093
|
}));
|
|
3101
3094
|
});
|
|
3102
3095
|
Swatch.displayName = "Swatch";
|
|
@@ -3115,7 +3108,7 @@ var Bar = (props) => /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
|
3115
3108
|
backgroundColor: "#fff"
|
|
3116
3109
|
}
|
|
3117
3110
|
});
|
|
3118
|
-
var Sketch = /* @__PURE__ */
|
|
3111
|
+
var Sketch = /* @__PURE__ */ React25__namespace.default.forwardRef((props, ref) => {
|
|
3119
3112
|
var {
|
|
3120
3113
|
prefixCls = "w-color-sketch",
|
|
3121
3114
|
className,
|
|
@@ -3127,13 +3120,13 @@ var Sketch = /* @__PURE__ */ React27__namespace.default.forwardRef((props, ref)
|
|
|
3127
3120
|
disableAlpha = false,
|
|
3128
3121
|
style
|
|
3129
3122
|
} = props, other = (0, import_objectWithoutPropertiesLoose9.default)(props, _excluded9);
|
|
3130
|
-
var [hsva, setHsva] =
|
|
3123
|
+
var [hsva, setHsva] = React25.useState({
|
|
3131
3124
|
h: 209,
|
|
3132
3125
|
s: 36,
|
|
3133
3126
|
v: 90,
|
|
3134
3127
|
a: 1
|
|
3135
3128
|
});
|
|
3136
|
-
|
|
3129
|
+
React25.useEffect(() => {
|
|
3137
3130
|
if (typeof color2 === "string" && validHex(color2)) {
|
|
3138
3131
|
setHsva(hexToHsva(color2));
|
|
3139
3132
|
}
|
|
@@ -3251,7 +3244,7 @@ var Sketch = /* @__PURE__ */ React27__namespace.default.forwardRef((props, ref)
|
|
|
3251
3244
|
innerProps: {
|
|
3252
3245
|
style: styleAlpha
|
|
3253
3246
|
},
|
|
3254
|
-
pointer: () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3247
|
+
pointer: () => /* @__PURE__ */ jsxRuntime.jsx(React25.Fragment, {})
|
|
3255
3248
|
})]
|
|
3256
3249
|
})]
|
|
3257
3250
|
}), editableDisable && /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
@@ -3366,19 +3359,19 @@ var Toolbar = ({
|
|
|
3366
3359
|
on_attachments_change,
|
|
3367
3360
|
disabled = false
|
|
3368
3361
|
}) => {
|
|
3369
|
-
const [link_url, set_link_url] =
|
|
3370
|
-
const [link_popover_open, set_link_popover_open] =
|
|
3371
|
-
const [text_color_open, set_text_color_open] =
|
|
3372
|
-
const [highlight_color_open, set_highlight_color_open] =
|
|
3373
|
-
const [variables_menu_open, set_variables_menu_open] =
|
|
3374
|
-
const [table_menu_open, set_table_menu_open] =
|
|
3375
|
-
const [text_color, set_text_color] =
|
|
3376
|
-
const [highlight_color, set_highlight_color] =
|
|
3377
|
-
const [table_rows, set_table_rows] =
|
|
3378
|
-
const [table_cols, set_table_cols] =
|
|
3379
|
-
const [hovered_cell, set_hovered_cell] =
|
|
3380
|
-
const file_input_ref =
|
|
3381
|
-
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);
|
|
3382
3375
|
if (!editor) {
|
|
3383
3376
|
return null;
|
|
3384
3377
|
}
|
|
@@ -4311,7 +4304,7 @@ var VariableExtension = core.Node.create({
|
|
|
4311
4304
|
}
|
|
4312
4305
|
});
|
|
4313
4306
|
var Tabs = TabsPrimitive__namespace.Root;
|
|
4314
|
-
var TabsList =
|
|
4307
|
+
var TabsList = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4315
4308
|
TabsPrimitive__namespace.List,
|
|
4316
4309
|
{
|
|
4317
4310
|
ref,
|
|
@@ -4323,7 +4316,7 @@ var TabsList = React27__namespace.forwardRef(({ className, ...props }, ref) => /
|
|
|
4323
4316
|
}
|
|
4324
4317
|
));
|
|
4325
4318
|
TabsList.displayName = TabsPrimitive__namespace.List.displayName;
|
|
4326
|
-
var TabsTrigger =
|
|
4319
|
+
var TabsTrigger = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4327
4320
|
TabsPrimitive__namespace.Trigger,
|
|
4328
4321
|
{
|
|
4329
4322
|
ref,
|
|
@@ -4335,7 +4328,7 @@ var TabsTrigger = React27__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
4335
4328
|
}
|
|
4336
4329
|
));
|
|
4337
4330
|
TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
|
|
4338
|
-
var TabsContent =
|
|
4331
|
+
var TabsContent = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4339
4332
|
TabsPrimitive__namespace.Content,
|
|
4340
4333
|
{
|
|
4341
4334
|
ref,
|
|
@@ -4370,14 +4363,14 @@ var HazoUiRte = ({
|
|
|
4370
4363
|
className,
|
|
4371
4364
|
show_output_viewer = false
|
|
4372
4365
|
}) => {
|
|
4373
|
-
const [attachments, set_attachments] =
|
|
4366
|
+
const [attachments, set_attachments] = React25__namespace.useState(
|
|
4374
4367
|
initial_attachments
|
|
4375
4368
|
);
|
|
4376
|
-
const [active_tab, set_active_tab] =
|
|
4369
|
+
const [active_tab, set_active_tab] = React25__namespace.useState("html");
|
|
4377
4370
|
const is_view_only = active_tab !== "html";
|
|
4378
|
-
const attachments_ref =
|
|
4371
|
+
const attachments_ref = React25__namespace.useRef(attachments);
|
|
4379
4372
|
attachments_ref.current = attachments;
|
|
4380
|
-
const debounced_on_change =
|
|
4373
|
+
const debounced_on_change = React25__namespace.useMemo(
|
|
4381
4374
|
() => debounce_fn((output) => {
|
|
4382
4375
|
if (on_change) {
|
|
4383
4376
|
on_change(output);
|
|
@@ -4476,7 +4469,7 @@ var HazoUiRte = ({
|
|
|
4476
4469
|
debounced_on_change(output);
|
|
4477
4470
|
}
|
|
4478
4471
|
});
|
|
4479
|
-
|
|
4472
|
+
React25__namespace.useEffect(() => {
|
|
4480
4473
|
if (editor && html !== void 0) {
|
|
4481
4474
|
const current_html = editor.getHTML();
|
|
4482
4475
|
if (html !== current_html && !editor.isFocused) {
|
|
@@ -4484,21 +4477,21 @@ var HazoUiRte = ({
|
|
|
4484
4477
|
}
|
|
4485
4478
|
}
|
|
4486
4479
|
}, [html, editor]);
|
|
4487
|
-
|
|
4480
|
+
React25__namespace.useEffect(() => {
|
|
4488
4481
|
if (editor) {
|
|
4489
4482
|
editor.setEditable(!disabled);
|
|
4490
4483
|
}
|
|
4491
4484
|
}, [disabled, editor]);
|
|
4492
|
-
const attachments_from_props_ref =
|
|
4493
|
-
const prev_initial_attachments_ref =
|
|
4494
|
-
|
|
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(() => {
|
|
4495
4488
|
if (JSON.stringify(initial_attachments) !== JSON.stringify(prev_initial_attachments_ref.current)) {
|
|
4496
4489
|
prev_initial_attachments_ref.current = initial_attachments;
|
|
4497
4490
|
attachments_from_props_ref.current = true;
|
|
4498
4491
|
set_attachments(initial_attachments);
|
|
4499
4492
|
}
|
|
4500
4493
|
}, [initial_attachments]);
|
|
4501
|
-
|
|
4494
|
+
React25__namespace.useEffect(() => {
|
|
4502
4495
|
if (attachments_from_props_ref.current) {
|
|
4503
4496
|
attachments_from_props_ref.current = false;
|
|
4504
4497
|
return;
|
|
@@ -5000,12 +4993,12 @@ var CommandPopover = ({
|
|
|
5000
4993
|
on_selection_change: _on_selection_change,
|
|
5001
4994
|
prefix_color
|
|
5002
4995
|
}) => {
|
|
5003
|
-
const container_ref =
|
|
5004
|
-
const grouped_commands =
|
|
4996
|
+
const container_ref = React25__namespace.useRef(null);
|
|
4997
|
+
const grouped_commands = React25__namespace.useMemo(
|
|
5005
4998
|
() => group_commands(commands),
|
|
5006
4999
|
[commands]
|
|
5007
5000
|
);
|
|
5008
|
-
|
|
5001
|
+
React25__namespace.useEffect(() => {
|
|
5009
5002
|
const handle_click_outside = (e) => {
|
|
5010
5003
|
if (container_ref.current && !container_ref.current.contains(e.target)) {
|
|
5011
5004
|
on_close();
|
|
@@ -5018,8 +5011,8 @@ var CommandPopover = ({
|
|
|
5018
5011
|
};
|
|
5019
5012
|
}
|
|
5020
5013
|
}, [is_open, on_close]);
|
|
5021
|
-
const [mounted, set_mounted] =
|
|
5022
|
-
|
|
5014
|
+
const [mounted, set_mounted] = React25__namespace.useState(false);
|
|
5015
|
+
React25__namespace.useEffect(() => {
|
|
5023
5016
|
set_mounted(true);
|
|
5024
5017
|
}, []);
|
|
5025
5018
|
if (!is_open || !mounted) return null;
|
|
@@ -5329,21 +5322,21 @@ var HazoUiTextbox = ({
|
|
|
5329
5322
|
on_command_change,
|
|
5330
5323
|
on_command_remove
|
|
5331
5324
|
}) => {
|
|
5332
|
-
const generated_instance_id =
|
|
5325
|
+
const generated_instance_id = React25__namespace.useId();
|
|
5333
5326
|
const instance_id = provided_instance_id || generated_instance_id;
|
|
5334
|
-
const [suggestion_state, set_suggestion_state] =
|
|
5335
|
-
const [selected_index, set_selected_index] =
|
|
5336
|
-
const [popover_position, set_popover_position] =
|
|
5337
|
-
const [edit_context, set_edit_context] =
|
|
5338
|
-
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);
|
|
5339
5332
|
const is_controlled = value !== void 0;
|
|
5340
|
-
const editor_container_ref =
|
|
5341
|
-
const edit_popover_ref =
|
|
5342
|
-
const [mounted, set_mounted] =
|
|
5343
|
-
|
|
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(() => {
|
|
5344
5337
|
set_mounted(true);
|
|
5345
5338
|
}, []);
|
|
5346
|
-
const suggestion_extensions =
|
|
5339
|
+
const suggestion_extensions = React25__namespace.useMemo(() => {
|
|
5347
5340
|
return create_command_suggestion_extension({
|
|
5348
5341
|
prefixes,
|
|
5349
5342
|
instance_id,
|
|
@@ -5394,7 +5387,7 @@ var HazoUiTextbox = ({
|
|
|
5394
5387
|
}
|
|
5395
5388
|
}
|
|
5396
5389
|
});
|
|
5397
|
-
|
|
5390
|
+
React25__namespace.useEffect(() => {
|
|
5398
5391
|
if (suggestion_state?.is_active && editor) {
|
|
5399
5392
|
requestAnimationFrame(() => {
|
|
5400
5393
|
const { from } = suggestion_state.range;
|
|
@@ -5418,7 +5411,7 @@ var HazoUiTextbox = ({
|
|
|
5418
5411
|
});
|
|
5419
5412
|
}
|
|
5420
5413
|
}, [suggestion_state, editor]);
|
|
5421
|
-
|
|
5414
|
+
React25__namespace.useEffect(() => {
|
|
5422
5415
|
if (is_controlled && editor && !editor.isFocused) {
|
|
5423
5416
|
const current_text = editor.getText();
|
|
5424
5417
|
if (value !== current_text) {
|
|
@@ -5427,12 +5420,12 @@ var HazoUiTextbox = ({
|
|
|
5427
5420
|
}
|
|
5428
5421
|
}
|
|
5429
5422
|
}, [value, editor, is_controlled, prefixes, pill_variant]);
|
|
5430
|
-
|
|
5423
|
+
React25__namespace.useEffect(() => {
|
|
5431
5424
|
if (editor) {
|
|
5432
5425
|
editor.setEditable(!disabled);
|
|
5433
5426
|
}
|
|
5434
5427
|
}, [disabled, editor]);
|
|
5435
|
-
const handle_command_select =
|
|
5428
|
+
const handle_command_select = React25__namespace.useCallback(
|
|
5436
5429
|
(command) => {
|
|
5437
5430
|
if (!editor || !suggestion_state) return;
|
|
5438
5431
|
const prefix_config = prefixes.find((p) => p.char === suggestion_state.prefix);
|
|
@@ -5452,15 +5445,15 @@ var HazoUiTextbox = ({
|
|
|
5452
5445
|
},
|
|
5453
5446
|
[editor, suggestion_state, pill_variant, on_command_insert, prefixes]
|
|
5454
5447
|
);
|
|
5455
|
-
const handle_popover_close =
|
|
5448
|
+
const handle_popover_close = React25__namespace.useCallback(() => {
|
|
5456
5449
|
set_suggestion_state(null);
|
|
5457
5450
|
editor?.commands.focus();
|
|
5458
5451
|
}, [editor]);
|
|
5459
|
-
const handle_edit_close =
|
|
5452
|
+
const handle_edit_close = React25__namespace.useCallback(() => {
|
|
5460
5453
|
set_edit_context(null);
|
|
5461
5454
|
editor?.commands.focus();
|
|
5462
5455
|
}, [editor]);
|
|
5463
|
-
const handle_command_update =
|
|
5456
|
+
const handle_command_update = React25__namespace.useCallback(
|
|
5464
5457
|
(new_command) => {
|
|
5465
5458
|
if (!editor || !edit_context) return;
|
|
5466
5459
|
const old_command = edit_context.command;
|
|
@@ -5476,7 +5469,7 @@ var HazoUiTextbox = ({
|
|
|
5476
5469
|
},
|
|
5477
5470
|
[editor, edit_context, on_command_change]
|
|
5478
5471
|
);
|
|
5479
|
-
const handle_command_remove =
|
|
5472
|
+
const handle_command_remove = React25__namespace.useCallback(() => {
|
|
5480
5473
|
if (!editor || !edit_context) return;
|
|
5481
5474
|
const command = edit_context.command;
|
|
5482
5475
|
editor.state.doc.descendants((node, pos) => {
|
|
@@ -5490,7 +5483,7 @@ var HazoUiTextbox = ({
|
|
|
5490
5483
|
}
|
|
5491
5484
|
set_edit_context(null);
|
|
5492
5485
|
}, [editor, edit_context, on_command_remove]);
|
|
5493
|
-
const filtered_commands =
|
|
5486
|
+
const filtered_commands = React25__namespace.useMemo(() => {
|
|
5494
5487
|
if (!suggestion_state) return [];
|
|
5495
5488
|
const query = suggestion_state.query.toLowerCase();
|
|
5496
5489
|
if (!query) return suggestion_state.commands;
|
|
@@ -5498,7 +5491,7 @@ var HazoUiTextbox = ({
|
|
|
5498
5491
|
(cmd) => cmd.action_label.toLowerCase().includes(query) || cmd.action.toLowerCase().includes(query) || cmd.action_description?.toLowerCase().includes(query)
|
|
5499
5492
|
);
|
|
5500
5493
|
}, [suggestion_state]);
|
|
5501
|
-
|
|
5494
|
+
React25__namespace.useEffect(() => {
|
|
5502
5495
|
if (!suggestion_state?.is_active) return;
|
|
5503
5496
|
const handle_keydown = (e) => {
|
|
5504
5497
|
switch (e.key) {
|
|
@@ -5533,7 +5526,7 @@ var HazoUiTextbox = ({
|
|
|
5533
5526
|
handle_command_select,
|
|
5534
5527
|
handle_popover_close
|
|
5535
5528
|
]);
|
|
5536
|
-
|
|
5529
|
+
React25__namespace.useEffect(() => {
|
|
5537
5530
|
if (!edit_context) return;
|
|
5538
5531
|
const handle_click_outside = (e) => {
|
|
5539
5532
|
if (edit_popover_ref.current && !edit_popover_ref.current.contains(e.target)) {
|
|
@@ -5548,12 +5541,12 @@ var HazoUiTextbox = ({
|
|
|
5548
5541
|
document.removeEventListener("mousedown", handle_click_outside);
|
|
5549
5542
|
};
|
|
5550
5543
|
}, [edit_context]);
|
|
5551
|
-
const edit_commands =
|
|
5544
|
+
const edit_commands = React25__namespace.useMemo(() => {
|
|
5552
5545
|
if (!edit_context) return [];
|
|
5553
5546
|
const prefix_config = prefixes.find((p) => p.char === edit_context.command.prefix);
|
|
5554
5547
|
return prefix_config?.commands || [];
|
|
5555
5548
|
}, [edit_context, prefixes]);
|
|
5556
|
-
|
|
5549
|
+
React25__namespace.useEffect(() => {
|
|
5557
5550
|
if (!edit_context) return;
|
|
5558
5551
|
const handle_keydown = (e) => {
|
|
5559
5552
|
switch (e.key) {
|
|
@@ -5591,7 +5584,7 @@ var HazoUiTextbox = ({
|
|
|
5591
5584
|
handle_command_remove,
|
|
5592
5585
|
handle_edit_close
|
|
5593
5586
|
]);
|
|
5594
|
-
|
|
5587
|
+
React25__namespace.useEffect(() => {
|
|
5595
5588
|
const handle_pill_click = (e) => {
|
|
5596
5589
|
const detail = e.detail;
|
|
5597
5590
|
const { id, prefix, action, action_label, node_pos } = detail;
|
|
@@ -5874,22 +5867,22 @@ var HazoUiTextarea = ({
|
|
|
5874
5867
|
on_command_change,
|
|
5875
5868
|
on_command_remove
|
|
5876
5869
|
}) => {
|
|
5877
|
-
const generated_instance_id =
|
|
5870
|
+
const generated_instance_id = React25__namespace.useId();
|
|
5878
5871
|
const instance_id = provided_instance_id || generated_instance_id;
|
|
5879
|
-
const [suggestion_state, set_suggestion_state] =
|
|
5880
|
-
const [selected_index, set_selected_index] =
|
|
5881
|
-
const [popover_position, set_popover_position] =
|
|
5882
|
-
const [edit_context, set_edit_context] =
|
|
5883
|
-
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);
|
|
5884
5877
|
const is_controlled = value !== void 0;
|
|
5885
|
-
const editor_container_ref =
|
|
5886
|
-
const edit_popover_ref =
|
|
5887
|
-
const [mounted, set_mounted] =
|
|
5888
|
-
|
|
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(() => {
|
|
5889
5882
|
set_mounted(true);
|
|
5890
5883
|
}, []);
|
|
5891
5884
|
const calculated_min_height = rows ? `${rows * 1.5}em` : min_height;
|
|
5892
|
-
const suggestion_extensions =
|
|
5885
|
+
const suggestion_extensions = React25__namespace.useMemo(() => {
|
|
5893
5886
|
return create_command_suggestion_extension({
|
|
5894
5887
|
prefixes,
|
|
5895
5888
|
instance_id,
|
|
@@ -5938,7 +5931,7 @@ var HazoUiTextarea = ({
|
|
|
5938
5931
|
}
|
|
5939
5932
|
}
|
|
5940
5933
|
});
|
|
5941
|
-
|
|
5934
|
+
React25__namespace.useEffect(() => {
|
|
5942
5935
|
if (suggestion_state?.is_active && editor) {
|
|
5943
5936
|
requestAnimationFrame(() => {
|
|
5944
5937
|
const { from } = suggestion_state.range;
|
|
@@ -5962,7 +5955,7 @@ var HazoUiTextarea = ({
|
|
|
5962
5955
|
});
|
|
5963
5956
|
}
|
|
5964
5957
|
}, [suggestion_state, editor]);
|
|
5965
|
-
|
|
5958
|
+
React25__namespace.useEffect(() => {
|
|
5966
5959
|
if (is_controlled && editor && !editor.isFocused) {
|
|
5967
5960
|
const current_text = editor.getText();
|
|
5968
5961
|
if (value !== current_text) {
|
|
@@ -5975,12 +5968,12 @@ var HazoUiTextarea = ({
|
|
|
5975
5968
|
}
|
|
5976
5969
|
}
|
|
5977
5970
|
}, [value, editor, is_controlled, prefixes, pill_variant]);
|
|
5978
|
-
|
|
5971
|
+
React25__namespace.useEffect(() => {
|
|
5979
5972
|
if (editor) {
|
|
5980
5973
|
editor.setEditable(!disabled);
|
|
5981
5974
|
}
|
|
5982
5975
|
}, [disabled, editor]);
|
|
5983
|
-
const handle_command_select =
|
|
5976
|
+
const handle_command_select = React25__namespace.useCallback(
|
|
5984
5977
|
(command) => {
|
|
5985
5978
|
if (!editor || !suggestion_state) return;
|
|
5986
5979
|
const prefix_config = prefixes.find((p) => p.char === suggestion_state.prefix);
|
|
@@ -6000,15 +5993,15 @@ var HazoUiTextarea = ({
|
|
|
6000
5993
|
},
|
|
6001
5994
|
[editor, suggestion_state, pill_variant, on_command_insert, prefixes]
|
|
6002
5995
|
);
|
|
6003
|
-
const handle_popover_close =
|
|
5996
|
+
const handle_popover_close = React25__namespace.useCallback(() => {
|
|
6004
5997
|
set_suggestion_state(null);
|
|
6005
5998
|
editor?.commands.focus();
|
|
6006
5999
|
}, [editor]);
|
|
6007
|
-
const handle_edit_close =
|
|
6000
|
+
const handle_edit_close = React25__namespace.useCallback(() => {
|
|
6008
6001
|
set_edit_context(null);
|
|
6009
6002
|
editor?.commands.focus();
|
|
6010
6003
|
}, [editor]);
|
|
6011
|
-
const handle_command_update =
|
|
6004
|
+
const handle_command_update = React25__namespace.useCallback(
|
|
6012
6005
|
(new_command) => {
|
|
6013
6006
|
if (!editor || !edit_context) return;
|
|
6014
6007
|
const old_command = edit_context.command;
|
|
@@ -6024,7 +6017,7 @@ var HazoUiTextarea = ({
|
|
|
6024
6017
|
},
|
|
6025
6018
|
[editor, edit_context, on_command_change]
|
|
6026
6019
|
);
|
|
6027
|
-
const handle_command_remove =
|
|
6020
|
+
const handle_command_remove = React25__namespace.useCallback(() => {
|
|
6028
6021
|
if (!editor || !edit_context) return;
|
|
6029
6022
|
const command = edit_context.command;
|
|
6030
6023
|
editor.state.doc.descendants((node, pos) => {
|
|
@@ -6038,7 +6031,7 @@ var HazoUiTextarea = ({
|
|
|
6038
6031
|
}
|
|
6039
6032
|
set_edit_context(null);
|
|
6040
6033
|
}, [editor, edit_context, on_command_remove]);
|
|
6041
|
-
const filtered_commands =
|
|
6034
|
+
const filtered_commands = React25__namespace.useMemo(() => {
|
|
6042
6035
|
if (!suggestion_state) return [];
|
|
6043
6036
|
const query = suggestion_state.query.toLowerCase();
|
|
6044
6037
|
if (!query) return suggestion_state.commands;
|
|
@@ -6046,7 +6039,7 @@ var HazoUiTextarea = ({
|
|
|
6046
6039
|
(cmd) => cmd.action_label.toLowerCase().includes(query) || cmd.action.toLowerCase().includes(query) || cmd.action_description?.toLowerCase().includes(query)
|
|
6047
6040
|
);
|
|
6048
6041
|
}, [suggestion_state]);
|
|
6049
|
-
|
|
6042
|
+
React25__namespace.useEffect(() => {
|
|
6050
6043
|
if (!suggestion_state?.is_active) return;
|
|
6051
6044
|
const handle_keydown = (e) => {
|
|
6052
6045
|
switch (e.key) {
|
|
@@ -6081,7 +6074,7 @@ var HazoUiTextarea = ({
|
|
|
6081
6074
|
handle_command_select,
|
|
6082
6075
|
handle_popover_close
|
|
6083
6076
|
]);
|
|
6084
|
-
|
|
6077
|
+
React25__namespace.useEffect(() => {
|
|
6085
6078
|
if (!edit_context) return;
|
|
6086
6079
|
const handle_click_outside = (e) => {
|
|
6087
6080
|
if (edit_popover_ref.current && !edit_popover_ref.current.contains(e.target)) {
|
|
@@ -6096,12 +6089,12 @@ var HazoUiTextarea = ({
|
|
|
6096
6089
|
document.removeEventListener("mousedown", handle_click_outside);
|
|
6097
6090
|
};
|
|
6098
6091
|
}, [edit_context]);
|
|
6099
|
-
const edit_commands =
|
|
6092
|
+
const edit_commands = React25__namespace.useMemo(() => {
|
|
6100
6093
|
if (!edit_context) return [];
|
|
6101
6094
|
const prefix_config = prefixes.find((p) => p.char === edit_context.command.prefix);
|
|
6102
6095
|
return prefix_config?.commands || [];
|
|
6103
6096
|
}, [edit_context, prefixes]);
|
|
6104
|
-
|
|
6097
|
+
React25__namespace.useEffect(() => {
|
|
6105
6098
|
if (!edit_context) return;
|
|
6106
6099
|
const handle_keydown = (e) => {
|
|
6107
6100
|
switch (e.key) {
|
|
@@ -6139,7 +6132,7 @@ var HazoUiTextarea = ({
|
|
|
6139
6132
|
handle_command_remove,
|
|
6140
6133
|
handle_edit_close
|
|
6141
6134
|
]);
|
|
6142
|
-
|
|
6135
|
+
React25__namespace.useEffect(() => {
|
|
6143
6136
|
const handle_pill_click = (e) => {
|
|
6144
6137
|
const detail = e.detail;
|
|
6145
6138
|
const { id, prefix, action, action_label, node_pos } = detail;
|
|
@@ -6686,7 +6679,7 @@ function HazoUiConfirmDialog({
|
|
|
6686
6679
|
openAnimation = "zoom",
|
|
6687
6680
|
closeAnimation = "zoom"
|
|
6688
6681
|
}) {
|
|
6689
|
-
const [internal_loading, set_internal_loading] =
|
|
6682
|
+
const [internal_loading, set_internal_loading] = React25__namespace.useState(false);
|
|
6690
6683
|
const config = get_hazo_ui_config();
|
|
6691
6684
|
const variant_preset = variant !== "default" ? CONFIRM_VARIANT_PRESETS[variant] : void 0;
|
|
6692
6685
|
const is_loading = external_loading ?? internal_loading;
|
|
@@ -6723,7 +6716,7 @@ function HazoUiConfirmDialog({
|
|
|
6723
6716
|
onCancel?.();
|
|
6724
6717
|
onOpenChange(false);
|
|
6725
6718
|
};
|
|
6726
|
-
const cancel_ref =
|
|
6719
|
+
const cancel_ref = React25__namespace.useRef(null);
|
|
6727
6720
|
return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
|
|
6728
6721
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6729
6722
|
DialogOverlay,
|
|
@@ -6808,7 +6801,7 @@ Drawer.displayName = "Drawer";
|
|
|
6808
6801
|
var DrawerTrigger = vaul.Drawer.Trigger;
|
|
6809
6802
|
var DrawerPortal = vaul.Drawer.Portal;
|
|
6810
6803
|
var DrawerClose = vaul.Drawer.Close;
|
|
6811
|
-
var DrawerOverlay =
|
|
6804
|
+
var DrawerOverlay = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6812
6805
|
vaul.Drawer.Overlay,
|
|
6813
6806
|
{
|
|
6814
6807
|
ref,
|
|
@@ -6820,7 +6813,7 @@ var DrawerOverlay = React27__namespace.forwardRef(({ className, ...props }, ref)
|
|
|
6820
6813
|
}
|
|
6821
6814
|
));
|
|
6822
6815
|
DrawerOverlay.displayName = "DrawerOverlay";
|
|
6823
|
-
var DrawerContent =
|
|
6816
|
+
var DrawerContent = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DrawerPortal, { children: [
|
|
6824
6817
|
/* @__PURE__ */ jsxRuntime.jsx(DrawerOverlay, {}),
|
|
6825
6818
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
6826
6819
|
vaul.Drawer.Content,
|
|
@@ -6861,7 +6854,7 @@ var DrawerFooter = ({
|
|
|
6861
6854
|
}
|
|
6862
6855
|
);
|
|
6863
6856
|
DrawerFooter.displayName = "DrawerFooter";
|
|
6864
|
-
var DrawerTitle =
|
|
6857
|
+
var DrawerTitle = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6865
6858
|
vaul.Drawer.Title,
|
|
6866
6859
|
{
|
|
6867
6860
|
ref,
|
|
@@ -6873,7 +6866,7 @@ var DrawerTitle = React27__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
6873
6866
|
}
|
|
6874
6867
|
));
|
|
6875
6868
|
DrawerTitle.displayName = "DrawerTitle";
|
|
6876
|
-
var DrawerDescription =
|
|
6869
|
+
var DrawerDescription = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6877
6870
|
vaul.Drawer.Description,
|
|
6878
6871
|
{
|
|
6879
6872
|
ref,
|
|
@@ -6883,14 +6876,14 @@ var DrawerDescription = React27__namespace.forwardRef(({ className, ...props },
|
|
|
6883
6876
|
));
|
|
6884
6877
|
DrawerDescription.displayName = "DrawerDescription";
|
|
6885
6878
|
function useMediaQuery(query) {
|
|
6886
|
-
const get_match =
|
|
6879
|
+
const get_match = React25__namespace.useCallback(() => {
|
|
6887
6880
|
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
6888
6881
|
return false;
|
|
6889
6882
|
}
|
|
6890
6883
|
return window.matchMedia(query).matches;
|
|
6891
6884
|
}, [query]);
|
|
6892
|
-
const [matches, set_matches] =
|
|
6893
|
-
|
|
6885
|
+
const [matches, set_matches] = React25__namespace.useState(false);
|
|
6886
|
+
React25__namespace.useEffect(() => {
|
|
6894
6887
|
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
6895
6888
|
return;
|
|
6896
6889
|
}
|
|
@@ -6907,7 +6900,7 @@ function useMediaQuery(query) {
|
|
|
6907
6900
|
return matches;
|
|
6908
6901
|
}
|
|
6909
6902
|
var Accordion = AccordionPrimitive__namespace.Root;
|
|
6910
|
-
var AccordionItem =
|
|
6903
|
+
var AccordionItem = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6911
6904
|
AccordionPrimitive__namespace.Item,
|
|
6912
6905
|
{
|
|
6913
6906
|
ref,
|
|
@@ -6916,7 +6909,7 @@ var AccordionItem = React27__namespace.forwardRef(({ className, ...props }, ref)
|
|
|
6916
6909
|
}
|
|
6917
6910
|
));
|
|
6918
6911
|
AccordionItem.displayName = "AccordionItem";
|
|
6919
|
-
var AccordionTrigger =
|
|
6912
|
+
var AccordionTrigger = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(AccordionPrimitive__namespace.Header, { className: "flex", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6920
6913
|
AccordionPrimitive__namespace.Trigger,
|
|
6921
6914
|
{
|
|
6922
6915
|
ref,
|
|
@@ -6932,7 +6925,7 @@ var AccordionTrigger = React27__namespace.forwardRef(({ className, children, ...
|
|
|
6932
6925
|
}
|
|
6933
6926
|
) }));
|
|
6934
6927
|
AccordionTrigger.displayName = AccordionPrimitive__namespace.Trigger.displayName;
|
|
6935
|
-
var AccordionContent =
|
|
6928
|
+
var AccordionContent = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6936
6929
|
AccordionPrimitive__namespace.Content,
|
|
6937
6930
|
{
|
|
6938
6931
|
ref,
|
|
@@ -6942,7 +6935,7 @@ var AccordionContent = React27__namespace.forwardRef(({ className, children, ...
|
|
|
6942
6935
|
}
|
|
6943
6936
|
));
|
|
6944
6937
|
AccordionContent.displayName = AccordionPrimitive__namespace.Content.displayName;
|
|
6945
|
-
var Checkbox =
|
|
6938
|
+
var Checkbox = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6946
6939
|
CheckboxPrimitive__namespace.Root,
|
|
6947
6940
|
{
|
|
6948
6941
|
ref,
|
|
@@ -6967,7 +6960,7 @@ var DropdownMenuGroup = DropdownMenuPrimitive__namespace.Group;
|
|
|
6967
6960
|
var DropdownMenuPortal = DropdownMenuPrimitive__namespace.Portal;
|
|
6968
6961
|
var DropdownMenuSub = DropdownMenuPrimitive__namespace.Sub;
|
|
6969
6962
|
var DropdownMenuRadioGroup = DropdownMenuPrimitive__namespace.RadioGroup;
|
|
6970
|
-
var DropdownMenuSubTrigger =
|
|
6963
|
+
var DropdownMenuSubTrigger = React25__namespace.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6971
6964
|
DropdownMenuPrimitive__namespace.SubTrigger,
|
|
6972
6965
|
{
|
|
6973
6966
|
ref,
|
|
@@ -6984,7 +6977,7 @@ var DropdownMenuSubTrigger = React27__namespace.forwardRef(({ className, inset,
|
|
|
6984
6977
|
}
|
|
6985
6978
|
));
|
|
6986
6979
|
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive__namespace.SubTrigger.displayName;
|
|
6987
|
-
var DropdownMenuSubContent =
|
|
6980
|
+
var DropdownMenuSubContent = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6988
6981
|
DropdownMenuPrimitive__namespace.SubContent,
|
|
6989
6982
|
{
|
|
6990
6983
|
ref,
|
|
@@ -6996,7 +6989,7 @@ var DropdownMenuSubContent = React27__namespace.forwardRef(({ className, ...prop
|
|
|
6996
6989
|
}
|
|
6997
6990
|
));
|
|
6998
6991
|
DropdownMenuSubContent.displayName = DropdownMenuPrimitive__namespace.SubContent.displayName;
|
|
6999
|
-
var DropdownMenuContent =
|
|
6992
|
+
var DropdownMenuContent = React25__namespace.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7000
6993
|
DropdownMenuPrimitive__namespace.Content,
|
|
7001
6994
|
{
|
|
7002
6995
|
ref,
|
|
@@ -7009,7 +7002,7 @@ var DropdownMenuContent = React27__namespace.forwardRef(({ className, sideOffset
|
|
|
7009
7002
|
}
|
|
7010
7003
|
) }));
|
|
7011
7004
|
DropdownMenuContent.displayName = DropdownMenuPrimitive__namespace.Content.displayName;
|
|
7012
|
-
var DropdownMenuItem =
|
|
7005
|
+
var DropdownMenuItem = React25__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7013
7006
|
DropdownMenuPrimitive__namespace.Item,
|
|
7014
7007
|
{
|
|
7015
7008
|
ref,
|
|
@@ -7022,7 +7015,7 @@ var DropdownMenuItem = React27__namespace.forwardRef(({ className, inset, ...pro
|
|
|
7022
7015
|
}
|
|
7023
7016
|
));
|
|
7024
7017
|
DropdownMenuItem.displayName = DropdownMenuPrimitive__namespace.Item.displayName;
|
|
7025
|
-
var DropdownMenuCheckboxItem =
|
|
7018
|
+
var DropdownMenuCheckboxItem = React25__namespace.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7026
7019
|
DropdownMenuPrimitive__namespace.CheckboxItem,
|
|
7027
7020
|
{
|
|
7028
7021
|
ref,
|
|
@@ -7039,7 +7032,7 @@ var DropdownMenuCheckboxItem = React27__namespace.forwardRef(({ className, child
|
|
|
7039
7032
|
}
|
|
7040
7033
|
));
|
|
7041
7034
|
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive__namespace.CheckboxItem.displayName;
|
|
7042
|
-
var DropdownMenuRadioItem =
|
|
7035
|
+
var DropdownMenuRadioItem = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7043
7036
|
DropdownMenuPrimitive__namespace.RadioItem,
|
|
7044
7037
|
{
|
|
7045
7038
|
ref,
|
|
@@ -7055,7 +7048,7 @@ var DropdownMenuRadioItem = React27__namespace.forwardRef(({ className, children
|
|
|
7055
7048
|
}
|
|
7056
7049
|
));
|
|
7057
7050
|
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive__namespace.RadioItem.displayName;
|
|
7058
|
-
var DropdownMenuLabel =
|
|
7051
|
+
var DropdownMenuLabel = React25__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7059
7052
|
DropdownMenuPrimitive__namespace.Label,
|
|
7060
7053
|
{
|
|
7061
7054
|
ref,
|
|
@@ -7068,7 +7061,7 @@ var DropdownMenuLabel = React27__namespace.forwardRef(({ className, inset, ...pr
|
|
|
7068
7061
|
}
|
|
7069
7062
|
));
|
|
7070
7063
|
DropdownMenuLabel.displayName = DropdownMenuPrimitive__namespace.Label.displayName;
|
|
7071
|
-
var DropdownMenuSeparator =
|
|
7064
|
+
var DropdownMenuSeparator = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7072
7065
|
DropdownMenuPrimitive__namespace.Separator,
|
|
7073
7066
|
{
|
|
7074
7067
|
ref,
|
|
@@ -7092,7 +7085,7 @@ var DropdownMenuShortcut = ({
|
|
|
7092
7085
|
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
|
7093
7086
|
var HoverCard = HoverCardPrimitive__namespace.Root;
|
|
7094
7087
|
var HoverCardTrigger = HoverCardPrimitive__namespace.Trigger;
|
|
7095
|
-
var HoverCardContent =
|
|
7088
|
+
var HoverCardContent = React25__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7096
7089
|
HoverCardPrimitive__namespace.Content,
|
|
7097
7090
|
{
|
|
7098
7091
|
ref,
|
|
@@ -7106,28 +7099,64 @@ var HoverCardContent = React27__namespace.forwardRef(({ className, align = "cent
|
|
|
7106
7099
|
}
|
|
7107
7100
|
));
|
|
7108
7101
|
HoverCardContent.displayName = HoverCardPrimitive__namespace.Content.displayName;
|
|
7109
|
-
var
|
|
7102
|
+
var Label3 = React25__namespace.forwardRef(
|
|
7110
7103
|
({ className, ...props }, ref) => {
|
|
7111
7104
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7112
|
-
"
|
|
7105
|
+
"label",
|
|
7113
7106
|
{
|
|
7107
|
+
ref,
|
|
7114
7108
|
className: cn(
|
|
7115
|
-
"
|
|
7116
|
-
"text-sm ring-offset-background",
|
|
7117
|
-
"placeholder:text-muted-foreground",
|
|
7118
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
7119
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
7109
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
7120
7110
|
className
|
|
7121
7111
|
),
|
|
7122
|
-
ref,
|
|
7123
7112
|
...props
|
|
7124
7113
|
}
|
|
7125
7114
|
);
|
|
7126
7115
|
}
|
|
7127
7116
|
);
|
|
7128
|
-
|
|
7129
|
-
var
|
|
7130
|
-
|
|
7117
|
+
Label3.displayName = "Label";
|
|
7118
|
+
var Switch = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7119
|
+
SwitchPrimitives__namespace.Root,
|
|
7120
|
+
{
|
|
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,
|
|
7131
7160
|
{
|
|
7132
7161
|
ref,
|
|
7133
7162
|
decorative,
|
|
@@ -7144,7 +7173,7 @@ Separator3.displayName = SeparatorPrimitive__namespace.Root.displayName;
|
|
|
7144
7173
|
var Collapsible = CollapsiblePrimitive__namespace.Root;
|
|
7145
7174
|
var CollapsibleTrigger2 = CollapsiblePrimitive__namespace.CollapsibleTrigger;
|
|
7146
7175
|
var CollapsibleContent2 = CollapsiblePrimitive__namespace.CollapsibleContent;
|
|
7147
|
-
var ScrollArea =
|
|
7176
|
+
var ScrollArea = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7148
7177
|
ScrollAreaPrimitive__namespace.Root,
|
|
7149
7178
|
{
|
|
7150
7179
|
ref,
|
|
@@ -7158,7 +7187,7 @@ var ScrollArea = React27__namespace.forwardRef(({ className, children, ...props
|
|
|
7158
7187
|
}
|
|
7159
7188
|
));
|
|
7160
7189
|
ScrollArea.displayName = ScrollAreaPrimitive__namespace.Root.displayName;
|
|
7161
|
-
var ScrollBar =
|
|
7190
|
+
var ScrollBar = React25__namespace.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7162
7191
|
ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,
|
|
7163
7192
|
{
|
|
7164
7193
|
ref,
|
|
@@ -7174,27 +7203,27 @@ var ScrollBar = React27__namespace.forwardRef(({ className, orientation = "verti
|
|
|
7174
7203
|
}
|
|
7175
7204
|
));
|
|
7176
7205
|
ScrollBar.displayName = ScrollAreaPrimitive__namespace.ScrollAreaScrollbar.displayName;
|
|
7177
|
-
var Card =
|
|
7206
|
+
var Card = React25__namespace.forwardRef(
|
|
7178
7207
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("rounded-lg border bg-card text-card-foreground shadow-sm", className), ...props })
|
|
7179
7208
|
);
|
|
7180
7209
|
Card.displayName = "Card";
|
|
7181
|
-
var CardHeader =
|
|
7210
|
+
var CardHeader = React25__namespace.forwardRef(
|
|
7182
7211
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex flex-col space-y-1.5 p-6", className), ...props })
|
|
7183
7212
|
);
|
|
7184
7213
|
CardHeader.displayName = "CardHeader";
|
|
7185
|
-
var CardTitle =
|
|
7214
|
+
var CardTitle = React25__namespace.forwardRef(
|
|
7186
7215
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("h3", { ref, className: cn("text-2xl font-semibold leading-none tracking-tight", className), ...props })
|
|
7187
7216
|
);
|
|
7188
7217
|
CardTitle.displayName = "CardTitle";
|
|
7189
|
-
var CardDescription =
|
|
7218
|
+
var CardDescription = React25__namespace.forwardRef(
|
|
7190
7219
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("p", { ref, className: cn("text-sm text-muted-foreground", className), ...props })
|
|
7191
7220
|
);
|
|
7192
7221
|
CardDescription.displayName = "CardDescription";
|
|
7193
|
-
var CardContent =
|
|
7222
|
+
var CardContent = React25__namespace.forwardRef(
|
|
7194
7223
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("p-6 pt-0", className), ...props })
|
|
7195
7224
|
);
|
|
7196
7225
|
CardContent.displayName = "CardContent";
|
|
7197
|
-
var CardFooter =
|
|
7226
|
+
var CardFooter = React25__namespace.forwardRef(
|
|
7198
7227
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex items-center p-6 pt-0", className), ...props })
|
|
7199
7228
|
);
|
|
7200
7229
|
CardFooter.displayName = "CardFooter";
|
|
@@ -7227,16 +7256,16 @@ var toggleVariants = classVarianceAuthority.cva(
|
|
|
7227
7256
|
defaultVariants: { variant: "default", size: "default" }
|
|
7228
7257
|
}
|
|
7229
7258
|
);
|
|
7230
|
-
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 }));
|
|
7231
7260
|
Toggle.displayName = TogglePrimitive__namespace.Root.displayName;
|
|
7232
|
-
var ToggleGroupContext =
|
|
7261
|
+
var ToggleGroupContext = React25__namespace.createContext({
|
|
7233
7262
|
size: "default",
|
|
7234
7263
|
variant: "default"
|
|
7235
7264
|
});
|
|
7236
|
-
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 }) }));
|
|
7237
7266
|
ToggleGroup.displayName = ToggleGroupPrimitive__namespace.Root.displayName;
|
|
7238
|
-
var ToggleGroupItem =
|
|
7239
|
-
const context =
|
|
7267
|
+
var ToggleGroupItem = React25__namespace.forwardRef(({ className, children, variant, size, ...props }, ref) => {
|
|
7268
|
+
const context = React25__namespace.useContext(ToggleGroupContext);
|
|
7240
7269
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7241
7270
|
ToggleGroupPrimitive__namespace.Item,
|
|
7242
7271
|
{
|
|
@@ -7251,7 +7280,7 @@ ToggleGroupItem.displayName = ToggleGroupPrimitive__namespace.Item.displayName;
|
|
|
7251
7280
|
var AlertDialog = AlertDialogPrimitive__namespace.Root;
|
|
7252
7281
|
var AlertDialogTrigger = AlertDialogPrimitive__namespace.Trigger;
|
|
7253
7282
|
var AlertDialogPortal = AlertDialogPrimitive__namespace.Portal;
|
|
7254
|
-
var AlertDialogOverlay =
|
|
7283
|
+
var AlertDialogOverlay = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7255
7284
|
AlertDialogPrimitive__namespace.Overlay,
|
|
7256
7285
|
{
|
|
7257
7286
|
ref,
|
|
@@ -7260,7 +7289,7 @@ var AlertDialogOverlay = React27__namespace.forwardRef(({ className, ...props },
|
|
|
7260
7289
|
}
|
|
7261
7290
|
));
|
|
7262
7291
|
AlertDialogOverlay.displayName = AlertDialogPrimitive__namespace.Overlay.displayName;
|
|
7263
|
-
var AlertDialogContent =
|
|
7292
|
+
var AlertDialogContent = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogPortal, { children: [
|
|
7264
7293
|
/* @__PURE__ */ jsxRuntime.jsx(AlertDialogOverlay, {}),
|
|
7265
7294
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7266
7295
|
AlertDialogPrimitive__namespace.Content,
|
|
@@ -7276,13 +7305,13 @@ var AlertDialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsxRuntime.
|
|
|
7276
7305
|
AlertDialogHeader.displayName = "AlertDialogHeader";
|
|
7277
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 });
|
|
7278
7307
|
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
7279
|
-
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 }));
|
|
7280
7309
|
AlertDialogTitle.displayName = AlertDialogPrimitive__namespace.Title.displayName;
|
|
7281
|
-
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 }));
|
|
7282
7311
|
AlertDialogDescription.displayName = AlertDialogPrimitive__namespace.Description.displayName;
|
|
7283
|
-
var AlertDialogAction =
|
|
7312
|
+
var AlertDialogAction = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(AlertDialogPrimitive__namespace.Action, { ref, className: cn(buttonVariants(), className), ...props }));
|
|
7284
7313
|
AlertDialogAction.displayName = AlertDialogPrimitive__namespace.Action.displayName;
|
|
7285
|
-
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 }));
|
|
7286
7315
|
AlertDialogCancel.displayName = AlertDialogPrimitive__namespace.Cancel.displayName;
|
|
7287
7316
|
var buttonGroupVariants = classVarianceAuthority.cva(
|
|
7288
7317
|
"flex w-fit items-stretch [&>*]:focus-visible:relative [&>*]:focus-visible:z-10",
|
|
@@ -7310,7 +7339,7 @@ function ButtonGroupText({ className, asChild = false, ...props }) {
|
|
|
7310
7339
|
function ButtonGroupSeparator({ className, orientation = "vertical", ...props }) {
|
|
7311
7340
|
return /* @__PURE__ */ jsxRuntime.jsx(Separator3, { orientation, className: cn("bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto", className), ...props });
|
|
7312
7341
|
}
|
|
7313
|
-
var SkeletonBase =
|
|
7342
|
+
var SkeletonBase = React25__namespace.forwardRef(
|
|
7314
7343
|
({ className, ...rest }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7315
7344
|
"div",
|
|
7316
7345
|
{
|
|
@@ -7486,8 +7515,8 @@ function LoadingTimeout({
|
|
|
7486
7515
|
firm: thresholds?.firm ?? 15e3,
|
|
7487
7516
|
expired: thresholds?.expired ?? 3e4
|
|
7488
7517
|
};
|
|
7489
|
-
const [phase, setPhase] =
|
|
7490
|
-
|
|
7518
|
+
const [phase, setPhase] = React25__namespace.useState(active ? "silent" : "idle");
|
|
7519
|
+
React25__namespace.useEffect(() => {
|
|
7491
7520
|
if (!active) {
|
|
7492
7521
|
setPhase("idle");
|
|
7493
7522
|
return;
|
|
@@ -7546,7 +7575,7 @@ function ProgressiveImage({
|
|
|
7546
7575
|
onLoad,
|
|
7547
7576
|
onError
|
|
7548
7577
|
}) {
|
|
7549
|
-
const [loaded, setLoaded] =
|
|
7578
|
+
const [loaded, setLoaded] = React25__namespace.useState(false);
|
|
7550
7579
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7551
7580
|
"div",
|
|
7552
7581
|
{
|
|
@@ -7627,8 +7656,8 @@ function errorToast({ title, description, duration = 5e3, action }) {
|
|
|
7627
7656
|
});
|
|
7628
7657
|
}
|
|
7629
7658
|
function useLoadingState(initial = false) {
|
|
7630
|
-
const [isLoading, setLoading] =
|
|
7631
|
-
const withLoading =
|
|
7659
|
+
const [isLoading, setLoading] = React25.useState(initial);
|
|
7660
|
+
const withLoading = React25.useCallback(async (fn) => {
|
|
7632
7661
|
setLoading(true);
|
|
7633
7662
|
try {
|
|
7634
7663
|
return await fn();
|
|
@@ -7639,8 +7668,8 @@ function useLoadingState(initial = false) {
|
|
|
7639
7668
|
return { isLoading, setLoading, withLoading };
|
|
7640
7669
|
}
|
|
7641
7670
|
function useErrorDisplay() {
|
|
7642
|
-
const [error, setRaw] =
|
|
7643
|
-
const setError =
|
|
7671
|
+
const [error, setRaw] = React25.useState(null);
|
|
7672
|
+
const setError = React25.useCallback((value) => {
|
|
7644
7673
|
if (value == null) {
|
|
7645
7674
|
setRaw(null);
|
|
7646
7675
|
return;
|
|
@@ -7655,9 +7684,1623 @@ function useErrorDisplay() {
|
|
|
7655
7684
|
}
|
|
7656
7685
|
setRaw(String(value));
|
|
7657
7686
|
}, []);
|
|
7658
|
-
const clearError =
|
|
7687
|
+
const clearError = React25.useCallback(() => setRaw(null), []);
|
|
7659
7688
|
return { error, setError, clearError };
|
|
7660
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
|
+
}
|
|
7661
9304
|
|
|
7662
9305
|
Object.defineProperty(exports, "rawToast", {
|
|
7663
9306
|
enumerable: true,
|
|
@@ -7739,10 +9382,13 @@ exports.HazoUiDialogTitle = DialogTitle;
|
|
|
7739
9382
|
exports.HazoUiDialogTrigger = DialogTrigger;
|
|
7740
9383
|
exports.HazoUiFlexInput = HazoUiFlexInput;
|
|
7741
9384
|
exports.HazoUiFlexRadio = HazoUiFlexRadio;
|
|
9385
|
+
exports.HazoUiKanban = HazoUiKanban;
|
|
9386
|
+
exports.HazoUiKanbanFilter = HazoUiKanbanFilter;
|
|
7742
9387
|
exports.HazoUiMultiFilterDialog = HazoUiMultiFilterDialog;
|
|
7743
9388
|
exports.HazoUiMultiSortDialog = HazoUiMultiSortDialog;
|
|
7744
9389
|
exports.HazoUiPillRadio = HazoUiPillRadio;
|
|
7745
9390
|
exports.HazoUiRte = HazoUiRte;
|
|
9391
|
+
exports.HazoUiTable = HazoUiTable;
|
|
7746
9392
|
exports.HazoUiTextarea = HazoUiTextarea;
|
|
7747
9393
|
exports.HazoUiTextbox = HazoUiTextbox;
|
|
7748
9394
|
exports.HazoUiToaster = HazoUiToaster;
|
|
@@ -7750,7 +9396,7 @@ exports.HoverCard = HoverCard;
|
|
|
7750
9396
|
exports.HoverCardContent = HoverCardContent;
|
|
7751
9397
|
exports.HoverCardTrigger = HoverCardTrigger;
|
|
7752
9398
|
exports.Input = Input;
|
|
7753
|
-
exports.Label =
|
|
9399
|
+
exports.Label = Label3;
|
|
7754
9400
|
exports.LoadingTimeout = LoadingTimeout;
|
|
7755
9401
|
exports.Popover = Popover;
|
|
7756
9402
|
exports.PopoverContent = PopoverContent;
|
|
@@ -7784,6 +9430,14 @@ exports.SkeletonGroup = SkeletonGroup;
|
|
|
7784
9430
|
exports.SkeletonRect = SkeletonRect;
|
|
7785
9431
|
exports.Spinner = Spinner;
|
|
7786
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;
|
|
7787
9441
|
exports.Tabs = Tabs;
|
|
7788
9442
|
exports.TabsContent = TabsContent;
|
|
7789
9443
|
exports.TabsList = TabsList;
|
|
@@ -7796,6 +9450,7 @@ exports.Tooltip = Tooltip;
|
|
|
7796
9450
|
exports.TooltipContent = TooltipContent;
|
|
7797
9451
|
exports.TooltipProvider = TooltipProvider;
|
|
7798
9452
|
exports.TooltipTrigger = TooltipTrigger;
|
|
9453
|
+
exports.applyKanbanFilter = applyKanbanFilter;
|
|
7799
9454
|
exports.buttonGroupVariants = buttonGroupVariants;
|
|
7800
9455
|
exports.create_command_suggestion_extension = create_command_suggestion_extension;
|
|
7801
9456
|
exports.errorToast = errorToast;
|