@panneau/field-upload 4.0.39 → 4.0.40-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +924 -443
  2. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -1,14 +1,11 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
3
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
- import _objectSpread from '@babel/runtime/helpers/objectSpread2';
1
+ import { c } from 'react/compiler-runtime';
5
2
  import { UppyContextProvider } from '@uppy/react';
6
3
  import Dashboard from '@uppy/react/dashboard';
7
4
  import DashboardModal from '@uppy/react/dashboard-modal';
8
5
  import classNames from 'classnames';
9
6
  import isArray from 'lodash/isArray';
10
7
  import isObject from 'lodash/isObject';
11
- import { useCallback, useMemo, useState, useRef, useEffect } from 'react';
8
+ import { useState, useRef, useEffect } from 'react';
12
9
  import { FormattedMessage } from 'react-intl';
13
10
  import { useQuery } from '@panneau/core/hooks';
14
11
  import Button from '@panneau/element-button';
@@ -19,323 +16,516 @@ import { useUppy } from '@panneau/uppy';
19
16
  import '@uppy/core/css/style.css';
20
17
  import '@uppy/dashboard/css/style.css';
21
18
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
22
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
23
19
 
24
20
  var styles = {"container":"panneau-field-upload-container","dashboard":"panneau-field-upload-dashboard","dashboardModal":"panneau-field-upload-dashboardModal"};
25
21
 
