@commercelayer/app-elements 5.6.0 → 5.7.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--5lVbv6t.js +720 -0
- package/dist/InputDateComponent-NpCZmpgY.js +4887 -0
- package/dist/RuleEngineComponent-BbIy4caP.js +1404 -0
- package/dist/dictionaries/customers.d.ts +1 -1
- package/dist/dictionaries/orders.d.ts +7 -7
- package/dist/dictionaries/promotions.d.ts +2 -2
- package/dist/dictionaries/returns.d.ts +4 -4
- package/dist/dictionaries/shipments.d.ts +4 -4
- package/dist/dictionaries/stockTransfers.d.ts +4 -4
- package/dist/dictionaries/types.d.ts +2 -2
- package/dist/fetchCoreResourcesSuggestions-DLZhtrDX.js +124 -0
- package/dist/helpers/appsNavigation.d.ts +2 -2
- package/dist/helpers/attachments.d.ts +1 -1
- package/dist/helpers/date.d.ts +13 -13
- package/dist/helpers/downloadJsonAsFile.d.ts +1 -1
- package/dist/helpers/resources.d.ts +4 -4
- package/dist/helpers/tracking.d.ts +4 -4
- package/dist/hooks/useClickAway.d.ts +1 -1
- package/dist/hooks/useEditMetadataOverlay.d.ts +3 -3
- package/dist/hooks/useEditTagsOverlay.d.ts +2 -2
- package/dist/hooks/useIsChanged.d.ts +1 -1
- package/dist/{main-YD7ko8U-.js → main-BqlK85T7.js} +26914 -28733
- package/dist/main.d.ts +60 -60
- package/dist/main.js +1 -1
- package/dist/{parseISO-Cq_loYUP.js → parseISO-B-bk2SyC.js} +17 -17
- package/dist/providers/CoreSdkProvider/CoreSdkProvider.d.ts +1 -1
- package/dist/providers/CoreSdkProvider/makeSdkClient.d.ts +1 -1
- package/dist/providers/CoreSdkProvider/useCoreApi.d.ts +1 -1
- package/dist/providers/GTMProvider.d.ts +1 -1
- package/dist/providers/TokenProvider/MockTokenProvider.d.ts +1 -1
- package/dist/providers/TokenProvider/TokenProvider.d.ts +1 -1
- package/dist/providers/TokenProvider/getAccessTokenFromUrl.d.ts +1 -1
- package/dist/providers/TokenProvider/index.d.ts +1 -1
- package/dist/providers/TokenProvider/reducer.d.ts +2 -2
- package/dist/providers/TokenProvider/storage.d.ts +4 -4
- package/dist/providers/TokenProvider/types.d.ts +10 -10
- package/dist/providers/TokenProvider/url.d.ts +1 -1
- package/dist/providers/TokenProvider/validateToken.d.ts +2 -2
- package/dist/providers/createApp.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist/tailwind.config.js +141 -142
- package/dist/ui/atoms/A.d.ts +1 -1
- package/dist/ui/atoms/Alert.d.ts +1 -1
- package/dist/ui/atoms/Avatar.d.ts +3 -3
- package/dist/ui/atoms/Avatar.utils.d.ts +18 -18
- package/dist/ui/atoms/AvatarLetter/colors.d.ts +1 -1
- package/dist/ui/atoms/Badge/Badge.d.ts +3 -3
- package/dist/ui/atoms/Badge/badgeVariants.d.ts +1 -1
- package/dist/ui/atoms/ButtonFilter.d.ts +1 -1
- package/dist/ui/atoms/Card.d.ts +15 -11
- package/dist/ui/atoms/CodeBlock.d.ts +1 -1
- package/dist/ui/atoms/EmptyState.d.ts +1 -1
- package/dist/ui/atoms/Grid.d.ts +6 -6
- package/dist/ui/atoms/Hint.d.ts +1 -1
- package/dist/ui/atoms/Hr.d.ts +2 -2
- package/dist/ui/atoms/Icon/Icon.d.ts +2 -2
- package/dist/ui/atoms/Icon/icons.d.ts +1 -1
- package/dist/ui/atoms/PageHeading/PageHeading.d.ts +3 -3
- package/dist/ui/atoms/PageHeading/PageHeadingToolbar.d.ts +2 -2
- package/dist/ui/atoms/Progress.d.ts +1 -1
- package/dist/ui/atoms/RadialProgress.d.ts +2 -2
- package/dist/ui/atoms/Section.d.ts +2 -2
- package/dist/ui/atoms/Skeleton.d.ts +1 -1
- package/dist/ui/atoms/Spacer.d.ts +3 -3
- package/dist/ui/atoms/StatusDot.d.ts +1 -1
- package/dist/ui/atoms/StatusIcon.d.ts +2 -2
- package/dist/ui/atoms/Table/Table.d.ts +1 -1
- package/dist/ui/atoms/Tag.d.ts +3 -3
- package/dist/ui/atoms/Text.d.ts +6 -6
- package/dist/ui/atoms/Tooltip.d.ts +2 -2
- package/dist/ui/composite/ActionButtons/ActionButtons.d.ts +2 -2
- package/dist/ui/composite/Address.d.ts +1 -1
- package/dist/ui/composite/Dropdown/Dropdown.d.ts +1 -1
- package/dist/ui/composite/Dropdown/DropdownItem.d.ts +11 -7
- package/dist/ui/composite/Dropdown/DropdownMenu.d.ts +3 -3
- package/dist/ui/composite/HomePageLayout.d.ts +3 -3
- package/dist/ui/composite/List.d.ts +2 -2
- package/dist/ui/composite/ListDetails.d.ts +2 -2
- package/dist/ui/composite/ListDetailsItem.d.ts +3 -3
- package/dist/ui/composite/ListItem.d.ts +7 -7
- package/dist/ui/composite/PageError.d.ts +2 -2
- package/dist/ui/composite/PageLayout.d.ts +6 -6
- package/dist/ui/composite/Routes/Routes.d.ts +3 -3
- package/dist/ui/composite/Routes/index.d.ts +2 -2
- package/dist/ui/composite/Routes/utils.d.ts +5 -5
- package/dist/ui/composite/SearchBar.d.ts +1 -1
- package/dist/ui/composite/Timeline.d.ts +1 -1
- package/dist/ui/composite/Toast.d.ts +1 -1
- package/dist/ui/composite/Toolbar.d.ts +6 -6
- package/dist/ui/forms/CodeEditor/CodeEditorComponent.d.ts +4 -4
- package/dist/ui/forms/CodeEditor/HookedCodeEditor.d.ts +1 -1
- package/dist/ui/forms/CodeEditor/fetchCoreResourcesSuggestions.d.ts +7 -7
- package/dist/ui/forms/CodeEditor/index.d.ts +1 -1
- package/dist/ui/forms/Input/Input.d.ts +2 -2
- package/dist/ui/forms/InputCheckbox/HookedInputCheckbox.d.ts +1 -1
- package/dist/ui/forms/InputCheckbox/InputCheckbox.d.ts +2 -2
- package/dist/ui/forms/InputCheckbox/index.d.ts +1 -1
- package/dist/ui/forms/InputCheckboxGroup/HookedInputCheckboxGroup.d.ts +1 -1
- package/dist/ui/forms/InputCheckboxGroup/InputCheckboxGroupItem.d.ts +2 -2
- package/dist/ui/forms/InputCheckboxGroup/index.d.ts +2 -2
- package/dist/ui/forms/InputCheckboxGroup/reducer.d.ts +3 -3
- package/dist/ui/forms/InputCurrency/HookedInputCurrency.d.ts +1 -1
- package/dist/ui/forms/InputCurrency/InputCurrency.d.ts +3 -3
- package/dist/ui/forms/InputCurrency/index.d.ts +1 -1
- package/dist/ui/forms/InputCurrency/utils.d.ts +1 -1
- package/dist/ui/forms/InputCurrencyRange.d.ts +3 -3
- package/dist/ui/forms/InputDate/HookedInputDate.d.ts +1 -1
- package/dist/ui/forms/InputDateRange/HookedInputDateRange.d.ts +1 -1
- package/dist/ui/forms/InputDateRange/InputDateRange.d.ts +5 -5
- package/dist/ui/forms/InputDateRange/index.d.ts +1 -1
- package/dist/ui/forms/InputFeedback.d.ts +1 -1
- package/dist/ui/forms/InputFile.d.ts +1 -1
- package/dist/ui/forms/InputJson.d.ts +1 -1
- package/dist/ui/forms/InputRadioGroup/HookedInputRadioGroup.d.ts +1 -1
- package/dist/ui/forms/InputRadioGroup/index.d.ts +1 -1
- package/dist/ui/forms/InputResourceGroup/FullList.d.ts +3 -3
- package/dist/ui/forms/InputResourceGroup/HookedInputResourceGroup.d.ts +1 -1
- package/dist/ui/forms/InputResourceGroup/InputResourceGroup.d.ts +1 -1
- package/dist/ui/forms/InputResourceGroup/index.d.ts +2 -2
- package/dist/ui/forms/InputResourceGroup/utils.d.ts +3 -3
- package/dist/ui/forms/InputSelect/CreatableComponent.d.ts +1 -1
- package/dist/ui/forms/InputSelect/GenericAsyncComponent.d.ts +1 -1
- package/dist/ui/forms/InputSelect/HookedInputSelect.d.ts +1 -1
- package/dist/ui/forms/InputSelect/InputSelect.d.ts +1 -1
- package/dist/ui/forms/InputSelect/SelectComponent.d.ts +1 -1
- package/dist/ui/forms/InputSelect/index.d.ts +3 -3
- package/dist/ui/forms/InputSelect/styles.d.ts +1 -1
- package/dist/ui/forms/InputSelect/utils.d.ts +1 -1
- package/dist/ui/forms/InputSimpleSelect/InputSimpleSelect.d.ts +1 -1
- package/dist/ui/forms/InputSimpleSelect/index.d.ts +2 -2
- package/dist/ui/forms/InputSpinner/HookedInputSpinner.d.ts +1 -1
- package/dist/ui/forms/InputSpinner/InputSpinner.d.ts +1 -1
- package/dist/ui/forms/InputSpinner/index.d.ts +1 -1
- package/dist/ui/forms/InputSwitch/InputSwitch.d.ts +1 -1
- package/dist/ui/forms/InputSwitch/index.d.ts +1 -1
- package/dist/ui/forms/InputTextArea/index.d.ts +1 -1
- package/dist/ui/forms/InputToggleButton/HookedInputToggleButton.d.ts +1 -1
- package/dist/ui/forms/InputToggleButton/InputToggleButton.d.ts +4 -4
- package/dist/ui/forms/InputToggleButton/index.d.ts +2 -2
- package/dist/ui/forms/MarketWithCurrencySelector/HookedMarketWithCurrencySelector.d.ts +2 -2
- package/dist/ui/forms/MarketWithCurrencySelector/index.d.ts +1 -1
- package/dist/ui/forms/ReactHookForm/HookedValidationApiError.d.ts +1 -1
- package/dist/ui/forms/ReactHookForm/setApiFormErrors.d.ts +1 -1
- package/dist/ui/forms/ReactHookForm/useValidationFeedback.d.ts +1 -1
- package/dist/ui/forms/RuleEngine/Action/ActionListItem.d.ts +1 -1
- package/dist/ui/forms/RuleEngine/Action/ActionValue.d.ts +1 -1
- package/dist/ui/forms/RuleEngine/Action/index.d.ts +1 -1
- package/dist/ui/forms/RuleEngine/Condition/ArrayMatch.d.ts +0 -0
- package/dist/ui/forms/RuleEngine/Condition/ConditionListItem.d.ts +1 -1
- package/dist/ui/forms/RuleEngine/Condition/ConditionMatcher.d.ts +1 -1
- package/dist/ui/forms/RuleEngine/Condition/ConditionValue.d.ts +1 -1
- package/dist/ui/forms/RuleEngine/Condition/Connector.d.ts +0 -0
- package/dist/ui/forms/RuleEngine/Condition/RangeInputs.d.ts +0 -0
- package/dist/ui/forms/RuleEngine/Condition/ValueComponents/InputArrayMatch.d.ts +2 -2
- package/dist/ui/forms/RuleEngine/Condition/ValueComponents/InputNumberRange.d.ts +2 -2
- package/dist/ui/forms/RuleEngine/Condition/ValueComponents/InputTextRange.d.ts +2 -2
- package/dist/ui/forms/RuleEngine/Condition/dictionaries.d.ts +0 -0
- package/dist/ui/forms/RuleEngine/Condition/index.d.ts +1 -1
- package/dist/ui/forms/RuleEngine/Condition/types.d.ts +0 -0
- package/dist/ui/forms/RuleEngine/Condition/utils.d.ts +1 -1
- package/dist/ui/forms/RuleEngine/RuleEngineComponent.d.ts +4 -4
- package/dist/ui/forms/RuleEngine/RuleEngineContext.d.ts +1 -1
- package/dist/ui/forms/RuleEngine/utils.d.ts +6 -6
- package/dist/ui/internals/FlexRow.d.ts +1 -1
- package/dist/ui/internals/InputWrapper.d.ts +6 -6
- package/dist/ui/internals/InteractiveElement.className.d.ts +4 -4
- package/dist/ui/internals/Overlay.d.ts +1 -1
- package/dist/ui/resources/ResourceAddress/ResourceAddress.d.ts +2 -2
- package/dist/ui/resources/ResourceAddress/ResourceAddressFormFields.d.ts +1 -1
- package/dist/ui/resources/ResourceAddress/index.d.ts +1 -1
- package/dist/ui/resources/ResourceAddress/useResourceAddressOverlay.d.ts +2 -2
- package/dist/ui/resources/ResourceAttachments/index.d.ts +1 -1
- package/dist/ui/resources/ResourceDetails/useEditDetailsOverlay.d.ts +2 -2
- package/dist/ui/resources/ResourceLineItems/index.d.ts +1 -1
- package/dist/ui/resources/ResourceListItem/ResourceListItem.d.ts +2 -2
- package/dist/ui/resources/ResourceListItem/ResourceListItem.mocks.d.ts +9 -0
- package/dist/ui/resources/ResourceListItem/index.d.ts +1 -1
- package/dist/ui/resources/ResourceListItem/types.d.ts +3 -3
- package/dist/ui/resources/ResourceMetadata/ResourceMetadata.d.ts +2 -2
- package/dist/ui/resources/ResourceMetadata/index.d.ts +1 -1
- package/dist/ui/resources/ResourceOrderTimeline.d.ts +1 -1
- package/dist/ui/resources/ResourcePaymentMethod.d.ts +3 -3
- package/dist/ui/resources/ResourceShipmentParcels.mocks.d.ts +2 -2
- package/dist/ui/resources/ResourceTags.d.ts +3 -3
- package/dist/ui/resources/useResourceFilters/FieldCurrencyRange.d.ts +1 -2
- package/dist/ui/resources/useResourceFilters/FiltersForm.d.ts +1 -1
- package/dist/ui/resources/useResourceFilters/FiltersNav.d.ts +1 -2
- package/dist/ui/resources/useResourceFilters/FiltersSearchBar.d.ts +3 -3
- package/dist/ui/resources/useResourceFilters/adaptFormValuesToSdk.d.ts +1 -1
- package/dist/ui/resources/useResourceFilters/adaptFormValuesToUrlQuery.d.ts +1 -1
- package/dist/ui/resources/useResourceFilters/adaptSdkToMetrics.d.ts +4 -4
- package/dist/ui/resources/useResourceFilters/adaptSdkToUrlQuery.d.ts +2 -2
- package/dist/ui/resources/useResourceFilters/adaptUrlQueryToFormValues.d.ts +1 -1
- package/dist/ui/resources/useResourceFilters/adaptUrlQueryToSdk.d.ts +1 -1
- package/dist/ui/resources/useResourceFilters/adaptUrlQueryToUrlQuery.d.ts +1 -1
- package/dist/ui/resources/useResourceFilters/adapters.types.d.ts +8 -8
- package/dist/ui/resources/useResourceFilters/timeUtils.d.ts +1 -1
- package/dist/ui/resources/useResourceFilters/types.d.ts +18 -18
- package/dist/ui/resources/useResourceFilters/useResourceFilters.d.ts +10 -11
- package/dist/ui/resources/useResourceFilters/utils.d.ts +2 -2
- package/dist/ui/resources/useResourceList/adaptMetricsOrderToCore.d.ts +1 -1
- package/dist/ui/resources/useResourceList/index.d.ts +1 -1
- package/dist/ui/resources/useResourceList/infiniteFetcher.d.ts +5 -5
- package/dist/ui/resources/useResourceList/metricsApiClient.d.ts +4 -4
- package/dist/ui/resources/useResourceList/reducer.d.ts +5 -5
- package/dist/ui/resources/useResourceList/useResourceList.d.ts +10 -10
- package/dist/ui/resources/useResourceList/utils.d.ts +1 -1
- package/dist/utils/array.d.ts +1 -1
- package/dist/utils/htmltags.d.ts +1 -1
- package/dist/utils/pagination.d.ts +4 -4
- package/dist/vendor.css +1 -1
- package/package.json +32 -35
- package/dist/CodeEditorComponent-DhpbUF3I.js +0 -739
- package/dist/InputDateComponent-BZyuY3F6.js +0 -4964
- package/dist/RuleEngineComponent-UggkM5Zc.js +0 -1390
- package/dist/fetchCoreResourcesSuggestions-CZkDwjO2.js +0 -126
|
@@ -1,1390 +0,0 @@
|
|
|
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 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
|
-
import "react-hook-form";
|
|
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
|
-
import { a as de } from "./fetchCoreResourcesSuggestions-CZkDwjO2.js";
|
|
6
|
-
import { p as A } from "./parseISO-Cq_loYUP.js";
|
|
7
|
-
function q(e, a) {
|
|
8
|
-
const l = e.match(
|
|
9
|
-
/(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(?:\.(\d{0,7}))?(?:Z|(.)(\d{2}):?(\d{2})?)?/
|
|
10
|
-
);
|
|
11
|
-
return l ? k(
|
|
12
|
-
Date.UTC(
|
|
13
|
-
+l[1],
|
|
14
|
-
+l[2] - 1,
|
|
15
|
-
+l[3],
|
|
16
|
-
+l[4] - (+l[9] || 0) * (l[8] == "-" ? -1 : 1),
|
|
17
|
-
+l[5] - (+l[10] || 0) * (l[8] == "-" ? -1 : 1),
|
|
18
|
-
+l[6],
|
|
19
|
-
+((l[7] || "0") + "00").substring(0, 3)
|
|
20
|
-
),
|
|
21
|
-
a == null ? void 0 : a.in
|
|
22
|
-
) : k(NaN, a == null ? void 0 : a.in);
|
|
23
|
-
}
|
|
24
|
-
function D(e, a, l) {
|
|
25
|
-
return e == null ? e : Z(e, a, l);
|
|
26
|
-
}
|
|
27
|
-
function M(e, a) {
|
|
28
|
-
return e == null ? !0 : G(e, a);
|
|
29
|
-
}
|
|
30
|
-
const W = ue(
|
|
31
|
-
void 0
|
|
32
|
-
);
|
|
33
|
-
function fe(e, a) {
|
|
34
|
-
var l;
|
|
35
|
-
switch (a.type) {
|
|
36
|
-
case "SET_PATH": {
|
|
37
|
-
const r = { ...e.value };
|
|
38
|
-
if (a.value === null)
|
|
39
|
-
if (/\.\d+$/.test(a.path)) {
|
|
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
|
-
} else
|
|
43
|
-
M(r, a.path);
|
|
44
|
-
else
|
|
45
|
-
D(r, a.path, a.value);
|
|
46
|
-
return {
|
|
47
|
-
...e,
|
|
48
|
-
value: r
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
case "SET_SELECTED_RULE_INDEX":
|
|
52
|
-
return {
|
|
53
|
-
...e,
|
|
54
|
-
selectedRuleIndex: a.index
|
|
55
|
-
};
|
|
56
|
-
case "SET_VALUE":
|
|
57
|
-
return E(e.value, a.value) ? e : a.value.rules.length === 0 ? {
|
|
58
|
-
selectedRuleIndex: 0,
|
|
59
|
-
value: {
|
|
60
|
-
rules: [
|
|
61
|
-
{
|
|
62
|
-
name: "Rule name",
|
|
63
|
-
// @ts-expect-error Setting `null` is intentional for rendering an empty action
|
|
64
|
-
actions: [null],
|
|
65
|
-
// @ts-expect-error Setting `null` is intentional for rendering an empty condition
|
|
66
|
-
conditions: [null]
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
}
|
|
70
|
-
} : {
|
|
71
|
-
...e,
|
|
72
|
-
value: a.value
|
|
73
|
-
};
|
|
74
|
-
default:
|
|
75
|
-
return e;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function me({
|
|
79
|
-
children: e,
|
|
80
|
-
initialValue: a
|
|
81
|
-
}) {
|
|
82
|
-
const [l, r] = re(fe, {
|
|
83
|
-
value: a,
|
|
84
|
-
selectedRuleIndex: 0
|
|
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
|
-
() => ({
|
|
93
|
-
state: l,
|
|
94
|
-
setPath: u,
|
|
95
|
-
setSelectedRuleIndex: i,
|
|
96
|
-
setValue: n
|
|
97
|
-
}),
|
|
98
|
-
[l, u, i, n]
|
|
99
|
-
);
|
|
100
|
-
return /* @__PURE__ */ t.jsx(W.Provider, { value: s, children: e });
|
|
101
|
-
}
|
|
102
|
-
function y() {
|
|
103
|
-
const e = ce(W);
|
|
104
|
-
if (e === void 0)
|
|
105
|
-
throw new Error("useRuleEngine must be used within a RuleEngineProvider");
|
|
106
|
-
return e;
|
|
107
|
-
}
|
|
108
|
-
const X = P([
|
|
109
|
-
"blank",
|
|
110
|
-
"present",
|
|
111
|
-
"null",
|
|
112
|
-
"not_null"
|
|
113
|
-
]);
|
|
114
|
-
function R(e) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
function ge({
|
|
118
|
-
item: e,
|
|
119
|
-
pathPrefix: a
|
|
120
|
-
}) {
|
|
121
|
-
var r, u, i, n;
|
|
122
|
-
const { setPath: l } = y();
|
|
123
|
-
if (e == null)
|
|
124
|
-
return null;
|
|
125
|
-
switch (e.type) {
|
|
126
|
-
case "buy_x_pay_y":
|
|
127
|
-
return /* @__PURE__ */ t.jsxs("div", { className: "w-36 flex items-center gap-0.5", children: [
|
|
128
|
-
/* @__PURE__ */ t.jsx(
|
|
129
|
-
g,
|
|
130
|
-
{
|
|
131
|
-
name: `${a}.value.x`,
|
|
132
|
-
type: "number",
|
|
133
|
-
suffix: "X",
|
|
134
|
-
defaultValue: (r = e.value) == null ? void 0 : r.x,
|
|
135
|
-
onChange: (s) => {
|
|
136
|
-
l(
|
|
137
|
-
`${a}.value.x`,
|
|
138
|
-
parseInt(s.currentTarget.value, 10)
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
),
|
|
143
|
-
/* @__PURE__ */ t.jsx(
|
|
144
|
-
g,
|
|
145
|
-
{
|
|
146
|
-
name: `${a}.value.y`,
|
|
147
|
-
type: "number",
|
|
148
|
-
suffix: "Y",
|
|
149
|
-
defaultValue: (u = e.value) == null ? void 0 : u.y,
|
|
150
|
-
onChange: (s) => {
|
|
151
|
-
l(
|
|
152
|
-
`${a}.value.y`,
|
|
153
|
-
parseInt(s.currentTarget.value, 10)
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
)
|
|
158
|
-
] });
|
|
159
|
-
case "every_x_discount_y":
|
|
160
|
-
return /* @__PURE__ */ t.jsxs("div", { className: "w-36 flex items-center gap-0.5", children: [
|
|
161
|
-
/* @__PURE__ */ t.jsx(
|
|
162
|
-
g,
|
|
163
|
-
{
|
|
164
|
-
name: `${a}.value.x`,
|
|
165
|
-
type: "number",
|
|
166
|
-
suffix: "X",
|
|
167
|
-
defaultValue: (i = e.value) == null ? void 0 : i.x,
|
|
168
|
-
onChange: (s) => {
|
|
169
|
-
l(
|
|
170
|
-
`${a}.value.x`,
|
|
171
|
-
parseInt(s.currentTarget.value, 10)
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
),
|
|
176
|
-
/* @__PURE__ */ t.jsx(
|
|
177
|
-
g,
|
|
178
|
-
{
|
|
179
|
-
name: `${a}.value.y`,
|
|
180
|
-
type: "number",
|
|
181
|
-
suffix: "Y",
|
|
182
|
-
defaultValue: (n = e.value) == null ? void 0 : n.y,
|
|
183
|
-
onChange: (s) => {
|
|
184
|
-
l(
|
|
185
|
-
`${a}.value.y`,
|
|
186
|
-
parseInt(s.currentTarget.value, 10)
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
)
|
|
191
|
-
] });
|
|
192
|
-
case "fixed_amount":
|
|
193
|
-
case "fixed_price":
|
|
194
|
-
return /* @__PURE__ */ t.jsx("div", { className: "w-36", children: /* @__PURE__ */ t.jsx(
|
|
195
|
-
g,
|
|
196
|
-
{
|
|
197
|
-
name: `${a}.value`,
|
|
198
|
-
type: "number",
|
|
199
|
-
defaultValue: e.value,
|
|
200
|
-
min: 0,
|
|
201
|
-
suffix: "cents",
|
|
202
|
-
onChange: (s) => {
|
|
203
|
-
l(
|
|
204
|
-
`${a}.value`,
|
|
205
|
-
parseInt(s.currentTarget.value, 10)
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
) });
|
|
210
|
-
case "percentage": {
|
|
211
|
-
const s = (e.value * 100).toFixed(2);
|
|
212
|
-
return /* @__PURE__ */ t.jsx("div", { className: "w-24", children: /* @__PURE__ */ t.jsx(
|
|
213
|
-
g,
|
|
214
|
-
{
|
|
215
|
-
name: `${a}.value`,
|
|
216
|
-
type: "number",
|
|
217
|
-
defaultValue: s.endsWith(".00") ? s.slice(0, -3) : s,
|
|
218
|
-
min: 0,
|
|
219
|
-
max: 100,
|
|
220
|
-
suffix: "%",
|
|
221
|
-
onChange: (c) => {
|
|
222
|
-
l(
|
|
223
|
-
`${a}.value`,
|
|
224
|
-
parseFloat(c.currentTarget.value) / 100
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
) });
|
|
229
|
-
}
|
|
230
|
-
default:
|
|
231
|
-
return R();
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
function xe({
|
|
235
|
-
item: e,
|
|
236
|
-
index: a,
|
|
237
|
-
onDelete: l
|
|
238
|
-
}) {
|
|
239
|
-
const {
|
|
240
|
-
setPath: r,
|
|
241
|
-
state: { selectedRuleIndex: u }
|
|
242
|
-
} = y(), i = {
|
|
243
|
-
percentage: "Percentage discount",
|
|
244
|
-
fixed_amount: "Fixed amount",
|
|
245
|
-
fixed_price: "Fixed price",
|
|
246
|
-
buy_x_pay_y: "Buy X, Pay Y",
|
|
247
|
-
every_x_discount_y: "Every X, Discount Y"
|
|
248
|
-
}, n = `rules.${u}.actions.${a}`;
|
|
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
|
-
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between gap-2 flex-grow p-2", children: [
|
|
251
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex-1", children: /* @__PURE__ */ t.jsx(
|
|
252
|
-
j,
|
|
253
|
-
{
|
|
254
|
-
name: `${n}.type`,
|
|
255
|
-
defaultValue: e != null ? {
|
|
256
|
-
label: i[e.type],
|
|
257
|
-
value: e.type
|
|
258
|
-
} : void 0,
|
|
259
|
-
initialValues: Object.entries(i).map(
|
|
260
|
-
([s, c]) => ({ value: s, label: c })
|
|
261
|
-
),
|
|
262
|
-
onSelect: (s) => {
|
|
263
|
-
V(s) && r(`${n}.type`, s.value);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
) }),
|
|
267
|
-
/* @__PURE__ */ t.jsx(ge, { item: e, pathPrefix: n }),
|
|
268
|
-
/* @__PURE__ */ t.jsx("div", { className: "text-black font-bold text-sm", children: "ON" }),
|
|
269
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex-1", children: /* @__PURE__ */ t.jsx(
|
|
270
|
-
g,
|
|
271
|
-
{
|
|
272
|
-
name: `${n}.selector`,
|
|
273
|
-
type: "text",
|
|
274
|
-
defaultValue: e != null ? e.selector : void 0,
|
|
275
|
-
onChange: (s) => {
|
|
276
|
-
r(`${n}.selector`, s.currentTarget.value);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
) })
|
|
280
|
-
] }),
|
|
281
|
-
l != null && /* @__PURE__ */ t.jsx(
|
|
282
|
-
J,
|
|
283
|
-
{
|
|
284
|
-
className: "w-8 border-l border-gray-100 flex items-center justify-center self-stretch",
|
|
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" }) }),
|
|
286
|
-
dropdownItems: /* @__PURE__ */ t.jsx(t.Fragment, { children: /* @__PURE__ */ t.jsx(
|
|
287
|
-
S,
|
|
288
|
-
{
|
|
289
|
-
label: "Delete",
|
|
290
|
-
onClick: () => {
|
|
291
|
-
r(`${n}`, null), l();
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
) })
|
|
295
|
-
}
|
|
296
|
-
)
|
|
297
|
-
] }) });
|
|
298
|
-
}
|
|
299
|
-
function he({
|
|
300
|
-
actions: e
|
|
301
|
-
}) {
|
|
302
|
-
const [a, l] = x(0), {
|
|
303
|
-
setPath: r,
|
|
304
|
-
state: { selectedRuleIndex: u }
|
|
305
|
-
} = y();
|
|
306
|
-
return /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
307
|
-
/* @__PURE__ */ t.jsx("div", { children: e == null ? void 0 : e.map((i, n, s) => /* @__PURE__ */ t.jsx(
|
|
308
|
-
xe,
|
|
309
|
-
{
|
|
310
|
-
item: i,
|
|
311
|
-
index: n,
|
|
312
|
-
onDelete: s.length > 1 ? () => {
|
|
313
|
-
l((c) => c + 1);
|
|
314
|
-
} : void 0
|
|
315
|
-
},
|
|
316
|
-
`${u}-${n}-${a}`
|
|
317
|
-
)) }),
|
|
318
|
-
/* @__PURE__ */ t.jsx("div", { className: "mt-6", children: /* @__PURE__ */ t.jsxs(
|
|
319
|
-
U,
|
|
320
|
-
{
|
|
321
|
-
size: "small",
|
|
322
|
-
variant: "secondary",
|
|
323
|
-
alignItems: "center",
|
|
324
|
-
onClick: () => {
|
|
325
|
-
r(
|
|
326
|
-
`rules.${u}.actions.${(e == null ? void 0 : e.length) ?? 0}`,
|
|
327
|
-
void 0
|
|
328
|
-
);
|
|
329
|
-
},
|
|
330
|
-
children: [
|
|
331
|
-
/* @__PURE__ */ t.jsx(p, { name: "plusCircle" }),
|
|
332
|
-
" Add action"
|
|
333
|
-
]
|
|
334
|
-
}
|
|
335
|
-
) })
|
|
336
|
-
] });
|
|
337
|
-
}
|
|
338
|
-
function Y(e) {
|
|
339
|
-
const [a, l] = x(void 0);
|
|
340
|
-
return N(() => {
|
|
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
|
-
});
|
|
346
|
-
}, [e == null ? void 0 : e.field]), { infos: a };
|
|
347
|
-
}
|
|
348
|
-
function B(e) {
|
|
349
|
-
if (typeof e == "string")
|
|
350
|
-
return T(q(e)) ? "datetime" : "string";
|
|
351
|
-
if (typeof e == "number")
|
|
352
|
-
return "integer";
|
|
353
|
-
if (typeof e == "boolean")
|
|
354
|
-
return "boolean";
|
|
355
|
-
if (Array.isArray(e)) {
|
|
356
|
-
if (typeof e[0] == "string")
|
|
357
|
-
return T(q(e[0])) ? "datetime" : "string";
|
|
358
|
-
if (typeof e[0] == "number")
|
|
359
|
-
return "integer";
|
|
360
|
-
}
|
|
361
|
-
return "string";
|
|
362
|
-
}
|
|
363
|
-
function be({
|
|
364
|
-
item: e,
|
|
365
|
-
pathPrefix: a
|
|
366
|
-
}) {
|
|
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
|
-
return u == null && (u = B(e == null ? void 0 : e.value)), /* @__PURE__ */ t.jsx(
|
|
371
|
-
j,
|
|
372
|
-
{
|
|
373
|
-
name: `${a}.matcher`,
|
|
374
|
-
value: e != null ? {
|
|
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
|
-
(e.matcher != null ? `⚠️ ${e.matcher}` : ""),
|
|
377
|
-
value: e.matcher
|
|
378
|
-
} : void 0,
|
|
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
|
-
) && l(`${a}.value`, null));
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
);
|
|
387
|
-
}
|
|
388
|
-
const O = [
|
|
389
|
-
{
|
|
390
|
-
/** Matches if field value equals provided value
|
|
391
|
-
* @field Integer, String, Datetime, Boolean
|
|
392
|
-
* @value Integer, String, Datetime, Boolean
|
|
393
|
-
*/
|
|
394
|
-
matcher: "eq",
|
|
395
|
-
label: "equals",
|
|
396
|
-
fieldTypes: ["integer", "string", "datetime", "boolean"]
|
|
397
|
-
},
|
|
398
|
-
{
|
|
399
|
-
/** Matches if field value is not equal to provided value
|
|
400
|
-
* @field Integer, String, Datetime, Boolean
|
|
401
|
-
* @value Integer, String, Datetime, Boolean
|
|
402
|
-
*/
|
|
403
|
-
matcher: "not_eq",
|
|
404
|
-
label: "not equals",
|
|
405
|
-
fieldTypes: ["integer", "string", "datetime", "boolean"]
|
|
406
|
-
},
|
|
407
|
-
{
|
|
408
|
-
/** Matches if field value is less than provided value
|
|
409
|
-
* @field Integer, Datetime
|
|
410
|
-
* @value Integer, Datetime
|
|
411
|
-
*/
|
|
412
|
-
matcher: "lt",
|
|
413
|
-
label: "<",
|
|
414
|
-
fieldTypes: ["integer", "datetime"]
|
|
415
|
-
},
|
|
416
|
-
{
|
|
417
|
-
/** Matches if field value is less than or equal to provided value
|
|
418
|
-
* @field Integer, Datetime
|
|
419
|
-
* @value Integer, Datetime
|
|
420
|
-
*/
|
|
421
|
-
matcher: "lteq",
|
|
422
|
-
label: "≤",
|
|
423
|
-
fieldTypes: ["integer", "datetime"]
|
|
424
|
-
},
|
|
425
|
-
{
|
|
426
|
-
/** Matches if field value is greater than provided value
|
|
427
|
-
* @field Integer, Datetime
|
|
428
|
-
* @value Integer, Datetime
|
|
429
|
-
*/
|
|
430
|
-
matcher: "gt",
|
|
431
|
-
label: ">",
|
|
432
|
-
fieldTypes: ["integer", "datetime"]
|
|
433
|
-
},
|
|
434
|
-
{
|
|
435
|
-
/** Matches if field value is greater than or equal to provided value
|
|
436
|
-
* @field Integer, Datetime
|
|
437
|
-
* @value Integer, Datetime
|
|
438
|
-
*/
|
|
439
|
-
matcher: "gteq",
|
|
440
|
-
label: "≥",
|
|
441
|
-
fieldTypes: ["integer", "datetime"]
|
|
442
|
-
},
|
|
443
|
-
{
|
|
444
|
-
/** Matches if field value is a multiple of provided value
|
|
445
|
-
* @field Integer
|
|
446
|
-
* @value Integer
|
|
447
|
-
*/
|
|
448
|
-
matcher: "multiple",
|
|
449
|
-
label: "is a multiple of",
|
|
450
|
-
fieldTypes: ["integer"]
|
|
451
|
-
},
|
|
452
|
-
{
|
|
453
|
-
/** Matches if field value matches regex pattern
|
|
454
|
-
* @field String
|
|
455
|
-
* @value String
|
|
456
|
-
*/
|
|
457
|
-
matcher: "matches",
|
|
458
|
-
label: "matches regex",
|
|
459
|
-
fieldTypes: ["string"]
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
/** Matches if field value does not match regex pattern
|
|
463
|
-
* @field String
|
|
464
|
-
* @value String
|
|
465
|
-
*/
|
|
466
|
-
matcher: "does_not_match",
|
|
467
|
-
label: "doesn't match regex",
|
|
468
|
-
fieldTypes: ["string"]
|
|
469
|
-
},
|
|
470
|
-
{
|
|
471
|
-
/** Matches if field value starts with provided string
|
|
472
|
-
* @field String
|
|
473
|
-
* @value String
|
|
474
|
-
*/
|
|
475
|
-
matcher: "start_with",
|
|
476
|
-
label: "starts with",
|
|
477
|
-
fieldTypes: ["string"]
|
|
478
|
-
},
|
|
479
|
-
{
|
|
480
|
-
/** Matches if field value does not start with provided string
|
|
481
|
-
* @field String
|
|
482
|
-
* @value String
|
|
483
|
-
*/
|
|
484
|
-
matcher: "not_start_with",
|
|
485
|
-
label: "doesn't start with",
|
|
486
|
-
fieldTypes: ["string"]
|
|
487
|
-
},
|
|
488
|
-
{
|
|
489
|
-
/** Matches if field value ends with provided string
|
|
490
|
-
* @field String
|
|
491
|
-
* @value String
|
|
492
|
-
*/
|
|
493
|
-
matcher: "end_with",
|
|
494
|
-
label: "ends with",
|
|
495
|
-
fieldTypes: ["string"]
|
|
496
|
-
},
|
|
497
|
-
{
|
|
498
|
-
/** Matches if field value does not end with provided string
|
|
499
|
-
* @field String
|
|
500
|
-
* @value String
|
|
501
|
-
*/
|
|
502
|
-
matcher: "not_end_with",
|
|
503
|
-
label: "doesn't end with",
|
|
504
|
-
fieldTypes: ["string"]
|
|
505
|
-
},
|
|
506
|
-
{
|
|
507
|
-
/** Matches if field value is between two values (exclusive)
|
|
508
|
-
* @field Integer, Datetime
|
|
509
|
-
* @value Array
|
|
510
|
-
*/
|
|
511
|
-
matcher: "gt_lt",
|
|
512
|
-
label: "> and <",
|
|
513
|
-
fieldTypes: ["integer"]
|
|
514
|
-
},
|
|
515
|
-
{
|
|
516
|
-
/** Matches if field value is between two values (inclusive start, exclusive end)
|
|
517
|
-
* @field Integer, Datetime
|
|
518
|
-
* @value Array
|
|
519
|
-
*/
|
|
520
|
-
matcher: "gteq_lt",
|
|
521
|
-
label: "≥ and <",
|
|
522
|
-
fieldTypes: ["integer"]
|
|
523
|
-
},
|
|
524
|
-
{
|
|
525
|
-
/** Matches if field value is greater than first and less than or equal to second
|
|
526
|
-
* @field Integer, Datetime
|
|
527
|
-
* @value Array
|
|
528
|
-
*/
|
|
529
|
-
matcher: "gt_lteq",
|
|
530
|
-
label: "> and ≤",
|
|
531
|
-
fieldTypes: ["integer"]
|
|
532
|
-
},
|
|
533
|
-
{
|
|
534
|
-
/** Matches if field value is between two values (inclusive)
|
|
535
|
-
* @field Integer, Datetime
|
|
536
|
-
* @value Array
|
|
537
|
-
*/
|
|
538
|
-
matcher: "gteq_lteq",
|
|
539
|
-
label: "≥ and ≤",
|
|
540
|
-
fieldTypes: ["integer"]
|
|
541
|
-
},
|
|
542
|
-
{
|
|
543
|
-
/** Matches if field value is between two values (exclusive)
|
|
544
|
-
* @field Integer, Datetime
|
|
545
|
-
* @value Array
|
|
546
|
-
*/
|
|
547
|
-
matcher: "gt_lt",
|
|
548
|
-
label: "date range",
|
|
549
|
-
visible: !1,
|
|
550
|
-
fieldTypes: ["datetime"]
|
|
551
|
-
},
|
|
552
|
-
{
|
|
553
|
-
/** Matches if field value is between two values (inclusive start, exclusive end)
|
|
554
|
-
* @field Integer, Datetime
|
|
555
|
-
* @value Array
|
|
556
|
-
*/
|
|
557
|
-
matcher: "gteq_lt",
|
|
558
|
-
label: "date range",
|
|
559
|
-
visible: !1,
|
|
560
|
-
fieldTypes: ["datetime"]
|
|
561
|
-
},
|
|
562
|
-
{
|
|
563
|
-
/** Matches if field value is greater than first and less than or equal to second
|
|
564
|
-
* @field Integer, Datetime
|
|
565
|
-
* @value Array
|
|
566
|
-
*/
|
|
567
|
-
matcher: "gt_lteq",
|
|
568
|
-
label: "date range",
|
|
569
|
-
visible: !1,
|
|
570
|
-
fieldTypes: ["datetime"]
|
|
571
|
-
},
|
|
572
|
-
{
|
|
573
|
-
/** Matches if field value is between two values (inclusive)
|
|
574
|
-
* @field Integer, Datetime
|
|
575
|
-
* @value Array
|
|
576
|
-
*/
|
|
577
|
-
matcher: "gteq_lteq",
|
|
578
|
-
label: "date range",
|
|
579
|
-
visible: !0,
|
|
580
|
-
fieldTypes: ["datetime"]
|
|
581
|
-
},
|
|
582
|
-
{
|
|
583
|
-
/** Matches if field value is in provided array
|
|
584
|
-
* @field Integer, String, Datetime
|
|
585
|
-
* @value Array
|
|
586
|
-
*/
|
|
587
|
-
matcher: "is_in",
|
|
588
|
-
label: "is one of",
|
|
589
|
-
fieldTypes: ["integer", "string", "datetime"]
|
|
590
|
-
},
|
|
591
|
-
{
|
|
592
|
-
/** Matches if field value is not in provided array
|
|
593
|
-
* @field Integer, String, Datetime
|
|
594
|
-
* @value Array
|
|
595
|
-
*/
|
|
596
|
-
matcher: "is_not_in",
|
|
597
|
-
label: "is not one of",
|
|
598
|
-
fieldTypes: ["integer", "string", "datetime"]
|
|
599
|
-
},
|
|
600
|
-
{
|
|
601
|
-
/** Matches objects within arrays that meet specified requirements
|
|
602
|
-
* @field Array
|
|
603
|
-
* @value Object
|
|
604
|
-
*/
|
|
605
|
-
matcher: "array_match",
|
|
606
|
-
label: "is",
|
|
607
|
-
fieldTypes: ["integer", "string", "datetime"]
|
|
608
|
-
},
|
|
609
|
-
{
|
|
610
|
-
/** Matches if field value is null or empty string */
|
|
611
|
-
matcher: "blank",
|
|
612
|
-
label: "is blank",
|
|
613
|
-
fieldTypes: ["integer", "string", "datetime", "boolean"]
|
|
614
|
-
},
|
|
615
|
-
{
|
|
616
|
-
/** Matches if field value is null */
|
|
617
|
-
matcher: "null",
|
|
618
|
-
label: "is null",
|
|
619
|
-
fieldTypes: ["integer", "string", "datetime", "boolean"]
|
|
620
|
-
},
|
|
621
|
-
{
|
|
622
|
-
/** Matches if field value is not null */
|
|
623
|
-
matcher: "not_null",
|
|
624
|
-
label: "is not null",
|
|
625
|
-
fieldTypes: ["integer", "string", "datetime", "boolean"]
|
|
626
|
-
},
|
|
627
|
-
{
|
|
628
|
-
/** Matches if field value is not null */
|
|
629
|
-
matcher: "present",
|
|
630
|
-
label: "is present",
|
|
631
|
-
fieldTypes: ["integer", "string", "datetime", "boolean"]
|
|
632
|
-
}
|
|
633
|
-
], F = {
|
|
634
|
-
in_and: {
|
|
635
|
-
label: "all of"
|
|
636
|
-
},
|
|
637
|
-
in_or: {
|
|
638
|
-
label: "at least one of"
|
|
639
|
-
},
|
|
640
|
-
not_in_and: {
|
|
641
|
-
label: "not any of"
|
|
642
|
-
},
|
|
643
|
-
not_in_or: {
|
|
644
|
-
label: "not at least one of"
|
|
645
|
-
}
|
|
646
|
-
};
|
|
647
|
-
function ye({
|
|
648
|
-
value: e,
|
|
649
|
-
pathPrefix: a
|
|
650
|
-
}) {
|
|
651
|
-
return (typeof e != "object" || Array.isArray(e) || e === null) && (e = {
|
|
652
|
-
in_and: []
|
|
653
|
-
}), /* @__PURE__ */ t.jsx("div", { children: Object.entries(e).map(([l, r], u) => /* @__PURE__ */ t.jsx(
|
|
654
|
-
ve,
|
|
655
|
-
{
|
|
656
|
-
pathPrefix: a,
|
|
657
|
-
defaultValue: r,
|
|
658
|
-
initialMatcher: l
|
|
659
|
-
},
|
|
660
|
-
`${a}.${u}`
|
|
661
|
-
)) });
|
|
662
|
-
}
|
|
663
|
-
function ve({
|
|
664
|
-
initialMatcher: e,
|
|
665
|
-
defaultValue: a,
|
|
666
|
-
pathPrefix: l
|
|
667
|
-
}) {
|
|
668
|
-
const [r, u] = x(e), [i, n] = x(e), [s, c] = x(a), { setPath: m } = y();
|
|
669
|
-
return N(() => {
|
|
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
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ t.jsx(
|
|
673
|
-
j,
|
|
674
|
-
{
|
|
675
|
-
defaultValue: [
|
|
676
|
-
{ value: i, label: F[i].label }
|
|
677
|
-
],
|
|
678
|
-
initialValues: Object.entries(F).map(
|
|
679
|
-
([o, { label: d }]) => ({
|
|
680
|
-
value: o,
|
|
681
|
-
label: d
|
|
682
|
-
})
|
|
683
|
-
),
|
|
684
|
-
onSelect: (o) => {
|
|
685
|
-
V(o) && n(o.value);
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
) }),
|
|
689
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ t.jsx(
|
|
690
|
-
j,
|
|
691
|
-
{
|
|
692
|
-
isMulti: !0,
|
|
693
|
-
isCreatable: !0,
|
|
694
|
-
defaultValue: (Array.isArray(s) ? s : []).map((o) => ({
|
|
695
|
-
value: o,
|
|
696
|
-
label: o.toString()
|
|
697
|
-
})),
|
|
698
|
-
initialValues: [],
|
|
699
|
-
onSelect: (o) => {
|
|
700
|
-
K(o) && c(
|
|
701
|
-
o.map(
|
|
702
|
-
(d) => typeof d.value == "boolean" ? d.value.toString() : d.value
|
|
703
|
-
)
|
|
704
|
-
);
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
) })
|
|
708
|
-
] });
|
|
709
|
-
}
|
|
710
|
-
function pe({
|
|
711
|
-
value: e,
|
|
712
|
-
onChange: a
|
|
713
|
-
}) {
|
|
714
|
-
const [l, r] = x(
|
|
715
|
-
Array.isArray(e) && typeof e[0] == "number" ? e[0] : null
|
|
716
|
-
), [u, i] = x(
|
|
717
|
-
Array.isArray(e) && typeof e[1] == "number" ? e[1] : null
|
|
718
|
-
);
|
|
719
|
-
return /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
720
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ t.jsx(
|
|
721
|
-
g,
|
|
722
|
-
{
|
|
723
|
-
type: "number",
|
|
724
|
-
placeholder: "Min",
|
|
725
|
-
value: l ?? "",
|
|
726
|
-
onChange: (n) => {
|
|
727
|
-
const s = parseInt(n.currentTarget.value, 10);
|
|
728
|
-
r(isNaN(s) ? null : s), a([isNaN(s) ? null : s, u]);
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
) }),
|
|
732
|
-
/* @__PURE__ */ t.jsx("span", { className: "text-gray-300", children: "to" }),
|
|
733
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ t.jsx(
|
|
734
|
-
g,
|
|
735
|
-
{
|
|
736
|
-
type: "number",
|
|
737
|
-
placeholder: "Max",
|
|
738
|
-
value: u ?? "",
|
|
739
|
-
onChange: (n) => {
|
|
740
|
-
const s = parseInt(n.currentTarget.value, 10);
|
|
741
|
-
i(isNaN(s) ? null : s), a([l, isNaN(s) ? null : s]);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
) })
|
|
745
|
-
] });
|
|
746
|
-
}
|
|
747
|
-
function je({
|
|
748
|
-
value: e,
|
|
749
|
-
onChange: a
|
|
750
|
-
}) {
|
|
751
|
-
const [l, r] = x(
|
|
752
|
-
Array.isArray(e) && typeof e[0] == "string" ? e[0] : null
|
|
753
|
-
), [u, i] = x(
|
|
754
|
-
Array.isArray(e) && typeof e[1] == "string" ? e[1] : null
|
|
755
|
-
);
|
|
756
|
-
return /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
757
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ t.jsx(
|
|
758
|
-
g,
|
|
759
|
-
{
|
|
760
|
-
type: "text",
|
|
761
|
-
placeholder: "Min",
|
|
762
|
-
value: l ?? "",
|
|
763
|
-
onChange: (n) => {
|
|
764
|
-
const s = n.currentTarget.value;
|
|
765
|
-
r(s), a([s, u]);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
) }),
|
|
769
|
-
/* @__PURE__ */ t.jsx("span", { className: "text-gray-300", children: "to" }),
|
|
770
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ t.jsx(
|
|
771
|
-
g,
|
|
772
|
-
{
|
|
773
|
-
type: "text",
|
|
774
|
-
placeholder: "Max",
|
|
775
|
-
value: u ?? "",
|
|
776
|
-
onChange: (n) => {
|
|
777
|
-
const s = n.currentTarget.value;
|
|
778
|
-
i(s), a([l, s]);
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
) })
|
|
782
|
-
] });
|
|
783
|
-
}
|
|
784
|
-
function Ne({
|
|
785
|
-
item: e,
|
|
786
|
-
pathPrefix: a
|
|
787
|
-
}) {
|
|
788
|
-
var m;
|
|
789
|
-
const { setPath: l } = y(), { infos: r } = Y(e), { user: u } = ee(), i = `${a}.value`;
|
|
790
|
-
if (e == null || X.includes(
|
|
791
|
-
e.matcher
|
|
792
|
-
))
|
|
793
|
-
return null;
|
|
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
|
-
case "datetime": {
|
|
802
|
-
c = "date";
|
|
803
|
-
break;
|
|
804
|
-
}
|
|
805
|
-
case "boolean": {
|
|
806
|
-
c = "boolean";
|
|
807
|
-
break;
|
|
808
|
-
}
|
|
809
|
-
case "string": {
|
|
810
|
-
c = "text";
|
|
811
|
-
break;
|
|
812
|
-
}
|
|
813
|
-
case "integer":
|
|
814
|
-
case "float": {
|
|
815
|
-
c = "number";
|
|
816
|
-
break;
|
|
817
|
-
}
|
|
818
|
-
case "array":
|
|
819
|
-
case "json":
|
|
820
|
-
case "object":
|
|
821
|
-
break;
|
|
822
|
-
default: {
|
|
823
|
-
c = "text";
|
|
824
|
-
break;
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
switch (n.matcher) {
|
|
828
|
-
case "eq":
|
|
829
|
-
case "not_eq":
|
|
830
|
-
case "lt":
|
|
831
|
-
case "lteq":
|
|
832
|
-
case "gt":
|
|
833
|
-
case "gteq":
|
|
834
|
-
case "multiple":
|
|
835
|
-
case "start_with":
|
|
836
|
-
case "not_start_with":
|
|
837
|
-
case "end_with":
|
|
838
|
-
case "not_end_with":
|
|
839
|
-
break;
|
|
840
|
-
case "matches":
|
|
841
|
-
case "does_not_match":
|
|
842
|
-
break;
|
|
843
|
-
case "gt_lt":
|
|
844
|
-
case "gteq_lt":
|
|
845
|
-
case "gt_lteq":
|
|
846
|
-
case "gteq_lteq": {
|
|
847
|
-
c === "number" && (c = "numberRange"), c === "text" && (c = "textRange"), c === "date" && (c = "dateRange");
|
|
848
|
-
break;
|
|
849
|
-
}
|
|
850
|
-
case "is_in":
|
|
851
|
-
case "is_not_in": {
|
|
852
|
-
c = "tag";
|
|
853
|
-
break;
|
|
854
|
-
}
|
|
855
|
-
case "array_match": {
|
|
856
|
-
c = "arrayMatch";
|
|
857
|
-
break;
|
|
858
|
-
}
|
|
859
|
-
default: {
|
|
860
|
-
R(n.matcher);
|
|
861
|
-
break;
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
switch (c) {
|
|
865
|
-
case "date": {
|
|
866
|
-
const o = A(
|
|
867
|
-
typeof n.value == "string" ? n.value : ""
|
|
868
|
-
);
|
|
869
|
-
return /* @__PURE__ */ t.jsx(
|
|
870
|
-
ae,
|
|
871
|
-
{
|
|
872
|
-
value: T(o) ? o : void 0,
|
|
873
|
-
showTimeSelect: !0,
|
|
874
|
-
placeholder: "Enter value",
|
|
875
|
-
onChange: (d) => {
|
|
876
|
-
l(i, d == null ? void 0 : d.toJSON());
|
|
877
|
-
},
|
|
878
|
-
timezone: u == null ? void 0 : u.timezone
|
|
879
|
-
}
|
|
880
|
-
);
|
|
881
|
-
}
|
|
882
|
-
case "dateRange": {
|
|
883
|
-
const o = Array.isArray(n.value) ? n.value.map((d) => {
|
|
884
|
-
const f = A(typeof d == "string" ? d : "");
|
|
885
|
-
return T(f) ? f : null;
|
|
886
|
-
}) : [null, null];
|
|
887
|
-
return /* @__PURE__ */ t.jsx(
|
|
888
|
-
te,
|
|
889
|
-
{
|
|
890
|
-
value: o,
|
|
891
|
-
showTimeSelect: !0,
|
|
892
|
-
onChange: (d) => {
|
|
893
|
-
l(
|
|
894
|
-
`${a}.value`,
|
|
895
|
-
d.map((f) => (f == null ? void 0 : f.toJSON()) ?? null)
|
|
896
|
-
);
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
);
|
|
900
|
-
}
|
|
901
|
-
case "numberRange":
|
|
902
|
-
return /* @__PURE__ */ t.jsx(
|
|
903
|
-
pe,
|
|
904
|
-
{
|
|
905
|
-
value: n.value,
|
|
906
|
-
onChange: (o) => {
|
|
907
|
-
l(i, o);
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
);
|
|
911
|
-
case "textRange":
|
|
912
|
-
return /* @__PURE__ */ t.jsx(
|
|
913
|
-
je,
|
|
914
|
-
{
|
|
915
|
-
value: n.value,
|
|
916
|
-
onChange: (o) => {
|
|
917
|
-
l(i, o);
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
);
|
|
921
|
-
case "arrayMatch":
|
|
922
|
-
return /* @__PURE__ */ t.jsx(
|
|
923
|
-
ye,
|
|
924
|
-
{
|
|
925
|
-
value: n.value,
|
|
926
|
-
pathPrefix: `${a}.value`
|
|
927
|
-
}
|
|
928
|
-
);
|
|
929
|
-
case "tag":
|
|
930
|
-
return /* @__PURE__ */ t.jsx(
|
|
931
|
-
j,
|
|
932
|
-
{
|
|
933
|
-
isMulti: !0,
|
|
934
|
-
isClearable: !1,
|
|
935
|
-
isCreatable: !0,
|
|
936
|
-
defaultValue: Array.isArray(n.value) ? n.value.map((o) => ({
|
|
937
|
-
label: o.toString(),
|
|
938
|
-
value: o
|
|
939
|
-
})) : [],
|
|
940
|
-
initialValues: [],
|
|
941
|
-
onSelect: (o) => {
|
|
942
|
-
K(o) && l(
|
|
943
|
-
`${a}.value`,
|
|
944
|
-
o.map((d) => {
|
|
945
|
-
if (s === "integer") {
|
|
946
|
-
const f = parseInt(d.value.toString(), 10);
|
|
947
|
-
return isNaN(f) ? null : f;
|
|
948
|
-
}
|
|
949
|
-
return d.value;
|
|
950
|
-
}).filter((d) => d != null)
|
|
951
|
-
);
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
);
|
|
955
|
-
case "number":
|
|
956
|
-
return /* @__PURE__ */ t.jsx(
|
|
957
|
-
g,
|
|
958
|
-
{
|
|
959
|
-
name: `${a}.value`,
|
|
960
|
-
type: "number",
|
|
961
|
-
defaultValue: typeof n.value == "number" ? n.value : "",
|
|
962
|
-
placeholder: "Enter value",
|
|
963
|
-
onChange: (o) => {
|
|
964
|
-
l(
|
|
965
|
-
`${a}.value`,
|
|
966
|
-
parseInt(o.currentTarget.value, 10)
|
|
967
|
-
);
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
);
|
|
971
|
-
case "boolean":
|
|
972
|
-
return /* @__PURE__ */ t.jsx(
|
|
973
|
-
j,
|
|
974
|
-
{
|
|
975
|
-
name: `${a}.value`,
|
|
976
|
-
defaultValue: typeof n.value == "boolean" ? {
|
|
977
|
-
label: n.value ? "Yes" : "No",
|
|
978
|
-
value: n.value
|
|
979
|
-
} : void 0,
|
|
980
|
-
initialValues: [
|
|
981
|
-
{ label: "Yes", value: !0 },
|
|
982
|
-
{ label: "No", value: !1 }
|
|
983
|
-
],
|
|
984
|
-
onSelect: (o) => {
|
|
985
|
-
V(o) && l(i, o.value);
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
);
|
|
989
|
-
case "text":
|
|
990
|
-
case null:
|
|
991
|
-
return /* @__PURE__ */ t.jsx(
|
|
992
|
-
g,
|
|
993
|
-
{
|
|
994
|
-
name: `${a}.value`,
|
|
995
|
-
type: "text",
|
|
996
|
-
defaultValue: typeof n.value == "string" ? n.value : JSON.stringify(n.value),
|
|
997
|
-
placeholder: "Enter value",
|
|
998
|
-
onChange: (o) => {
|
|
999
|
-
l(i, o.currentTarget.value);
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
);
|
|
1003
|
-
default:
|
|
1004
|
-
return R();
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
function _e({
|
|
1008
|
-
item: e,
|
|
1009
|
-
nestingLevel: a,
|
|
1010
|
-
pathPrefix: l,
|
|
1011
|
-
onDelete: r
|
|
1012
|
-
}) {
|
|
1013
|
-
const { setPath: u } = y(), i = [];
|
|
1014
|
-
return a < 2 && (i[0] ?? (i[0] = []), i[0].push(
|
|
1015
|
-
/* @__PURE__ */ t.jsx(
|
|
1016
|
-
S,
|
|
1017
|
-
{
|
|
1018
|
-
label: "Nest conditions",
|
|
1019
|
-
onClick: () => {
|
|
1020
|
-
var n;
|
|
1021
|
-
u(
|
|
1022
|
-
`${l}.nested.conditions.${(((n = e == null ? void 0 : e.nested) == null ? void 0 : n.conditions) ?? []).length}`,
|
|
1023
|
-
void 0
|
|
1024
|
-
);
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
)
|
|
1028
|
-
)), r != null && (i[1] ?? (i[1] = []), i[1].push(
|
|
1029
|
-
/* @__PURE__ */ t.jsx(
|
|
1030
|
-
S,
|
|
1031
|
-
{
|
|
1032
|
-
label: "Delete",
|
|
1033
|
-
onClick: () => {
|
|
1034
|
-
u(`${l}`, null), r();
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
)
|
|
1038
|
-
)), /* @__PURE__ */ t.jsxs("div", { className: "bg-gray-50 rounded-md flex items-center", children: [
|
|
1039
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex items-center justify-between gap-2 flex-grow p-2", children: /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col gap-2 flex-grow", children: [
|
|
1040
|
-
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1041
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex-1", children: /* @__PURE__ */ t.jsx(
|
|
1042
|
-
g,
|
|
1043
|
-
{
|
|
1044
|
-
name: `${l}.field`,
|
|
1045
|
-
type: "text",
|
|
1046
|
-
defaultValue: e != null ? e.field : void 0,
|
|
1047
|
-
onChange: (n) => {
|
|
1048
|
-
u(`${l}.field`, n.currentTarget.value);
|
|
1049
|
-
},
|
|
1050
|
-
onBlur: (n) => {
|
|
1051
|
-
u(`${l}.field`, n.currentTarget.value);
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
) }),
|
|
1055
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex-14", children: /* @__PURE__ */ t.jsx(be, { item: e, pathPrefix: l }) })
|
|
1056
|
-
] }),
|
|
1057
|
-
/* @__PURE__ */ t.jsx(Ne, { item: e, pathPrefix: l })
|
|
1058
|
-
] }) }),
|
|
1059
|
-
i.length > 0 && /* @__PURE__ */ t.jsx(
|
|
1060
|
-
J,
|
|
1061
|
-
{
|
|
1062
|
-
className: "w-8 border-l border-gray-100 flex items-center justify-center self-stretch",
|
|
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" }) }),
|
|
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))
|
|
1068
|
-
}
|
|
1069
|
-
)
|
|
1070
|
-
] });
|
|
1071
|
-
}
|
|
1072
|
-
function H({
|
|
1073
|
-
item: e,
|
|
1074
|
-
children: a,
|
|
1075
|
-
nestingLevel: l = 0,
|
|
1076
|
-
pathPrefix: r
|
|
1077
|
-
}) {
|
|
1078
|
-
var o, d;
|
|
1079
|
-
const {
|
|
1080
|
-
state: { selectedRuleIndex: u }
|
|
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;
|
|
1082
|
-
return /* @__PURE__ */ t.jsxs(
|
|
1083
|
-
"div",
|
|
1084
|
-
{
|
|
1085
|
-
className: $("query-group", {
|
|
1086
|
-
"p-4 border border-gray-200 rounded-md": m
|
|
1087
|
-
}),
|
|
1088
|
-
children: [
|
|
1089
|
-
a,
|
|
1090
|
-
e != null && (e.conditions ?? []).length > 0 && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
1091
|
-
/* @__PURE__ */ t.jsxs(
|
|
1092
|
-
"select",
|
|
1093
|
-
{
|
|
1094
|
-
onChange: (f) => {
|
|
1095
|
-
n(
|
|
1096
|
-
`${r}.conditions_logic`,
|
|
1097
|
-
f.currentTarget.value
|
|
1098
|
-
);
|
|
1099
|
-
},
|
|
1100
|
-
defaultValue: i,
|
|
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",
|
|
1102
|
-
children: [
|
|
1103
|
-
/* @__PURE__ */ t.jsxs("option", { value: "and", children: [
|
|
1104
|
-
m ? "Nested in " : "",
|
|
1105
|
-
"AND"
|
|
1106
|
-
] }),
|
|
1107
|
-
/* @__PURE__ */ t.jsxs("option", { value: "or", children: [
|
|
1108
|
-
m ? "Nested in " : "",
|
|
1109
|
-
"OR"
|
|
1110
|
-
] })
|
|
1111
|
-
]
|
|
1112
|
-
}
|
|
1113
|
-
),
|
|
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) => {
|
|
1115
|
-
const v = h === b.length - 1;
|
|
1116
|
-
return /* @__PURE__ */ t.jsxs(
|
|
1117
|
-
"div",
|
|
1118
|
-
{
|
|
1119
|
-
className: "flex items-center mb-4 last:mb-0 relative",
|
|
1120
|
-
children: [
|
|
1121
|
-
/* @__PURE__ */ t.jsx(we, { rounded: v }),
|
|
1122
|
-
/* @__PURE__ */ t.jsx("div", { className: "ml-4 w-full", children: /* @__PURE__ */ t.jsx(
|
|
1123
|
-
H,
|
|
1124
|
-
{
|
|
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`,
|
|
1128
|
-
children: /* @__PURE__ */ t.jsx(
|
|
1129
|
-
"div",
|
|
1130
|
-
{
|
|
1131
|
-
className: $({
|
|
1132
|
-
"mb-4": (f == null ? void 0 : f.nested) != null
|
|
1133
|
-
}),
|
|
1134
|
-
children: /* @__PURE__ */ t.jsx(
|
|
1135
|
-
_e,
|
|
1136
|
-
{
|
|
1137
|
-
item: f,
|
|
1138
|
-
nestingLevel: l,
|
|
1139
|
-
pathPrefix: `${r}.conditions.${h}`,
|
|
1140
|
-
onDelete: b.length > 1 || l > 0 ? () => {
|
|
1141
|
-
c((_) => _ + 1);
|
|
1142
|
-
} : void 0
|
|
1143
|
-
}
|
|
1144
|
-
)
|
|
1145
|
-
}
|
|
1146
|
-
)
|
|
1147
|
-
}
|
|
1148
|
-
) })
|
|
1149
|
-
]
|
|
1150
|
-
},
|
|
1151
|
-
`${u}-${h}-${s}`
|
|
1152
|
-
);
|
|
1153
|
-
}) })
|
|
1154
|
-
] })
|
|
1155
|
-
]
|
|
1156
|
-
}
|
|
1157
|
-
);
|
|
1158
|
-
}
|
|
1159
|
-
function we({
|
|
1160
|
-
rounded: e = !1
|
|
1161
|
-
}) {
|
|
1162
|
-
return e ? /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
1163
|
-
/* @__PURE__ */ t.jsx("div", { className: "absolute -left-[1px] top-1/2 w-px h-1/2 bg-white" }),
|
|
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" })
|
|
1165
|
-
] }) : /* @__PURE__ */ t.jsx("div", { className: "absolute left-0 top-1/2 -translate-y-1/2 w-3.5 h-px bg-gray-200" });
|
|
1166
|
-
}
|
|
1167
|
-
function Te() {
|
|
1168
|
-
var i;
|
|
1169
|
-
const {
|
|
1170
|
-
setPath: e,
|
|
1171
|
-
state: { value: a, selectedRuleIndex: l }
|
|
1172
|
-
} = y(), [r, u] = x(
|
|
1173
|
-
((i = a.rules[l]) == null ? void 0 : i.name) ?? ""
|
|
1174
|
-
);
|
|
1175
|
-
return N(() => {
|
|
1176
|
-
var n;
|
|
1177
|
-
u(((n = a.rules[l]) == null ? void 0 : n.name) ?? "");
|
|
1178
|
-
}, [l]), /* @__PURE__ */ t.jsx(
|
|
1179
|
-
"div",
|
|
1180
|
-
{
|
|
1181
|
-
contentEditable: "plaintext-only",
|
|
1182
|
-
suppressContentEditableWarning: !0,
|
|
1183
|
-
onInput: (n) => {
|
|
1184
|
-
const c = n.currentTarget.innerText.replace(/[\n\s]+/g, " ").trim();
|
|
1185
|
-
e(`rules.${l}.name`, c);
|
|
1186
|
-
},
|
|
1187
|
-
onKeyDown: (n) => {
|
|
1188
|
-
n.key === "Enter" && (n.preventDefault(), n.currentTarget.blur());
|
|
1189
|
-
},
|
|
1190
|
-
onBlur: (n) => {
|
|
1191
|
-
const s = n.currentTarget;
|
|
1192
|
-
s.innerText = s.innerText.replace(/[\n\s]+/g, " ").trim();
|
|
1193
|
-
},
|
|
1194
|
-
children: r
|
|
1195
|
-
},
|
|
1196
|
-
l
|
|
1197
|
-
);
|
|
1198
|
-
}
|
|
1199
|
-
const L = {
|
|
1200
|
-
rules: []
|
|
1201
|
-
}, C = (e) => {
|
|
1202
|
-
try {
|
|
1203
|
-
return JSON.parse(e ?? JSON.stringify(L));
|
|
1204
|
-
} catch {
|
|
1205
|
-
return L;
|
|
1206
|
-
}
|
|
1207
|
-
}, $e = (e) => {
|
|
1208
|
-
try {
|
|
1209
|
-
return JSON.parse(e ?? "{}"), !0;
|
|
1210
|
-
} catch {
|
|
1211
|
-
return !1;
|
|
1212
|
-
}
|
|
1213
|
-
};
|
|
1214
|
-
function qe(e) {
|
|
1215
|
-
const [a, l] = x(
|
|
1216
|
-
C(e.value ?? e.defaultValue)
|
|
1217
|
-
);
|
|
1218
|
-
return N(
|
|
1219
|
-
function() {
|
|
1220
|
-
a.rules.length === 0 && l(C(e.value));
|
|
1221
|
-
},
|
|
1222
|
-
[e.value]
|
|
1223
|
-
), /* @__PURE__ */ t.jsx(me, { initialValue: { rules: a.rules }, children: /* @__PURE__ */ t.jsx(Ce, { ...e }) });
|
|
1224
|
-
}
|
|
1225
|
-
function Ce(e) {
|
|
1226
|
-
const {
|
|
1227
|
-
state: { value: a, selectedRuleIndex: l },
|
|
1228
|
-
setSelectedRuleIndex: r,
|
|
1229
|
-
setValue: u,
|
|
1230
|
-
setPath: i
|
|
1231
|
-
} = y(), [n, s] = x(
|
|
1232
|
-
e.defaultCodeEditorVisible ?? !1
|
|
1233
|
-
), c = a.rules[l], m = oe(null), [o, d] = x(0);
|
|
1234
|
-
N(
|
|
1235
|
-
function() {
|
|
1236
|
-
var b, v, _;
|
|
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);
|
|
1238
|
-
},
|
|
1239
|
-
[a]
|
|
1240
|
-
);
|
|
1241
|
-
const f = w(
|
|
1242
|
-
(h) => {
|
|
1243
|
-
const b = C(h);
|
|
1244
|
-
m.current != null && m.current.hasTextFocus() && $e(h) && !E(b, a) && (u(b), d((v) => v + 1));
|
|
1245
|
-
},
|
|
1246
|
-
[a]
|
|
1247
|
-
);
|
|
1248
|
-
return /* @__PURE__ */ t.jsx(
|
|
1249
|
-
ne,
|
|
1250
|
-
{
|
|
1251
|
-
hint: e.hint,
|
|
1252
|
-
feedback: e.feedback,
|
|
1253
|
-
className: "h-full [&>div:first-of-type]:h-full",
|
|
1254
|
-
children: /* @__PURE__ */ t.jsxs("section", { className: "flex h-full", children: [
|
|
1255
|
-
/* @__PURE__ */ t.jsxs(
|
|
1256
|
-
"div",
|
|
1257
|
-
{
|
|
1258
|
-
className: `shrink-0 basis-3/5 overflow-x-auto relative flex flex-col ${n ? "" : "grow"}`,
|
|
1259
|
-
children: [
|
|
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: [
|
|
1261
|
-
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-4 flex-wrap", children: [
|
|
1262
|
-
a.rules.map((h, b) => {
|
|
1263
|
-
const v = `#${(b + 1).toString().padStart(2, "0")}`;
|
|
1264
|
-
return /* @__PURE__ */ t.jsx(
|
|
1265
|
-
"button",
|
|
1266
|
-
{
|
|
1267
|
-
className: $("font-bold", {
|
|
1268
|
-
"text-black": l === b
|
|
1269
|
-
}),
|
|
1270
|
-
onClick: () => {
|
|
1271
|
-
r(b);
|
|
1272
|
-
},
|
|
1273
|
-
children: v
|
|
1274
|
-
},
|
|
1275
|
-
`${l}-${h.id}`
|
|
1276
|
-
);
|
|
1277
|
-
}),
|
|
1278
|
-
/* @__PURE__ */ t.jsx(
|
|
1279
|
-
"button",
|
|
1280
|
-
{
|
|
1281
|
-
className: $("font-bold", {
|
|
1282
|
-
"text-black": !0
|
|
1283
|
-
}),
|
|
1284
|
-
onClick: () => {
|
|
1285
|
-
i(`rules.${a.rules.length}`, {
|
|
1286
|
-
name: "Rule name",
|
|
1287
|
-
actions: [null],
|
|
1288
|
-
conditions: [null]
|
|
1289
|
-
}), r(a.rules.length);
|
|
1290
|
-
},
|
|
1291
|
-
children: /* @__PURE__ */ t.jsx(p, { name: "plus", size: 16, className: "shrink-0" })
|
|
1292
|
-
}
|
|
1293
|
-
)
|
|
1294
|
-
] }),
|
|
1295
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex-grow flex justify-end", children: /* @__PURE__ */ t.jsx(
|
|
1296
|
-
"button",
|
|
1297
|
-
{
|
|
1298
|
-
className: "text-blue-600 hover:text-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500",
|
|
1299
|
-
onClick: () => {
|
|
1300
|
-
s(!n);
|
|
1301
|
-
},
|
|
1302
|
-
children: /* @__PURE__ */ t.jsx(p, { name: "sidebarSimple", size: 16, color: "#101111" })
|
|
1303
|
-
}
|
|
1304
|
-
) })
|
|
1305
|
-
] }),
|
|
1306
|
-
/* @__PURE__ */ t.jsxs(Ee, { children: [
|
|
1307
|
-
/* @__PURE__ */ t.jsxs("div", { className: "mb-8 flex items-center gap-2", children: [
|
|
1308
|
-
/* @__PURE__ */ t.jsx(Te, {}),
|
|
1309
|
-
/* @__PURE__ */ t.jsx(p, { name: "pencilSimple", size: 16, className: "shrink-0" })
|
|
1310
|
-
] }),
|
|
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: [
|
|
1314
|
-
/* @__PURE__ */ t.jsx(
|
|
1315
|
-
H,
|
|
1316
|
-
{
|
|
1317
|
-
item: c,
|
|
1318
|
-
pathPrefix: `rules.${l}`
|
|
1319
|
-
}
|
|
1320
|
-
),
|
|
1321
|
-
/* @__PURE__ */ t.jsx("div", { className: "mt-6", children: /* @__PURE__ */ t.jsxs(
|
|
1322
|
-
U,
|
|
1323
|
-
{
|
|
1324
|
-
size: "small",
|
|
1325
|
-
variant: "secondary",
|
|
1326
|
-
alignItems: "center",
|
|
1327
|
-
onClick: () => {
|
|
1328
|
-
var h;
|
|
1329
|
-
i(
|
|
1330
|
-
`rules.${l}.conditions.${((h = c == null ? void 0 : c.conditions) == null ? void 0 : h.length) ?? 0}`,
|
|
1331
|
-
void 0
|
|
1332
|
-
);
|
|
1333
|
-
},
|
|
1334
|
-
children: [
|
|
1335
|
-
/* @__PURE__ */ t.jsx(p, { name: "plusCircle" }),
|
|
1336
|
-
" Add condition"
|
|
1337
|
-
]
|
|
1338
|
-
}
|
|
1339
|
-
) })
|
|
1340
|
-
] })
|
|
1341
|
-
] })
|
|
1342
|
-
]
|
|
1343
|
-
},
|
|
1344
|
-
o
|
|
1345
|
-
),
|
|
1346
|
-
n && /* @__PURE__ */ t.jsx("div", { className: "shrink-0 basis-2/5", children: /* @__PURE__ */ t.jsx(
|
|
1347
|
-
se,
|
|
1348
|
-
{
|
|
1349
|
-
ref: m,
|
|
1350
|
-
name: e.id ?? e.name,
|
|
1351
|
-
height: "100%",
|
|
1352
|
-
language: "json",
|
|
1353
|
-
jsonSchema: "order-rules",
|
|
1354
|
-
defaultValue: JSON.stringify(a, null, 2),
|
|
1355
|
-
noRounding: !0,
|
|
1356
|
-
onChange: f
|
|
1357
|
-
}
|
|
1358
|
-
) })
|
|
1359
|
-
] })
|
|
1360
|
-
}
|
|
1361
|
-
);
|
|
1362
|
-
}
|
|
1363
|
-
function Ve({ children: e }) {
|
|
1364
|
-
return /* @__PURE__ */ t.jsxs("div", { className: "text-gray-500 flex items-center justify-center flex-col", children: [
|
|
1365
|
-
/* @__PURE__ */ t.jsx("div", { className: "h-6 w-[2px] bg-gray-200" }),
|
|
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 }),
|
|
1367
|
-
/* @__PURE__ */ t.jsx("div", { className: "h-6 w-[2px] bg-gray-200" })
|
|
1368
|
-
] });
|
|
1369
|
-
}
|
|
1370
|
-
function z({
|
|
1371
|
-
children: e,
|
|
1372
|
-
title: a,
|
|
1373
|
-
icon: l
|
|
1374
|
-
}) {
|
|
1375
|
-
return /* @__PURE__ */ t.jsxs("div", { className: "rounded-md bg-white shadow-sm", children: [
|
|
1376
|
-
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center space-x-4 py-4 border-b border-gray-100", children: [
|
|
1377
|
-
/* @__PURE__ */ t.jsx("div", { className: "w-8 h-8 -ml-4 bg-white rounded-full border border-gray-200 flex items-center justify-center shadow-sm shadow-primary-200", children: /* @__PURE__ */ t.jsx(p, { name: l }) }),
|
|
1378
|
-
/* @__PURE__ */ t.jsx("h2", { className: "text-lg font-semibold", children: a })
|
|
1379
|
-
] }),
|
|
1380
|
-
/* @__PURE__ */ t.jsx("div", { className: "p-6", children: e })
|
|
1381
|
-
] });
|
|
1382
|
-
}
|
|
1383
|
-
function Ee({
|
|
1384
|
-
children: e
|
|
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 }) });
|
|
1387
|
-
}
|
|
1388
|
-
export {
|
|
1389
|
-
qe as RuleEngine
|
|
1390
|
-
};
|