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