26
- var DEFAULT_TYPES = ['audio', 'image', 'video'];
27
- var DEFAULT_SOURCES = ['webcam', 'facebook', 'instagram', 'dropbox', 'google-drive'];
28
- function UploadField(_ref) {
29
- var _ref$resource = _ref.resource,
30
- resource = _ref$resource === void 0 ? 'medias' : _ref$resource,
31
- _ref$value = _ref.value,
32
- value = _ref$value === void 0 ? null : _ref$value,
33
- _ref$name = _ref.name,
34
- name = _ref$name === void 0 ? null : _ref$name,
35
- _ref$types = _ref.types,
36
- types = _ref$types === void 0 ? DEFAULT_TYPES : _ref$types,
37
- _ref$fileTypes = _ref.fileTypes,
38
- fileTypes = _ref$fileTypes === void 0 ? null : _ref$fileTypes,
39
- _ref$sources = _ref.sources,
40
- sources = _ref$sources === void 0 ? DEFAULT_SOURCES : _ref$sources,
41
- _ref$withButton = _ref.withButton,
42
- withButton = _ref$withButton === void 0 ? false : _ref$withButton,
43
- _ref$withFind = _ref.withFind,
44
- withFind = _ref$withFind === void 0 ? false : _ref$withFind,
45
- _ref$withClearButton = _ref.withClearButton,
46
- withClearButton = _ref$withClearButton === void 0 ? false : _ref$withClearButton,
47
- _ref$withoutMedia = _ref.withoutMedia,
48
- withoutMedia = _ref$withoutMedia === void 0 ? false : _ref$withoutMedia,
49
- _ref$addButtonLabel = _ref.addButtonLabel,
50
- initialAddButtonLabel = _ref$addButtonLabel === void 0 ? null : _ref$addButtonLabel,
51
- _ref$findButtonLabel = _ref.findButtonLabel,
52
- initialFindButtonLabel = _ref$findButtonLabel === void 0 ? null : _ref$findButtonLabel,
53
- _ref$clearButtonLabel = _ref.clearButtonLabel,
54
- initialCleanButtonLabel = _ref$clearButtonLabel === void 0 ? null : _ref$clearButtonLabel,
55
- _ref$allowMultipleUpl = _ref.allowMultipleUploads,
56
- allowMultipleUploads = _ref$allowMultipleUpl === void 0 ? false : _ref$allowMultipleUpl,
57
- _ref$closeAfterFinish = _ref.closeAfterFinish,
58
- closeAfterFinish = _ref$closeAfterFinish === void 0 ? true : _ref$closeAfterFinish,
59
- _ref$maxNumberOfFiles = _ref.maxNumberOfFiles,
60
- maxNumberOfFiles = _ref$maxNumberOfFiles === void 0 ? 1 : _ref$maxNumberOfFiles,
61
- _ref$namePath = _ref.namePath,
62
- namePath = _ref$namePath === void 0 ? 'name' : _ref$namePath,
63
- _ref$thumbnailPath = _ref.thumbnailPath,
64
- thumbnailPath = _ref$thumbnailPath === void 0 ? 'thumbnail_url' : _ref$thumbnailPath,
65
- _ref$sizePath = _ref.sizePath,
66
- sizePath = _ref$sizePath === void 0 ? 'metadata.size' : _ref$sizePath,
67
- _ref$linkPath = _ref.linkPath,
68
- linkPath = _ref$linkPath === void 0 ? null : _ref$linkPath,
69
- _ref$uppyProps = _ref.uppyProps,
70
- uppyProps = _ref$uppyProps === void 0 ? null : _ref$uppyProps,
71
- _ref$width = _ref.width,
72
- width = _ref$width === void 0 ? null : _ref$width,
73
- _ref$height = _ref.height,
74
- height = _ref$height === void 0 ? 300 : _ref$height,
75
- _ref$disabled = _ref.disabled,
76
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
77
- _ref$uploadDisabled = _ref.uploadDisabled,
78
- uploadDisabled = _ref$uploadDisabled === void 0 ? false : _ref$uploadDisabled,
79
- _ref$outline = _ref.outline,
80
- outline = _ref$outline === void 0 ? true : _ref$outline,
81
- _ref$loading = _ref.loading,
82
- parentLoading = _ref$loading === void 0 ? false : _ref$loading,
83
- _ref$onChange = _ref.onChange,
84
- onChange = _ref$onChange === void 0 ? null : _ref$onChange,
85
- _ref$onClear = _ref.onClear,
86
- onClear = _ref$onClear === void 0 ? null : _ref$onClear,
87
- _ref$onClickAdd = _ref.onClickAdd,
88
- onClickAdd = _ref$onClickAdd === void 0 ? null : _ref$onClickAdd,
89
- _ref$onClickFind = _ref.onClickFind,
90
- onClickFind = _ref$onClickFind === void 0 ? null : _ref$onClickFind,
91
- _ref$className = _ref.className,
92
- className = _ref$className === void 0 ? null : _ref$className;
93
- var addButtonLabel = initialAddButtonLabel || /*#__PURE__*/jsx(FormattedMessage, {
94
- id: "BeKVq6",
95
- defaultMessage: [{
96
- "type": 0,
97
- "value": "Upload file"
98
- }]
99
- });
100
- var findButtonLabel = initialFindButtonLabel || /*#__PURE__*/jsx(FormattedMessage, {
101
- id: "une5WQ",
102
- defaultMessage: [{
103
- "type": 0,
104
- "value": "Find a file"
105
- }]
106
- });
107
- var clearButtonLabel = initialCleanButtonLabel || /*#__PURE__*/jsx(FormattedMessage, {
108
- id: "odaCUe",
109
- defaultMessage: [{
110
- "type": 0,
111
- "value": "Clear"
112
- }]
113
- });
114
- var mergeData = useCallback(function (newValue) {
115
- // Merge the response from our back-end
116
- if (isObject(newValue) && isObject(newValue.response) && newValue.response.status === 200 && newValue.response.body !== null) {
117
- return _objectSpread(_objectSpread({}, newValue), newValue.response.body || null);
118
- }
119
- return newValue;
120
- }, []);
121
- var onComplete = useCallback(function (response) {
122
- var newValue = null;
123
- if (isArray(response)) {
124
- if (allowMultipleUploads) {
125
- newValue = response;
22
+ const DEFAULT_TYPES = ['audio', 'image', 'video'];
23
+ const DEFAULT_SOURCES = ['webcam', 'facebook', 'instagram', 'dropbox', 'google-drive'];
24
+ function UploadField(t0) {
25
+ const $ = c(123);
26
+ const {
27
+ resource: t1,
28
+ value: t2,
29
+ name: t3,
30
+ types: t4,
31
+ fileTypes: t5,
32
+ sources: t6,
33
+ withButton: t7,
34
+ withFind: t8,
35
+ withClearButton: t9,
36
+ withoutMedia: t10,
37
+ addButtonLabel: t11,
38
+ findButtonLabel: t12,
39
+ clearButtonLabel: t13,
40
+ allowMultipleUploads: t14,
41
+ closeAfterFinish: t15,
42
+ maxNumberOfFiles: t16,
43
+ namePath: t17,
44
+ thumbnailPath: t18,
45
+ sizePath: t19,
46
+ linkPath: t20,
47
+ uppyProps: t21,
48
+ width: t22,
49
+ height: t23,
50
+ disabled: t24,
51
+ uploadDisabled: t25,
52
+ outline: t26,
53
+ loading: t27,
54
+ onChange: t28,
55
+ onClear: t29,
56
+ onClickAdd: t30,
57
+ onClickFind: t31,
58
+ className: t32
59
+ } = t0;
60
+ const resource = t1 === undefined ? "medias" : t1;
61
+ const value = t2 === undefined ? null : t2;
62
+ const name = t3 === undefined ? null : t3;
63
+ const types = t4 === undefined ? DEFAULT_TYPES : t4;
64
+ const fileTypes = t5 === undefined ? null : t5;
65
+ const sources = t6 === undefined ? DEFAULT_SOURCES : t6;
66
+ const withButton = t7 === undefined ? false : t7;
67
+ const withFind = t8 === undefined ? false : t8;
68
+ const withClearButton = t9 === undefined ? false : t9;
69
+ const withoutMedia = t10 === undefined ? false : t10;
70
+ const initialAddButtonLabel = t11 === undefined ? null : t11;
71
+ const initialFindButtonLabel = t12 === undefined ? null : t12;
72
+ const initialCleanButtonLabel = t13 === undefined ? null : t13;
73
+ const allowMultipleUploads = t14 === undefined ? false : t14;
74
+ const closeAfterFinish = t15 === undefined ? true : t15;
75
+ const maxNumberOfFiles = t16 === undefined ? 1 : t16;
76
+ const namePath = t17 === undefined ? "name" : t17;
77
+ const thumbnailPath = t18 === undefined ? "thumbnail_url" : t18;
78
+ const sizePath = t19 === undefined ? "metadata.size" : t19;
79
+ const linkPath = t20 === undefined ? null : t20;
80
+ const uppyProps = t21 === undefined ? null : t21;
81
+ const width = t22 === undefined ? null : t22;
82
+ const height = t23 === undefined ? 300 : t23;
83
+ const disabled = t24 === undefined ? false : t24;
84
+ const uploadDisabled = t25 === undefined ? false : t25;
85
+ const outline = t26 === undefined ? true : t26;
86
+ const parentLoading = t27 === undefined ? false : t27;
87
+ const onChange = t28 === undefined ? null : t28;
88
+ const onClear = t29 === undefined ? null : t29;
89
+ const onClickAdd = t30 === undefined ? null : t30;
90
+ const onClickFind = t31 === undefined ? null : t31;
91
+ const className = t32 === undefined ? null : t32;
92
+ let t33;
93
+ if ($[0] !== initialAddButtonLabel) {
94
+ t33 = initialAddButtonLabel || /*#__PURE__*/jsx(FormattedMessage, {
95
+ id: "BeKVq6"
96
+ });
97
+ $[0] = initialAddButtonLabel;
98
+ $[1] = t33;
99
+ } else {
100
+ t33 = $[1];
101
+ }
102
+ const addButtonLabel = t33;
103
+ let t34;
104
+ if ($[2] !== initialFindButtonLabel) {
105
+ t34 = initialFindButtonLabel || /*#__PURE__*/jsx(FormattedMessage, {
106
+ id: "une5WQ"
107
+ });
108
+ $[2] = initialFindButtonLabel;
109
+ $[3] = t34;
110
+ } else {
111
+ t34 = $[3];
112
+ }
113
+ const findButtonLabel = t34;
114
+ let t35;
115
+ if ($[4] !== initialCleanButtonLabel) {
116
+ t35 = initialCleanButtonLabel || /*#__PURE__*/jsx(FormattedMessage, {
117
+ id: "odaCUe"
118
+ });
119
+ $[4] = initialCleanButtonLabel;
120
+ $[5] = t35;
121
+ } else {
122
+ t35 = $[5];
123
+ }
124
+ const clearButtonLabel = t35;
125
+ const mergeData = _temp;
126
+ let t36;
127
+ if ($[6] !== allowMultipleUploads || $[7] !== onChange) {
128
+ t36 = response => {
129
+ let newValue_0 = null;
130
+ if (isArray(response)) {
131
+ if (allowMultipleUploads) {
132
+ newValue_0 = response;
133
+ } else {
134
+ const [first] = response;
135
+ newValue_0 = first;
136
+ }
137
+ } else {
138
+ if (response && response.successful) {
139
+ newValue_0 = response.successful.length > 0 ? response.successful[0].response.body : null;
140
+ }
141
+ }
142
+ if (isArray(newValue_0)) {
143
+ newValue_0 = newValue_0.map(val => mergeData(val));
126
144
  } else {
127
- var _response = _slicedToArray(response, 1),
128
- first = _response[0];
129
- newValue = first;
145
+ if (newValue_0 !== null) {
146
+ newValue_0 = mergeData(newValue_0);
147
+ }
130
148
  }
131
- } else if (response && response.successful) {
132
- newValue = response.successful.length > 0 ? response.successful[0].response.body : null;
133
- }
134
- if (isArray(newValue)) {
135
- newValue = newValue.map(function (val) {
136
- return mergeData(val);
137
- });
138
- } else if (newValue !== null) {
139
- newValue = mergeData(newValue);
140
- }
141
- if (onChange !== null) {
142
- onChange(newValue);
143
- }
144
- }, [onChange, allowMultipleUploads, mergeData]);
145
- var typesString = useMemo(function () {
146
- return types !== null ? types.join('.') : ['audio', 'image', 'video'].join('.');
147
- }, [types]);
148
- var allowedFileTypes = useMemo(function () {
149
+ if (onChange !== null) {
150
+ onChange(newValue_0);
151
+ }
152
+ };
153
+ $[6] = allowMultipleUploads;
154
+ $[7] = onChange;
155
+ $[8] = t36;
156
+ } else {
157
+ t36 = $[8];
158
+ }
159
+ const onComplete = t36;
160
+ let t37;
161
+ if ($[9] !== types) {
162
+ t37 = types !== null ? types.join(".") : ["audio", "image", "video"].join(".");
163
+ $[9] = types;
164
+ $[10] = t37;
165
+ } else {
166
+ t37 = $[10];
167
+ }
168
+ const typesString = t37;
169
+ let t38;
170
+ bb0: {
149
171
  if (fileTypes !== null) {
150
- return fileTypes;
151
- }
152
- return typesString.split('.').map(function (type) {
153
- return "".concat(type, "/*");
154
- });
155
- }, [typesString, fileTypes]);
156
- var uppyFinalProps = useMemo(function () {
157
- return _objectSpread(_objectSpread({
158
- maxNumberOfFiles: allowMultipleUploads && maxNumberOfFiles === 1 ? 50 : maxNumberOfFiles,
159
- allowedFileTypes: allowedFileTypes,
160
- sources: sources
161
- }, uppyProps), {}, {
162
- allowMultipleUploads: allowMultipleUploads,
163
- autoProceed: true,
164
- onComplete: onComplete
165
- });
166
- }, [uppyProps, allowedFileTypes, allowMultipleUploads, maxNumberOfFiles, sources, onComplete]);
167
- var uppy = useUppy(uppyFinalProps);
168
- var _useState = useState(false),
169
- _useState2 = _slicedToArray(_useState, 2),
170
- modalOpened = _useState2[0],
171
- setModalOpened = _useState2[1];
172
- var openModal = useCallback(function () {
173
- setModalOpened(!modalOpened);
174
- }, [modalOpened, setModalOpened]);
175
- var closeModal = useCallback(function () {
176
- setModalOpened(false);
177
- if (uppy !== null) {
178
- uppy.cancelAll({
179
- reason: 'user'
180
- });
181
- }
182
- }, [uppy, setModalOpened]);
183
- var onClickClear = useCallback(function () {
184
- if (onClear !== null) {
185
- onClear();
186
- }
187
- if (uppy !== null) {
188
- uppy.cancelAll({
189
- reason: 'user'
190
- });
172
+ t38 = fileTypes;
173
+ break bb0;
191
174
  }
192
- }, [uppy, onClear]);
193
- var onClickRemove = useCallback(function (idx) {
194
- if (onChange !== null && isArray(value) && value.length > 1) {
195
- onChange(value.filter(function (v, i) {
196
- return i !== idx;
197
- }));
198
- } else if (onChange !== null) {
199
- onChange(null);
200
- }
201
- }, [value, onChange]);
202
- var values = useMemo(function () {
203
- if (isArray(value)) {
204
- return value;
205
- }
206
- return value !== null ? [value] : null;
207
- }, [value]);
208
-
209
- // Resource-modal-picker
210
- var hasMedia = values !== null && values.length > 0;
211
- var _useState3 = useState(false),
212
- _useState4 = _slicedToArray(_useState3, 2),
213
- resourceModalOpen = _useState4[0],
214
- setResourceModalOpen = _useState4[1];
215
- var showResourceModal = resource !== null && withFind && resourceModalOpen;
216
- var openResourceModal = useCallback(function () {
217
- setResourceModalOpen(true);
218
- }, [resourceModalOpen, setResourceModalOpen]);
219
- var _useState5 = useState([]),
220
- _useState6 = _slicedToArray(_useState5, 2),
221
- modalItems = _useState6[0],
222
- setModalItems = _useState6[1];
223
- var closeResourceModal = useCallback(function () {
224
- setResourceModalOpen(false);
225
- setModalItems([]);
226
- }, [resourceModalOpen, setResourceModalOpen, setModalItems]);
227
- var finalOnClickFind = useCallback(function () {
228
- if (onClickFind !== null) {
229
- onClickFind();
175
+ let t39;
176
+ if ($[11] !== typesString) {
177
+ t39 = typesString.split(".").map(_temp2);
178
+ $[11] = typesString;
179
+ $[12] = t39;
230
180
  } else {
231
- openResourceModal();
181
+ t39 = $[12];
232
182
  }
233
- }, [onClickFind, openResourceModal]);
234
- var onSelectionChange = useCallback(function (newValue) {
235
- if (allowMultipleUploads) {
236
- if (newValue !== null && !isArray(newValue)) {
237
- var _ref2 = newValue || {},
238
- _ref2$id = _ref2.id,
239
- id = _ref2$id === void 0 ? null : _ref2$id;
240
- if (id !== null) {
241
- var previous = (modalItems || []).find(function () {
242
- var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
243
- _ref3$id = _ref3.id,
244
- itemId = _ref3$id === void 0 ? null : _ref3$id;
245
- return id === itemId;
246
- });
247
- if (previous) {
248
- setModalItems((modalItems || []).filter(function () {
249
- var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
250
- _ref4$id = _ref4.id,
251
- itemId = _ref4$id === void 0 ? null : _ref4$id;
252
- return id !== itemId;
253
- }));
254
- } else {
255
- setModalItems([].concat(_toConsumableArray(modalItems || []), [newValue]));
256
- }
183
+ t38 = t39;
184
+ }
185
+ const allowedFileTypes = t38;
186
+ const t39 = allowMultipleUploads && maxNumberOfFiles === 1 ? 50 : maxNumberOfFiles;
187
+ let t40;
188
+ if ($[13] !== allowMultipleUploads || $[14] !== allowedFileTypes || $[15] !== onComplete || $[16] !== sources || $[17] !== t39 || $[18] !== uppyProps) {
189
+ t40 = {
190
+ maxNumberOfFiles: t39,
191
+ allowedFileTypes,
192
+ sources,
193
+ ...uppyProps,
194
+ allowMultipleUploads,
195
+ autoProceed: true,
196
+ onComplete
197
+ };
198
+ $[13] = allowMultipleUploads;
199
+ $[14] = allowedFileTypes;
200
+ $[15] = onComplete;
201
+ $[16] = sources;
202
+ $[17] = t39;
203
+ $[18] = uppyProps;
204
+ $[19] = t40;
205
+ } else {
206
+ t40 = $[19];
207
+ }
208
+ const uppyFinalProps = t40;
209
+ const uppy = useUppy(uppyFinalProps);
210
+ const [modalOpened, setModalOpened] = useState(false);
211
+ let t41;
212
+ if ($[20] !== modalOpened) {
213
+ t41 = () => {
214
+ setModalOpened(!modalOpened);
215
+ };
216
+ $[20] = modalOpened;
217
+ $[21] = t41;
218
+ } else {
219
+ t41 = $[21];
220
+ }
221
+ const openModal = t41;
222
+ let t42;
223
+ if ($[22] !== uppy) {
224
+ t42 = () => {
225
+ setModalOpened(false);
226
+ if (uppy !== null) {
227
+ uppy.cancelAll({
228
+ reason: "user"
229
+ });
230
+ }
231
+ };
232
+ $[22] = uppy;
233
+ $[23] = t42;
234
+ } else {
235
+ t42 = $[23];
236
+ }
237
+ const closeModal = t42;
238
+ let t43;
239
+ if ($[24] !== onClear || $[25] !== uppy) {
240
+ t43 = () => {
241
+ if (onClear !== null) {
242
+ onClear();
243
+ }
244
+ if (uppy !== null) {
245
+ uppy.cancelAll({
246
+ reason: "user"
247
+ });
248
+ }
249
+ };
250
+ $[24] = onClear;
251
+ $[25] = uppy;
252
+ $[26] = t43;
253
+ } else {
254
+ t43 = $[26];
255
+ }
256
+ const onClickClear = t43;
257
+ let t44;
258
+ if ($[27] !== onChange || $[28] !== value) {
259
+ t44 = idx => {
260
+ if (onChange !== null && isArray(value) && value.length > 1) {
261
+ onChange(value.filter((v, i) => i !== idx));
262
+ } else {
263
+ if (onChange !== null) {
264
+ onChange(null);
257
265
  }
258
- } else if (newValue !== null && isArray(newValue)) {
259
- setModalItems(newValue);
260
266
  }
267
+ };
268
+ $[27] = onChange;
269
+ $[28] = value;
270
+ $[29] = t44;
271
+ } else {
272
+ t44 = $[29];
273
+ }
274
+ const onClickRemove = t44;
275
+ let t45;
276
+ bb1: {
277
+ if (isArray(value)) {
278
+ t45 = value;
279
+ break bb1;
280
+ }
281
+ let t46;
282
+ if ($[30] !== value) {
283
+ t46 = value !== null ? [value] : null;
284
+ $[30] = value;
285
+ $[31] = t46;
261
286
  } else {
262
- setModalItems(newValue);
287
+ t46 = $[31];
263
288
  }
264
- }, [onChange, setResourceModalOpen, allowMultipleUploads, modalItems, setModalItems]);
265
- var confirmResourceModal = useCallback(function () {
266
- if (onChange !== null) {
267
- // Always multiple onchange
268
- onChange(modalItems);
289
+ t45 = t46;
290
+ }
291
+ const values = t45;
292
+ const hasMedia = values !== null && values.length > 0;
293
+ const [resourceModalOpen, setResourceModalOpen] = useState(false);
294
+ const showResourceModal = resource !== null && withFind && resourceModalOpen;
295
+ let t46;
296
+ if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
297
+ t46 = () => {
298
+ setResourceModalOpen(true);
299
+ };
300
+ $[32] = t46;
301
+ } else {
302
+ t46 = $[32];
303
+ }
304
+ const openResourceModal = t46;
305
+ let t47;
306
+ if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
307
+ t47 = [];
308
+ $[33] = t47;
309
+ } else {
310
+ t47 = $[33];
311
+ }
312
+ const [modalItems, setModalItems] = useState(t47);
313
+ let t48;
314
+ if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
315
+ t48 = () => {
269
316
  setResourceModalOpen(false);
270
317
  setModalItems([]);
271
- }
272
- }, [onChange, setResourceModalOpen, modalItems, allowMultipleUploads, setModalItems]);
273
- var initialQuery = useMemo(function () {
274
- return {
275
- types: types
276
318
  };
277
- }, [types]);
278
- var _useQuery = useQuery(initialQuery, true),
279
- listQuery = _useQuery.query,
280
- onListPageChange = _useQuery.onPageChange,
281
- onListQueryChange = _useQuery.onQueryChange,
282
- onListQueryReset = _useQuery.onQueryReset;
283
- var finalOnPageChange = useCallback(function (e) {
284
- var pageNumber = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
285
- e.preventDefault();
286
- e.stopPropagation();
287
- onListPageChange(pageNumber);
288
- }, [onListPageChange]);
289
- var finalOnQueryChange = useCallback(function (newQuery) {
290
- onListQueryChange(newQuery);
291
- }, [onListQueryChange]);
292
- var containerRef = useRef(null);
293
-
294
- // Keep this stable, uppy doesnt like changes
295
- var _useState7 = useState(null),
296
- _useState8 = _slicedToArray(_useState7, 2),
297
- finalUppy = _useState8[0],
298
- setFinalUppy = _useState8[1];
299
- useEffect(function () {
300
- if (uppy !== null && finalUppy === null) {
301
- setFinalUppy(uppy);
302
- }
303
- }, [uppy, finalUppy]);
304
-
305
- // Uppy state
306
- var _useState9 = useState(false),
307
- _useState0 = _slicedToArray(_useState9, 2),
308
- loading = _useState0[0],
309
- setLoading = _useState0[1];
310
- var startLoading = useCallback(function () {
311
- setLoading(true);
312
- }, []);
313
- var endLoading = useCallback(function () {
314
- setLoading(false);
315
- }, []);
316
- useEffect(function () {
317
- if (uppy !== null) {
318
- uppy.on('upload', startLoading);
319
- uppy.on('complete', endLoading);
320
- uppy.on('upload-error', endLoading);
321
- uppy.on('error', endLoading);
322
- uppy.on('cancell-all', endLoading);
323
- }
324
- return function () {
319
+ $[34] = t48;
320
+ } else {
321
+ t48 = $[34];
322
+ }
323
+ const closeResourceModal = t48;
324
+ let t49;
325
+ if ($[35] !== onClickFind) {
326
+ t49 = () => {
327
+ if (onClickFind !== null) {
328
+ onClickFind();
329
+ } else {
330
+ openResourceModal();
331
+ }
332
+ };
333
+ $[35] = onClickFind;
334
+ $[36] = t49;
335
+ } else {
336
+ t49 = $[36];
337
+ }
338
+ const finalOnClickFind = t49;
339
+ let t50;
340
+ if ($[37] !== allowMultipleUploads || $[38] !== modalItems) {
341
+ t50 = newValue_1 => {
342
+ if (allowMultipleUploads) {
343
+ if (newValue_1 !== null && !isArray(newValue_1)) {
344
+ const {
345
+ id: t51
346
+ } = newValue_1 || {};
347
+ const id = t51 === undefined ? null : t51;
348
+ if (id !== null) {
349
+ const previous = (modalItems || []).find(t52 => {
350
+ const {
351
+ id: t53
352
+ } = t52 === undefined ? {} : t52;
353
+ const itemId = t53 === undefined ? null : t53;
354
+ return id === itemId;
355
+ });
356
+ if (previous) {
357
+ setModalItems((modalItems || []).filter(t54 => {
358
+ const {
359
+ id: t55
360
+ } = t54 === undefined ? {} : t54;
361
+ const itemId_0 = t55 === undefined ? null : t55;
362
+ return id !== itemId_0;
363
+ }));
364
+ } else {
365
+ setModalItems([...(modalItems || []), newValue_1]);
366
+ }
367
+ }
368
+ } else {
369
+ if (newValue_1 !== null && isArray(newValue_1)) {
370
+ setModalItems(newValue_1);
371
+ }
372
+ }
373
+ } else {
374
+ setModalItems(newValue_1);
375
+ }
376
+ };
377
+ $[37] = allowMultipleUploads;
378
+ $[38] = modalItems;
379
+ $[39] = t50;
380
+ } else {
381
+ t50 = $[39];
382
+ }
383
+ const onSelectionChange = t50;
384
+ let t51;
385
+ if ($[40] !== modalItems || $[41] !== onChange) {
386
+ t51 = () => {
387
+ if (onChange !== null) {
388
+ onChange(modalItems);
389
+ setResourceModalOpen(false);
390
+ setModalItems([]);
391
+ }
392
+ };
393
+ $[40] = modalItems;
394
+ $[41] = onChange;
395
+ $[42] = t51;
396
+ } else {
397
+ t51 = $[42];
398
+ }
399
+ const confirmResourceModal = t51;
400
+ let t52;
401
+ if ($[43] !== types) {
402
+ t52 = {
403
+ types
404
+ };
405
+ $[43] = types;
406
+ $[44] = t52;
407
+ } else {
408
+ t52 = $[44];
409
+ }
410
+ const initialQuery = t52;
411
+ const {
412
+ query: listQuery,
413
+ onPageChange: onListPageChange,
414
+ onQueryChange: onListQueryChange,
415
+ onQueryReset: onListQueryReset
416
+ } = useQuery(initialQuery, true);
417
+ let t53;
418
+ if ($[45] !== onListPageChange) {
419
+ t53 = (e, t54) => {
420
+ const pageNumber = t54 === undefined ? null : t54;
421
+ e.preventDefault();
422
+ e.stopPropagation();
423
+ onListPageChange(pageNumber);
424
+ };
425
+ $[45] = onListPageChange;
426
+ $[46] = t53;
427
+ } else {
428
+ t53 = $[46];
429
+ }
430
+ const finalOnPageChange = t53;
431
+ let t54;
432
+ if ($[47] !== onListQueryChange) {
433
+ t54 = newQuery => {
434
+ onListQueryChange(newQuery);
435
+ };
436
+ $[47] = onListQueryChange;
437
+ $[48] = t54;
438
+ } else {
439
+ t54 = $[48];
440
+ }
441
+ const finalOnQueryChange = t54;
442
+ const containerRef = useRef(null);
443
+ const [finalUppy, setFinalUppy] = useState(null);
444
+ let t55;
445
+ let t56;
446
+ if ($[49] !== finalUppy || $[50] !== uppy) {
447
+ t55 = () => {
448
+ if (uppy !== null && finalUppy === null) {
449
+ setFinalUppy(uppy);
450
+ }
451
+ };
452
+ t56 = [uppy, finalUppy];
453
+ $[49] = finalUppy;
454
+ $[50] = uppy;
455
+ $[51] = t55;
456
+ $[52] = t56;
457
+ } else {
458
+ t55 = $[51];
459
+ t56 = $[52];
460
+ }
461
+ useEffect(t55, t56);
462
+ const [loading, setLoading] = useState(false);
463
+ let t57;
464
+ if ($[53] === Symbol.for("react.memo_cache_sentinel")) {
465
+ t57 = () => {
466
+ setLoading(true);
467
+ };
468
+ $[53] = t57;
469
+ } else {
470
+ t57 = $[53];
471
+ }
472
+ const startLoading = t57;
473
+ let t58;
474
+ if ($[54] === Symbol.for("react.memo_cache_sentinel")) {
475
+ t58 = () => {
476
+ setLoading(false);
477
+ };
478
+ $[54] = t58;
479
+ } else {
480
+ t58 = $[54];
481
+ }
482
+ const endLoading = t58;
483
+ let t59;
484
+ let t60;
485
+ if ($[55] !== uppy) {
486
+ t59 = () => {
325
487
  if (uppy !== null) {
326
- uppy.off('upload', startLoading);
327
- uppy.off('complete', endLoading);
328
- uppy.off('upload-error', endLoading);
329
- uppy.off('error', endLoading);
330
- uppy.off('cancell-all', endLoading);
488
+ uppy.on("upload", startLoading);
489
+ uppy.on("complete", endLoading);
490
+ uppy.on("upload-error", endLoading);
491
+ uppy.on("error", endLoading);
492
+ uppy.on("cancell-all", endLoading);
331
493
  }
494
+ return () => {
495
+ if (uppy !== null) {
496
+ uppy.off("upload", startLoading);
497
+ uppy.off("complete", endLoading);
498
+ uppy.off("upload-error", endLoading);
499
+ uppy.off("error", endLoading);
500
+ uppy.off("cancell-all", endLoading);
501
+ }
502
+ };
332
503
  };
333
- }, [uppy, startLoading, endLoading]);
334
- var finalLoading = loading || parentLoading;
335
- return /*#__PURE__*/jsxs("div", {
336
- className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
337
- ref: containerRef,
338
- children: [!withoutMedia && hasMedia ? /*#__PURE__*/jsx(MediaCards, {
504
+ t60 = [uppy, startLoading, endLoading];
505
+ $[55] = uppy;
506
+ $[56] = t59;
507
+ $[57] = t60;
508
+ } else {
509
+ t59 = $[56];
510
+ t60 = $[57];
511
+ }
512
+ useEffect(t59, t60);
513
+ const finalLoading = loading || parentLoading;
514
+ const t61 = className !== null;
515
+ let t62;
516
+ if ($[58] !== className || $[59] !== t61) {
517
+ t62 = classNames([styles.container, {
518
+ [className]: t61
519
+ }]);
520
+ $[58] = className;
521
+ $[59] = t61;
522
+ $[60] = t62;
523
+ } else {
524
+ t62 = $[60];
525
+ }
526
+ let t63;
527
+ if ($[61] !== disabled || $[62] !== hasMedia || $[63] !== linkPath || $[64] !== namePath || $[65] !== onClickRemove || $[66] !== sizePath || $[67] !== thumbnailPath || $[68] !== values || $[69] !== withoutMedia) {
528
+ t63 = !withoutMedia && hasMedia ? /*#__PURE__*/jsx(MediaCards, {
339
529
  value: values,
340
530
  namePath: namePath,
341
531
  thumbnailPath: thumbnailPath,
@@ -343,7 +533,23 @@ function UploadField(_ref) {
343
533
  linkPath: linkPath,
344
534
  disabled: disabled,
345
535
  onClickRemove: onClickRemove
346
- }) : null, !withoutMedia && hasMedia && withClearButton ? /*#__PURE__*/jsx("div", {
536
+ }) : null;
537
+ $[61] = disabled;
538
+ $[62] = hasMedia;
539
+ $[63] = linkPath;
540
+ $[64] = namePath;
541
+ $[65] = onClickRemove;
542
+ $[66] = sizePath;
543
+ $[67] = thumbnailPath;
544
+ $[68] = values;
545
+ $[69] = withoutMedia;
546
+ $[70] = t63;
547
+ } else {
548
+ t63 = $[70];
549
+ }
550
+ let t64;
551
+ if ($[71] !== clearButtonLabel || $[72] !== hasMedia || $[73] !== onClickClear || $[74] !== withClearButton || $[75] !== withoutMedia) {
552
+ t64 = !withoutMedia && hasMedia && withClearButton ? /*#__PURE__*/jsx("div", {
347
553
  className: "row mt-2",
348
554
  children: /*#__PURE__*/jsx("div", {
349
555
  className: "col-auto",
@@ -356,26 +562,36 @@ function UploadField(_ref) {
356
562
  })
357
563
  })
358
564
  })
359
- }) : null, finalUppy !== null ? /*#__PURE__*/jsxs(UppyContextProvider, {
565
+ }) : null;
566
+ $[71] = clearButtonLabel;
567
+ $[72] = hasMedia;
568
+ $[73] = onClickClear;
569
+ $[74] = withClearButton;
570
+ $[75] = withoutMedia;
571
+ $[76] = t64;
572
+ } else {
573
+ t64 = $[76];
574
+ }
575
+ let t65;
576
+ if ($[77] !== closeAfterFinish || $[78] !== closeModal || $[79] !== finalUppy || $[80] !== hasMedia || $[81] !== height || $[82] !== modalOpened || $[83] !== showResourceModal || $[84] !== sources || $[85] !== uploadDisabled || $[86] !== width || $[87] !== withButton) {
577
+ t65 = finalUppy !== null ? /*#__PURE__*/jsxs(UppyContextProvider, {
360
578
  uppy: finalUppy,
361
579
  children: [!uploadDisabled && !hasMedia && !withButton && finalUppy !== null ? /*#__PURE__*/jsx("div", {
362
580
  className: styles.dashboard,
363
- children: /*#__PURE__*/jsx(Dashboard, _objectSpread(_objectSpread(_objectSpread({
364
- uppy: finalUppy
365
- // {...(containerWidth !== null && height !== null
366
- // ? { width: containerWidth }
367
- // : null)}
368
- }, width !== null ? {
369
- width: width
370
- } : null), height !== null ? {
371
- height: height
372
- } : null), {}, {
581
+ children: /*#__PURE__*/jsx(Dashboard, {
582
+ uppy: finalUppy,
583
+ ...(width !== null ? {
584
+ width
585
+ } : null),
586
+ ...(height !== null ? {
587
+ height
588
+ } : null),
373
589
  plugins: sources,
374
590
  inline: true,
375
591
  showProgressDetails: true,
376
592
  areInsidesReadyToBeVisible: true,
377
593
  proudlyDisplayPoweredByUppy: false
378
- }))
594
+ })
379
595
  }) : null, !showResourceModal && !uploadDisabled && withButton && finalUppy !== null && modalOpened ? /*#__PURE__*/jsx(DashboardModal, {
380
596
  uppy: finalUppy,
381
597
  className: styles.dashboardModal,
@@ -391,7 +607,25 @@ function UploadField(_ref) {
391
607
  doneButtonHandler: closeModal,
392
608
  closeAfterFinish: closeAfterFinish
393
609
  }) : null]
394
- }) : null, withoutMedia || (!hasMedia || allowMultipleUploads) && (withButton || withFind) ? /*#__PURE__*/jsxs("div", {
610
+ }) : null;
611
+ $[77] = closeAfterFinish;
612
+ $[78] = closeModal;
613
+ $[79] = finalUppy;
614
+ $[80] = hasMedia;
615
+ $[81] = height;
616
+ $[82] = modalOpened;
617
+ $[83] = showResourceModal;
618
+ $[84] = sources;
619
+ $[85] = uploadDisabled;
620
+ $[86] = width;
621
+ $[87] = withButton;
622
+ $[88] = t65;
623
+ } else {
624
+ t65 = $[88];
625
+ }
626
+ let t66;
627
+ if ($[89] !== addButtonLabel || $[90] !== allowMultipleUploads || $[91] !== disabled || $[92] !== finalLoading || $[93] !== finalOnClickFind || $[94] !== findButtonLabel || $[95] !== hasMedia || $[96] !== onClickAdd || $[97] !== openModal || $[98] !== outline || $[99] !== withButton || $[100] !== withFind || $[101] !== withoutMedia) {
628
+ t66 = withoutMedia || (!hasMedia || allowMultipleUploads) && (withButton || withFind) ? /*#__PURE__*/jsxs("div", {
395
629
  className: "row",
396
630
  children: [withButton ? /*#__PURE__*/jsx("div", {
397
631
  className: "col-auto mb-2 pe-0",
@@ -399,18 +633,14 @@ function UploadField(_ref) {
399
633
  id: "trigger-uppy",
400
634
  type: "button",
401
635
  theme: "primary",
402
- icon: finalLoading ? 'loading' : 'upload',
636
+ icon: finalLoading ? "loading" : "upload",
403
637
  iconPosition: "right",
404
638
  onClick: onClickAdd || openModal,
405
639
  disabled: finalLoading || disabled,
406
640
  outline: outline,
407
641
  children: /*#__PURE__*/jsx(Label, {
408
642
  children: finalLoading ? /*#__PURE__*/jsx(FormattedMessage, {
409
- id: "NozDYd",
410
- defaultMessage: [{
411
- "type": 0,
412
- "value": "Uploading"
413
- }]
643
+ id: "NozDYd"
414
644
  }) : addButtonLabel
415
645
  })
416
646
  })
@@ -429,8 +659,28 @@ function UploadField(_ref) {
429
659
  })
430
660
  })
431
661
  }) : null]
432
- }) : null, showResourceModal ? /*#__PURE__*/jsx(ModalResourceItems, {
433
- id: "upload-".concat(name),
662
+ }) : null;
663
+ $[89] = addButtonLabel;
664
+ $[90] = allowMultipleUploads;
665
+ $[91] = disabled;
666
+ $[92] = finalLoading;
667
+ $[93] = finalOnClickFind;
668
+ $[94] = findButtonLabel;
669
+ $[95] = hasMedia;
670
+ $[96] = onClickAdd;
671
+ $[97] = openModal;
672
+ $[98] = outline;
673
+ $[99] = withButton;
674
+ $[100] = withFind;
675
+ $[101] = withoutMedia;
676
+ $[102] = t66;
677
+ } else {
678
+ t66 = $[102];
679
+ }
680
+ let t67;
681
+ if ($[103] !== allowMultipleUploads || $[104] !== confirmResourceModal || $[105] !== disabled || $[106] !== finalOnPageChange || $[107] !== finalOnQueryChange || $[108] !== listQuery || $[109] !== modalItems || $[110] !== name || $[111] !== onListQueryReset || $[112] !== onSelectionChange || $[113] !== resource || $[114] !== showResourceModal) {
682
+ t67 = showResourceModal ? /*#__PURE__*/jsx(ModalResourceItems, {
683
+ id: `upload-${name}`,
434
684
  resource: resource,
435
685
  query: listQuery,
436
686
  onPageChange: finalOnPageChange,
@@ -442,7 +692,7 @@ function UploadField(_ref) {
442
692
  selectedItems: modalItems,
443
693
  onSelectionChange: onSelectionChange,
444
694
  multipleSelection: allowMultipleUploads,
445
- onClose: closeResourceModal,
695
+ onClosed: closeResourceModal,
446
696
  children: /*#__PURE__*/jsxs("div", {
447
697
  className: "d-flex mt-4 justify-content-between",
448
698
  children: [modalItems !== null && modalItems.length > 0 ? /*#__PURE__*/jsxs("span", {
@@ -457,11 +707,7 @@ function UploadField(_ref) {
457
707
  disabled: disabled,
458
708
  className: "d-block me-2",
459
709
  children: /*#__PURE__*/jsx(FormattedMessage, {
460
- id: "PyxZY2",
461
- defaultMessage: [{
462
- "type": 0,
463
- "value": "Cancel"
464
- }]
710
+ id: "PyxZY2"
465
711
  })
466
712
  }), /*#__PURE__*/jsx(Button, {
467
713
  type: "button",
@@ -470,17 +716,58 @@ function UploadField(_ref) {
470
716
  disabled: disabled || modalItems !== null && modalItems.length === 0,
471
717
  className: "d-block",
472
718
  children: /*#__PURE__*/jsx(FormattedMessage, {
473
- id: "rvOVCV",
474
- defaultMessage: [{
475
- "type": 0,
476
- "value": "Confirm selection"
477
- }]
719
+ id: "rvOVCV"
478
720
  })
479
721
  })]
480
722
  })]
481
723
  })
482
- }) : null]
483
- });
724
+ }) : null;
725
+ $[103] = allowMultipleUploads;
726
+ $[104] = confirmResourceModal;
727
+ $[105] = disabled;
728
+ $[106] = finalOnPageChange;
729
+ $[107] = finalOnQueryChange;
730
+ $[108] = listQuery;
731
+ $[109] = modalItems;
732
+ $[110] = name;
733
+ $[111] = onListQueryReset;
734
+ $[112] = onSelectionChange;
735
+ $[113] = resource;
736
+ $[114] = showResourceModal;
737
+ $[115] = t67;
738
+ } else {
739
+ t67 = $[115];
740
+ }
741
+ let t68;
742
+ if ($[116] !== t62 || $[117] !== t63 || $[118] !== t64 || $[119] !== t65 || $[120] !== t66 || $[121] !== t67) {
743
+ t68 = /*#__PURE__*/jsxs("div", {
744
+ className: t62,
745
+ ref: containerRef,
746
+ children: [t63, t64, t65, t66, t67]
747
+ });
748
+ $[116] = t62;
749
+ $[117] = t63;
750
+ $[118] = t64;
751
+ $[119] = t65;
752
+ $[120] = t66;
753
+ $[121] = t67;
754
+ $[122] = t68;
755
+ } else {
756
+ t68 = $[122];
757
+ }
758
+ return t68;
759
+ }
760
+ function _temp2(type) {
761
+ return `${type}/*`;
762
+ }
763
+ function _temp(newValue) {
764
+ if (isObject(newValue) && isObject(newValue.response) && newValue.response.status === 200 && newValue.response.body !== null) {
765
+ return {
766
+ ...newValue,
767
+ ...(newValue.response.body || null)
768
+ };
769
+ }
770
+ return newValue;
484
771
  }
