@sparrowengg/integrations-templates-frontend 2.1.0-notion-release.18 → 2.1.0-notion-release.20

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.
Files changed (65) hide show
  1. package/dist/cjs/_virtual/index8.js +2 -2
  2. package/dist/cjs/_virtual/index9.js +2 -2
  3. package/dist/cjs/cascader-dropdown/cascader-dropdown-content.js +5 -4
  4. package/dist/cjs/cascader-dropdown/cascader-dropdown-content.js.map +1 -1
  5. package/dist/cjs/commons/components/MappingCondtion/conditionWrapper.js +612 -0
  6. package/dist/cjs/commons/components/MappingCondtion/conditionWrapper.js.map +1 -0
  7. package/dist/cjs/commons/components/MappingCondtion/index.js +154 -0
  8. package/dist/cjs/commons/components/MappingCondtion/index.js.map +1 -0
  9. package/dist/cjs/commons/constants/index.js.map +1 -1
  10. package/dist/cjs/commons/helpers/index.js +0 -1
  11. package/dist/cjs/commons/helpers/index.js.map +1 -1
  12. package/dist/cjs/dynamic-mapping/components/Mapping.js +1 -2
  13. package/dist/cjs/dynamic-mapping/components/Mapping.js.map +1 -1
  14. package/dist/cjs/dynamic-mapping/index.js +13 -3
  15. package/dist/cjs/dynamic-mapping/index.js.map +1 -1
  16. package/dist/cjs/integration-template/components/dashboard.js +52 -9
  17. package/dist/cjs/integration-template/components/dashboard.js.map +1 -1
  18. package/dist/cjs/mapping/components/field.js +1 -1
  19. package/dist/cjs/mapping/components/field.js.map +1 -1
  20. package/dist/cjs/mapping/components/mapping.js +71 -24
  21. package/dist/cjs/mapping/components/mapping.js.map +1 -1
  22. package/dist/cjs/mapping/utils/conditionDescriptionBuilder.js +200 -0
  23. package/dist/cjs/mapping/utils/conditionDescriptionBuilder.js.map +1 -0
  24. package/dist/cjs/node_modules/@sparrowengg/twigs-react/dist/es/dialog/dialog.js +2 -0
  25. package/dist/cjs/node_modules/@sparrowengg/twigs-react/dist/es/dialog/dialog.js.map +1 -1
  26. package/dist/cjs/node_modules/@sparrowengg/twigs-react/dist/es/node_modules/@radix-ui/react-menu/dist/index.js +7 -7
  27. package/dist/cjs/node_modules/hoist-non-react-statics/node_modules/react-is/index.js +1 -1
  28. package/dist/cjs/node_modules/style-to-js/cjs/index.js +1 -1
  29. package/dist/cjs/node_modules/style-to-object/cjs/index.js +1 -1
  30. package/dist/cjs/popover/popover.js +3 -1
  31. package/dist/cjs/popover/popover.js.map +1 -1
  32. package/dist/es/_virtual/index8.js +2 -2
  33. package/dist/es/_virtual/index9.js +2 -2
  34. package/dist/es/cascader-dropdown/cascader-dropdown-content.js +6 -5
  35. package/dist/es/cascader-dropdown/cascader-dropdown-content.js.map +1 -1
  36. package/dist/es/commons/components/MappingCondtion/conditionWrapper.js +608 -0
  37. package/dist/es/commons/components/MappingCondtion/conditionWrapper.js.map +1 -0
  38. package/dist/es/commons/components/MappingCondtion/index.js +150 -0
  39. package/dist/es/commons/components/MappingCondtion/index.js.map +1 -0
  40. package/dist/es/commons/constants/index.js.map +1 -1
  41. package/dist/es/commons/helpers/index.js +0 -1
  42. package/dist/es/commons/helpers/index.js.map +1 -1
  43. package/dist/es/dynamic-mapping/components/Mapping.js +1 -2
  44. package/dist/es/dynamic-mapping/components/Mapping.js.map +1 -1
  45. package/dist/es/dynamic-mapping/index.js +13 -3
  46. package/dist/es/dynamic-mapping/index.js.map +1 -1
  47. package/dist/es/integration-template/components/dashboard.js +52 -9
  48. package/dist/es/integration-template/components/dashboard.js.map +1 -1
  49. package/dist/es/mapping/components/field.js +1 -1
  50. package/dist/es/mapping/components/field.js.map +1 -1
  51. package/dist/es/mapping/components/mapping.js +60 -13
  52. package/dist/es/mapping/components/mapping.js.map +1 -1
  53. package/dist/es/mapping/utils/conditionDescriptionBuilder.js +198 -0
  54. package/dist/es/mapping/utils/conditionDescriptionBuilder.js.map +1 -0
  55. package/dist/es/node_modules/@sparrowengg/twigs-react/dist/es/dialog/dialog.js +3 -2
  56. package/dist/es/node_modules/@sparrowengg/twigs-react/dist/es/dialog/dialog.js.map +1 -1
  57. package/dist/es/node_modules/@sparrowengg/twigs-react/dist/es/dropdown/dropdown.js +2 -2
  58. package/dist/es/node_modules/@sparrowengg/twigs-react/dist/es/node_modules/@radix-ui/react-dropdown-menu/dist/index.js +1 -1
  59. package/dist/es/node_modules/hoist-non-react-statics/node_modules/react-is/index.js +1 -1
  60. package/dist/es/node_modules/style-to-js/cjs/index.js +1 -1
  61. package/dist/es/node_modules/style-to-object/cjs/index.js +1 -1
  62. package/dist/es/popover/popover.js +4 -3
  63. package/dist/es/popover/popover.js.map +1 -1
  64. package/dist/index.d.ts +6 -1
  65. package/package.json +1 -1
