@pibit.ai/cure-design-system 0.6.37 → 0.6.38
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 +311 -288
- package/dist/patterns/filter-group/date-adapter.d.ts +20 -0
- package/dist/patterns/filter-group/date-adapter.d.ts.map +1 -0
- package/dist/patterns/filter-group/date-adapter.js +38 -0
- package/dist/patterns/filter-group/document-fields-to-tree.d.ts +33 -0
- package/dist/patterns/filter-group/document-fields-to-tree.d.ts.map +1 -0
- package/dist/patterns/filter-group/document-fields-to-tree.js +53 -0
- package/dist/patterns/filter-group/filter-condition-row.d.ts +47 -0
- package/dist/patterns/filter-group/filter-condition-row.d.ts.map +1 -0
- package/dist/patterns/filter-group/filter-condition-row.js +642 -0
- package/dist/patterns/filter-group/filter-group-builder.d.ts +42 -0
- package/dist/patterns/filter-group/filter-group-builder.d.ts.map +1 -0
- package/dist/patterns/filter-group/filter-group-builder.js +92 -0
- package/dist/patterns/filter-group/filter-group-card.d.ts +25 -0
- package/dist/patterns/filter-group/filter-group-card.d.ts.map +1 -0
- package/dist/patterns/filter-group/filter-group-card.js +266 -0
- package/dist/patterns/filter-group/index.d.ts +11 -0
- package/dist/patterns/filter-group/index.d.ts.map +1 -0
- package/dist/patterns/filter-group/nested-field-select.d.ts +68 -0
- package/dist/patterns/filter-group/nested-field-select.d.ts.map +1 -0
- package/dist/patterns/filter-group/nested-field-select.js +431 -0
- package/dist/patterns/filter-group/types.d.ts +105 -0
- package/dist/patterns/filter-group/types.d.ts.map +1 -0
- package/dist/patterns/filter-group/types.js +222 -0
- package/dist/patterns/filter-group/use-filter-group.d.ts +38 -0
- package/dist/patterns/filter-group/use-filter-group.d.ts.map +1 -0
- package/dist/patterns/filter-group/use-filter-group.js +81 -0
- package/dist/patterns/filter-group/validation.d.ts +13 -0
- package/dist/patterns/filter-group/validation.d.ts.map +1 -0
- package/dist/patterns/filter-group/validation.js +19 -0
- package/dist/styles/components.css +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx as t, jsxs as s } from "react/jsx-runtime";
|
|
2
|
+
import { Plus as a, CodeSquare02 as v } from "@untitledui/icons";
|
|
3
|
+
import { FilterGroupCard as z } from "./filter-group-card.js";
|
|
4
|
+
import { DEFAULT_OPERATORS as F, createEmptyCondition as p, createEmptyGroup as b } from "./types.js";
|
|
5
|
+
import { cx as m } from "../../utils/cn.js";
|
|
6
|
+
import { AddActionButton as u } from "../condition-builder/add-action-button.js";
|
|
7
|
+
import { ButtonUtility as g } from "../../primitives/button/button-utility.js";
|
|
8
|
+
const D = ({
|
|
9
|
+
fields: i,
|
|
10
|
+
operators: n = F,
|
|
11
|
+
value: h,
|
|
12
|
+
onChange: f,
|
|
13
|
+
maxDepth: d = 3,
|
|
14
|
+
size: x = "sm",
|
|
15
|
+
className: c,
|
|
16
|
+
showRootOperator: y = !0,
|
|
17
|
+
documentFields: C,
|
|
18
|
+
useFixedPositioning: S = !1,
|
|
19
|
+
invalidConditionIds: w = /* @__PURE__ */ new Set()
|
|
20
|
+
}) => {
|
|
21
|
+
var l;
|
|
22
|
+
const e = h || {
|
|
23
|
+
id: "root",
|
|
24
|
+
type: "group",
|
|
25
|
+
operator: "and",
|
|
26
|
+
children: []
|
|
27
|
+
}, o = (r) => {
|
|
28
|
+
f({ ...e, ...r });
|
|
29
|
+
}, A = () => {
|
|
30
|
+
const r = p(i, n);
|
|
31
|
+
o({ children: [...e.children, r] });
|
|
32
|
+
}, G = () => {
|
|
33
|
+
const r = b(e.operator === "and" ? "or" : "and");
|
|
34
|
+
r.children = [p(i, n)], o({ children: [...e.children, r] });
|
|
35
|
+
}, N = d > 1;
|
|
36
|
+
return ((l = e == null ? void 0 : e.children) == null ? void 0 : l.length) === 0 ? /* @__PURE__ */ t("div", { className: m("py-4", c), children: /* @__PURE__ */ s("div", { className: "flex items-center gap-3", children: [
|
|
37
|
+
/* @__PURE__ */ t(
|
|
38
|
+
u,
|
|
39
|
+
{
|
|
40
|
+
icon: a,
|
|
41
|
+
fontSize: "text-sm",
|
|
42
|
+
iconSize: "size-4",
|
|
43
|
+
className: "text-brand-600 hover:text-brand-700",
|
|
44
|
+
onClick: A,
|
|
45
|
+
children: "Add Filter"
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
N && /* @__PURE__ */ t(
|
|
49
|
+
u,
|
|
50
|
+
{
|
|
51
|
+
icon: a,
|
|
52
|
+
fontSize: "text-sm",
|
|
53
|
+
iconSize: "size-4",
|
|
54
|
+
className: "text-brand-600 hover:text-brand-700",
|
|
55
|
+
onClick: G,
|
|
56
|
+
children: "Add Filter Group"
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
] }) }) : /* @__PURE__ */ s("div", { className: m("py-2", c), children: [
|
|
60
|
+
/* @__PURE__ */ t("div", { className: "flex w-full justify-end", children: /* @__PURE__ */ t(
|
|
61
|
+
g,
|
|
62
|
+
{
|
|
63
|
+
isDisabled: !0,
|
|
64
|
+
color: "tertiary",
|
|
65
|
+
icon: /* @__PURE__ */ t(v, {}),
|
|
66
|
+
tooltip: "Switch to Code View"
|
|
67
|
+
}
|
|
68
|
+
) }),
|
|
69
|
+
/* @__PURE__ */ t(
|
|
70
|
+
z,
|
|
71
|
+
{
|
|
72
|
+
group: e,
|
|
73
|
+
fields: i,
|
|
74
|
+
operators: n,
|
|
75
|
+
depth: 0,
|
|
76
|
+
maxDepth: d,
|
|
77
|
+
isFirst: !0,
|
|
78
|
+
showLogicalOperator: y,
|
|
79
|
+
onUpdate: o,
|
|
80
|
+
onDelete: () => o({ children: [] }),
|
|
81
|
+
size: x,
|
|
82
|
+
documentFields: C,
|
|
83
|
+
useFixedPositioning: S,
|
|
84
|
+
invalidConditionIds: w
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
] });
|
|
88
|
+
};
|
|
89
|
+
export {
|
|
90
|
+
D as FilterGroupBuilder,
|
|
91
|
+
D as default
|
|
92
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FilterGroup, FilterField, FilterOperator, FilterLogicalOperator, DocumentFieldsConfig } from './types';
|
|
3
|
+
interface FilterGroupCardProps {
|
|
4
|
+
group: FilterGroup;
|
|
5
|
+
fields: FilterField[];
|
|
6
|
+
operators?: FilterOperator[];
|
|
7
|
+
depth: number;
|
|
8
|
+
maxDepth: number;
|
|
9
|
+
logicalOperator?: FilterLogicalOperator;
|
|
10
|
+
isFirst: boolean;
|
|
11
|
+
showLogicalOperator: boolean;
|
|
12
|
+
onUpdate: (updates: Partial<FilterGroup>) => void;
|
|
13
|
+
onDelete: () => void;
|
|
14
|
+
onLogicalOperatorChange?: (operator: FilterLogicalOperator) => void;
|
|
15
|
+
size?: "sm" | "md" | "lg";
|
|
16
|
+
/** Document fields for nested field selection */
|
|
17
|
+
documentFields?: DocumentFieldsConfig;
|
|
18
|
+
/** Whether to use fixed positioning for the dropdown */
|
|
19
|
+
useFixedPositioning?: boolean;
|
|
20
|
+
/** Set of condition IDs that are invalid (for error highlighting) */
|
|
21
|
+
invalidConditionIds?: Set<string>;
|
|
22
|
+
}
|
|
23
|
+
export declare const FilterGroupCard: React.FC<FilterGroupCardProps>;
|
|
24
|
+
export default FilterGroupCard;
|
|
25
|
+
//# sourceMappingURL=filter-group-card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-group-card.d.ts","sourceRoot":"","sources":["../../../src/patterns/filter-group/filter-group-card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EACR,WAAW,EAGX,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACvB,MAAM,SAAS,CAAC;AAOjB,UAAU,oBAAoB;IAC1B,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,qBAAqB,CAAC;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAClD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,uBAAuB,CAAC,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACpE,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,iDAAiD;IACjD,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,wDAAwD;IACxD,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,qEAAqE;IACrE,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACrC;AAOD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA6T1D,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { jsxs as c, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { Plus as u, Trash02 as W } from "@untitledui/icons";
|
|
3
|
+
import { FilterConditionRow as R } from "./filter-condition-row.js";
|
|
4
|
+
import { createEmptyCondition as F, DEFAULT_OPERATORS as L, createEmptyGroup as H } from "./types.js";
|
|
5
|
+
import { cx as J } from "../../utils/cn.js";
|
|
6
|
+
import { AddActionButton as N } from "../condition-builder/add-action-button.js";
|
|
7
|
+
import { useDragControls as M } from "../../node_modules/framer-motion/dist/es/gestures/drag/use-drag-controls.js";
|
|
8
|
+
import { Select as b } from "../../primitives/select/select.js";
|
|
9
|
+
import { ButtonUtility as Q } from "../../primitives/button/button-utility.js";
|
|
10
|
+
import { Button as V } from "../../primitives/button/button.js";
|
|
11
|
+
import { ReorderGroup as D } from "../../node_modules/framer-motion/dist/es/components/Reorder/Group.js";
|
|
12
|
+
import { ReorderItem as X } from "../../node_modules/framer-motion/dist/es/components/Reorder/Item.js";
|
|
13
|
+
const I = [
|
|
14
|
+
{ id: "and", label: "And" },
|
|
15
|
+
{ id: "or", label: "Or" }
|
|
16
|
+
], _ = ({
|
|
17
|
+
group: t,
|
|
18
|
+
fields: s,
|
|
19
|
+
operators: d,
|
|
20
|
+
depth: m,
|
|
21
|
+
maxDepth: v,
|
|
22
|
+
logicalOperator: S,
|
|
23
|
+
isFirst: j,
|
|
24
|
+
showLogicalOperator: g,
|
|
25
|
+
onUpdate: n,
|
|
26
|
+
onDelete: E,
|
|
27
|
+
onLogicalOperatorChange: C,
|
|
28
|
+
size: h = "sm",
|
|
29
|
+
documentFields: p,
|
|
30
|
+
useFixedPositioning: f = !1,
|
|
31
|
+
invalidConditionIds: w = /* @__PURE__ */ new Set()
|
|
32
|
+
}) => {
|
|
33
|
+
var k;
|
|
34
|
+
const O = m < v, B = M(), A = (e) => {
|
|
35
|
+
n({ children: e });
|
|
36
|
+
}, x = (e, o) => {
|
|
37
|
+
const l = t.children.map(
|
|
38
|
+
(a) => a.id === e ? { ...a, ...o } : a
|
|
39
|
+
);
|
|
40
|
+
n({ children: l });
|
|
41
|
+
}, y = (e) => {
|
|
42
|
+
const o = t.children.filter((l) => l.id !== e);
|
|
43
|
+
n({ children: o });
|
|
44
|
+
}, G = () => {
|
|
45
|
+
const e = F(s, d || L);
|
|
46
|
+
n({ children: [...t.children, e] });
|
|
47
|
+
}, z = () => {
|
|
48
|
+
if (!O) return;
|
|
49
|
+
const e = H(t.operator === "and" ? "or" : "and");
|
|
50
|
+
e.children = [F(s, d || L)], n({ children: [...t.children, e] });
|
|
51
|
+
}, T = () => {
|
|
52
|
+
n({ children: [] });
|
|
53
|
+
}, K = () => t.operator === "or" ? "Any of the following are true..." : "All of the following are true...", q = (e, o) => {
|
|
54
|
+
const l = o === 0 ? void 0 : t.operator, a = o === 0;
|
|
55
|
+
return e.type === "condition" ? /* @__PURE__ */ r(
|
|
56
|
+
R,
|
|
57
|
+
{
|
|
58
|
+
condition: e,
|
|
59
|
+
fields: s,
|
|
60
|
+
operators: d,
|
|
61
|
+
logicalOperator: l,
|
|
62
|
+
isFirst: a,
|
|
63
|
+
showLogicalOperator: !a,
|
|
64
|
+
onUpdate: (i) => x(e.id, i),
|
|
65
|
+
onDelete: () => y(e.id),
|
|
66
|
+
onLogicalOperatorChange: (i) => n({ operator: i }),
|
|
67
|
+
size: h,
|
|
68
|
+
documentFields: p,
|
|
69
|
+
useFixedPositioning: f,
|
|
70
|
+
isInvalid: w.has(e.id)
|
|
71
|
+
},
|
|
72
|
+
e.id
|
|
73
|
+
) : e.type === "group" ? /* @__PURE__ */ r(
|
|
74
|
+
_,
|
|
75
|
+
{
|
|
76
|
+
group: e,
|
|
77
|
+
fields: s,
|
|
78
|
+
operators: d,
|
|
79
|
+
depth: m + 1,
|
|
80
|
+
maxDepth: v,
|
|
81
|
+
logicalOperator: l,
|
|
82
|
+
isFirst: a,
|
|
83
|
+
showLogicalOperator: !a,
|
|
84
|
+
onUpdate: (i) => x(e.id, i),
|
|
85
|
+
onDelete: () => y(e.id),
|
|
86
|
+
onLogicalOperatorChange: (i) => n({ operator: i }),
|
|
87
|
+
size: h,
|
|
88
|
+
documentFields: p,
|
|
89
|
+
useFixedPositioning: f
|
|
90
|
+
},
|
|
91
|
+
e.id
|
|
92
|
+
) : null;
|
|
93
|
+
};
|
|
94
|
+
return m === 0 ? /* @__PURE__ */ c("div", { className: "space-y-0", children: [
|
|
95
|
+
g && t.children.length > 0 && /* @__PURE__ */ r("div", { className: "flex items-center pb-3", children: /* @__PURE__ */ r("div", { className: "w-[72px] flex-shrink-0", children: /* @__PURE__ */ r(
|
|
96
|
+
b,
|
|
97
|
+
{
|
|
98
|
+
size: h,
|
|
99
|
+
className: "w-full",
|
|
100
|
+
selectedKey: t.operator,
|
|
101
|
+
onSelectionChange: (e) => n({ operator: e }),
|
|
102
|
+
items: I,
|
|
103
|
+
children: (e) => /* @__PURE__ */ r(b.Item, { id: e.id, children: e.label })
|
|
104
|
+
}
|
|
105
|
+
) }) }),
|
|
106
|
+
t.children && /* @__PURE__ */ r(D, { axis: "y", values: t.children, onReorder: A, className: "space-y-0", children: (k = t.children) == null ? void 0 : k.map((e, o) => q(e, o)) }),
|
|
107
|
+
/* @__PURE__ */ c("div", { className: "flex items-center gap-3 pt-3", children: [
|
|
108
|
+
/* @__PURE__ */ r(
|
|
109
|
+
N,
|
|
110
|
+
{
|
|
111
|
+
icon: u,
|
|
112
|
+
fontSize: "text-sm",
|
|
113
|
+
iconSize: "size-4",
|
|
114
|
+
className: "text-brand-600 hover:text-brand-700",
|
|
115
|
+
onClick: G,
|
|
116
|
+
children: "Add Filter"
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
O && /* @__PURE__ */ r(
|
|
120
|
+
N,
|
|
121
|
+
{
|
|
122
|
+
icon: u,
|
|
123
|
+
fontSize: "text-sm",
|
|
124
|
+
iconSize: "size-4",
|
|
125
|
+
className: "text-brand-600 hover:text-brand-700",
|
|
126
|
+
onClick: z,
|
|
127
|
+
children: "Add Filter Group"
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
] })
|
|
131
|
+
] }) : /* @__PURE__ */ c(
|
|
132
|
+
X,
|
|
133
|
+
{
|
|
134
|
+
value: t,
|
|
135
|
+
id: t.id,
|
|
136
|
+
dragListener: !1,
|
|
137
|
+
dragControls: B,
|
|
138
|
+
className: "flex items-start gap-2 py-2 select-none",
|
|
139
|
+
initial: !1,
|
|
140
|
+
animate: !1,
|
|
141
|
+
style: { position: "relative" },
|
|
142
|
+
children: [
|
|
143
|
+
/* @__PURE__ */ r("div", { className: "w-[72px] flex-shrink-0 pt-2", children: j ? /* @__PURE__ */ r("span", { className: "text-sm font-medium text-secondary pl-1", children: "Where" }) : g ? /* @__PURE__ */ r(
|
|
144
|
+
b,
|
|
145
|
+
{
|
|
146
|
+
size: h,
|
|
147
|
+
className: "w-full",
|
|
148
|
+
selectedKey: S,
|
|
149
|
+
onSelectionChange: (e) => C == null ? void 0 : C(e),
|
|
150
|
+
items: I,
|
|
151
|
+
children: (e) => /* @__PURE__ */ r(b.Item, { id: e.id, children: e.label })
|
|
152
|
+
}
|
|
153
|
+
) : /* @__PURE__ */ r("span", { className: "text-sm font-medium text-secondary pl-3", children: S === "or" ? "Or" : "And" }) }),
|
|
154
|
+
/* @__PURE__ */ c(
|
|
155
|
+
"div",
|
|
156
|
+
{
|
|
157
|
+
className: J(
|
|
158
|
+
"flex-1 rounded-lg bg-secondary_subtle p-1.5",
|
|
159
|
+
m % 2 === 1 && "bg-secondary_subtle",
|
|
160
|
+
m % 2 === 0 && "bg-primary"
|
|
161
|
+
),
|
|
162
|
+
children: [
|
|
163
|
+
/* @__PURE__ */ c("div", { className: "flex items-center justify-between mb-2", children: [
|
|
164
|
+
/* @__PURE__ */ r("span", { className: "text-sm text-tertiary", children: K() }),
|
|
165
|
+
/* @__PURE__ */ r(
|
|
166
|
+
Q,
|
|
167
|
+
{
|
|
168
|
+
color: "tertiary",
|
|
169
|
+
size: "xs",
|
|
170
|
+
icon: /* @__PURE__ */ r(W, { size: 18 }),
|
|
171
|
+
"aria-label": "Remove group",
|
|
172
|
+
onClick: E,
|
|
173
|
+
className: "text-quaternary hover:bg-secondary_hover hover:text-secondary"
|
|
174
|
+
}
|
|
175
|
+
)
|
|
176
|
+
] }),
|
|
177
|
+
/* @__PURE__ */ r(D, { axis: "y", values: t.children, onReorder: A, className: "space-y-0", children: t.children.map((e, o) => {
|
|
178
|
+
const l = o === 0, a = l ? void 0 : t.operator;
|
|
179
|
+
return e.type === "condition" ? /* @__PURE__ */ r(
|
|
180
|
+
R,
|
|
181
|
+
{
|
|
182
|
+
condition: e,
|
|
183
|
+
fields: s,
|
|
184
|
+
operators: d,
|
|
185
|
+
logicalOperator: a,
|
|
186
|
+
isFirst: l,
|
|
187
|
+
showLogicalOperator: !l,
|
|
188
|
+
onUpdate: (i) => x(e.id, i),
|
|
189
|
+
onDelete: () => y(e.id),
|
|
190
|
+
onLogicalOperatorChange: (i) => n({ operator: i }),
|
|
191
|
+
size: h,
|
|
192
|
+
documentFields: p,
|
|
193
|
+
useFixedPositioning: f,
|
|
194
|
+
isInvalid: w.has(e.id)
|
|
195
|
+
},
|
|
196
|
+
e.id
|
|
197
|
+
) : e.type === "group" ? /* @__PURE__ */ r(
|
|
198
|
+
_,
|
|
199
|
+
{
|
|
200
|
+
group: e,
|
|
201
|
+
fields: s,
|
|
202
|
+
operators: d,
|
|
203
|
+
depth: m + 1,
|
|
204
|
+
maxDepth: v,
|
|
205
|
+
logicalOperator: a,
|
|
206
|
+
isFirst: l,
|
|
207
|
+
showLogicalOperator: !l,
|
|
208
|
+
onUpdate: (i) => x(e.id, i),
|
|
209
|
+
onDelete: () => y(e.id),
|
|
210
|
+
onLogicalOperatorChange: (i) => n({ operator: i }),
|
|
211
|
+
size: h,
|
|
212
|
+
documentFields: p,
|
|
213
|
+
useFixedPositioning: f,
|
|
214
|
+
invalidConditionIds: w
|
|
215
|
+
},
|
|
216
|
+
e.id
|
|
217
|
+
) : null;
|
|
218
|
+
}) }),
|
|
219
|
+
/* @__PURE__ */ c("div", { className: "flex items-center justify-between pt-3 mt-2", children: [
|
|
220
|
+
/* @__PURE__ */ c("div", { className: "flex items-center gap-3", children: [
|
|
221
|
+
/* @__PURE__ */ r(
|
|
222
|
+
N,
|
|
223
|
+
{
|
|
224
|
+
icon: u,
|
|
225
|
+
fontSize: "text-sm",
|
|
226
|
+
iconSize: "size-4",
|
|
227
|
+
className: "text-brand-600 hover:text-brand-700",
|
|
228
|
+
onClick: G,
|
|
229
|
+
children: "Add Filter"
|
|
230
|
+
}
|
|
231
|
+
),
|
|
232
|
+
O && /* @__PURE__ */ r(
|
|
233
|
+
N,
|
|
234
|
+
{
|
|
235
|
+
icon: u,
|
|
236
|
+
fontSize: "text-sm",
|
|
237
|
+
iconSize: "size-4",
|
|
238
|
+
className: "text-brand-600 hover:text-brand-700",
|
|
239
|
+
onClick: z,
|
|
240
|
+
children: "Add Filter Group"
|
|
241
|
+
}
|
|
242
|
+
)
|
|
243
|
+
] }),
|
|
244
|
+
t.children.length > 0 && /* @__PURE__ */ r(
|
|
245
|
+
V,
|
|
246
|
+
{
|
|
247
|
+
type: "button",
|
|
248
|
+
color: "link-gray",
|
|
249
|
+
size: "sm",
|
|
250
|
+
className: "text-sm font-medium text-secondary hover:text-primary",
|
|
251
|
+
onClick: T,
|
|
252
|
+
children: "Clear Group"
|
|
253
|
+
}
|
|
254
|
+
)
|
|
255
|
+
] })
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
};
|
|
263
|
+
export {
|
|
264
|
+
_ as FilterGroupCard,
|
|
265
|
+
_ as default
|
|
266
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { FilterGroupBuilder } from './filter-group-builder';
|
|
2
|
+
export { FilterGroupCard } from './filter-group-card';
|
|
3
|
+
export { FilterConditionRow } from './filter-condition-row';
|
|
4
|
+
export { NestedFieldSelect, type NestedFieldSelectProps } from './nested-field-select';
|
|
5
|
+
export { useFilterGroup } from './use-filter-group';
|
|
6
|
+
export type { UseFilterGroupOptions, UseFilterGroupReturn } from './use-filter-group';
|
|
7
|
+
export type { FilterGroupBuilderProps, FilterGroup, FilterCondition, FilterNode, FilterField, FilterFieldOption, FilterOperator, FilterLogicalOperator, DocumentFieldDefinition, DocumentDefinition, DocumentFieldsConfig, } from './types';
|
|
8
|
+
export { DEFAULT_OPERATORS, generateId, createEmptyCondition, createEmptyGroup } from './types';
|
|
9
|
+
export { validateFilterGroup, isFilterGroupValid } from './validation';
|
|
10
|
+
export { defaultFilterDateAdapter, parseFilterDate, parseFilterTimestamp, formatFilterTimestamp, type FilterDateAdapter, } from './date-adapter';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/patterns/filter-group/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAGvF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAGtF,YAAY,EACR,uBAAuB,EACvB,WAAW,EACX,eAAe,EACf,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACvB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhG,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGvE,OAAO,EACH,wBAAwB,EACxB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,iBAAiB,GACzB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DocumentFieldsConfig } from './types';
|
|
3
|
+
import { TreeViewNode } from '../tree-view';
|
|
4
|
+
export interface NestedFieldSelectProps {
|
|
5
|
+
/** Document fields configuration */
|
|
6
|
+
documentFields: DocumentFieldsConfig;
|
|
7
|
+
/** Currently selected field (format: "DOCUMENT_KEY.field_key" or "DOCUMENT_KEY.parent_key.field_key") */
|
|
8
|
+
selectedFieldId: string;
|
|
9
|
+
/** Callback when a field is selected */
|
|
10
|
+
onFieldSelect: (fieldId: string, documentKey: string, fieldKey: string) => void;
|
|
11
|
+
/**
|
|
12
|
+
* When provided, used to resolve the display label for a selected field id
|
|
13
|
+
* (e.g. Risk Cure paths containing `$ref` segments).
|
|
14
|
+
*/
|
|
15
|
+
resolveSelectedLabel?: (fieldId: string) => string | null;
|
|
16
|
+
/** Component size */
|
|
17
|
+
size?: "sm" | "md" | "lg";
|
|
18
|
+
/** Placeholder text */
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
/** Custom class name */
|
|
21
|
+
className?: string;
|
|
22
|
+
/** Allow custom value input alongside field selection */
|
|
23
|
+
allowCustomValue?: boolean;
|
|
24
|
+
/** Custom value (when allowCustomValue is true) */
|
|
25
|
+
customValue?: string;
|
|
26
|
+
/** Callback when custom value changes (when allowCustomValue is true) */
|
|
27
|
+
onCustomValueChange?: (value: string) => void;
|
|
28
|
+
/** Use fixed positioning (ignored; popover handles placement automatically) */
|
|
29
|
+
useFixedPositioning?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* When allowCustomValue is true: "field" = tree select mode (click opens tree, only icon highlighted);
|
|
32
|
+
* "static" = free text mode (input visible; dropdown opens calendar if valueDataType is "date", else tree).
|
|
33
|
+
*/
|
|
34
|
+
valueMode?: "field" | "static";
|
|
35
|
+
/**
|
|
36
|
+
* When allowCustomValue and valueMode is "static", if valueDataType === "date" clicking the field
|
|
37
|
+
* opens a calendar-only popover (no "Select date" button).
|
|
38
|
+
*/
|
|
39
|
+
valueDataType?: string;
|
|
40
|
+
/**
|
|
41
|
+
* When allowCustomValue is true: called when the user clicks the Dataflow02 icon to toggle
|
|
42
|
+
* between tree select (field) and free text (static) mode.
|
|
43
|
+
*/
|
|
44
|
+
onValueModeChange?: (mode: "field" | "static") => void;
|
|
45
|
+
/**
|
|
46
|
+
* When provided, only nodes for which this returns true are selectable.
|
|
47
|
+
* Other nodes stay visible for navigation. Omitted → any node is selectable.
|
|
48
|
+
*/
|
|
49
|
+
canSelectNode?: (node: TreeViewNode) => boolean;
|
|
50
|
+
/** Whether the field select is invalid */
|
|
51
|
+
isInvalid?: boolean;
|
|
52
|
+
/** When true, shows a clear control when a value is selected. Default false. */
|
|
53
|
+
isClearable?: boolean;
|
|
54
|
+
/** When true, opens the field hierarchy fully expanded. Default false. */
|
|
55
|
+
expandAllByDefault?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* When true, clicking clear reopens the dropdown (tree or calendar).
|
|
58
|
+
* Does not apply when there is no dropdown (e.g. static text input). Default false.
|
|
59
|
+
*/
|
|
60
|
+
openOnClear?: boolean;
|
|
61
|
+
/** Optional callback when cleared. If omitted, clears via `onFieldSelect` / `onCustomValueChange`. */
|
|
62
|
+
onClear?: () => void;
|
|
63
|
+
/** Disables interaction and applies disabled styling. */
|
|
64
|
+
isDisabled?: boolean;
|
|
65
|
+
}
|
|
66
|
+
export declare const NestedFieldSelect: React.FC<NestedFieldSelectProps>;
|
|
67
|
+
export default NestedFieldSelect;
|
|
68
|
+
//# sourceMappingURL=nested-field-select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nested-field-select.d.ts","sourceRoot":"","sources":["../../../src/patterns/filter-group/nested-field-select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAgBjF,OAAO,KAAK,EAAE,oBAAoB,EAA2B,MAAM,SAAS,CAAC;AAc7E,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAgBnE,MAAM,WAAW,sBAAsB;IACnC,oCAAoC;IACpC,cAAc,EAAE,oBAAoB,CAAC;IACrC,yGAAyG;IACzG,eAAe,EAAE,MAAM,CAAC;IACxB,wCAAwC;IACxC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAChF;;;OAGG;IACH,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAC1D,qBAAqB;IACrB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wBAAwB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,+EAA+E;IAC/E,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC/B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,KAAK,IAAI,CAAC;IACvD;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;IAChD,0CAA0C;IAC1C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gFAAgF;IAChF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0EAA0E;IAC1E,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,sGAAsG;IACtG,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,yDAAyD;IACzD,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAsDD,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA6e9D,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|