485
772
 
486
773
  var definition = [{
@@ -504,137 +791,312 @@ var definition = [{
504
791
  }];
505
792
 
506
793
  function AudioField(props) {
507
- var types = useMemo(function () {
508
- return ['audio'];
509
- }, []);
510
- return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
511
- types: types
512
- }));
794
+ const $ = c(3);
795
+ let t0;
796
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
797
+ t0 = ["audio"];
798
+ $[0] = t0;
799
+ } else {
800
+ t0 = $[0];
801
+ }
802
+ const types = t0;
803
+ let t1;
804
+ if ($[1] !== props) {
805
+ t1 = /*#__PURE__*/jsx(UploadField, {
806
+ ...props,
807
+ types: types
808
+ });
809
+ $[1] = props;
810
+ $[2] = t1;
811
+ } else {
812
+ t1 = $[2];
813
+ }
814
+ return t1;
513
815
  }
514
816
 
515
817
  function ImageField(props) {
516
- var types = useMemo(function () {
517
- return ['image'];
518
- }, []);
519
- return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
520
- types: types
521
- }));
818
+ const $ = c(3);
819
+ let t0;
820
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
821
+ t0 = ["image"];
822
+ $[0] = t0;
823
+ } else {
824
+ t0 = $[0];
825
+ }
826
+ const types = t0;
827
+ let t1;
828
+ if ($[1] !== props) {
829
+ t1 = /*#__PURE__*/jsx(UploadField, {
830
+ ...props,
831
+ types: types
832
+ });
833
+ $[1] = props;
834
+ $[2] = t1;
835
+ } else {
836
+ t1 = $[2];
837
+ }
838
+ return t1;
522
839
  }
