@panneau/core 4.0.14 → 4.0.15

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/utils.js CHANGED
@@ -33,7 +33,6 @@ function checkClickable(el) {
33
33
  tagName = _ref2$tagName === void 0 ? null : _ref2$tagName,
34
34
  _ref2$parentNode = _ref2.parentNode,
35
35
  parentNode = _ref2$parentNode === void 0 ? null : _ref2$parentNode;
36
- _ref2.dataset;
37
36
  if (tagName === 'BODY') {
38
37
  return false;
39
38
  }
@@ -58,15 +57,15 @@ function checkClickable(el) {
58
57
  return false;
59
58
  }
60
59
 
61
- var convertStyleToString = function convertStyleToString(style) {
60
+ function convertStyleToString(style) {
62
61
  return style !== null ? Object.keys(style).map(function (key) {
63
62
  return "".concat(snakeCase(key), ":").concat(isNumber(style[key]) ? "".concat(style[key], "px") : style[key], ";");
64
63
  }).join('\n') : '';
65
- };
64
+ }
66
65
 
67
- var createNullableOnChange = function createNullableOnChange() {
66
+ function createNullableOnChange() {
68
67
  var onChange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
69
- return function (newValue) {
68
+ return function nullableOnChange(newValue) {
70
69
  var nullableValue = newValue;
71
70
  if (isObject(newValue)) {
72
71
  var allNull = Object.keys(newValue).reduce(function (acc, key) {
@@ -80,10 +79,10 @@ var createNullableOnChange = function createNullableOnChange() {
80
79
  onChange(nullableValue);
81
80
  }
82
81
  };
83
- };
82
+ }
84
83
 
85
- var createUseEvent = function createUseEvent(eventsManager) {
86
- return function (event, callback) {
84
+ function createUseEvent(eventsManager) {
85
+ return function useEvent(event, callback) {
87
86
  var enabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
88
87
  useEffect(function () {
89
88
  if (enabled && eventsManager !== null) {
@@ -96,7 +95,7 @@ var createUseEvent = function createUseEvent(eventsManager) {
96
95
  };
97
96
  }, [eventsManager, event, callback, enabled]);
98
97
  };
99
- };
98
+ }
100
99
 
101
100
  /*! clipboard-copy. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
102
101
 
@@ -211,17 +210,17 @@ function _copyToClipboard() {
211
210
  return _copyToClipboard.apply(this, arguments);
212
211
  }
213
212
 
214
- var _flattenComponents = function flattenComponents(components) {
213
+ function flattenComponents(components) {
215
214
  var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
216
215
  if (components === null) {
217
216
  return null;
218
217
  }
219
218
  return Object.keys(components).reduce(function (newMap, key) {
220
- return ReactIs.isValidElementType(components[key]) ? _objectSpread(_objectSpread({}, newMap), {}, _defineProperty({}, prefix !== null ? "".concat(prefix, ".").concat(key) : key, components[key])) : _objectSpread(_objectSpread({}, newMap), _flattenComponents(components[key], key));
219
+ return ReactIs.isValidElementType(components[key]) ? _objectSpread(_objectSpread({}, newMap), {}, _defineProperty({}, prefix !== null ? "".concat(prefix, ".").concat(key) : key, components[key])) : _objectSpread(_objectSpread({}, newMap), flattenComponents(components[key], key));
221
220
  }, {});
222
- };
221
+ }
223
222
 
224
- var formatDuration = function formatDuration(timeInSeconds) {
223
+ function formatDuration(timeInSeconds) {
225
224
  var numberOfSeconds = parseInt(String(timeInSeconds), 10); // don't forget the second param
226
225
  var hours = Math.floor(numberOfSeconds / 3600);
227
226
  var minutes = Math.floor((numberOfSeconds - hours * 3600) / 60);
@@ -236,10 +235,10 @@ var formatDuration = function formatDuration(timeInSeconds) {
236
235
  seconds = "0".concat(seconds);
237
236
  }
238
237
  return "".concat(hours, ":").concat(minutes, ":").concat(seconds);
239
- };
238
+ }
240
239
 
241
240
  var _excluded$1 = ["component"];
242
- var getComponent = function getComponent(component) {
241
+ function getComponent(component) {
243
242
  var _ref = isObject(component) ? component : {
244
243
  component: component
245
244
  };
@@ -249,10 +248,10 @@ var getComponent = function getComponent(component) {
249
248
  name: component,
250
249
  props: Object.keys(props).length > 0 ? props : null
251
250
  };
252
- };
251
+ }
253
252
 
254
253
  var _excluded = ["id", "field"];
255
- var getColumnFromField = function getColumnFromField(field) {
254
+ function getColumnFromField(field) {
256
255
  if (field === null) {
257
256
  return null;
258
257
  }
@@ -276,8 +275,8 @@ var getColumnFromField = function getColumnFromField(field) {
276
275
  component: componentName,
277
276
  field: field
278
277
  });
279
- };
280
- var getColumnsWithFields = function getColumnsWithFields(resource, columns) {
278
+ }
279
+ function getColumnsWithFields(resource, columns) {
281
280
  var _resource$fields = resource.fields,
282
281
  fields = _resource$fields === void 0 ? [] : _resource$fields;
283
282
  var newColumns = columns !== null ? columns.map(function (column) {
@@ -299,9 +298,9 @@ var getColumnsWithFields = function getColumnsWithFields(resource, columns) {
299
298
  return it !== null;
300
299
  }) : [];
301
300
  return newColumns;
302
- };
301
+ }
303
302
 
304
- var getComponentFromName = function getComponentFromName() {
303
+ function getComponentFromName() {
305
304
  var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
306
305
  var components = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
307
306
  var defaultComponent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
@@ -314,9 +313,9 @@ var getComponentFromName = function getComponentFromName() {
314
313
  console.warn('Could not find component from name', name, pascalName, components);
315
314
  }
316
315
  return component;
317
- };
316
+ }
318
317
 
319
- var getDefinitionFromId = function getDefinitionFromId() {
318
+ function getDefinitionFromId() {
320
319
  var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
321
320
  var items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
322
321
  var defaultObject = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
@@ -329,17 +328,17 @@ var getDefinitionFromId = function getDefinitionFromId() {
329
328
  }) || items.find(function (i) {
330
329
  return i.id === id;
331
330
  }) || defaultObject;
332
- };
331
+ }
333
332
 
334
- var getDisplayName = function getDisplayName(_ref) {
333
+ function getDisplayName(_ref) {
335
334
  var _ref$displayName = _ref.displayName,
336
335
  displayName = _ref$displayName === void 0 ? null : _ref$displayName,
337
336
  _ref$name = _ref.name,
338
337
  name = _ref$name === void 0 ? null : _ref$name;
339
338
  return displayName || name || 'Component';
340
- };
339
+ }
341
340
 
342
- var _getFieldByName = function getFieldByName(fields, name) {
341
+ function getFieldByName(fields, name) {
343
342
  return fields.reduce(function (foundField, it) {
344
343
  if (foundField !== null) {
345
344
  return foundField;
@@ -351,11 +350,11 @@ var _getFieldByName = function getFieldByName(fields, name) {
351
350
  if (name !== null && fieldName === name) {
352
351
  return it;
353
352
  }
354
- return _getFieldByName(subFields, name);
353
+ return getFieldByName(subFields, name);
355
354
  }, null);
356
- };
355
+ }
357
356
 
358
- var getFieldFromPath = function getFieldFromPath(path, fields, fieldManager) {
357
+ function getFieldFromPath(path, fields, fieldManager) {
359
358
  return (isArray(path) ? path : [path]).reduce(function (foundField, key) {
360
359
  if (foundField === null) {
361
360
  return null;
@@ -380,29 +379,29 @@ var getFieldFromPath = function getFieldFromPath(path, fields, fieldManager) {
380
379
  listItems: true
381
380
  });
382
381
  }
383
- return _getFieldByName([].concat(_toConsumableArray(fieldFields || []), _toConsumableArray(subFields || []), _toConsumableArray(settings || [])), key);
382
+ return getFieldByName([].concat(_toConsumableArray(fieldFields || []), _toConsumableArray(subFields || []), _toConsumableArray(settings || [])), key);
384
383
  }, {
385
384
  fields: fields
386
385
  });
387
- };
386
+ }
388
387
 
389
- var getFileName = function getFileName() {
388
+ function getFileName() {
390
389
  var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
391
390
  if (url === null || typeof url.match === 'undefined') {
392
391
  return null;
393
392
  }
394
393
  var match = url.match(/([^/]+)(\?.*)?$/);
395
394
  return match ? match[1] : url;
396
- };
395
+ }
397
396
 
398
- var getPathValue = function getPathValue(it, path) {
397
+ function getPathValue(it, path) {
399
398
  var value = get(it, path, null);
400
399
  return value !== null && isObject(value) ? Object.values(value).reduce(function (foundValue, val) {
401
400
  return foundValue !== null ? foundValue : val;
402
401
  }, null) : value;
403
- };
402
+ }
404
403
 
405
- var getSelectOptions = function getSelectOptions(options) {
404
+ function getSelectOptions(options) {
406
405
  return options.map(function (it) {
407
406
  if (isObject(it)) {
408
407
  var _ref = it,
@@ -425,11 +424,11 @@ var getSelectOptions = function getSelectOptions(options) {
425
424
  label: capitalize("".concat(it))
426
425
  };
427
426
  });
428
- };
427
+ }
429
428
 
430
- var isMessage = function isMessage(message) {
429
+ function isMessage(message) {
431
430
  return isObject(message) && typeof message.defaultMessage !== 'undefined';
432
- };
431
+ }
433
432
 
434
433
  /**
435
434
  * Locale loader
@@ -541,7 +540,7 @@ function selectPage(pageSelected, items, selectedItems, onSelectionChange) {
541
540
  }
542
541
  }
543
542
 
544
- var _setValue = function setValue(value, keyParts, fieldValue) {
543
+ function setValue(value, keyParts, fieldValue) {
545
544
  var key = keyParts.shift();
546
545
  if (!key) {
547
546
  return value;
@@ -551,16 +550,16 @@ var _setValue = function setValue(value, keyParts, fieldValue) {
551
550
  if (isArray) {
552
551
  var index = parseInt(key, 10);
553
552
  var arrayValue = value;
554
- var newArrayValue = fieldValue !== null ? [].concat(_toConsumableArray(arrayValue.slice(0, index)), [keyParts.length > 0 ? _setValue(arrayValue !== null ? arrayValue[index] || null : null, keyParts, fieldValue) : fieldValue], _toConsumableArray(arrayValue.slice(index + 1))) : [].concat(_toConsumableArray(arrayValue.slice(0, index)), _toConsumableArray(arrayValue.slice(index + 1)));
553
+ var newArrayValue = fieldValue !== null ? [].concat(_toConsumableArray(arrayValue.slice(0, index)), [keyParts.length > 0 ? setValue(arrayValue !== null ? arrayValue[index] || null : null, keyParts, fieldValue) : fieldValue], _toConsumableArray(arrayValue.slice(index + 1))) : [].concat(_toConsumableArray(arrayValue.slice(0, index)), _toConsumableArray(arrayValue.slice(index + 1)));
555
554
  return newArrayValue.length > 0 ? newArrayValue : null;
556
555
  }
557
556
  var objectValue = value;
558
- return _objectSpread(_objectSpread({}, objectValue), {}, _defineProperty({}, key, keyParts.length > 0 ? _setValue(objectValue !== null ? objectValue[key] || null : null, keyParts, fieldValue) : fieldValue));
557
+ return _objectSpread(_objectSpread({}, objectValue), {}, _defineProperty({}, key, keyParts.length > 0 ? setValue(objectValue !== null ? objectValue[key] || null : null, keyParts, fieldValue) : fieldValue));
559
558
  }
560
559
  return null;
561
- };
560
+ }
562
561
 
563
- var slug = function slug(str) {
562
+ function slug(str) {
564
563
  var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
565
564
  var toSlug;
566
565
  if (separator === '-') {
@@ -571,19 +570,19 @@ var slug = function slug(str) {
571
570
  return slugify(toSlug, {
572
571
  lower: true
573
572
  });
574
- };
573
+ }
575
574
 
576
- var _validateFields = function validateFields(fields, value) {
575
+ function validateFields(fields, value) {
577
576
  return fields.reduce(function (acc, field) {
578
577
  if (acc === true) {
579
578
  if (field.type === 'fields' && field.fields) {
580
- return _validateFields(field.fields, value);
579
+ return validateFields(field.fields, value);
581
580
  }
582
581
  var val = value && field.name && value[field.name] ? value[field.name] : false;
583
582
  return !(field.required && !val);
584
583
  }
585
584
  return acc;
586
585
  }, true);
587
- };
586
+ }
588
587
 
589
- export { checkClickable, convertStyleToString, copyToClipboard, createNullableOnChange, createUseEvent, _flattenComponents as flattenComponents, formatDuration, getColumnsWithFields, getComponent, getComponentFromName, getDefinitionFromId, getDisplayName, _getFieldByName as getFieldByName, getFieldFromPath, getFileName, getPathValue, getSelectOptions, isMessage, loadPackage, selectItem, selectPage, _setValue as setFieldValue, slug, _validateFields as validateFields };
588
+ export { checkClickable, convertStyleToString, copyToClipboard, createNullableOnChange, createUseEvent, flattenComponents, formatDuration, getColumnsWithFields, getComponent, getComponentFromName, getDefinitionFromId, getDisplayName, getFieldByName, getFieldFromPath, getFileName, getPathValue, getSelectOptions, isMessage, loadPackage, selectItem, selectPage, setValue as setFieldValue, slug, validateFields };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/core",
3
- "version": "4.0.14",
3
+ "version": "4.0.15",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -96,5 +96,5 @@
96
96
  "publishConfig": {
97
97
  "access": "public"
98
98
  },
99
- "gitHead": "ce35c2ddb30a7be2efe951882d9826dca577f5d4"
99
+ "gitHead": "83c02ca2f26e02383ef452ffcafda984d0b211cd"
100
100
  }