@panneau/core 3.0.300 → 3.0.314
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 +36 -16
- 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
|
@@ -269,33 +269,53 @@ var useDocumentEvent = createUseEvent(eventsManager$1);
|
|
|
269
269
|
var _excluded$1 = ["value", "errors", "onChange"];
|
|
270
270
|
|
|
271
271
|
// prettier-ignore
|
|
272
|
-
var
|
|
272
|
+
var _getFieldsPropsFromFields = function getFieldsPropsFromFields(fields, _ref) {
|
|
273
273
|
var value = _ref.value,
|
|
274
274
|
errors = _ref.errors,
|
|
275
275
|
_onChange = _ref.onChange,
|
|
276
276
|
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
277
277
|
var locales = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
278
|
-
return fields.reduce(function (allFields, field) {
|
|
278
|
+
return (fields || []).reduce(function (allFields, field) {
|
|
279
279
|
var _ref2 = isObject(field) ? field : {},
|
|
280
280
|
_ref2$name = _ref2.name,
|
|
281
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,
|
|
282
284
|
_ref2$component = _ref2.component,
|
|
283
285
|
component = _ref2$component === void 0 ? null : _ref2$component;
|
|
284
286
|
var fieldErrors = errors !== null ? errors[name] || [] : [];
|
|
285
|
-
var
|
|
287
|
+
var finalErrors = component === 'localized' ? (locales || []).reduce(function (previousErrors, locale) {
|
|
286
288
|
var items = errors !== null ? get(errors, "".concat(name, ".").concat(locale), []) || [] : [];
|
|
287
289
|
var finalItems = isArray(items) ? items : [items];
|
|
288
290
|
var finalPrevious = isArray(previousErrors) ? previousErrors : [];
|
|
289
291
|
return [].concat(_toConsumableArray(finalPrevious), _toConsumableArray(finalItems));
|
|
290
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
|
+
}
|
|
291
306
|
return [].concat(_toConsumableArray(allFields), [_objectSpread(_objectSpread({}, isObject(field) ? field : null), {}, {
|
|
292
307
|
name: name,
|
|
293
308
|
component: component,
|
|
294
309
|
value: value !== null ? value[name] || null : null,
|
|
295
|
-
errors:
|
|
310
|
+
errors: finalErrors.length > 0 ? finalErrors : null,
|
|
296
311
|
onChange: function onChange(fieldValue) {
|
|
297
312
|
return _onChange(name, fieldValue);
|
|
298
|
-
}
|
|
313
|
+
},
|
|
314
|
+
fields: fieldFields !== null && isArray(fieldFields) ? _getFieldsPropsFromFields(fieldFields, {
|
|
315
|
+
value: value !== null && name !== null && isObject(value[name]) ? value[name] : null,
|
|
316
|
+
errors: subfieldErrors,
|
|
317
|
+
onChange: _onChange
|
|
318
|
+
}, locales) : null
|
|
299
319
|
}, props)]);
|
|
300
320
|
}, []);
|
|
301
321
|
};
|
|
@@ -356,9 +376,9 @@ var useForm = function useForm() {
|
|
|
356
376
|
requestState = _useState8[0],
|
|
357
377
|
setRequestState = _useState8[1];
|
|
358
378
|
var _useState9 = useState(null),
|
|
359
|
-
|
|
360
|
-
response =
|
|
361
|
-
setResponse =
|
|
379
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
380
|
+
response = _useState0[0],
|
|
381
|
+
setResponse = _useState0[1];
|
|
362
382
|
var hasProvidedValue = setProvidedValue !== null;
|
|
363
383
|
var value = hasProvidedValue ? providedValue : stateValue;
|
|
364
384
|
var setValue = hasProvidedValue ? setProvidedValue : setStateValue;
|
|
@@ -391,7 +411,7 @@ var useForm = function useForm() {
|
|
|
391
411
|
setValue(_objectSpread(_objectSpread({}, value), {}, _defineProperty({}, fieldName, fieldValue)));
|
|
392
412
|
}, fieldsKey);
|
|
393
413
|
var fieldsProps = useMemo(function () {
|
|
394
|
-
return
|
|
414
|
+
return _getFieldsPropsFromFields(fields || [], {
|
|
395
415
|
value: value,
|
|
396
416
|
errors: errors,
|
|
397
417
|
onChange: onFieldChange
|
|
@@ -868,13 +888,13 @@ var useMediaApi = function useMediaApi() {
|
|
|
868
888
|
playing = _useState8[0],
|
|
869
889
|
setPlaying = _useState8[1];
|
|
870
890
|
var _useState9 = useState(false),
|
|
871
|
-
|
|
872
|
-
ready =
|
|
873
|
-
setReady =
|
|
874
|
-
var
|
|
875
|
-
|
|
876
|
-
initialPlay =
|
|
877
|
-
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];
|
|
878
898
|
var progressStepsReached = useRef({});
|
|
879
899
|
var paused = !playing;
|
|
880
900
|
|
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.314",
|
|
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": "4f73f877d9d2468145fe1173106b08e6ecdc24a5"
|
|
114
114
|
}
|