523
840
 
524
841
  function ImagesField(props) {
525
- var types = useMemo(function () {
526
- return ['image'];
527
- }, []);
528
- return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
529
- types: types,
530
- allowMultipleUploads: true
531
- }));
842
+ const $ = c(3);
843
+ let t0;
844
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
845
+ t0 = ["image"];
846
+ $[0] = t0;
847
+ } else {
848
+ t0 = $[0];
849
+ }
850
+ const types = t0;
851
+ let t1;
852
+ if ($[1] !== props) {
853
+ t1 = /*#__PURE__*/jsx(UploadField, {
854
+ ...props,
855
+ types: types,
856
+ allowMultipleUploads: true
857
+ });
858
+ $[1] = props;
859
+ $[2] = t1;
860
+ } else {
861
+ t1 = $[2];
862
+ }
863
+ return t1;
532
864
  }
533
865
 
534
866
  function VideoField(props) {
535
- var types = useMemo(function () {
536
- return ['video'];
537
- }, []);
538
- return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
539
- types: types
540
- }));
867
+ const $ = c(3);
868
+ let t0;
869
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
870
+ t0 = ["video"];
871
+ $[0] = t0;
872
+ } else {
873
+ t0 = $[0];
874
+ }
875
+ const types = t0;
876
+ let t1;
877
+ if ($[1] !== props) {
878
+ t1 = /*#__PURE__*/jsx(UploadField, {
879
+ ...props,
880
+ types: types
881
+ });
882
+ $[1] = props;
883
+ $[2] = t1;
884
+ } else {
885
+ t1 = $[2];
886
+ }
887
+ return t1;
541
888
  }
