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