@@ -0,0 +1,608 @@
1
+ import React__default, { useState, useImperativeHandle, useEffect } from 'react';
2
+ import { CascaderDropdown } from '../../../cascader-dropdown/cascader-dropdown.js';
3
+ import { initialFilterValueSelectorValue } from '../../../cascader-dropdown/helpers/cascader-dropdown-constants.js';
4
+ import { prefixClassName } from '../../../cascader-dropdown/styled/StyledItem.js';
5
+ import { FilterPillWithoutOperator, FilterPill } from '../../../filter/filter-pill.js';
6
+ import { TooltipProvider, Tooltip } from '../../../node_modules/@sparrowengg/twigs-react/dist/es/tooltip/tooltip.js';
7
+ import { Flex } from '../../../node_modules/@sparrowengg/twigs-react/dist/es/flex/flex.js';
8
+ import { Box } from '../../../node_modules/@sparrowengg/twigs-react/dist/es/box/box.js';
9
+ import { Text } from '../../../node_modules/@sparrowengg/twigs-react/dist/es/text/text.js';
10
+ import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '../../../node_modules/@sparrowengg/twigs-react/dist/es/dropdown/dropdown.js';
11
+ import { Button } from '../../../node_modules/@sparrowengg/twigs-react/dist/es/button/button.js';
12
+ import { ChevronDownIcon } from '../../../node_modules/@sparrowengg/twigs-react-icons/dist/es/icons/chevron-down.js';
13
+ import { IconButton } from '../../../node_modules/@sparrowengg/twigs-react/dist/es/button/icon-button.js';
14
+ import { DeleteIcon } from '../../../node_modules/@sparrowengg/twigs-react-icons/dist/es/icons/delete.js';
15
+ import { PlusIcon } from '../../../node_modules/@sparrowengg/twigs-react-icons/dist/es/icons/plus.js';
16
+
17
+ var __defProp = Object.defineProperty;
18
+ var __defProps = Object.defineProperties;
19
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
20
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
21
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
22
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
23
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
24
+ var __spreadValues = (a, b) => {
25
+ for (var prop in b || (b = {}))
26
+ if (__hasOwnProp.call(b, prop))
27
+ __defNormalProp(a, prop, b[prop]);
28
+ if (__getOwnPropSymbols)
29
+ for (var prop of __getOwnPropSymbols(b)) {
30
+ if (__propIsEnum.call(b, prop))
31
+ __defNormalProp(a, prop, b[prop]);
32
+ }
33
+ return a;
34
+ };
35
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
36
+ const SurveyIcon = () => {
37
+ return /* @__PURE__ */ React__default.createElement(
38
+ "svg",
39
+ {
40
+ width: "20",
41
+ height: "20",
42
+ viewBox: "0 0 20 20",
43
+ fill: "none",
44
+ xmlns: "http://www.w3.org/2000/svg"
45
+ },
46
+ /* @__PURE__ */ React__default.createElement(
47
+ "path",
48
+ {
49
+ 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",
50
+ stroke: "#6A6A6A",
51
+ strokeWidth: "1.5",
52
+ strokeLinecap: "round"
53
+ }
54
+ )
55
+ );
56
+ };
57
+ const ContactPropertyIcon = () => {
58
+ return /* @__PURE__ */ React__default.createElement(
59
+ "svg",
60
+ {
61
+ width: "16",
62
+ height: "16",
63
+ viewBox: "0 0 16 16",
64
+ fill: "none",
65
+ xmlns: "http://www.w3.org/2000/svg"
66
+ },
67
+ /* @__PURE__ */ React__default.createElement(
68
+ "path",
69
+ {
70
+ 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",
71
+ stroke: "#575757",
72
+ strokeWidth: "1.2",
73
+ strokeLinecap: "round",
74
+ strokeLinejoin: "round"
75
+ }
76
+ )
77
+ );
78
+ };
79
+ const VariablesIcon = () => {
80
+ return /* @__PURE__ */ React__default.createElement(
81
+ "svg",
82
+ {
83
+ width: "16",
84
+ height: "16",
85
+ viewBox: "0 0 16 16",
86
+ fill: "none",
87
+ xmlns: "http://www.w3.org/2000/svg"
88
+ },
89
+ /* @__PURE__ */ React__default.createElement(
90
+ "path",
91
+ {
92
+ 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",
93
+ stroke: "#575757",
94
+ strokeWidth: "1.2",
95
+ strokeLinecap: "round",
96
+ strokeLinejoin: "round"
97
+ }
98
+ )
99
+ );
100
+ };
101
+ const connectorOptionsMap = {
102
+ AND: "and",
103
+ OR: "or"
104
+ };
105
+ const connectorOptions = Object.keys(connectorOptionsMap).map((key) => ({
106
+ label: connectorOptionsMap[key],
107
+ value: key
108
+ }));
109
+ const allAnyOptionsMap = {
110
+ ALL: "all",
111
+ ANY: "any"
112
+ };
113
+ const allAnyOptions = Object.keys(allAnyOptionsMap).map((key) => ({
114
+ label: allAnyOptionsMap[key],
115
+ value: key
116
+ }));
117
+ const PillIconMap = {
118
+ contactProperties: ContactPropertyIcon,
119
+ variables: VariablesIcon,
120
+ surveys: SurveyIcon
121
+ };
122
+ const ConditionWrapper = React__default.forwardRef(({ existingContions, setExistingCondtions, onConditionsChange, conditionData }, ref) => {
123
+ const [conditionsData, setConditionsData] = useState({
124
+ globalConnector: "ALL",
125
+ filterGroups: []
126
+ });
127
+ const [showError, setShowError] = useState(/* @__PURE__ */ new Set());
128
+ const updateFilters = (group, filterPillValue, filterIndex) => {
129
+ const newFilters = group.filters.map((loopFilter, loopFilterIndex) => {
130
+ if (loopFilterIndex === filterIndex)
131
+ return filterPillValue;
132
+ return loopFilter;
133
+ });
134
+ return __spreadProps(__spreadValues({}, group), {
135
+ filters: newFilters
136
+ });
137
+ };
138
+ const replaceFilterPillData = (filterPillValue, groupIndex, filterIndex) => {
139
+ setShowError((prev) => {
140
+ prev.delete(
141
+ `${filterPillValue.property.value}-${groupIndex}-${filterIndex}`
142
+ );
143
+ return prev;
144
+ });
145
+ setConditionsData((prev) => __spreadProps(__spreadValues({}, prev), {
146
+ filterGroups: prev.filterGroups.map((loopGroup, loopGroupIndex) => {
147
+ if (loopGroupIndex !== groupIndex)
148
+ return loopGroup;
149
+ return updateFilters(loopGroup, filterPillValue, filterIndex);
150
+ })
151
+ }));
152
+ };
153
+ const addCondition = (selectedProperty) => {
154
+ setShowError(/* @__PURE__ */ new Set());
155
+ if (!selectedProperty)
156
+ return;
157
+ setConditionsData((prev) => {
158
+ const newData = __spreadProps(__spreadValues({}, prev), {
159
+ filterGroups: [
160
+ ...prev.filterGroups,
161
+ {
162
+ filters: [
163
+ {
164
+ comparator: "AND",
165
+ property: selectedProperty,
166
+ value: initialFilterValueSelectorValue
167
+ }
168
+ ]
169
+ }
170
+ ]
171
+ });
172
+ onConditionsChange(newData.filterGroups.length);
173
+ return newData;
174
+ });
175
+ };
176
+ const insertCondition = (selectedProperty, groupIndex, filterIndex) => {
177
+ setShowError(/* @__PURE__ */ new Set());
178
+ setConditionsData((prev) => __spreadProps(__spreadValues({}, prev), {
179
+ filterGroups: [
180
+ ...prev.filterGroups.slice(0, groupIndex),
181
+ {
182
+ filters: [
183
+ ...prev.filterGroups[groupIndex].filters.slice(0, filterIndex + 1),
184
+ {
185
+ comparator: "AND",
186
+ property: selectedProperty,
187
+ value: initialFilterValueSelectorValue
188
+ },
189
+ ...prev.filterGroups[groupIndex].filters.slice(filterIndex + 1)
190
+ ]
191
+ },
192
+ ...prev.filterGroups.slice(groupIndex + 1)
193
+ ]
194
+ }));
195
+ };
196
+ const filterConditions = (group, filterIndex) => {
197
+ return __spreadProps(__spreadValues({}, group), {
198
+ filters: group.filters.filter(
199
+ (_, loopFilterIndex) => loopFilterIndex !== filterIndex
200
+ )
201
+ });
202
+ };
203
+ const deleteCondition = (groupIndex, filterIndex) => {
204
+ setShowError(/* @__PURE__ */ new Set());
205
+ setConditionsData((prev) => {
206
+ const updatedGroup = filterConditions(
207
+ prev.filterGroups[groupIndex],
208
+ filterIndex
209
+ );
210
+ let newData;
211
+ if (updatedGroup.filters.length === 0) {
212
+ newData = __spreadProps(__spreadValues({}, prev), {
213
+ filterGroups: prev.filterGroups.filter(
214
+ (_, loopGroupIndex) => loopGroupIndex !== groupIndex
215
+ )
216
+ });
217
+ } else {
218
+ newData = __spreadProps(__spreadValues({}, prev), {
219
+ filterGroups: prev.filterGroups.map((group, loopGroupIndex) => {
220
+ if (loopGroupIndex !== groupIndex)
221
+ return group;
222
+ return updatedGroup;
223
+ })
224
+ });
225
+ }
226
+ onConditionsChange(newData.filterGroups.length);
227
+ return newData;
228
+ });
229
+ };
230
+ const deleteGroup = (groupIndex) => {
231
+ setShowError(/* @__PURE__ */ new Set());
232
+ setConditionsData((prev) => {
233
+ const newData = __spreadProps(__spreadValues({}, prev), {
234
+ filterGroups: prev.filterGroups.filter(
235
+ (_, loopGroupIndex) => loopGroupIndex !== groupIndex
236
+ )
237
+ });
238
+ onConditionsChange(newData.filterGroups.length);
239
+ return newData;
240
+ });
241
+ };
242
+ const onGlobalConnectorChange = (value) => {
243
+ setConditionsData((prev) => __spreadProps(__spreadValues({}, prev), {
244
+ globalConnector: value
245
+ }));
246
+ };
247
+ const updateFilterInGroup = (group, filterIndex, newComparator) => {
248
+ return __spreadProps(__spreadValues({}, group), {
249
+ filters: group.filters.map((filter, loopFilterIndex) => {
250
+ if (loopFilterIndex !== filterIndex)
251
+ return filter;
252
+ return __spreadProps(__spreadValues({}, filter), {
253
+ comparator: newComparator
254
+ });
255
+ })
256
+ });
257
+ };
258
+ const onComparatorChange = (value, groupIndex, filterIndex) => {
259
+ setConditionsData((prev) => __spreadProps(__spreadValues({}, prev), {
260
+ filterGroups: prev.filterGroups.map((group, loopGroupIndex) => {
261
+ if (loopGroupIndex !== groupIndex)
262
+ return group;
263
+ return updateFilterInGroup(group, filterIndex, value);
264
+ })
265
+ }));
266
+ };
267
+ const handleSave = () => {
268
+ setExistingCondtions(conditionsData);
269
+ console.log(conditionsData);
270
+ const errorSet = /* @__PURE__ */ new Set();
271
+ conditionsData.filterGroups.forEach((group, groupIndex) => {
272
+ group.filters.forEach((filter, filterIndex) => {
273
+ if (!filter.connector || !filter.value[filter.connector.dataType]) {
274
+ errorSet.add(`${filter.property.value}-${groupIndex}-${filterIndex}`);
275
+ }
276
+ });
277
+ });
278
+ setShowError(errorSet);
279
+ };
280
+ useImperativeHandle(ref, () => ({
281
+ handleSave
282
+ }));
283
+ useEffect(() => {
284
+ var _a;
285
+ if (existingContions) {
286
+ setConditionsData(existingContions);
287
+ onConditionsChange(((_a = existingContions.filterGroups) == null ? void 0 : _a.length) || 0);
288
+ }
289
+ }, [existingContions, onConditionsChange]);
290
+ return /* @__PURE__ */ React__default.createElement(TooltipProvider, null, /* @__PURE__ */ React__default.createElement(
291
+ Flex,
292
+ {
293
+ alignItems: "center",
294
+ gap: "$2",
295
+ css: {
296
+ width: "100%",
297
+ ".twigs-cascader-dropdown": {
298
+ zIndex: "999999 !important"
299
+ }
300
+ }
301
+ },
302
+ /* @__PURE__ */ React__default.createElement(Box, { css: { margin: "0 0 $6 0", width: "100%" } }, /* @__PURE__ */ React__default.createElement(Flex, null, /* @__PURE__ */ React__default.createElement(Text, { size: "md", css: { color: "$neutral900" } }, "Which meet", /* @__PURE__ */ React__default.createElement(Box, { as: "span", css: { display: "inline-block", margin: "0 $2" } }, /* @__PURE__ */ React__default.createElement(DropdownMenu, { size: "sm" }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
303
+ Button,
304
+ {
305
+ rightIcon: /* @__PURE__ */ React__default.createElement(ChevronDownIcon, null),
306
+ size: "sm",
307
+ variant: "ghost",
308
+ color: "default",
309
+ css: {
310
+ "& span": {
311
+ fontFamily: "DM Sans !important"
312
+ },
313
+ height: "$7",
314
+ paddingRight: "0",
315
+ fontWeight: "$7"
316
+ }
317
+ },
318
+ allAnyOptionsMap[conditionsData.globalConnector]
319
+ )), /* @__PURE__ */ React__default.createElement(
320
+ DropdownMenuContent,
321
+ {
322
+ align: "start",
323
+ css: { zIndex: "1000", minWidth: "100px" }
324
+ },
325
+ allAnyOptions.map((option) => /* @__PURE__ */ React__default.createElement(
326
+ DropdownMenuItem,
327
+ {
328
+ onClick: () => onGlobalConnectorChange(option.value),
329
+ key: option.value,
330
+ css: __spreadValues({
331
+ cursor: "pointer"
332
+ }, conditionsData.globalConnector === option.value && {
333
+ "&, &:hover": {
334
+ backgroundColorOpacity: ["$primary200", 0.08]
335
+ }
336
+ })
337
+ },
338
+ option.label
339
+ ))
340
+ ))), "of these conditions:")), /* @__PURE__ */ React__default.createElement(Flex, { flexDirection: "column", gap: "$1", css: { maxWidth: "600px" } }, conditionsData.filterGroups.map((group, groupIndex) => (
341
+ // eslint-disable-next-line react/no-array-index-key
342
+ /* @__PURE__ */ React__default.createElement(Group, { key: groupIndex }, /* @__PURE__ */ React__default.createElement(GroupTitle, { onDelete: () => deleteGroup(groupIndex) }, "When"), group.filters.map((filter, filterIndex) => {
343
+ var _a, _b, _c, _d, _e, _f;
344
+ const selectedRootProperty = (_b = (_a = filter.property.selectionPath) == null ? void 0 : _a[0]) == null ? void 0 : _b.value;
345
+ const Icon = PillIconMap[selectedRootProperty];
346
+ const key = `${(_d = (_c = filter.property.operators) == null ? void 0 : _c[0]) == null ? void 0 : _d.value}-${groupIndex}-${filterIndex}`;
347
+ return /* @__PURE__ */ React__default.createElement(
348
+ Flex,
349
+ {
350
+ key: filter.property.value,
351
+ alignItems: "center",
352
+ gap: "$1",
353
+ css: {
354
+ "&:hover, &:focus, &:active, &:focus-visible": {
355
+ [`.${prefixClassName("add-condition-in-group-button")}`]: {
356
+ opacity: "1"
357
+ }
358
+ }
359
+ }
360
+ },
361
+ filterIndex > 0 && /* @__PURE__ */ React__default.createElement(
362
+ ComparatorDropdown,
363
+ {
364
+ filter,
365
+ onComparatorChange: (value) => onComparatorChange(value, groupIndex, filterIndex)
366
+ }
367
+ ),
368
+ ((_e = filter.property.operators) == null ? void 0 : _e.length) === 1 ? /* @__PURE__ */ React__default.createElement(
369
+ FilterPillWithoutOperator,
370
+ {
371
+ key,
372
+ data: filter.property.operators[0],
373
+ filterPillData: conditionsData.filterGroups[groupIndex].filters[filterIndex],
374
+ setFilterPillData: (filterPillValue) => replaceFilterPillData(
375
+ filterPillValue,
376
+ groupIndex,
377
+ filterIndex
378
+ ),
379
+ icon: Icon && /* @__PURE__ */ React__default.createElement(Icon, null),
380
+ onDelete: () => deleteCondition(groupIndex, filterIndex),
381
+ variant: "outline",
382
+ showError: showError.has(
383
+ `${filter.property.value}-${groupIndex}-${filterIndex}`
384
+ )
385
+ }
386
+ ) : /* @__PURE__ */ React__default.createElement(
387
+ FilterPill,
388
+ {
389
+ key,
390
+ cascaderDropdownData: (_f = filter.property.operators) != null ? _f : [],
391
+ filterPillData: conditionsData.filterGroups[groupIndex].filters[filterIndex],
392
+ setFilterPillData: (filterPillValue) => replaceFilterPillData(
393
+ filterPillValue,
394
+ groupIndex,
395
+ filterIndex
396
+ ),
397
+ onDelete: () => deleteCondition(groupIndex, filterIndex),
398
+ variant: "outline",
399
+ icon: Icon && /* @__PURE__ */ React__default.createElement(Icon, null),
400
+ showError: showError.has(
401
+ `${filter.property.value}-${groupIndex}-${filterIndex}`
402
+ )
403
+ }
404
+ ),
405
+ /* @__PURE__ */ React__default.createElement(
406
+ AddConditionInGroupButton,
407
+ {
408
+ conditionData,
409
+ insertCondition: (selectedProperty) => insertCondition(
410
+ selectedProperty,
411
+ groupIndex,
412
+ filterIndex
413
+ )
414
+ }
415
+ )
416
+ );
417
+ }))
418
+ )), /* @__PURE__ */ React__default.createElement(Flex, { alignItems: "center", gap: "$4", css: { marginTop: "$6", marginLeft: "-$2" } }, /* @__PURE__ */ React__default.createElement(
419
+ AddConditionButton,
420
+ {
421
+ conditionData,
422
+ onAdd: (selectedProperty) => {
423
+ addCondition(selectedProperty);
424
+ }
425
+ },
426
+ /* @__PURE__ */ React__default.createElement(
427
+ Button,
428
+ {
429
+ leftIcon: /* @__PURE__ */ React__default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React__default.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" })),
430
+ color: "secondary",
431
+ variant: "ghost",
432
+ css: {
433
+ height: "auto",
434
+ minWidth: "fit-content",
435
+ "& span": {
436
+ fontFamily: "DM Sans !important"
437
+ }
438
+ }
439
+ },
440
+ "Add group"
441
+ )
442
+ ), /* @__PURE__ */ React__default.createElement(
443
+ Box,
444
+ {
445
+ css: {
446
+ width: "100%",
447
+ borderBottom: "2px dashed $secondary100"
448
+ }
449
+ }
450
+ ))))
451
+ ));
452
+ });
453
+ ConditionWrapper.displayName = "ConditionWrapper";
454
+ const Group = ({ children }) => {
455
+ return /* @__PURE__ */ React__default.createElement(Flex, { css: { padding: "$4 0" }, flexDirection: "column", gap: "$2" }, children);
456
+ };
457
+ const GroupTitle = ({
458
+ children,
459
+ onDelete
460
+ }) => {
461
+ return /* @__PURE__ */ React__default.createElement(
462
+ Flex,
463
+ {
464
+ alignItems: "center",
465
+ justifyContent: "space-between",
466
+ css: { padding: "$1 0" },
467
+ gap: "$2"
468
+ },
469
+ /* @__PURE__ */ React__default.createElement(Text, { weight: "bold", css: { color: "$secondary900" } }, children),
470
+ /* @__PURE__ */ React__default.createElement(
471
+ Box,
472
+ {
473
+ css: {
474
+ height: "1px",
475
+ width: "100%",
476
+ backgroundColor: "$black100",
477
+ flex: "1"
478
+ }
479
+ }
480
+ ),
481
+ /* @__PURE__ */ React__default.createElement(Tooltip, { content: "Remove Group", css: { zIndex: "99999" } }, /* @__PURE__ */ React__default.createElement(
482
+ IconButton,
483
+ {
484
+ css: { height: "$5", width: "$5" },
485
+ variant: "ghost",
486
+ color: "default",
487
+ icon: /* @__PURE__ */ React__default.createElement(DeleteIcon, null),
488
+ onClick: onDelete
489
+ }
490
+ ))
491
+ );
492
+ };
493
+ const AddConditionButton = ({
494
+ conditionData,
495
+ children,
496
+ onAdd,
497
+ dropdownContentProps,
498
+ tooltipProps
499
+ }) => {
500
+ const onChange = ({
501
+ selectedProperty,
502
+ selectionPath
503
+ }) => {
504
+ if (!(selectedProperty == null ? void 0 : selectedProperty.label) || !(selectedProperty == null ? void 0 : selectedProperty.value))
505
+ return;
506
+ onAdd(__spreadProps(__spreadValues({}, selectedProperty), { selectionPath }));
507
+ };
508
+ return /* @__PURE__ */ React__default.createElement(
509
+ CascaderDropdown,
510
+ {
511
+ data: conditionData,
512
+ dropdownContentProps: __spreadValues({ align: "start" }, dropdownContentProps),
513
+ onChange,
514
+ tooltipProps
515
+ },
516
+ children
517
+ );
518
+ };
519
+ const ComparatorDropdown = ({
520
+ filter,
521
+ onComparatorChange
522
+ }) => {
523
+ return /* @__PURE__ */ React__default.createElement(DropdownMenu, { size: "sm" }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
524
+ Button,
525
+ {
526
+ rightIcon: /* @__PURE__ */ React__default.createElement(ChevronDownIcon, null),
527
+ size: "sm",
528
+ variant: "ghost",
529
+ color: "default",
530
+ css: {
531
+ height: "$7",
532
+ fontWeight: "$4",
533
+ color: "$neutral800",
534
+ paddingRight: "$1",
535
+ paddingLeft: "$2"
536
+ }
537
+ },
538
+ connectorOptionsMap[filter.comparator]
539
+ )), /* @__PURE__ */ React__default.createElement(
540
+ DropdownMenuContent,
541
+ {
542
+ align: "start",
543
+ css: { zIndex: "1000", minWidth: "100px" }
544
+ },
545
+ connectorOptions.map((option) => /* @__PURE__ */ React__default.createElement(
546
+ DropdownMenuItem,
547
+ {
548
+ key: option.value,
549
+ onClick: () => onComparatorChange(option.value),
550
+ css: __spreadValues({
551
+ cursor: "pointer"
552
+ }, filter.comparator === option.value && {
553
+ "&, &:hover": {
554
+ backgroundColorOpacity: ["$primary200", 0.08]
555
+ }
556
+ })
557
+ },
558
+ option.label
559
+ ))
560
+ ));
561
+ };
562
+ const AddConditionInGroupButton = ({
563
+ conditionData,
564
+ insertCondition
565
+ }) => {
566
+ const handleAddCondition = (selectedProperty) => {
567
+ if (!selectedProperty)
568
+ return;
569
+ insertCondition(selectedProperty);
570
+ };
571
+ return /* @__PURE__ */ React__default.createElement(
572
+ AddConditionButton,
573
+ {
574
+ conditionData,
575
+ onAdd: handleAddCondition,
576
+ tooltipProps: {
577
+ content: "Add condition",
578
+ side: "right",
579
+ css: { zIndex: "99999" }
580
+ }
581
+ },
582
+ /* @__PURE__ */ React__default.createElement(
583
+ IconButton,
584
+ {
585
+ className: prefixClassName("add-condition-in-group-button"),
586
+ size: "md",
587
+ css: {
588
+ height: "$6",
589
+ width: "$6",
590
+ borderRadius: "$sm",
591
+ border: "1px dashed $black300",
592
+ opacity: "0",
593
+ transition: "opacity 0.2s ease-in-out",
594
+ marginLeft: "$3",
595
+ "&:hover, &:focus, &:active, &:focus-visible": {
596
+ opacity: 1
597
+ }
598
+ },
599
+ icon: /* @__PURE__ */ React__default.createElement(PlusIcon, null),
600
+ color: "default",
601
+ variant: "ghost"
602
+ }
603
+ )
604
+ );
605
+ };
606
+
607
+ export { ConditionWrapper as default };
608
+ //# sourceMappingURL=conditionWrapper.js.map