542
889
 
543
890
  function DocumentField(props) {
544
- var fileTypes = useMemo(function () {
545
- return ['.pdf'];
546
- }, []);
547
- var types = useMemo(function () {
548
- return ['document'];
549
- }, []);
550
- return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
551
- fileTypes: fileTypes,
552
- types: types
553
- }));
891
+ const $ = c(4);
892
+ let t0;
893
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
894
+ t0 = [".pdf"];
895
+ $[0] = t0;
896
+ } else {
897
+ t0 = $[0];
898
+ }
899
+ const fileTypes = t0;
900
+ let t1;
901
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
902
+ t1 = ["document"];
903
+ $[1] = t1;
904
+ } else {
905
+ t1 = $[1];
906
+ }
907
+ const types = t1;
908
+ let t2;
909
+ if ($[2] !== props) {
910
+ t2 = /*#__PURE__*/jsx(UploadField, {
911
+ ...props,
912
+ fileTypes: fileTypes,
913
+ types: types
914
+ });
915
+ $[2] = props;
916
+ $[3] = t2;
917
+ } else {
918
+ t2 = $[3];
919
+ }
920
+ return t2;
554
921
  }
555
922
 
556
923
  function FontField(props) {
557
- var fileTypes = useMemo(function () {
558
- return ['.ttf', '.otf'];
559
- }, []);
560
- return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
561
- fileTypes: fileTypes
562
- }));
924
+ const $ = c(3);
925
+ let t0;
926
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
927
+ t0 = [".ttf", ".otf"];
928
+ $[0] = t0;
929
+ } else {
930
+ t0 = $[0];
931
+ }
932
+ const fileTypes = t0;
933
+ let t1;
934
+ if ($[1] !== props) {
935
+ t1 = /*#__PURE__*/jsx(UploadField, {
936
+ ...props,
937
+ fileTypes: fileTypes
938
+ });
939
+ $[1] = props;
940
+ $[2] = t1;
941
+ } else {
942
+ t1 = $[2];
943
+ }
944
+ return t1;
563
945
  }
