@wealthx/shadcn 1.5.1 → 1.5.3
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/.turbo/turbo-build.log +115 -115
- package/CHANGELOG.md +12 -0
- package/dist/chunk-G2EWIP2N.mjs +960 -0
- package/dist/{chunk-MHHA7QGO.mjs → chunk-ODO6BUOF.mjs} +1 -1
- package/dist/chunk-PX4M67XQ.mjs +301 -0
- package/dist/{chunk-FYUSF5KO.mjs → chunk-QRVEI6J3.mjs} +1 -1
- package/dist/{chunk-42NEC57Y.mjs → chunk-RAKBWNQH.mjs} +272 -3
- package/dist/components/ui/{contact-alert-dialog.js → contact-alert-dialog/index.js} +1029 -593
- package/dist/components/ui/contact-alert-dialog/index.mjs +31 -0
- package/dist/components/ui/file-preview-dialog.js +407 -100
- package/dist/components/ui/file-preview-dialog.mjs +3 -1
- package/dist/components/ui/kanban-column.js +408 -113
- package/dist/components/ui/kanban-column.mjs +3 -2
- package/dist/components/ui/opportunity-card.js +383 -88
- package/dist/components/ui/opportunity-card.mjs +2 -1
- package/dist/components/ui/pipeline-board.js +424 -129
- package/dist/components/ui/pipeline-board.mjs +4 -3
- package/dist/index.js +3081 -2282
- package/dist/index.mjs +39 -35
- package/dist/styles.css +1 -1
- package/package.json +5 -4
- package/src/components/index.tsx +3 -2
- package/src/components/ui/contact-alert-dialog/builder-ui.tsx +556 -0
- package/src/components/ui/contact-alert-dialog/config.ts +262 -0
- package/src/components/ui/contact-alert-dialog/contact-alert-dialog.tsx +214 -0
- package/src/components/ui/contact-alert-dialog/index.tsx +15 -0
- package/src/components/ui/contact-alert-dialog/types.ts +61 -0
- package/src/components/ui/contact-alert-dialog/utils.ts +93 -0
- package/src/components/ui/file-preview-dialog.tsx +299 -99
- package/src/components/ui/opportunity-card.tsx +328 -1
- package/src/styles/styles-css.ts +1 -1
- package/tsup.config.ts +1 -1
- package/dist/chunk-5WMFKQZ6.mjs +0 -180
- package/dist/chunk-Y24TXIFJ.mjs +0 -518
- package/dist/components/ui/contact-alert-dialog.mjs +0 -27
- package/src/components/ui/contact-alert-dialog.tsx +0 -710
|
@@ -56,16 +56,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
56
56
|
));
|
|
57
57
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
58
58
|
|
|
59
|
-
// src/components/ui/contact-alert-dialog.tsx
|
|
59
|
+
// src/components/ui/contact-alert-dialog/index.tsx
|
|
60
60
|
var contact_alert_dialog_exports = {};
|
|
61
61
|
__export(contact_alert_dialog_exports, {
|
|
62
62
|
ALERT_QUERY_FIELDS: () => ALERT_QUERY_FIELDS,
|
|
63
|
+
AlertSharingType: () => AlertSharingType,
|
|
63
64
|
ContactAlertDialog: () => ContactAlertDialog,
|
|
64
|
-
ContactAlertQueryBuilder: () => ContactAlertQueryBuilder
|
|
65
|
+
ContactAlertQueryBuilder: () => ContactAlertQueryBuilder,
|
|
66
|
+
createAlertTree: () => createAlertTree
|
|
65
67
|
});
|
|
66
68
|
module.exports = __toCommonJS(contact_alert_dialog_exports);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
|
|
70
|
+
// src/components/ui/contact-alert-dialog/contact-alert-dialog.tsx
|
|
71
|
+
var React5 = __toESM(require("react"));
|
|
72
|
+
var import_ui4 = require("@react-awesome-query-builder/ui");
|
|
69
73
|
|
|
70
74
|
// src/components/ui/dialog.tsx
|
|
71
75
|
var import_lucide_react2 = require("lucide-react");
|
|
@@ -421,146 +425,14 @@ function Input(_a) {
|
|
|
421
425
|
);
|
|
422
426
|
}
|
|
423
427
|
|
|
424
|
-
// src/components/ui/input-group.tsx
|
|
425
|
-
var import_class_variance_authority2 = require("class-variance-authority");
|
|
426
|
-
|
|
427
|
-
// src/components/ui/textarea.tsx
|
|
428
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
429
|
-
|
|
430
|
-
// src/components/ui/input-group.tsx
|
|
431
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
432
|
-
function InputGroup(_a) {
|
|
433
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
434
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
435
|
-
"div",
|
|
436
|
-
__spreadValues({
|
|
437
|
-
className: cn(
|
|
438
|
-
"group/input-group relative flex w-full items-center border border-input shadow-xs transition-[color,box-shadow] outline-none dark:bg-input/30",
|
|
439
|
-
"h-9 min-w-0 has-[>textarea]:h-auto",
|
|
440
|
-
// Variants based on alignment.
|
|
441
|
-
"has-[>[data-align=inline-start]]:[&>input]:pl-2",
|
|
442
|
-
"has-[>[data-align=inline-end]]:[&>input]:pr-2",
|
|
443
|
-
"has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3",
|
|
444
|
-
"has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3",
|
|
445
|
-
// Focus state.
|
|
446
|
-
"has-[[data-slot=input-group-control]:focus-visible]:border-primary has-[[data-slot=input-group-control]:focus-visible]:ring-[3px] has-[[data-slot=input-group-control]:focus-visible]:ring-primary/20",
|
|
447
|
-
// Error state.
|
|
448
|
-
"has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",
|
|
449
|
-
className
|
|
450
|
-
),
|
|
451
|
-
"data-slot": "input-group",
|
|
452
|
-
role: "group"
|
|
453
|
-
}, props)
|
|
454
|
-
);
|
|
455
|
-
}
|
|
456
|
-
var inputGroupAddonVariants = (0, import_class_variance_authority2.cva)(
|
|
457
|
-
"flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",
|
|
458
|
-
{
|
|
459
|
-
variants: {
|
|
460
|
-
align: {
|
|
461
|
-
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
|
|
462
|
-
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
|
|
463
|
-
"block-start": "order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5 [.border-b]:pb-3",
|
|
464
|
-
"block-end": "order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5 [.border-t]:pt-3"
|
|
465
|
-
}
|
|
466
|
-
},
|
|
467
|
-
defaultVariants: {
|
|
468
|
-
align: "inline-start"
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
);
|
|
472
|
-
function InputGroupAddon(_a) {
|
|
473
|
-
var _b = _a, {
|
|
474
|
-
className,
|
|
475
|
-
align = "inline-start"
|
|
476
|
-
} = _b, props = __objRest(_b, [
|
|
477
|
-
"className",
|
|
478
|
-
"align"
|
|
479
|
-
]);
|
|
480
|
-
return (
|
|
481
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- click only forwards focus to the sibling input; the div is not truly interactive
|
|
482
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
483
|
-
"div",
|
|
484
|
-
__spreadValues({
|
|
485
|
-
className: cn(inputGroupAddonVariants({ align }), className),
|
|
486
|
-
"data-align": align,
|
|
487
|
-
"data-slot": "input-group-addon",
|
|
488
|
-
onClick: (e) => {
|
|
489
|
-
var _a2, _b2;
|
|
490
|
-
if (e.target.closest("button")) {
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
493
|
-
(_b2 = (_a2 = e.currentTarget.parentElement) == null ? void 0 : _a2.querySelector("input")) == null ? void 0 : _b2.focus();
|
|
494
|
-
},
|
|
495
|
-
onKeyDown: (e) => {
|
|
496
|
-
var _a2, _b2;
|
|
497
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
498
|
-
(_b2 = (_a2 = e.currentTarget.parentElement) == null ? void 0 : _a2.querySelector("input")) == null ? void 0 : _b2.focus();
|
|
499
|
-
}
|
|
500
|
-
},
|
|
501
|
-
role: "group"
|
|
502
|
-
}, props)
|
|
503
|
-
)
|
|
504
|
-
);
|
|
505
|
-
}
|
|
506
|
-
var inputGroupButtonVariants = (0, import_class_variance_authority2.cva)(
|
|
507
|
-
"flex items-center gap-2 text-sm shadow-none",
|
|
508
|
-
{
|
|
509
|
-
variants: {
|
|
510
|
-
size: {
|
|
511
|
-
xs: "h-6 gap-1 px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
|
|
512
|
-
sm: "h-8 gap-1.5 px-2.5 has-[>svg]:px-2.5",
|
|
513
|
-
"icon-xs": "size-6 p-0 has-[>svg]:p-0",
|
|
514
|
-
"icon-sm": "size-8 p-0 has-[>svg]:p-0"
|
|
515
|
-
}
|
|
516
|
-
},
|
|
517
|
-
defaultVariants: {
|
|
518
|
-
size: "xs"
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
);
|
|
522
|
-
function InputGroupText(_a) {
|
|
523
|
-
var _b = _a, {
|
|
524
|
-
className
|
|
525
|
-
} = _b, props = __objRest(_b, [
|
|
526
|
-
"className"
|
|
527
|
-
]);
|
|
528
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
529
|
-
"span",
|
|
530
|
-
__spreadValues({
|
|
531
|
-
className: cn(
|
|
532
|
-
"flex items-center gap-2 text-body-small text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
|
|
533
|
-
className
|
|
534
|
-
)
|
|
535
|
-
}, props)
|
|
536
|
-
);
|
|
537
|
-
}
|
|
538
|
-
function InputGroupInput(_a) {
|
|
539
|
-
var _b = _a, {
|
|
540
|
-
className
|
|
541
|
-
} = _b, props = __objRest(_b, [
|
|
542
|
-
"className"
|
|
543
|
-
]);
|
|
544
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
545
|
-
Input,
|
|
546
|
-
__spreadValues({
|
|
547
|
-
className: cn(
|
|
548
|
-
"flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent",
|
|
549
|
-
className
|
|
550
|
-
),
|
|
551
|
-
"data-slot": "input-group-control"
|
|
552
|
-
}, props)
|
|
553
|
-
);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
428
|
// src/components/ui/checkbox.tsx
|
|
557
429
|
var import_react3 = require("react");
|
|
558
430
|
var import_lucide_react3 = require("lucide-react");
|
|
559
431
|
var import_checkbox = require("@base-ui/react/checkbox");
|
|
560
|
-
var
|
|
432
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
561
433
|
function Checkbox(_a) {
|
|
562
434
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
563
|
-
return /* @__PURE__ */ (0,
|
|
435
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
564
436
|
import_checkbox.Checkbox.Root,
|
|
565
437
|
__spreadProps(__spreadValues({
|
|
566
438
|
className: cn(
|
|
@@ -579,14 +451,14 @@ function Checkbox(_a) {
|
|
|
579
451
|
),
|
|
580
452
|
"data-slot": "checkbox"
|
|
581
453
|
}, props), {
|
|
582
|
-
children: /* @__PURE__ */ (0,
|
|
454
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
583
455
|
import_checkbox.Checkbox.Indicator,
|
|
584
456
|
{
|
|
585
457
|
className: "grid place-content-center text-current transition-none",
|
|
586
458
|
"data-slot": "checkbox-indicator",
|
|
587
459
|
children: [
|
|
588
|
-
/* @__PURE__ */ (0,
|
|
589
|
-
/* @__PURE__ */ (0,
|
|
460
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.CheckIcon, { className: "size-3.5 group-data-indeterminate:hidden" }),
|
|
461
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.MinusIcon, { className: "size-3.5 hidden group-data-indeterminate:block" })
|
|
590
462
|
]
|
|
591
463
|
}
|
|
592
464
|
)
|
|
@@ -595,13 +467,13 @@ function Checkbox(_a) {
|
|
|
595
467
|
}
|
|
596
468
|
|
|
597
469
|
// src/components/ui/label.tsx
|
|
598
|
-
var
|
|
470
|
+
var import_jsx_runtime6 = (
|
|
599
471
|
// eslint-disable-next-line jsx-a11y/label-has-associated-control -- htmlFor is passed by the consumer
|
|
600
472
|
require("react/jsx-runtime")
|
|
601
473
|
);
|
|
602
474
|
function Label(_a) {
|
|
603
475
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
604
|
-
return /* @__PURE__ */ (0,
|
|
476
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
605
477
|
"label",
|
|
606
478
|
__spreadValues({
|
|
607
479
|
className: cn(
|
|
@@ -615,15 +487,15 @@ function Label(_a) {
|
|
|
615
487
|
|
|
616
488
|
// src/components/ui/field.tsx
|
|
617
489
|
var import_react4 = require("react");
|
|
618
|
-
var
|
|
490
|
+
var import_class_variance_authority2 = require("class-variance-authority");
|
|
619
491
|
|
|
620
492
|
// src/components/ui/separator.tsx
|
|
621
493
|
var import_separator = require("@base-ui/react/separator");
|
|
622
|
-
var
|
|
494
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
623
495
|
|
|
624
496
|
// src/components/ui/field.tsx
|
|
625
|
-
var
|
|
626
|
-
var fieldVariants = (0,
|
|
497
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
498
|
+
var fieldVariants = (0, import_class_variance_authority2.cva)(
|
|
627
499
|
"group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
|
|
628
500
|
{
|
|
629
501
|
variants: {
|
|
@@ -654,7 +526,7 @@ function Field(_a) {
|
|
|
654
526
|
"className",
|
|
655
527
|
"orientation"
|
|
656
528
|
]);
|
|
657
|
-
return /* @__PURE__ */ (0,
|
|
529
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
658
530
|
"div",
|
|
659
531
|
__spreadValues({
|
|
660
532
|
className: cn(fieldVariants({ orientation }), className),
|
|
@@ -666,7 +538,7 @@ function Field(_a) {
|
|
|
666
538
|
}
|
|
667
539
|
function FieldLabel(_a) {
|
|
668
540
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
669
|
-
return /* @__PURE__ */ (0,
|
|
541
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
670
542
|
Label,
|
|
671
543
|
__spreadValues({
|
|
672
544
|
className: cn(
|
|
@@ -680,239 +552,92 @@ function FieldLabel(_a) {
|
|
|
680
552
|
);
|
|
681
553
|
}
|
|
682
554
|
|
|
683
|
-
// src/components/ui/
|
|
684
|
-
var
|
|
685
|
-
var
|
|
686
|
-
var
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
555
|
+
// src/components/ui/toggle-group.tsx
|
|
556
|
+
var React3 = __toESM(require("react"));
|
|
557
|
+
var import_toggle_group = require("@base-ui/react/toggle-group");
|
|
558
|
+
var import_toggle2 = require("@base-ui/react/toggle");
|
|
559
|
+
|
|
560
|
+
// src/components/ui/toggle.tsx
|
|
561
|
+
var import_class_variance_authority3 = require("class-variance-authority");
|
|
562
|
+
var import_toggle = require("@base-ui/react/toggle");
|
|
563
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
564
|
+
var toggleVariants = (0, import_class_variance_authority3.cva)(
|
|
565
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-pressed:bg-primary/10 data-pressed:inset-ring data-pressed:inset-ring-primary data-pressed:text-foreground data-pressed:hover:bg-primary/10 data-pressed:hover:text-foreground dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
566
|
+
{
|
|
567
|
+
variants: {
|
|
568
|
+
variant: {
|
|
569
|
+
default: "bg-transparent hover:bg-muted hover:text-muted-foreground",
|
|
570
|
+
outline: "border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"
|
|
571
|
+
},
|
|
572
|
+
size: {
|
|
573
|
+
default: "h-9 min-w-9 px-2 text-label-large",
|
|
574
|
+
sm: "h-8 min-w-8 px-1.5 text-label-medium",
|
|
575
|
+
lg: "h-10 min-w-10 px-2.5 text-h5"
|
|
576
|
+
}
|
|
577
|
+
},
|
|
578
|
+
defaultVariants: {
|
|
579
|
+
variant: "default",
|
|
580
|
+
size: "default"
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
);
|
|
584
|
+
|
|
585
|
+
// src/components/ui/toggle-group.tsx
|
|
586
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
587
|
+
var ToggleGroupContext = React3.createContext({
|
|
588
|
+
size: "default",
|
|
589
|
+
variant: "default",
|
|
590
|
+
spacing: 0
|
|
591
|
+
});
|
|
592
|
+
function ToggleGroup(_a) {
|
|
696
593
|
var _b = _a, {
|
|
697
594
|
className,
|
|
698
|
-
|
|
595
|
+
variant,
|
|
596
|
+
size,
|
|
597
|
+
spacing = 0,
|
|
598
|
+
type,
|
|
699
599
|
children
|
|
700
600
|
} = _b, props = __objRest(_b, [
|
|
701
601
|
"className",
|
|
602
|
+
"variant",
|
|
702
603
|
"size",
|
|
604
|
+
"spacing",
|
|
605
|
+
"type",
|
|
703
606
|
"children"
|
|
704
607
|
]);
|
|
705
|
-
return /* @__PURE__ */ (0,
|
|
706
|
-
|
|
608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
609
|
+
import_toggle_group.ToggleGroup,
|
|
707
610
|
__spreadProps(__spreadValues({
|
|
708
611
|
className: cn(
|
|
709
|
-
|
|
612
|
+
// WealthX: removed rounded-md (sharp corners) and shadow-xs (flat panels)
|
|
613
|
+
"group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))]",
|
|
710
614
|
className
|
|
711
615
|
),
|
|
712
616
|
"data-size": size,
|
|
713
|
-
"data-slot": "
|
|
617
|
+
"data-slot": "toggle-group",
|
|
618
|
+
"data-spacing": spacing,
|
|
619
|
+
"data-variant": variant,
|
|
620
|
+
multiple: type === "multiple",
|
|
621
|
+
style: { "--gap": spacing }
|
|
714
622
|
}, props), {
|
|
715
|
-
children:
|
|
716
|
-
children,
|
|
717
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_select.Select.Icon, { className: "transition-transform duration-200 data-popup-open:rotate-180", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react4.ChevronDownIcon, { className: "size-4 opacity-50" }) })
|
|
718
|
-
]
|
|
623
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ToggleGroupContext.Provider, { value: { variant, size, spacing }, children })
|
|
719
624
|
})
|
|
720
625
|
);
|
|
721
626
|
}
|
|
722
|
-
function
|
|
627
|
+
function ToggleGroupItem(_a) {
|
|
723
628
|
var _b = _a, {
|
|
724
629
|
className,
|
|
725
630
|
children,
|
|
726
|
-
|
|
631
|
+
variant,
|
|
632
|
+
size
|
|
727
633
|
} = _b, props = __objRest(_b, [
|
|
728
634
|
"className",
|
|
729
635
|
"children",
|
|
730
|
-
"
|
|
731
|
-
|
|
732
|
-
const themeVars = useThemeVars();
|
|
733
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_select.Select.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
734
|
-
import_select.Select.Positioner,
|
|
735
|
-
{
|
|
736
|
-
className: "z-[200]",
|
|
737
|
-
align: "start",
|
|
738
|
-
alignItemWithTrigger: false,
|
|
739
|
-
sideOffset: 4,
|
|
740
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
741
|
-
import_select.Select.Popup,
|
|
742
|
-
__spreadProps(__spreadValues({
|
|
743
|
-
className: cn(
|
|
744
|
-
"relative max-h-[var(--available-height)] min-w-[var(--anchor-width,8rem)] overflow-x-hidden overflow-y-auto border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-ending-style:animate-out data-ending-style:fade-out-0 data-ending-style:zoom-out-95 data-ending-style:fill-mode-forwards data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95",
|
|
745
|
-
className
|
|
746
|
-
),
|
|
747
|
-
"data-slot": "select-content",
|
|
748
|
-
style: __spreadValues(__spreadValues({}, themeVars), style)
|
|
749
|
-
}, props), {
|
|
750
|
-
children: [
|
|
751
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SelectScrollUpButton, {}),
|
|
752
|
-
children,
|
|
753
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SelectScrollDownButton, {})
|
|
754
|
-
]
|
|
755
|
-
})
|
|
756
|
-
)
|
|
757
|
-
}
|
|
758
|
-
) });
|
|
759
|
-
}
|
|
760
|
-
function SelectItem(_a) {
|
|
761
|
-
var _b = _a, {
|
|
762
|
-
className,
|
|
763
|
-
children
|
|
764
|
-
} = _b, props = __objRest(_b, [
|
|
765
|
-
"className",
|
|
766
|
-
"children"
|
|
767
|
-
]);
|
|
768
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
769
|
-
import_select.Select.Item,
|
|
770
|
-
__spreadProps(__spreadValues({
|
|
771
|
-
className: cn(
|
|
772
|
-
"relative flex w-full cursor-default items-center gap-2 py-1.5 pr-8 pl-2 text-body-small outline-hidden select-none data-highlighted:bg-primary/5 data-highlighted:text-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
|
773
|
-
className
|
|
774
|
-
),
|
|
775
|
-
"data-slot": "select-item"
|
|
776
|
-
}, props), {
|
|
777
|
-
children: [
|
|
778
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
779
|
-
"span",
|
|
780
|
-
{
|
|
781
|
-
className: "absolute right-2 flex size-3.5 items-center justify-center",
|
|
782
|
-
"data-slot": "select-item-indicator",
|
|
783
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_select.Select.ItemIndicator, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react4.CheckIcon, { className: "size-4" }) })
|
|
784
|
-
}
|
|
785
|
-
),
|
|
786
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_select.Select.ItemText, { children })
|
|
787
|
-
]
|
|
788
|
-
})
|
|
789
|
-
);
|
|
790
|
-
}
|
|
791
|
-
function SelectScrollUpButton(_a) {
|
|
792
|
-
var _b = _a, {
|
|
793
|
-
className
|
|
794
|
-
} = _b, props = __objRest(_b, [
|
|
795
|
-
"className"
|
|
796
|
-
]);
|
|
797
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
798
|
-
import_select.Select.ScrollUpArrow,
|
|
799
|
-
__spreadProps(__spreadValues({
|
|
800
|
-
className: cn(
|
|
801
|
-
"flex cursor-default items-center justify-center py-1",
|
|
802
|
-
className
|
|
803
|
-
),
|
|
804
|
-
"data-slot": "select-scroll-up-button"
|
|
805
|
-
}, props), {
|
|
806
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react4.ChevronUpIcon, { className: "size-4" })
|
|
807
|
-
})
|
|
808
|
-
);
|
|
809
|
-
}
|
|
810
|
-
function SelectScrollDownButton(_a) {
|
|
811
|
-
var _b = _a, {
|
|
812
|
-
className
|
|
813
|
-
} = _b, props = __objRest(_b, [
|
|
814
|
-
"className"
|
|
815
|
-
]);
|
|
816
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
817
|
-
import_select.Select.ScrollDownArrow,
|
|
818
|
-
__spreadProps(__spreadValues({
|
|
819
|
-
className: cn(
|
|
820
|
-
"flex cursor-default items-center justify-center py-1",
|
|
821
|
-
className
|
|
822
|
-
),
|
|
823
|
-
"data-slot": "select-scroll-down-button"
|
|
824
|
-
}, props), {
|
|
825
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react4.ChevronDownIcon, { className: "size-4" })
|
|
826
|
-
})
|
|
827
|
-
);
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
// src/components/ui/toggle-group.tsx
|
|
831
|
-
var React3 = __toESM(require("react"));
|
|
832
|
-
var import_toggle_group = require("@base-ui/react/toggle-group");
|
|
833
|
-
var import_toggle2 = require("@base-ui/react/toggle");
|
|
834
|
-
|
|
835
|
-
// src/components/ui/toggle.tsx
|
|
836
|
-
var import_class_variance_authority4 = require("class-variance-authority");
|
|
837
|
-
var import_toggle = require("@base-ui/react/toggle");
|
|
838
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
839
|
-
var toggleVariants = (0, import_class_variance_authority4.cva)(
|
|
840
|
-
"inline-flex items-center justify-center gap-2 whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-pressed:bg-primary/10 data-pressed:inset-ring data-pressed:inset-ring-primary data-pressed:text-foreground data-pressed:hover:bg-primary/10 data-pressed:hover:text-foreground dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
841
|
-
{
|
|
842
|
-
variants: {
|
|
843
|
-
variant: {
|
|
844
|
-
default: "bg-transparent hover:bg-muted hover:text-muted-foreground",
|
|
845
|
-
outline: "border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"
|
|
846
|
-
},
|
|
847
|
-
size: {
|
|
848
|
-
default: "h-9 min-w-9 px-2 text-label-large",
|
|
849
|
-
sm: "h-8 min-w-8 px-1.5 text-label-medium",
|
|
850
|
-
lg: "h-10 min-w-10 px-2.5 text-h5"
|
|
851
|
-
}
|
|
852
|
-
},
|
|
853
|
-
defaultVariants: {
|
|
854
|
-
variant: "default",
|
|
855
|
-
size: "default"
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
);
|
|
859
|
-
|
|
860
|
-
// src/components/ui/toggle-group.tsx
|
|
861
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
862
|
-
var ToggleGroupContext = React3.createContext({
|
|
863
|
-
size: "default",
|
|
864
|
-
variant: "default",
|
|
865
|
-
spacing: 0
|
|
866
|
-
});
|
|
867
|
-
function ToggleGroup(_a) {
|
|
868
|
-
var _b = _a, {
|
|
869
|
-
className,
|
|
870
|
-
variant,
|
|
871
|
-
size,
|
|
872
|
-
spacing = 0,
|
|
873
|
-
type,
|
|
874
|
-
children
|
|
875
|
-
} = _b, props = __objRest(_b, [
|
|
876
|
-
"className",
|
|
877
|
-
"variant",
|
|
878
|
-
"size",
|
|
879
|
-
"spacing",
|
|
880
|
-
"type",
|
|
881
|
-
"children"
|
|
882
|
-
]);
|
|
883
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
884
|
-
import_toggle_group.ToggleGroup,
|
|
885
|
-
__spreadProps(__spreadValues({
|
|
886
|
-
className: cn(
|
|
887
|
-
// WealthX: removed rounded-md (sharp corners) and shadow-xs (flat panels)
|
|
888
|
-
"group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))]",
|
|
889
|
-
className
|
|
890
|
-
),
|
|
891
|
-
"data-size": size,
|
|
892
|
-
"data-slot": "toggle-group",
|
|
893
|
-
"data-spacing": spacing,
|
|
894
|
-
"data-variant": variant,
|
|
895
|
-
multiple: type === "multiple",
|
|
896
|
-
style: { "--gap": spacing }
|
|
897
|
-
}, props), {
|
|
898
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ToggleGroupContext.Provider, { value: { variant, size, spacing }, children })
|
|
899
|
-
})
|
|
900
|
-
);
|
|
901
|
-
}
|
|
902
|
-
function ToggleGroupItem(_a) {
|
|
903
|
-
var _b = _a, {
|
|
904
|
-
className,
|
|
905
|
-
children,
|
|
906
|
-
variant,
|
|
907
|
-
size
|
|
908
|
-
} = _b, props = __objRest(_b, [
|
|
909
|
-
"className",
|
|
910
|
-
"children",
|
|
911
|
-
"variant",
|
|
912
|
-
"size"
|
|
636
|
+
"variant",
|
|
637
|
+
"size"
|
|
913
638
|
]);
|
|
914
639
|
const context = React3.useContext(ToggleGroupContext);
|
|
915
|
-
return /* @__PURE__ */ (0,
|
|
640
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
916
641
|
import_toggle2.Toggle,
|
|
917
642
|
__spreadProps(__spreadValues({
|
|
918
643
|
className: cn(
|
|
@@ -935,8 +660,15 @@ function ToggleGroupItem(_a) {
|
|
|
935
660
|
);
|
|
936
661
|
}
|
|
937
662
|
|
|
938
|
-
// src/components/ui/contact-alert-dialog.
|
|
939
|
-
var
|
|
663
|
+
// src/components/ui/contact-alert-dialog/types.ts
|
|
664
|
+
var AlertSharingType = /* @__PURE__ */ ((AlertSharingType2) => {
|
|
665
|
+
AlertSharingType2["PRIVATE"] = "PRIVATE";
|
|
666
|
+
AlertSharingType2["COMPANY"] = "COMPANY";
|
|
667
|
+
return AlertSharingType2;
|
|
668
|
+
})(AlertSharingType || {});
|
|
669
|
+
|
|
670
|
+
// src/components/ui/contact-alert-dialog/config.ts
|
|
671
|
+
var import_ui = require("@react-awesome-query-builder/ui");
|
|
940
672
|
var ALERT_QUERY_FIELDS = [
|
|
941
673
|
{
|
|
942
674
|
key: "userMetric.max_loan_amount",
|
|
@@ -1060,13 +792,126 @@ var SEVERITY_LABELS = {
|
|
|
1060
792
|
WATCH: "Watch",
|
|
1061
793
|
NEED_ACTION: "Need Action"
|
|
1062
794
|
};
|
|
1063
|
-
var
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
795
|
+
var QB_CONFIG = __spreadProps(__spreadValues({}, import_ui.BasicConfig), {
|
|
796
|
+
fields: {
|
|
797
|
+
"userMetric.max_loan_amount": {
|
|
798
|
+
label: "Borrowing Capacity",
|
|
799
|
+
type: "number",
|
|
800
|
+
operators: [
|
|
801
|
+
"equal",
|
|
802
|
+
"less",
|
|
803
|
+
"less_or_equal",
|
|
804
|
+
"greater",
|
|
805
|
+
"greater_or_equal",
|
|
806
|
+
"between"
|
|
807
|
+
],
|
|
808
|
+
valueSources: ["value"]
|
|
809
|
+
},
|
|
810
|
+
"userMetric.debt_outstanding": {
|
|
811
|
+
label: "Outstanding Debt",
|
|
812
|
+
type: "number",
|
|
813
|
+
operators: [
|
|
814
|
+
"equal",
|
|
815
|
+
"less",
|
|
816
|
+
"less_or_equal",
|
|
817
|
+
"greater",
|
|
818
|
+
"greater_or_equal"
|
|
819
|
+
],
|
|
820
|
+
valueSources: ["value"]
|
|
821
|
+
},
|
|
822
|
+
"userMetric.lvr": {
|
|
823
|
+
label: "Current LVR",
|
|
824
|
+
type: "number",
|
|
825
|
+
operators: [
|
|
826
|
+
"equal",
|
|
827
|
+
"less",
|
|
828
|
+
"less_or_equal",
|
|
829
|
+
"greater",
|
|
830
|
+
"greater_or_equal"
|
|
831
|
+
],
|
|
832
|
+
valueSources: ["value"]
|
|
833
|
+
},
|
|
834
|
+
"userMetric.has_met_buying_goal": {
|
|
835
|
+
label: "Has Met Buying Goal",
|
|
836
|
+
type: "boolean",
|
|
837
|
+
operators: ["equal"],
|
|
838
|
+
valueSources: ["value"]
|
|
839
|
+
},
|
|
840
|
+
"userMetric.excess_monthly_surplus": {
|
|
841
|
+
label: "Excess Monthly Surplus",
|
|
842
|
+
type: "number",
|
|
843
|
+
operators: [
|
|
844
|
+
"equal",
|
|
845
|
+
"less",
|
|
846
|
+
"less_or_equal",
|
|
847
|
+
"greater",
|
|
848
|
+
"greater_or_equal"
|
|
849
|
+
],
|
|
850
|
+
valueSources: ["value"]
|
|
851
|
+
},
|
|
852
|
+
"userMetric.equity": {
|
|
853
|
+
label: "Equity Amount",
|
|
854
|
+
type: "number",
|
|
855
|
+
operators: [
|
|
856
|
+
"equal",
|
|
857
|
+
"less",
|
|
858
|
+
"less_or_equal",
|
|
859
|
+
"greater",
|
|
860
|
+
"greater_or_equal"
|
|
861
|
+
],
|
|
862
|
+
valueSources: ["value"]
|
|
863
|
+
},
|
|
864
|
+
"userMetric.max_debt_interest_rate": {
|
|
865
|
+
label: "Max Debt Interest Rate",
|
|
866
|
+
type: "number",
|
|
867
|
+
operators: [
|
|
868
|
+
"equal",
|
|
869
|
+
"less",
|
|
870
|
+
"less_or_equal",
|
|
871
|
+
"greater",
|
|
872
|
+
"greater_or_equal"
|
|
873
|
+
],
|
|
874
|
+
valueSources: ["value"]
|
|
875
|
+
},
|
|
876
|
+
"userMetric.min_debt_interest_rate": {
|
|
877
|
+
label: "Min Debt Interest Rate",
|
|
878
|
+
type: "number",
|
|
879
|
+
operators: [
|
|
880
|
+
"equal",
|
|
881
|
+
"less",
|
|
882
|
+
"less_or_equal",
|
|
883
|
+
"greater",
|
|
884
|
+
"greater_or_equal"
|
|
885
|
+
],
|
|
886
|
+
valueSources: ["value"]
|
|
887
|
+
}
|
|
888
|
+
}
|
|
1069
889
|
});
|
|
890
|
+
var EMPTY_QUERY_VALUE = {
|
|
891
|
+
id: "root",
|
|
892
|
+
type: "group",
|
|
893
|
+
properties: { conjunction: "AND", not: false },
|
|
894
|
+
children1: [
|
|
895
|
+
{
|
|
896
|
+
id: "rule-init",
|
|
897
|
+
type: "rule",
|
|
898
|
+
properties: {
|
|
899
|
+
field: "userMetric.max_loan_amount",
|
|
900
|
+
operator: "greater_or_equal",
|
|
901
|
+
value: [null],
|
|
902
|
+
valueSrc: ["value"]
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
]
|
|
906
|
+
};
|
|
907
|
+
function createAlertTree(query) {
|
|
908
|
+
const q = query != null ? query : EMPTY_QUERY_VALUE;
|
|
909
|
+
const loaded = import_ui.Utils.loadTree(q);
|
|
910
|
+
return import_ui.Utils.sanitizeTree(loaded, QB_CONFIG).fixedTree;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
// src/components/ui/contact-alert-dialog/utils.ts
|
|
914
|
+
var import_ui2 = require("@react-awesome-query-builder/ui");
|
|
1070
915
|
function longestOf(labels) {
|
|
1071
916
|
return labels.reduce((a, b) => a.length >= b.length ? a : b, "");
|
|
1072
917
|
}
|
|
@@ -1077,7 +922,7 @@ function allOperatorLabels(fields) {
|
|
|
1077
922
|
const fieldOps = f.type === "boolean" ? BOOLEAN_OPERATORS : (_a = f.operators) != null ? _a : ALL_NUMERIC_OPERATORS;
|
|
1078
923
|
fieldOps.forEach((op) => ops.add(op));
|
|
1079
924
|
}
|
|
1080
|
-
return
|
|
925
|
+
return Array.from(ops).map((op) => OPERATOR_LABELS[op]);
|
|
1081
926
|
}
|
|
1082
927
|
function formatWithCommas(raw) {
|
|
1083
928
|
if (!raw) return "";
|
|
@@ -1088,214 +933,801 @@ function formatWithCommas(raw) {
|
|
|
1088
933
|
function parseCommas(display) {
|
|
1089
934
|
return display.replace(/[^\d.]/g, "").replace(/(\..*)\./g, "$1");
|
|
1090
935
|
}
|
|
1091
|
-
function
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
)
|
|
1104
|
-
|
|
1105
|
-
|
|
936
|
+
function ruleSummary(ruleProps, fields) {
|
|
937
|
+
var _a, _b, _c, _d, _e, _f;
|
|
938
|
+
const field = (_a = ruleProps == null ? void 0 : ruleProps.field) != null ? _a : "";
|
|
939
|
+
const operator = (_b = ruleProps == null ? void 0 : ruleProps.operator) != null ? _b : "equal";
|
|
940
|
+
const value0 = (_c = ruleProps == null ? void 0 : ruleProps.value) == null ? void 0 : _c[0];
|
|
941
|
+
const value1 = (_d = ruleProps == null ? void 0 : ruleProps.value) == null ? void 0 : _d[1];
|
|
942
|
+
const fieldDef = fields.find((f) => f.key === field);
|
|
943
|
+
const fieldLabel = (_e = fieldDef == null ? void 0 : fieldDef.label) != null ? _e : field;
|
|
944
|
+
const opLabel = (_f = OPERATOR_LABELS[operator]) != null ? _f : operator;
|
|
945
|
+
const formatVal = (v) => {
|
|
946
|
+
if (v === null || v === void 0) return "\u2026";
|
|
947
|
+
if ((fieldDef == null ? void 0 : fieldDef.type) === "boolean") return v ? "Yes" : "No";
|
|
948
|
+
const n = typeof v === "number" ? v : parseFloat(String(v));
|
|
949
|
+
if (!isFinite(n)) return "\u2026";
|
|
950
|
+
if ((fieldDef == null ? void 0 : fieldDef.unit) === "dollar")
|
|
951
|
+
return `$${formatWithCommas(n.toString())}`;
|
|
952
|
+
if ((fieldDef == null ? void 0 : fieldDef.unit) === "percent") return `${n}%`;
|
|
953
|
+
return String(v);
|
|
954
|
+
};
|
|
955
|
+
if (operator === "between") {
|
|
956
|
+
return `${fieldLabel} between ${formatVal(value0)} and ${formatVal(value1)}`;
|
|
957
|
+
}
|
|
958
|
+
return `${fieldLabel} ${opLabel} ${formatVal(value0)}`;
|
|
1106
959
|
}
|
|
1107
|
-
function
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
placeholder
|
|
1123
|
-
}
|
|
1124
|
-
),
|
|
1125
|
-
unit === "percent" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(InputGroupAddon, { align: "inline-end", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(InputGroupText, { children: "%" }) })
|
|
1126
|
-
] });
|
|
960
|
+
function checkGroupValid(children) {
|
|
961
|
+
return children.some((child) => {
|
|
962
|
+
var _a, _b, _c, _d;
|
|
963
|
+
const c = child;
|
|
964
|
+
if (c.type === "rule") {
|
|
965
|
+
const field = (_a = c.properties) == null ? void 0 : _a.field;
|
|
966
|
+
if (!field) return false;
|
|
967
|
+
const fieldDef = ALERT_QUERY_FIELDS.find((f) => f.key === field);
|
|
968
|
+
if ((fieldDef == null ? void 0 : fieldDef.type) === "boolean") return true;
|
|
969
|
+
const v = (_c = (_b = c.properties) == null ? void 0 : _b.value) == null ? void 0 : _c[0];
|
|
970
|
+
return v !== null && v !== void 0;
|
|
971
|
+
}
|
|
972
|
+
if (c.type === "group") return checkGroupValid((_d = c.children1) != null ? _d : []);
|
|
973
|
+
return false;
|
|
974
|
+
});
|
|
1127
975
|
}
|
|
1128
|
-
function
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
longestOperatorLabel,
|
|
1133
|
-
onUpdate,
|
|
1134
|
-
onRemove,
|
|
1135
|
-
removable
|
|
1136
|
-
}) {
|
|
1137
|
-
var _a, _b, _c, _d, _e;
|
|
1138
|
-
const fieldDef = (_a = fields.find((f) => f.key === rule.field)) != null ? _a : fields[0];
|
|
1139
|
-
const isBooleanField = fieldDef.type === "boolean";
|
|
1140
|
-
const availableOperators = isBooleanField ? BOOLEAN_OPERATORS : (_b = fieldDef.operators) != null ? _b : ALL_NUMERIC_OPERATORS;
|
|
1141
|
-
const update = (patch) => onUpdate(__spreadValues(__spreadValues({}, rule), patch));
|
|
1142
|
-
function handleFieldChange(key) {
|
|
1143
|
-
var _a2;
|
|
1144
|
-
const newField = fields.find((f) => f.key === key);
|
|
1145
|
-
const newOps = (newField == null ? void 0 : newField.type) === "boolean" ? BOOLEAN_OPERATORS : (_a2 = newField == null ? void 0 : newField.operators) != null ? _a2 : ALL_NUMERIC_OPERATORS;
|
|
1146
|
-
const validOp = newOps.includes(rule.operator) ? rule.operator : newOps[0];
|
|
1147
|
-
update({ field: key, operator: validOp, value: "", value2: "" });
|
|
1148
|
-
}
|
|
1149
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-wrap items-center gap-1.5 border border-border bg-muted/20 p-2", children: [
|
|
1150
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectAutoWidth, { longestLabel: longestFieldLabel, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Select, { value: rule.field, onValueChange: handleFieldChange, children: [
|
|
1151
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectTrigger, { size: "sm", className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectValue, { children: (_d = (_c = fields.find((f) => f.key === rule.field)) == null ? void 0 : _c.label) != null ? _d : rule.field }) }),
|
|
1152
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectContent, { children: fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectItem, { value: f.key, children: f.label }, f.key)) })
|
|
1153
|
-
] }) }),
|
|
1154
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectAutoWidth, { longestLabel: longestOperatorLabel, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1155
|
-
Select,
|
|
1156
|
-
{
|
|
1157
|
-
value: rule.operator,
|
|
1158
|
-
onValueChange: (v) => update({ operator: v }),
|
|
1159
|
-
children: [
|
|
1160
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectTrigger, { size: "sm", className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectValue, { children: OPERATOR_LABELS[rule.operator] }) }),
|
|
1161
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectContent, { children: availableOperators.map((op) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectItem, { value: op, children: OPERATOR_LABELS[op] }, op)) })
|
|
1162
|
-
]
|
|
1163
|
-
}
|
|
1164
|
-
) }),
|
|
1165
|
-
isBooleanField ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1166
|
-
Select,
|
|
1167
|
-
{
|
|
1168
|
-
value: rule.value || "true",
|
|
1169
|
-
onValueChange: (v) => update({ value: v }),
|
|
1170
|
-
children: [
|
|
1171
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectTrigger, { size: "sm", className: "w-36", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectValue, { children: (rule.value || "true") === "false" ? "No" : "Yes" }) }),
|
|
1172
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(SelectContent, { children: [
|
|
1173
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectItem, { value: "true", children: "Yes" }),
|
|
1174
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectItem, { value: "false", children: "No" })
|
|
1175
|
-
] })
|
|
1176
|
-
]
|
|
1177
|
-
}
|
|
1178
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
1179
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1180
|
-
ValueInput,
|
|
1181
|
-
{
|
|
1182
|
-
value: rule.value,
|
|
1183
|
-
onChange: (v) => update({ value: v }),
|
|
1184
|
-
unit: fieldDef.unit
|
|
1185
|
-
}
|
|
1186
|
-
),
|
|
1187
|
-
rule.operator === "between" && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
1188
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-xs text-muted-foreground", children: "and" }),
|
|
1189
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1190
|
-
ValueInput,
|
|
1191
|
-
{
|
|
1192
|
-
value: (_e = rule.value2) != null ? _e : "",
|
|
1193
|
-
onChange: (v) => update({ value2: v }),
|
|
1194
|
-
unit: fieldDef.unit
|
|
1195
|
-
}
|
|
1196
|
-
)
|
|
1197
|
-
] })
|
|
1198
|
-
] }),
|
|
1199
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1200
|
-
Button,
|
|
1201
|
-
{
|
|
1202
|
-
type: "button",
|
|
1203
|
-
variant: "ghost",
|
|
1204
|
-
size: "sm",
|
|
1205
|
-
onClick: onRemove,
|
|
1206
|
-
disabled: !removable,
|
|
1207
|
-
"aria-label": "Remove rule",
|
|
1208
|
-
className: "ml-auto",
|
|
1209
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.Trash2Icon, {})
|
|
1210
|
-
}
|
|
1211
|
-
)
|
|
1212
|
-
] });
|
|
976
|
+
function isTreeValid(tree) {
|
|
977
|
+
var _a;
|
|
978
|
+
const json = import_ui2.Utils.getTree(tree);
|
|
979
|
+
return checkGroupValid((_a = json == null ? void 0 : json.children1) != null ? _a : []);
|
|
1213
980
|
}
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
981
|
+
|
|
982
|
+
// src/components/ui/contact-alert-dialog/builder-ui.tsx
|
|
983
|
+
var React4 = __toESM(require("react"));
|
|
984
|
+
var import_lucide_react5 = require("lucide-react");
|
|
985
|
+
var import_accordion = require("@base-ui/react/accordion");
|
|
986
|
+
var import_ui3 = require("@react-awesome-query-builder/ui");
|
|
987
|
+
|
|
988
|
+
// src/components/ui/input-group.tsx
|
|
989
|
+
var import_class_variance_authority4 = require("class-variance-authority");
|
|
990
|
+
|
|
991
|
+
// src/components/ui/textarea.tsx
|
|
992
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
993
|
+
|
|
994
|
+
// src/components/ui/input-group.tsx
|
|
995
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
996
|
+
function InputGroup(_a) {
|
|
997
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
998
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
999
|
+
"div",
|
|
1000
|
+
__spreadValues({
|
|
1001
|
+
className: cn(
|
|
1002
|
+
"group/input-group relative flex w-full items-center border border-input shadow-xs transition-[color,box-shadow] outline-none dark:bg-input/30",
|
|
1003
|
+
"h-9 min-w-0 has-[>textarea]:h-auto",
|
|
1004
|
+
// Variants based on alignment.
|
|
1005
|
+
"has-[>[data-align=inline-start]]:[&>input]:pl-2",
|
|
1006
|
+
"has-[>[data-align=inline-end]]:[&>input]:pr-2",
|
|
1007
|
+
"has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3",
|
|
1008
|
+
"has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3",
|
|
1009
|
+
// Focus state.
|
|
1010
|
+
"has-[[data-slot=input-group-control]:focus-visible]:border-primary has-[[data-slot=input-group-control]:focus-visible]:ring-[3px] has-[[data-slot=input-group-control]:focus-visible]:ring-primary/20",
|
|
1011
|
+
// Error state.
|
|
1012
|
+
"has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",
|
|
1013
|
+
className
|
|
1014
|
+
),
|
|
1015
|
+
"data-slot": "input-group",
|
|
1016
|
+
role: "group"
|
|
1017
|
+
}, props)
|
|
1018
|
+
);
|
|
1019
|
+
}
|
|
1020
|
+
var inputGroupAddonVariants = (0, import_class_variance_authority4.cva)(
|
|
1021
|
+
"flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",
|
|
1022
|
+
{
|
|
1023
|
+
variants: {
|
|
1024
|
+
align: {
|
|
1025
|
+
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
|
|
1026
|
+
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
|
|
1027
|
+
"block-start": "order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5 [.border-b]:pb-3",
|
|
1028
|
+
"block-end": "order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5 [.border-t]:pt-3"
|
|
1029
|
+
}
|
|
1030
|
+
},
|
|
1031
|
+
defaultVariants: {
|
|
1032
|
+
align: "inline-start"
|
|
1033
|
+
}
|
|
1250
1034
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1035
|
+
);
|
|
1036
|
+
function InputGroupAddon(_a) {
|
|
1037
|
+
var _b = _a, {
|
|
1038
|
+
className,
|
|
1039
|
+
align = "inline-start"
|
|
1040
|
+
} = _b, props = __objRest(_b, [
|
|
1041
|
+
"className",
|
|
1042
|
+
"align"
|
|
1043
|
+
]);
|
|
1044
|
+
return (
|
|
1045
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- click only forwards focus to the sibling input; the div is not truly interactive
|
|
1046
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1047
|
+
"div",
|
|
1048
|
+
__spreadValues({
|
|
1049
|
+
className: cn(inputGroupAddonVariants({ align }), className),
|
|
1050
|
+
"data-align": align,
|
|
1051
|
+
"data-slot": "input-group-addon",
|
|
1052
|
+
onClick: (e) => {
|
|
1053
|
+
var _a2, _b2;
|
|
1054
|
+
if (e.target.closest("button")) {
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
(_b2 = (_a2 = e.currentTarget.parentElement) == null ? void 0 : _a2.querySelector("input")) == null ? void 0 : _b2.focus();
|
|
1058
|
+
},
|
|
1059
|
+
onKeyDown: (e) => {
|
|
1060
|
+
var _a2, _b2;
|
|
1061
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1062
|
+
(_b2 = (_a2 = e.currentTarget.parentElement) == null ? void 0 : _a2.querySelector("input")) == null ? void 0 : _b2.focus();
|
|
1063
|
+
}
|
|
1064
|
+
},
|
|
1065
|
+
role: "group"
|
|
1066
|
+
}, props)
|
|
1067
|
+
)
|
|
1068
|
+
);
|
|
1069
|
+
}
|
|
1070
|
+
var inputGroupButtonVariants = (0, import_class_variance_authority4.cva)(
|
|
1071
|
+
"flex items-center gap-2 text-sm shadow-none",
|
|
1072
|
+
{
|
|
1073
|
+
variants: {
|
|
1074
|
+
size: {
|
|
1075
|
+
xs: "h-6 gap-1 px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
|
|
1076
|
+
sm: "h-8 gap-1.5 px-2.5 has-[>svg]:px-2.5",
|
|
1077
|
+
"icon-xs": "size-6 p-0 has-[>svg]:p-0",
|
|
1078
|
+
"icon-sm": "size-8 p-0 has-[>svg]:p-0"
|
|
1079
|
+
}
|
|
1080
|
+
},
|
|
1081
|
+
defaultVariants: {
|
|
1082
|
+
size: "xs"
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
);
|
|
1086
|
+
function InputGroupText(_a) {
|
|
1087
|
+
var _b = _a, {
|
|
1088
|
+
className
|
|
1089
|
+
} = _b, props = __objRest(_b, [
|
|
1090
|
+
"className"
|
|
1091
|
+
]);
|
|
1092
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1093
|
+
"span",
|
|
1094
|
+
__spreadValues({
|
|
1095
|
+
className: cn(
|
|
1096
|
+
"flex items-center gap-2 text-body-small text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
|
|
1097
|
+
className
|
|
1098
|
+
)
|
|
1099
|
+
}, props)
|
|
1100
|
+
);
|
|
1101
|
+
}
|
|
1102
|
+
function InputGroupInput(_a) {
|
|
1103
|
+
var _b = _a, {
|
|
1104
|
+
className
|
|
1105
|
+
} = _b, props = __objRest(_b, [
|
|
1106
|
+
"className"
|
|
1107
|
+
]);
|
|
1108
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1109
|
+
Input,
|
|
1110
|
+
__spreadValues({
|
|
1111
|
+
className: cn(
|
|
1112
|
+
"flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent",
|
|
1113
|
+
className
|
|
1114
|
+
),
|
|
1115
|
+
"data-slot": "input-group-control"
|
|
1116
|
+
}, props)
|
|
1117
|
+
);
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
// src/components/ui/select.tsx
|
|
1121
|
+
var import_lucide_react4 = require("lucide-react");
|
|
1122
|
+
var import_select = require("@base-ui/react/select");
|
|
1123
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1124
|
+
function Select(_a) {
|
|
1125
|
+
var props = __objRest(_a, []);
|
|
1126
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_select.Select.Root, __spreadValues({ "data-slot": "select" }, props));
|
|
1127
|
+
}
|
|
1128
|
+
function SelectValue(_a) {
|
|
1129
|
+
var props = __objRest(_a, []);
|
|
1130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_select.Select.Value, __spreadValues({ "data-slot": "select-value" }, props));
|
|
1131
|
+
}
|
|
1132
|
+
function SelectTrigger(_a) {
|
|
1133
|
+
var _b = _a, {
|
|
1134
|
+
className,
|
|
1135
|
+
size = "default",
|
|
1136
|
+
children
|
|
1137
|
+
} = _b, props = __objRest(_b, [
|
|
1138
|
+
"className",
|
|
1139
|
+
"size",
|
|
1140
|
+
"children"
|
|
1141
|
+
]);
|
|
1142
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1143
|
+
import_select.Select.Trigger,
|
|
1144
|
+
__spreadProps(__spreadValues({
|
|
1145
|
+
className: cn(
|
|
1146
|
+
"flex w-fit items-center justify-between gap-2 border border-input bg-transparent px-3 py-2 text-body-medium whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-primary focus-visible:ring-[3px] focus-visible:ring-primary/20 data-popup-open:border-primary data-popup-open:ring-[3px] data-popup-open:ring-primary/20 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-placeholder:font-normal data-placeholder:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
|
|
1147
|
+
className
|
|
1148
|
+
),
|
|
1149
|
+
"data-size": size,
|
|
1150
|
+
"data-slot": "select-trigger"
|
|
1151
|
+
}, props), {
|
|
1152
|
+
children: [
|
|
1153
|
+
children,
|
|
1154
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_select.Select.Icon, { className: "transition-transform duration-200 data-popup-open:rotate-180", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.ChevronDownIcon, { className: "size-4 opacity-50" }) })
|
|
1155
|
+
]
|
|
1156
|
+
})
|
|
1157
|
+
);
|
|
1158
|
+
}
|
|
1159
|
+
function SelectContent(_a) {
|
|
1160
|
+
var _b = _a, {
|
|
1161
|
+
className,
|
|
1162
|
+
children,
|
|
1163
|
+
style
|
|
1164
|
+
} = _b, props = __objRest(_b, [
|
|
1165
|
+
"className",
|
|
1166
|
+
"children",
|
|
1167
|
+
"style"
|
|
1168
|
+
]);
|
|
1169
|
+
const themeVars = useThemeVars();
|
|
1170
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_select.Select.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1171
|
+
import_select.Select.Positioner,
|
|
1172
|
+
{
|
|
1173
|
+
className: "z-[200]",
|
|
1174
|
+
align: "start",
|
|
1175
|
+
alignItemWithTrigger: false,
|
|
1176
|
+
sideOffset: 4,
|
|
1177
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1178
|
+
import_select.Select.Popup,
|
|
1179
|
+
__spreadProps(__spreadValues({
|
|
1180
|
+
className: cn(
|
|
1181
|
+
"relative max-h-[var(--available-height)] min-w-[var(--anchor-width,8rem)] overflow-x-hidden overflow-y-auto border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-ending-style:animate-out data-ending-style:fade-out-0 data-ending-style:zoom-out-95 data-ending-style:fill-mode-forwards data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95",
|
|
1182
|
+
className
|
|
1183
|
+
),
|
|
1184
|
+
"data-slot": "select-content",
|
|
1185
|
+
style: __spreadValues(__spreadValues({}, themeVars), style)
|
|
1186
|
+
}, props), {
|
|
1187
|
+
children: [
|
|
1188
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SelectScrollUpButton, {}),
|
|
1189
|
+
children,
|
|
1190
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SelectScrollDownButton, {})
|
|
1191
|
+
]
|
|
1192
|
+
})
|
|
1193
|
+
)
|
|
1194
|
+
}
|
|
1195
|
+
) });
|
|
1196
|
+
}
|
|
1197
|
+
function SelectItem(_a) {
|
|
1198
|
+
var _b = _a, {
|
|
1199
|
+
className,
|
|
1200
|
+
children
|
|
1201
|
+
} = _b, props = __objRest(_b, [
|
|
1202
|
+
"className",
|
|
1203
|
+
"children"
|
|
1204
|
+
]);
|
|
1205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1206
|
+
import_select.Select.Item,
|
|
1207
|
+
__spreadProps(__spreadValues({
|
|
1208
|
+
className: cn(
|
|
1209
|
+
"relative flex w-full cursor-default items-center gap-2 py-1.5 pr-8 pl-2 text-body-small outline-hidden select-none data-highlighted:bg-primary/5 data-highlighted:text-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
|
1210
|
+
className
|
|
1211
|
+
),
|
|
1212
|
+
"data-slot": "select-item"
|
|
1213
|
+
}, props), {
|
|
1214
|
+
children: [
|
|
1215
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1216
|
+
"span",
|
|
1217
|
+
{
|
|
1218
|
+
className: "absolute right-2 flex size-3.5 items-center justify-center",
|
|
1219
|
+
"data-slot": "select-item-indicator",
|
|
1220
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_select.Select.ItemIndicator, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.CheckIcon, { className: "size-4" }) })
|
|
1221
|
+
}
|
|
1222
|
+
),
|
|
1223
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_select.Select.ItemText, { children })
|
|
1224
|
+
]
|
|
1225
|
+
})
|
|
1226
|
+
);
|
|
1227
|
+
}
|
|
1228
|
+
function SelectScrollUpButton(_a) {
|
|
1229
|
+
var _b = _a, {
|
|
1230
|
+
className
|
|
1231
|
+
} = _b, props = __objRest(_b, [
|
|
1232
|
+
"className"
|
|
1233
|
+
]);
|
|
1234
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1235
|
+
import_select.Select.ScrollUpArrow,
|
|
1236
|
+
__spreadProps(__spreadValues({
|
|
1237
|
+
className: cn(
|
|
1238
|
+
"flex cursor-default items-center justify-center py-1",
|
|
1239
|
+
className
|
|
1240
|
+
),
|
|
1241
|
+
"data-slot": "select-scroll-up-button"
|
|
1242
|
+
}, props), {
|
|
1243
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.ChevronUpIcon, { className: "size-4" })
|
|
1244
|
+
})
|
|
1245
|
+
);
|
|
1246
|
+
}
|
|
1247
|
+
function SelectScrollDownButton(_a) {
|
|
1248
|
+
var _b = _a, {
|
|
1249
|
+
className
|
|
1250
|
+
} = _b, props = __objRest(_b, [
|
|
1251
|
+
"className"
|
|
1252
|
+
]);
|
|
1253
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1254
|
+
import_select.Select.ScrollDownArrow,
|
|
1255
|
+
__spreadProps(__spreadValues({
|
|
1256
|
+
className: cn(
|
|
1257
|
+
"flex cursor-default items-center justify-center py-1",
|
|
1258
|
+
className
|
|
1259
|
+
),
|
|
1260
|
+
"data-slot": "select-scroll-down-button"
|
|
1261
|
+
}, props), {
|
|
1262
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.ChevronDownIcon, { className: "size-4" })
|
|
1263
|
+
})
|
|
1264
|
+
);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
// src/components/ui/contact-alert-dialog/builder-ui.tsx
|
|
1268
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1269
|
+
function SelectAutoWidth({
|
|
1270
|
+
longestLabel,
|
|
1271
|
+
children
|
|
1272
|
+
}) {
|
|
1273
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "relative inline-block shrink-0", children: [
|
|
1274
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1275
|
+
"span",
|
|
1276
|
+
{
|
|
1277
|
+
"aria-hidden": true,
|
|
1278
|
+
className: "invisible block h-8 whitespace-nowrap pl-3 pr-10 text-body-medium",
|
|
1279
|
+
children: longestLabel
|
|
1280
|
+
}
|
|
1281
|
+
),
|
|
1282
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "absolute inset-0", children })
|
|
1283
|
+
] });
|
|
1284
|
+
}
|
|
1285
|
+
function ValueInput({
|
|
1286
|
+
value,
|
|
1287
|
+
onChange,
|
|
1288
|
+
unit,
|
|
1289
|
+
placeholder = "0"
|
|
1290
|
+
}) {
|
|
1291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(InputGroup, { className: "w-36", children: [
|
|
1292
|
+
unit === "dollar" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(InputGroupAddon, { align: "inline-start", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(InputGroupText, { children: "$" }) }),
|
|
1293
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1294
|
+
InputGroupInput,
|
|
1295
|
+
{
|
|
1296
|
+
type: "text",
|
|
1297
|
+
inputMode: "numeric",
|
|
1298
|
+
value: formatWithCommas(value),
|
|
1299
|
+
onChange: (e) => onChange(parseCommas(e.target.value)),
|
|
1300
|
+
placeholder
|
|
1301
|
+
}
|
|
1302
|
+
),
|
|
1303
|
+
unit === "percent" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(InputGroupAddon, { align: "inline-end", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(InputGroupText, { children: "%" }) })
|
|
1304
|
+
] });
|
|
1305
|
+
}
|
|
1306
|
+
function RuleEditorFields({
|
|
1307
|
+
ruleProps,
|
|
1308
|
+
path,
|
|
1309
|
+
actions,
|
|
1310
|
+
fields,
|
|
1311
|
+
longestFieldLabel,
|
|
1312
|
+
longestOperatorLabel
|
|
1313
|
+
}) {
|
|
1314
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1315
|
+
const field = (_c = (_b = ruleProps == null ? void 0 : ruleProps.field) != null ? _b : (_a = fields[0]) == null ? void 0 : _a.key) != null ? _c : "";
|
|
1316
|
+
const operator = (_d = ruleProps == null ? void 0 : ruleProps.operator) != null ? _d : "greater_or_equal";
|
|
1317
|
+
const value0 = (_e = ruleProps == null ? void 0 : ruleProps.value) == null ? void 0 : _e[0];
|
|
1318
|
+
const value1 = (_f = ruleProps == null ? void 0 : ruleProps.value) == null ? void 0 : _f[1];
|
|
1319
|
+
const fieldDef = (_g = fields.find((f) => f.key === field)) != null ? _g : fields[0];
|
|
1320
|
+
const isBooleanField = (fieldDef == null ? void 0 : fieldDef.type) === "boolean";
|
|
1321
|
+
const availableOperators = isBooleanField ? BOOLEAN_OPERATORS : (_h = fieldDef == null ? void 0 : fieldDef.operators) != null ? _h : ALL_NUMERIC_OPERATORS;
|
|
1322
|
+
function handleFieldChange(key) {
|
|
1323
|
+
actions.setField(path, key);
|
|
1324
|
+
}
|
|
1325
|
+
function handleOperatorChange(op) {
|
|
1326
|
+
actions.setOperator(path, op);
|
|
1327
|
+
}
|
|
1328
|
+
function handleValueChange(idx, raw) {
|
|
1329
|
+
const n = parseFloat(parseCommas(raw));
|
|
1330
|
+
if (!isNaN(n)) {
|
|
1331
|
+
actions.setValue(path, idx, n, "number");
|
|
1332
|
+
} else if (!raw) {
|
|
1333
|
+
actions.setValue(path, idx, null, "number");
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
function handleBoolChange(v) {
|
|
1337
|
+
actions.setValue(path, 0, v === "true", "boolean");
|
|
1338
|
+
}
|
|
1339
|
+
const valStr = (v) => {
|
|
1340
|
+
if (v === null || v === void 0) return "";
|
|
1341
|
+
return String(v);
|
|
1342
|
+
};
|
|
1343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-wrap items-center gap-1.5", children: [
|
|
1344
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectAutoWidth, { longestLabel: longestFieldLabel, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1345
|
+
Select,
|
|
1346
|
+
{
|
|
1347
|
+
value: field,
|
|
1348
|
+
onValueChange: (v) => handleFieldChange(v),
|
|
1349
|
+
children: [
|
|
1350
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectTrigger, { size: "sm", className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectValue, { children: (_j = (_i = fields.find((f) => f.key === field)) == null ? void 0 : _i.label) != null ? _j : field }) }),
|
|
1351
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectContent, { children: fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectItem, { value: f.key, children: f.label }, f.key)) })
|
|
1352
|
+
]
|
|
1353
|
+
}
|
|
1354
|
+
) }),
|
|
1355
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectAutoWidth, { longestLabel: longestOperatorLabel, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1356
|
+
Select,
|
|
1357
|
+
{
|
|
1358
|
+
value: operator,
|
|
1359
|
+
onValueChange: (v) => handleOperatorChange(v),
|
|
1360
|
+
children: [
|
|
1361
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectTrigger, { size: "sm", className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectValue, { children: (_k = OPERATOR_LABELS[operator]) != null ? _k : operator }) }),
|
|
1362
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectContent, { children: availableOperators.map((op) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectItem, { value: op, children: OPERATOR_LABELS[op] }, op)) })
|
|
1363
|
+
]
|
|
1364
|
+
}
|
|
1365
|
+
) }),
|
|
1366
|
+
isBooleanField ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1367
|
+
Select,
|
|
1368
|
+
{
|
|
1369
|
+
value: String(value0 != null ? value0 : true),
|
|
1370
|
+
onValueChange: (v) => handleBoolChange(v),
|
|
1371
|
+
children: [
|
|
1372
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectTrigger, { size: "sm", className: "w-36", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectValue, { children: (value0 != null ? value0 : true) ? "Yes" : "No" }) }),
|
|
1373
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(SelectContent, { children: [
|
|
1374
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectItem, { value: "true", children: "Yes" }),
|
|
1375
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectItem, { value: "false", children: "No" })
|
|
1376
|
+
] })
|
|
1377
|
+
]
|
|
1378
|
+
}
|
|
1379
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
1380
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1381
|
+
ValueInput,
|
|
1382
|
+
{
|
|
1383
|
+
value: valStr(value0),
|
|
1384
|
+
onChange: (v) => handleValueChange(0, v),
|
|
1385
|
+
unit: fieldDef == null ? void 0 : fieldDef.unit
|
|
1386
|
+
}
|
|
1387
|
+
),
|
|
1388
|
+
operator === "between" && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
1389
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-xs text-muted-foreground", children: "and" }),
|
|
1390
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1391
|
+
ValueInput,
|
|
1392
|
+
{
|
|
1393
|
+
value: valStr(value1),
|
|
1394
|
+
onChange: (v) => handleValueChange(1, v),
|
|
1395
|
+
unit: fieldDef == null ? void 0 : fieldDef.unit
|
|
1396
|
+
}
|
|
1397
|
+
)
|
|
1398
|
+
] })
|
|
1399
|
+
] })
|
|
1400
|
+
] });
|
|
1401
|
+
}
|
|
1402
|
+
function RuleAccordionItem({
|
|
1403
|
+
ruleId,
|
|
1404
|
+
ruleProps,
|
|
1405
|
+
path,
|
|
1406
|
+
actions,
|
|
1407
|
+
fields,
|
|
1408
|
+
longestFieldLabel,
|
|
1409
|
+
longestOperatorLabel,
|
|
1410
|
+
removable
|
|
1411
|
+
}) {
|
|
1412
|
+
const summary = ruleSummary(ruleProps, fields);
|
|
1413
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_accordion.Accordion.Item, { value: ruleId, className: "border-b", children: [
|
|
1414
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_accordion.Accordion.Header, { className: "flex items-center", children: [
|
|
1415
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1416
|
+
import_accordion.Accordion.Trigger,
|
|
1417
|
+
{
|
|
1418
|
+
className: cn(
|
|
1419
|
+
"flex flex-1 items-center gap-3 py-3 text-left text-sm outline-none",
|
|
1420
|
+
"rounded-none hover:underline",
|
|
1421
|
+
"focus-visible:ring-2 focus-visible:ring-foreground/30",
|
|
1422
|
+
"[&[data-panel-open]>svg:last-child]:rotate-180"
|
|
1423
|
+
),
|
|
1424
|
+
children: [
|
|
1425
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "flex-1 text-sm text-foreground", children: summary }),
|
|
1426
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.ChevronDownIcon, { className: "size-4 shrink-0 text-muted-foreground transition-transform duration-200" })
|
|
1427
|
+
]
|
|
1428
|
+
}
|
|
1429
|
+
),
|
|
1430
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1431
|
+
Button,
|
|
1432
|
+
{
|
|
1433
|
+
type: "button",
|
|
1434
|
+
variant: "ghost",
|
|
1435
|
+
size: "sm",
|
|
1436
|
+
className: "shrink-0 px-2",
|
|
1437
|
+
onClick: () => actions.removeRule(path),
|
|
1438
|
+
disabled: !removable,
|
|
1439
|
+
"aria-label": "Remove rule",
|
|
1440
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.Trash2Icon, { className: "size-4" })
|
|
1441
|
+
}
|
|
1442
|
+
)
|
|
1443
|
+
] }),
|
|
1444
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_accordion.Accordion.Panel, { className: "overflow-hidden h-(--accordion-panel-height) transition-[height] duration-200 ease-out data-starting-style:h-0 data-ending-style:h-0", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "pb-3", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1445
|
+
RuleEditorFields,
|
|
1446
|
+
{
|
|
1447
|
+
ruleProps,
|
|
1448
|
+
path,
|
|
1449
|
+
actions,
|
|
1450
|
+
fields,
|
|
1451
|
+
longestFieldLabel,
|
|
1452
|
+
longestOperatorLabel
|
|
1453
|
+
}
|
|
1454
|
+
) }) })
|
|
1455
|
+
] });
|
|
1456
|
+
}
|
|
1457
|
+
function SubGroupAccordionItem({
|
|
1458
|
+
groupId,
|
|
1459
|
+
group,
|
|
1460
|
+
path,
|
|
1461
|
+
actions,
|
|
1462
|
+
fields,
|
|
1463
|
+
longestFieldLabel,
|
|
1464
|
+
longestOperatorLabel
|
|
1465
|
+
}) {
|
|
1466
|
+
var _a, _b, _c;
|
|
1467
|
+
const conjunction = (_b = (_a = group.properties) == null ? void 0 : _a.conjunction) != null ? _b : "AND";
|
|
1468
|
+
const nestedChildren = (_c = group.children1) != null ? _c : [];
|
|
1469
|
+
const count = nestedChildren.length;
|
|
1470
|
+
const triggerLabel = `Group (${count} ${count === 1 ? "rule" : "rules"})`;
|
|
1471
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_accordion.Accordion.Item, { value: groupId, className: "border-b", children: [
|
|
1472
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_accordion.Accordion.Header, { className: "flex items-center", children: [
|
|
1473
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1474
|
+
import_accordion.Accordion.Trigger,
|
|
1475
|
+
{
|
|
1476
|
+
className: cn(
|
|
1477
|
+
"flex flex-1 items-center gap-3 py-3 text-left text-sm outline-none",
|
|
1478
|
+
"rounded-none hover:underline",
|
|
1479
|
+
"focus-visible:ring-2 focus-visible:ring-foreground/30",
|
|
1480
|
+
"[&[data-panel-open]>svg:last-child]:rotate-180"
|
|
1481
|
+
),
|
|
1482
|
+
children: [
|
|
1483
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "flex-1 text-sm font-medium text-foreground", children: triggerLabel }),
|
|
1484
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.ChevronDownIcon, { className: "size-4 shrink-0 text-muted-foreground transition-transform duration-200" })
|
|
1485
|
+
]
|
|
1486
|
+
}
|
|
1487
|
+
),
|
|
1488
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1489
|
+
Button,
|
|
1490
|
+
{
|
|
1491
|
+
type: "button",
|
|
1492
|
+
variant: "ghost",
|
|
1493
|
+
size: "sm",
|
|
1494
|
+
className: "shrink-0 px-2",
|
|
1495
|
+
onClick: () => actions.removeGroup(path),
|
|
1496
|
+
"aria-label": "Remove group",
|
|
1497
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.Trash2Icon, { className: "size-4" })
|
|
1498
|
+
}
|
|
1499
|
+
)
|
|
1500
|
+
] }),
|
|
1501
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_accordion.Accordion.Panel, { className: "overflow-hidden h-(--accordion-panel-height) transition-[height] duration-200 ease-out data-starting-style:h-0 data-ending-style:h-0", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "pb-3 pl-4 border-l ml-2 flex flex-col gap-3", children: [
|
|
1502
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1255
1503
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1256
|
-
|
|
1504
|
+
Checkbox,
|
|
1257
1505
|
{
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
longestOperatorLabel,
|
|
1262
|
-
onUpdate: (updated) => updateRule(idx, updated),
|
|
1263
|
-
onRemove: () => removeRule(idx),
|
|
1264
|
-
removable: value.rules.length > 1
|
|
1506
|
+
id: `subgroup-${groupId}-combinator`,
|
|
1507
|
+
checked: conjunction === "AND",
|
|
1508
|
+
onCheckedChange: (checked) => actions.setConjunction(path, checked ? "AND" : "OR")
|
|
1265
1509
|
}
|
|
1266
1510
|
),
|
|
1267
|
-
|
|
1268
|
-
|
|
1511
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1512
|
+
Label,
|
|
1269
1513
|
{
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
value: (_a = value.logicalOps[idx]) != null ? _a : "AND",
|
|
1274
|
-
onValueChange: (v) => v && setLogicalOp(idx, v),
|
|
1275
|
-
children: [
|
|
1276
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ToggleGroupItem, { value: "AND", children: "AND" }),
|
|
1277
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ToggleGroupItem, { value: "OR", children: "OR" })
|
|
1278
|
-
]
|
|
1514
|
+
htmlFor: `subgroup-${groupId}-combinator`,
|
|
1515
|
+
className: "cursor-pointer font-normal text-sm",
|
|
1516
|
+
children: "Match all conditions"
|
|
1279
1517
|
}
|
|
1280
|
-
)
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1518
|
+
),
|
|
1519
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "text-xs text-muted-foreground", children: [
|
|
1520
|
+
"(",
|
|
1521
|
+
conjunction,
|
|
1522
|
+
")"
|
|
1523
|
+
] })
|
|
1524
|
+
] }),
|
|
1525
|
+
nestedChildren.map((child) => {
|
|
1526
|
+
var _a2;
|
|
1527
|
+
const c = child;
|
|
1528
|
+
const ruleId = (_a2 = c.id) != null ? _a2 : "";
|
|
1529
|
+
const rulePath = [...path, ruleId];
|
|
1530
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-start gap-1.5", children: [
|
|
1531
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1532
|
+
RuleEditorFields,
|
|
1533
|
+
{
|
|
1534
|
+
ruleProps: c.properties,
|
|
1535
|
+
path: rulePath,
|
|
1536
|
+
actions,
|
|
1537
|
+
fields,
|
|
1538
|
+
longestFieldLabel,
|
|
1539
|
+
longestOperatorLabel
|
|
1540
|
+
}
|
|
1541
|
+
) }),
|
|
1542
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1543
|
+
Button,
|
|
1544
|
+
{
|
|
1545
|
+
type: "button",
|
|
1546
|
+
variant: "ghost",
|
|
1547
|
+
size: "sm",
|
|
1548
|
+
className: "shrink-0 px-2",
|
|
1549
|
+
onClick: () => actions.removeRule(rulePath),
|
|
1550
|
+
disabled: nestedChildren.length <= 1,
|
|
1551
|
+
"aria-label": "Remove rule",
|
|
1552
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.Trash2Icon, { className: "size-4" })
|
|
1553
|
+
}
|
|
1554
|
+
)
|
|
1555
|
+
] }, ruleId);
|
|
1556
|
+
}),
|
|
1557
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1558
|
+
Button,
|
|
1559
|
+
{
|
|
1560
|
+
type: "button",
|
|
1561
|
+
variant: "ghost",
|
|
1562
|
+
size: "sm",
|
|
1563
|
+
onClick: () => actions.addRule(path),
|
|
1564
|
+
className: "w-fit",
|
|
1565
|
+
children: [
|
|
1566
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.PlusIcon, { className: "size-4" }),
|
|
1567
|
+
"Add rule"
|
|
1568
|
+
]
|
|
1569
|
+
}
|
|
1570
|
+
)
|
|
1571
|
+
] }) })
|
|
1572
|
+
] });
|
|
1573
|
+
}
|
|
1574
|
+
function CustomBuilderUI({
|
|
1575
|
+
tree,
|
|
1576
|
+
actions,
|
|
1577
|
+
fields,
|
|
1578
|
+
defaultOpenItems,
|
|
1579
|
+
className
|
|
1580
|
+
}) {
|
|
1581
|
+
var _a, _b, _c, _d;
|
|
1582
|
+
const treeJson = import_ui3.Utils.getTree(tree);
|
|
1583
|
+
const rootId = (_a = treeJson == null ? void 0 : treeJson.id) != null ? _a : "root";
|
|
1584
|
+
const conjunction = (_c = (_b = treeJson == null ? void 0 : treeJson.properties) == null ? void 0 : _b.conjunction) != null ? _c : "AND";
|
|
1585
|
+
const children = (_d = treeJson == null ? void 0 : treeJson.children1) != null ? _d : [];
|
|
1586
|
+
const longestFieldLabel = React4.useMemo(
|
|
1587
|
+
() => longestOf(fields.map((f) => f.label)),
|
|
1588
|
+
[fields]
|
|
1589
|
+
);
|
|
1590
|
+
const longestOperatorLabel = React4.useMemo(
|
|
1591
|
+
() => longestOf(allOperatorLabels(fields)),
|
|
1592
|
+
[fields]
|
|
1593
|
+
);
|
|
1594
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: cn("flex flex-col gap-3", className), children: [
|
|
1595
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1596
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1597
|
+
Checkbox,
|
|
1598
|
+
{
|
|
1599
|
+
id: "qb-root-combinator",
|
|
1600
|
+
checked: conjunction === "AND",
|
|
1601
|
+
onCheckedChange: (checked) => actions.setConjunction([rootId], checked ? "AND" : "OR")
|
|
1602
|
+
}
|
|
1603
|
+
),
|
|
1604
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1605
|
+
Label,
|
|
1606
|
+
{
|
|
1607
|
+
htmlFor: "qb-root-combinator",
|
|
1608
|
+
className: "cursor-pointer font-normal text-sm",
|
|
1609
|
+
children: "Match all conditions"
|
|
1610
|
+
}
|
|
1611
|
+
),
|
|
1612
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "text-xs text-muted-foreground", children: [
|
|
1613
|
+
"(",
|
|
1614
|
+
conjunction,
|
|
1615
|
+
")"
|
|
1616
|
+
] })
|
|
1617
|
+
] }),
|
|
1618
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1619
|
+
import_accordion.Accordion.Root,
|
|
1285
1620
|
{
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1621
|
+
multiple: true,
|
|
1622
|
+
defaultValue: defaultOpenItems,
|
|
1623
|
+
className: "border-t",
|
|
1624
|
+
children: children.map((child) => {
|
|
1625
|
+
var _a2;
|
|
1626
|
+
const c = child;
|
|
1627
|
+
const childId = (_a2 = c.id) != null ? _a2 : "";
|
|
1628
|
+
const childPath = [rootId, childId];
|
|
1629
|
+
if (c.type === "group") {
|
|
1630
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1631
|
+
SubGroupAccordionItem,
|
|
1632
|
+
{
|
|
1633
|
+
groupId: childId,
|
|
1634
|
+
group: c,
|
|
1635
|
+
path: childPath,
|
|
1636
|
+
actions,
|
|
1637
|
+
fields,
|
|
1638
|
+
longestFieldLabel,
|
|
1639
|
+
longestOperatorLabel
|
|
1640
|
+
},
|
|
1641
|
+
childId
|
|
1642
|
+
);
|
|
1643
|
+
}
|
|
1644
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1645
|
+
RuleAccordionItem,
|
|
1646
|
+
{
|
|
1647
|
+
ruleId: childId,
|
|
1648
|
+
ruleProps: c.properties,
|
|
1649
|
+
path: childPath,
|
|
1650
|
+
actions,
|
|
1651
|
+
fields,
|
|
1652
|
+
longestFieldLabel,
|
|
1653
|
+
longestOperatorLabel,
|
|
1654
|
+
removable: children.length > 1
|
|
1655
|
+
},
|
|
1656
|
+
childId
|
|
1657
|
+
);
|
|
1658
|
+
})
|
|
1295
1659
|
}
|
|
1296
|
-
)
|
|
1660
|
+
),
|
|
1661
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex gap-2", children: [
|
|
1662
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1663
|
+
Button,
|
|
1664
|
+
{
|
|
1665
|
+
type: "button",
|
|
1666
|
+
variant: "outline",
|
|
1667
|
+
size: "sm",
|
|
1668
|
+
onClick: () => actions.addRule([rootId]),
|
|
1669
|
+
children: [
|
|
1670
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.PlusIcon, { className: "size-4" }),
|
|
1671
|
+
"Add rule"
|
|
1672
|
+
]
|
|
1673
|
+
}
|
|
1674
|
+
),
|
|
1675
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1676
|
+
Button,
|
|
1677
|
+
{
|
|
1678
|
+
type: "button",
|
|
1679
|
+
variant: "outline",
|
|
1680
|
+
size: "sm",
|
|
1681
|
+
onClick: () => actions.addGroup([rootId]),
|
|
1682
|
+
children: [
|
|
1683
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.PlusIcon, { className: "size-4" }),
|
|
1684
|
+
"Add group"
|
|
1685
|
+
]
|
|
1686
|
+
}
|
|
1687
|
+
)
|
|
1688
|
+
] })
|
|
1297
1689
|
] });
|
|
1298
1690
|
}
|
|
1691
|
+
|
|
1692
|
+
// src/components/ui/contact-alert-dialog/contact-alert-dialog.tsx
|
|
1693
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1694
|
+
function ContactAlertQueryBuilder({
|
|
1695
|
+
value,
|
|
1696
|
+
onChange,
|
|
1697
|
+
fields = ALERT_QUERY_FIELDS,
|
|
1698
|
+
className
|
|
1699
|
+
}) {
|
|
1700
|
+
const defaultOpenItems = React5.useMemo(() => {
|
|
1701
|
+
var _a;
|
|
1702
|
+
const json = import_ui4.Utils.getTree(value);
|
|
1703
|
+
return ((_a = json == null ? void 0 : json.children1) != null ? _a : []).map((c) => {
|
|
1704
|
+
var _a2;
|
|
1705
|
+
return (_a2 = c.id) != null ? _a2 : "";
|
|
1706
|
+
}).filter(Boolean);
|
|
1707
|
+
}, []);
|
|
1708
|
+
const renderBuilder = React5.useCallback(
|
|
1709
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1710
|
+
(props) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1711
|
+
CustomBuilderUI,
|
|
1712
|
+
{
|
|
1713
|
+
tree: props.tree,
|
|
1714
|
+
actions: props.actions,
|
|
1715
|
+
fields,
|
|
1716
|
+
defaultOpenItems,
|
|
1717
|
+
className
|
|
1718
|
+
}
|
|
1719
|
+
),
|
|
1720
|
+
[fields, defaultOpenItems, className]
|
|
1721
|
+
);
|
|
1722
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1723
|
+
import_ui4.Query,
|
|
1724
|
+
__spreadProps(__spreadValues({}, QB_CONFIG), {
|
|
1725
|
+
value,
|
|
1726
|
+
onChange: (newTree) => onChange(newTree),
|
|
1727
|
+
renderBuilder
|
|
1728
|
+
})
|
|
1729
|
+
);
|
|
1730
|
+
}
|
|
1299
1731
|
function ContactAlertDialog({
|
|
1300
1732
|
open,
|
|
1301
1733
|
onOpenChange,
|
|
@@ -1309,36 +1741,38 @@ function ContactAlertDialog({
|
|
|
1309
1741
|
isLoading = false,
|
|
1310
1742
|
className
|
|
1311
1743
|
}) {
|
|
1312
|
-
const [name, setName] =
|
|
1313
|
-
const [severity, setSeverity] =
|
|
1314
|
-
const [
|
|
1315
|
-
|
|
1744
|
+
const [name, setName] = React5.useState(initialName);
|
|
1745
|
+
const [severity, setSeverity] = React5.useState(initialSeverity);
|
|
1746
|
+
const [tree, setTree] = React5.useState(
|
|
1747
|
+
() => createAlertTree(initialQuery)
|
|
1316
1748
|
);
|
|
1317
|
-
const [shareAcrossCompany, setShareAcrossCompany] =
|
|
1749
|
+
const [shareAcrossCompany, setShareAcrossCompany] = React5.useState(
|
|
1318
1750
|
initialShareAcrossCompany
|
|
1319
1751
|
);
|
|
1320
|
-
|
|
1752
|
+
React5.useEffect(() => {
|
|
1321
1753
|
if (open) {
|
|
1322
1754
|
setName(initialName);
|
|
1323
1755
|
setSeverity(initialSeverity);
|
|
1324
|
-
|
|
1756
|
+
setTree(createAlertTree(initialQuery));
|
|
1325
1757
|
setShareAcrossCompany(initialShareAcrossCompany);
|
|
1326
1758
|
}
|
|
1327
1759
|
}, [open]);
|
|
1328
|
-
const hasValidRule =
|
|
1329
|
-
const fieldDef = ALERT_QUERY_FIELDS.find((f) => f.key === r.field);
|
|
1330
|
-
return (fieldDef == null ? void 0 : fieldDef.type) === "boolean" || r.value !== "";
|
|
1331
|
-
});
|
|
1760
|
+
const hasValidRule = React5.useMemo(() => isTreeValid(tree), [tree]);
|
|
1332
1761
|
const canSave = name.trim().length > 0 && hasValidRule && !isLoading;
|
|
1333
1762
|
function handleSave() {
|
|
1334
1763
|
if (!canSave) return;
|
|
1335
|
-
onSave({
|
|
1764
|
+
onSave({
|
|
1765
|
+
name: name.trim(),
|
|
1766
|
+
severity,
|
|
1767
|
+
filterSegment: import_ui4.Utils.sanitizeTree(tree, QB_CONFIG).fixedTree,
|
|
1768
|
+
sharingType: shareAcrossCompany ? "COMPANY" /* COMPANY */ : "PRIVATE" /* PRIVATE */
|
|
1769
|
+
});
|
|
1336
1770
|
}
|
|
1337
|
-
return /* @__PURE__ */ (0,
|
|
1338
|
-
/* @__PURE__ */ (0,
|
|
1339
|
-
/* @__PURE__ */ (0,
|
|
1340
|
-
/* @__PURE__ */ (0,
|
|
1341
|
-
/* @__PURE__ */ (0,
|
|
1771
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Dialog, { open, onOpenChange: isLoading ? void 0 : onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(DialogContent, { size: "2xl", className, children: [
|
|
1772
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DialogTitle, { children: mode === "edit" ? "Update Alert" : "Create Alert" }) }),
|
|
1773
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col gap-1.5", children: [
|
|
1774
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-sm font-medium text-foreground", children: "Alert trigger severity" }),
|
|
1775
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1342
1776
|
ToggleGroup,
|
|
1343
1777
|
{
|
|
1344
1778
|
type: "single",
|
|
@@ -1346,13 +1780,13 @@ function ContactAlertDialog({
|
|
|
1346
1780
|
size: "sm",
|
|
1347
1781
|
value: severity,
|
|
1348
1782
|
onValueChange: (v) => v && setSeverity(v),
|
|
1349
|
-
children: ["NEED_ACTION", "WATCH", "INSIGHT"].map((s) => /* @__PURE__ */ (0,
|
|
1783
|
+
children: ["NEED_ACTION", "WATCH", "INSIGHT"].map((s) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ToggleGroupItem, { value: s, children: SEVERITY_LABELS[s] }, s))
|
|
1350
1784
|
}
|
|
1351
1785
|
)
|
|
1352
1786
|
] }),
|
|
1353
|
-
/* @__PURE__ */ (0,
|
|
1354
|
-
/* @__PURE__ */ (0,
|
|
1355
|
-
/* @__PURE__ */ (0,
|
|
1787
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Field, { children: [
|
|
1788
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(FieldLabel, { children: "Alert name" }),
|
|
1789
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1356
1790
|
Input,
|
|
1357
1791
|
{
|
|
1358
1792
|
value: name,
|
|
@@ -1361,8 +1795,8 @@ function ContactAlertDialog({
|
|
|
1361
1795
|
}
|
|
1362
1796
|
)
|
|
1363
1797
|
] }),
|
|
1364
|
-
isCompanyAdmin && /* @__PURE__ */ (0,
|
|
1365
|
-
/* @__PURE__ */ (0,
|
|
1798
|
+
isCompanyAdmin && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1799
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1366
1800
|
Checkbox,
|
|
1367
1801
|
{
|
|
1368
1802
|
id: "alert-share",
|
|
@@ -1370,21 +1804,21 @@ function ContactAlertDialog({
|
|
|
1370
1804
|
onCheckedChange: (v) => setShareAcrossCompany(!!v)
|
|
1371
1805
|
}
|
|
1372
1806
|
),
|
|
1373
|
-
/* @__PURE__ */ (0,
|
|
1807
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Label, { htmlFor: "alert-share", className: "cursor-pointer font-normal", children: "Share across company" })
|
|
1374
1808
|
] }),
|
|
1375
|
-
/* @__PURE__ */ (0,
|
|
1376
|
-
/* @__PURE__ */ (0,
|
|
1377
|
-
/* @__PURE__ */ (0,
|
|
1809
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col gap-1.5", children: [
|
|
1810
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-sm font-medium text-foreground", children: "Filter conditions" }),
|
|
1811
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1378
1812
|
ContactAlertQueryBuilder,
|
|
1379
1813
|
{
|
|
1380
|
-
value:
|
|
1381
|
-
onChange:
|
|
1814
|
+
value: tree,
|
|
1815
|
+
onChange: setTree,
|
|
1382
1816
|
fields: ALERT_QUERY_FIELDS
|
|
1383
1817
|
}
|
|
1384
1818
|
)
|
|
1385
1819
|
] }),
|
|
1386
|
-
/* @__PURE__ */ (0,
|
|
1387
|
-
/* @__PURE__ */ (0,
|
|
1820
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(DialogFooter, { children: [
|
|
1821
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1388
1822
|
Button,
|
|
1389
1823
|
{
|
|
1390
1824
|
variant: "outline",
|
|
@@ -1393,13 +1827,15 @@ function ContactAlertDialog({
|
|
|
1393
1827
|
children: "Cancel"
|
|
1394
1828
|
}
|
|
1395
1829
|
),
|
|
1396
|
-
/* @__PURE__ */ (0,
|
|
1830
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Button, { disabled: !canSave, onClick: handleSave, children: mode === "edit" ? "Update Alert" : "Create Alert" })
|
|
1397
1831
|
] })
|
|
1398
1832
|
] }) });
|
|
1399
1833
|
}
|
|
1400
1834
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1401
1835
|
0 && (module.exports = {
|
|
1402
1836
|
ALERT_QUERY_FIELDS,
|
|
1837
|
+
AlertSharingType,
|
|
1403
1838
|
ContactAlertDialog,
|
|
1404
|
-
ContactAlertQueryBuilder
|
|
1839
|
+
ContactAlertQueryBuilder,
|
|
1840
|
+
createAlertTree
|
|
1405
1841
|
});
|