@pibit.ai/cure-design-system 0.6.34 → 0.6.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +453 -425
- package/dist/patterns/condition-builder/add-action-button.d.ts +17 -0
- package/dist/patterns/condition-builder/add-action-button.d.ts.map +1 -0
- package/dist/patterns/condition-builder/add-action-button.js +26 -0
- package/dist/patterns/condition-builder/condition-builder.d.ts +4 -0
- package/dist/patterns/condition-builder/condition-builder.d.ts.map +1 -0
- package/dist/patterns/condition-builder/condition-builder.js +134 -0
- package/dist/patterns/condition-builder/condition-group.d.ts +4 -0
- package/dist/patterns/condition-builder/condition-group.d.ts.map +1 -0
- package/dist/patterns/condition-builder/condition-group.js +476 -0
- package/dist/patterns/condition-builder/condition-reorder-handle.d.ts +17 -0
- package/dist/patterns/condition-builder/condition-reorder-handle.d.ts.map +1 -0
- package/dist/patterns/condition-builder/condition-reorder-handle.js +66 -0
- package/dist/patterns/condition-builder/condition-row.d.ts +4 -0
- package/dist/patterns/condition-builder/condition-row.d.ts.map +1 -0
- package/dist/patterns/condition-builder/condition-row.js +238 -0
- package/dist/patterns/condition-builder/index.d.ts +43 -0
- package/dist/patterns/condition-builder/index.d.ts.map +1 -0
- package/dist/patterns/condition-builder/types.d.ts +342 -0
- package/dist/patterns/condition-builder/types.d.ts.map +1 -0
- package/dist/patterns/condition-builder/types.js +16 -0
- package/dist/patterns/condition-builder/utils.d.ts +73 -0
- package/dist/patterns/condition-builder/utils.d.ts.map +1 -0
- package/dist/patterns/condition-builder/utils.js +180 -0
- package/dist/patterns/condition-builder/utils.test.d.ts +2 -0
- package/dist/patterns/condition-builder/utils.test.d.ts.map +1 -0
- package/dist/patterns/confirm-dialog/confirm-dialog.d.ts.map +1 -1
- package/dist/patterns/confirm-dialog/confirm-dialog.js +15 -15
- package/dist/styles/components.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Link-style add action ("Add Filter", "Add Filter Group") on the DS Button, kept visually
|
|
4
|
+
* identical to the raw button it replaces: medium weight, 1.5 gap, caller-driven colour and
|
|
5
|
+
* font size (the caller's classes land last, so they win over the link variant's defaults).
|
|
6
|
+
*/
|
|
7
|
+
export declare const AddActionButton: ({ icon: Icon, fontSize, iconSize, className, onClick, children, }: {
|
|
8
|
+
icon: FC<{
|
|
9
|
+
className?: string;
|
|
10
|
+
}>;
|
|
11
|
+
fontSize: string;
|
|
12
|
+
iconSize: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
onClick: () => void;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=add-action-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-action-button.d.ts","sourceRoot":"","sources":["../../../src/patterns/condition-builder/add-action-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAI3C;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,mEAO7B;IACC,IAAI,EAAE,EAAE,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;CACvB,4CAYA,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { cx as e } from "../../utils/cn.js";
|
|
3
|
+
import { Button as s } from "../../primitives/button/button.js";
|
|
4
|
+
const d = ({
|
|
5
|
+
icon: o,
|
|
6
|
+
fontSize: t,
|
|
7
|
+
iconSize: i,
|
|
8
|
+
className: m,
|
|
9
|
+
onClick: n,
|
|
10
|
+
children: r
|
|
11
|
+
}) => /* @__PURE__ */ c(
|
|
12
|
+
s,
|
|
13
|
+
{
|
|
14
|
+
type: "button",
|
|
15
|
+
color: "link-color",
|
|
16
|
+
size: "sm",
|
|
17
|
+
iconLeading: o,
|
|
18
|
+
leadingClassName: i,
|
|
19
|
+
className: e("gap-1.5 font-medium", t, m),
|
|
20
|
+
onClick: n,
|
|
21
|
+
children: r
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
export {
|
|
25
|
+
d as AddActionButton
|
|
26
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ConditionBuilderProps, BaseGroupCondition, BaseLeafCondition } from './types';
|
|
2
|
+
export declare function ConditionBuilder<TCondition, TLeaf extends TCondition & BaseLeafCondition, TGroup extends TCondition & BaseGroupCondition<TCondition>>({ conditions, rootOperator, config, onAddCondition, onUpdateCondition, onDeleteCondition, onAddGroup, onUpdateGroupOperator, onDeleteGroup, onDuplicateCondition, onReorder, onUpdateRootOperator, renderLeafRow, hideOperatorColumn, invalidPaths, getErrorMessage, maxDepth, size, emptyStateLabel, addFilterLabel, addFilterGroupLabel, addActionClassName, nestedAddActionClassName, hideAddActions, getOperatorOptions, className, reorderGroupClassName, extraAddActions, renderCustomNode, isDeleteDisabled, showRootClearGroup, onRootClearGroup, }: ConditionBuilderProps<TCondition, TLeaf, TGroup>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export default ConditionBuilder;
|
|
4
|
+
//# sourceMappingURL=condition-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condition-builder.d.ts","sourceRoot":"","sources":["../../../src/patterns/condition-builder/condition-builder.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAqB5F,wBAAgB,gBAAgB,CAC5B,UAAU,EACV,KAAK,SAAS,UAAU,GAAG,iBAAiB,EAC5C,MAAM,SAAS,UAAU,GAAG,kBAAkB,CAAC,UAAU,CAAC,EAC5D,EACE,UAAU,EACV,YAAY,EACZ,MAAM,EACN,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,SAAS,EACT,oBAAoB,EACpB,aAAa,EACb,kBAA0B,EAC1B,YAAwB,EACxB,eAAe,EACf,QAAY,EACZ,IAAW,EACX,eAA8B,EAC9B,cAA6B,EAC7B,mBAAwC,EACxC,kBAA0D,EAC1D,wBAAwB,EACxB,cAAsB,EACtB,kBAAkB,EAClB,SAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,kBAA0B,EAC1B,gBAAgB,GACnB,EAAE,qBAAqB,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,2CA6FlD;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as O } from "react";
|
|
3
|
+
import { Plus as x } from "@untitledui/icons";
|
|
4
|
+
import { ConditionGroup as Q } from "./condition-group.js";
|
|
5
|
+
import { AddActionButton as v } from "./add-action-button.js";
|
|
6
|
+
import { cx as S } from "../../utils/cn.js";
|
|
7
|
+
const o = {
|
|
8
|
+
sm: "text-xs",
|
|
9
|
+
md: "text-sm",
|
|
10
|
+
lg: "text-md"
|
|
11
|
+
}, N = {
|
|
12
|
+
sm: "size-4",
|
|
13
|
+
md: "size-5",
|
|
14
|
+
lg: "size-6"
|
|
15
|
+
};
|
|
16
|
+
function Z({
|
|
17
|
+
conditions: l,
|
|
18
|
+
rootOperator: m,
|
|
19
|
+
config: g,
|
|
20
|
+
onAddCondition: s,
|
|
21
|
+
onUpdateCondition: y,
|
|
22
|
+
onDeleteCondition: w,
|
|
23
|
+
onAddGroup: c,
|
|
24
|
+
onUpdateGroupOperator: z,
|
|
25
|
+
onDeleteGroup: F,
|
|
26
|
+
onDuplicateCondition: G,
|
|
27
|
+
onReorder: P,
|
|
28
|
+
onUpdateRootOperator: b,
|
|
29
|
+
renderLeafRow: j,
|
|
30
|
+
hideOperatorColumn: k = !1,
|
|
31
|
+
invalidPaths: B = /* @__PURE__ */ new Set(),
|
|
32
|
+
getErrorMessage: C,
|
|
33
|
+
maxDepth: f = 2,
|
|
34
|
+
size: e = "sm",
|
|
35
|
+
emptyStateLabel: M = "conditions",
|
|
36
|
+
addFilterLabel: a = "Add Filter",
|
|
37
|
+
addFilterGroupLabel: d = "Add Filter Group",
|
|
38
|
+
addActionClassName: i = "text-brand-600 hover:text-brand-700",
|
|
39
|
+
nestedAddActionClassName: U,
|
|
40
|
+
hideAddActions: p = !1,
|
|
41
|
+
getOperatorOptions: q,
|
|
42
|
+
className: D = "py-2",
|
|
43
|
+
reorderGroupClassName: E,
|
|
44
|
+
extraAddActions: r,
|
|
45
|
+
renderCustomNode: H,
|
|
46
|
+
isDeleteDisabled: I,
|
|
47
|
+
showRootClearGroup: J = !1,
|
|
48
|
+
onRootClearGroup: K
|
|
49
|
+
}) {
|
|
50
|
+
const L = O(
|
|
51
|
+
() => ({
|
|
52
|
+
operator: m,
|
|
53
|
+
conditions: l
|
|
54
|
+
}),
|
|
55
|
+
[m, l]
|
|
56
|
+
);
|
|
57
|
+
return l.length === 0 ? /* @__PURE__ */ t("div", { className: "py-4", children: /* @__PURE__ */ n("div", { className: S("text-center py-8 text-tertiary", o[e]), children: [
|
|
58
|
+
/* @__PURE__ */ n("p", { className: "mb-4", children: [
|
|
59
|
+
"No ",
|
|
60
|
+
M,
|
|
61
|
+
" defined yet."
|
|
62
|
+
] }),
|
|
63
|
+
p ? null : /* @__PURE__ */ n("div", { className: "flex items-center justify-center gap-3", children: [
|
|
64
|
+
/* @__PURE__ */ t(
|
|
65
|
+
v,
|
|
66
|
+
{
|
|
67
|
+
icon: x,
|
|
68
|
+
fontSize: o[e],
|
|
69
|
+
iconSize: N[e],
|
|
70
|
+
className: i,
|
|
71
|
+
onClick: () => s([]),
|
|
72
|
+
children: a
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
/* @__PURE__ */ t(
|
|
76
|
+
v,
|
|
77
|
+
{
|
|
78
|
+
icon: x,
|
|
79
|
+
fontSize: o[e],
|
|
80
|
+
iconSize: N[e],
|
|
81
|
+
className: i,
|
|
82
|
+
onClick: () => c([]),
|
|
83
|
+
children: d
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
r == null ? void 0 : r({
|
|
87
|
+
nodePath: [],
|
|
88
|
+
level: 0,
|
|
89
|
+
canAddNestedGroup: 0 < f
|
|
90
|
+
})
|
|
91
|
+
] })
|
|
92
|
+
] }) }) : /* @__PURE__ */ t("div", { className: S(D, "min-w-0 max-w-full overflow-x-hidden"), children: /* @__PURE__ */ t(
|
|
93
|
+
Q,
|
|
94
|
+
{
|
|
95
|
+
group: L,
|
|
96
|
+
nodePath: [],
|
|
97
|
+
level: 0,
|
|
98
|
+
maxDepth: f ?? 2,
|
|
99
|
+
isFirst: !0,
|
|
100
|
+
config: g,
|
|
101
|
+
onAddCondition: s,
|
|
102
|
+
onUpdateCondition: y,
|
|
103
|
+
onDeleteCondition: w,
|
|
104
|
+
onAddGroup: c,
|
|
105
|
+
onUpdateGroupOperator: (u, h) => {
|
|
106
|
+
u.length === 0 ? b(h) : z(u, h);
|
|
107
|
+
},
|
|
108
|
+
onDeleteGroup: F,
|
|
109
|
+
onDuplicateCondition: G,
|
|
110
|
+
onReorder: P,
|
|
111
|
+
renderLeafRow: j,
|
|
112
|
+
hideOperatorColumn: k,
|
|
113
|
+
invalidPaths: B ?? /* @__PURE__ */ new Set(),
|
|
114
|
+
getErrorMessage: C,
|
|
115
|
+
size: e ?? "sm",
|
|
116
|
+
addFilterLabel: a ?? "Add Filter",
|
|
117
|
+
addFilterGroupLabel: d ?? "Add Filter Group",
|
|
118
|
+
addActionClassName: i,
|
|
119
|
+
nestedAddActionClassName: U,
|
|
120
|
+
hideAddActions: p,
|
|
121
|
+
getOperatorOptions: q,
|
|
122
|
+
reorderGroupClassName: E,
|
|
123
|
+
extraAddActions: r,
|
|
124
|
+
renderCustomNode: H,
|
|
125
|
+
isDeleteDisabled: I,
|
|
126
|
+
showRootClearGroup: J,
|
|
127
|
+
onRootClearGroup: K
|
|
128
|
+
}
|
|
129
|
+
) });
|
|
130
|
+
}
|
|
131
|
+
export {
|
|
132
|
+
Z as ConditionBuilder,
|
|
133
|
+
Z as default
|
|
134
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ConditionGroupProps, BaseGroupCondition, BaseLeafCondition } from './types';
|
|
2
|
+
export declare function ConditionGroup<TCondition, TLeaf extends TCondition & BaseLeafCondition, TGroup extends TCondition & BaseGroupCondition<TCondition>>({ group, nodePath, level, maxDepth, config, onAddCondition, onUpdateCondition, onDeleteCondition, onAddGroup, onUpdateGroupOperator, onDeleteGroup, onDuplicateCondition, onReorder, renderLeafRow, hideOperatorColumn, invalidPaths, getErrorMessage, size, addFilterLabel, addFilterGroupLabel, addActionClassName, nestedAddActionClassName, hideAddActions, getOperatorOptions, reorderGroupClassName, extraAddActions, renderCustomNode, isDeleteDisabled, showRootClearGroup, onRootClearGroup, }: ConditionGroupProps<TCondition, TLeaf, TGroup>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export default ConditionGroup;
|
|
4
|
+
//# sourceMappingURL=condition-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condition-group.d.ts","sourceRoot":"","sources":["../../../src/patterns/condition-builder/condition-group.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EACR,mBAAmB,EAEnB,kBAAkB,EAClB,iBAAiB,EAEpB,MAAM,SAAS,CAAC;AA6MjB,wBAAgB,cAAc,CAC1B,UAAU,EACV,KAAK,SAAS,UAAU,GAAG,iBAAiB,EAC5C,MAAM,SAAS,UAAU,GAAG,kBAAkB,CAAC,UAAU,CAAC,EAC5D,EACE,KAAK,EACL,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,MAAM,EACN,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,SAAS,EACT,aAAa,EACb,kBAA0B,EAC1B,YAAY,EACZ,eAAe,EACf,IAAI,EACJ,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,EACxB,cAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,kBAA0B,EAC1B,gBAAgB,GACnB,EAAE,mBAAmB,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,2CAufhD;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import { jsxs as g, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useContext as Ke, createContext as Te, useState as U, useMemo as Be, useRef as _, useEffect as We } from "react";
|
|
3
|
+
import { Plus as de, Trash02 as pe } from "@untitledui/icons";
|
|
4
|
+
import { pathToString as ge } from "./utils.js";
|
|
5
|
+
import { cx as p } from "../../utils/cn.js";
|
|
6
|
+
import { ConditionRow as je } from "./condition-row.js";
|
|
7
|
+
import { ConditionReorderHandle as ve, WORKFLOW_REORDER_HANDLE_CLASS as Ae } from "./condition-reorder-handle.js";
|
|
8
|
+
import { AddActionButton as ye } from "./add-action-button.js";
|
|
9
|
+
import { Button as Ge } from "../../primitives/button/button.js";
|
|
10
|
+
import { useDragControls as Le } from "../../node_modules/framer-motion/dist/es/gestures/drag/use-drag-controls.js";
|
|
11
|
+
import { Select as G } from "../../primitives/select/select.js";
|
|
12
|
+
import { ButtonUtility as Ne } from "../../primitives/button/button-utility.js";
|
|
13
|
+
import { ReorderGroup as xe } from "../../node_modules/framer-motion/dist/es/components/Reorder/Group.js";
|
|
14
|
+
import { ReorderItem as Re } from "../../node_modules/framer-motion/dist/es/components/Reorder/Item.js";
|
|
15
|
+
function ze(m) {
|
|
16
|
+
const c = _(/* @__PURE__ */ new WeakMap()), a = _(/* @__PURE__ */ new Map()), h = _(0), i = _([]);
|
|
17
|
+
return (b, v) => {
|
|
18
|
+
const o = b;
|
|
19
|
+
if (c.current.has(o)) {
|
|
20
|
+
const R = c.current.get(o);
|
|
21
|
+
return i.current[v] = R, R;
|
|
22
|
+
}
|
|
23
|
+
const f = i.current[v], N = f != null ? a.current.get(f) : void 0;
|
|
24
|
+
if (f != null && N !== void 0 && !m.includes(N))
|
|
25
|
+
return c.current.set(o, f), a.current.set(f, o), i.current[v] = f, f;
|
|
26
|
+
const l = `cond-${h.current++}`;
|
|
27
|
+
return c.current.set(o, l), a.current.set(l, o), i.current[v] = l, l;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const we = [
|
|
31
|
+
{ id: "AND", label: "And" },
|
|
32
|
+
{ id: "OR", label: "Or" }
|
|
33
|
+
], P = {
|
|
34
|
+
sm: "text-xs",
|
|
35
|
+
md: "text-sm",
|
|
36
|
+
lg: "text-md"
|
|
37
|
+
}, be = {
|
|
38
|
+
sm: "size-4",
|
|
39
|
+
md: "size-5",
|
|
40
|
+
lg: "size-6"
|
|
41
|
+
}, Se = "min-w-0 flex-1 truncate text-xs font-semibold leading-4.5 text-secondary", Me = "w-[68px] shrink-0 [&_button>*]:h-7 [&_button>*]:py-1", Ie = Te(null), Ve = (m) => m % 2 === 0 ? "bg-primary" : "bg-secondary_subtle", qe = (m) => m === 0 ? "bg-secondary_subtle" : "bg-primary border border-[#E3EAFC]";
|
|
42
|
+
function X({
|
|
43
|
+
condition: m,
|
|
44
|
+
onDragStartSession: c,
|
|
45
|
+
children: a
|
|
46
|
+
}) {
|
|
47
|
+
const h = Le();
|
|
48
|
+
return /* @__PURE__ */ t(
|
|
49
|
+
Re,
|
|
50
|
+
{
|
|
51
|
+
value: m,
|
|
52
|
+
as: "div",
|
|
53
|
+
dragListener: !1,
|
|
54
|
+
dragControls: h,
|
|
55
|
+
style: { position: "relative" },
|
|
56
|
+
whileDrag: {
|
|
57
|
+
opacity: 0.85,
|
|
58
|
+
scale: 1.02,
|
|
59
|
+
boxShadow: "0 8px 24px rgba(0, 0, 0, 0.12)",
|
|
60
|
+
zIndex: 50
|
|
61
|
+
},
|
|
62
|
+
transition: { type: "spring", stiffness: 300, damping: 25 },
|
|
63
|
+
children: a((b) => {
|
|
64
|
+
c == null || c(), h.start(b);
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
function $e({
|
|
70
|
+
condition: m,
|
|
71
|
+
renderCustomNode: c,
|
|
72
|
+
customCtx: a,
|
|
73
|
+
onDragStartSession: h,
|
|
74
|
+
renderOperatorColumn: i,
|
|
75
|
+
hideOperatorColumn: b,
|
|
76
|
+
renderDefault: v
|
|
77
|
+
}) {
|
|
78
|
+
const o = Le(), N = c(m, {
|
|
79
|
+
...a,
|
|
80
|
+
onDragHandlePointerDown: (L) => {
|
|
81
|
+
h == null || h(), o.start(L);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return N == null ? v() : /* @__PURE__ */ t(
|
|
85
|
+
Re,
|
|
86
|
+
{
|
|
87
|
+
value: m,
|
|
88
|
+
as: "div",
|
|
89
|
+
dragListener: !1,
|
|
90
|
+
dragControls: o,
|
|
91
|
+
style: { position: "relative" },
|
|
92
|
+
whileDrag: {
|
|
93
|
+
opacity: 0.85,
|
|
94
|
+
scale: 1.02,
|
|
95
|
+
boxShadow: "0 8px 24px rgba(0, 0, 0, 0.12)",
|
|
96
|
+
zIndex: 50
|
|
97
|
+
},
|
|
98
|
+
transition: { type: "spring", stiffness: 300, damping: 25 },
|
|
99
|
+
children: /* @__PURE__ */ g("div", { className: "flex items-start gap-2 py-2 min-w-0", children: [
|
|
100
|
+
!b && /* @__PURE__ */ t("div", { className: "w-[75px] shrink-0 pt-2", children: i(a.index) }),
|
|
101
|
+
/* @__PURE__ */ t("div", { className: "min-w-0 flex-1", children: N })
|
|
102
|
+
] })
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
function Je({
|
|
107
|
+
group: m,
|
|
108
|
+
nodePath: c,
|
|
109
|
+
level: a,
|
|
110
|
+
maxDepth: h,
|
|
111
|
+
config: i,
|
|
112
|
+
onAddCondition: b,
|
|
113
|
+
onUpdateCondition: v,
|
|
114
|
+
onDeleteCondition: o,
|
|
115
|
+
onAddGroup: f,
|
|
116
|
+
onUpdateGroupOperator: N,
|
|
117
|
+
onDeleteGroup: L,
|
|
118
|
+
onDuplicateCondition: l,
|
|
119
|
+
onReorder: R,
|
|
120
|
+
renderLeafRow: z,
|
|
121
|
+
hideOperatorColumn: d = !1,
|
|
122
|
+
invalidPaths: Y,
|
|
123
|
+
getErrorMessage: K,
|
|
124
|
+
size: u,
|
|
125
|
+
addFilterLabel: Z,
|
|
126
|
+
addFilterGroupLabel: D,
|
|
127
|
+
addActionClassName: M,
|
|
128
|
+
nestedAddActionClassName: ee,
|
|
129
|
+
hideAddActions: re = !1,
|
|
130
|
+
getOperatorOptions: Ce,
|
|
131
|
+
reorderGroupClassName: V,
|
|
132
|
+
extraAddActions: T,
|
|
133
|
+
renderCustomNode: q,
|
|
134
|
+
isDeleteDisabled: S,
|
|
135
|
+
showRootClearGroup: ke = !1,
|
|
136
|
+
onRootClearGroup: te
|
|
137
|
+
}) {
|
|
138
|
+
const ne = a < h, se = a === 0 ? M : ee ?? M, O = i.getGroupOperator(m), x = i.getGroupConditions(m), $ = Ke(Ie), [ce, Pe] = U(null), H = Be(
|
|
139
|
+
() => $ ?? { hoveredPath: ce, setHoveredPath: Pe },
|
|
140
|
+
[$, ce]
|
|
141
|
+
), ae = (e) => d ? (r) => {
|
|
142
|
+
r.stopPropagation(), H.setHoveredPath(e);
|
|
143
|
+
} : void 0, le = d ? () => H.setHoveredPath(null) : void 0, [oe, ie] = U(!1), [_e, ue] = U([]), B = _(null), E = _(null), W = () => {
|
|
144
|
+
const e = [...x];
|
|
145
|
+
ie(!0), ue(e), B.current = e;
|
|
146
|
+
const r = () => {
|
|
147
|
+
const s = B.current, n = x;
|
|
148
|
+
s && (s.length !== n.length || s.some((w, C) => w !== n[C])) && R(c, s), B.current = null, document.removeEventListener("pointerup", r), E.current = null, requestAnimationFrame(() => ie(!1));
|
|
149
|
+
};
|
|
150
|
+
E.current = r, document.addEventListener("pointerup", r);
|
|
151
|
+
}, me = (e) => {
|
|
152
|
+
if (oe) {
|
|
153
|
+
B.current = e, ue(e);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
e !== x && (e.length === x.length && e.every((r, s) => x[s] === r) || R(c, e));
|
|
157
|
+
}, I = oe ? _e : x, j = ze(I);
|
|
158
|
+
We(() => () => {
|
|
159
|
+
E.current && (document.removeEventListener("pointerup", E.current), E.current = null);
|
|
160
|
+
}, []);
|
|
161
|
+
const J = (e) => {
|
|
162
|
+
if (e === 0)
|
|
163
|
+
return /* @__PURE__ */ t("span", { className: p("font-medium text-secondary pl-1", P[u]), children: "Where" });
|
|
164
|
+
const r = e === 1, s = O === "OR" ? "Or" : "And";
|
|
165
|
+
return r ? /* @__PURE__ */ t(
|
|
166
|
+
G,
|
|
167
|
+
{
|
|
168
|
+
size: u,
|
|
169
|
+
className: "w-full",
|
|
170
|
+
selectedKey: O,
|
|
171
|
+
onSelectionChange: (n) => N(c, n),
|
|
172
|
+
items: we,
|
|
173
|
+
"aria-label": "Logical operator for this group",
|
|
174
|
+
children: (n) => /* @__PURE__ */ t(G.Item, { id: n.id, children: n.label })
|
|
175
|
+
}
|
|
176
|
+
) : /* @__PURE__ */ t("span", { className: p("font-medium text-secondary pl-3", P[u]), children: s });
|
|
177
|
+
}, Oe = (e) => e === 0 ? /* @__PURE__ */ t("span", { className: Se, children: "Where" }) : e === 1 ? /* @__PURE__ */ t(
|
|
178
|
+
G,
|
|
179
|
+
{
|
|
180
|
+
size: "sm",
|
|
181
|
+
className: Me,
|
|
182
|
+
textStyles: "font-semibold text-secondary",
|
|
183
|
+
selectedKey: O,
|
|
184
|
+
onSelectionChange: (r) => N(c, r),
|
|
185
|
+
items: we,
|
|
186
|
+
"aria-label": "Logical operator for this group",
|
|
187
|
+
children: (r) => /* @__PURE__ */ t(G.Item, { id: r.id, children: r.label })
|
|
188
|
+
}
|
|
189
|
+
) : /* @__PURE__ */ t("span", { className: Se, children: O === "OR" ? "Or" : "And" }), He = (e, r, s) => {
|
|
190
|
+
const n = [...c, r], y = ge(n), w = r === 0, C = Y.has(y), A = K == null ? void 0 : K(y);
|
|
191
|
+
return /* @__PURE__ */ t(
|
|
192
|
+
X,
|
|
193
|
+
{
|
|
194
|
+
condition: e,
|
|
195
|
+
onDragStartSession: W,
|
|
196
|
+
children: (F) => /* @__PURE__ */ g(
|
|
197
|
+
"div",
|
|
198
|
+
{
|
|
199
|
+
className: p("flex min-w-0 items-center gap-2", d ? "py-0" : "py-1"),
|
|
200
|
+
onMouseOver: ae(y),
|
|
201
|
+
children: [
|
|
202
|
+
!d && /* @__PURE__ */ t("div", { className: "w-[75px] shrink-0", children: J(r) }),
|
|
203
|
+
/* @__PURE__ */ t("div", { className: d ? "min-w-0 flex-1" : "min-w-[80px] flex-1", children: z ? z({
|
|
204
|
+
condition: e,
|
|
205
|
+
nodePath: n,
|
|
206
|
+
isFirst: w,
|
|
207
|
+
onUpdate: (k) => v(n, k),
|
|
208
|
+
onDelete: () => o(n),
|
|
209
|
+
onDuplicate: l ? () => l(n) : void 0,
|
|
210
|
+
isInvalid: C,
|
|
211
|
+
errorMessage: A,
|
|
212
|
+
size: u,
|
|
213
|
+
onDragHandlePointerDown: F,
|
|
214
|
+
isDeleteDisabled: s,
|
|
215
|
+
isDragHandleVisible: d ? H.hoveredPath === y : void 0
|
|
216
|
+
}) : /* @__PURE__ */ t(
|
|
217
|
+
je,
|
|
218
|
+
{
|
|
219
|
+
condition: e,
|
|
220
|
+
nodePath: n,
|
|
221
|
+
isFirst: w,
|
|
222
|
+
onUpdate: (k) => v(n, k),
|
|
223
|
+
onDelete: () => o(n),
|
|
224
|
+
onDuplicate: l ? () => l(n) : void 0,
|
|
225
|
+
isInvalid: C,
|
|
226
|
+
errorMessage: A,
|
|
227
|
+
size: u,
|
|
228
|
+
getOperatorOptions: Ce,
|
|
229
|
+
onDragHandlePointerDown: F,
|
|
230
|
+
isDeleteDisabled: s
|
|
231
|
+
}
|
|
232
|
+
) })
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
},
|
|
237
|
+
j(e, r)
|
|
238
|
+
);
|
|
239
|
+
}, Ee = (e, r, s) => {
|
|
240
|
+
const n = [...c, r], y = r === 0, w = Ve(a + 1), C = qe(a), A = i.getGroupOperator(e), F = ge(n), k = /* @__PURE__ */ t(
|
|
241
|
+
Je,
|
|
242
|
+
{
|
|
243
|
+
group: e,
|
|
244
|
+
nodePath: n,
|
|
245
|
+
level: a + 1,
|
|
246
|
+
maxDepth: h,
|
|
247
|
+
isFirst: y,
|
|
248
|
+
parentOperator: O,
|
|
249
|
+
config: i,
|
|
250
|
+
onAddCondition: b,
|
|
251
|
+
onUpdateCondition: v,
|
|
252
|
+
onDeleteCondition: o,
|
|
253
|
+
onAddGroup: f,
|
|
254
|
+
onUpdateGroupOperator: N,
|
|
255
|
+
onDeleteGroup: L,
|
|
256
|
+
onDuplicateCondition: l,
|
|
257
|
+
onReorder: R,
|
|
258
|
+
renderLeafRow: z,
|
|
259
|
+
hideOperatorColumn: d,
|
|
260
|
+
invalidPaths: Y,
|
|
261
|
+
getErrorMessage: K,
|
|
262
|
+
size: u,
|
|
263
|
+
addFilterLabel: Z,
|
|
264
|
+
addFilterGroupLabel: D,
|
|
265
|
+
addActionClassName: M,
|
|
266
|
+
nestedAddActionClassName: ee,
|
|
267
|
+
hideAddActions: re,
|
|
268
|
+
reorderGroupClassName: V,
|
|
269
|
+
extraAddActions: T,
|
|
270
|
+
renderCustomNode: q,
|
|
271
|
+
isDeleteDisabled: S
|
|
272
|
+
}
|
|
273
|
+
);
|
|
274
|
+
if (d) {
|
|
275
|
+
const Q = H.hoveredPath === F;
|
|
276
|
+
return /* @__PURE__ */ t(
|
|
277
|
+
X,
|
|
278
|
+
{
|
|
279
|
+
condition: e,
|
|
280
|
+
onDragStartSession: W,
|
|
281
|
+
children: (Fe) => /* @__PURE__ */ g(
|
|
282
|
+
"div",
|
|
283
|
+
{
|
|
284
|
+
className: "relative flex min-w-0 flex-col gap-1.5",
|
|
285
|
+
onMouseOver: ae(F),
|
|
286
|
+
children: [
|
|
287
|
+
/* @__PURE__ */ t(
|
|
288
|
+
ve,
|
|
289
|
+
{
|
|
290
|
+
className: p(
|
|
291
|
+
Ae,
|
|
292
|
+
"absolute right-0 top-0 z-10 translate-x-1/2",
|
|
293
|
+
Q ? "opacity-100" : "pointer-events-none opacity-0"
|
|
294
|
+
),
|
|
295
|
+
size: u,
|
|
296
|
+
onDragHandlePointerDown: Fe,
|
|
297
|
+
onDuplicate: l ? () => l(n) : void 0
|
|
298
|
+
}
|
|
299
|
+
),
|
|
300
|
+
/* @__PURE__ */ g(
|
|
301
|
+
"div",
|
|
302
|
+
{
|
|
303
|
+
className: p(
|
|
304
|
+
"flex min-w-0 items-center justify-between gap-0.5",
|
|
305
|
+
r === 1 ? "h-7 pr-1" : "h-[18px] px-1"
|
|
306
|
+
),
|
|
307
|
+
children: [
|
|
308
|
+
Oe(r),
|
|
309
|
+
!s && /* @__PURE__ */ t(
|
|
310
|
+
Ne,
|
|
311
|
+
{
|
|
312
|
+
color: "tertiary",
|
|
313
|
+
size: "4xs",
|
|
314
|
+
icon: pe,
|
|
315
|
+
"aria-label": "Remove group",
|
|
316
|
+
onClick: () => L(n),
|
|
317
|
+
className: "shrink-0 hover:bg-secondary_hover hover:text-fg-secondary"
|
|
318
|
+
}
|
|
319
|
+
)
|
|
320
|
+
]
|
|
321
|
+
}
|
|
322
|
+
),
|
|
323
|
+
/* @__PURE__ */ t("div", { className: p("min-w-0 rounded-[10px] p-1.5", C), children: k })
|
|
324
|
+
]
|
|
325
|
+
}
|
|
326
|
+
)
|
|
327
|
+
},
|
|
328
|
+
j(e, r)
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
return /* @__PURE__ */ t(
|
|
332
|
+
X,
|
|
333
|
+
{
|
|
334
|
+
condition: e,
|
|
335
|
+
onDragStartSession: W,
|
|
336
|
+
children: (Q) => /* @__PURE__ */ g("div", { className: "flex min-w-0 items-start gap-2 py-2", children: [
|
|
337
|
+
/* @__PURE__ */ t("div", { className: "w-[75px] shrink-0 pt-2", children: J(r) }),
|
|
338
|
+
/* @__PURE__ */ g("div", { className: p("relative min-w-0 flex-1 overflow-hidden rounded-lg p-3", w), children: [
|
|
339
|
+
/* @__PURE__ */ g("div", { className: "mb-2 flex min-w-0 items-center gap-0.5", children: [
|
|
340
|
+
/* @__PURE__ */ t("span", { className: p("min-w-0 flex-1 text-tertiary", P[u]), children: A === "OR" ? "Any of the following are true..." : "All of the following are true..." }),
|
|
341
|
+
!s && /* @__PURE__ */ t(
|
|
342
|
+
Ne,
|
|
343
|
+
{
|
|
344
|
+
"aria-label": "Remove group",
|
|
345
|
+
icon: pe,
|
|
346
|
+
color: "tertiary",
|
|
347
|
+
size: "3xs",
|
|
348
|
+
onClick: () => L(n)
|
|
349
|
+
}
|
|
350
|
+
)
|
|
351
|
+
] }),
|
|
352
|
+
k
|
|
353
|
+
] }),
|
|
354
|
+
!d && /* @__PURE__ */ t(
|
|
355
|
+
ve,
|
|
356
|
+
{
|
|
357
|
+
className: "mt-2 w-9 shrink-0",
|
|
358
|
+
size: u,
|
|
359
|
+
onDragHandlePointerDown: Q,
|
|
360
|
+
onDuplicate: l ? () => l(n) : void 0
|
|
361
|
+
}
|
|
362
|
+
)
|
|
363
|
+
] })
|
|
364
|
+
},
|
|
365
|
+
j(e, r)
|
|
366
|
+
);
|
|
367
|
+
}, he = (e, r) => {
|
|
368
|
+
const s = [...c, r], n = x.length, y = !!(S != null && S({ nodePath: s, siblingCount: n })), w = () => i.isLeafCondition(e) ? He(e, r, y) : i.isGroupCondition(e) ? Ee(e, r, y) : null;
|
|
369
|
+
return q ? /* @__PURE__ */ t(
|
|
370
|
+
$e,
|
|
371
|
+
{
|
|
372
|
+
condition: e,
|
|
373
|
+
renderCustomNode: q,
|
|
374
|
+
customCtx: {
|
|
375
|
+
nodePath: s,
|
|
376
|
+
index: r,
|
|
377
|
+
isFirst: r === 0,
|
|
378
|
+
onDuplicate: l ? () => l(s) : void 0,
|
|
379
|
+
onDelete: () => o(s)
|
|
380
|
+
},
|
|
381
|
+
onDragStartSession: W,
|
|
382
|
+
renderOperatorColumn: J,
|
|
383
|
+
hideOperatorColumn: d,
|
|
384
|
+
renderDefault: w
|
|
385
|
+
},
|
|
386
|
+
j(e, r)
|
|
387
|
+
) : w();
|
|
388
|
+
}, fe = (e = !1) => re ? null : /* @__PURE__ */ g("div", { className: "flex flex-1 items-center justify-between pt-3", children: [
|
|
389
|
+
/* @__PURE__ */ g("div", { className: "flex items-center gap-3", children: [
|
|
390
|
+
/* @__PURE__ */ t(
|
|
391
|
+
ye,
|
|
392
|
+
{
|
|
393
|
+
icon: de,
|
|
394
|
+
fontSize: P[u],
|
|
395
|
+
iconSize: be[u],
|
|
396
|
+
className: se,
|
|
397
|
+
onClick: () => b(c),
|
|
398
|
+
children: Z
|
|
399
|
+
}
|
|
400
|
+
),
|
|
401
|
+
ne && /* @__PURE__ */ t(
|
|
402
|
+
ye,
|
|
403
|
+
{
|
|
404
|
+
icon: de,
|
|
405
|
+
fontSize: P[u],
|
|
406
|
+
iconSize: be[u],
|
|
407
|
+
className: se,
|
|
408
|
+
onClick: () => f(c),
|
|
409
|
+
children: D
|
|
410
|
+
}
|
|
411
|
+
),
|
|
412
|
+
T == null ? void 0 : T({ nodePath: c, level: a, canAddNestedGroup: ne })
|
|
413
|
+
] }),
|
|
414
|
+
e && x.length > 0 && /* @__PURE__ */ t(
|
|
415
|
+
Ge,
|
|
416
|
+
{
|
|
417
|
+
type: "button",
|
|
418
|
+
color: "link-gray",
|
|
419
|
+
size: "sm",
|
|
420
|
+
className: p("font-medium text-secondary hover:text-primary", P[u]),
|
|
421
|
+
onClick: () => {
|
|
422
|
+
if (a === 0 && te) {
|
|
423
|
+
te();
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
for (let r = x.length - 1; r >= 0; r--) {
|
|
427
|
+
const s = [...c, r], n = r + 1;
|
|
428
|
+
S != null && S({ nodePath: s, siblingCount: n }) || o(s);
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
children: "Clear Group"
|
|
432
|
+
}
|
|
433
|
+
)
|
|
434
|
+
] });
|
|
435
|
+
if (a === 0) {
|
|
436
|
+
const e = /* @__PURE__ */ g(
|
|
437
|
+
"div",
|
|
438
|
+
{
|
|
439
|
+
className: "space-y-0 min-w-0 max-w-full",
|
|
440
|
+
onMouseOver: le,
|
|
441
|
+
onMouseLeave: le,
|
|
442
|
+
children: [
|
|
443
|
+
I.length > 0 && /* @__PURE__ */ t(
|
|
444
|
+
xe,
|
|
445
|
+
{
|
|
446
|
+
axis: "y",
|
|
447
|
+
values: I,
|
|
448
|
+
onReorder: me,
|
|
449
|
+
className: p("space-y-0", V),
|
|
450
|
+
children: I.map((r, s) => he(r, s))
|
|
451
|
+
}
|
|
452
|
+
),
|
|
453
|
+
fe(ke)
|
|
454
|
+
]
|
|
455
|
+
}
|
|
456
|
+
);
|
|
457
|
+
return $ ? e : /* @__PURE__ */ t(Ie.Provider, { value: H, children: e });
|
|
458
|
+
}
|
|
459
|
+
return /* @__PURE__ */ g("div", { className: "space-y-0 min-w-0", children: [
|
|
460
|
+
I.length > 0 && /* @__PURE__ */ t(
|
|
461
|
+
xe,
|
|
462
|
+
{
|
|
463
|
+
axis: "y",
|
|
464
|
+
values: I,
|
|
465
|
+
onReorder: me,
|
|
466
|
+
className: p("space-y-0", V),
|
|
467
|
+
children: I.map((e, r) => he(e, r))
|
|
468
|
+
}
|
|
469
|
+
),
|
|
470
|
+
fe(!d)
|
|
471
|
+
] });
|
|
472
|
+
}
|
|
473
|
+
export {
|
|
474
|
+
Je as ConditionGroup,
|
|
475
|
+
Je as default
|
|
476
|
+
};
|