564
946
 
565
- var _excluded = ["value", "onChange"];
566
- function UpdateFileField(_ref) {
567
- var _ref$value = _ref.value,
568
- value = _ref$value === void 0 ? null : _ref$value;
569
- _ref.onChange;
570
- var props = _objectWithoutProperties(_ref, _excluded);
571
- var _useState = useState(null),
572
- _useState2 = _slicedToArray(_useState, 2),
573
- newValue = _useState2[0],
574
- setNewValue = _useState2[1];
575
- var _useState3 = useState(null),
576
- _useState4 = _slicedToArray(_useState3, 2),
577
- visibleFile = _useState4[0],
578
- setVisibleFile = _useState4[1];
579
- var _ref2 = value || {},
580
- previousId = _ref2.id,
581
- _ref2$type = _ref2.type,
582
- type = _ref2$type === void 0 ? null : _ref2$type;
583
- var onUploadChange = useCallback(function () {
584
- var uploadedFile = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
585
- if (uploadedFile !== null) {
586
- setVisibleFile(uploadedFile);
587
- }
588
- setNewValue(uploadedFile);
589
- }, [setNewValue, setVisibleFile]);
590
- var uppyProps = useMemo(function () {
591
- return {
947
+ function UpdateFileField(t0) {
948
+ const $ = c(24);
949
+ let props;
950
+ let t1;
951
+ let t2;
952
+ if ($[0] !== t0) {
953
+ ({
954
+ value: t1,
955
+ onChange: t2,
956
+ ...props
957
+ } = t0);
958
+ $[0] = t0;
959
+ $[1] = props;
960
+ $[2] = t1;
961
+ $[3] = t2;
962
+ } else {
963
+ props = $[1];
964
+ t1 = $[2];
965
+ t2 = $[3];
966
+ }
967
+ const value = t1 === undefined ? null : t1;
968
+ const [newValue, setNewValue] = useState(null);
969
+ const [visibleFile, setVisibleFile] = useState(null);
970
+ let t3;
971
+ if ($[4] !== value) {
972
+ t3 = value || {};
973
+ $[4] = value;
974
+ $[5] = t3;
975
+ } else {
976
+ t3 = $[5];
977
+ }
978
+ const {
979
+ id: previousId,
980
+ type: t4
981
+ } = t3;
982
+ const type = t4 === undefined ? null : t4;
983
+ let t5;
984
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
985
+ t5 = t6 => {
986
+ const uploadedFile = t6 === undefined ? null : t6;
987
+ if (uploadedFile !== null) {
988
+ setVisibleFile(uploadedFile);
989
+ }
990
+ setNewValue(uploadedFile);
991
+ };
992
+ $[6] = t5;
993
+ } else {
994
+ t5 = $[6];
995
+ }
996
+ const onUploadChange = t5;
997
+ let t6;
998
+ if ($[7] !== previousId) {
999
+ t6 = {
592
1000
  meta: {
593
- previousId: previousId
1001
+ previousId
594
1002
  }
595
1003
  };
596
- }, [previousId]);
597
- var uploadProps = useMemo(function () {
598
- if (type === 'image') {
599
- return {
600
- types: ['image']
601
- };
1004
+ $[7] = previousId;
1005
+ $[8] = t6;
1006
+ } else {
1007
+ t6 = $[8];
1008
+ }
1009
+ const uppyProps = t6;
1010
+ let t7;
1011
+ bb0: {
1012
+ if (type === "image") {
1013
+ let t8;
1014
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
1015
+ t8 = {
1016
+ types: ["image"]
1017
+ };
1018
+ $[9] = t8;
1019
+ } else {
1020
+ t8 = $[9];
1021
+ }
1022
+ t7 = t8;
1023
+ break bb0;
602
1024
  }
603
- if (type === 'audio') {
604
- return {
605
- types: ['audio']
606
- };
1025
+ if (type === "audio") {
1026
+ let t8;
1027
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
1028
+ t8 = {
1029
+ types: ["audio"]
1030
+ };
1031
+ $[10] = t8;
1032
+ } else {
1033
+ t8 = $[10];
1034
+ }
1035
+ t7 = t8;
1036
+ break bb0;
607
1037
  }
608
- if (type === 'video') {
609
- return {
610
- types: ['video']
611
- };
1038
+ if (type === "video") {
1039
+ let t8;
1040
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
1041
+ t8 = {
1042
+ types: ["video"]
1043
+ };
1044
+ $[11] = t8;
1045
+ } else {
1046
+ t8 = $[11];
1047
+ }
1048
+ t7 = t8;
1049
+ break bb0;
612
1050
  }
613
- if (type === 'document') {
614
- return {
615
- types: [],
616
- fileTypes: ['.pdf']
617
- };
1051
+ if (type === "document") {
1052
+ let t8;
1053
+ if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
1054
+ t8 = {
1055
+ types: [],
1056
+ fileTypes: [".pdf"]
1057
+ };
1058
+ $[12] = t8;
1059
+ } else {
1060
+ t8 = $[12];
1061
+ }
1062
+ t7 = t8;
1063
+ break bb0;
618
1064
  }
619
- return null;
620
- }, [type]);
621
- return /*#__PURE__*/jsxs(Fragment, {
622
- children: [/*#__PURE__*/jsx("div", {
1065
+ t7 = null;
1066
+ }
1067
+ const uploadProps = t7;
1068
+ const t8 = visibleFile || value;
1069
+ let t9;
1070
+ if ($[13] !== t8) {
1071
+ t9 = /*#__PURE__*/jsx("div", {
623
1072
  className: "mb-3",
624
1073
  children: /*#__PURE__*/jsx(MediaCard, {
625
- value: visibleFile || value,
1074
+ value: t8,
626
1075
  withoutDescription: true
627
1076
  })
628
- }), /*#__PURE__*/jsx("div", {
1077
+ });
1078
+ $[13] = t8;
1079
+ $[14] = t9;
1080
+ } else {
1081
+ t9 = $[14];
1082
+ }
1083
+ let t10;
1084
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
1085
+ t10 = /*#__PURE__*/jsx(FormattedMessage, {
1086
+ id: "daHjZg"
1087
+ });
1088
+ $[15] = t10;
1089
+ } else {
1090
+ t10 = $[15];
1091
+ }
1092
+ let t11;
1093
+ if ($[16] !== newValue || $[17] !== props || $[18] !== uploadProps || $[19] !== uppyProps) {
1094
+ t11 = /*#__PURE__*/jsx("div", {
629
1095
  className: "mb-3",
630
- children: /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread(_objectSpread({}, props), uploadProps), {}, {
631
- addButtonLabel: /*#__PURE__*/jsx(FormattedMessage, {
632
- id: "daHjZg",
633
- defaultMessage: [{
634
- "type": 0,
635
- "value": "Edit file"
636
- }]
637
- }),
1096
+ children: /*#__PURE__*/jsx(UploadField, {
1097
+ ...props,
1098
+ ...uploadProps,
1099
+ addButtonLabel: t10,
638
1100
  allowMultipleUploads: false,
639
1101
  linkPath: "panneauUrl",
640
1102
  onChange: onUploadChange,
@@ -643,9 +1105,28 @@ function UpdateFileField(_ref) {
643
1105
  value: newValue,
644
1106
  withButton: true,
645
1107
  uppyProps: uppyProps
646
- }))
647
- })]
648
- });
1108
+ })
1109
+ });
1110
+ $[16] = newValue;
1111
+ $[17] = props;
1112
+ $[18] = uploadProps;
1113
+ $[19] = uppyProps;
1114
+ $[20] = t11;
1115
+ } else {
1116
+ t11 = $[20];
1117
+ }
1118
+ let t12;
1119
+ if ($[21] !== t11 || $[22] !== t9) {
1120
+ t12 = /*#__PURE__*/jsxs(Fragment, {
1121
+ children: [t9, t11]
1122
+ });
1123
+ $[21] = t11;
1124
+ $[22] = t9;
1125
+ $[23] = t12;
1126
+ } else {
1127
+ t12 = $[23];
1128
+ }
1129
+ return t12;
649
1130
  }
650
1131
 
651
1132
  export { AudioField, DocumentField, FontField, ImageField, ImagesField, UpdateFileField, VideoField, UploadField as default, definition };