@sparrowengg/integrations-templates-frontend 2.1.0-notion-release.18 → 2.1.0-notion-release.19
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/cjs/_virtual/index8.js +2 -2
- package/dist/cjs/_virtual/index9.js +2 -2
- package/dist/cjs/cascader-dropdown/cascader-dropdown-content.js +5 -4
- package/dist/cjs/cascader-dropdown/cascader-dropdown-content.js.map +1 -1
- package/dist/cjs/commons/components/MappingCondtion/conditionWrapper.js +612 -0
- package/dist/cjs/commons/components/MappingCondtion/conditionWrapper.js.map +1 -0
- package/dist/cjs/commons/components/MappingCondtion/index.js +118 -0
- package/dist/cjs/commons/components/MappingCondtion/index.js.map +1 -0
- package/dist/cjs/commons/constants/index.js.map +1 -1
- package/dist/cjs/commons/helpers/index.js +0 -1
- package/dist/cjs/commons/helpers/index.js.map +1 -1
- package/dist/cjs/dynamic-mapping/components/Mapping.js +1 -2
- package/dist/cjs/dynamic-mapping/components/Mapping.js.map +1 -1
- package/dist/cjs/dynamic-mapping/index.js +13 -3
- package/dist/cjs/dynamic-mapping/index.js.map +1 -1
- package/dist/cjs/mapping/components/field.js +1 -1
- package/dist/cjs/mapping/components/field.js.map +1 -1
- package/dist/cjs/mapping/components/mapping.js +37 -16
- package/dist/cjs/mapping/components/mapping.js.map +1 -1
- package/dist/cjs/node_modules/@sparrowengg/twigs-react/dist/es/dialog/dialog.js +2 -0
- package/dist/cjs/node_modules/@sparrowengg/twigs-react/dist/es/dialog/dialog.js.map +1 -1
- package/dist/cjs/node_modules/@sparrowengg/twigs-react/dist/es/node_modules/@radix-ui/react-menu/dist/index.js +7 -7
- package/dist/cjs/node_modules/hoist-non-react-statics/node_modules/react-is/index.js +1 -1
- package/dist/cjs/node_modules/style-to-js/cjs/index.js +1 -1
- package/dist/cjs/node_modules/style-to-object/cjs/index.js +1 -1
- package/dist/cjs/popover/popover.js +3 -1
- package/dist/cjs/popover/popover.js.map +1 -1
- package/dist/es/_virtual/index8.js +2 -2
- package/dist/es/_virtual/index9.js +2 -2
- package/dist/es/cascader-dropdown/cascader-dropdown-content.js +6 -5
- package/dist/es/cascader-dropdown/cascader-dropdown-content.js.map +1 -1
- package/dist/es/commons/components/MappingCondtion/conditionWrapper.js +608 -0
- package/dist/es/commons/components/MappingCondtion/conditionWrapper.js.map +1 -0
- package/dist/es/commons/components/MappingCondtion/index.js +114 -0
- package/dist/es/commons/components/MappingCondtion/index.js.map +1 -0
- package/dist/es/commons/constants/index.js.map +1 -1
- package/dist/es/commons/helpers/index.js +0 -1
- package/dist/es/commons/helpers/index.js.map +1 -1
- package/dist/es/dynamic-mapping/components/Mapping.js +1 -2
- package/dist/es/dynamic-mapping/components/Mapping.js.map +1 -1
- package/dist/es/dynamic-mapping/index.js +13 -3
- package/dist/es/dynamic-mapping/index.js.map +1 -1
- package/dist/es/mapping/components/field.js +1 -1
- package/dist/es/mapping/components/field.js.map +1 -1
- package/dist/es/mapping/components/mapping.js +26 -5
- package/dist/es/mapping/components/mapping.js.map +1 -1
- package/dist/es/node_modules/@sparrowengg/twigs-react/dist/es/dialog/dialog.js +3 -2
- package/dist/es/node_modules/@sparrowengg/twigs-react/dist/es/dialog/dialog.js.map +1 -1
- package/dist/es/node_modules/@sparrowengg/twigs-react/dist/es/dropdown/dropdown.js +2 -2
- package/dist/es/node_modules/@sparrowengg/twigs-react/dist/es/node_modules/@radix-ui/react-dropdown-menu/dist/index.js +1 -1
- package/dist/es/node_modules/hoist-non-react-statics/node_modules/react-is/index.js +1 -1
- package/dist/es/node_modules/style-to-js/cjs/index.js +1 -1
- package/dist/es/node_modules/style-to-object/cjs/index.js +1 -1
- package/dist/es/popover/popover.js +4 -3
- package/dist/es/popover/popover.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/package.json +1 -1
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var cascaderDropdown = require('../../../cascader-dropdown/cascader-dropdown.js');
|
|
7
|
+
var cascaderDropdownConstants = require('../../../cascader-dropdown/helpers/cascader-dropdown-constants.js');
|
|
8
|
+
var StyledItem = require('../../../cascader-dropdown/styled/StyledItem.js');
|
|
9
|
+
var filterPill = require('../../../filter/filter-pill.js');
|
|
10
|
+
var tooltip = require('../../../node_modules/@sparrowengg/twigs-react/dist/es/tooltip/tooltip.js');
|
|
11
|
+
var flex = require('../../../node_modules/@sparrowengg/twigs-react/dist/es/flex/flex.js');
|
|
12
|
+
var box = require('../../../node_modules/@sparrowengg/twigs-react/dist/es/box/box.js');
|
|
13
|
+
var text = require('../../../node_modules/@sparrowengg/twigs-react/dist/es/text/text.js');
|
|
14
|
+
var dropdown = require('../../../node_modules/@sparrowengg/twigs-react/dist/es/dropdown/dropdown.js');
|
|
15
|
+
var button = require('../../../node_modules/@sparrowengg/twigs-react/dist/es/button/button.js');
|
|
16
|
+
var chevronDown = require('../../../node_modules/@sparrowengg/twigs-react-icons/dist/es/icons/chevron-down.js');
|
|
17
|
+
var iconButton = require('../../../node_modules/@sparrowengg/twigs-react/dist/es/button/icon-button.js');
|
|
18
|
+
var _delete = require('../../../node_modules/@sparrowengg/twigs-react-icons/dist/es/icons/delete.js');
|
|
19
|
+
var plus = require('../../../node_modules/@sparrowengg/twigs-react-icons/dist/es/icons/plus.js');
|
|
20
|
+
|
|
21
|
+
var __defProp = Object.defineProperty;
|
|
22
|
+
var __defProps = Object.defineProperties;
|
|
23
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
24
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
25
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
26
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
27
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
28
|
+
var __spreadValues = (a, b) => {
|
|
29
|
+
for (var prop in b || (b = {}))
|
|
30
|
+
if (__hasOwnProp.call(b, prop))
|
|
31
|
+
__defNormalProp(a, prop, b[prop]);
|
|
32
|
+
if (__getOwnPropSymbols)
|
|
33
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
34
|
+
if (__propIsEnum.call(b, prop))
|
|
35
|
+
__defNormalProp(a, prop, b[prop]);
|
|
36
|
+
}
|
|
37
|
+
return a;
|
|
38
|
+
};
|
|
39
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
40
|
+
const SurveyIcon = () => {
|
|
41
|
+
return /* @__PURE__ */ React.createElement(
|
|
42
|
+
"svg",
|
|
43
|
+
{
|
|
44
|
+
width: "20",
|
|
45
|
+
height: "20",
|
|
46
|
+
viewBox: "0 0 20 20",
|
|
47
|
+
fill: "none",
|
|
48
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
49
|
+
},
|
|
50
|
+
/* @__PURE__ */ React.createElement(
|
|
51
|
+
"path",
|
|
52
|
+
{
|
|
53
|
+
d: "M7.5 3.75H5.625C4.58947 3.75 3.75 4.58947 3.75 5.625V15.625C3.75 16.6605 4.58947 17.5 5.625 17.5H14.375C15.4105 17.5 16.25 16.6605 16.25 15.625V5.625C16.25 4.58947 15.4105 3.75 14.375 3.75H12.5M7.5 3.75C7.5 4.44036 8.05964 5 8.75 5H11.25C11.9404 5 12.5 4.44036 12.5 3.75M7.5 3.75C7.5 3.05964 8.05964 2.5 8.75 2.5H11.25C11.9404 2.5 12.5 3.05964 12.5 3.75M9.36498 8.80859L7.91023 10.1926L6.87164 9.25765M9.36498 12.5586L7.91023 13.9426L6.87164 13.0077M11.875 9.375H13.125M11.875 13.125H13.125",
|
|
54
|
+
stroke: "#6A6A6A",
|
|
55
|
+
strokeWidth: "1.5",
|
|
56
|
+
strokeLinecap: "round"
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
const ContactPropertyIcon = () => {
|
|
62
|
+
return /* @__PURE__ */ React.createElement(
|
|
63
|
+
"svg",
|
|
64
|
+
{
|
|
65
|
+
width: "16",
|
|
66
|
+
height: "16",
|
|
67
|
+
viewBox: "0 0 16 16",
|
|
68
|
+
fill: "none",
|
|
69
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
70
|
+
},
|
|
71
|
+
/* @__PURE__ */ React.createElement(
|
|
72
|
+
"path",
|
|
73
|
+
{
|
|
74
|
+
d: "M12.4379 13.5662C11.9487 12.074 10.6519 10.6642 9.32857 10.6644H6.69988C5.87888 10.6643 5.08868 11.0437 4.49002 11.7256C4.14406 12.1194 3.87379 12.6009 3.69843 13.1357L3.55654 13.5662M4.66293 13.9976H11.3318C12.804 13.9976 13.9974 12.8042 13.9974 11.332V4.66311C13.9974 3.19097 12.804 1.99756 11.3318 1.99756H4.66293C3.19079 1.99756 1.99738 3.19097 1.99738 4.66311V11.332C1.99738 12.8041 3.19078 13.9976 4.66293 13.9976ZM7.99738 8.61347C7.15264 8.61347 6.46784 7.92867 6.46784 7.08393V6.82017C6.46784 5.97543 7.15264 5.29063 7.99738 5.29063C8.84212 5.29063 9.52691 5.97543 9.52691 6.82017V7.08393C9.52691 7.92867 8.84212 8.61347 7.99738 8.61347Z",
|
|
75
|
+
stroke: "#575757",
|
|
76
|
+
strokeWidth: "1.2",
|
|
77
|
+
strokeLinecap: "round",
|
|
78
|
+
strokeLinejoin: "round"
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
const VariablesIcon = () => {
|
|
84
|
+
return /* @__PURE__ */ React.createElement(
|
|
85
|
+
"svg",
|
|
86
|
+
{
|
|
87
|
+
width: "16",
|
|
88
|
+
height: "16",
|
|
89
|
+
viewBox: "0 0 16 16",
|
|
90
|
+
fill: "none",
|
|
91
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
92
|
+
},
|
|
93
|
+
/* @__PURE__ */ React.createElement(
|
|
94
|
+
"path",
|
|
95
|
+
{
|
|
96
|
+
d: "M8 3V1.5M8 12.3633V13.8633M5.39767 11.0591C5.58659 11.3837 5.85679 11.6536 6.18171 11.8422C6.50663 12.0308 6.87508 12.1317 7.25084 12.1349H8.89487C9.40877 12.1345 9.90479 11.9464 10.2896 11.606C10.6744 11.2657 10.9214 10.7965 10.9842 10.2869C11.047 9.77721 10.9212 9.2622 10.6305 8.83876C10.3398 8.41533 9.90419 8.11266 9.40573 7.98774L6.59427 7.282C6.09581 7.15707 5.66024 6.85441 5.36952 6.43097C5.07881 6.00754 4.953 5.49253 5.01579 4.98287C5.07857 4.47322 5.32561 4.00407 5.71041 3.66372C6.09521 3.32336 6.59123 3.13528 7.10513 3.13487H8.74916C9.1242 3.13747 9.49211 3.23754 9.81672 3.42525C10.1413 3.61296 10.4115 3.88184 10.6006 4.20547",
|
|
97
|
+
stroke: "#575757",
|
|
98
|
+
strokeWidth: "1.2",
|
|
99
|
+
strokeLinecap: "round",
|
|
100
|
+
strokeLinejoin: "round"
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
const connectorOptionsMap = {
|
|
106
|
+
AND: "and",
|
|
107
|
+
OR: "or"
|
|
108
|
+
};
|
|
109
|
+
const connectorOptions = Object.keys(connectorOptionsMap).map((key) => ({
|
|
110
|
+
label: connectorOptionsMap[key],
|
|
111
|
+
value: key
|
|
112
|
+
}));
|
|
113
|
+
const allAnyOptionsMap = {
|
|
114
|
+
ALL: "all",
|
|
115
|
+
ANY: "any"
|
|
116
|
+
};
|
|
117
|
+
const allAnyOptions = Object.keys(allAnyOptionsMap).map((key) => ({
|
|
118
|
+
label: allAnyOptionsMap[key],
|
|
119
|
+
value: key
|
|
120
|
+
}));
|
|
121
|
+
const PillIconMap = {
|
|
122
|
+
contactProperties: ContactPropertyIcon,
|
|
123
|
+
variables: VariablesIcon,
|
|
124
|
+
surveys: SurveyIcon
|
|
125
|
+
};
|
|
126
|
+
const ConditionWrapper = React.forwardRef(({ existingContions, setExistingCondtions, onConditionsChange, conditionData }, ref) => {
|
|
127
|
+
const [conditionsData, setConditionsData] = React.useState({
|
|
128
|
+
globalConnector: "ALL",
|
|
129
|
+
filterGroups: []
|
|
130
|
+
});
|
|
131
|
+
const [showError, setShowError] = React.useState(/* @__PURE__ */ new Set());
|
|
132
|
+
const updateFilters = (group, filterPillValue, filterIndex) => {
|
|
133
|
+
const newFilters = group.filters.map((loopFilter, loopFilterIndex) => {
|
|
134
|
+
if (loopFilterIndex === filterIndex)
|
|
135
|
+
return filterPillValue;
|
|
136
|
+
return loopFilter;
|
|
137
|
+
});
|
|
138
|
+
return __spreadProps(__spreadValues({}, group), {
|
|
139
|
+
filters: newFilters
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
const replaceFilterPillData = (filterPillValue, groupIndex, filterIndex) => {
|
|
143
|
+
setShowError((prev) => {
|
|
144
|
+
prev.delete(
|
|
145
|
+
`${filterPillValue.property.value}-${groupIndex}-${filterIndex}`
|
|
146
|
+
);
|
|
147
|
+
return prev;
|
|
148
|
+
});
|
|
149
|
+
setConditionsData((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
150
|
+
filterGroups: prev.filterGroups.map((loopGroup, loopGroupIndex) => {
|
|
151
|
+
if (loopGroupIndex !== groupIndex)
|
|
152
|
+
return loopGroup;
|
|
153
|
+
return updateFilters(loopGroup, filterPillValue, filterIndex);
|
|
154
|
+
})
|
|
155
|
+
}));
|
|
156
|
+
};
|
|
157
|
+
const addCondition = (selectedProperty) => {
|
|
158
|
+
setShowError(/* @__PURE__ */ new Set());
|
|
159
|
+
if (!selectedProperty)
|
|
160
|
+
return;
|
|
161
|
+
setConditionsData((prev) => {
|
|
162
|
+
const newData = __spreadProps(__spreadValues({}, prev), {
|
|
163
|
+
filterGroups: [
|
|
164
|
+
...prev.filterGroups,
|
|
165
|
+
{
|
|
166
|
+
filters: [
|
|
167
|
+
{
|
|
168
|
+
comparator: "AND",
|
|
169
|
+
property: selectedProperty,
|
|
170
|
+
value: cascaderDropdownConstants.initialFilterValueSelectorValue
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
});
|
|
176
|
+
onConditionsChange(newData.filterGroups.length);
|
|
177
|
+
return newData;
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
const insertCondition = (selectedProperty, groupIndex, filterIndex) => {
|
|
181
|
+
setShowError(/* @__PURE__ */ new Set());
|
|
182
|
+
setConditionsData((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
183
|
+
filterGroups: [
|
|
184
|
+
...prev.filterGroups.slice(0, groupIndex),
|
|
185
|
+
{
|
|
186
|
+
filters: [
|
|
187
|
+
...prev.filterGroups[groupIndex].filters.slice(0, filterIndex + 1),
|
|
188
|
+
{
|
|
189
|
+
comparator: "AND",
|
|
190
|
+
property: selectedProperty,
|
|
191
|
+
value: cascaderDropdownConstants.initialFilterValueSelectorValue
|
|
192
|
+
},
|
|
193
|
+
...prev.filterGroups[groupIndex].filters.slice(filterIndex + 1)
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
...prev.filterGroups.slice(groupIndex + 1)
|
|
197
|
+
]
|
|
198
|
+
}));
|
|
199
|
+
};
|
|
200
|
+
const filterConditions = (group, filterIndex) => {
|
|
201
|
+
return __spreadProps(__spreadValues({}, group), {
|
|
202
|
+
filters: group.filters.filter(
|
|
203
|
+
(_, loopFilterIndex) => loopFilterIndex !== filterIndex
|
|
204
|
+
)
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
const deleteCondition = (groupIndex, filterIndex) => {
|
|
208
|
+
setShowError(/* @__PURE__ */ new Set());
|
|
209
|
+
setConditionsData((prev) => {
|
|
210
|
+
const updatedGroup = filterConditions(
|
|
211
|
+
prev.filterGroups[groupIndex],
|
|
212
|
+
filterIndex
|
|
213
|
+
);
|
|
214
|
+
let newData;
|
|
215
|
+
if (updatedGroup.filters.length === 0) {
|
|
216
|
+
newData = __spreadProps(__spreadValues({}, prev), {
|
|
217
|
+
filterGroups: prev.filterGroups.filter(
|
|
218
|
+
(_, loopGroupIndex) => loopGroupIndex !== groupIndex
|
|
219
|
+
)
|
|
220
|
+
});
|
|
221
|
+
} else {
|
|
222
|
+
newData = __spreadProps(__spreadValues({}, prev), {
|
|
223
|
+
filterGroups: prev.filterGroups.map((group, loopGroupIndex) => {
|
|
224
|
+
if (loopGroupIndex !== groupIndex)
|
|
225
|
+
return group;
|
|
226
|
+
return updatedGroup;
|
|
227
|
+
})
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
onConditionsChange(newData.filterGroups.length);
|
|
231
|
+
return newData;
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
const deleteGroup = (groupIndex) => {
|
|
235
|
+
setShowError(/* @__PURE__ */ new Set());
|
|
236
|
+
setConditionsData((prev) => {
|
|
237
|
+
const newData = __spreadProps(__spreadValues({}, prev), {
|
|
238
|
+
filterGroups: prev.filterGroups.filter(
|
|
239
|
+
(_, loopGroupIndex) => loopGroupIndex !== groupIndex
|
|
240
|
+
)
|
|
241
|
+
});
|
|
242
|
+
onConditionsChange(newData.filterGroups.length);
|
|
243
|
+
return newData;
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
const onGlobalConnectorChange = (value) => {
|
|
247
|
+
setConditionsData((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
248
|
+
globalConnector: value
|
|
249
|
+
}));
|
|
250
|
+
};
|
|
251
|
+
const updateFilterInGroup = (group, filterIndex, newComparator) => {
|
|
252
|
+
return __spreadProps(__spreadValues({}, group), {
|
|
253
|
+
filters: group.filters.map((filter, loopFilterIndex) => {
|
|
254
|
+
if (loopFilterIndex !== filterIndex)
|
|
255
|
+
return filter;
|
|
256
|
+
return __spreadProps(__spreadValues({}, filter), {
|
|
257
|
+
comparator: newComparator
|
|
258
|
+
});
|
|
259
|
+
})
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
const onComparatorChange = (value, groupIndex, filterIndex) => {
|
|
263
|
+
setConditionsData((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
264
|
+
filterGroups: prev.filterGroups.map((group, loopGroupIndex) => {
|
|
265
|
+
if (loopGroupIndex !== groupIndex)
|
|
266
|
+
return group;
|
|
267
|
+
return updateFilterInGroup(group, filterIndex, value);
|
|
268
|
+
})
|
|
269
|
+
}));
|
|
270
|
+
};
|
|
271
|
+
const handleSave = () => {
|
|
272
|
+
setExistingCondtions(conditionsData);
|
|
273
|
+
console.log(conditionsData);
|
|
274
|
+
const errorSet = /* @__PURE__ */ new Set();
|
|
275
|
+
conditionsData.filterGroups.forEach((group, groupIndex) => {
|
|
276
|
+
group.filters.forEach((filter, filterIndex) => {
|
|
277
|
+
if (!filter.connector || !filter.value[filter.connector.dataType]) {
|
|
278
|
+
errorSet.add(`${filter.property.value}-${groupIndex}-${filterIndex}`);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
setShowError(errorSet);
|
|
283
|
+
};
|
|
284
|
+
React.useImperativeHandle(ref, () => ({
|
|
285
|
+
handleSave
|
|
286
|
+
}));
|
|
287
|
+
React.useEffect(() => {
|
|
288
|
+
var _a;
|
|
289
|
+
if (existingContions) {
|
|
290
|
+
setConditionsData(existingContions);
|
|
291
|
+
onConditionsChange(((_a = existingContions.filterGroups) == null ? void 0 : _a.length) || 0);
|
|
292
|
+
}
|
|
293
|
+
}, [existingContions, onConditionsChange]);
|
|
294
|
+
return /* @__PURE__ */ React.createElement(tooltip.TooltipProvider, null, /* @__PURE__ */ React.createElement(
|
|
295
|
+
flex.Flex,
|
|
296
|
+
{
|
|
297
|
+
alignItems: "center",
|
|
298
|
+
gap: "$2",
|
|
299
|
+
css: {
|
|
300
|
+
width: "100%",
|
|
301
|
+
".twigs-cascader-dropdown": {
|
|
302
|
+
zIndex: "999999 !important"
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
/* @__PURE__ */ React.createElement(box.Box, { css: { margin: "0 0 $6 0", width: "100%" } }, /* @__PURE__ */ React.createElement(flex.Flex, null, /* @__PURE__ */ React.createElement(text.Text, { size: "md", css: { color: "$neutral900" } }, "Which meet", /* @__PURE__ */ React.createElement(box.Box, { as: "span", css: { display: "inline-block", margin: "0 $2" } }, /* @__PURE__ */ React.createElement(dropdown.DropdownMenu, { size: "sm" }, /* @__PURE__ */ React.createElement(dropdown.DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(
|
|
307
|
+
button.Button,
|
|
308
|
+
{
|
|
309
|
+
rightIcon: /* @__PURE__ */ React.createElement(chevronDown.ChevronDownIcon, null),
|
|
310
|
+
size: "sm",
|
|
311
|
+
variant: "ghost",
|
|
312
|
+
color: "default",
|
|
313
|
+
css: {
|
|
314
|
+
"& span": {
|
|
315
|
+
fontFamily: "DM Sans !important"
|
|
316
|
+
},
|
|
317
|
+
height: "$7",
|
|
318
|
+
paddingRight: "0",
|
|
319
|
+
fontWeight: "$7"
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
allAnyOptionsMap[conditionsData.globalConnector]
|
|
323
|
+
)), /* @__PURE__ */ React.createElement(
|
|
324
|
+
dropdown.DropdownMenuContent,
|
|
325
|
+
{
|
|
326
|
+
align: "start",
|
|
327
|
+
css: { zIndex: "1000", minWidth: "100px" }
|
|
328
|
+
},
|
|
329
|
+
allAnyOptions.map((option) => /* @__PURE__ */ React.createElement(
|
|
330
|
+
dropdown.DropdownMenuItem,
|
|
331
|
+
{
|
|
332
|
+
onClick: () => onGlobalConnectorChange(option.value),
|
|
333
|
+
key: option.value,
|
|
334
|
+
css: __spreadValues({
|
|
335
|
+
cursor: "pointer"
|
|
336
|
+
}, conditionsData.globalConnector === option.value && {
|
|
337
|
+
"&, &:hover": {
|
|
338
|
+
backgroundColorOpacity: ["$primary200", 0.08]
|
|
339
|
+
}
|
|
340
|
+
})
|
|
341
|
+
},
|
|
342
|
+
option.label
|
|
343
|
+
))
|
|
344
|
+
))), "of these conditions:")), /* @__PURE__ */ React.createElement(flex.Flex, { flexDirection: "column", gap: "$1", css: { maxWidth: "600px" } }, conditionsData.filterGroups.map((group, groupIndex) => (
|
|
345
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
346
|
+
/* @__PURE__ */ React.createElement(Group, { key: groupIndex }, /* @__PURE__ */ React.createElement(GroupTitle, { onDelete: () => deleteGroup(groupIndex) }, "When"), group.filters.map((filter, filterIndex) => {
|
|
347
|
+
var _a, _b, _c, _d, _e, _f;
|
|
348
|
+
const selectedRootProperty = (_b = (_a = filter.property.selectionPath) == null ? void 0 : _a[0]) == null ? void 0 : _b.value;
|
|
349
|
+
const Icon = PillIconMap[selectedRootProperty];
|
|
350
|
+
const key = `${(_d = (_c = filter.property.operators) == null ? void 0 : _c[0]) == null ? void 0 : _d.value}-${groupIndex}-${filterIndex}`;
|
|
351
|
+
return /* @__PURE__ */ React.createElement(
|
|
352
|
+
flex.Flex,
|
|
353
|
+
{
|
|
354
|
+
key: filter.property.value,
|
|
355
|
+
alignItems: "center",
|
|
356
|
+
gap: "$1",
|
|
357
|
+
css: {
|
|
358
|
+
"&:hover, &:focus, &:active, &:focus-visible": {
|
|
359
|
+
[`.${StyledItem.prefixClassName("add-condition-in-group-button")}`]: {
|
|
360
|
+
opacity: "1"
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
filterIndex > 0 && /* @__PURE__ */ React.createElement(
|
|
366
|
+
ComparatorDropdown,
|
|
367
|
+
{
|
|
368
|
+
filter,
|
|
369
|
+
onComparatorChange: (value) => onComparatorChange(value, groupIndex, filterIndex)
|
|
370
|
+
}
|
|
371
|
+
),
|
|
372
|
+
((_e = filter.property.operators) == null ? void 0 : _e.length) === 1 ? /* @__PURE__ */ React.createElement(
|
|
373
|
+
filterPill.FilterPillWithoutOperator,
|
|
374
|
+
{
|
|
375
|
+
key,
|
|
376
|
+
data: filter.property.operators[0],
|
|
377
|
+
filterPillData: conditionsData.filterGroups[groupIndex].filters[filterIndex],
|
|
378
|
+
setFilterPillData: (filterPillValue) => replaceFilterPillData(
|
|
379
|
+
filterPillValue,
|
|
380
|
+
groupIndex,
|
|
381
|
+
filterIndex
|
|
382
|
+
),
|
|
383
|
+
icon: Icon && /* @__PURE__ */ React.createElement(Icon, null),
|
|
384
|
+
onDelete: () => deleteCondition(groupIndex, filterIndex),
|
|
385
|
+
variant: "outline",
|
|
386
|
+
showError: showError.has(
|
|
387
|
+
`${filter.property.value}-${groupIndex}-${filterIndex}`
|
|
388
|
+
)
|
|
389
|
+
}
|
|
390
|
+
) : /* @__PURE__ */ React.createElement(
|
|
391
|
+
filterPill.FilterPill,
|
|
392
|
+
{
|
|
393
|
+
key,
|
|
394
|
+
cascaderDropdownData: (_f = filter.property.operators) != null ? _f : [],
|
|
395
|
+
filterPillData: conditionsData.filterGroups[groupIndex].filters[filterIndex],
|
|
396
|
+
setFilterPillData: (filterPillValue) => replaceFilterPillData(
|
|
397
|
+
filterPillValue,
|
|
398
|
+
groupIndex,
|
|
399
|
+
filterIndex
|
|
400
|
+
),
|
|
401
|
+
onDelete: () => deleteCondition(groupIndex, filterIndex),
|
|
402
|
+
variant: "outline",
|
|
403
|
+
icon: Icon && /* @__PURE__ */ React.createElement(Icon, null),
|
|
404
|
+
showError: showError.has(
|
|
405
|
+
`${filter.property.value}-${groupIndex}-${filterIndex}`
|
|
406
|
+
)
|
|
407
|
+
}
|
|
408
|
+
),
|
|
409
|
+
/* @__PURE__ */ React.createElement(
|
|
410
|
+
AddConditionInGroupButton,
|
|
411
|
+
{
|
|
412
|
+
conditionData,
|
|
413
|
+
insertCondition: (selectedProperty) => insertCondition(
|
|
414
|
+
selectedProperty,
|
|
415
|
+
groupIndex,
|
|
416
|
+
filterIndex
|
|
417
|
+
)
|
|
418
|
+
}
|
|
419
|
+
)
|
|
420
|
+
);
|
|
421
|
+
}))
|
|
422
|
+
)), /* @__PURE__ */ React.createElement(flex.Flex, { alignItems: "center", gap: "$4", css: { marginTop: "$6", marginLeft: "-$2" } }, /* @__PURE__ */ React.createElement(
|
|
423
|
+
AddConditionButton,
|
|
424
|
+
{
|
|
425
|
+
conditionData,
|
|
426
|
+
onAdd: (selectedProperty) => {
|
|
427
|
+
addCondition(selectedProperty);
|
|
428
|
+
}
|
|
429
|
+
},
|
|
430
|
+
/* @__PURE__ */ React.createElement(
|
|
431
|
+
button.Button,
|
|
432
|
+
{
|
|
433
|
+
leftIcon: /* @__PURE__ */ React.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React.createElement("path", { d: "M2.05371 3H13.2504M2.05371 6.5H13.2504M2.05371 10H6.75038M11.0004 14.3333V9.66667M13.3337 12H8.66705", stroke: "#64748B", "stroke-width": "1.2", "stroke-linecap": "round", "stroke-linejoin": "round" })),
|
|
434
|
+
color: "secondary",
|
|
435
|
+
variant: "ghost",
|
|
436
|
+
css: {
|
|
437
|
+
height: "auto",
|
|
438
|
+
minWidth: "fit-content",
|
|
439
|
+
"& span": {
|
|
440
|
+
fontFamily: "DM Sans !important"
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
"Add group"
|
|
445
|
+
)
|
|
446
|
+
), /* @__PURE__ */ React.createElement(
|
|
447
|
+
box.Box,
|
|
448
|
+
{
|
|
449
|
+
css: {
|
|
450
|
+
width: "100%",
|
|
451
|
+
borderBottom: "2px dashed $secondary100"
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
))))
|
|
455
|
+
));
|
|
456
|
+
});
|
|
457
|
+
ConditionWrapper.displayName = "ConditionWrapper";
|
|
458
|
+
const Group = ({ children }) => {
|
|
459
|
+
return /* @__PURE__ */ React.createElement(flex.Flex, { css: { padding: "$4 0" }, flexDirection: "column", gap: "$2" }, children);
|
|
460
|
+
};
|
|
461
|
+
const GroupTitle = ({
|
|
462
|
+
children,
|
|
463
|
+
onDelete
|
|
464
|
+
}) => {
|
|
465
|
+
return /* @__PURE__ */ React.createElement(
|
|
466
|
+
flex.Flex,
|
|
467
|
+
{
|
|
468
|
+
alignItems: "center",
|
|
469
|
+
justifyContent: "space-between",
|
|
470
|
+
css: { padding: "$1 0" },
|
|
471
|
+
gap: "$2"
|
|
472
|
+
},
|
|
473
|
+
/* @__PURE__ */ React.createElement(text.Text, { weight: "bold", css: { color: "$secondary900" } }, children),
|
|
474
|
+
/* @__PURE__ */ React.createElement(
|
|
475
|
+
box.Box,
|
|
476
|
+
{
|
|
477
|
+
css: {
|
|
478
|
+
height: "1px",
|
|
479
|
+
width: "100%",
|
|
480
|
+
backgroundColor: "$black100",
|
|
481
|
+
flex: "1"
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
),
|
|
485
|
+
/* @__PURE__ */ React.createElement(tooltip.Tooltip, { content: "Remove Group", css: { zIndex: "99999" } }, /* @__PURE__ */ React.createElement(
|
|
486
|
+
iconButton.IconButton,
|
|
487
|
+
{
|
|
488
|
+
css: { height: "$5", width: "$5" },
|
|
489
|
+
variant: "ghost",
|
|
490
|
+
color: "default",
|
|
491
|
+
icon: /* @__PURE__ */ React.createElement(_delete.DeleteIcon, null),
|
|
492
|
+
onClick: onDelete
|
|
493
|
+
}
|
|
494
|
+
))
|
|
495
|
+
);
|
|
496
|
+
};
|
|
497
|
+
const AddConditionButton = ({
|
|
498
|
+
conditionData,
|
|
499
|
+
children,
|
|
500
|
+
onAdd,
|
|
501
|
+
dropdownContentProps,
|
|
502
|
+
tooltipProps
|
|
503
|
+
}) => {
|
|
504
|
+
const onChange = ({
|
|
505
|
+
selectedProperty,
|
|
506
|
+
selectionPath
|
|
507
|
+
}) => {
|
|
508
|
+
if (!(selectedProperty == null ? void 0 : selectedProperty.label) || !(selectedProperty == null ? void 0 : selectedProperty.value))
|
|
509
|
+
return;
|
|
510
|
+
onAdd(__spreadProps(__spreadValues({}, selectedProperty), { selectionPath }));
|
|
511
|
+
};
|
|
512
|
+
return /* @__PURE__ */ React.createElement(
|
|
513
|
+
cascaderDropdown.CascaderDropdown,
|
|
514
|
+
{
|
|
515
|
+
data: conditionData,
|
|
516
|
+
dropdownContentProps: __spreadValues({ align: "start" }, dropdownContentProps),
|
|
517
|
+
onChange,
|
|
518
|
+
tooltipProps
|
|
519
|
+
},
|
|
520
|
+
children
|
|
521
|
+
);
|
|
522
|
+
};
|
|
523
|
+
const ComparatorDropdown = ({
|
|
524
|
+
filter,
|
|
525
|
+
onComparatorChange
|
|
526
|
+
}) => {
|
|
527
|
+
return /* @__PURE__ */ React.createElement(dropdown.DropdownMenu, { size: "sm" }, /* @__PURE__ */ React.createElement(dropdown.DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(
|
|
528
|
+
button.Button,
|
|
529
|
+
{
|
|
530
|
+
rightIcon: /* @__PURE__ */ React.createElement(chevronDown.ChevronDownIcon, null),
|
|
531
|
+
size: "sm",
|
|
532
|
+
variant: "ghost",
|
|
533
|
+
color: "default",
|
|
534
|
+
css: {
|
|
535
|
+
height: "$7",
|
|
536
|
+
fontWeight: "$4",
|
|
537
|
+
color: "$neutral800",
|
|
538
|
+
paddingRight: "$1",
|
|
539
|
+
paddingLeft: "$2"
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
connectorOptionsMap[filter.comparator]
|
|
543
|
+
)), /* @__PURE__ */ React.createElement(
|
|
544
|
+
dropdown.DropdownMenuContent,
|
|
545
|
+
{
|
|
546
|
+
align: "start",
|
|
547
|
+
css: { zIndex: "1000", minWidth: "100px" }
|
|
548
|
+
},
|
|
549
|
+
connectorOptions.map((option) => /* @__PURE__ */ React.createElement(
|
|
550
|
+
dropdown.DropdownMenuItem,
|
|
551
|
+
{
|
|
552
|
+
key: option.value,
|
|
553
|
+
onClick: () => onComparatorChange(option.value),
|
|
554
|
+
css: __spreadValues({
|
|
555
|
+
cursor: "pointer"
|
|
556
|
+
}, filter.comparator === option.value && {
|
|
557
|
+
"&, &:hover": {
|
|
558
|
+
backgroundColorOpacity: ["$primary200", 0.08]
|
|
559
|
+
}
|
|
560
|
+
})
|
|
561
|
+
},
|
|
562
|
+
option.label
|
|
563
|
+
))
|
|
564
|
+
));
|
|
565
|
+
};
|
|
566
|
+
const AddConditionInGroupButton = ({
|
|
567
|
+
conditionData,
|
|
568
|
+
insertCondition
|
|
569
|
+
}) => {
|
|
570
|
+
const handleAddCondition = (selectedProperty) => {
|
|
571
|
+
if (!selectedProperty)
|
|
572
|
+
return;
|
|
573
|
+
insertCondition(selectedProperty);
|
|
574
|
+
};
|
|
575
|
+
return /* @__PURE__ */ React.createElement(
|
|
576
|
+
AddConditionButton,
|
|
577
|
+
{
|
|
578
|
+
conditionData,
|
|
579
|
+
onAdd: handleAddCondition,
|
|
580
|
+
tooltipProps: {
|
|
581
|
+
content: "Add condition",
|
|
582
|
+
side: "right",
|
|
583
|
+
css: { zIndex: "99999" }
|
|
584
|
+
}
|
|
585
|
+
},
|
|
586
|
+
/* @__PURE__ */ React.createElement(
|
|
587
|
+
iconButton.IconButton,
|
|
588
|
+
{
|
|
589
|
+
className: StyledItem.prefixClassName("add-condition-in-group-button"),
|
|
590
|
+
size: "md",
|
|
591
|
+
css: {
|
|
592
|
+
height: "$6",
|
|
593
|
+
width: "$6",
|
|
594
|
+
borderRadius: "$sm",
|
|
595
|
+
border: "1px dashed $black300",
|
|
596
|
+
opacity: "0",
|
|
597
|
+
transition: "opacity 0.2s ease-in-out",
|
|
598
|
+
marginLeft: "$3",
|
|
599
|
+
"&:hover, &:focus, &:active, &:focus-visible": {
|
|
600
|
+
opacity: 1
|
|
601
|
+
}
|
|
602
|
+
},
|
|
603
|
+
icon: /* @__PURE__ */ React.createElement(plus.PlusIcon, null),
|
|
604
|
+
color: "default",
|
|
605
|
+
variant: "ghost"
|
|
606
|
+
}
|
|
607
|
+
)
|
|
608
|
+
);
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
exports.default = ConditionWrapper;
|
|
612
|
+
//# sourceMappingURL=conditionWrapper.js.map
|