@panneau/core 3.0.295 → 3.0.307
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/es/contexts.js +1 -1
- package/es/hooks.js +35 -41
- package/es/index.js +3 -3
- package/es/utils.js +35 -39
- package/package.json +2 -2
package/es/contexts.js
CHANGED
|
@@ -2,7 +2,7 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
|
2
2
|
import isString from 'lodash-es/isString';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React, { useContext, useMemo, useState, useEffect, useRef, useCallback } from 'react';
|
|
5
|
-
import { ComponentsManager, PropTypes as PropTypes$1,
|
|
5
|
+
import { ComponentsManager, FieldsManager, PropTypes as PropTypes$1, Tracking } from '@panneau/core';
|
|
6
6
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
7
7
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
8
8
|
import uniqBy from 'lodash-es/uniqBy';
|
package/es/hooks.js
CHANGED
|
@@ -136,30 +136,6 @@ var useActions = function useActions() {
|
|
|
136
136
|
theme: 'primary',
|
|
137
137
|
onClick: onClickEdit
|
|
138
138
|
}, getEditPropsFromItem !== null ? getEditPropsFromItem(item) : null);
|
|
139
|
-
// case 'duplicate':
|
|
140
|
-
// return {
|
|
141
|
-
// id: 'duplicate',
|
|
142
|
-
// component: 'duplicate',
|
|
143
|
-
// label: iconsOnly ? null : duplicateLabel,
|
|
144
|
-
// icon: iconsOnly ? 'copy' : null,
|
|
145
|
-
// href:
|
|
146
|
-
// urlGenerator !== null && !preferDuplicateModal
|
|
147
|
-
// ? urlGenerator('duplicate', {
|
|
148
|
-
// id,
|
|
149
|
-
// }) || null
|
|
150
|
-
// : null,
|
|
151
|
-
// theme: 'warning',
|
|
152
|
-
// onClick: onClickDuplicate,
|
|
153
|
-
// endpoint:
|
|
154
|
-
// urlGenerator !== null && preferDuplicateModal
|
|
155
|
-
// ? urlGenerator('duplicate', {
|
|
156
|
-
// id,
|
|
157
|
-
// }) || null
|
|
158
|
-
// : null,
|
|
159
|
-
// ...(getDuplicatePropsFromItem !== null
|
|
160
|
-
// ? getDuplicatePropsFromItem(item)
|
|
161
|
-
// : null),
|
|
162
|
-
// };
|
|
163
139
|
case 'duplicate':
|
|
164
140
|
return {
|
|
165
141
|
id: 'duplicate',
|
|
@@ -293,7 +269,7 @@ var useDocumentEvent = createUseEvent(eventsManager$1);
|
|
|
293
269
|
var _excluded$1 = ["value", "errors", "onChange"];
|
|
294
270
|
|
|
295
271
|
// prettier-ignore
|
|
296
|
-
var
|
|
272
|
+
var _getFieldsPropsFromFields = function getFieldsPropsFromFields(fields, _ref) {
|
|
297
273
|
var value = _ref.value,
|
|
298
274
|
errors = _ref.errors,
|
|
299
275
|
_onChange = _ref.onChange,
|
|
@@ -303,23 +279,43 @@ var getFieldsPropsFromFields = function getFieldsPropsFromFields(fields, _ref) {
|
|
|
303
279
|
var _ref2 = isObject(field) ? field : {},
|
|
304
280
|
_ref2$name = _ref2.name,
|
|
305
281
|
name = _ref2$name === void 0 ? isString(field) ? field : null : _ref2$name,
|
|
282
|
+
_ref2$fields = _ref2.fields,
|
|
283
|
+
fieldFields = _ref2$fields === void 0 ? null : _ref2$fields,
|
|
306
284
|
_ref2$component = _ref2.component,
|
|
307
285
|
component = _ref2$component === void 0 ? null : _ref2$component;
|
|
308
286
|
var fieldErrors = errors !== null ? errors[name] || [] : [];
|
|
309
|
-
var
|
|
287
|
+
var finalErrors = component === 'localized' ? (locales || []).reduce(function (previousErrors, locale) {
|
|
310
288
|
var items = errors !== null ? get(errors, "".concat(name, ".").concat(locale), []) || [] : [];
|
|
311
289
|
var finalItems = isArray(items) ? items : [items];
|
|
312
290
|
var finalPrevious = isArray(previousErrors) ? previousErrors : [];
|
|
313
291
|
return [].concat(_toConsumableArray(finalPrevious), _toConsumableArray(finalItems));
|
|
314
292
|
}, fieldErrors) : fieldErrors;
|
|
293
|
+
var subfieldErrors = errors;
|
|
294
|
+
if (errors !== null && name !== null) {
|
|
295
|
+
subfieldErrors = Object.keys(errors).reduce(function (acc, key) {
|
|
296
|
+
if (key === name) {
|
|
297
|
+
acc[key] = errors[key];
|
|
298
|
+
}
|
|
299
|
+
if (key.startsWith("".concat(name, ".")) || key.startsWith("".concat(name, "["))) {
|
|
300
|
+
var finalKey = key.substring(name.length + 1);
|
|
301
|
+
acc[finalKey] = errors[key];
|
|
302
|
+
}
|
|
303
|
+
return acc;
|
|
304
|
+
}, {});
|
|
305
|
+
}
|
|
315
306
|
return [].concat(_toConsumableArray(allFields), [_objectSpread(_objectSpread({}, isObject(field) ? field : null), {}, {
|
|
316
307
|
name: name,
|
|
317
308
|
component: component,
|
|
318
309
|
value: value !== null ? value[name] || null : null,
|
|
319
|
-
errors:
|
|
310
|
+
errors: finalErrors.length > 0 ? finalErrors : null,
|
|
320
311
|
onChange: function onChange(fieldValue) {
|
|
321
312
|
return _onChange(name, fieldValue);
|
|
322
|
-
}
|
|
313
|
+
},
|
|
314
|
+
fields: fieldFields !== null ? _getFieldsPropsFromFields(fieldFields, {
|
|
315
|
+
value: value !== null && name !== null && isObject(value[name]) ? value[name] : null,
|
|
316
|
+
errors: subfieldErrors,
|
|
317
|
+
onChange: _onChange
|
|
318
|
+
}, locales) : null
|
|
323
319
|
}, props)]);
|
|
324
320
|
}, []);
|
|
325
321
|
};
|
|
@@ -380,9 +376,9 @@ var useForm = function useForm() {
|
|
|
380
376
|
requestState = _useState8[0],
|
|
381
377
|
setRequestState = _useState8[1];
|
|
382
378
|
var _useState9 = useState(null),
|
|
383
|
-
|
|
384
|
-
response =
|
|
385
|
-
setResponse =
|
|
379
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
380
|
+
response = _useState0[0],
|
|
381
|
+
setResponse = _useState0[1];
|
|
386
382
|
var hasProvidedValue = setProvidedValue !== null;
|
|
387
383
|
var value = hasProvidedValue ? providedValue : stateValue;
|
|
388
384
|
var setValue = hasProvidedValue ? setProvidedValue : setStateValue;
|
|
@@ -415,7 +411,7 @@ var useForm = function useForm() {
|
|
|
415
411
|
setValue(_objectSpread(_objectSpread({}, value), {}, _defineProperty({}, fieldName, fieldValue)));
|
|
416
412
|
}, fieldsKey);
|
|
417
413
|
var fieldsProps = useMemo(function () {
|
|
418
|
-
return
|
|
414
|
+
return _getFieldsPropsFromFields(fields, {
|
|
419
415
|
value: value,
|
|
420
416
|
errors: errors,
|
|
421
417
|
onChange: onFieldChange
|
|
@@ -892,18 +888,17 @@ var useMediaApi = function useMediaApi() {
|
|
|
892
888
|
playing = _useState8[0],
|
|
893
889
|
setPlaying = _useState8[1];
|
|
894
890
|
var _useState9 = useState(false),
|
|
895
|
-
|
|
896
|
-
ready =
|
|
897
|
-
setReady =
|
|
898
|
-
var
|
|
899
|
-
|
|
900
|
-
initialPlay =
|
|
901
|
-
setInitialPlay =
|
|
891
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
892
|
+
ready = _useState0[0],
|
|
893
|
+
setReady = _useState0[1];
|
|
894
|
+
var _useState1 = useState(true),
|
|
895
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
896
|
+
initialPlay = _useState10[0],
|
|
897
|
+
setInitialPlay = _useState10[1];
|
|
902
898
|
var progressStepsReached = useRef({});
|
|
903
899
|
var paused = !playing;
|
|
904
900
|
|
|
905
901
|
// Exposed methods
|
|
906
|
-
|
|
907
902
|
var play = useCallback(function () {
|
|
908
903
|
var media = ref.current;
|
|
909
904
|
if (media !== null) {
|
|
@@ -959,7 +954,6 @@ var useMediaApi = function useMediaApi() {
|
|
|
959
954
|
}, [muted]);
|
|
960
955
|
|
|
961
956
|
// Media events callbacks
|
|
962
|
-
|
|
963
957
|
var onCustomPlay = useCallback(function () {
|
|
964
958
|
if (onPlay !== null) {
|
|
965
959
|
onPlay({
|
package/es/index.js
CHANGED
|
@@ -771,9 +771,9 @@ var MediasParser = /*#__PURE__*/function () {
|
|
|
771
771
|
var keyPrefix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
772
772
|
var dataIsArray = isArray(data);
|
|
773
773
|
var keys = dataIsArray ? _toConsumableArray(data.keys()) : Object.keys(data);
|
|
774
|
-
return keys.reduce(function (
|
|
775
|
-
var currentData =
|
|
776
|
-
currentMedias =
|
|
774
|
+
return keys.reduce(function (_ref0, key) {
|
|
775
|
+
var currentData = _ref0.data,
|
|
776
|
+
currentMedias = _ref0.medias;
|
|
777
777
|
var path = [keyPrefix, key].filter(function (it) {
|
|
778
778
|
return it !== null;
|
|
779
779
|
}).join('.');
|
package/es/utils.js
CHANGED
|
@@ -2,7 +2,7 @@ import isNumber from 'lodash-es/isNumber';
|
|
|
2
2
|
import { snakeCase } from 'snake-case';
|
|
3
3
|
import isObject from 'lodash-es/isObject';
|
|
4
4
|
import { useEffect, isValidElement } from 'react';
|
|
5
|
-
import
|
|
5
|
+
import _regenerator from '@babel/runtime/helpers/regenerator';
|
|
6
6
|
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
7
7
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
8
8
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
@@ -110,20 +110,17 @@ function copyClipboardApi(_x) {
|
|
|
110
110
|
return _copyClipboardApi.apply(this, arguments);
|
|
111
111
|
}
|
|
112
112
|
function _copyClipboardApi() {
|
|
113
|
-
_copyClipboardApi = _asyncToGenerator(/*#__PURE__*/
|
|
114
|
-
return
|
|
115
|
-
while (1) switch (_context.
|
|
113
|
+
_copyClipboardApi = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(text) {
|
|
114
|
+
return _regenerator().w(function (_context) {
|
|
115
|
+
while (1) switch (_context.n) {
|
|
116
116
|
case 0:
|
|
117
117
|
if (navigator.clipboard) {
|
|
118
|
-
_context.
|
|
118
|
+
_context.n = 1;
|
|
119
119
|
break;
|
|
120
120
|
}
|
|
121
121
|
throw makeError();
|
|
122
|
-
case
|
|
123
|
-
return _context.
|
|
124
|
-
case 3:
|
|
125
|
-
case "end":
|
|
126
|
-
return _context.stop();
|
|
122
|
+
case 1:
|
|
123
|
+
return _context.a(2, navigator.clipboard.writeText(text));
|
|
127
124
|
}
|
|
128
125
|
}, _callee);
|
|
129
126
|
}));
|
|
@@ -133,10 +130,10 @@ function copyExecCommand(_x2) {
|
|
|
133
130
|
return _copyExecCommand.apply(this, arguments);
|
|
134
131
|
}
|
|
135
132
|
function _copyExecCommand() {
|
|
136
|
-
_copyExecCommand = _asyncToGenerator(/*#__PURE__*/
|
|
133
|
+
_copyExecCommand = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(text) {
|
|
137
134
|
var span, selection, range, success;
|
|
138
|
-
return
|
|
139
|
-
while (1) switch (_context2.
|
|
135
|
+
return _regenerator().w(function (_context2) {
|
|
136
|
+
while (1) switch (_context2.n) {
|
|
140
137
|
case 0:
|
|
141
138
|
// Put the text to copy into a <span>
|
|
142
139
|
span = document.createElement('span');
|
|
@@ -167,13 +164,12 @@ function _copyExecCommand() {
|
|
|
167
164
|
window.document.body.removeChild(span);
|
|
168
165
|
}
|
|
169
166
|
if (success) {
|
|
170
|
-
_context2.
|
|
167
|
+
_context2.n = 1;
|
|
171
168
|
break;
|
|
172
169
|
}
|
|
173
170
|
throw makeError();
|
|
174
|
-
case
|
|
175
|
-
|
|
176
|
-
return _context2.stop();
|
|
171
|
+
case 1:
|
|
172
|
+
return _context2.a(2);
|
|
177
173
|
}
|
|
178
174
|
}, _callee2);
|
|
179
175
|
}));
|
|
@@ -183,34 +179,34 @@ function copyToClipboard(_x3) {
|
|
|
183
179
|
return _copyToClipboard.apply(this, arguments);
|
|
184
180
|
}
|
|
185
181
|
function _copyToClipboard() {
|
|
186
|
-
_copyToClipboard = _asyncToGenerator(/*#__PURE__*/
|
|
187
|
-
|
|
188
|
-
|
|
182
|
+
_copyToClipboard = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(text) {
|
|
183
|
+
var _t, _t2;
|
|
184
|
+
return _regenerator().w(function (_context3) {
|
|
185
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
189
186
|
case 0:
|
|
190
|
-
_context3.
|
|
191
|
-
_context3.
|
|
187
|
+
_context3.p = 0;
|
|
188
|
+
_context3.n = 1;
|
|
192
189
|
return copyClipboardApi(text);
|
|
193
|
-
case
|
|
194
|
-
_context3.
|
|
190
|
+
case 1:
|
|
191
|
+
_context3.n = 6;
|
|
195
192
|
break;
|
|
196
|
-
case
|
|
197
|
-
_context3.
|
|
198
|
-
|
|
199
|
-
_context3.
|
|
200
|
-
_context3.
|
|
193
|
+
case 2:
|
|
194
|
+
_context3.p = 2;
|
|
195
|
+
_t = _context3.v;
|
|
196
|
+
_context3.p = 3;
|
|
197
|
+
_context3.n = 4;
|
|
201
198
|
return copyExecCommand(text);
|
|
202
|
-
case
|
|
203
|
-
_context3.
|
|
199
|
+
case 4:
|
|
200
|
+
_context3.n = 6;
|
|
204
201
|
break;
|
|
205
|
-
case
|
|
206
|
-
_context3.
|
|
207
|
-
|
|
208
|
-
throw
|
|
209
|
-
case
|
|
210
|
-
|
|
211
|
-
return _context3.stop();
|
|
202
|
+
case 5:
|
|
203
|
+
_context3.p = 5;
|
|
204
|
+
_t2 = _context3.v;
|
|
205
|
+
throw _t2 || _t || makeError();
|
|
206
|
+
case 6:
|
|
207
|
+
return _context3.a(2);
|
|
212
208
|
}
|
|
213
|
-
}, _callee3, null, [[
|
|
209
|
+
}, _callee3, null, [[3, 5], [0, 2]]);
|
|
214
210
|
}));
|
|
215
211
|
return _copyToClipboard.apply(this, arguments);
|
|
216
212
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.307",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"publishConfig": {
|
|
111
111
|
"access": "public"
|
|
112
112
|
},
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "cbe5e8b1705d01c5653a4df617a06243344310d3"
|
|
114
114
|
}
|