@commercelayer/app-elements 5.5.4 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CodeEditorComponent-BTinRSNU.js → CodeEditorComponent-DhpbUF3I.js} +1 -1
- package/dist/{InputDateComponent-DbOIWLmQ.js → InputDateComponent-BZyuY3F6.js} +2 -2
- package/dist/{RuleEngineComponent-BTMemWTZ.js → RuleEngineComponent-UggkM5Zc.js} +273 -272
- package/dist/{main-DR-JViDx.js → main-YD7ko8U-.js} +8 -6
- package/dist/main.js +1 -1
- package/dist/{parseISO-BGAQxnde.js → parseISO-Cq_loYUP.js} +1 -1
- package/package.json +2 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { t as k, b as Z, d as G, j as t, i as E, g as Q, e as P, f as g, h as j, k as V, D as
|
|
2
|
+
import { t as k, b as Z, d as G, j as t, i as E, g as Q, e as P, f as g, h as j, k as V, D as J, l as S, n as p, B as U, o as T, p as K, u as ee, q as te, r as ae, s as le, v as $, I as ne, C as se } from "./main-YD7ko8U-.js";
|
|
3
3
|
import "react-hook-form";
|
|
4
|
-
import I, { useReducer as
|
|
4
|
+
import I, { useReducer as re, useCallback as w, useMemo as ie, createContext as ue, useContext as ce, useState as x, useEffect as N, useRef as oe } from "react";
|
|
5
5
|
import { a as de } from "./fetchCoreResourcesSuggestions-CZkDwjO2.js";
|
|
6
|
-
import { p as A } from "./parseISO-
|
|
6
|
+
import { p as A } from "./parseISO-Cq_loYUP.js";
|
|
7
7
|
function q(e, a) {
|
|
8
8
|
const l = e.match(
|
|
9
9
|
/(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(?:\.(\d{0,7}))?(?:Z|(.)(\d{2}):?(\d{2})?)?/
|
|
@@ -27,25 +27,25 @@ function D(e, a, l) {
|
|
|
27
27
|
function M(e, a) {
|
|
28
28
|
return e == null ? !0 : G(e, a);
|
|
29
29
|
}
|
|
30
|
-
const W =
|
|
30
|
+
const W = ue(
|
|
31
31
|
void 0
|
|
32
32
|
);
|
|
33
|
-
function
|
|
33
|
+
function fe(e, a) {
|
|
34
34
|
var l;
|
|
35
35
|
switch (a.type) {
|
|
36
36
|
case "SET_PATH": {
|
|
37
|
-
const
|
|
37
|
+
const r = { ...e.value };
|
|
38
38
|
if (a.value === null)
|
|
39
39
|
if (/\.\d+$/.test(a.path)) {
|
|
40
|
-
const u = a.path.replace(/\.\d+$/, ""),
|
|
41
|
-
Array.isArray(
|
|
40
|
+
const u = a.path.replace(/\.\d+$/, ""), i = parseInt(((l = a.path.match(/\d+$/)) == null ? void 0 : l[0]) ?? "0", 10), n = Q(r, u);
|
|
41
|
+
Array.isArray(n) && (n.splice(i, 1), D(r, u, n), n.length === 0 && u.endsWith(".nested.conditions") && M(r, u.replace(/\.conditions$/, "")));
|
|
42
42
|
} else
|
|
43
|
-
M(
|
|
43
|
+
M(r, a.path);
|
|
44
44
|
else
|
|
45
|
-
D(
|
|
45
|
+
D(r, a.path, a.value);
|
|
46
46
|
return {
|
|
47
47
|
...e,
|
|
48
|
-
value:
|
|
48
|
+
value: r
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
case "SET_SELECTED_RULE_INDEX":
|
|
@@ -75,32 +75,32 @@ function oe(e, a) {
|
|
|
75
75
|
return e;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function me({
|
|
79
79
|
children: e,
|
|
80
80
|
initialValue: a
|
|
81
81
|
}) {
|
|
82
|
-
const [l,
|
|
82
|
+
const [l, r] = re(fe, {
|
|
83
83
|
value: a,
|
|
84
84
|
selectedRuleIndex: 0
|
|
85
|
-
}), u = w((
|
|
86
|
-
|
|
87
|
-
}, []),
|
|
88
|
-
|
|
89
|
-
}, []),
|
|
90
|
-
|
|
91
|
-
}, []),
|
|
85
|
+
}), u = w((c, m) => {
|
|
86
|
+
r({ type: "SET_PATH", path: c, value: m });
|
|
87
|
+
}, []), i = w((c) => {
|
|
88
|
+
r({ type: "SET_SELECTED_RULE_INDEX", index: c });
|
|
89
|
+
}, []), n = w((c) => {
|
|
90
|
+
r({ type: "SET_VALUE", value: c });
|
|
91
|
+
}, []), s = ie(
|
|
92
92
|
() => ({
|
|
93
93
|
state: l,
|
|
94
94
|
setPath: u,
|
|
95
|
-
setSelectedRuleIndex:
|
|
96
|
-
setValue:
|
|
95
|
+
setSelectedRuleIndex: i,
|
|
96
|
+
setValue: n
|
|
97
97
|
}),
|
|
98
|
-
[l, u,
|
|
98
|
+
[l, u, i, n]
|
|
99
99
|
);
|
|
100
|
-
return /* @__PURE__ */ t.jsx(W.Provider, { value:
|
|
100
|
+
return /* @__PURE__ */ t.jsx(W.Provider, { value: s, children: e });
|
|
101
101
|
}
|
|
102
102
|
function y() {
|
|
103
|
-
const e =
|
|
103
|
+
const e = ce(W);
|
|
104
104
|
if (e === void 0)
|
|
105
105
|
throw new Error("useRuleEngine must be used within a RuleEngineProvider");
|
|
106
106
|
return e;
|
|
@@ -114,11 +114,11 @@ const X = P([
|
|
|
114
114
|
function R(e) {
|
|
115
115
|
return null;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function ge({
|
|
118
118
|
item: e,
|
|
119
119
|
pathPrefix: a
|
|
120
120
|
}) {
|
|
121
|
-
var
|
|
121
|
+
var r, u, i, n;
|
|
122
122
|
const { setPath: l } = y();
|
|
123
123
|
if (e == null)
|
|
124
124
|
return null;
|
|
@@ -131,11 +131,11 @@ function me({
|
|
|
131
131
|
name: `${a}.value.x`,
|
|
132
132
|
type: "number",
|
|
133
133
|
suffix: "X",
|
|
134
|
-
defaultValue: (
|
|
135
|
-
onChange: (
|
|
134
|
+
defaultValue: (r = e.value) == null ? void 0 : r.x,
|
|
135
|
+
onChange: (s) => {
|
|
136
136
|
l(
|
|
137
137
|
`${a}.value.x`,
|
|
138
|
-
parseInt(
|
|
138
|
+
parseInt(s.currentTarget.value, 10)
|
|
139
139
|
);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
@@ -147,10 +147,10 @@ function me({
|
|
|
147
147
|
type: "number",
|
|
148
148
|
suffix: "Y",
|
|
149
149
|
defaultValue: (u = e.value) == null ? void 0 : u.y,
|
|
150
|
-
onChange: (
|
|
150
|
+
onChange: (s) => {
|
|
151
151
|
l(
|
|
152
152
|
`${a}.value.y`,
|
|
153
|
-
parseInt(
|
|
153
|
+
parseInt(s.currentTarget.value, 10)
|
|
154
154
|
);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
@@ -164,11 +164,11 @@ function me({
|
|
|
164
164
|
name: `${a}.value.x`,
|
|
165
165
|
type: "number",
|
|
166
166
|
suffix: "X",
|
|
167
|
-
defaultValue: (
|
|
168
|
-
onChange: (
|
|
167
|
+
defaultValue: (i = e.value) == null ? void 0 : i.x,
|
|
168
|
+
onChange: (s) => {
|
|
169
169
|
l(
|
|
170
170
|
`${a}.value.x`,
|
|
171
|
-
parseInt(
|
|
171
|
+
parseInt(s.currentTarget.value, 10)
|
|
172
172
|
);
|
|
173
173
|
}
|
|
174
174
|
}
|
|
@@ -179,11 +179,11 @@ function me({
|
|
|
179
179
|
name: `${a}.value.y`,
|
|
180
180
|
type: "number",
|
|
181
181
|
suffix: "Y",
|
|
182
|
-
defaultValue: (
|
|
183
|
-
onChange: (
|
|
182
|
+
defaultValue: (n = e.value) == null ? void 0 : n.y,
|
|
183
|
+
onChange: (s) => {
|
|
184
184
|
l(
|
|
185
185
|
`${a}.value.y`,
|
|
186
|
-
parseInt(
|
|
186
|
+
parseInt(s.currentTarget.value, 10)
|
|
187
187
|
);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
@@ -199,29 +199,29 @@ function me({
|
|
|
199
199
|
defaultValue: e.value,
|
|
200
200
|
min: 0,
|
|
201
201
|
suffix: "cents",
|
|
202
|
-
onChange: (
|
|
202
|
+
onChange: (s) => {
|
|
203
203
|
l(
|
|
204
204
|
`${a}.value`,
|
|
205
|
-
parseInt(
|
|
205
|
+
parseInt(s.currentTarget.value, 10)
|
|
206
206
|
);
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
) });
|
|
210
210
|
case "percentage": {
|
|
211
|
-
const
|
|
211
|
+
const s = (e.value * 100).toFixed(2);
|
|
212
212
|
return /* @__PURE__ */ t.jsx("div", { className: "w-24", children: /* @__PURE__ */ t.jsx(
|
|
213
213
|
g,
|
|
214
214
|
{
|
|
215
215
|
name: `${a}.value`,
|
|
216
216
|
type: "number",
|
|
217
|
-
defaultValue:
|
|
217
|
+
defaultValue: s.endsWith(".00") ? s.slice(0, -3) : s,
|
|
218
218
|
min: 0,
|
|
219
219
|
max: 100,
|
|
220
220
|
suffix: "%",
|
|
221
|
-
onChange: (
|
|
221
|
+
onChange: (c) => {
|
|
222
222
|
l(
|
|
223
223
|
`${a}.value`,
|
|
224
|
-
parseFloat(
|
|
224
|
+
parseFloat(c.currentTarget.value) / 100
|
|
225
225
|
);
|
|
226
226
|
}
|
|
227
227
|
}
|
|
@@ -231,55 +231,55 @@ function me({
|
|
|
231
231
|
return R();
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
-
function
|
|
234
|
+
function xe({
|
|
235
235
|
item: e,
|
|
236
236
|
index: a,
|
|
237
237
|
onDelete: l
|
|
238
238
|
}) {
|
|
239
239
|
const {
|
|
240
|
-
setPath:
|
|
240
|
+
setPath: r,
|
|
241
241
|
state: { selectedRuleIndex: u }
|
|
242
|
-
} = y(),
|
|
242
|
+
} = y(), i = {
|
|
243
243
|
percentage: "Percentage discount",
|
|
244
244
|
fixed_amount: "Fixed amount",
|
|
245
245
|
fixed_price: "Fixed price",
|
|
246
246
|
buy_x_pay_y: "Buy X, Pay Y",
|
|
247
247
|
every_x_discount_y: "Every X, Discount Y"
|
|
248
|
-
},
|
|
248
|
+
}, n = `rules.${u}.actions.${a}`;
|
|
249
249
|
return /* @__PURE__ */ t.jsx("div", { className: "mb-4 last:mb-0", children: /* @__PURE__ */ t.jsxs("div", { className: "bg-gray-50 rounded-md flex items-center", children: [
|
|
250
250
|
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between gap-2 flex-grow p-2", children: [
|
|
251
251
|
/* @__PURE__ */ t.jsx("div", { className: "flex-1", children: /* @__PURE__ */ t.jsx(
|
|
252
252
|
j,
|
|
253
253
|
{
|
|
254
|
-
name: `${
|
|
254
|
+
name: `${n}.type`,
|
|
255
255
|
defaultValue: e != null ? {
|
|
256
|
-
label:
|
|
256
|
+
label: i[e.type],
|
|
257
257
|
value: e.type
|
|
258
258
|
} : void 0,
|
|
259
|
-
initialValues: Object.entries(
|
|
260
|
-
([
|
|
259
|
+
initialValues: Object.entries(i).map(
|
|
260
|
+
([s, c]) => ({ value: s, label: c })
|
|
261
261
|
),
|
|
262
|
-
onSelect: (
|
|
263
|
-
V(
|
|
262
|
+
onSelect: (s) => {
|
|
263
|
+
V(s) && r(`${n}.type`, s.value);
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
) }),
|
|
267
|
-
/* @__PURE__ */ t.jsx(
|
|
267
|
+
/* @__PURE__ */ t.jsx(ge, { item: e, pathPrefix: n }),
|
|
268
268
|
/* @__PURE__ */ t.jsx("div", { className: "text-black font-bold text-sm", children: "ON" }),
|
|
269
269
|
/* @__PURE__ */ t.jsx("div", { className: "flex-1", children: /* @__PURE__ */ t.jsx(
|
|
270
270
|
g,
|
|
271
271
|
{
|
|
272
|
-
name: `${
|
|
272
|
+
name: `${n}.selector`,
|
|
273
273
|
type: "text",
|
|
274
274
|
defaultValue: e != null ? e.selector : void 0,
|
|
275
|
-
onChange: (
|
|
276
|
-
|
|
275
|
+
onChange: (s) => {
|
|
276
|
+
r(`${n}.selector`, s.currentTarget.value);
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
) })
|
|
280
280
|
] }),
|
|
281
281
|
l != null && /* @__PURE__ */ t.jsx(
|
|
282
|
-
|
|
282
|
+
J,
|
|
283
283
|
{
|
|
284
284
|
className: "w-8 border-l border-gray-100 flex items-center justify-center self-stretch",
|
|
285
285
|
dropdownLabel: /* @__PURE__ */ t.jsx("button", { className: "flex items-center justify-center self-stretch flex-grow", children: /* @__PURE__ */ t.jsx(p, { name: "dotsThreeVertical", size: 16, weight: "bold" }) }),
|
|
@@ -288,7 +288,7 @@ function ge({
|
|
|
288
288
|
{
|
|
289
289
|
label: "Delete",
|
|
290
290
|
onClick: () => {
|
|
291
|
-
|
|
291
|
+
r(`${n}`, null), l();
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
) })
|
|
@@ -296,24 +296,24 @@ function ge({
|
|
|
296
296
|
)
|
|
297
297
|
] }) });
|
|
298
298
|
}
|
|
299
|
-
function
|
|
299
|
+
function he({
|
|
300
300
|
actions: e
|
|
301
301
|
}) {
|
|
302
302
|
const [a, l] = x(0), {
|
|
303
|
-
setPath:
|
|
303
|
+
setPath: r,
|
|
304
304
|
state: { selectedRuleIndex: u }
|
|
305
305
|
} = y();
|
|
306
306
|
return /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
307
|
-
/* @__PURE__ */ t.jsx("div", { children: e == null ? void 0 : e.map((
|
|
308
|
-
|
|
307
|
+
/* @__PURE__ */ t.jsx("div", { children: e == null ? void 0 : e.map((i, n, s) => /* @__PURE__ */ t.jsx(
|
|
308
|
+
xe,
|
|
309
309
|
{
|
|
310
|
-
item:
|
|
311
|
-
index:
|
|
312
|
-
onDelete:
|
|
313
|
-
l((
|
|
310
|
+
item: i,
|
|
311
|
+
index: n,
|
|
312
|
+
onDelete: s.length > 1 ? () => {
|
|
313
|
+
l((c) => c + 1);
|
|
314
314
|
} : void 0
|
|
315
315
|
},
|
|
316
|
-
`${u}-${
|
|
316
|
+
`${u}-${n}-${a}`
|
|
317
317
|
)) }),
|
|
318
318
|
/* @__PURE__ */ t.jsx("div", { className: "mt-6", children: /* @__PURE__ */ t.jsxs(
|
|
319
319
|
U,
|
|
@@ -322,7 +322,7 @@ function xe({
|
|
|
322
322
|
variant: "secondary",
|
|
323
323
|
alignItems: "center",
|
|
324
324
|
onClick: () => {
|
|
325
|
-
|
|
325
|
+
r(
|
|
326
326
|
`rules.${u}.actions.${(e == null ? void 0 : e.length) ?? 0}`,
|
|
327
327
|
void 0
|
|
328
328
|
);
|
|
@@ -338,10 +338,10 @@ function xe({
|
|
|
338
338
|
function Y(e) {
|
|
339
339
|
const [a, l] = x(void 0);
|
|
340
340
|
return N(() => {
|
|
341
|
-
(e == null ? void 0 : e.field) != null && de(e.field).then((
|
|
342
|
-
l(
|
|
343
|
-
}).catch((
|
|
344
|
-
console.error("Error fetching field info:",
|
|
341
|
+
(e == null ? void 0 : e.field) != null && de(e.field).then((r) => {
|
|
342
|
+
l(r);
|
|
343
|
+
}).catch((r) => {
|
|
344
|
+
console.error("Error fetching field info:", r);
|
|
345
345
|
});
|
|
346
346
|
}, [e == null ? void 0 : e.field]), { infos: a };
|
|
347
347
|
}
|
|
@@ -360,26 +360,26 @@ function B(e) {
|
|
|
360
360
|
}
|
|
361
361
|
return "string";
|
|
362
362
|
}
|
|
363
|
-
function
|
|
363
|
+
function be({
|
|
364
364
|
item: e,
|
|
365
365
|
pathPrefix: a
|
|
366
366
|
}) {
|
|
367
|
-
var
|
|
368
|
-
const { setPath: l } = y(), { infos:
|
|
369
|
-
let u = (
|
|
367
|
+
var i, n;
|
|
368
|
+
const { setPath: l } = y(), { infos: r } = Y(e);
|
|
369
|
+
let u = (i = r == null ? void 0 : r.field) == null ? void 0 : i.type;
|
|
370
370
|
return u == null && (u = B(e == null ? void 0 : e.value)), /* @__PURE__ */ t.jsx(
|
|
371
371
|
j,
|
|
372
372
|
{
|
|
373
373
|
name: `${a}.matcher`,
|
|
374
374
|
value: e != null ? {
|
|
375
|
-
label: ((
|
|
375
|
+
label: ((n = O.find((s) => s.matcher === e.matcher && (u != null && s.fieldTypes.includes(u) || u == null))) == null ? void 0 : n.label) ?? // eslint-disable-next-line no-irregular-whitespace
|
|
376
376
|
(e.matcher != null ? `⚠️ ${e.matcher}` : ""),
|
|
377
377
|
value: e.matcher
|
|
378
378
|
} : void 0,
|
|
379
|
-
initialValues: O.filter(({ fieldTypes:
|
|
380
|
-
onSelect: (
|
|
381
|
-
V(
|
|
382
|
-
|
|
379
|
+
initialValues: O.filter(({ fieldTypes: s, visible: c }) => c !== !1 && s.includes(u)).map(({ matcher: s, label: c }) => ({ value: s, label: c })),
|
|
380
|
+
onSelect: (s) => {
|
|
381
|
+
V(s) && (l(`${a}.matcher`, s.value), X.includes(
|
|
382
|
+
s.value
|
|
383
383
|
) && l(`${a}.value`, null));
|
|
384
384
|
}
|
|
385
385
|
}
|
|
@@ -644,45 +644,45 @@ const O = [
|
|
|
644
644
|
label: "not at least one of"
|
|
645
645
|
}
|
|
646
646
|
};
|
|
647
|
-
function
|
|
647
|
+
function ye({
|
|
648
648
|
value: e,
|
|
649
649
|
pathPrefix: a
|
|
650
650
|
}) {
|
|
651
651
|
return (typeof e != "object" || Array.isArray(e) || e === null) && (e = {
|
|
652
652
|
in_and: []
|
|
653
|
-
}), /* @__PURE__ */ t.jsx("div", { children: Object.entries(e).map(([l,
|
|
654
|
-
|
|
653
|
+
}), /* @__PURE__ */ t.jsx("div", { children: Object.entries(e).map(([l, r], u) => /* @__PURE__ */ t.jsx(
|
|
654
|
+
ve,
|
|
655
655
|
{
|
|
656
656
|
pathPrefix: a,
|
|
657
|
-
defaultValue:
|
|
657
|
+
defaultValue: r,
|
|
658
658
|
initialMatcher: l
|
|
659
659
|
},
|
|
660
660
|
`${a}.${u}`
|
|
661
661
|
)) });
|
|
662
662
|
}
|
|
663
|
-
function
|
|
663
|
+
function ve({
|
|
664
664
|
initialMatcher: e,
|
|
665
665
|
defaultValue: a,
|
|
666
666
|
pathPrefix: l
|
|
667
667
|
}) {
|
|
668
|
-
const [
|
|
668
|
+
const [r, u] = x(e), [i, n] = x(e), [s, c] = x(a), { setPath: m } = y();
|
|
669
669
|
return N(() => {
|
|
670
|
-
|
|
671
|
-
}, [
|
|
670
|
+
r !== i && (m(`${l}.${r}`, null), u(i)), m(`${l}.${i}`, s);
|
|
671
|
+
}, [i, s, m]), /* @__PURE__ */ t.jsxs("div", { className: "flex gap-2 last-of-type:mt-2", children: [
|
|
672
672
|
/* @__PURE__ */ t.jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ t.jsx(
|
|
673
673
|
j,
|
|
674
674
|
{
|
|
675
675
|
defaultValue: [
|
|
676
|
-
{ value:
|
|
676
|
+
{ value: i, label: F[i].label }
|
|
677
677
|
],
|
|
678
678
|
initialValues: Object.entries(F).map(
|
|
679
|
-
([o, { label:
|
|
679
|
+
([o, { label: d }]) => ({
|
|
680
680
|
value: o,
|
|
681
|
-
label:
|
|
681
|
+
label: d
|
|
682
682
|
})
|
|
683
683
|
),
|
|
684
684
|
onSelect: (o) => {
|
|
685
|
-
V(o) &&
|
|
685
|
+
V(o) && n(o.value);
|
|
686
686
|
}
|
|
687
687
|
}
|
|
688
688
|
) }),
|
|
@@ -691,15 +691,15 @@ function ye({
|
|
|
691
691
|
{
|
|
692
692
|
isMulti: !0,
|
|
693
693
|
isCreatable: !0,
|
|
694
|
-
defaultValue: (Array.isArray(
|
|
694
|
+
defaultValue: (Array.isArray(s) ? s : []).map((o) => ({
|
|
695
695
|
value: o,
|
|
696
696
|
label: o.toString()
|
|
697
697
|
})),
|
|
698
698
|
initialValues: [],
|
|
699
699
|
onSelect: (o) => {
|
|
700
|
-
K(o) &&
|
|
700
|
+
K(o) && c(
|
|
701
701
|
o.map(
|
|
702
|
-
(
|
|
702
|
+
(d) => typeof d.value == "boolean" ? d.value.toString() : d.value
|
|
703
703
|
)
|
|
704
704
|
);
|
|
705
705
|
}
|
|
@@ -707,13 +707,13 @@ function ye({
|
|
|
707
707
|
) })
|
|
708
708
|
] });
|
|
709
709
|
}
|
|
710
|
-
function
|
|
710
|
+
function pe({
|
|
711
711
|
value: e,
|
|
712
712
|
onChange: a
|
|
713
713
|
}) {
|
|
714
|
-
const [l,
|
|
714
|
+
const [l, r] = x(
|
|
715
715
|
Array.isArray(e) && typeof e[0] == "number" ? e[0] : null
|
|
716
|
-
), [u,
|
|
716
|
+
), [u, i] = x(
|
|
717
717
|
Array.isArray(e) && typeof e[1] == "number" ? e[1] : null
|
|
718
718
|
);
|
|
719
719
|
return /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
@@ -723,9 +723,9 @@ function ve({
|
|
|
723
723
|
type: "number",
|
|
724
724
|
placeholder: "Min",
|
|
725
725
|
value: l ?? "",
|
|
726
|
-
onChange: (
|
|
727
|
-
const
|
|
728
|
-
|
|
726
|
+
onChange: (n) => {
|
|
727
|
+
const s = parseInt(n.currentTarget.value, 10);
|
|
728
|
+
r(isNaN(s) ? null : s), a([isNaN(s) ? null : s, u]);
|
|
729
729
|
}
|
|
730
730
|
}
|
|
731
731
|
) }),
|
|
@@ -736,21 +736,21 @@ function ve({
|
|
|
736
736
|
type: "number",
|
|
737
737
|
placeholder: "Max",
|
|
738
738
|
value: u ?? "",
|
|
739
|
-
onChange: (
|
|
740
|
-
const
|
|
741
|
-
|
|
739
|
+
onChange: (n) => {
|
|
740
|
+
const s = parseInt(n.currentTarget.value, 10);
|
|
741
|
+
i(isNaN(s) ? null : s), a([l, isNaN(s) ? null : s]);
|
|
742
742
|
}
|
|
743
743
|
}
|
|
744
744
|
) })
|
|
745
745
|
] });
|
|
746
746
|
}
|
|
747
|
-
function
|
|
747
|
+
function je({
|
|
748
748
|
value: e,
|
|
749
749
|
onChange: a
|
|
750
750
|
}) {
|
|
751
|
-
const [l,
|
|
751
|
+
const [l, r] = x(
|
|
752
752
|
Array.isArray(e) && typeof e[0] == "string" ? e[0] : null
|
|
753
|
-
), [u,
|
|
753
|
+
), [u, i] = x(
|
|
754
754
|
Array.isArray(e) && typeof e[1] == "string" ? e[1] : null
|
|
755
755
|
);
|
|
756
756
|
return /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
@@ -760,9 +760,9 @@ function pe({
|
|
|
760
760
|
type: "text",
|
|
761
761
|
placeholder: "Min",
|
|
762
762
|
value: l ?? "",
|
|
763
|
-
onChange: (
|
|
764
|
-
const
|
|
765
|
-
|
|
763
|
+
onChange: (n) => {
|
|
764
|
+
const s = n.currentTarget.value;
|
|
765
|
+
r(s), a([s, u]);
|
|
766
766
|
}
|
|
767
767
|
}
|
|
768
768
|
) }),
|
|
@@ -773,46 +773,46 @@ function pe({
|
|
|
773
773
|
type: "text",
|
|
774
774
|
placeholder: "Max",
|
|
775
775
|
value: u ?? "",
|
|
776
|
-
onChange: (
|
|
777
|
-
const
|
|
778
|
-
s
|
|
776
|
+
onChange: (n) => {
|
|
777
|
+
const s = n.currentTarget.value;
|
|
778
|
+
i(s), a([l, s]);
|
|
779
779
|
}
|
|
780
780
|
}
|
|
781
781
|
) })
|
|
782
782
|
] });
|
|
783
783
|
}
|
|
784
|
-
function
|
|
784
|
+
function Ne({
|
|
785
785
|
item: e,
|
|
786
786
|
pathPrefix: a
|
|
787
787
|
}) {
|
|
788
|
-
var
|
|
789
|
-
const { setPath: l } = y(), { infos:
|
|
788
|
+
var m;
|
|
789
|
+
const { setPath: l } = y(), { infos: r } = Y(e), { user: u } = ee(), i = `${a}.value`;
|
|
790
790
|
if (e == null || X.includes(
|
|
791
791
|
e.matcher
|
|
792
792
|
))
|
|
793
793
|
return null;
|
|
794
|
-
const
|
|
795
|
-
let
|
|
796
|
-
|
|
797
|
-
(
|
|
798
|
-
)) && (
|
|
799
|
-
let
|
|
800
|
-
switch (
|
|
794
|
+
const n = e;
|
|
795
|
+
let s = (m = r == null ? void 0 : r.field) == null ? void 0 : m.type;
|
|
796
|
+
s == null && (s = B(n.value)), (typeof n.value == "string" && /^{{.*}}$/.test(n.value) || Array.isArray(n.value) && n.value.some(
|
|
797
|
+
(o) => typeof o == "string" && /^{{.*}}$/.test(o)
|
|
798
|
+
)) && (s = "string");
|
|
799
|
+
let c = null;
|
|
800
|
+
switch (s) {
|
|
801
801
|
case "datetime": {
|
|
802
|
-
|
|
802
|
+
c = "date";
|
|
803
803
|
break;
|
|
804
804
|
}
|
|
805
805
|
case "boolean": {
|
|
806
|
-
|
|
806
|
+
c = "boolean";
|
|
807
807
|
break;
|
|
808
808
|
}
|
|
809
809
|
case "string": {
|
|
810
|
-
|
|
810
|
+
c = "text";
|
|
811
811
|
break;
|
|
812
812
|
}
|
|
813
813
|
case "integer":
|
|
814
814
|
case "float": {
|
|
815
|
-
|
|
815
|
+
c = "number";
|
|
816
816
|
break;
|
|
817
817
|
}
|
|
818
818
|
case "array":
|
|
@@ -820,11 +820,11 @@ function je({
|
|
|
820
820
|
case "object":
|
|
821
821
|
break;
|
|
822
822
|
default: {
|
|
823
|
-
|
|
823
|
+
c = "text";
|
|
824
824
|
break;
|
|
825
825
|
}
|
|
826
826
|
}
|
|
827
|
-
switch (
|
|
827
|
+
switch (n.matcher) {
|
|
828
828
|
case "eq":
|
|
829
829
|
case "not_eq":
|
|
830
830
|
case "lt":
|
|
@@ -844,54 +844,55 @@ function je({
|
|
|
844
844
|
case "gteq_lt":
|
|
845
845
|
case "gt_lteq":
|
|
846
846
|
case "gteq_lteq": {
|
|
847
|
-
|
|
847
|
+
c === "number" && (c = "numberRange"), c === "text" && (c = "textRange"), c === "date" && (c = "dateRange");
|
|
848
848
|
break;
|
|
849
849
|
}
|
|
850
850
|
case "is_in":
|
|
851
851
|
case "is_not_in": {
|
|
852
|
-
|
|
852
|
+
c = "tag";
|
|
853
853
|
break;
|
|
854
854
|
}
|
|
855
855
|
case "array_match": {
|
|
856
|
-
|
|
856
|
+
c = "arrayMatch";
|
|
857
857
|
break;
|
|
858
858
|
}
|
|
859
859
|
default: {
|
|
860
|
-
R(
|
|
860
|
+
R(n.matcher);
|
|
861
861
|
break;
|
|
862
862
|
}
|
|
863
863
|
}
|
|
864
|
-
switch (
|
|
864
|
+
switch (c) {
|
|
865
865
|
case "date": {
|
|
866
|
-
const
|
|
867
|
-
typeof
|
|
866
|
+
const o = A(
|
|
867
|
+
typeof n.value == "string" ? n.value : ""
|
|
868
868
|
);
|
|
869
869
|
return /* @__PURE__ */ t.jsx(
|
|
870
|
-
|
|
870
|
+
ae,
|
|
871
871
|
{
|
|
872
|
-
value: T(
|
|
872
|
+
value: T(o) ? o : void 0,
|
|
873
873
|
showTimeSelect: !0,
|
|
874
874
|
placeholder: "Enter value",
|
|
875
|
-
onChange: (
|
|
876
|
-
l(
|
|
877
|
-
}
|
|
875
|
+
onChange: (d) => {
|
|
876
|
+
l(i, d == null ? void 0 : d.toJSON());
|
|
877
|
+
},
|
|
878
|
+
timezone: u == null ? void 0 : u.timezone
|
|
878
879
|
}
|
|
879
880
|
);
|
|
880
881
|
}
|
|
881
882
|
case "dateRange": {
|
|
882
|
-
const
|
|
883
|
-
const f = A(typeof
|
|
883
|
+
const o = Array.isArray(n.value) ? n.value.map((d) => {
|
|
884
|
+
const f = A(typeof d == "string" ? d : "");
|
|
884
885
|
return T(f) ? f : null;
|
|
885
886
|
}) : [null, null];
|
|
886
887
|
return /* @__PURE__ */ t.jsx(
|
|
887
|
-
|
|
888
|
+
te,
|
|
888
889
|
{
|
|
889
|
-
value:
|
|
890
|
+
value: o,
|
|
890
891
|
showTimeSelect: !0,
|
|
891
|
-
onChange: (
|
|
892
|
+
onChange: (d) => {
|
|
892
893
|
l(
|
|
893
894
|
`${a}.value`,
|
|
894
|
-
|
|
895
|
+
d.map((f) => (f == null ? void 0 : f.toJSON()) ?? null)
|
|
895
896
|
);
|
|
896
897
|
}
|
|
897
898
|
}
|
|
@@ -899,29 +900,29 @@ function je({
|
|
|
899
900
|
}
|
|
900
901
|
case "numberRange":
|
|
901
902
|
return /* @__PURE__ */ t.jsx(
|
|
902
|
-
|
|
903
|
+
pe,
|
|
903
904
|
{
|
|
904
|
-
value:
|
|
905
|
-
onChange: (
|
|
906
|
-
l(
|
|
905
|
+
value: n.value,
|
|
906
|
+
onChange: (o) => {
|
|
907
|
+
l(i, o);
|
|
907
908
|
}
|
|
908
909
|
}
|
|
909
910
|
);
|
|
910
911
|
case "textRange":
|
|
911
912
|
return /* @__PURE__ */ t.jsx(
|
|
912
|
-
|
|
913
|
+
je,
|
|
913
914
|
{
|
|
914
|
-
value:
|
|
915
|
-
onChange: (
|
|
916
|
-
l(
|
|
915
|
+
value: n.value,
|
|
916
|
+
onChange: (o) => {
|
|
917
|
+
l(i, o);
|
|
917
918
|
}
|
|
918
919
|
}
|
|
919
920
|
);
|
|
920
921
|
case "arrayMatch":
|
|
921
922
|
return /* @__PURE__ */ t.jsx(
|
|
922
|
-
|
|
923
|
+
ye,
|
|
923
924
|
{
|
|
924
|
-
value:
|
|
925
|
+
value: n.value,
|
|
925
926
|
pathPrefix: `${a}.value`
|
|
926
927
|
}
|
|
927
928
|
);
|
|
@@ -932,21 +933,21 @@ function je({
|
|
|
932
933
|
isMulti: !0,
|
|
933
934
|
isClearable: !1,
|
|
934
935
|
isCreatable: !0,
|
|
935
|
-
defaultValue: Array.isArray(
|
|
936
|
-
label:
|
|
937
|
-
value:
|
|
936
|
+
defaultValue: Array.isArray(n.value) ? n.value.map((o) => ({
|
|
937
|
+
label: o.toString(),
|
|
938
|
+
value: o
|
|
938
939
|
})) : [],
|
|
939
940
|
initialValues: [],
|
|
940
|
-
onSelect: (
|
|
941
|
-
K(
|
|
941
|
+
onSelect: (o) => {
|
|
942
|
+
K(o) && l(
|
|
942
943
|
`${a}.value`,
|
|
943
|
-
|
|
944
|
-
if (
|
|
945
|
-
const f = parseInt(
|
|
944
|
+
o.map((d) => {
|
|
945
|
+
if (s === "integer") {
|
|
946
|
+
const f = parseInt(d.value.toString(), 10);
|
|
946
947
|
return isNaN(f) ? null : f;
|
|
947
948
|
}
|
|
948
|
-
return
|
|
949
|
-
}).filter((
|
|
949
|
+
return d.value;
|
|
950
|
+
}).filter((d) => d != null)
|
|
950
951
|
);
|
|
951
952
|
}
|
|
952
953
|
}
|
|
@@ -957,12 +958,12 @@ function je({
|
|
|
957
958
|
{
|
|
958
959
|
name: `${a}.value`,
|
|
959
960
|
type: "number",
|
|
960
|
-
defaultValue: typeof
|
|
961
|
+
defaultValue: typeof n.value == "number" ? n.value : "",
|
|
961
962
|
placeholder: "Enter value",
|
|
962
|
-
onChange: (
|
|
963
|
+
onChange: (o) => {
|
|
963
964
|
l(
|
|
964
965
|
`${a}.value`,
|
|
965
|
-
parseInt(
|
|
966
|
+
parseInt(o.currentTarget.value, 10)
|
|
966
967
|
);
|
|
967
968
|
}
|
|
968
969
|
}
|
|
@@ -972,16 +973,16 @@ function je({
|
|
|
972
973
|
j,
|
|
973
974
|
{
|
|
974
975
|
name: `${a}.value`,
|
|
975
|
-
defaultValue: typeof
|
|
976
|
-
label:
|
|
977
|
-
value:
|
|
976
|
+
defaultValue: typeof n.value == "boolean" ? {
|
|
977
|
+
label: n.value ? "Yes" : "No",
|
|
978
|
+
value: n.value
|
|
978
979
|
} : void 0,
|
|
979
980
|
initialValues: [
|
|
980
981
|
{ label: "Yes", value: !0 },
|
|
981
982
|
{ label: "No", value: !1 }
|
|
982
983
|
],
|
|
983
|
-
onSelect: (
|
|
984
|
-
V(
|
|
984
|
+
onSelect: (o) => {
|
|
985
|
+
V(o) && l(i, o.value);
|
|
985
986
|
}
|
|
986
987
|
}
|
|
987
988
|
);
|
|
@@ -992,10 +993,10 @@ function je({
|
|
|
992
993
|
{
|
|
993
994
|
name: `${a}.value`,
|
|
994
995
|
type: "text",
|
|
995
|
-
defaultValue: typeof
|
|
996
|
+
defaultValue: typeof n.value == "string" ? n.value : JSON.stringify(n.value),
|
|
996
997
|
placeholder: "Enter value",
|
|
997
|
-
onChange: (
|
|
998
|
-
l(
|
|
998
|
+
onChange: (o) => {
|
|
999
|
+
l(i, o.currentTarget.value);
|
|
999
1000
|
}
|
|
1000
1001
|
}
|
|
1001
1002
|
);
|
|
@@ -1003,34 +1004,34 @@ function je({
|
|
|
1003
1004
|
return R();
|
|
1004
1005
|
}
|
|
1005
1006
|
}
|
|
1006
|
-
function
|
|
1007
|
+
function _e({
|
|
1007
1008
|
item: e,
|
|
1008
1009
|
nestingLevel: a,
|
|
1009
1010
|
pathPrefix: l,
|
|
1010
|
-
onDelete:
|
|
1011
|
+
onDelete: r
|
|
1011
1012
|
}) {
|
|
1012
|
-
const { setPath: u } = y(),
|
|
1013
|
-
return a < 2 && (
|
|
1013
|
+
const { setPath: u } = y(), i = [];
|
|
1014
|
+
return a < 2 && (i[0] ?? (i[0] = []), i[0].push(
|
|
1014
1015
|
/* @__PURE__ */ t.jsx(
|
|
1015
1016
|
S,
|
|
1016
1017
|
{
|
|
1017
1018
|
label: "Nest conditions",
|
|
1018
1019
|
onClick: () => {
|
|
1019
|
-
var
|
|
1020
|
+
var n;
|
|
1020
1021
|
u(
|
|
1021
|
-
`${l}.nested.conditions.${(((
|
|
1022
|
+
`${l}.nested.conditions.${(((n = e == null ? void 0 : e.nested) == null ? void 0 : n.conditions) ?? []).length}`,
|
|
1022
1023
|
void 0
|
|
1023
1024
|
);
|
|
1024
1025
|
}
|
|
1025
1026
|
}
|
|
1026
1027
|
)
|
|
1027
|
-
)),
|
|
1028
|
+
)), r != null && (i[1] ?? (i[1] = []), i[1].push(
|
|
1028
1029
|
/* @__PURE__ */ t.jsx(
|
|
1029
1030
|
S,
|
|
1030
1031
|
{
|
|
1031
1032
|
label: "Delete",
|
|
1032
1033
|
onClick: () => {
|
|
1033
|
-
u(`${l}`, null),
|
|
1034
|
+
u(`${l}`, null), r();
|
|
1034
1035
|
}
|
|
1035
1036
|
}
|
|
1036
1037
|
)
|
|
@@ -1043,27 +1044,27 @@ function Ne({
|
|
|
1043
1044
|
name: `${l}.field`,
|
|
1044
1045
|
type: "text",
|
|
1045
1046
|
defaultValue: e != null ? e.field : void 0,
|
|
1046
|
-
onChange: (
|
|
1047
|
-
u(`${l}.field`,
|
|
1047
|
+
onChange: (n) => {
|
|
1048
|
+
u(`${l}.field`, n.currentTarget.value);
|
|
1048
1049
|
},
|
|
1049
|
-
onBlur: (
|
|
1050
|
-
u(`${l}.field`,
|
|
1050
|
+
onBlur: (n) => {
|
|
1051
|
+
u(`${l}.field`, n.currentTarget.value);
|
|
1051
1052
|
}
|
|
1052
1053
|
}
|
|
1053
1054
|
) }),
|
|
1054
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex-14", children: /* @__PURE__ */ t.jsx(
|
|
1055
|
+
/* @__PURE__ */ t.jsx("div", { className: "flex-14", children: /* @__PURE__ */ t.jsx(be, { item: e, pathPrefix: l }) })
|
|
1055
1056
|
] }),
|
|
1056
|
-
/* @__PURE__ */ t.jsx(
|
|
1057
|
+
/* @__PURE__ */ t.jsx(Ne, { item: e, pathPrefix: l })
|
|
1057
1058
|
] }) }),
|
|
1058
|
-
|
|
1059
|
-
|
|
1059
|
+
i.length > 0 && /* @__PURE__ */ t.jsx(
|
|
1060
|
+
J,
|
|
1060
1061
|
{
|
|
1061
1062
|
className: "w-8 border-l border-gray-100 flex items-center justify-center self-stretch",
|
|
1062
1063
|
dropdownLabel: /* @__PURE__ */ t.jsx("button", { className: "flex items-center justify-center self-stretch flex-grow", children: /* @__PURE__ */ t.jsx(p, { name: "dotsThreeVertical", size: 16, weight: "bold" }) }),
|
|
1063
|
-
dropdownItems:
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
] },
|
|
1064
|
+
dropdownItems: i.map((n, s, c) => /* @__PURE__ */ t.jsxs(I.Fragment, { children: [
|
|
1065
|
+
n.map((m, o) => /* @__PURE__ */ t.jsx(I.Fragment, { children: m }, o)),
|
|
1066
|
+
s < c.length - 1 && /* @__PURE__ */ t.jsx(le, {})
|
|
1067
|
+
] }, s))
|
|
1067
1068
|
}
|
|
1068
1069
|
)
|
|
1069
1070
|
] });
|
|
@@ -1072,17 +1073,17 @@ function H({
|
|
|
1072
1073
|
item: e,
|
|
1073
1074
|
children: a,
|
|
1074
1075
|
nestingLevel: l = 0,
|
|
1075
|
-
pathPrefix:
|
|
1076
|
+
pathPrefix: r
|
|
1076
1077
|
}) {
|
|
1077
|
-
var o,
|
|
1078
|
+
var o, d;
|
|
1078
1079
|
const {
|
|
1079
1080
|
state: { selectedRuleIndex: u }
|
|
1080
|
-
} = y(),
|
|
1081
|
+
} = y(), i = ((o = e == null ? void 0 : e.conditions_logic) == null ? void 0 : o.toLowerCase()) ?? "and", { setPath: n } = y(), [s, c] = x(0), m = l > 0;
|
|
1081
1082
|
return /* @__PURE__ */ t.jsxs(
|
|
1082
1083
|
"div",
|
|
1083
1084
|
{
|
|
1084
1085
|
className: $("query-group", {
|
|
1085
|
-
"p-4 border border-gray-200 rounded-md":
|
|
1086
|
+
"p-4 border border-gray-200 rounded-md": m
|
|
1086
1087
|
}),
|
|
1087
1088
|
children: [
|
|
1088
1089
|
a,
|
|
@@ -1090,54 +1091,54 @@ function H({
|
|
|
1090
1091
|
/* @__PURE__ */ t.jsxs(
|
|
1091
1092
|
"select",
|
|
1092
1093
|
{
|
|
1093
|
-
onChange: (
|
|
1094
|
-
|
|
1095
|
-
`${
|
|
1096
|
-
|
|
1094
|
+
onChange: (f) => {
|
|
1095
|
+
n(
|
|
1096
|
+
`${r}.conditions_logic`,
|
|
1097
|
+
f.currentTarget.value
|
|
1097
1098
|
);
|
|
1098
1099
|
},
|
|
1099
|
-
defaultValue:
|
|
1100
|
+
defaultValue: i,
|
|
1100
1101
|
className: "pl-4 pr-8 py-2 font-bold focus:ring-0 focus:outline-none appearance-none bg-gray-50 border border-gray-200 rounded-md text-sm leading-4",
|
|
1101
1102
|
children: [
|
|
1102
1103
|
/* @__PURE__ */ t.jsxs("option", { value: "and", children: [
|
|
1103
|
-
|
|
1104
|
+
m ? "Nested in " : "",
|
|
1104
1105
|
"AND"
|
|
1105
1106
|
] }),
|
|
1106
1107
|
/* @__PURE__ */ t.jsxs("option", { value: "or", children: [
|
|
1107
|
-
|
|
1108
|
+
m ? "Nested in " : "",
|
|
1108
1109
|
"OR"
|
|
1109
1110
|
] })
|
|
1110
1111
|
]
|
|
1111
1112
|
}
|
|
1112
1113
|
),
|
|
1113
|
-
/* @__PURE__ */ t.jsx("div", { className: "border-l border-gray-200 ml-3 pt-3", children: (
|
|
1114
|
+
/* @__PURE__ */ t.jsx("div", { className: "border-l border-gray-200 ml-3 pt-3", children: (d = e == null ? void 0 : e.conditions) == null ? void 0 : d.map((f, h, b) => {
|
|
1114
1115
|
const v = h === b.length - 1;
|
|
1115
1116
|
return /* @__PURE__ */ t.jsxs(
|
|
1116
1117
|
"div",
|
|
1117
1118
|
{
|
|
1118
1119
|
className: "flex items-center mb-4 last:mb-0 relative",
|
|
1119
1120
|
children: [
|
|
1120
|
-
/* @__PURE__ */ t.jsx(
|
|
1121
|
+
/* @__PURE__ */ t.jsx(we, { rounded: v }),
|
|
1121
1122
|
/* @__PURE__ */ t.jsx("div", { className: "ml-4 w-full", children: /* @__PURE__ */ t.jsx(
|
|
1122
1123
|
H,
|
|
1123
1124
|
{
|
|
1124
|
-
item: (
|
|
1125
|
-
nestingLevel: (
|
|
1126
|
-
pathPrefix: `${
|
|
1125
|
+
item: (f == null ? void 0 : f.nested) ?? void 0,
|
|
1126
|
+
nestingLevel: (f == null ? void 0 : f.nested) != null ? l + 1 : 0,
|
|
1127
|
+
pathPrefix: `${r}.conditions.${h}.nested`,
|
|
1127
1128
|
children: /* @__PURE__ */ t.jsx(
|
|
1128
1129
|
"div",
|
|
1129
1130
|
{
|
|
1130
1131
|
className: $({
|
|
1131
|
-
"mb-4": (
|
|
1132
|
+
"mb-4": (f == null ? void 0 : f.nested) != null
|
|
1132
1133
|
}),
|
|
1133
1134
|
children: /* @__PURE__ */ t.jsx(
|
|
1134
|
-
|
|
1135
|
+
_e,
|
|
1135
1136
|
{
|
|
1136
|
-
item:
|
|
1137
|
+
item: f,
|
|
1137
1138
|
nestingLevel: l,
|
|
1138
|
-
pathPrefix: `${
|
|
1139
|
+
pathPrefix: `${r}.conditions.${h}`,
|
|
1139
1140
|
onDelete: b.length > 1 || l > 0 ? () => {
|
|
1140
|
-
|
|
1141
|
+
c((_) => _ + 1);
|
|
1141
1142
|
} : void 0
|
|
1142
1143
|
}
|
|
1143
1144
|
)
|
|
@@ -1147,7 +1148,7 @@ function H({
|
|
|
1147
1148
|
) })
|
|
1148
1149
|
]
|
|
1149
1150
|
},
|
|
1150
|
-
`${u}-${h}-${
|
|
1151
|
+
`${u}-${h}-${s}`
|
|
1151
1152
|
);
|
|
1152
1153
|
}) })
|
|
1153
1154
|
] })
|
|
@@ -1155,7 +1156,7 @@ function H({
|
|
|
1155
1156
|
}
|
|
1156
1157
|
);
|
|
1157
1158
|
}
|
|
1158
|
-
function
|
|
1159
|
+
function we({
|
|
1159
1160
|
rounded: e = !1
|
|
1160
1161
|
}) {
|
|
1161
1162
|
return e ? /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
@@ -1163,34 +1164,34 @@ function _e({
|
|
|
1163
1164
|
/* @__PURE__ */ t.jsx("div", { className: "absolute -left-[1px] top-1/2 -translate-y-1/2 w-3.5 h-3.5 border-l border-b rounded-es-sm bg-white border-gray-200" })
|
|
1164
1165
|
] }) : /* @__PURE__ */ t.jsx("div", { className: "absolute left-0 top-1/2 -translate-y-1/2 w-3.5 h-px bg-gray-200" });
|
|
1165
1166
|
}
|
|
1166
|
-
function
|
|
1167
|
-
var
|
|
1167
|
+
function Te() {
|
|
1168
|
+
var i;
|
|
1168
1169
|
const {
|
|
1169
1170
|
setPath: e,
|
|
1170
1171
|
state: { value: a, selectedRuleIndex: l }
|
|
1171
|
-
} = y(), [
|
|
1172
|
-
((
|
|
1172
|
+
} = y(), [r, u] = x(
|
|
1173
|
+
((i = a.rules[l]) == null ? void 0 : i.name) ?? ""
|
|
1173
1174
|
);
|
|
1174
1175
|
return N(() => {
|
|
1175
|
-
var
|
|
1176
|
-
u(((
|
|
1176
|
+
var n;
|
|
1177
|
+
u(((n = a.rules[l]) == null ? void 0 : n.name) ?? "");
|
|
1177
1178
|
}, [l]), /* @__PURE__ */ t.jsx(
|
|
1178
1179
|
"div",
|
|
1179
1180
|
{
|
|
1180
1181
|
contentEditable: "plaintext-only",
|
|
1181
1182
|
suppressContentEditableWarning: !0,
|
|
1182
|
-
onInput: (
|
|
1183
|
-
const
|
|
1184
|
-
e(`rules.${l}.name`,
|
|
1183
|
+
onInput: (n) => {
|
|
1184
|
+
const c = n.currentTarget.innerText.replace(/[\n\s]+/g, " ").trim();
|
|
1185
|
+
e(`rules.${l}.name`, c);
|
|
1185
1186
|
},
|
|
1186
|
-
onKeyDown: (
|
|
1187
|
-
|
|
1187
|
+
onKeyDown: (n) => {
|
|
1188
|
+
n.key === "Enter" && (n.preventDefault(), n.currentTarget.blur());
|
|
1188
1189
|
},
|
|
1189
|
-
onBlur: (
|
|
1190
|
-
const
|
|
1191
|
-
|
|
1190
|
+
onBlur: (n) => {
|
|
1191
|
+
const s = n.currentTarget;
|
|
1192
|
+
s.innerText = s.innerText.replace(/[\n\s]+/g, " ").trim();
|
|
1192
1193
|
},
|
|
1193
|
-
children:
|
|
1194
|
+
children: r
|
|
1194
1195
|
},
|
|
1195
1196
|
l
|
|
1196
1197
|
);
|
|
@@ -1203,14 +1204,14 @@ const L = {
|
|
|
1203
1204
|
} catch {
|
|
1204
1205
|
return L;
|
|
1205
1206
|
}
|
|
1206
|
-
},
|
|
1207
|
+
}, $e = (e) => {
|
|
1207
1208
|
try {
|
|
1208
1209
|
return JSON.parse(e ?? "{}"), !0;
|
|
1209
1210
|
} catch {
|
|
1210
1211
|
return !1;
|
|
1211
1212
|
}
|
|
1212
1213
|
};
|
|
1213
|
-
function
|
|
1214
|
+
function qe(e) {
|
|
1214
1215
|
const [a, l] = x(
|
|
1215
1216
|
C(e.value ?? e.defaultValue)
|
|
1216
1217
|
);
|
|
@@ -1219,33 +1220,33 @@ function Ae(e) {
|
|
|
1219
1220
|
a.rules.length === 0 && l(C(e.value));
|
|
1220
1221
|
},
|
|
1221
1222
|
[e.value]
|
|
1222
|
-
), /* @__PURE__ */ t.jsx(
|
|
1223
|
+
), /* @__PURE__ */ t.jsx(me, { initialValue: { rules: a.rules }, children: /* @__PURE__ */ t.jsx(Ce, { ...e }) });
|
|
1223
1224
|
}
|
|
1224
|
-
function
|
|
1225
|
+
function Ce(e) {
|
|
1225
1226
|
const {
|
|
1226
1227
|
state: { value: a, selectedRuleIndex: l },
|
|
1227
|
-
setSelectedRuleIndex:
|
|
1228
|
+
setSelectedRuleIndex: r,
|
|
1228
1229
|
setValue: u,
|
|
1229
|
-
setPath:
|
|
1230
|
-
} = y(), [
|
|
1230
|
+
setPath: i
|
|
1231
|
+
} = y(), [n, s] = x(
|
|
1231
1232
|
e.defaultCodeEditorVisible ?? !1
|
|
1232
|
-
),
|
|
1233
|
+
), c = a.rules[l], m = oe(null), [o, d] = x(0);
|
|
1233
1234
|
N(
|
|
1234
1235
|
function() {
|
|
1235
1236
|
var b, v, _;
|
|
1236
|
-
E(C((b =
|
|
1237
|
+
E(C((b = m.current) == null ? void 0 : b.getValue()), a) || (v = m.current) == null || v.setValue(JSON.stringify(a, null, 2)), (_ = e.onChange) == null || _.call(e, a);
|
|
1237
1238
|
},
|
|
1238
1239
|
[a]
|
|
1239
1240
|
);
|
|
1240
|
-
const
|
|
1241
|
+
const f = w(
|
|
1241
1242
|
(h) => {
|
|
1242
1243
|
const b = C(h);
|
|
1243
|
-
|
|
1244
|
+
m.current != null && m.current.hasTextFocus() && $e(h) && !E(b, a) && (u(b), d((v) => v + 1));
|
|
1244
1245
|
},
|
|
1245
1246
|
[a]
|
|
1246
1247
|
);
|
|
1247
1248
|
return /* @__PURE__ */ t.jsx(
|
|
1248
|
-
|
|
1249
|
+
ne,
|
|
1249
1250
|
{
|
|
1250
1251
|
hint: e.hint,
|
|
1251
1252
|
feedback: e.feedback,
|
|
@@ -1254,7 +1255,7 @@ function $e(e) {
|
|
|
1254
1255
|
/* @__PURE__ */ t.jsxs(
|
|
1255
1256
|
"div",
|
|
1256
1257
|
{
|
|
1257
|
-
className: `shrink-0 basis-3/5 overflow-x-auto relative flex flex-col ${
|
|
1258
|
+
className: `shrink-0 basis-3/5 overflow-x-auto relative flex flex-col ${n ? "" : "grow"}`,
|
|
1258
1259
|
children: [
|
|
1259
1260
|
/* @__PURE__ */ t.jsxs("header", { className: "w-full bg-white border-b border-gray-200 py-3 px-8 flex text-[13px] gap-4 text-gray-400 font-semibold items-center", children: [
|
|
1260
1261
|
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-4 flex-wrap", children: [
|
|
@@ -1267,7 +1268,7 @@ function $e(e) {
|
|
|
1267
1268
|
"text-black": l === b
|
|
1268
1269
|
}),
|
|
1269
1270
|
onClick: () => {
|
|
1270
|
-
|
|
1271
|
+
r(b);
|
|
1271
1272
|
},
|
|
1272
1273
|
children: v
|
|
1273
1274
|
},
|
|
@@ -1281,11 +1282,11 @@ function $e(e) {
|
|
|
1281
1282
|
"text-black": !0
|
|
1282
1283
|
}),
|
|
1283
1284
|
onClick: () => {
|
|
1284
|
-
|
|
1285
|
+
i(`rules.${a.rules.length}`, {
|
|
1285
1286
|
name: "Rule name",
|
|
1286
1287
|
actions: [null],
|
|
1287
1288
|
conditions: [null]
|
|
1288
|
-
}),
|
|
1289
|
+
}), r(a.rules.length);
|
|
1289
1290
|
},
|
|
1290
1291
|
children: /* @__PURE__ */ t.jsx(p, { name: "plus", size: 16, className: "shrink-0" })
|
|
1291
1292
|
}
|
|
@@ -1296,24 +1297,24 @@ function $e(e) {
|
|
|
1296
1297
|
{
|
|
1297
1298
|
className: "text-blue-600 hover:text-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500",
|
|
1298
1299
|
onClick: () => {
|
|
1299
|
-
|
|
1300
|
+
s(!n);
|
|
1300
1301
|
},
|
|
1301
1302
|
children: /* @__PURE__ */ t.jsx(p, { name: "sidebarSimple", size: 16, color: "#101111" })
|
|
1302
1303
|
}
|
|
1303
1304
|
) })
|
|
1304
1305
|
] }),
|
|
1305
|
-
/* @__PURE__ */ t.jsxs(
|
|
1306
|
+
/* @__PURE__ */ t.jsxs(Ee, { children: [
|
|
1306
1307
|
/* @__PURE__ */ t.jsxs("div", { className: "mb-8 flex items-center gap-2", children: [
|
|
1307
|
-
/* @__PURE__ */ t.jsx(
|
|
1308
|
+
/* @__PURE__ */ t.jsx(Te, {}),
|
|
1308
1309
|
/* @__PURE__ */ t.jsx(p, { name: "pencilSimple", size: 16, className: "shrink-0" })
|
|
1309
1310
|
] }),
|
|
1310
|
-
/* @__PURE__ */ t.jsx(
|
|
1311
|
-
/* @__PURE__ */ t.jsx(
|
|
1312
|
-
/* @__PURE__ */ t.jsxs(
|
|
1311
|
+
/* @__PURE__ */ t.jsx(z, { title: "Actions", icon: "lightning", children: /* @__PURE__ */ t.jsx(he, { actions: c == null ? void 0 : c.actions }) }),
|
|
1312
|
+
/* @__PURE__ */ t.jsx(Ve, { children: "when" }),
|
|
1313
|
+
/* @__PURE__ */ t.jsxs(z, { title: "Conditions", icon: "treeView", children: [
|
|
1313
1314
|
/* @__PURE__ */ t.jsx(
|
|
1314
1315
|
H,
|
|
1315
1316
|
{
|
|
1316
|
-
item:
|
|
1317
|
+
item: c,
|
|
1317
1318
|
pathPrefix: `rules.${l}`
|
|
1318
1319
|
}
|
|
1319
1320
|
),
|
|
@@ -1325,8 +1326,8 @@ function $e(e) {
|
|
|
1325
1326
|
alignItems: "center",
|
|
1326
1327
|
onClick: () => {
|
|
1327
1328
|
var h;
|
|
1328
|
-
|
|
1329
|
-
`rules.${l}.conditions.${((h =
|
|
1329
|
+
i(
|
|
1330
|
+
`rules.${l}.conditions.${((h = c == null ? void 0 : c.conditions) == null ? void 0 : h.length) ?? 0}`,
|
|
1330
1331
|
void 0
|
|
1331
1332
|
);
|
|
1332
1333
|
},
|
|
@@ -1342,31 +1343,31 @@ function $e(e) {
|
|
|
1342
1343
|
},
|
|
1343
1344
|
o
|
|
1344
1345
|
),
|
|
1345
|
-
|
|
1346
|
-
|
|
1346
|
+
n && /* @__PURE__ */ t.jsx("div", { className: "shrink-0 basis-2/5", children: /* @__PURE__ */ t.jsx(
|
|
1347
|
+
se,
|
|
1347
1348
|
{
|
|
1348
|
-
ref:
|
|
1349
|
+
ref: m,
|
|
1349
1350
|
name: e.id ?? e.name,
|
|
1350
1351
|
height: "100%",
|
|
1351
1352
|
language: "json",
|
|
1352
1353
|
jsonSchema: "order-rules",
|
|
1353
1354
|
defaultValue: JSON.stringify(a, null, 2),
|
|
1354
1355
|
noRounding: !0,
|
|
1355
|
-
onChange:
|
|
1356
|
+
onChange: f
|
|
1356
1357
|
}
|
|
1357
1358
|
) })
|
|
1358
1359
|
] })
|
|
1359
1360
|
}
|
|
1360
1361
|
);
|
|
1361
1362
|
}
|
|
1362
|
-
function
|
|
1363
|
+
function Ve({ children: e }) {
|
|
1363
1364
|
return /* @__PURE__ */ t.jsxs("div", { className: "text-gray-500 flex items-center justify-center flex-col", children: [
|
|
1364
1365
|
/* @__PURE__ */ t.jsx("div", { className: "h-6 w-[2px] bg-gray-200" }),
|
|
1365
1366
|
/* @__PURE__ */ t.jsx("span", { className: "font-bold my-1 bg-gray-200 px-3 relative uppercase rounded h-[25px] items-center flex text-sm", children: e }),
|
|
1366
1367
|
/* @__PURE__ */ t.jsx("div", { className: "h-6 w-[2px] bg-gray-200" })
|
|
1367
1368
|
] });
|
|
1368
1369
|
}
|
|
1369
|
-
function
|
|
1370
|
+
function z({
|
|
1370
1371
|
children: e,
|
|
1371
1372
|
title: a,
|
|
1372
1373
|
icon: l
|
|
@@ -1379,11 +1380,11 @@ function J({
|
|
|
1379
1380
|
/* @__PURE__ */ t.jsx("div", { className: "p-6", children: e })
|
|
1380
1381
|
] });
|
|
1381
1382
|
}
|
|
1382
|
-
function
|
|
1383
|
+
function Ee({
|
|
1383
1384
|
children: e
|
|
1384
1385
|
}) {
|
|
1385
1386
|
return /* @__PURE__ */ t.jsx("div", { className: "h-full w-full bg-gray-50 p-8 [background-image:radial-gradient(#d6d6d6_1px,transparent_1px)] [background-size:16px_16px] overflow-auto", children: /* @__PURE__ */ t.jsx("div", { className: "max-w-[900px] mx-auto", children: e }) });
|
|
1386
1387
|
}
|
|
1387
1388
|
export {
|
|
1388
|
-
|
|
1389
|
+
qe as RuleEngine
|
|
1389
1390
|
};
|