@sparrowengg/integrations-templates-frontend 1.9.84-beta.11 → 1.9.84-beta.13

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.
@@ -0,0 +1,1069 @@
1
+ import { parseDate as $fae977aafc393c5c$export$6b862160d295c8e } from '../node_modules/@internationalized/date/dist/string.js';
2
+ import EditConfirmation from '../commons/components/edit-confirmation.js';
3
+ import React__default, { useState, useEffect } from 'react';
4
+ import Arrow from '../commons/icons/arrow.js';
5
+ import Mapping$1 from './components/mapping.js';
6
+ import { surveySparrowURL, dynamicDateOptions } from '../commons/constants/index.js';
7
+ import dayjs from '../node_modules/dayjs/dayjs.min.js';
8
+ import { Mapping } from '../mapping/components/mapping.js';
9
+ import { ThemeProvider } from '../node_modules/@sparrowengg/twigs-react/dist/es/theme-provider/theme-provider.js';
10
+ import { TooltipProvider, Tooltip } from '../node_modules/@sparrowengg/twigs-react/dist/es/tooltip/tooltip.js';
11
+ import { Box } from '../node_modules/@sparrowengg/twigs-react/dist/es/box/box.js';
12
+ import { Flex } from '../node_modules/@sparrowengg/twigs-react/dist/es/flex/flex.js';
13
+ import { IconButton } from '../node_modules/@sparrowengg/twigs-react/dist/es/button/icon-button.js';
14
+ import { ArrowLeftIcon } from '../node_modules/@sparrowengg/twigs-react-icons/dist/es/icons/arrow-left.js';
15
+ import { Heading } from '../node_modules/@sparrowengg/twigs-react/dist/es/heading/heading.js';
16
+ import { Button } from '../node_modules/@sparrowengg/twigs-react/dist/es/button/button.js';
17
+ import { Text } from '../node_modules/@sparrowengg/twigs-react/dist/es/text/text.js';
18
+ import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent } from '../node_modules/@sparrowengg/twigs-react/dist/es/dropdown/dropdown.js';
19
+ import { Input } from '../node_modules/@sparrowengg/twigs-react/dist/es/input/input.js';
20
+ import { ChevronDownIcon } from '../node_modules/@sparrowengg/twigs-react-icons/dist/es/icons/chevron-down.js';
21
+ import { Calendar } from '../node_modules/@sparrowengg/twigs-react/dist/es/calendar/calendar.js';
22
+ import { RadioGroup, Radio } from '../node_modules/@sparrowengg/twigs-react/dist/es/radio/radio.js';
23
+ import { FormLabel } from '../node_modules/@sparrowengg/twigs-react/dist/es/form-label/form-label.js';
24
+ import { FormInput } from '../node_modules/@sparrowengg/twigs-react/dist/es/input/form-input.js';
25
+ import { Checkbox } from '../node_modules/@sparrowengg/twigs-react/dist/es/checkbox/checkbox.js';
26
+ import { Switch } from '../node_modules/@sparrowengg/twigs-react/dist/es/switch/switch.js';
27
+ import { Select } from '../node_modules/@sparrowengg/twigs-react/dist/es/select/select.js';
28
+ import { c as components } from '../node_modules/react-select/dist/index-a301f526.esm.js';
29
+ import { PlusIcon } from '../node_modules/@sparrowengg/twigs-react-icons/dist/es/icons/plus.js';
30
+ import { Chip } from '../node_modules/@sparrowengg/twigs-react/dist/es/chip/chip.js';
31
+ import { TickCircleFillIcon } from '../node_modules/@sparrowengg/twigs-react-icons/dist/es/icons/tick-circle-fill.js';
32
+
33
+ var __defProp = Object.defineProperty;
34
+ var __defProps = Object.defineProperties;
35
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
36
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
37
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
38
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
39
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
40
+ var __spreadValues = (a, b) => {
41
+ for (var prop in b || (b = {}))
42
+ if (__hasOwnProp.call(b, prop))
43
+ __defNormalProp(a, prop, b[prop]);
44
+ if (__getOwnPropSymbols)
45
+ for (var prop of __getOwnPropSymbols(b)) {
46
+ if (__propIsEnum.call(b, prop))
47
+ __defNormalProp(a, prop, b[prop]);
48
+ }
49
+ return a;
50
+ };
51
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
52
+ const DynamicMapping = ({
53
+ mappingType,
54
+ integrationFields,
55
+ configuration,
56
+ isMappingPage,
57
+ navigateMappingPage,
58
+ setIntegrationFields,
59
+ token,
60
+ apiURL = surveySparrowURL,
61
+ surveyDetails,
62
+ importResponse,
63
+ hasExistingMapping,
64
+ onSaveHandler,
65
+ editField,
66
+ previousMappingHandler,
67
+ surveyType,
68
+ havingTypeDropdown,
69
+ fields,
70
+ setFields,
71
+ surveyId,
72
+ integrationName,
73
+ customList,
74
+ oldResponse
75
+ }) => {
76
+ const [ssMappingData, setSSMappingData] = useState({
77
+ questions: [],
78
+ variables: [],
79
+ contactProperties: [],
80
+ expressions: [],
81
+ property: [],
82
+ derivedQuestions: []
83
+ });
84
+ const [isEditConfirmationOpen, setIsEditConfirmationOpen] = useState(false);
85
+ const [originalMappingData, setOriginalMappingData] = useState(null);
86
+ const [originalConfigurationFields, setOriginalConfigurationFields] = useState(null);
87
+ const [originalConfiguredFields, setOriginalConfiguredFields] = useState(null);
88
+ const [originalImportResponse, setOriginalImportResponse] = useState(null);
89
+ const [isInitialLoad, setIsInitialLoad] = useState(true);
90
+ useEffect(() => {
91
+ if (!!(editField == null ? void 0 : editField.id)) {
92
+ navigateMappingPage(true);
93
+ setOriginalConfigurationFields(
94
+ JSON.parse(JSON.stringify(configuration.configurationFields))
95
+ );
96
+ setOriginalConfiguredFields(
97
+ JSON.parse(JSON.stringify(configuration.configuredFields))
98
+ );
99
+ setOriginalImportResponse(JSON.parse(JSON.stringify(importResponse)));
100
+ }
101
+ }, []);
102
+ const hasFieldsChanged = () => {
103
+ if (!(editField == null ? void 0 : editField.id) || !originalMappingData)
104
+ return true;
105
+ const mappingDataChanged = JSON.stringify(ssMappingData) !== JSON.stringify(originalMappingData);
106
+ JSON.stringify(JSON.parse(JSON.stringify(importResponse))) !== JSON.stringify(originalImportResponse);
107
+ const configFieldsChanged = JSON.stringify(configuration.configurationFields) !== JSON.stringify(originalConfigurationFields);
108
+ const configuredFieldsChanged = JSON.stringify(configuration.configuredFields) !== JSON.stringify(originalConfiguredFields);
109
+ return configFieldsChanged || configuredFieldsChanged || !isInitialLoad && mappingDataChanged;
110
+ };
111
+ return /* @__PURE__ */ React__default.createElement(
112
+ ThemeProvider,
113
+ {
114
+ theme: {
115
+ fonts: {
116
+ body: "DM Sans, Roboto Mono, sans-serif",
117
+ heading: "DM Sans, Roboto Mono, sans-serif"
118
+ }
119
+ }
120
+ },
121
+ /* @__PURE__ */ React__default.createElement(TooltipProvider, null, /* @__PURE__ */ React__default.createElement(Box, { css: { width: "100%" } }, /* @__PURE__ */ React__default.createElement(
122
+ MappingHeader,
123
+ {
124
+ mappingType: mappingType != null ? mappingType : "",
125
+ isEditConfirmationOpen,
126
+ setIsEditConfirmationOpen,
127
+ editField,
128
+ importResponse,
129
+ ssMappingData,
130
+ configuration,
131
+ hasFieldsChanged: hasFieldsChanged(),
132
+ saveConfiguration: () => {
133
+ configuration.onSaveHandler();
134
+ },
135
+ isMappingPage,
136
+ hasExistingMapping,
137
+ navigateConfigPage: () => navigateMappingPage(false),
138
+ previousMappingHandler,
139
+ onSaveHandler: () => {
140
+ onSaveHandler((editField == null ? void 0 : editField.id) ? editField : {});
141
+ }
142
+ }
143
+ ), !isMappingPage && configuration.hasConfiguration ? /* @__PURE__ */ React__default.createElement(
144
+ Flex,
145
+ {
146
+ justifyContent: "center",
147
+ alignItems: "center",
148
+ css: { marginTop: "$40" }
149
+ },
150
+ /* @__PURE__ */ React__default.createElement(
151
+ ConfigurationSetup,
152
+ {
153
+ configuration,
154
+ surveyName: surveyDetails.surveyName,
155
+ editField
156
+ }
157
+ )
158
+ ) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, mappingType === "MULTI_MAPPING" ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
159
+ Mapping,
160
+ {
161
+ surveyType,
162
+ havingTypeDropdown,
163
+ fields,
164
+ setFields,
165
+ surveyDetails,
166
+ integrationFields,
167
+ setIntegrationFields,
168
+ surveyId: surveyDetails.surveyId,
169
+ token,
170
+ apiURL,
171
+ integrationName,
172
+ customList,
173
+ oldResponse
174
+ }
175
+ )) : /* @__PURE__ */ React__default.createElement(
176
+ Mapping$1,
177
+ {
178
+ setOriginalMappingData,
179
+ integrationFields,
180
+ setIntegrationFields,
181
+ token,
182
+ setIsInitialLoad,
183
+ apiURL,
184
+ surveyId: surveyDetails.surveyId,
185
+ surveyProperties: surveyDetails.surveyProperties,
186
+ importResponse,
187
+ ssMappingData,
188
+ setSSMappingData,
189
+ editField
190
+ }
191
+ ))))
192
+ );
193
+ };
194
+ const MappingHeader = ({
195
+ isEditConfirmationOpen,
196
+ editField,
197
+ importResponse,
198
+ hasExistingMapping,
199
+ ssMappingData,
200
+ isMappingPage,
201
+ navigateConfigPage,
202
+ onSaveHandler,
203
+ previousMappingHandler,
204
+ saveConfiguration,
205
+ configuration,
206
+ setIsEditConfirmationOpen,
207
+ hasFieldsChanged,
208
+ mappingType
209
+ }) => {
210
+ const isButtonDisabled = () => {
211
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
212
+ if (isMappingPage) {
213
+ if (mappingType === "MULTI_MAPPING") {
214
+ return false;
215
+ }
216
+ if (editField == null ? void 0 : editField.id) {
217
+ return !hasFieldsChanged;
218
+ }
219
+ if (((_a = importResponse == null ? void 0 : importResponse.value) == null ? void 0 : _a.ImportMethod) === "SEND_ALL_DATA") {
220
+ return !(((_b = ssMappingData == null ? void 0 : ssMappingData.questions) == null ? void 0 : _b.length) || ((_c = ssMappingData == null ? void 0 : ssMappingData.variables) == null ? void 0 : _c.length) || ((_d = ssMappingData == null ? void 0 : ssMappingData.contactProperties) == null ? void 0 : _d.length) || ((_e = ssMappingData == null ? void 0 : ssMappingData.expressions) == null ? void 0 : _e.length) || ((_f = ssMappingData == null ? void 0 : ssMappingData.property) == null ? void 0 : _f.length) || ((_g = ssMappingData == null ? void 0 : ssMappingData.derivedQuestions) == null ? void 0 : _g.length));
221
+ } else {
222
+ const isMappingDisabled = ((_h = ssMappingData == null ? void 0 : ssMappingData.questions) == null ? void 0 : _h.some(
223
+ (question) => question.isEnabled
224
+ )) || ((_i = ssMappingData == null ? void 0 : ssMappingData.variables) == null ? void 0 : _i.some(
225
+ (variable) => variable.isEnabled
226
+ )) || ((_j = ssMappingData == null ? void 0 : ssMappingData.contactProperties) == null ? void 0 : _j.some(
227
+ (property) => property.isEnabled
228
+ )) || ((_k = ssMappingData == null ? void 0 : ssMappingData.expressions) == null ? void 0 : _k.some(
229
+ (expression) => expression.isEnabled
230
+ )) || ((_l = ssMappingData == null ? void 0 : ssMappingData.derivedQuestions) == null ? void 0 : _l.some(
231
+ (derivedQuestion) => derivedQuestion.isEnabled
232
+ )) || ((_m = ssMappingData == null ? void 0 : ssMappingData.property) == null ? void 0 : _m.some(
233
+ (property) => property.isEnabled
234
+ ));
235
+ return !isMappingDisabled;
236
+ }
237
+ } else {
238
+ const isAllFieldsDisabled = (_n = Object.values(
239
+ (configuration == null ? void 0 : configuration.configurationFields) || {}
240
+ )) == null ? void 0 : _n.some(
241
+ (field) => (field == null ? void 0 : field.value) === null || (field == null ? void 0 : field.value) === void 0
242
+ );
243
+ if ((_p = (_o = configuration == null ? void 0 : configuration.configurationFields) == null ? void 0 : _o.find(
244
+ (field) => (field == null ? void 0 : field.id) === "responseImportSettings"
245
+ )) == null ? void 0 : _p.value) {
246
+ return isAllFieldsDisabled || !((_q = configuration == null ? void 0 : configuration.configuredFields) == null ? void 0 : _q.responseImportType);
247
+ } else {
248
+ return isAllFieldsDisabled;
249
+ }
250
+ }
251
+ };
252
+ const isMappingPageDisabled = () => {
253
+ var _a, _b, _c, _d;
254
+ const isAllFieldsDisabled = (_a = Object.values(
255
+ (configuration == null ? void 0 : configuration.configurationFields) || {}
256
+ )) == null ? void 0 : _a.some(
257
+ (field) => (field == null ? void 0 : field.value) === null || (field == null ? void 0 : field.value) === void 0
258
+ );
259
+ if ((_c = (_b = configuration == null ? void 0 : configuration.configurationFields) == null ? void 0 : _b.find(
260
+ (field) => (field == null ? void 0 : field.id) === "responseImportSettings"
261
+ )) == null ? void 0 : _c.value) {
262
+ return isAllFieldsDisabled || !((_d = configuration == null ? void 0 : configuration.configuredFields) == null ? void 0 : _d.responseImportType);
263
+ } else {
264
+ return isAllFieldsDisabled;
265
+ }
266
+ };
267
+ return /* @__PURE__ */ React__default.createElement(
268
+ Flex,
269
+ {
270
+ alignItems: "center",
271
+ justifyContent: "space-between",
272
+ css: {
273
+ borderBottom: "$borderWidths$xs solid $neutral200",
274
+ padding: "$8 $12"
275
+ }
276
+ },
277
+ /* @__PURE__ */ React__default.createElement(
278
+ Flex,
279
+ {
280
+ gap: "$6",
281
+ alignItems: "center",
282
+ css: { visibility: hasExistingMapping ? "visible" : "hidden" }
283
+ },
284
+ /* @__PURE__ */ React__default.createElement(
285
+ IconButton,
286
+ {
287
+ onClick: () => previousMappingHandler == null ? void 0 : previousMappingHandler(),
288
+ color: "default",
289
+ icon: /* @__PURE__ */ React__default.createElement(ArrowLeftIcon, null),
290
+ size: "lg"
291
+ }
292
+ ),
293
+ /* @__PURE__ */ React__default.createElement(Heading, { size: "h6" }, (editField == null ? void 0 : editField.id) ? "Edit Mapping" : "New Mapping")
294
+ ),
295
+ /* @__PURE__ */ React__default.createElement(
296
+ Flex,
297
+ {
298
+ alignItems: "center",
299
+ gap: "$4",
300
+ css: {
301
+ "& button": { background: "transparent !important", fontSize: "$md" }
302
+ }
303
+ },
304
+ /* @__PURE__ */ React__default.createElement(
305
+ Button,
306
+ {
307
+ css: { color: !isMappingPage ? "$neutral900" : "$neutral800" },
308
+ color: "default",
309
+ variant: "ghost",
310
+ size: "md",
311
+ onClick: () => isMappingPage && navigateConfigPage()
312
+ },
313
+ "Configuration"
314
+ ),
315
+ /* @__PURE__ */ React__default.createElement(Arrow, null),
316
+ /* @__PURE__ */ React__default.createElement(
317
+ Button,
318
+ {
319
+ disabled: isMappingPageDisabled(),
320
+ css: {
321
+ color: isMappingPage ? "$neutral900" : "$neutral800",
322
+ cursor: isMappingPageDisabled() ? "not-allowed" : "pointer"
323
+ },
324
+ color: "default",
325
+ variant: "ghost",
326
+ onClick: () => {
327
+ if (isMappingPage) {
328
+ onSaveHandler({});
329
+ } else {
330
+ saveConfiguration();
331
+ }
332
+ },
333
+ size: "md"
334
+ },
335
+ "Mapping"
336
+ )
337
+ ),
338
+ /* @__PURE__ */ React__default.createElement(
339
+ Flex,
340
+ {
341
+ justifyContent: "end",
342
+ css: {
343
+ width: "180px"
344
+ }
345
+ },
346
+ /* @__PURE__ */ React__default.createElement(
347
+ Button,
348
+ {
349
+ size: "lg",
350
+ disabled: isButtonDisabled(),
351
+ onClick: () => {
352
+ if (isMappingPage) {
353
+ if (editField == null ? void 0 : editField.id) {
354
+ setIsEditConfirmationOpen(true);
355
+ } else {
356
+ onSaveHandler({});
357
+ }
358
+ } else {
359
+ saveConfiguration();
360
+ }
361
+ }
362
+ },
363
+ isMappingPage ? (editField == null ? void 0 : editField.id) ? "Update Mapping" : "Save Mapping" : "Continue, Mapping"
364
+ )
365
+ ),
366
+ isEditConfirmationOpen && /* @__PURE__ */ React__default.createElement(
367
+ EditConfirmation,
368
+ {
369
+ name: "Are you sure?",
370
+ description: "Saving this updated mapping properties will generate new sheet with the revised mapping.",
371
+ onConfirm: async () => {
372
+ await onSaveHandler({});
373
+ setIsEditConfirmationOpen(false);
374
+ },
375
+ onCancel: () => {
376
+ setIsEditConfirmationOpen(false);
377
+ }
378
+ }
379
+ )
380
+ );
381
+ };
382
+ const ConfigurationSetup = ({
383
+ configuration,
384
+ surveyName,
385
+ editField
386
+ }) => {
387
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
388
+ return /* @__PURE__ */ React__default.createElement(Box, { css: { maxWidth: 488, width: "100%" } }, /* @__PURE__ */ React__default.createElement(Heading, { size: "h5" }, "Event Details"), /* @__PURE__ */ React__default.createElement(Flex, { gap: "$2", css: { marginTop: "$4" } }, /* @__PURE__ */ React__default.createElement(Text, { size: "sm", css: { color: "$neutral500" } }, "Survey Name:"), /* @__PURE__ */ React__default.createElement(
389
+ Tooltip,
390
+ {
391
+ content: (surveyName == null ? void 0 : surveyName.length) > 25 ? surveyName : "",
392
+ css: {
393
+ zIndex: "9999999 !important",
394
+ fontFamily: "DM Sans !important"
395
+ }
396
+ },
397
+ /* @__PURE__ */ React__default.createElement(Box, null, /* @__PURE__ */ React__default.createElement(
398
+ Text,
399
+ {
400
+ size: "sm",
401
+ weight: "medium",
402
+ truncate: true,
403
+ css: { color: "$neutral800", maxWidth: "270px" }
404
+ },
405
+ surveyName
406
+ ))
407
+ )), /* @__PURE__ */ React__default.createElement(
408
+ Flex,
409
+ {
410
+ flexDirection: "column",
411
+ gap: "$8",
412
+ css: {
413
+ marginTop: "$12",
414
+ "& label": {
415
+ color: "$neutral800"
416
+ }
417
+ }
418
+ },
419
+ (_a = configuration.configurationFields) == null ? void 0 : _a.map((field) => {
420
+ return /* @__PURE__ */ React__default.createElement(
421
+ Configuration,
422
+ {
423
+ field,
424
+ configuredFields: configuration.configuredFields
425
+ }
426
+ );
427
+ }),
428
+ configuration.importOptions.showImportOptions && /* @__PURE__ */ React__default.createElement(
429
+ Flex,
430
+ {
431
+ gap: "$2",
432
+ flexDirection: "column",
433
+ css: {
434
+ marginTop: "-4px !important"
435
+ }
436
+ },
437
+ /* @__PURE__ */ React__default.createElement(
438
+ CustomDropdown,
439
+ {
440
+ editField,
441
+ data: configuration.importOptions.options,
442
+ value: (_d = (_c = (_b = configuration == null ? void 0 : configuration.configuredFields) == null ? void 0 : _b.responseImportType) == null ? void 0 : _c.value) != null ? _d : configuration.importOptions.options[0],
443
+ onChangeHandler: configuration.importOptions.onChangeHandler
444
+ }
445
+ )
446
+ ),
447
+ ((_g = (_f = (_e = configuration.configuredFields) == null ? void 0 : _e.responseImportType) == null ? void 0 : _f.value) == null ? void 0 : _g.type) === "date" && /* @__PURE__ */ React__default.createElement(
448
+ Text,
449
+ {
450
+ size: "sm",
451
+ weight: "regular",
452
+ css: { color: "$neutral600", marginTop: "-$6" }
453
+ },
454
+ `Existing responses from ${(_j = (_i = (_h = configuration.configuredFields) == null ? void 0 : _h.responseImportType) == null ? void 0 : _i.value) == null ? void 0 : _j.value} will be imported`
455
+ ),
456
+ configuration.importOptions.excludeResponse && ((_m = (_l = (_k = configuration.configuredFields) == null ? void 0 : _k.responseImportType) == null ? void 0 : _l.value) == null ? void 0 : _m.type) === "dateRange" && /* @__PURE__ */ React__default.createElement(
457
+ Configuration,
458
+ {
459
+ field: configuration.importOptions.excludeResponse,
460
+ configuredFields: configuration.configuredFields,
461
+ responseImportType: (_q = (_p = (_o = (_n = configuration.configuredFields) == null ? void 0 : _n.responseImportType) == null ? void 0 : _o.value) == null ? void 0 : _p.value) == null ? void 0 : _q.label
462
+ }
463
+ )
464
+ ));
465
+ };
466
+ const CustomDropdown = ({ data, onChangeHandler, value, editField }) => {
467
+ var _a, _b, _c, _d, _e;
468
+ const [date, setDate] = useState(() => {
469
+ try {
470
+ return value ? $fae977aafc393c5c$export$6b862160d295c8e(dayjs(value).format("YYYY-MM-DD")) : $fae977aafc393c5c$export$6b862160d295c8e(dayjs().format("YYYY-MM-DD"));
471
+ } catch (e) {
472
+ return $fae977aafc393c5c$export$6b862160d295c8e(dayjs().format("YYYY-MM-DD"));
473
+ }
474
+ });
475
+ const [days, setDays] = useState((_b = (_a = value == null ? void 0 : value.value) == null ? void 0 : _a.value) != null ? _b : 0);
476
+ const [open, setOpen] = useState(false);
477
+ const [hasBeenOpened, setHasBeenOpened] = useState(false);
478
+ useEffect(() => {
479
+ if (!(editField == null ? void 0 : editField.id) && !hasBeenOpened) {
480
+ setOpen(true);
481
+ setHasBeenOpened(true);
482
+ }
483
+ }, [editField == null ? void 0 : editField.id, hasBeenOpened]);
484
+ return /* @__PURE__ */ React__default.createElement(DropdownMenu, { open, onOpenChange: setOpen, modal: false }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
485
+ Input,
486
+ {
487
+ size: "lg",
488
+ rightIcon: /* @__PURE__ */ React__default.createElement(ChevronDownIcon, { size: 30, color: "#6A6A6A" }),
489
+ placeholder: "Choose",
490
+ value: (value == null ? void 0 : value.type) === "date" ? `${value == null ? void 0 : value.label} > ${value == null ? void 0 : value.value}` : (value == null ? void 0 : value.type) === "dateRange" ? `${value == null ? void 0 : value.label} - ${((_c = value == null ? void 0 : value.value) == null ? void 0 : _c.type) === "custom" ? `${(_d = value == null ? void 0 : value.value) == null ? void 0 : _d.value} days` : (_e = value == null ? void 0 : value.value) == null ? void 0 : _e.label}` : value == null ? void 0 : value.label,
491
+ css: {
492
+ "& input": {
493
+ textAlign: "left !important"
494
+ }
495
+ }
496
+ }
497
+ )), /* @__PURE__ */ React__default.createElement(
498
+ DropdownMenuContent,
499
+ {
500
+ css: {
501
+ width: "488px",
502
+ marginBlockStart: "$2",
503
+ p: {
504
+ margin: "0px !important"
505
+ },
506
+ zIndex: "99 !important"
507
+ },
508
+ className: "dm-sans"
509
+ },
510
+ data.map((option) => {
511
+ var _a2;
512
+ if (!option.type) {
513
+ return /* @__PURE__ */ React__default.createElement(
514
+ Tooltip,
515
+ {
516
+ content: option.tooltip || "",
517
+ css: {
518
+ zIndex: "9999999 !important",
519
+ fontFamily: "DM Sans !important"
520
+ }
521
+ },
522
+ /* @__PURE__ */ React__default.createElement(Box, null, /* @__PURE__ */ React__default.createElement(
523
+ DropdownMenuItem,
524
+ {
525
+ disabled: option == null ? void 0 : option.disabled,
526
+ css: {
527
+ cursor: (option == null ? void 0 : option.disabled) ? "not-allowed !important" : "pointer !important",
528
+ background: (value == null ? void 0 : value.type) === option.type ? "#4A9CA626 !important" : "transparent !important"
529
+ },
530
+ onClick: () => onChangeHandler({
531
+ id: "responseImportType",
532
+ value: option
533
+ })
534
+ },
535
+ /* @__PURE__ */ React__default.createElement(
536
+ Flex,
537
+ {
538
+ justifyContent: "space-between",
539
+ alignItems: "center",
540
+ css: {
541
+ width: "100%"
542
+ }
543
+ },
544
+ /* @__PURE__ */ React__default.createElement(Flex, { justifyContent: "center", flexDirection: "column" }, /* @__PURE__ */ React__default.createElement(
545
+ Text,
546
+ {
547
+ size: "sm",
548
+ weight: "regular",
549
+ css: { color: "$neutral900" }
550
+ },
551
+ option.label
552
+ ), /* @__PURE__ */ React__default.createElement(
553
+ Text,
554
+ {
555
+ size: "xs",
556
+ weight: "regular",
557
+ css: { color: "$neutral700" }
558
+ },
559
+ option.description
560
+ ))
561
+ )
562
+ ))
563
+ );
564
+ } else {
565
+ return /* @__PURE__ */ React__default.createElement(
566
+ Tooltip,
567
+ {
568
+ content: option.tooltip || "",
569
+ css: {
570
+ fontFamily: "DM Sans !important",
571
+ zIndex: "9999999 !important"
572
+ }
573
+ },
574
+ /* @__PURE__ */ React__default.createElement(Box, null, /* @__PURE__ */ React__default.createElement(DropdownMenuSub, null, /* @__PURE__ */ React__default.createElement(
575
+ DropdownMenuSubTrigger,
576
+ {
577
+ disabled: option == null ? void 0 : option.disabled,
578
+ css: {
579
+ cursor: (option == null ? void 0 : option.disabled) ? "not-allowed !important" : "pointer !important",
580
+ background: (value == null ? void 0 : value.type) === option.type ? "#4A9CA626 !important" : "transparent !important"
581
+ }
582
+ },
583
+ " ",
584
+ /* @__PURE__ */ React__default.createElement(
585
+ Flex,
586
+ {
587
+ justifyContent: "space-between",
588
+ alignItems: "center",
589
+ css: {
590
+ width: "100%"
591
+ }
592
+ },
593
+ /* @__PURE__ */ React__default.createElement(
594
+ Flex,
595
+ {
596
+ css: { cursor: "pointer" },
597
+ justifyContent: "center",
598
+ flexDirection: "column"
599
+ },
600
+ /* @__PURE__ */ React__default.createElement(
601
+ Text,
602
+ {
603
+ size: "sm",
604
+ weight: "regular",
605
+ css: { color: "$neutral900" }
606
+ },
607
+ option.label
608
+ ),
609
+ /* @__PURE__ */ React__default.createElement(
610
+ Text,
611
+ {
612
+ size: "xs",
613
+ weight: "regular",
614
+ css: { color: "$neutral700" }
615
+ },
616
+ option.description
617
+ )
618
+ )
619
+ )
620
+ ), /* @__PURE__ */ React__default.createElement(
621
+ DropdownMenuSubContent,
622
+ {
623
+ sideOffset: 10,
624
+ alignOffset: -5,
625
+ css: __spreadProps(__spreadValues({
626
+ padding: "0px !important",
627
+ maxHeight: "500px",
628
+ minWidth: "224px",
629
+ maxWidth: "260px",
630
+ margin: "0px !important"
631
+ }, option.type === "date" && {
632
+ border: "none !important"
633
+ }), {
634
+ p: {
635
+ margin: "0px !important"
636
+ },
637
+ marginBlockEnd: "$10 !important"
638
+ }),
639
+ className: "dm-sans"
640
+ },
641
+ option.type === "date" && /* @__PURE__ */ React__default.createElement(
642
+ Calendar,
643
+ __spreadProps(__spreadValues(__spreadValues({
644
+ footerActionText: "Apply",
645
+ size: "md",
646
+ value: date,
647
+ onChange: setDate
648
+ }, (option == null ? void 0 : option.minValue) && {
649
+ minValue: $fae977aafc393c5c$export$6b862160d295c8e(option == null ? void 0 : option.minValue)
650
+ }), (option == null ? void 0 : option.maxValue) && {
651
+ maxValue: $fae977aafc393c5c$export$6b862160d295c8e(option == null ? void 0 : option.maxValue)
652
+ }), {
653
+ footerAction: () => {
654
+ onChangeHandler({
655
+ id: "responseImportType",
656
+ value: __spreadProps(__spreadValues({}, option), {
657
+ value: dayjs(date.toString()).format(
658
+ "MMM D, YYYY"
659
+ )
660
+ })
661
+ });
662
+ setOpen(false);
663
+ }
664
+ })
665
+ ),
666
+ option.type === "dateRange" && /* @__PURE__ */ React__default.createElement(
667
+ Flex,
668
+ {
669
+ css: {
670
+ paddingInline: "$4 !important",
671
+ paddingBlock: "$8 !important"
672
+ },
673
+ flexDirection: "column",
674
+ gap: "$4"
675
+ },
676
+ /* @__PURE__ */ React__default.createElement(
677
+ RadioGroup,
678
+ {
679
+ defaultValue: value == null ? void 0 : value.value,
680
+ onChange: (value2) => {
681
+ var _a3;
682
+ onChangeHandler({
683
+ id: "responseImportType",
684
+ value: __spreadProps(__spreadValues({}, option), {
685
+ value: {
686
+ type: value2,
687
+ value: value2,
688
+ label: (_a3 = dynamicDateOptions.find(
689
+ (option2) => option2.value === value2
690
+ )) == null ? void 0 : _a3.label
691
+ }
692
+ })
693
+ });
694
+ }
695
+ },
696
+ dynamicDateOptions.map((option2) => /* @__PURE__ */ React__default.createElement(
697
+ Box,
698
+ {
699
+ css: {
700
+ padding: "$4 !important"
701
+ }
702
+ },
703
+ /* @__PURE__ */ React__default.createElement(Radio, { value: option2.value }, " ", option2.label, " ")
704
+ ))
705
+ ),
706
+ ((_a2 = value == null ? void 0 : value.value) == null ? void 0 : _a2.type) === "custom" && /* @__PURE__ */ React__default.createElement(
707
+ Box,
708
+ {
709
+ css: {
710
+ paddingRight: "$4 !important",
711
+ position: "relative"
712
+ }
713
+ },
714
+ /* @__PURE__ */ React__default.createElement(
715
+ Input,
716
+ {
717
+ size: "md",
718
+ variant: "filled",
719
+ value: days,
720
+ onChange: (e) => setDays(e.target.value)
721
+ }
722
+ ),
723
+ /* @__PURE__ */ React__default.createElement(
724
+ Text,
725
+ {
726
+ css: {
727
+ position: "absolute",
728
+ right: "$8",
729
+ top: "$3"
730
+ }
731
+ },
732
+ "Days"
733
+ )
734
+ ),
735
+ /* @__PURE__ */ React__default.createElement(
736
+ Flex,
737
+ {
738
+ justifyContent: "space-between",
739
+ css: {
740
+ borderBlockStart: "$borderWidths$xs, solid, $neutral200 !important",
741
+ padding: "$8"
742
+ }
743
+ },
744
+ /* @__PURE__ */ React__default.createElement(Button, { size: "sm", variant: "ghost", color: "secondary" }, "Cancel"),
745
+ /* @__PURE__ */ React__default.createElement(
746
+ Button,
747
+ {
748
+ size: "sm",
749
+ variant: "ghost",
750
+ color: "primary",
751
+ onClick: () => {
752
+ var _a3, _b2;
753
+ onChangeHandler({
754
+ id: "responseImportType",
755
+ value: __spreadProps(__spreadValues({}, option), {
756
+ value: {
757
+ type: (_a3 = value == null ? void 0 : value.value) == null ? void 0 : _a3.type,
758
+ value: days,
759
+ label: (_b2 = value == null ? void 0 : value.value) == null ? void 0 : _b2.label
760
+ }
761
+ })
762
+ });
763
+ setOpen(false);
764
+ }
765
+ },
766
+ "Apply"
767
+ )
768
+ )
769
+ )
770
+ )))
771
+ );
772
+ }
773
+ })
774
+ ));
775
+ };
776
+ const Configuration = ({
777
+ field,
778
+ configuredFields,
779
+ responseImportType = null
780
+ }) => {
781
+ var _a, _b, _c, _d;
782
+ let fieldValue = null;
783
+ fieldValue = (_b = (_a = configuredFields == null ? void 0 : configuredFields[field.id]) == null ? void 0 : _a.value) != null ? _b : null;
784
+ const [error, setError] = useState({
785
+ errorMessage: "",
786
+ error: false,
787
+ id: null
788
+ });
789
+ switch (field.fieldType) {
790
+ case "switch":
791
+ return /* @__PURE__ */ React__default.createElement(
792
+ Flex,
793
+ {
794
+ gap: "$4",
795
+ alignItems: "center",
796
+ css: {
797
+ marginBlockStart: "$12",
798
+ borderTop: "$borderWidths$xs solid $neutral200",
799
+ paddingTop: "$16"
800
+ }
801
+ },
802
+ /* @__PURE__ */ React__default.createElement(
803
+ Switch,
804
+ {
805
+ disabled: field == null ? void 0 : field.disabled,
806
+ size: "sm",
807
+ checked: field == null ? void 0 : field.value,
808
+ onChange: (value) => field.onChangeHandler({
809
+ id: field.id,
810
+ value
811
+ })
812
+ }
813
+ ),
814
+ /* @__PURE__ */ React__default.createElement(Text, { size: "md", weight: "regular", css: { color: "$neutral900" } }, field.label)
815
+ );
816
+ case "checkbox":
817
+ return /* @__PURE__ */ React__default.createElement(Flex, { flexDirection: "column", alignItems: "start", gap: "$4" }, /* @__PURE__ */ React__default.createElement(Flex, { gap: "$4", alignItems: "center" }, /* @__PURE__ */ React__default.createElement(
818
+ Checkbox,
819
+ {
820
+ disabled: field == null ? void 0 : field.disabled,
821
+ checked: !!fieldValue,
822
+ onChange: (value) => field.onChangeHandler({
823
+ id: field.id,
824
+ value
825
+ })
826
+ }
827
+ ), /* @__PURE__ */ React__default.createElement(Text, { size: "sm", weight: "regular", css: { color: "$neutral900" } }, field.label)), /* @__PURE__ */ React__default.createElement(Text, { size: "sm", weight: "regular", css: { color: "$neutral500" } }, field.value ? field.ifChecked() : field.ifUnchecked(responseImportType)));
828
+ case "input":
829
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, (field == null ? void 0 : field.id) === "spreadsheet" ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, ((_c = configuredFields == null ? void 0 : configuredFields.action) == null ? void 0 : _c.value) ? /* @__PURE__ */ React__default.createElement(
830
+ Box,
831
+ {
832
+ className: "dm-sans",
833
+ css: {
834
+ label: {
835
+ fontSize: "$xs !important"
836
+ }
837
+ }
838
+ },
839
+ /* @__PURE__ */ React__default.createElement(
840
+ FormInput,
841
+ __spreadProps(__spreadValues(__spreadProps(__spreadValues({
842
+ disabled: field == null ? void 0 : field.disabled
843
+ }, error.id === field.id && {
844
+ error: error.errorMessage,
845
+ errorBorder: error.error
846
+ }), {
847
+ label: field.label,
848
+ value: typeof fieldValue === "object" ? "" : fieldValue || "",
849
+ size: "lg"
850
+ }), field.pattern && {
851
+ pattern: field.pattern
852
+ }), {
853
+ onChange: (event) => {
854
+ if (field == null ? void 0 : field.pattern) {
855
+ const pattern = new RegExp(field.pattern);
856
+ if (!pattern.test(event.currentTarget.value) && event.currentTarget.value !== "") {
857
+ setError({
858
+ errorMessage: field.errorMessage,
859
+ error: true,
860
+ id: field.id
861
+ });
862
+ } else {
863
+ setError({
864
+ errorMessage: "",
865
+ error: false,
866
+ id: null
867
+ });
868
+ }
869
+ field.onChangeHandler({
870
+ id: field.id,
871
+ value: event.currentTarget.value
872
+ });
873
+ } else {
874
+ field.onChangeHandler({
875
+ id: field.id,
876
+ value: event.currentTarget.value
877
+ });
878
+ }
879
+ }
880
+ })
881
+ )
882
+ ) : null) : /* @__PURE__ */ React__default.createElement(
883
+ Box,
884
+ {
885
+ className: "dm-sans",
886
+ css: {
887
+ label: {
888
+ fontSize: "$xs !important"
889
+ }
890
+ }
891
+ },
892
+ /* @__PURE__ */ React__default.createElement(
893
+ FormInput,
894
+ __spreadProps(__spreadValues(__spreadProps(__spreadValues({
895
+ disabled: field == null ? void 0 : field.disabled
896
+ }, error.id === field.id && {
897
+ error: error.errorMessage,
898
+ errorBorder: error.error
899
+ }), {
900
+ label: field.label,
901
+ value: typeof fieldValue === "object" ? "" : fieldValue || "",
902
+ size: "lg"
903
+ }), field.pattern && {
904
+ pattern: field.pattern
905
+ }), {
906
+ onChange: (event) => {
907
+ if (field == null ? void 0 : field.pattern) {
908
+ const pattern = new RegExp(field.pattern);
909
+ if (!pattern.test(event.currentTarget.value) && event.currentTarget.value !== "") {
910
+ setError({
911
+ errorMessage: field.errorMessage,
912
+ error: true,
913
+ id: field.id
914
+ });
915
+ } else {
916
+ setError({
917
+ errorMessage: "",
918
+ error: false,
919
+ id: null
920
+ });
921
+ }
922
+ field.onChangeHandler({
923
+ id: field.id,
924
+ value: event.currentTarget.value
925
+ });
926
+ } else {
927
+ field.onChangeHandler({
928
+ id: field.id,
929
+ value: event.currentTarget.value
930
+ });
931
+ }
932
+ }
933
+ })
934
+ )
935
+ ));
936
+ default:
937
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, field.id === "spreadsheet" ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, ((_d = configuredFields == null ? void 0 : configuredFields.action) == null ? void 0 : _d.value) ? /* @__PURE__ */ React__default.createElement(
938
+ Flex,
939
+ {
940
+ gap: "$2",
941
+ flexDirection: "column",
942
+ css: {
943
+ cursor: "pointer !important",
944
+ ".twigs-select__indicator": {
945
+ width: "14px !important",
946
+ color: "#848484 !important"
947
+ }
948
+ }
949
+ },
950
+ /* @__PURE__ */ React__default.createElement(FormLabel, { size: "xs", css: { fontWeight: "$5" } }, field.label),
951
+ /* @__PURE__ */ React__default.createElement(CustomAddNewSelect, { field })
952
+ ) : null) : /* @__PURE__ */ React__default.createElement(
953
+ Flex,
954
+ {
955
+ gap: "$2",
956
+ flexDirection: "column",
957
+ css: {
958
+ cursor: "pointer !important",
959
+ ".twigs-select__indicator": {
960
+ width: "14px !important",
961
+ color: "#848484 !important"
962
+ }
963
+ }
964
+ },
965
+ /* @__PURE__ */ React__default.createElement(FormLabel, { size: "xs", css: { fontWeight: "$5" } }, field.label),
966
+ /* @__PURE__ */ React__default.createElement(CustomAddNewSelect, { field })
967
+ ));
968
+ }
969
+ };
970
+ const CustomAddNewSelect = ({ field }) => {
971
+ return /* @__PURE__ */ React__default.createElement(
972
+ Select,
973
+ {
974
+ isDisabled: field == null ? void 0 : field.disabled,
975
+ placeholder: "",
976
+ size: "lg",
977
+ css: {
978
+ cursor: "pointer"
979
+ },
980
+ components: {
981
+ Option: CustomShareOption,
982
+ SingleValue: CustomSingleValue
983
+ },
984
+ styles: {
985
+ singleValue: (provided, state) => __spreadProps(__spreadValues({}, provided), {
986
+ display: "flex",
987
+ alignItems: "center",
988
+ cursor: "pointer"
989
+ })
990
+ },
991
+ value: field.value,
992
+ onChange: (value) => {
993
+ var _a;
994
+ field.onChangeHandler({
995
+ id: (_a = field == null ? void 0 : field.id) != null ? _a : field == null ? void 0 : field.label,
996
+ value
997
+ });
998
+ },
999
+ options: field.options
1000
+ }
1001
+ );
1002
+ };
1003
+ const CustomShareOption = (props) => {
1004
+ if (props.data.value === "ADD_NEW") {
1005
+ return /* @__PURE__ */ React__default.createElement(
1006
+ Tooltip,
1007
+ {
1008
+ content: props.data.tooltip || "",
1009
+ css: {
1010
+ zIndex: 999999999,
1011
+ fontFamily: "DM Sans !important"
1012
+ }
1013
+ },
1014
+ /* @__PURE__ */ React__default.createElement(Box, null, /* @__PURE__ */ React__default.createElement(components.Option, __spreadValues({}, props), /* @__PURE__ */ React__default.createElement(
1015
+ Flex,
1016
+ {
1017
+ justifyContent: "center",
1018
+ alignItems: "center",
1019
+ css: { cursor: "pointer", zIndex: 999999999 }
1020
+ },
1021
+ /* @__PURE__ */ React__default.createElement(
1022
+ Flex,
1023
+ {
1024
+ gap: "$2",
1025
+ alignItems: "center",
1026
+ css: {
1027
+ color: "$primary500",
1028
+ fontSize: "$sm",
1029
+ fontWeight: "$7"
1030
+ }
1031
+ },
1032
+ /* @__PURE__ */ React__default.createElement(PlusIcon, { size: 16, color: "#4A9CA6" }),
1033
+ "Add Account"
1034
+ )
1035
+ )))
1036
+ );
1037
+ } else {
1038
+ return /* @__PURE__ */ React__default.createElement(components.Option, __spreadValues({}, props), /* @__PURE__ */ React__default.createElement(
1039
+ Flex,
1040
+ {
1041
+ css: { cursor: "pointer", zIndex: 999999999 },
1042
+ alignItems: "center",
1043
+ justifyContent: "space-between",
1044
+ gap: "$2"
1045
+ },
1046
+ /* @__PURE__ */ React__default.createElement(Text, { size: "sm" }, props.label),
1047
+ " ",
1048
+ props.data.isAddonAccount && /* @__PURE__ */ React__default.createElement(
1049
+ Chip,
1050
+ {
1051
+ color: "primary",
1052
+ size: "sm",
1053
+ leftElement: /* @__PURE__ */ React__default.createElement(TickCircleFillIcon, null)
1054
+ },
1055
+ "In Use (Add-on)"
1056
+ )
1057
+ ));
1058
+ }
1059
+ };
1060
+ const CustomSingleValue = (props) => {
1061
+ if (props.data.value === "ADD_NEW") {
1062
+ return /* @__PURE__ */ React__default.createElement(components.SingleValue, __spreadValues({}, props), /* @__PURE__ */ React__default.createElement(Flex, { css: { cursor: "pointer" }, alignItems: "center", gap: "$2" }, /* @__PURE__ */ React__default.createElement(PlusIcon, { size: 16 }), /* @__PURE__ */ React__default.createElement(Text, { size: "sm" }, props.data.label)));
1063
+ } else {
1064
+ return /* @__PURE__ */ React__default.createElement(components.SingleValue, __spreadValues({}, props), /* @__PURE__ */ React__default.createElement(Flex, { css: { cursor: "pointer" }, alignItems: "center", gap: "$2" }, /* @__PURE__ */ React__default.createElement(Text, { size: "sm" }, props.data.label)));
1065
+ }
1066
+ };
1067
+
1068
+ export { DynamicMapping };
1069
+ //# sourceMappingURL=index.js.map