@bigbinary/neeto-molecules 4.0.54 → 4.0.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Chevron-DX-gOKBh.js → Chevron-DXA34GCh.js} +2 -2
- package/dist/{Chevron-DX-gOKBh.js.map → Chevron-DXA34GCh.js.map} +1 -1
- package/dist/ConfigurePageSidebar.js +1 -1
- package/dist/ErrorPage.js +1 -1
- package/dist/OptionFields.js +605 -471
- package/dist/OptionFields.js.map +1 -1
- package/dist/Schedule.js +7 -6
- package/dist/Schedule.js.map +1 -1
- package/dist/Sidebar.js +2 -1
- package/dist/Sidebar.js.map +1 -1
- package/dist/cjs/{Chevron-BF749Dye.js → Chevron-C5y6R4rr.js} +2 -2
- package/dist/cjs/{Chevron-BF749Dye.js.map → Chevron-C5y6R4rr.js.map} +1 -1
- package/dist/cjs/ConfigurePageSidebar.js +1 -1
- package/dist/cjs/ErrorPage.js +1 -1
- package/dist/cjs/OptionFields.js +603 -469
- package/dist/cjs/OptionFields.js.map +1 -1
- package/dist/cjs/Schedule.js +7 -6
- package/dist/cjs/Schedule.js.map +1 -1
- package/dist/cjs/Sidebar.js +2 -1
- package/dist/cjs/Sidebar.js.map +1 -1
- package/package.json +1 -1
- package/types/OptionFields.d.ts +3 -0
package/dist/OptionFields.js
CHANGED
|
@@ -3,27 +3,29 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
3
3
|
import { useState, useRef } from 'react';
|
|
4
4
|
import { DragDropContext, Droppable, Draggable } from '@hello-pangea/dnd';
|
|
5
5
|
import { useField, FieldArray } from 'formik';
|
|
6
|
-
import {
|
|
6
|
+
import { slugify, isNotPresent, findIndexById, isNotEmpty, noop } from '@bigbinary/neeto-cist';
|
|
7
7
|
import Plus from '@bigbinary/neeto-icons/Plus';
|
|
8
8
|
import Button from '@bigbinary/neetoui/Button';
|
|
9
|
-
import { identity, reject, prop, pluck, clone, insert, move, assocPath, remove, append
|
|
9
|
+
import { isEmpty, identity, reject, prop, pluck, clone, insert, move, assocPath, remove, append } from 'ramda';
|
|
10
10
|
import { useTranslation, Trans } from 'react-i18next';
|
|
11
11
|
import Modal from '@bigbinary/neetoui/Modal';
|
|
12
12
|
import Textarea from '@bigbinary/neetoui/Textarea';
|
|
13
13
|
import Typography from '@bigbinary/neetoui/Typography';
|
|
14
14
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
15
15
|
import i18next, { t } from 'i18next';
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import { withT } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
19
|
-
import Edit from '@bigbinary/neeto-icons/Edit';
|
|
16
|
+
import Editor from '@bigbinary/neeto-editor/Editor';
|
|
17
|
+
import Checkbox$1 from '@bigbinary/neetoui/Checkbox';
|
|
20
18
|
import Drag from '@bigbinary/neeto-icons/Drag';
|
|
19
|
+
import { withT } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
21
20
|
import Copy from '@bigbinary/neeto-icons/Copy';
|
|
22
21
|
import Delete from '@bigbinary/neeto-icons/Delete';
|
|
23
|
-
import Input from '@bigbinary/neetoui/formik/Input';
|
|
24
|
-
import Textarea$1 from '@bigbinary/neetoui/formik/Textarea';
|
|
25
22
|
import ImageUploader from '@bigbinary/neeto-image-uploader-frontend/ImageUploader';
|
|
26
23
|
import classnames from 'classnames';
|
|
24
|
+
import Input from '@bigbinary/neetoui/formik/Input';
|
|
25
|
+
import Textarea$1 from '@bigbinary/neetoui/formik/Textarea';
|
|
26
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
27
|
+
import { n } from './inject-css-C2dztUxs.js';
|
|
28
|
+
import Edit from '@bigbinary/neeto-icons/Edit';
|
|
27
29
|
|
|
28
30
|
var BulkOptionModal = function BulkOptionModal(_ref) {
|
|
29
31
|
var isOpen = _ref.isOpen,
|
|
@@ -94,39 +96,407 @@ var BulkOptionModal = function BulkOptionModal(_ref) {
|
|
|
94
96
|
});
|
|
95
97
|
};
|
|
96
98
|
|
|
97
|
-
var
|
|
98
|
-
var
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
99
|
+
var Checkbox = function Checkbox(_ref) {
|
|
100
|
+
var name = _ref.name,
|
|
101
|
+
optionIndex = _ref.optionIndex;
|
|
102
|
+
var checkboxName = name.replace(".label", ".selected");
|
|
103
|
+
var _useField = useField(checkboxName),
|
|
104
|
+
_useField2 = _slicedToArray(_useField, 3),
|
|
105
|
+
value = _useField2[0].value;
|
|
106
|
+
_useField2[1];
|
|
107
|
+
var setValue = _useField2[2].setValue;
|
|
108
|
+
return /*#__PURE__*/jsx("div", {
|
|
109
|
+
className: "flex h-8 flex-shrink-0 items-center",
|
|
110
|
+
children: /*#__PURE__*/jsx(Checkbox$1, {
|
|
111
|
+
checked: value || false,
|
|
112
|
+
"data-testid": "checkbox-option-".concat(optionIndex),
|
|
113
|
+
onChange: function onChange(e) {
|
|
114
|
+
setValue(e.target.checked);
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
});
|
|
109
118
|
};
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
|
|
120
|
+
function ownKeys$8(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
121
|
+
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
122
|
+
var DragHandle = function DragHandle(props) {
|
|
123
|
+
return /*#__PURE__*/jsx("div", _objectSpread$8(_objectSpread$8({
|
|
124
|
+
className: "neeto-ui-text-gray-500 flex h-8 flex-shrink-0 cursor-grab items-center",
|
|
125
|
+
"data-cy": "drag-handle",
|
|
126
|
+
"data-testid": "drag-handle"
|
|
127
|
+
}, props), {}, {
|
|
128
|
+
children: /*#__PURE__*/jsx(Drag, {
|
|
129
|
+
size: 16,
|
|
130
|
+
strokeWidth: 2
|
|
131
|
+
})
|
|
132
|
+
}));
|
|
119
133
|
};
|
|
120
134
|
|
|
121
|
-
var
|
|
122
|
-
var
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
var OptionActions = withT(function (_ref) {
|
|
136
|
+
var t = _ref.t,
|
|
137
|
+
disabled = _ref.disabled,
|
|
138
|
+
_ref$hideCloneOption = _ref.hideCloneOption,
|
|
139
|
+
hideCloneOption = _ref$hideCloneOption === void 0 ? false : _ref$hideCloneOption,
|
|
140
|
+
_ref$hideDeleteOption = _ref.hideDeleteOption,
|
|
141
|
+
hideDeleteOption = _ref$hideDeleteOption === void 0 ? false : _ref$hideDeleteOption,
|
|
142
|
+
optionIndex = _ref.optionIndex,
|
|
143
|
+
id = _ref.id,
|
|
144
|
+
arrayHelpers = _ref.arrayHelpers,
|
|
145
|
+
onClone = _ref.onClone,
|
|
146
|
+
onDelete = _ref.onDelete,
|
|
147
|
+
_ref$className = _ref.className,
|
|
148
|
+
className = _ref$className === void 0 ? "" : _ref$className;
|
|
149
|
+
return /*#__PURE__*/jsxs("div", {
|
|
150
|
+
className: "flex items-center gap-1 ".concat(className),
|
|
151
|
+
children: [!hideCloneOption && /*#__PURE__*/jsx(Button, {
|
|
152
|
+
disabled: disabled,
|
|
153
|
+
className: "p-0.5",
|
|
154
|
+
"data-cy": "clone-option-button-".concat(optionIndex),
|
|
155
|
+
"data-testid": "clone-option-button-".concat(optionIndex),
|
|
156
|
+
icon: Copy,
|
|
157
|
+
size: "small",
|
|
158
|
+
style: "text",
|
|
159
|
+
tooltipProps: {
|
|
160
|
+
content: t("neetoMolecules.common.actions.clone"),
|
|
161
|
+
position: "top",
|
|
162
|
+
touch: ["hold", 500]
|
|
163
|
+
},
|
|
164
|
+
onClick: function onClick() {
|
|
165
|
+
return onClone(id);
|
|
166
|
+
}
|
|
167
|
+
}), !hideDeleteOption && /*#__PURE__*/jsx(Button, {
|
|
168
|
+
disabled: disabled,
|
|
169
|
+
className: "p-0.5",
|
|
170
|
+
"data-cy": "delete-option-button-".concat(optionIndex),
|
|
171
|
+
"data-testid": "delete-option-button-".concat(optionIndex),
|
|
172
|
+
icon: Delete,
|
|
173
|
+
size: "small",
|
|
174
|
+
style: "text",
|
|
175
|
+
tooltipProps: {
|
|
176
|
+
content: t("neetoMolecules.common.actions.delete"),
|
|
177
|
+
position: "top",
|
|
178
|
+
touch: ["hold", 500]
|
|
179
|
+
},
|
|
180
|
+
onClick: function onClick() {
|
|
181
|
+
return onDelete(id, arrayHelpers);
|
|
182
|
+
}
|
|
183
|
+
})]
|
|
129
184
|
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
function ownKeys$7(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
188
|
+
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
189
|
+
var EditorOption = function EditorOption(_ref) {
|
|
190
|
+
var innerRef = _ref.innerRef,
|
|
191
|
+
draggableProps = _ref.draggableProps,
|
|
192
|
+
dragHandleProps = _ref.dragHandleProps,
|
|
193
|
+
isDraggable = _ref.isDraggable,
|
|
194
|
+
optionIndex = _ref.optionIndex,
|
|
195
|
+
isCheckboxEnabled = _ref.isCheckboxEnabled,
|
|
196
|
+
name = _ref.name,
|
|
197
|
+
disabled = _ref.disabled,
|
|
198
|
+
placeholder = _ref.placeholder,
|
|
199
|
+
shouldFocus = _ref.shouldFocus,
|
|
200
|
+
_onChange = _ref.onChange,
|
|
201
|
+
_onBlur = _ref.onBlur,
|
|
202
|
+
id = _ref.id,
|
|
203
|
+
arrayHelpers = _ref.arrayHelpers,
|
|
204
|
+
hideCloneOption = _ref.hideCloneOption,
|
|
205
|
+
hideDeleteOption = _ref.hideDeleteOption,
|
|
206
|
+
onClone = _ref.onClone,
|
|
207
|
+
onDelete = _ref.onDelete;
|
|
208
|
+
var _useField = useField(name),
|
|
209
|
+
_useField2 = _slicedToArray(_useField, 1),
|
|
210
|
+
field = _useField2[0];
|
|
211
|
+
return /*#__PURE__*/jsx("div", _objectSpread$7(_objectSpread$7({
|
|
212
|
+
ref: innerRef
|
|
213
|
+
}, _objectSpread$7(_objectSpread$7({}, draggableProps), dragHandleProps)), {}, {
|
|
214
|
+
"data-cy": "form-block-options",
|
|
215
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
216
|
+
className: "nf-input-options group relative mb-2 flex items-start gap-1",
|
|
217
|
+
children: [isDraggable && /*#__PURE__*/jsx(DragHandle, _objectSpread$7(_objectSpread$7({}, dragHandleProps), {}, {
|
|
218
|
+
"data-testid": "drag-handle-".concat(optionIndex)
|
|
219
|
+
})), isCheckboxEnabled && /*#__PURE__*/jsx(Checkbox, {
|
|
220
|
+
name: name,
|
|
221
|
+
optionIndex: optionIndex
|
|
222
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
223
|
+
className: "flex w-full items-start gap-2",
|
|
224
|
+
children: [/*#__PURE__*/jsx(Editor, {
|
|
225
|
+
disabled: disabled,
|
|
226
|
+
name: name,
|
|
227
|
+
placeholder: placeholder,
|
|
228
|
+
autoFocus: shouldFocus,
|
|
229
|
+
className: "flex-1",
|
|
230
|
+
"data-cy": "editor-option-".concat(optionIndex),
|
|
231
|
+
"data-testid": "editor-option-".concat(optionIndex),
|
|
232
|
+
initialValue: field.value,
|
|
233
|
+
onChange: function onChange(value) {
|
|
234
|
+
return _onChange({
|
|
235
|
+
id: id,
|
|
236
|
+
value: value
|
|
237
|
+
});
|
|
238
|
+
},
|
|
239
|
+
onBlur: function onBlur(value) {
|
|
240
|
+
_onChange({
|
|
241
|
+
id: id,
|
|
242
|
+
value: value,
|
|
243
|
+
isOnBlur: true
|
|
244
|
+
});
|
|
245
|
+
_onBlur === null || _onBlur === void 0 || _onBlur(id, value);
|
|
246
|
+
}
|
|
247
|
+
}), /*#__PURE__*/jsx("div", {
|
|
248
|
+
className: "absolute right-2 top-2",
|
|
249
|
+
children: /*#__PURE__*/jsx(OptionActions, {
|
|
250
|
+
arrayHelpers: arrayHelpers,
|
|
251
|
+
disabled: disabled,
|
|
252
|
+
hideCloneOption: hideCloneOption,
|
|
253
|
+
hideDeleteOption: hideDeleteOption,
|
|
254
|
+
id: id,
|
|
255
|
+
onClone: onClone,
|
|
256
|
+
onDelete: onDelete,
|
|
257
|
+
optionIndex: optionIndex
|
|
258
|
+
})
|
|
259
|
+
})]
|
|
260
|
+
})]
|
|
261
|
+
})
|
|
262
|
+
}));
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
266
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
267
|
+
var ImageOption = function ImageOption(_ref) {
|
|
268
|
+
var id = _ref.id,
|
|
269
|
+
name = _ref.name,
|
|
270
|
+
optionIndex = _ref.optionIndex,
|
|
271
|
+
disabled = _ref.disabled,
|
|
272
|
+
placeholder = _ref.placeholder,
|
|
273
|
+
shouldFocus = _ref.shouldFocus,
|
|
274
|
+
onKeyDown = _ref.onKeyDown,
|
|
275
|
+
_onChange = _ref.onChange,
|
|
276
|
+
_onBlur = _ref.onBlur,
|
|
277
|
+
onDelete = _ref.onDelete,
|
|
278
|
+
onClone = _ref.onClone,
|
|
279
|
+
arrayHelpers = _ref.arrayHelpers,
|
|
280
|
+
_ref$hideDeleteOption = _ref.hideDeleteOption,
|
|
281
|
+
hideDeleteOption = _ref$hideDeleteOption === void 0 ? false : _ref$hideDeleteOption,
|
|
282
|
+
_ref$hideCloneOption = _ref.hideCloneOption,
|
|
283
|
+
hideCloneOption = _ref$hideCloneOption === void 0 ? false : _ref$hideCloneOption,
|
|
284
|
+
innerRef = _ref.innerRef,
|
|
285
|
+
draggableProps = _ref.draggableProps,
|
|
286
|
+
dragHandleProps = _ref.dragHandleProps,
|
|
287
|
+
isDraggable = _ref.isDraggable,
|
|
288
|
+
isCheckboxEnabled = _ref.isCheckboxEnabled,
|
|
289
|
+
isEditor = _ref.isEditor;
|
|
290
|
+
var imageFieldName = name.replace(".label", ".image");
|
|
291
|
+
var _useField = useField(name),
|
|
292
|
+
_useField2 = _slicedToArray(_useField, 1),
|
|
293
|
+
field = _useField2[0];
|
|
294
|
+
var _useField3 = useField(imageFieldName),
|
|
295
|
+
_useField4 = _slicedToArray(_useField3, 3);
|
|
296
|
+
_useField4[0];
|
|
297
|
+
var image = _useField4[1].value,
|
|
298
|
+
setValue = _useField4[2].setValue;
|
|
299
|
+
var handleImageChange = function handleImageChange(changedImage) {
|
|
300
|
+
var imageValue = isEmpty(changedImage === null || changedImage === void 0 ? void 0 : changedImage.url) ? null : changedImage;
|
|
301
|
+
setValue(imageValue, false);
|
|
302
|
+
_onChange({
|
|
303
|
+
id: id,
|
|
304
|
+
value: imageValue,
|
|
305
|
+
isOnBlur: false,
|
|
306
|
+
fieldType: "image"
|
|
307
|
+
});
|
|
308
|
+
};
|
|
309
|
+
return /*#__PURE__*/jsx("div", _objectSpread$6(_objectSpread$6({
|
|
310
|
+
ref: innerRef
|
|
311
|
+
}, _objectSpread$6(_objectSpread$6({}, draggableProps), dragHandleProps)), {}, {
|
|
312
|
+
"data-cy": "form-block-options",
|
|
313
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
314
|
+
className: "nf-input-options group relative mb-2 flex items-start gap-1",
|
|
315
|
+
children: [isDraggable && /*#__PURE__*/jsx(DragHandle, _objectSpread$6(_objectSpread$6({}, dragHandleProps), {}, {
|
|
316
|
+
"data-testid": "drag-handle-".concat(optionIndex)
|
|
317
|
+
})), isCheckboxEnabled && /*#__PURE__*/jsx(Checkbox, {
|
|
318
|
+
name: name,
|
|
319
|
+
optionIndex: optionIndex
|
|
320
|
+
}), /*#__PURE__*/jsx("div", {
|
|
321
|
+
className: classnames("flex w-full items-center justify-center", {
|
|
322
|
+
"pointer-events-none opacity-80": disabled
|
|
323
|
+
}),
|
|
324
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
325
|
+
className: "neeto-ui-rounded-lg neeto-ui-border-gray-200 neeto-molecules-option-fields__image-option neeto-ui-bg-white group relative flex w-full flex-col gap-2 border p-2 pr-8",
|
|
326
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
327
|
+
className: "neeto-molecules-option-fields__image-uploader-container flex-shrink-0",
|
|
328
|
+
"data-testid": "picture-choice-option-".concat(optionIndex),
|
|
329
|
+
children: /*#__PURE__*/jsx(ImageUploader, {
|
|
330
|
+
className: "neeto-molecules-option-fields__image-uploader w-full",
|
|
331
|
+
isOptionsDisabled: disabled,
|
|
332
|
+
src: image === null || image === void 0 ? void 0 : image.url,
|
|
333
|
+
uploadConfig: IMAGE_UPLOAD_CONFIG,
|
|
334
|
+
onUploadComplete: handleImageChange
|
|
335
|
+
}, image === null || image === void 0 ? void 0 : image.url)
|
|
336
|
+
}), /*#__PURE__*/jsx("div", {
|
|
337
|
+
className: "w-full",
|
|
338
|
+
children: isEditor ? /*#__PURE__*/jsx(Editor, {
|
|
339
|
+
disabled: disabled,
|
|
340
|
+
name: name,
|
|
341
|
+
placeholder: placeholder,
|
|
342
|
+
autoFocus: shouldFocus,
|
|
343
|
+
className: "flex-1",
|
|
344
|
+
"data-cy": "editor-option-".concat(optionIndex),
|
|
345
|
+
"data-testid": "editor-option-".concat(optionIndex),
|
|
346
|
+
initialValue: field.value,
|
|
347
|
+
onChange: function onChange(value) {
|
|
348
|
+
return _onChange({
|
|
349
|
+
id: id,
|
|
350
|
+
value: value
|
|
351
|
+
});
|
|
352
|
+
},
|
|
353
|
+
onBlur: function onBlur(value) {
|
|
354
|
+
_onChange({
|
|
355
|
+
id: id,
|
|
356
|
+
value: value,
|
|
357
|
+
isOnBlur: true
|
|
358
|
+
});
|
|
359
|
+
_onBlur === null || _onBlur === void 0 || _onBlur(id, value);
|
|
360
|
+
}
|
|
361
|
+
}) : /*#__PURE__*/jsx(Input, _defineProperty(_defineProperty({
|
|
362
|
+
disabled: disabled,
|
|
363
|
+
name: name,
|
|
364
|
+
onBlur: _onBlur,
|
|
365
|
+
onKeyDown: onKeyDown,
|
|
366
|
+
placeholder: placeholder,
|
|
367
|
+
autoFocus: shouldFocus,
|
|
368
|
+
"data-cy": "option-input-".concat(optionIndex),
|
|
369
|
+
"data-testid": "input-option-".concat(optionIndex),
|
|
370
|
+
onFocus: function onFocus(_ref2) {
|
|
371
|
+
var target = _ref2.target;
|
|
372
|
+
return target.select();
|
|
373
|
+
}
|
|
374
|
+
}, "onBlur", function onBlur(event) {
|
|
375
|
+
_onChange({
|
|
376
|
+
id: id,
|
|
377
|
+
value: event.target.value,
|
|
378
|
+
isOnBlur: true
|
|
379
|
+
});
|
|
380
|
+
_onBlur === null || _onBlur === void 0 || _onBlur(id, event.target.value);
|
|
381
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
382
|
+
args[_key - 1] = arguments[_key];
|
|
383
|
+
}
|
|
384
|
+
field.onBlur.apply(field, [event].concat(args));
|
|
385
|
+
}), "onChange", function onChange(_ref3) {
|
|
386
|
+
var target = _ref3.target;
|
|
387
|
+
return _onChange({
|
|
388
|
+
id: id,
|
|
389
|
+
value: target.value
|
|
390
|
+
});
|
|
391
|
+
}))
|
|
392
|
+
}), /*#__PURE__*/jsx("div", {
|
|
393
|
+
className: "absolute right-3 top-1/2 flex -translate-y-1/2 items-center gap-1 opacity-0 transition-opacity duration-200 group-hover:opacity-100",
|
|
394
|
+
children: /*#__PURE__*/jsx(OptionActions, {
|
|
395
|
+
arrayHelpers: arrayHelpers,
|
|
396
|
+
disabled: disabled,
|
|
397
|
+
hideCloneOption: hideCloneOption,
|
|
398
|
+
hideDeleteOption: hideDeleteOption,
|
|
399
|
+
id: id,
|
|
400
|
+
onClone: onClone,
|
|
401
|
+
onDelete: onDelete,
|
|
402
|
+
optionIndex: optionIndex
|
|
403
|
+
})
|
|
404
|
+
})]
|
|
405
|
+
})
|
|
406
|
+
})]
|
|
407
|
+
})
|
|
408
|
+
}));
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
412
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
413
|
+
var InputOption = function InputOption(_ref) {
|
|
414
|
+
var shouldFocus = _ref.shouldFocus,
|
|
415
|
+
_ref$hideDeleteOption = _ref.hideDeleteOption,
|
|
416
|
+
hideDeleteOption = _ref$hideDeleteOption === void 0 ? false : _ref$hideDeleteOption,
|
|
417
|
+
_ref$hideCloneOption = _ref.hideCloneOption,
|
|
418
|
+
hideCloneOption = _ref$hideCloneOption === void 0 ? false : _ref$hideCloneOption,
|
|
419
|
+
innerRef = _ref.innerRef,
|
|
420
|
+
draggableProps = _ref.draggableProps,
|
|
421
|
+
dragHandleProps = _ref.dragHandleProps,
|
|
422
|
+
onKeyDown = _ref.onKeyDown,
|
|
423
|
+
onDelete = _ref.onDelete,
|
|
424
|
+
onClone = _ref.onClone,
|
|
425
|
+
_onChange = _ref.onChange,
|
|
426
|
+
optionIndex = _ref.optionIndex,
|
|
427
|
+
disabled = _ref.disabled,
|
|
428
|
+
isTextArea = _ref.isTextArea,
|
|
429
|
+
id = _ref.id,
|
|
430
|
+
isDraggable = _ref.isDraggable,
|
|
431
|
+
name = _ref.name,
|
|
432
|
+
placeholder = _ref.placeholder,
|
|
433
|
+
_onBlur = _ref.onBlur,
|
|
434
|
+
arrayHelpers = _ref.arrayHelpers,
|
|
435
|
+
_ref$isCheckboxEnable = _ref.isCheckboxEnabled,
|
|
436
|
+
isCheckboxEnabled = _ref$isCheckboxEnable === void 0 ? false : _ref$isCheckboxEnable;
|
|
437
|
+
var Component = isTextArea ? Textarea$1 : Input;
|
|
438
|
+
var _useField = useField(name),
|
|
439
|
+
_useField2 = _slicedToArray(_useField, 1),
|
|
440
|
+
field = _useField2[0];
|
|
441
|
+
return /*#__PURE__*/jsx("div", _objectSpread$5(_objectSpread$5({
|
|
442
|
+
ref: innerRef
|
|
443
|
+
}, _objectSpread$5(_objectSpread$5({}, draggableProps), dragHandleProps)), {}, {
|
|
444
|
+
"data-cy": "form-block-options",
|
|
445
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
446
|
+
className: "nf-input-options group relative mb-2 flex items-start gap-1",
|
|
447
|
+
children: [isDraggable && /*#__PURE__*/jsx(DragHandle, _objectSpread$5(_objectSpread$5({}, dragHandleProps), {}, {
|
|
448
|
+
"data-testid": "drag-handle-".concat(optionIndex)
|
|
449
|
+
})), isCheckboxEnabled && /*#__PURE__*/jsx(Checkbox, {
|
|
450
|
+
name: name,
|
|
451
|
+
optionIndex: optionIndex
|
|
452
|
+
}), /*#__PURE__*/jsx("div", {
|
|
453
|
+
className: "flex w-full items-start gap-2",
|
|
454
|
+
children: /*#__PURE__*/jsx(Component, {
|
|
455
|
+
disabled: disabled,
|
|
456
|
+
name: name,
|
|
457
|
+
onKeyDown: onKeyDown,
|
|
458
|
+
placeholder: placeholder,
|
|
459
|
+
autoFocus: shouldFocus,
|
|
460
|
+
className: "flex-1",
|
|
461
|
+
"data-cy": "option-input-".concat(optionIndex),
|
|
462
|
+
"data-testid": "".concat(isTextArea ? "textarea-option" : "input-option", "-").concat(optionIndex),
|
|
463
|
+
suffix: /*#__PURE__*/jsx(OptionActions, {
|
|
464
|
+
arrayHelpers: arrayHelpers,
|
|
465
|
+
disabled: disabled,
|
|
466
|
+
hideCloneOption: hideCloneOption,
|
|
467
|
+
hideDeleteOption: hideDeleteOption,
|
|
468
|
+
id: id,
|
|
469
|
+
onClone: onClone,
|
|
470
|
+
onDelete: onDelete,
|
|
471
|
+
optionIndex: optionIndex
|
|
472
|
+
}),
|
|
473
|
+
onChange: function onChange(_ref2) {
|
|
474
|
+
var target = _ref2.target;
|
|
475
|
+
return _onChange({
|
|
476
|
+
id: id,
|
|
477
|
+
value: target.value
|
|
478
|
+
});
|
|
479
|
+
},
|
|
480
|
+
onFocus: function onFocus(_ref3) {
|
|
481
|
+
var target = _ref3.target;
|
|
482
|
+
return target.select();
|
|
483
|
+
},
|
|
484
|
+
onBlur: function onBlur(event) {
|
|
485
|
+
_onChange({
|
|
486
|
+
id: id,
|
|
487
|
+
value: event.target.value,
|
|
488
|
+
isOnBlur: true
|
|
489
|
+
});
|
|
490
|
+
_onBlur === null || _onBlur === void 0 || _onBlur(id, event.target.value);
|
|
491
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
492
|
+
args[_key - 1] = arguments[_key];
|
|
493
|
+
}
|
|
494
|
+
field.onBlur.apply(field, [event].concat(args));
|
|
495
|
+
}
|
|
496
|
+
})
|
|
497
|
+
})]
|
|
498
|
+
})
|
|
499
|
+
}));
|
|
130
500
|
};
|
|
131
501
|
|
|
132
502
|
var getOrderedOptions = function getOrderedOptions() {
|
|
@@ -204,11 +574,160 @@ var getMultiInputError = function getMultiInputError(isMultiInput, meta) {
|
|
|
204
574
|
return null;
|
|
205
575
|
};
|
|
206
576
|
|
|
207
|
-
function ownKeys$
|
|
208
|
-
function _objectSpread$
|
|
577
|
+
function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
578
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
579
|
+
var MultiInputOption = withT(function (_ref) {
|
|
580
|
+
var shouldFocus = _ref.shouldFocus,
|
|
581
|
+
_ref$hideDeleteOption = _ref.hideDeleteOption,
|
|
582
|
+
hideDeleteOption = _ref$hideDeleteOption === void 0 ? false : _ref$hideDeleteOption,
|
|
583
|
+
_ref$hideCloneOption = _ref.hideCloneOption,
|
|
584
|
+
hideCloneOption = _ref$hideCloneOption === void 0 ? false : _ref$hideCloneOption,
|
|
585
|
+
innerRef = _ref.innerRef,
|
|
586
|
+
draggableProps = _ref.draggableProps,
|
|
587
|
+
dragHandleProps = _ref.dragHandleProps,
|
|
588
|
+
_onKeyDown = _ref.onKeyDown,
|
|
589
|
+
onDelete = _ref.onDelete,
|
|
590
|
+
onClone = _ref.onClone,
|
|
591
|
+
_onChange = _ref.onChange,
|
|
592
|
+
optionIndex = _ref.optionIndex,
|
|
593
|
+
disabled = _ref.disabled,
|
|
594
|
+
id = _ref.id,
|
|
595
|
+
isDraggable = _ref.isDraggable,
|
|
596
|
+
name = _ref.name,
|
|
597
|
+
placeholder = _ref.placeholder,
|
|
598
|
+
_onBlur = _ref.onBlur,
|
|
599
|
+
arrayHelpers = _ref.arrayHelpers,
|
|
600
|
+
_ref$inputConfig = _ref.inputConfig,
|
|
601
|
+
inputConfig = _ref$inputConfig === void 0 ? [] : _ref$inputConfig,
|
|
602
|
+
isCheckboxEnabled = _ref.isCheckboxEnabled;
|
|
603
|
+
return /*#__PURE__*/jsx("div", _objectSpread$4(_objectSpread$4({
|
|
604
|
+
ref: innerRef
|
|
605
|
+
}, _objectSpread$4(_objectSpread$4({}, draggableProps), dragHandleProps)), {}, {
|
|
606
|
+
"data-cy": "form-block-multi-options",
|
|
607
|
+
"data-testid": "form-block-multi-options",
|
|
608
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
609
|
+
className: "nf-multi-input-options group relative mb-2 flex items-center gap-1",
|
|
610
|
+
children: [isDraggable && /*#__PURE__*/jsx(DragHandle, _objectSpread$4(_objectSpread$4({}, dragHandleProps), {}, {
|
|
611
|
+
"data-testid": "drag-handle-".concat(optionIndex)
|
|
612
|
+
})), isCheckboxEnabled && /*#__PURE__*/jsx(Checkbox, {
|
|
613
|
+
name: name,
|
|
614
|
+
optionIndex: optionIndex
|
|
615
|
+
}), /*#__PURE__*/jsx("div", {
|
|
616
|
+
className: "flex flex-1 flex-col gap-2",
|
|
617
|
+
children: /*#__PURE__*/jsx("div", {
|
|
618
|
+
className: "flex gap-2",
|
|
619
|
+
children: inputConfig.map(function (config, inputIndex) {
|
|
620
|
+
var _field$value;
|
|
621
|
+
var inputName = "".concat(name.replace(".label", ""), ".values.").concat(inputIndex);
|
|
622
|
+
var inputType = config.type || INPUT_TYPES.TEXT;
|
|
623
|
+
var isNumberType = inputType === INPUT_TYPES.NUMBER;
|
|
624
|
+
var _useField = useField(inputName),
|
|
625
|
+
_useField2 = _slicedToArray(_useField, 1),
|
|
626
|
+
field = _useField2[0];
|
|
627
|
+
return /*#__PURE__*/jsx("div", {
|
|
628
|
+
className: "flex-1",
|
|
629
|
+
children: /*#__PURE__*/jsx(Input, _objectSpread$4(_objectSpread$4({
|
|
630
|
+
disabled: disabled,
|
|
631
|
+
autoFocus: shouldFocus && inputIndex === 0,
|
|
632
|
+
"data-cy": "multi-option-input-".concat(optionIndex, "-").concat(inputIndex),
|
|
633
|
+
"data-testid": "multi-option-input-".concat(optionIndex, "-").concat(inputIndex)
|
|
634
|
+
}, isNumberType && {
|
|
635
|
+
min: config.min,
|
|
636
|
+
max: config.max
|
|
637
|
+
}), {}, {
|
|
638
|
+
name: inputName,
|
|
639
|
+
type: inputType,
|
|
640
|
+
value: (_field$value = field.value) !== null && _field$value !== void 0 ? _field$value : config.defaultValue,
|
|
641
|
+
placeholder: config.placeholder || "".concat(placeholder, " ").concat(inputIndex + 1),
|
|
642
|
+
onFocus: function onFocus(_ref2) {
|
|
643
|
+
var target = _ref2.target;
|
|
644
|
+
return target.select();
|
|
645
|
+
},
|
|
646
|
+
onBlur: function onBlur(event) {
|
|
647
|
+
return handleInputBlur(event, {
|
|
648
|
+
id: id,
|
|
649
|
+
inputIndex: inputIndex,
|
|
650
|
+
onChange: _onChange,
|
|
651
|
+
onBlur: _onBlur,
|
|
652
|
+
field: field,
|
|
653
|
+
config: config
|
|
654
|
+
});
|
|
655
|
+
},
|
|
656
|
+
onChange: function onChange(_ref3) {
|
|
657
|
+
var target = _ref3.target;
|
|
658
|
+
return _onChange({
|
|
659
|
+
id: id,
|
|
660
|
+
value: target.value,
|
|
661
|
+
inputIndex: inputIndex
|
|
662
|
+
});
|
|
663
|
+
},
|
|
664
|
+
onKeyDown: function onKeyDown(event) {
|
|
665
|
+
return isNumberType ? handleNumberKeyDown(event, _onKeyDown) : _onKeyDown === null || _onKeyDown === void 0 ? void 0 : _onKeyDown(event);
|
|
666
|
+
}
|
|
667
|
+
}))
|
|
668
|
+
}, inputIndex);
|
|
669
|
+
})
|
|
670
|
+
})
|
|
671
|
+
}), /*#__PURE__*/jsx(OptionActions, {
|
|
672
|
+
arrayHelpers: arrayHelpers,
|
|
673
|
+
disabled: disabled,
|
|
674
|
+
hideCloneOption: hideCloneOption,
|
|
675
|
+
hideDeleteOption: hideDeleteOption,
|
|
676
|
+
id: id,
|
|
677
|
+
onClone: onClone,
|
|
678
|
+
onDelete: onDelete,
|
|
679
|
+
optionIndex: optionIndex
|
|
680
|
+
})]
|
|
681
|
+
})
|
|
682
|
+
}));
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
var DEFAULT_OPTION_LABEL = i18next.t("neetoMolecules.optionFields.defaultOption");
|
|
686
|
+
var IMAGE_UPLOAD_CONFIG = {
|
|
687
|
+
maxImageSize: 1,
|
|
688
|
+
allowedImageTypes: {
|
|
689
|
+
"image/jpg": [".jpg", ".jpeg"],
|
|
690
|
+
"image/png": [".png"],
|
|
691
|
+
"image/svg": [".svg"]
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
var INPUT_TYPES = {
|
|
695
|
+
TEXT: "text",
|
|
696
|
+
NUMBER: "number"
|
|
697
|
+
};
|
|
698
|
+
var OPTION_ACTIONS = {
|
|
699
|
+
UPDATE_IMAGE: "update_image",
|
|
700
|
+
UPDATE_VALUES: "update_values",
|
|
701
|
+
UPDATE_LABEL: "update_label",
|
|
702
|
+
DELETE: "delete",
|
|
703
|
+
REORDER: "reorder",
|
|
704
|
+
ADD: "add",
|
|
705
|
+
BULK_ADD: "bulk_add",
|
|
706
|
+
CLONE: "clone"
|
|
707
|
+
};
|
|
708
|
+
var OPTION_MAP = {
|
|
709
|
+
multiInput: MultiInputOption,
|
|
710
|
+
pictureChoice: ImageOption,
|
|
711
|
+
editor: EditorOption,
|
|
712
|
+
input: InputOption
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
var FormError = function FormError(_ref) {
|
|
716
|
+
var error = _ref.error;
|
|
717
|
+
if (isNotPresent(error) || typeof error !== "string") return null;
|
|
718
|
+
return /*#__PURE__*/jsx(Typography, {
|
|
719
|
+
className: "neeto-ui-input__error",
|
|
720
|
+
"data-testid": "validation-error-container",
|
|
721
|
+
style: "body3",
|
|
722
|
+
children: error
|
|
723
|
+
});
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
727
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
209
728
|
var attachPosition = function attachPosition(options) {
|
|
210
729
|
return options.map(function (option, index) {
|
|
211
|
-
return _objectSpread$
|
|
730
|
+
return _objectSpread$3(_objectSpread$3({}, option), {}, {
|
|
212
731
|
position: index
|
|
213
732
|
});
|
|
214
733
|
});
|
|
@@ -318,7 +837,7 @@ var useOptionFields = function useOptionFields(_ref) {
|
|
|
318
837
|
var handleAddOption = function handleAddOption() {
|
|
319
838
|
var id = randomId();
|
|
320
839
|
var position = options.length;
|
|
321
|
-
var newOption = _objectSpread$
|
|
840
|
+
var newOption = _objectSpread$3(_objectSpread$3({
|
|
322
841
|
id: "draft-".concat(id),
|
|
323
842
|
altId: "alt-".concat(id),
|
|
324
843
|
label: isNewItemsPrefilled ? _generateLabel(itemLabel, options) : "",
|
|
@@ -355,7 +874,7 @@ var useOptionFields = function useOptionFields(_ref) {
|
|
|
355
874
|
var optionToClone = options[index];
|
|
356
875
|
if (!optionToClone) return;
|
|
357
876
|
var newId = randomId();
|
|
358
|
-
var clonedOption = _objectSpread$
|
|
877
|
+
var clonedOption = _objectSpread$3(_objectSpread$3({}, optionToClone), {}, {
|
|
359
878
|
id: "draft-".concat(newId),
|
|
360
879
|
altId: "alt-".concat(newId),
|
|
361
880
|
label: isMultiInput ? optionToClone.label : t("neetoMolecules.optionFields.clonedOption", {
|
|
@@ -396,78 +915,11 @@ var useOptionFields = function useOptionFields(_ref) {
|
|
|
396
915
|
};
|
|
397
916
|
};
|
|
398
917
|
|
|
399
|
-
var css = ".neeto-molecules-option-fields__image-uploader img{max-height:100px}";
|
|
400
|
-
n(css,{});
|
|
401
|
-
|
|
402
|
-
function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
403
|
-
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
404
|
-
var DragHandle = function DragHandle(props) {
|
|
405
|
-
return /*#__PURE__*/jsx("div", _objectSpread$4(_objectSpread$4({
|
|
406
|
-
className: "neeto-ui-text-gray-500 flex h-8 flex-shrink-0 cursor-grab items-center",
|
|
407
|
-
"data-cy": "drag-handle",
|
|
408
|
-
"data-testid": "drag-handle"
|
|
409
|
-
}, props), {}, {
|
|
410
|
-
children: /*#__PURE__*/jsx(Drag, {
|
|
411
|
-
size: 16,
|
|
412
|
-
strokeWidth: 2
|
|
413
|
-
})
|
|
414
|
-
}));
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
var OptionActions = withT(function (_ref) {
|
|
418
|
-
var t = _ref.t,
|
|
419
|
-
disabled = _ref.disabled,
|
|
420
|
-
_ref$hideCloneOption = _ref.hideCloneOption,
|
|
421
|
-
hideCloneOption = _ref$hideCloneOption === void 0 ? false : _ref$hideCloneOption,
|
|
422
|
-
_ref$hideDeleteOption = _ref.hideDeleteOption,
|
|
423
|
-
hideDeleteOption = _ref$hideDeleteOption === void 0 ? false : _ref$hideDeleteOption,
|
|
424
|
-
optionIndex = _ref.optionIndex,
|
|
425
|
-
id = _ref.id,
|
|
426
|
-
arrayHelpers = _ref.arrayHelpers,
|
|
427
|
-
onClone = _ref.onClone,
|
|
428
|
-
onDelete = _ref.onDelete,
|
|
429
|
-
_ref$className = _ref.className,
|
|
430
|
-
className = _ref$className === void 0 ? "" : _ref$className;
|
|
431
|
-
return /*#__PURE__*/jsxs("div", {
|
|
432
|
-
className: "flex items-center gap-1 ".concat(className),
|
|
433
|
-
children: [!hideCloneOption && /*#__PURE__*/jsx(Button, {
|
|
434
|
-
disabled: disabled,
|
|
435
|
-
className: "p-0.5",
|
|
436
|
-
"data-cy": "clone-option-button-".concat(optionIndex),
|
|
437
|
-
"data-testid": "clone-option-button-".concat(optionIndex),
|
|
438
|
-
icon: Copy,
|
|
439
|
-
size: "small",
|
|
440
|
-
style: "text",
|
|
441
|
-
tooltipProps: {
|
|
442
|
-
content: t("neetoMolecules.common.actions.clone"),
|
|
443
|
-
position: "top",
|
|
444
|
-
touch: ["hold", 500]
|
|
445
|
-
},
|
|
446
|
-
onClick: function onClick() {
|
|
447
|
-
return onClone(id);
|
|
448
|
-
}
|
|
449
|
-
}), !hideDeleteOption && /*#__PURE__*/jsx(Button, {
|
|
450
|
-
disabled: disabled,
|
|
451
|
-
className: "p-0.5",
|
|
452
|
-
"data-cy": "delete-option-button-".concat(optionIndex),
|
|
453
|
-
"data-testid": "delete-option-button-".concat(optionIndex),
|
|
454
|
-
icon: Delete,
|
|
455
|
-
size: "small",
|
|
456
|
-
style: "text",
|
|
457
|
-
tooltipProps: {
|
|
458
|
-
content: t("neetoMolecules.common.actions.delete"),
|
|
459
|
-
position: "top",
|
|
460
|
-
touch: ["hold", 500]
|
|
461
|
-
},
|
|
462
|
-
onClick: function onClick() {
|
|
463
|
-
return onDelete(id, arrayHelpers);
|
|
464
|
-
}
|
|
465
|
-
})]
|
|
466
|
-
});
|
|
467
|
-
});
|
|
918
|
+
var css = ".neeto-molecules-option-fields__image-uploader img{max-height:100px}";
|
|
919
|
+
n(css,{});
|
|
468
920
|
|
|
469
|
-
function ownKeys$
|
|
470
|
-
function _objectSpread$
|
|
921
|
+
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
922
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
471
923
|
var BlockOption = withT(function (_ref) {
|
|
472
924
|
var t = _ref.t,
|
|
473
925
|
innerRef = _ref.innerRef,
|
|
@@ -484,16 +936,21 @@ var BlockOption = withT(function (_ref) {
|
|
|
484
936
|
id = _ref.id,
|
|
485
937
|
isDraggable = _ref.isDraggable,
|
|
486
938
|
optionIndex = _ref.optionIndex,
|
|
487
|
-
arrayHelpers = _ref.arrayHelpers
|
|
488
|
-
|
|
939
|
+
arrayHelpers = _ref.arrayHelpers,
|
|
940
|
+
isCheckboxEnabled = _ref.isCheckboxEnabled,
|
|
941
|
+
name = _ref.name;
|
|
942
|
+
return /*#__PURE__*/jsx("div", _objectSpread$2(_objectSpread$2(_objectSpread$2({
|
|
489
943
|
ref: innerRef
|
|
490
944
|
}, draggableProps), dragHandleProps), {}, {
|
|
491
945
|
children: /*#__PURE__*/jsxs("div", {
|
|
492
946
|
className: "neeto-ui-border-gray-400 hover:neeto-ui-bg-gray-200 neeto-ui-rounded-sm shadow-xs group relative mb-2 flex h-10 cursor-pointer items-center gap-2 border p-3 transition-colors duration-300 ease-in-out",
|
|
493
947
|
"data-cy": "address-field-block",
|
|
494
|
-
children: [isDraggable && /*#__PURE__*/jsx(DragHandle, _objectSpread$
|
|
948
|
+
children: [isDraggable && /*#__PURE__*/jsx(DragHandle, _objectSpread$2(_objectSpread$2({}, dragHandleProps), {}, {
|
|
495
949
|
"data-testid": "drag-handle-".concat(optionIndex)
|
|
496
|
-
})), /*#__PURE__*/jsx(
|
|
950
|
+
})), isCheckboxEnabled && /*#__PURE__*/jsx(Checkbox, {
|
|
951
|
+
name: name,
|
|
952
|
+
optionIndex: optionIndex
|
|
953
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
497
954
|
className: "flex-grow truncate leading-4",
|
|
498
955
|
"data-cy": "address-text-field",
|
|
499
956
|
"data-testid": "address-text-field",
|
|
@@ -531,310 +988,8 @@ var BlockOption = withT(function (_ref) {
|
|
|
531
988
|
}));
|
|
532
989
|
});
|
|
533
990
|
|
|
534
|
-
var ImageOption = function ImageOption(_ref) {
|
|
535
|
-
var id = _ref.id,
|
|
536
|
-
name = _ref.name,
|
|
537
|
-
optionIndex = _ref.optionIndex,
|
|
538
|
-
disabled = _ref.disabled,
|
|
539
|
-
field = _ref.field,
|
|
540
|
-
placeholder = _ref.placeholder,
|
|
541
|
-
shouldFocus = _ref.shouldFocus,
|
|
542
|
-
onKeyDown = _ref.onKeyDown,
|
|
543
|
-
_onChange = _ref.onChange,
|
|
544
|
-
_onBlur = _ref.onBlur,
|
|
545
|
-
onDelete = _ref.onDelete,
|
|
546
|
-
onClone = _ref.onClone,
|
|
547
|
-
arrayHelpers = _ref.arrayHelpers,
|
|
548
|
-
_ref$hideDeleteOption = _ref.hideDeleteOption,
|
|
549
|
-
hideDeleteOption = _ref$hideDeleteOption === void 0 ? false : _ref$hideDeleteOption,
|
|
550
|
-
_ref$hideCloneOption = _ref.hideCloneOption,
|
|
551
|
-
hideCloneOption = _ref$hideCloneOption === void 0 ? false : _ref$hideCloneOption;
|
|
552
|
-
var imageFieldName = name.replace(".label", ".image");
|
|
553
|
-
var _useField = useField(imageFieldName),
|
|
554
|
-
_useField2 = _slicedToArray(_useField, 3);
|
|
555
|
-
_useField2[0];
|
|
556
|
-
var image = _useField2[1].value,
|
|
557
|
-
setValue = _useField2[2].setValue;
|
|
558
|
-
var handleImageChange = function handleImageChange(changedImage) {
|
|
559
|
-
var imageValue = isEmpty(changedImage === null || changedImage === void 0 ? void 0 : changedImage.url) ? null : changedImage;
|
|
560
|
-
setValue(imageValue, false);
|
|
561
|
-
_onChange({
|
|
562
|
-
id: id,
|
|
563
|
-
value: imageValue,
|
|
564
|
-
isOnBlur: false,
|
|
565
|
-
fieldType: "image"
|
|
566
|
-
});
|
|
567
|
-
};
|
|
568
|
-
return /*#__PURE__*/jsx("div", {
|
|
569
|
-
className: classnames("flex w-full items-center justify-center", {
|
|
570
|
-
"pointer-events-none opacity-80": disabled
|
|
571
|
-
}),
|
|
572
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
573
|
-
className: "neeto-ui-rounded-lg neeto-ui-border-gray-200 neeto-molecules-option-fields__image-option neeto-ui-bg-white group relative flex w-full flex-col gap-2 border p-2 pr-8",
|
|
574
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
575
|
-
className: "neeto-molecules-option-fields__image-uploader-container flex-shrink-0",
|
|
576
|
-
"data-testid": "picture-choice-option-".concat(optionIndex),
|
|
577
|
-
children: /*#__PURE__*/jsx(ImageUploader, {
|
|
578
|
-
className: "neeto-molecules-option-fields__image-uploader w-full",
|
|
579
|
-
isOptionsDisabled: disabled,
|
|
580
|
-
src: image === null || image === void 0 ? void 0 : image.url,
|
|
581
|
-
uploadConfig: IMAGE_UPLOAD_CONFIG,
|
|
582
|
-
onUploadComplete: handleImageChange
|
|
583
|
-
}, image === null || image === void 0 ? void 0 : image.url)
|
|
584
|
-
}), /*#__PURE__*/jsx("div", {
|
|
585
|
-
className: "w-full",
|
|
586
|
-
children: /*#__PURE__*/jsx(Input, _defineProperty({
|
|
587
|
-
disabled: disabled,
|
|
588
|
-
name: name,
|
|
589
|
-
onBlur: _onBlur,
|
|
590
|
-
onKeyDown: onKeyDown,
|
|
591
|
-
placeholder: placeholder,
|
|
592
|
-
autoFocus: shouldFocus,
|
|
593
|
-
"data-cy": "option-input-".concat(optionIndex),
|
|
594
|
-
"data-testid": "input-option-".concat(optionIndex),
|
|
595
|
-
onChange: function onChange(_ref2) {
|
|
596
|
-
var target = _ref2.target;
|
|
597
|
-
return _onChange({
|
|
598
|
-
id: id,
|
|
599
|
-
value: target.value
|
|
600
|
-
});
|
|
601
|
-
},
|
|
602
|
-
onFocus: function onFocus(_ref3) {
|
|
603
|
-
var target = _ref3.target;
|
|
604
|
-
return target.select();
|
|
605
|
-
}
|
|
606
|
-
}, "onBlur", function onBlur(event) {
|
|
607
|
-
_onChange({
|
|
608
|
-
id: id,
|
|
609
|
-
value: event.target.value,
|
|
610
|
-
isOnBlur: true
|
|
611
|
-
});
|
|
612
|
-
_onBlur === null || _onBlur === void 0 || _onBlur(id, event.target.value);
|
|
613
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
614
|
-
args[_key - 1] = arguments[_key];
|
|
615
|
-
}
|
|
616
|
-
field.onBlur.apply(field, [event].concat(args));
|
|
617
|
-
}))
|
|
618
|
-
}), /*#__PURE__*/jsx("div", {
|
|
619
|
-
className: "absolute right-3 top-1/2 flex -translate-y-1/2 items-center gap-1 opacity-0 transition-opacity duration-200 group-hover:opacity-100",
|
|
620
|
-
children: /*#__PURE__*/jsx(OptionActions, {
|
|
621
|
-
arrayHelpers: arrayHelpers,
|
|
622
|
-
disabled: disabled,
|
|
623
|
-
hideCloneOption: hideCloneOption,
|
|
624
|
-
hideDeleteOption: hideDeleteOption,
|
|
625
|
-
id: id,
|
|
626
|
-
onClone: onClone,
|
|
627
|
-
onDelete: onDelete,
|
|
628
|
-
optionIndex: optionIndex
|
|
629
|
-
})
|
|
630
|
-
})]
|
|
631
|
-
})
|
|
632
|
-
});
|
|
633
|
-
};
|
|
634
|
-
|
|
635
|
-
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
636
|
-
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
637
|
-
var InputOption = function InputOption(_ref) {
|
|
638
|
-
var shouldFocus = _ref.shouldFocus,
|
|
639
|
-
_ref$hideDeleteOption = _ref.hideDeleteOption,
|
|
640
|
-
hideDeleteOption = _ref$hideDeleteOption === void 0 ? false : _ref$hideDeleteOption,
|
|
641
|
-
_ref$hideCloneOption = _ref.hideCloneOption,
|
|
642
|
-
hideCloneOption = _ref$hideCloneOption === void 0 ? false : _ref$hideCloneOption,
|
|
643
|
-
innerRef = _ref.innerRef,
|
|
644
|
-
draggableProps = _ref.draggableProps,
|
|
645
|
-
dragHandleProps = _ref.dragHandleProps,
|
|
646
|
-
isPictureChoice = _ref.isPictureChoice,
|
|
647
|
-
onKeyDown = _ref.onKeyDown,
|
|
648
|
-
onDelete = _ref.onDelete,
|
|
649
|
-
onClone = _ref.onClone,
|
|
650
|
-
_onChange = _ref.onChange,
|
|
651
|
-
optionIndex = _ref.optionIndex,
|
|
652
|
-
disabled = _ref.disabled,
|
|
653
|
-
isTextArea = _ref.isTextArea,
|
|
654
|
-
id = _ref.id,
|
|
655
|
-
isDraggable = _ref.isDraggable,
|
|
656
|
-
name = _ref.name,
|
|
657
|
-
placeholder = _ref.placeholder,
|
|
658
|
-
_onBlur = _ref.onBlur,
|
|
659
|
-
arrayHelpers = _ref.arrayHelpers;
|
|
660
|
-
var Component = isTextArea ? Textarea$1 : Input;
|
|
661
|
-
var _useField = useField(name),
|
|
662
|
-
_useField2 = _slicedToArray(_useField, 1),
|
|
663
|
-
field = _useField2[0];
|
|
664
|
-
return /*#__PURE__*/jsx("div", _objectSpread$2(_objectSpread$2({
|
|
665
|
-
ref: innerRef
|
|
666
|
-
}, _objectSpread$2(_objectSpread$2({}, draggableProps), dragHandleProps)), {}, {
|
|
667
|
-
"data-cy": "form-block-options",
|
|
668
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
669
|
-
className: "nf-input-options group relative mb-2 flex items-start gap-1",
|
|
670
|
-
children: [isDraggable && /*#__PURE__*/jsx(DragHandle, _objectSpread$2(_objectSpread$2({}, dragHandleProps), {}, {
|
|
671
|
-
"data-testid": "drag-handle-".concat(optionIndex)
|
|
672
|
-
})), isPictureChoice ? /*#__PURE__*/jsx(ImageOption, {
|
|
673
|
-
arrayHelpers: arrayHelpers,
|
|
674
|
-
disabled: disabled,
|
|
675
|
-
field: field,
|
|
676
|
-
hideCloneOption: hideCloneOption,
|
|
677
|
-
hideDeleteOption: hideDeleteOption,
|
|
678
|
-
id: id,
|
|
679
|
-
name: name,
|
|
680
|
-
onBlur: _onBlur,
|
|
681
|
-
onChange: _onChange,
|
|
682
|
-
onClone: onClone,
|
|
683
|
-
onDelete: onDelete,
|
|
684
|
-
onKeyDown: onKeyDown,
|
|
685
|
-
optionIndex: optionIndex,
|
|
686
|
-
placeholder: placeholder,
|
|
687
|
-
shouldFocus: shouldFocus
|
|
688
|
-
}) : /*#__PURE__*/jsx(Component, {
|
|
689
|
-
disabled: disabled,
|
|
690
|
-
name: name,
|
|
691
|
-
onKeyDown: onKeyDown,
|
|
692
|
-
placeholder: placeholder,
|
|
693
|
-
autoFocus: shouldFocus,
|
|
694
|
-
"data-cy": "option-input-".concat(optionIndex),
|
|
695
|
-
"data-testid": "".concat(isTextArea ? "textarea-option" : "input-option", "-").concat(optionIndex),
|
|
696
|
-
suffix: /*#__PURE__*/jsx(OptionActions, {
|
|
697
|
-
arrayHelpers: arrayHelpers,
|
|
698
|
-
disabled: disabled,
|
|
699
|
-
hideCloneOption: hideCloneOption,
|
|
700
|
-
hideDeleteOption: hideDeleteOption,
|
|
701
|
-
id: id,
|
|
702
|
-
onClone: onClone,
|
|
703
|
-
onDelete: onDelete,
|
|
704
|
-
optionIndex: optionIndex
|
|
705
|
-
}),
|
|
706
|
-
onChange: function onChange(_ref2) {
|
|
707
|
-
var target = _ref2.target;
|
|
708
|
-
return _onChange({
|
|
709
|
-
id: id,
|
|
710
|
-
value: target.value
|
|
711
|
-
});
|
|
712
|
-
},
|
|
713
|
-
onFocus: function onFocus(_ref3) {
|
|
714
|
-
var target = _ref3.target;
|
|
715
|
-
return target.select();
|
|
716
|
-
},
|
|
717
|
-
onBlur: function onBlur(event) {
|
|
718
|
-
_onChange({
|
|
719
|
-
id: id,
|
|
720
|
-
value: event.target.value,
|
|
721
|
-
isOnBlur: true
|
|
722
|
-
});
|
|
723
|
-
_onBlur === null || _onBlur === void 0 || _onBlur(id, event.target.value);
|
|
724
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
725
|
-
args[_key - 1] = arguments[_key];
|
|
726
|
-
}
|
|
727
|
-
field.onBlur.apply(field, [event].concat(args));
|
|
728
|
-
}
|
|
729
|
-
})]
|
|
730
|
-
})
|
|
731
|
-
}));
|
|
732
|
-
};
|
|
733
|
-
|
|
734
991
|
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
735
992
|
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
736
|
-
var MultiInputOption = withT(function (_ref) {
|
|
737
|
-
var shouldFocus = _ref.shouldFocus,
|
|
738
|
-
_ref$hideDeleteOption = _ref.hideDeleteOption,
|
|
739
|
-
hideDeleteOption = _ref$hideDeleteOption === void 0 ? false : _ref$hideDeleteOption,
|
|
740
|
-
_ref$hideCloneOption = _ref.hideCloneOption,
|
|
741
|
-
hideCloneOption = _ref$hideCloneOption === void 0 ? false : _ref$hideCloneOption,
|
|
742
|
-
innerRef = _ref.innerRef,
|
|
743
|
-
draggableProps = _ref.draggableProps,
|
|
744
|
-
dragHandleProps = _ref.dragHandleProps,
|
|
745
|
-
_onKeyDown = _ref.onKeyDown,
|
|
746
|
-
onDelete = _ref.onDelete,
|
|
747
|
-
onClone = _ref.onClone,
|
|
748
|
-
_onChange = _ref.onChange,
|
|
749
|
-
optionIndex = _ref.optionIndex,
|
|
750
|
-
disabled = _ref.disabled,
|
|
751
|
-
id = _ref.id,
|
|
752
|
-
isDraggable = _ref.isDraggable,
|
|
753
|
-
name = _ref.name,
|
|
754
|
-
placeholder = _ref.placeholder,
|
|
755
|
-
_onBlur = _ref.onBlur,
|
|
756
|
-
arrayHelpers = _ref.arrayHelpers,
|
|
757
|
-
_ref$inputConfig = _ref.inputConfig,
|
|
758
|
-
inputConfig = _ref$inputConfig === void 0 ? [] : _ref$inputConfig;
|
|
759
|
-
return /*#__PURE__*/jsx("div", _objectSpread$1(_objectSpread$1({
|
|
760
|
-
ref: innerRef
|
|
761
|
-
}, _objectSpread$1(_objectSpread$1({}, draggableProps), dragHandleProps)), {}, {
|
|
762
|
-
"data-cy": "form-block-multi-options",
|
|
763
|
-
"data-testid": "form-block-multi-options",
|
|
764
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
765
|
-
className: "nf-multi-input-options group relative mb-2 flex items-center gap-1",
|
|
766
|
-
children: [isDraggable && /*#__PURE__*/jsx(DragHandle, _objectSpread$1(_objectSpread$1({}, dragHandleProps), {}, {
|
|
767
|
-
"data-testid": "drag-handle-".concat(optionIndex)
|
|
768
|
-
})), /*#__PURE__*/jsx("div", {
|
|
769
|
-
className: "flex flex-1 flex-col gap-2",
|
|
770
|
-
children: /*#__PURE__*/jsx("div", {
|
|
771
|
-
className: "flex gap-2",
|
|
772
|
-
children: inputConfig.map(function (config, inputIndex) {
|
|
773
|
-
var _field$value;
|
|
774
|
-
var inputName = "".concat(name.replace(".label", ""), ".values.").concat(inputIndex);
|
|
775
|
-
var inputType = config.type || INPUT_TYPES.TEXT;
|
|
776
|
-
var isNumberType = inputType === INPUT_TYPES.NUMBER;
|
|
777
|
-
var _useField = useField(inputName),
|
|
778
|
-
_useField2 = _slicedToArray(_useField, 1),
|
|
779
|
-
field = _useField2[0];
|
|
780
|
-
return /*#__PURE__*/jsx("div", {
|
|
781
|
-
className: "flex-1",
|
|
782
|
-
children: /*#__PURE__*/jsx(Input, _objectSpread$1(_objectSpread$1({
|
|
783
|
-
disabled: disabled,
|
|
784
|
-
autoFocus: shouldFocus && inputIndex === 0,
|
|
785
|
-
"data-cy": "multi-option-input-".concat(optionIndex, "-").concat(inputIndex),
|
|
786
|
-
"data-testid": "multi-option-input-".concat(optionIndex, "-").concat(inputIndex)
|
|
787
|
-
}, isNumberType && {
|
|
788
|
-
min: config.min,
|
|
789
|
-
max: config.max
|
|
790
|
-
}), {}, {
|
|
791
|
-
name: inputName,
|
|
792
|
-
type: inputType,
|
|
793
|
-
value: (_field$value = field.value) !== null && _field$value !== void 0 ? _field$value : config.defaultValue,
|
|
794
|
-
placeholder: config.placeholder || "".concat(placeholder, " ").concat(inputIndex + 1),
|
|
795
|
-
onFocus: function onFocus(_ref2) {
|
|
796
|
-
var target = _ref2.target;
|
|
797
|
-
return target.select();
|
|
798
|
-
},
|
|
799
|
-
onBlur: function onBlur(event) {
|
|
800
|
-
return handleInputBlur(event, {
|
|
801
|
-
id: id,
|
|
802
|
-
inputIndex: inputIndex,
|
|
803
|
-
onChange: _onChange,
|
|
804
|
-
onBlur: _onBlur,
|
|
805
|
-
field: field,
|
|
806
|
-
config: config
|
|
807
|
-
});
|
|
808
|
-
},
|
|
809
|
-
onChange: function onChange(_ref3) {
|
|
810
|
-
var target = _ref3.target;
|
|
811
|
-
return _onChange({
|
|
812
|
-
id: id,
|
|
813
|
-
value: target.value,
|
|
814
|
-
inputIndex: inputIndex
|
|
815
|
-
});
|
|
816
|
-
},
|
|
817
|
-
onKeyDown: function onKeyDown(event) {
|
|
818
|
-
return isNumberType ? handleNumberKeyDown(event, _onKeyDown) : _onKeyDown === null || _onKeyDown === void 0 ? void 0 : _onKeyDown(event);
|
|
819
|
-
}
|
|
820
|
-
}))
|
|
821
|
-
}, inputIndex);
|
|
822
|
-
})
|
|
823
|
-
})
|
|
824
|
-
}), /*#__PURE__*/jsx(OptionActions, {
|
|
825
|
-
arrayHelpers: arrayHelpers,
|
|
826
|
-
disabled: disabled,
|
|
827
|
-
hideCloneOption: hideCloneOption,
|
|
828
|
-
hideDeleteOption: hideDeleteOption,
|
|
829
|
-
id: id,
|
|
830
|
-
onClone: onClone,
|
|
831
|
-
onDelete: onDelete,
|
|
832
|
-
optionIndex: optionIndex
|
|
833
|
-
})]
|
|
834
|
-
})
|
|
835
|
-
}));
|
|
836
|
-
});
|
|
837
|
-
|
|
838
993
|
var OptionField = function OptionField(_ref) {
|
|
839
994
|
var option = _ref.option,
|
|
840
995
|
editable = _ref.editable,
|
|
@@ -848,9 +1003,11 @@ var OptionField = function OptionField(_ref) {
|
|
|
848
1003
|
onEdit = _ref.onEdit,
|
|
849
1004
|
draggable = _ref.draggable,
|
|
850
1005
|
disabled = _ref.disabled,
|
|
1006
|
+
isCheckboxEnabled = _ref.isCheckboxEnabled,
|
|
851
1007
|
isPictureChoice = _ref.isPictureChoice,
|
|
852
1008
|
isTextArea = _ref.isTextArea,
|
|
853
1009
|
isMultiInput = _ref.isMultiInput,
|
|
1010
|
+
isEditor = _ref.isEditor,
|
|
854
1011
|
inputConfig = _ref.inputConfig,
|
|
855
1012
|
shouldFocus = _ref.shouldFocus,
|
|
856
1013
|
isEditable = _ref.isEditable,
|
|
@@ -861,69 +1018,40 @@ var OptionField = function OptionField(_ref) {
|
|
|
861
1018
|
optionIndex = _ref.optionIndex,
|
|
862
1019
|
onBlur = _ref.onBlur,
|
|
863
1020
|
arrayHelpers = _ref.arrayHelpers;
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
arrayHelpers: arrayHelpers,
|
|
867
|
-
dragHandleProps: dragHandleProps,
|
|
868
|
-
draggableProps: draggableProps,
|
|
869
|
-
handleDeleteClick: handleDeleteClick,
|
|
870
|
-
hideCloneOption: hideCloneOption,
|
|
871
|
-
hideDeleteOption: hideDeleteOption,
|
|
872
|
-
innerRef: innerRef,
|
|
873
|
-
onEdit: onEdit,
|
|
874
|
-
optionIndex: optionIndex,
|
|
875
|
-
id: option.id,
|
|
876
|
-
isDraggable: draggable && !disabled,
|
|
877
|
-
label: option.label,
|
|
878
|
-
onClone: handleCloneClick
|
|
879
|
-
});
|
|
880
|
-
}
|
|
881
|
-
if (isMultiInput) {
|
|
882
|
-
return /*#__PURE__*/jsx(MultiInputOption, {
|
|
883
|
-
arrayHelpers: arrayHelpers,
|
|
884
|
-
dragHandleProps: dragHandleProps,
|
|
885
|
-
draggableProps: draggableProps,
|
|
886
|
-
hideCloneOption: hideCloneOption,
|
|
887
|
-
hideDeleteOption: hideDeleteOption,
|
|
888
|
-
innerRef: innerRef,
|
|
889
|
-
inputConfig: inputConfig,
|
|
890
|
-
name: name,
|
|
891
|
-
onBlur: onBlur,
|
|
892
|
-
option: option,
|
|
893
|
-
optionIndex: optionIndex,
|
|
894
|
-
shouldFocus: shouldFocus,
|
|
895
|
-
disabled: !isEditable || disabled,
|
|
896
|
-
id: option.id,
|
|
897
|
-
isDraggable: draggable && !disabled,
|
|
898
|
-
placeholder: generatePlaceholder(itemLabel, optionIndex),
|
|
899
|
-
onChange: handleChange,
|
|
900
|
-
onClone: handleCloneClick,
|
|
901
|
-
onDelete: handleDeleteClick,
|
|
902
|
-
onKeyDown: handleKeyDown
|
|
903
|
-
});
|
|
904
|
-
}
|
|
905
|
-
return /*#__PURE__*/jsx(InputOption, {
|
|
1021
|
+
var commonProps = {
|
|
1022
|
+
id: option.id,
|
|
906
1023
|
arrayHelpers: arrayHelpers,
|
|
907
1024
|
dragHandleProps: dragHandleProps,
|
|
908
1025
|
draggableProps: draggableProps,
|
|
909
1026
|
hideCloneOption: hideCloneOption,
|
|
910
1027
|
hideDeleteOption: hideDeleteOption,
|
|
911
1028
|
innerRef: innerRef,
|
|
912
|
-
|
|
913
|
-
isTextArea: isTextArea,
|
|
1029
|
+
isCheckboxEnabled: isCheckboxEnabled,
|
|
914
1030
|
name: name,
|
|
915
|
-
onBlur: onBlur,
|
|
916
1031
|
optionIndex: optionIndex,
|
|
917
|
-
shouldFocus: shouldFocus,
|
|
918
|
-
disabled: !isEditable || disabled,
|
|
919
|
-
id: option.id,
|
|
920
1032
|
isDraggable: draggable && !disabled,
|
|
1033
|
+
onClone: handleCloneClick
|
|
1034
|
+
};
|
|
1035
|
+
var Component = isMultiInput && OPTION_MAP.multiInput || isPictureChoice && OPTION_MAP.pictureChoice || isEditor && OPTION_MAP.editor || OPTION_MAP.input;
|
|
1036
|
+
return editable ? /*#__PURE__*/jsx(Component, _objectSpread$1(_objectSpread$1({}, _objectSpread$1(_objectSpread$1({}, commonProps), {}, {
|
|
1037
|
+
inputConfig: inputConfig,
|
|
1038
|
+
isEditor: isEditor,
|
|
1039
|
+
isTextArea: isTextArea,
|
|
1040
|
+
onBlur: onBlur,
|
|
1041
|
+
option: option,
|
|
1042
|
+
shouldFocus: shouldFocus
|
|
1043
|
+
})), {}, {
|
|
1044
|
+
disabled: !isEditable || disabled,
|
|
921
1045
|
placeholder: generatePlaceholder(itemLabel, optionIndex),
|
|
922
1046
|
onChange: handleChange,
|
|
923
|
-
onClone: handleCloneClick,
|
|
924
1047
|
onDelete: handleDeleteClick,
|
|
925
1048
|
onKeyDown: handleKeyDown
|
|
926
|
-
})
|
|
1049
|
+
})) : /*#__PURE__*/jsx(BlockOption, _objectSpread$1(_objectSpread$1({}, _objectSpread$1(_objectSpread$1({}, commonProps), {}, {
|
|
1050
|
+
handleDeleteClick: handleDeleteClick,
|
|
1051
|
+
onEdit: onEdit
|
|
1052
|
+
})), {}, {
|
|
1053
|
+
label: option.label
|
|
1054
|
+
}));
|
|
927
1055
|
};
|
|
928
1056
|
|
|
929
1057
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -954,12 +1082,16 @@ var OptionFields = function OptionFields(_ref) {
|
|
|
954
1082
|
isDeleteOptionEnabled = _ref$isDeleteOptionEn === void 0 ? true : _ref$isDeleteOptionEn,
|
|
955
1083
|
_ref$isCloneOptionEna = _ref.isCloneOptionEnabled,
|
|
956
1084
|
isCloneOptionEnabled = _ref$isCloneOptionEna === void 0 ? false : _ref$isCloneOptionEna,
|
|
1085
|
+
_ref$isCheckboxEnable = _ref.isCheckboxEnabled,
|
|
1086
|
+
isCheckboxEnabled = _ref$isCheckboxEnable === void 0 ? false : _ref$isCheckboxEnable,
|
|
957
1087
|
_ref$isPictureChoice = _ref.isPictureChoice,
|
|
958
1088
|
isPictureChoice = _ref$isPictureChoice === void 0 ? false : _ref$isPictureChoice,
|
|
959
1089
|
_ref$isTextArea = _ref.isTextArea,
|
|
960
1090
|
isTextArea = _ref$isTextArea === void 0 ? false : _ref$isTextArea,
|
|
961
1091
|
_ref$isMultiInput = _ref.isMultiInput,
|
|
962
1092
|
isMultiInput = _ref$isMultiInput === void 0 ? false : _ref$isMultiInput,
|
|
1093
|
+
_ref$isEditor = _ref.isEditor,
|
|
1094
|
+
isEditor = _ref$isEditor === void 0 ? false : _ref$isEditor,
|
|
963
1095
|
_ref$inputConfig = _ref.inputConfig,
|
|
964
1096
|
inputConfig = _ref$inputConfig === void 0 ? [] : _ref$inputConfig,
|
|
965
1097
|
_ref$shouldDestroy = _ref.shouldDestroy,
|
|
@@ -1017,7 +1149,7 @@ var OptionFields = function OptionFields(_ref) {
|
|
|
1017
1149
|
// This condition only needed for server id generated types
|
|
1018
1150
|
var isEditable = true;
|
|
1019
1151
|
if (shouldDestroy) isEditable = options.every(prop("id") || error);
|
|
1020
|
-
var orderedOptions = getOrderedOptions(options
|
|
1152
|
+
var orderedOptions = getOrderedOptions(options);
|
|
1021
1153
|
var filteredOptions = orderedOptions.filter(function (_ref2) {
|
|
1022
1154
|
var deleted = _ref2[destroyFlagName];
|
|
1023
1155
|
return !deleted;
|
|
@@ -1042,7 +1174,9 @@ var OptionFields = function OptionFields(_ref) {
|
|
|
1042
1174
|
itemLabel: itemLabel,
|
|
1043
1175
|
onEdit: onEdit,
|
|
1044
1176
|
onBlur: onBlur,
|
|
1045
|
-
shouldFocus: shouldFocus
|
|
1177
|
+
shouldFocus: shouldFocus,
|
|
1178
|
+
isCheckboxEnabled: isCheckboxEnabled,
|
|
1179
|
+
isEditor: isEditor
|
|
1046
1180
|
};
|
|
1047
1181
|
|
|
1048
1182
|
// To fix the element positioned incorrectly while dragging when in a pane or modal.
|