json-edit-react 0.9.1 → 0.9.3

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/README.md CHANGED
@@ -335,6 +335,7 @@ This component is heavily inspired by [react-json-view](https://github.com/mac-s
335
335
 
336
336
  ## Changelog
337
337
 
338
- - **0.9.0**: Initial release
338
+ - **0.9.3**: Bundle as ES6 module
339
339
  - **0.9.1**: Export more Types from the package
340
+ - **0.9.0**: Initial release
340
341
 
@@ -12,6 +12,45 @@ var fi = require('react-icons/fi');
12
12
  var ti = require('react-icons/ti');
13
13
  var fa = require('react-icons/fa');
14
14
 
15
+ /******************************************************************************
16
+ Copyright (c) Microsoft Corporation.
17
+
18
+ Permission to use, copy, modify, and/or distribute this software for any
19
+ purpose with or without fee is hereby granted.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
22
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
23
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
24
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
25
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27
+ PERFORMANCE OF THIS SOFTWARE.
28
+ ***************************************************************************** */
29
+ /* global Reflect, Promise */
30
+
31
+
32
+ function __rest(s, e) {
33
+ var t = {};
34
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
35
+ t[p] = s[p];
36
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
37
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
38
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
39
+ t[p[i]] = s[p[i]];
40
+ }
41
+ return t;
42
+ }
43
+
44
+ function __awaiter(thisArg, _arguments, P, generator) {
45
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
46
+ return new (P || (P = Promise))(function (resolve, reject) {
47
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
48
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
49
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
50
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
51
+ });
52
+ }
53
+
15
54
  var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
16
55
 
17
56
  var css = ":root {\n --jer-form-border: 1px solid #ededf0;\n --jer-form-border-focus: 1px solid #e2e2e2;\n --jer-expand-transition-time: 0.2s;\n --jer-highlight-color: #b3d8ff;\n}\n.jer-editor-container {\n font-size: 1.1em;\n /* font-size: 20px; */\n padding: 1em;\n margin-top: 1em;\n margin-bottom: 1em;\n border-radius: 0.5em;\n}\n\n.jer-editor-container textarea {\n /* width: 90%; */\n color: var(--jer-input-color);\n border: var(--jer-form-border);\n border-radius: 0.3em;\n outline: none;\n}\n\n.jer-editor-container textarea:focus {\n border: var(--jer-form-border-focus);\n}\n\n.jer-editor-container input {\n border: var(--jer-form-border);\n border-radius: 0.3em;\n outline: none;\n}\n\n.jer-editor-container input:focus {\n border: var(--jer-form-border-focus);\n}\n\n/* Input highlighted text */\n.jer-editor-container ::selection {\n background-color: var(--jer-highlight-color);\n}\n\n.jer-editor-container select {\n /* color: red; */\n}\n\n.jer-component {\n}\n\n.fb-collection-component {\n}\n\n.jer-collection-header-row,\n.jer-value-main-row {\n display: flex;\n min-height: 1.7em;\n gap: 0.3em;\n align-items: center;\n}\n\n.jer-collection-header-row {\n display: flex;\n flex-wrap: wrap;\n}\n\n.jer-brackets {\n}\n\n.jer-collection-item-count {\n}\n\n.jer-collection-inner {\n position: relative;\n}\n\n.jer-collection-text-edit {\n display: flex;\n flex-direction: column;\n gap: 0.3em;\n}\n\n.jer-collection-text-area {\n resize: both;\n padding-top: 0.2em;\n padding-left: 0.5em;\n padding-right: 0.5em;\n padding-bottom: 0;\n overflow: hidden;\n max-height: 40em;\n}\n\n.jer-collection-input-button-row {\n width: 90%;\n display: flex;\n justify-content: flex-end;\n font-size: 150%;\n}\n\n.jer-collection-element {\n}\n\n.jer-collection-error-row {\n position: absolute;\n bottom: 0;\n}\n\n.jer-collection-error-row-edit {\n}\n\n.jer-error-slug {\n margin-left: 1em;\n}\n\n.jer-value-component {\n position: relative;\n}\n\n.jer-value-main-row {\n display: flex;\n}\n\n.jer-value-error-row {\n position: absolute;\n}\n\n.jer-value-string {\n line-height: 1.3em;\n}\n\n.jer-input-text {\n resize: none;\n margin: 0;\n height: 1.4em;\n padding-left: 0.5em;\n padding-right: 0.5em;\n padding-bottom: 0;\n min-width: 6em;\n overflow: hidden;\n max-height: 30em;\n}\n\n/* To prevent over-writing by UI libraries */\n.jer-type-select {\n border: revert;\n border-radius: revert;\n padding: revert;\n font-family: revert;\n font-size: revert;\n color: revert;\n}\n\n.jer-value-number {\n}\n\n.jer-value-boolean {\n}\n\n.jer-value-null {\n}\n\n.jer-value-object {\n}\n\n.jer-object-key {\n word-break: break-word;\n line-height: 1.1em;\n}\n\n.jer-value-array {\n}\n\n.jer-value-invalid {\n opacity: 0.5;\n font-style: italic;\n}\n\n/* .jer-input-text, */\n.jer-input-number {\n height: 1.6em;\n}\n\n.jer-input-number {\n min-width: 3em;\n}\n\n.jer-input-component {\n}\n\n.jer-edit-buttons,\n.jer-confirm-buttons {\n display: flex;\n align-items: center;\n cursor: pointer;\n}\n\n.jer-input-buttons {\n gap: 0.4em;\n}\n\n.jer-edit-buttons {\n gap: 0.4em;\n margin-left: 0.5em;\n opacity: 0;\n}\n\n.jer-confirm-buttons {\n gap: 0.2em;\n margin-left: 0.4em;\n}\n\n.jer-edit-buttons:hover {\n opacity: 1;\n position: relative;\n}\n\n.jer-collection-header-row:hover > .jer-edit-buttons {\n opacity: 1;\n}\n\n.jer-value-main-row:hover > .jer-edit-buttons {\n opacity: 1;\n}\n\n.jer-input-buttons {\n}\n\n.jer-icon-wrapper {\n height: 1.4em;\n opacity: 1;\n transition: 0.2s;\n}\n\n.jer-icon-wrapper:active {\n position: relative;\n top: 0.07em;\n}\n\n.jer-icon-wrapper:hover {\n opacity: 0.85;\n transition: 0.2s;\n transform: scale(1.2);\n}\n\n.jer-copy-pulse {\n position: relative;\n}\n\n.jer-copy-pulse:hover {\n}\n\n.jer-copy-pulse:after {\n content: '';\n display: block;\n position: absolute;\n border-radius: 50%;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n opacity: 0;\n transition: all 0.5s;\n box-shadow: 0 0 15px 5px var(--jer-icon-copy-color);\n}\n\n.jer-copy-pulse:active:after {\n box-shadow: 0 0 0 0 var(--jer-icon-copy-color);\n position: absolute;\n border-radius: 4em;\n left: 0;\n top: 0;\n opacity: 1;\n transition: 0s;\n}\n\n.jer-copy-pulse:active {\n top: 0.07em;\n}\n\n.jer-rotate-90 {\n transform: rotate(-90deg);\n transition: transform var(--jer-expand-transition-time);\n}\n\n.jer-icon {\n /* font-size: '2em'; */\n}\n\n.jer-icon:hover {\n opacity: 0.85;\n transition: 0.3s;\n transform: scale(1.2);\n}\n";
@@ -273,7 +312,7 @@ const ThemeProvider = ({ children }) => {
273
312
  const [styles, setStyles] = react.useState(emptyStyleObject);
274
313
  const [icons, setIcons] = react.useState({});
275
314
  const setTheme = (theme) => setStyles(compileStyles(theme));
276
- return (jsxRuntime.jsx(ThemeProviderContext.Provider, { value: { styles, setTheme, icons, setIcons }, children: children }));
315
+ return (jsxRuntime.jsx(ThemeProviderContext.Provider, Object.assign({ value: { styles, setTheme, icons, setIcons } }, { children: children })));
277
316
  };
278
317
  const useTheme = () => react.useContext(ThemeProviderContext);
279
318
  const compileStyles = (themeInput) => {
@@ -286,23 +325,25 @@ const compileStyles = (themeInput) => {
286
325
  return buildStyleObject(defaultTheme, isStyleObject(themeInput) ? { styles: themeInput } : themeInput);
287
326
  };
288
327
  const buildStyleObject = (baseTheme, overrides = { styles: emptyStyleObject }) => {
328
+ var _a, _b, _c, _d;
289
329
  const [defaultStyles, baseStyles, overrideStyles] = [defaultTheme, baseTheme, overrides].map((theme) => {
290
330
  const { fragments, styles } = theme;
291
331
  const compiledStyles = {};
292
332
  Object.entries(styles).forEach(([key, value]) => {
293
333
  const elements = Array.isArray(value) ? value : [value];
294
334
  const cssStyles = elements.reduce((acc, curr) => {
335
+ var _a;
295
336
  if (typeof curr === 'string') {
296
- const style = fragments?.[curr] ?? curr;
337
+ const style = (_a = fragments === null || fragments === void 0 ? void 0 : fragments[curr]) !== null && _a !== void 0 ? _a : curr;
297
338
  switch (typeof style) {
298
339
  case 'string':
299
- return { ...acc, [defaultStyleProperties[key]]: style };
340
+ return Object.assign(Object.assign({}, acc), { [defaultStyleProperties[key]]: style });
300
341
  default:
301
- return { ...acc, ...style };
342
+ return Object.assign(Object.assign({}, acc), style);
302
343
  }
303
344
  }
304
345
  else
305
- return { ...acc, ...curr };
346
+ return Object.assign(Object.assign({}, acc), curr);
306
347
  }, {});
307
348
  compiledStyles[key] = cssStyles;
308
349
  });
@@ -310,16 +351,12 @@ const buildStyleObject = (baseTheme, overrides = { styles: emptyStyleObject }) =
310
351
  });
311
352
  const finalStyles = {};
312
353
  Object.keys(defaultTheme.styles).forEach((key) => {
313
- finalStyles[key] = {
314
- ...defaultStyles[key],
315
- ...baseStyles[key],
316
- ...overrideStyles[key],
317
- };
354
+ finalStyles[key] = Object.assign(Object.assign(Object.assign({}, defaultStyles[key]), baseStyles[key]), overrideStyles[key]);
318
355
  });
319
- if (finalStyles?.inputHighlight?.backgroundColor)
320
- document.documentElement.style.setProperty('--jer-highlight-color', finalStyles?.inputHighlight?.backgroundColor);
321
- if (finalStyles?.iconCopy?.color)
322
- document.documentElement.style.setProperty('--jer-icon-copy-color', finalStyles?.iconCopy?.color);
356
+ if ((_a = finalStyles === null || finalStyles === void 0 ? void 0 : finalStyles.inputHighlight) === null || _a === void 0 ? void 0 : _a.backgroundColor)
357
+ document.documentElement.style.setProperty('--jer-highlight-color', (_b = finalStyles === null || finalStyles === void 0 ? void 0 : finalStyles.inputHighlight) === null || _b === void 0 ? void 0 : _b.backgroundColor);
358
+ if ((_c = finalStyles === null || finalStyles === void 0 ? void 0 : finalStyles.iconCopy) === null || _c === void 0 ? void 0 : _c.color)
359
+ document.documentElement.style.setProperty('--jer-icon-copy-color', (_d = finalStyles === null || finalStyles === void 0 ? void 0 : finalStyles.iconCopy) === null || _d === void 0 ? void 0 : _d.color);
323
360
  return finalStyles;
324
361
  };
325
362
  const isStyleObject = (overrideObject) => {
@@ -349,25 +386,10 @@ const defaultStyleProperties = {
349
386
  const AutogrowTextArea = ({ className, name, value, setValue, handleKeyPress, }) => {
350
387
  const { styles } = useTheme();
351
388
  const dummyValue = value.slice(-1) === '\n' ? value + '.' : value;
352
- return (jsxRuntime.jsxs("div", { style: { display: 'grid' }, children: [jsxRuntime.jsx("textarea", { style: {
353
- height: 'auto',
354
- gridArea: '1 / 1 / 2 / 2',
355
- overflowY: 'auto',
356
- ...styles.input,
357
- }, rows: 1, className: className, name: name, value: value, onChange: (e) => setValue(e.target.value), autoFocus: true, onFocus: (e) => {
389
+ return (jsxRuntime.jsxs("div", Object.assign({ style: { display: 'grid' } }, { children: [jsxRuntime.jsx("textarea", { style: Object.assign({ height: 'auto', gridArea: '1 / 1 / 2 / 2', overflowY: 'auto' }, styles.input), rows: 1, className: className, name: name, value: value, onChange: (e) => setValue(e.target.value), autoFocus: true, onFocus: (e) => {
358
390
  if (value.length < 40)
359
391
  e.target.select();
360
- }, onKeyDown: handleKeyPress }), jsxRuntime.jsx("span", { className: className, style: {
361
- visibility: 'hidden',
362
- height: 'auto',
363
- gridArea: '1 / 1 / 2 / 2',
364
- color: 'red',
365
- opacity: 0.9,
366
- whiteSpace: 'pre-wrap',
367
- overflow: 'clip',
368
- border: '1px solid transparent',
369
- ...styles.input,
370
- }, children: dummyValue })] }));
392
+ }, onKeyDown: handleKeyPress }), jsxRuntime.jsx("span", Object.assign({ className: className, style: Object.assign({ visibility: 'hidden', height: 'auto', gridArea: '1 / 1 / 2 / 2', color: 'red', opacity: 0.9, whiteSpace: 'pre-wrap', overflow: 'clip', border: '1px solid transparent' }, styles.input) }, { children: dummyValue }))] })));
371
393
  };
372
394
 
373
395
  const truncate = (string, length = 200) => string.length < length ? string : `${string.slice(0, length - 2).trim()}...`;
@@ -380,10 +402,10 @@ const StringValue = ({ value, setValue, isEditing, path, setIsEditing, handleEdi
380
402
  handleCancel();
381
403
  };
382
404
  const breakString = (text) => text.split('\n').map((line, index, arr) => (jsxRuntime.jsxs("span", { children: [line, index < arr.length - 1 ? jsxRuntime.jsx("br", {}) : null] }, index)));
383
- return isEditing ? (jsxRuntime.jsx(AutogrowTextArea, { className: "jer-input-text", name: path.join('.'), value: value, setValue: setValue, isEditing: isEditing, handleKeyPress: handleKeyPress })) : (jsxRuntime.jsxs("div", { onDoubleClick: () => setIsEditing(true), onClick: (e) => {
405
+ return isEditing ? (jsxRuntime.jsx(AutogrowTextArea, { className: "jer-input-text", name: path.join('.'), value: value, setValue: setValue, isEditing: isEditing, handleKeyPress: handleKeyPress })) : (jsxRuntime.jsxs("div", Object.assign({ onDoubleClick: () => setIsEditing(true), onClick: (e) => {
384
406
  if (e.getModifierState('Control') || e.getModifierState('Meta'))
385
407
  setIsEditing(true);
386
- }, className: "jer-value-string", style: styles.string, children: ["\"", breakString(truncate(value, stringTruncate)), "\""] }));
408
+ }, className: "jer-value-string", style: styles.string }, { children: ["\"", breakString(truncate(value, stringTruncate)), "\""] })));
387
409
  };
388
410
  const NumberValue = ({ value, setValue, isEditing, path, setIsEditing, handleEdit, handleCancel, }) => {
389
411
  const { styles } = useTheme();
@@ -393,47 +415,45 @@ const NumberValue = ({ value, setValue, isEditing, path, setIsEditing, handleEdi
393
415
  else if (e.key === 'Escape')
394
416
  handleCancel();
395
417
  };
396
- const validateNumber = (input) => {
397
- return input.replace(/[^0-9.-]/g, '');
398
- };
399
- return isEditing ? (jsxRuntime.jsx("input", { className: "jer-input-number", type: "text", name: path.join('.'), value: value, onChange: (e) => setValue(validateNumber(e.target.value)), autoFocus: true, onFocus: (e) => e.target.select(), onKeyDown: handleKeyPress, style: { width: `${String(value).length / 1.5 + 2}em` } })) : (jsxRuntime.jsx("span", { onDoubleClick: () => setIsEditing(true), className: "jer-value-number", style: styles.number, children: value }));
418
+ return isEditing ? (jsxRuntime.jsx("input", { className: "jer-input-number", type: "text", name: path.join('.'), value: value, onChange: (e) => setValue(e.target.value), autoFocus: true, onFocus: (e) => e.target.select(), onKeyDown: handleKeyPress, style: { width: `${String(value).length / 1.5 + 2}em` } })) : (jsxRuntime.jsx("span", Object.assign({ onDoubleClick: () => setIsEditing(true), className: "jer-value-number", style: styles.number }, { children: value })));
400
419
  };
401
420
  const BooleanValue = ({ value, setValue, isEditing, path, setIsEditing, }) => {
402
421
  const { styles } = useTheme();
403
- return isEditing ? (jsxRuntime.jsx("input", { className: "jer-input-boolean", type: "checkbox", name: path.join('.'), checked: value, onChange: () => setValue(!value) })) : (jsxRuntime.jsx("span", { onDoubleClick: () => setIsEditing(true), className: "jer-value-boolean", style: styles.boolean, children: String(value) }));
422
+ return isEditing ? (jsxRuntime.jsx("input", { className: "jer-input-boolean", type: "checkbox", name: path.join('.'), checked: value, onChange: () => setValue(!value) })) : (jsxRuntime.jsx("span", Object.assign({ onDoubleClick: () => setIsEditing(true), className: "jer-value-boolean", style: styles.boolean }, { children: String(value) })));
404
423
  };
405
424
  const NullValue = ({ value, isEditing, setIsEditing }) => {
406
425
  const { styles } = useTheme();
407
- return isEditing ? (jsxRuntime.jsx("div", { className: "jer-input-null", children: "null" })) : (jsxRuntime.jsx("div", { onDoubleClick: () => setIsEditing(true), className: "jer-value-null", style: styles.null, children: String(value) }));
426
+ return isEditing ? (jsxRuntime.jsx("div", Object.assign({ className: "jer-input-null" }, { children: "null" }))) : (jsxRuntime.jsx("div", Object.assign({ onDoubleClick: () => setIsEditing(true), className: "jer-value-null", style: styles.null }, { children: String(value) })));
408
427
  };
409
428
  const ObjectValue = () => {
410
- return jsxRuntime.jsx("span", { className: "jer-value-object", children: '{ }' });
429
+ return jsxRuntime.jsx("span", Object.assign({ className: "jer-value-object" }, { children: '{ }' }));
411
430
  };
412
431
  const ArrayValue = ({ value }) => {
413
- return jsxRuntime.jsx("span", { className: "jer-value-array", children: `[${value === null ? '' : value}]` });
432
+ return jsxRuntime.jsx("span", Object.assign({ className: "jer-value-array" }, { children: `[${value === null ? '' : value}]` }));
414
433
  };
415
434
  const InvalidValue = () => {
416
- return jsxRuntime.jsx("span", { className: "jer-value-invalid", children: "Invalid value" });
435
+ return jsxRuntime.jsx("span", Object.assign({ className: "jer-value-invalid" }, { children: "Invalid value" }));
417
436
  };
418
437
 
419
438
  const Icon = ({ name, rotate }) => {
439
+ var _a, _b, _c, _d, _e, _f, _g;
420
440
  const { styles, icons } = useTheme();
421
441
  const commonProps = { size: '1.4em', className: 'jer-icon' };
422
442
  switch (name) {
423
443
  case 'add':
424
- return icons?.add ?? jsxRuntime.jsx(bi.BiPlusCircle, { ...commonProps, style: styles.iconAdd });
444
+ return (_a = icons === null || icons === void 0 ? void 0 : icons.add) !== null && _a !== void 0 ? _a : jsxRuntime.jsx(bi.BiPlusCircle, Object.assign({}, commonProps, { style: styles.iconAdd }));
425
445
  case 'edit':
426
- return icons?.edit ?? jsxRuntime.jsx(bi.BiEdit, { ...commonProps, style: styles.iconEdit });
446
+ return (_b = icons === null || icons === void 0 ? void 0 : icons.edit) !== null && _b !== void 0 ? _b : jsxRuntime.jsx(bi.BiEdit, Object.assign({}, commonProps, { style: styles.iconEdit }));
427
447
  case 'delete':
428
- return (icons?.delete ?? jsxRuntime.jsx(md.MdDeleteForever, { ...commonProps, style: styles.iconDelete, size: "1.5em" }));
448
+ return ((_c = icons === null || icons === void 0 ? void 0 : icons.delete) !== null && _c !== void 0 ? _c : jsxRuntime.jsx(md.MdDeleteForever, Object.assign({}, commonProps, { style: styles.iconDelete, size: "1.5em" })));
429
449
  case 'copy':
430
- return icons?.copy ?? jsxRuntime.jsx(hi.HiOutlineClipboardCopy, { ...commonProps, style: styles.iconCopy });
450
+ return (_d = icons === null || icons === void 0 ? void 0 : icons.copy) !== null && _d !== void 0 ? _d : jsxRuntime.jsx(hi.HiOutlineClipboardCopy, Object.assign({}, commonProps, { style: styles.iconCopy }));
431
451
  case 'ok':
432
- return (icons?.ok ?? (jsxRuntime.jsx(fi.FiCheckCircle, { ...commonProps, style: { fontSize: '90%', ...styles.iconOk } })));
452
+ return ((_e = icons === null || icons === void 0 ? void 0 : icons.ok) !== null && _e !== void 0 ? _e : (jsxRuntime.jsx(fi.FiCheckCircle, Object.assign({}, commonProps, { style: Object.assign({ fontSize: '90%' }, styles.iconOk) }))));
433
453
  case 'cancel':
434
- return (icons?.cancel ?? (jsxRuntime.jsx(ti.TiCancel, { ...commonProps, style: { fontSize: '130%', ...styles.iconCancel } })));
454
+ return ((_f = icons === null || icons === void 0 ? void 0 : icons.cancel) !== null && _f !== void 0 ? _f : (jsxRuntime.jsx(ti.TiCancel, Object.assign({}, commonProps, { style: Object.assign({ fontSize: '130%' }, styles.iconCancel) }))));
435
455
  case 'chevron':
436
- return (icons?.chevron ?? (jsxRuntime.jsx(fa.FaChevronDown, { className: `${rotate ? ' jer-rotate-90' : ''}`, style: styles.iconCollection })));
456
+ return ((_g = icons === null || icons === void 0 ? void 0 : icons.chevron) !== null && _g !== void 0 ? _g : (jsxRuntime.jsx(fa.FaChevronDown, { className: `${rotate ? ' jer-rotate-90' : ''}`, style: styles.iconCollection })));
437
457
  default:
438
458
  return jsxRuntime.jsx(jsxRuntime.Fragment, {});
439
459
  }
@@ -473,22 +493,22 @@ const EditButtons = ({ startEdit, handleDelete, handleAdd, enableClipboard, type
473
493
  if (typeof enableClipboard === 'function')
474
494
  enableClipboard({ value, path, key: name, type });
475
495
  };
476
- return (jsxRuntime.jsxs("div", { className: "jer-edit-buttons", style: isAdding ? { opacity: 1 } : undefined, children: [enableClipboard && (jsxRuntime.jsx("div", { onClick: handleCopy, className: "jer-copy-pulse", children: jsxRuntime.jsx(Icon, { name: "copy" }) })), startEdit && (jsxRuntime.jsx("div", { onClick: startEdit, children: jsxRuntime.jsx(Icon, { name: "edit" }) })), handleDelete && (jsxRuntime.jsx("div", { onClick: handleDelete, children: jsxRuntime.jsx(Icon, { name: "delete" }) })), handleAdd && (jsxRuntime.jsx("div", { onClick: () => {
496
+ return (jsxRuntime.jsxs("div", Object.assign({ className: "jer-edit-buttons", style: isAdding ? { opacity: 1 } : undefined }, { children: [enableClipboard && (jsxRuntime.jsx("div", Object.assign({ onClick: handleCopy, className: "jer-copy-pulse" }, { children: jsxRuntime.jsx(Icon, { name: "copy" }) }))), startEdit && (jsxRuntime.jsx("div", Object.assign({ onClick: startEdit }, { children: jsxRuntime.jsx(Icon, { name: "edit" }) }))), handleDelete && (jsxRuntime.jsx("div", Object.assign({ onClick: handleDelete }, { children: jsxRuntime.jsx(Icon, { name: "delete" }) }))), handleAdd && (jsxRuntime.jsx("div", Object.assign({ onClick: () => {
477
497
  if (type === 'object')
478
498
  setIsAdding(true);
479
499
  else
480
500
  handleAdd('');
481
- }, children: jsxRuntime.jsx(Icon, { name: "add" }) })), isAdding && handleAdd && type === 'object' && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("input", { className: "jer-input-new-key", type: "text", name: "new-object-key", value: newKey, onChange: (e) => setNewKey(e.target.value), autoFocus: true, onFocus: (e) => e.target.select(), onKeyDown: handleKeyPress, style: { ...styles.input } }), jsxRuntime.jsx(InputButtons, { onOk: () => {
501
+ } }, { children: jsxRuntime.jsx(Icon, { name: "add" }) }))), isAdding && handleAdd && type === 'object' && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("input", { className: "jer-input-new-key", type: "text", name: "new-object-key", value: newKey, onChange: (e) => setNewKey(e.target.value), autoFocus: true, onFocus: (e) => e.target.select(), onKeyDown: handleKeyPress, style: Object.assign({}, styles.input) }), jsxRuntime.jsx(InputButtons, { onOk: () => {
482
502
  if (!!newKey) {
483
503
  setIsAdding(false);
484
504
  handleAdd(newKey);
485
505
  }
486
506
  }, onCancel: () => {
487
507
  setIsAdding(false);
488
- } })] }))] }));
508
+ } })] }))] })));
489
509
  };
490
510
  const InputButtons = ({ onOk, onCancel }) => {
491
- return (jsxRuntime.jsxs("div", { className: "jer-confirm-buttons", children: [jsxRuntime.jsx("div", { onClick: onOk, children: jsxRuntime.jsx(Icon, { name: "ok" }) }), jsxRuntime.jsx("div", { onClick: onCancel, children: jsxRuntime.jsx(Icon, { name: "cancel" }) })] }));
511
+ return (jsxRuntime.jsxs("div", Object.assign({ className: "jer-confirm-buttons" }, { children: [jsxRuntime.jsx("div", Object.assign({ onClick: onOk }, { children: jsxRuntime.jsx(Icon, { name: "ok" }) })), jsxRuntime.jsx("div", Object.assign({ onClick: onCancel }, { children: jsxRuntime.jsx(Icon, { name: "cancel" }) }))] })));
492
512
  };
493
513
  const stringifyPath = (path) => path.reduce((str, part) => {
494
514
  if (typeof part === 'number')
@@ -569,11 +589,8 @@ const ValueNodeWrapper = ({ data, name, path, onEdit, onDelete, enableClipboard,
569
589
  path,
570
590
  stringTruncate,
571
591
  };
572
- return (jsxRuntime.jsx("div", { className: "jer-component jer-value-component", style: { marginLeft: `${indent / 2}em` }, children: jsxRuntime.jsxs("div", { className: "jer-value-main-row", children: [showArrayIndices && (jsxRuntime.jsxs("label", { htmlFor: path.join('.'), className: "jer-object-key", style: {
573
- ...styles.property,
574
- minWidth: `${Math.min(String(name).length + 1, 5)}ch`,
575
- }, children: [name, ":", ' '] })), jsxRuntime.jsx("div", { className: "jer-input-component", children: getInputComponent(dataType, inputProps) }), isEditing ? (jsxRuntime.jsx(InputButtons, { onOk: handleEdit, onCancel: handleCancel })) : (dataType !== 'invalid' &&
576
- !error && (jsxRuntime.jsx(EditButtons, { startEdit: canEdit ? () => setIsEditing(true) : undefined, handleDelete: canDelete ? handleDelete : undefined, data: data, enableClipboard: enableClipboard, name: name, path: path, translate: translate }))), isEditing && (jsxRuntime.jsx("select", { name: `${name}-type-select`, className: "jer-type-select", onChange: (e) => handleChangeDataType(e.target.value), value: dataType, children: DataTypes.map((type) => (jsxRuntime.jsx("option", { value: type, children: type }, type))) })), !isEditing && error && (jsxRuntime.jsx("span", { className: "jer-error-slug", style: styles.error, children: error }))] }) }));
592
+ return (jsxRuntime.jsx("div", Object.assign({ className: "jer-component jer-value-component", style: { marginLeft: `${indent / 2}em` } }, { children: jsxRuntime.jsxs("div", Object.assign({ className: "jer-value-main-row" }, { children: [showArrayIndices && (jsxRuntime.jsxs("label", Object.assign({ htmlFor: path.join('.'), className: "jer-object-key", style: Object.assign(Object.assign({}, styles.property), { minWidth: `${Math.min(String(name).length + 1, 5)}ch` }) }, { children: [name, ":", ' '] }))), jsxRuntime.jsx("div", Object.assign({ className: "jer-input-component" }, { children: getInputComponent(dataType, inputProps) })), isEditing ? (jsxRuntime.jsx(InputButtons, { onOk: handleEdit, onCancel: handleCancel })) : (dataType !== 'invalid' &&
593
+ !error && (jsxRuntime.jsx(EditButtons, { startEdit: canEdit ? () => setIsEditing(true) : undefined, handleDelete: canDelete ? handleDelete : undefined, data: data, enableClipboard: enableClipboard, name: name, path: path, translate: translate }))), isEditing && (jsxRuntime.jsx("select", Object.assign({ name: `${name}-type-select`, className: "jer-type-select", onChange: (e) => handleChangeDataType(e.target.value), value: dataType }, { children: DataTypes.map((type) => (jsxRuntime.jsx("option", Object.assign({ value: type }, { children: type }), type))) }))), !isEditing && error && (jsxRuntime.jsx("span", Object.assign({ className: "jer-error-slug", style: styles.error }, { children: error })))] })) })));
577
594
  };
578
595
  const getDataType = (value) => {
579
596
  if (typeof value === 'string')
@@ -590,19 +607,19 @@ const getInputComponent = (dataType, inputProps) => {
590
607
  const value = inputProps.value;
591
608
  switch (dataType) {
592
609
  case 'string':
593
- return jsxRuntime.jsx(StringValue, { ...inputProps, value: value });
610
+ return jsxRuntime.jsx(StringValue, Object.assign({}, inputProps, { value: value }));
594
611
  case 'number':
595
- return jsxRuntime.jsx(NumberValue, { ...inputProps, value: value });
612
+ return jsxRuntime.jsx(NumberValue, Object.assign({}, inputProps, { value: value }));
596
613
  case 'boolean':
597
- return jsxRuntime.jsx(BooleanValue, { ...inputProps, value: value });
614
+ return jsxRuntime.jsx(BooleanValue, Object.assign({}, inputProps, { value: value }));
598
615
  case 'null':
599
- return jsxRuntime.jsx(NullValue, { ...inputProps });
616
+ return jsxRuntime.jsx(NullValue, Object.assign({}, inputProps));
600
617
  case 'object':
601
- return jsxRuntime.jsx(ObjectValue, { ...inputProps });
618
+ return jsxRuntime.jsx(ObjectValue, Object.assign({}, inputProps));
602
619
  case 'array':
603
- return jsxRuntime.jsx(ArrayValue, { ...inputProps });
620
+ return jsxRuntime.jsx(ArrayValue, Object.assign({}, inputProps));
604
621
  default:
605
- return jsxRuntime.jsx(InvalidValue, { ...inputProps });
622
+ return jsxRuntime.jsx(InvalidValue, Object.assign({}, inputProps));
606
623
  }
607
624
  };
608
625
  const convertValue = (value, type) => {
@@ -626,7 +643,8 @@ const convertValue = (value, type) => {
626
643
  };
627
644
 
628
645
  const isCollection = (value) => value !== null && typeof value == 'object';
629
- const CollectionNode = ({ data, path, name, ...props }) => {
646
+ const CollectionNode = (_a) => {
647
+ var { data, path, name } = _a, props = __rest(_a, ["data", "path", "name"]);
630
648
  const { styles } = useTheme();
631
649
  const { onEdit, onAdd, onDelete, restrictEditFilter, restrictDeleteFilter, restrictAddFilter, collapseFilter, enableClipboard, indent, keySort, showArrayIndices, defaultValue, translate, } = props;
632
650
  const [isEditing, setIsEditing] = react.useState(false);
@@ -665,7 +683,7 @@ const CollectionNode = ({ data, path, name, ...props }) => {
665
683
  showError(error);
666
684
  });
667
685
  }
668
- catch {
686
+ catch (_a) {
669
687
  setError(translate('ERROR_INVALID_JSON'));
670
688
  setTimeout(() => setError(null), ERROR_DISPLAY_TIME);
671
689
  console.log('Invalid JSON');
@@ -714,21 +732,21 @@ const CollectionNode = ({ data, path, name, ...props }) => {
714
732
  if (keySort && collectionType === 'object')
715
733
  keyValueArray.sort(typeof keySort === 'function' ? (a, b) => keySort(a[0], b[0]) : undefined);
716
734
  const numOfLines = JSON.stringify(data, null, 2).split('\n').length;
717
- return (jsxRuntime.jsxs("div", { className: "jer-component fb-collection-component", style: { marginLeft: `${path.length === 0 ? 0 : indent / 2}em` }, children: [jsxRuntime.jsxs("div", { className: "jer-collection-header-row", children: [jsxRuntime.jsx("div", { onClick: () => {
735
+ return (jsxRuntime.jsxs("div", Object.assign({ className: "jer-component fb-collection-component", style: { marginLeft: `${path.length === 0 ? 0 : indent / 2}em` } }, { children: [jsxRuntime.jsxs("div", Object.assign({ className: "jer-collection-header-row" }, { children: [jsxRuntime.jsx("div", Object.assign({ onClick: () => {
718
736
  if (!isEditing)
719
737
  setCollapsed(!collapsed);
720
- }, children: jsxRuntime.jsx(Icon, { name: "chevron", rotate: collapsed }) }), jsxRuntime.jsxs("div", { className: "jer-collection-name", children: [jsxRuntime.jsx("span", { style: styles.property, children: showLabel ? `${name}:` : null }), jsxRuntime.jsx("span", { className: "jer-brackets", style: styles.bracket, children: brackets.open })] }), jsxRuntime.jsx("div", { className: "jer-collection-item-count", style: styles.itemCount, children: collectionSize === 1
738
+ } }, { children: jsxRuntime.jsx(Icon, { name: "chevron", rotate: collapsed }) })), jsxRuntime.jsxs("div", Object.assign({ className: "jer-collection-name" }, { children: [jsxRuntime.jsx("span", Object.assign({ style: styles.property }, { children: showLabel ? `${name}:` : null })), jsxRuntime.jsx("span", Object.assign({ className: "jer-brackets", style: styles.bracket }, { children: brackets.open }))] })), jsxRuntime.jsx("div", Object.assign({ className: "jer-collection-item-count", style: styles.itemCount }, { children: collectionSize === 1
721
739
  ? translate('ITEM_SINGLE', 1)
722
- : translate('ITEMS_MULTIPLE', collectionSize) }), collapsed && (jsxRuntime.jsx("div", { className: "jer-brackets", style: styles.bracket, children: brackets.close })), !isEditing && (jsxRuntime.jsx(EditButtons, { startEdit: canEdit
740
+ : translate('ITEMS_MULTIPLE', collectionSize) })), collapsed && (jsxRuntime.jsx("div", Object.assign({ className: "jer-brackets", style: styles.bracket }, { children: brackets.close }))), !isEditing && (jsxRuntime.jsx(EditButtons, { startEdit: canEdit
723
741
  ? () => {
724
742
  setIsEditing(true);
725
743
  setCollapsed(false);
726
744
  }
727
- : undefined, handleAdd: canAdd ? handleAdd : undefined, handleDelete: canDelete ? handleDelete : undefined, enableClipboard: enableClipboard, type: collectionType, data: data, name: name, path: path, translate: translate }))] }), jsxRuntime.jsxs("div", { className: 'jer-collection-inner', style: {
745
+ : undefined, handleAdd: canAdd ? handleAdd : undefined, handleDelete: canDelete ? handleDelete : undefined, enableClipboard: enableClipboard, type: collectionType, data: data, name: name, path: path, translate: translate }))] })), jsxRuntime.jsxs("div", Object.assign({ className: 'jer-collection-inner', style: {
728
746
  maxHeight: collapsed ? 0 : `${numOfLines * 1.6}em`,
729
747
  overflowY: collapsed ? 'hidden' : 'visible',
730
748
  transition: `max-height ${transitionTime}`,
731
- }, children: [isEditing ? (jsxRuntime.jsxs("div", { className: "jer-collection-text-edit", children: [jsxRuntime.jsx(AutogrowTextArea, { className: "jer-collection-text-area", name: path.join('.'), value: stringifiedValue, setValue: setStringifiedValue, isEditing: isEditing, handleKeyPress: handleKeyPress }), jsxRuntime.jsx("div", { className: "jer-collection-input-button-row", children: jsxRuntime.jsx(InputButtons, { onOk: handleEdit, onCancel: handleCancel, isCollection: true }) })] })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: keyValueArray.map(([key, value]) => (jsxRuntime.jsx("div", { className: "jer-collection-element", children: isCollection(value) ? (jsxRuntime.jsx(CollectionNode, { data: value, path: [...path, key], name: key, ...props }, key)) : (jsxRuntime.jsx(ValueNodeWrapper, { data: value, path: [...path, key], name: key, ...props, showArrayIndices: collectionType === 'object' ? true : showArrayIndices }, key)) }, key))) })), jsxRuntime.jsx("div", { className: isEditing ? 'jer-collection-error-row' : 'jer-collection-error-row-edit', children: error && (jsxRuntime.jsx("span", { className: "jer-error-slug", style: styles.error, children: error })) })] }), !collapsed && (jsxRuntime.jsx("div", { className: "jer-brackets", style: styles.bracket, children: brackets.close }))] }));
749
+ } }, { children: [isEditing ? (jsxRuntime.jsxs("div", Object.assign({ className: "jer-collection-text-edit" }, { children: [jsxRuntime.jsx(AutogrowTextArea, { className: "jer-collection-text-area", name: path.join('.'), value: stringifiedValue, setValue: setStringifiedValue, isEditing: isEditing, handleKeyPress: handleKeyPress }), jsxRuntime.jsx("div", Object.assign({ className: "jer-collection-input-button-row" }, { children: jsxRuntime.jsx(InputButtons, { onOk: handleEdit, onCancel: handleCancel, isCollection: true }) }))] }))) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: keyValueArray.map(([key, value]) => (jsxRuntime.jsx("div", Object.assign({ className: "jer-collection-element" }, { children: isCollection(value) ? (jsxRuntime.jsx(CollectionNode, Object.assign({ data: value, path: [...path, key], name: key }, props), key)) : (jsxRuntime.jsx(ValueNodeWrapper, Object.assign({ data: value, path: [...path, key], name: key }, props, { showArrayIndices: collectionType === 'object' ? true : showArrayIndices }), key)) }), key))) })), jsxRuntime.jsx("div", Object.assign({ className: isEditing ? 'jer-collection-error-row' : 'jer-collection-error-row-edit' }, { children: error && (jsxRuntime.jsx("span", Object.assign({ className: "jer-error-slug", style: styles.error }, { children: error }))) }))] })), !collapsed && (jsxRuntime.jsx("div", Object.assign({ className: "jer-brackets", style: styles.bracket }, { children: brackets.close })))] })));
732
750
  };
733
751
 
734
752
  const localisedStrings = {
@@ -743,7 +761,7 @@ const localisedStrings = {
743
761
  };
744
762
  const translate = (translations, key, count) => {
745
763
  const string = key in translations ? translations[key] : localisedStrings[key];
746
- return count === undefined ? string : string?.replace('{{count}}', String(count));
764
+ return count === undefined ? string : string === null || string === void 0 ? void 0 : string.replace('{{count}}', String(count));
747
765
  };
748
766
  const getTranslateFunction = (translations) => (key, count) => translate(translations, key, count);
749
767
 
@@ -761,10 +779,10 @@ const Editor = ({ data: srcData, rootName = 'root', onUpdate, onEdit: srcEdit =
761
779
  if (icons)
762
780
  setIcons(icons);
763
781
  }, [theme, icons]);
764
- const onEdit = async (value, path) => {
782
+ const onEdit = (value, path) => __awaiter(void 0, void 0, void 0, function* () {
765
783
  const { currentData, newData, currentValue, newValue } = updateDataObject(data, path, value, 'update');
766
784
  if (srcEdit) {
767
- const result = await srcEdit({
785
+ const result = yield srcEdit({
768
786
  currentData,
769
787
  newData,
770
788
  currentValue,
@@ -780,11 +798,11 @@ const Editor = ({ data: srcData, rootName = 'root', onUpdate, onEdit: srcEdit =
780
798
  }
781
799
  else
782
800
  setData(newData);
783
- };
784
- const onDelete = async (value, path) => {
801
+ });
802
+ const onDelete = (value, path) => __awaiter(void 0, void 0, void 0, function* () {
785
803
  const { currentData, newData, currentValue, newValue } = updateDataObject(data, path, value, 'delete');
786
804
  if (srcDelete) {
787
- const result = await srcDelete({
805
+ const result = yield srcDelete({
788
806
  currentData,
789
807
  newData,
790
808
  currentValue,
@@ -800,11 +818,11 @@ const Editor = ({ data: srcData, rootName = 'root', onUpdate, onEdit: srcEdit =
800
818
  }
801
819
  else
802
820
  setData(newData);
803
- };
804
- const onAdd = async (value, path) => {
821
+ });
822
+ const onAdd = (value, path) => __awaiter(void 0, void 0, void 0, function* () {
805
823
  const { currentData, newData, currentValue, newValue } = updateDataObject(data, path, value, 'add');
806
824
  if (srcAdd) {
807
- const result = await srcAdd({
825
+ const result = yield srcAdd({
808
826
  currentData,
809
827
  newData,
810
828
  currentValue,
@@ -820,7 +838,7 @@ const Editor = ({ data: srcData, rootName = 'root', onUpdate, onEdit: srcEdit =
820
838
  }
821
839
  else
822
840
  setData(newData);
823
- };
841
+ });
824
842
  const restrictEditFilter = getFilterFunction(restrictEdit);
825
843
  const restrictDeleteFilter = getFilterFunction(restrictDelete);
826
844
  const restrictAddFilter = getFilterFunction(restrictAdd);
@@ -843,9 +861,9 @@ const Editor = ({ data: srcData, rootName = 'root', onUpdate, onEdit: srcEdit =
843
861
  };
844
862
  if (!styles)
845
863
  return null;
846
- return (jsxRuntime.jsx("div", { className: 'jer-editor-container ' + className, style: { ...styles.container, minWidth, maxWidth }, children: isCollection(data) && jsxRuntime.jsx(CollectionNode, { data: data, path: [], ...otherProps }) }));
864
+ return (jsxRuntime.jsx("div", Object.assign({ className: 'jer-editor-container ' + className, style: Object.assign(Object.assign({}, styles.container), { minWidth, maxWidth }) }, { children: isCollection(data) && jsxRuntime.jsx(CollectionNode, Object.assign({ data: data, path: [] }, otherProps)) })));
847
865
  };
848
- const JsonEditor = (props) => (jsxRuntime.jsx(ThemeProvider, { children: jsxRuntime.jsx(Editor, { ...props }) }));
866
+ const JsonEditor = (props) => (jsxRuntime.jsx(ThemeProvider, { children: jsxRuntime.jsx(Editor, Object.assign({}, props)) }));
849
867
  const updateDataObject = (data, path, newValue, action) => {
850
868
  if (path.length === 0) {
851
869
  return {
package/build/index.d.ts CHANGED
@@ -32,6 +32,7 @@ declare const localisedStrings: {
32
32
  ERROR_ADD: string;
33
33
  };
34
34
  type LocalisedStrings = typeof localisedStrings;
35
+ type TranslateFunction = (key: keyof LocalisedStrings, count?: number) => string;
35
36
 
36
37
  interface JsonEditorProps {
37
38
  data: object;
@@ -95,4 +96,4 @@ type CompareFunction = (a: string, b: string) => number;
95
96
 
96
97
  declare const JsonEditor: React$1.FC<JsonEditorProps>;
97
98
 
98
- export { JsonEditor, Theme, ThemeInput, ThemeName, themes };
99
+ export { CompareFunction, CopyFunction, FilterFunction, IconReplacements, JsonEditor, JsonEditorProps, LocalisedStrings, Theme, ThemeInput, ThemeName, TranslateFunction, UpdateFunction, themes };
@@ -10,6 +10,45 @@ import { FiCheckCircle } from 'react-icons/fi';
10
10
  import { TiCancel } from 'react-icons/ti';
11
11
  import { FaChevronDown } from 'react-icons/fa';
12
12
 
13
+ /******************************************************************************
14
+ Copyright (c) Microsoft Corporation.
15
+
16
+ Permission to use, copy, modify, and/or distribute this software for any
17
+ purpose with or without fee is hereby granted.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
20
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
21
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
22
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
23
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
24
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
25
+ PERFORMANCE OF THIS SOFTWARE.
26
+ ***************************************************************************** */
27
+ /* global Reflect, Promise */
28
+
29
+
30
+ function __rest(s, e) {
31
+ var t = {};
32
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
33
+ t[p] = s[p];
34
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
35
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
36
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
37
+ t[p[i]] = s[p[i]];
38
+ }
39
+ return t;
40
+ }
41
+
42
+ function __awaiter(thisArg, _arguments, P, generator) {
43
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
44
+ return new (P || (P = Promise))(function (resolve, reject) {
45
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
46
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
47
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
48
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
49
+ });
50
+ }
51
+
13
52
  var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
14
53
 
15
54
  var css = ":root {\n --jer-form-border: 1px solid #ededf0;\n --jer-form-border-focus: 1px solid #e2e2e2;\n --jer-expand-transition-time: 0.2s;\n --jer-highlight-color: #b3d8ff;\n}\n.jer-editor-container {\n font-size: 1.1em;\n /* font-size: 20px; */\n padding: 1em;\n margin-top: 1em;\n margin-bottom: 1em;\n border-radius: 0.5em;\n}\n\n.jer-editor-container textarea {\n /* width: 90%; */\n color: var(--jer-input-color);\n border: var(--jer-form-border);\n border-radius: 0.3em;\n outline: none;\n}\n\n.jer-editor-container textarea:focus {\n border: var(--jer-form-border-focus);\n}\n\n.jer-editor-container input {\n border: var(--jer-form-border);\n border-radius: 0.3em;\n outline: none;\n}\n\n.jer-editor-container input:focus {\n border: var(--jer-form-border-focus);\n}\n\n/* Input highlighted text */\n.jer-editor-container ::selection {\n background-color: var(--jer-highlight-color);\n}\n\n.jer-editor-container select {\n /* color: red; */\n}\n\n.jer-component {\n}\n\n.fb-collection-component {\n}\n\n.jer-collection-header-row,\n.jer-value-main-row {\n display: flex;\n min-height: 1.7em;\n gap: 0.3em;\n align-items: center;\n}\n\n.jer-collection-header-row {\n display: flex;\n flex-wrap: wrap;\n}\n\n.jer-brackets {\n}\n\n.jer-collection-item-count {\n}\n\n.jer-collection-inner {\n position: relative;\n}\n\n.jer-collection-text-edit {\n display: flex;\n flex-direction: column;\n gap: 0.3em;\n}\n\n.jer-collection-text-area {\n resize: both;\n padding-top: 0.2em;\n padding-left: 0.5em;\n padding-right: 0.5em;\n padding-bottom: 0;\n overflow: hidden;\n max-height: 40em;\n}\n\n.jer-collection-input-button-row {\n width: 90%;\n display: flex;\n justify-content: flex-end;\n font-size: 150%;\n}\n\n.jer-collection-element {\n}\n\n.jer-collection-error-row {\n position: absolute;\n bottom: 0;\n}\n\n.jer-collection-error-row-edit {\n}\n\n.jer-error-slug {\n margin-left: 1em;\n}\n\n.jer-value-component {\n position: relative;\n}\n\n.jer-value-main-row {\n display: flex;\n}\n\n.jer-value-error-row {\n position: absolute;\n}\n\n.jer-value-string {\n line-height: 1.3em;\n}\n\n.jer-input-text {\n resize: none;\n margin: 0;\n height: 1.4em;\n padding-left: 0.5em;\n padding-right: 0.5em;\n padding-bottom: 0;\n min-width: 6em;\n overflow: hidden;\n max-height: 30em;\n}\n\n/* To prevent over-writing by UI libraries */\n.jer-type-select {\n border: revert;\n border-radius: revert;\n padding: revert;\n font-family: revert;\n font-size: revert;\n color: revert;\n}\n\n.jer-value-number {\n}\n\n.jer-value-boolean {\n}\n\n.jer-value-null {\n}\n\n.jer-value-object {\n}\n\n.jer-object-key {\n word-break: break-word;\n line-height: 1.1em;\n}\n\n.jer-value-array {\n}\n\n.jer-value-invalid {\n opacity: 0.5;\n font-style: italic;\n}\n\n/* .jer-input-text, */\n.jer-input-number {\n height: 1.6em;\n}\n\n.jer-input-number {\n min-width: 3em;\n}\n\n.jer-input-component {\n}\n\n.jer-edit-buttons,\n.jer-confirm-buttons {\n display: flex;\n align-items: center;\n cursor: pointer;\n}\n\n.jer-input-buttons {\n gap: 0.4em;\n}\n\n.jer-edit-buttons {\n gap: 0.4em;\n margin-left: 0.5em;\n opacity: 0;\n}\n\n.jer-confirm-buttons {\n gap: 0.2em;\n margin-left: 0.4em;\n}\n\n.jer-edit-buttons:hover {\n opacity: 1;\n position: relative;\n}\n\n.jer-collection-header-row:hover > .jer-edit-buttons {\n opacity: 1;\n}\n\n.jer-value-main-row:hover > .jer-edit-buttons {\n opacity: 1;\n}\n\n.jer-input-buttons {\n}\n\n.jer-icon-wrapper {\n height: 1.4em;\n opacity: 1;\n transition: 0.2s;\n}\n\n.jer-icon-wrapper:active {\n position: relative;\n top: 0.07em;\n}\n\n.jer-icon-wrapper:hover {\n opacity: 0.85;\n transition: 0.2s;\n transform: scale(1.2);\n}\n\n.jer-copy-pulse {\n position: relative;\n}\n\n.jer-copy-pulse:hover {\n}\n\n.jer-copy-pulse:after {\n content: '';\n display: block;\n position: absolute;\n border-radius: 50%;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n opacity: 0;\n transition: all 0.5s;\n box-shadow: 0 0 15px 5px var(--jer-icon-copy-color);\n}\n\n.jer-copy-pulse:active:after {\n box-shadow: 0 0 0 0 var(--jer-icon-copy-color);\n position: absolute;\n border-radius: 4em;\n left: 0;\n top: 0;\n opacity: 1;\n transition: 0s;\n}\n\n.jer-copy-pulse:active {\n top: 0.07em;\n}\n\n.jer-rotate-90 {\n transform: rotate(-90deg);\n transition: transform var(--jer-expand-transition-time);\n}\n\n.jer-icon {\n /* font-size: '2em'; */\n}\n\n.jer-icon:hover {\n opacity: 0.85;\n transition: 0.3s;\n transform: scale(1.2);\n}\n";
@@ -271,7 +310,7 @@ const ThemeProvider = ({ children }) => {
271
310
  const [styles, setStyles] = useState(emptyStyleObject);
272
311
  const [icons, setIcons] = useState({});
273
312
  const setTheme = (theme) => setStyles(compileStyles(theme));
274
- return (jsx(ThemeProviderContext.Provider, { value: { styles, setTheme, icons, setIcons }, children: children }));
313
+ return (jsx(ThemeProviderContext.Provider, Object.assign({ value: { styles, setTheme, icons, setIcons } }, { children: children })));
275
314
  };
276
315
  const useTheme = () => useContext(ThemeProviderContext);
277
316
  const compileStyles = (themeInput) => {
@@ -284,23 +323,25 @@ const compileStyles = (themeInput) => {
284
323
  return buildStyleObject(defaultTheme, isStyleObject(themeInput) ? { styles: themeInput } : themeInput);
285
324
  };
286
325
  const buildStyleObject = (baseTheme, overrides = { styles: emptyStyleObject }) => {
326
+ var _a, _b, _c, _d;
287
327
  const [defaultStyles, baseStyles, overrideStyles] = [defaultTheme, baseTheme, overrides].map((theme) => {
288
328
  const { fragments, styles } = theme;
289
329
  const compiledStyles = {};
290
330
  Object.entries(styles).forEach(([key, value]) => {
291
331
  const elements = Array.isArray(value) ? value : [value];
292
332
  const cssStyles = elements.reduce((acc, curr) => {
333
+ var _a;
293
334
  if (typeof curr === 'string') {
294
- const style = fragments?.[curr] ?? curr;
335
+ const style = (_a = fragments === null || fragments === void 0 ? void 0 : fragments[curr]) !== null && _a !== void 0 ? _a : curr;
295
336
  switch (typeof style) {
296
337
  case 'string':
297
- return { ...acc, [defaultStyleProperties[key]]: style };
338
+ return Object.assign(Object.assign({}, acc), { [defaultStyleProperties[key]]: style });
298
339
  default:
299
- return { ...acc, ...style };
340
+ return Object.assign(Object.assign({}, acc), style);
300
341
  }
301
342
  }
302
343
  else
303
- return { ...acc, ...curr };
344
+ return Object.assign(Object.assign({}, acc), curr);
304
345
  }, {});
305
346
  compiledStyles[key] = cssStyles;
306
347
  });
@@ -308,16 +349,12 @@ const buildStyleObject = (baseTheme, overrides = { styles: emptyStyleObject }) =
308
349
  });
309
350
  const finalStyles = {};
310
351
  Object.keys(defaultTheme.styles).forEach((key) => {
311
- finalStyles[key] = {
312
- ...defaultStyles[key],
313
- ...baseStyles[key],
314
- ...overrideStyles[key],
315
- };
352
+ finalStyles[key] = Object.assign(Object.assign(Object.assign({}, defaultStyles[key]), baseStyles[key]), overrideStyles[key]);
316
353
  });
317
- if (finalStyles?.inputHighlight?.backgroundColor)
318
- document.documentElement.style.setProperty('--jer-highlight-color', finalStyles?.inputHighlight?.backgroundColor);
319
- if (finalStyles?.iconCopy?.color)
320
- document.documentElement.style.setProperty('--jer-icon-copy-color', finalStyles?.iconCopy?.color);
354
+ if ((_a = finalStyles === null || finalStyles === void 0 ? void 0 : finalStyles.inputHighlight) === null || _a === void 0 ? void 0 : _a.backgroundColor)
355
+ document.documentElement.style.setProperty('--jer-highlight-color', (_b = finalStyles === null || finalStyles === void 0 ? void 0 : finalStyles.inputHighlight) === null || _b === void 0 ? void 0 : _b.backgroundColor);
356
+ if ((_c = finalStyles === null || finalStyles === void 0 ? void 0 : finalStyles.iconCopy) === null || _c === void 0 ? void 0 : _c.color)
357
+ document.documentElement.style.setProperty('--jer-icon-copy-color', (_d = finalStyles === null || finalStyles === void 0 ? void 0 : finalStyles.iconCopy) === null || _d === void 0 ? void 0 : _d.color);
321
358
  return finalStyles;
322
359
  };
323
360
  const isStyleObject = (overrideObject) => {
@@ -347,25 +384,10 @@ const defaultStyleProperties = {
347
384
  const AutogrowTextArea = ({ className, name, value, setValue, handleKeyPress, }) => {
348
385
  const { styles } = useTheme();
349
386
  const dummyValue = value.slice(-1) === '\n' ? value + '.' : value;
350
- return (jsxs("div", { style: { display: 'grid' }, children: [jsx("textarea", { style: {
351
- height: 'auto',
352
- gridArea: '1 / 1 / 2 / 2',
353
- overflowY: 'auto',
354
- ...styles.input,
355
- }, rows: 1, className: className, name: name, value: value, onChange: (e) => setValue(e.target.value), autoFocus: true, onFocus: (e) => {
387
+ return (jsxs("div", Object.assign({ style: { display: 'grid' } }, { children: [jsx("textarea", { style: Object.assign({ height: 'auto', gridArea: '1 / 1 / 2 / 2', overflowY: 'auto' }, styles.input), rows: 1, className: className, name: name, value: value, onChange: (e) => setValue(e.target.value), autoFocus: true, onFocus: (e) => {
356
388
  if (value.length < 40)
357
389
  e.target.select();
358
- }, onKeyDown: handleKeyPress }), jsx("span", { className: className, style: {
359
- visibility: 'hidden',
360
- height: 'auto',
361
- gridArea: '1 / 1 / 2 / 2',
362
- color: 'red',
363
- opacity: 0.9,
364
- whiteSpace: 'pre-wrap',
365
- overflow: 'clip',
366
- border: '1px solid transparent',
367
- ...styles.input,
368
- }, children: dummyValue })] }));
390
+ }, onKeyDown: handleKeyPress }), jsx("span", Object.assign({ className: className, style: Object.assign({ visibility: 'hidden', height: 'auto', gridArea: '1 / 1 / 2 / 2', color: 'red', opacity: 0.9, whiteSpace: 'pre-wrap', overflow: 'clip', border: '1px solid transparent' }, styles.input) }, { children: dummyValue }))] })));
369
391
  };
370
392
 
371
393
  const truncate = (string, length = 200) => string.length < length ? string : `${string.slice(0, length - 2).trim()}...`;
@@ -378,10 +400,10 @@ const StringValue = ({ value, setValue, isEditing, path, setIsEditing, handleEdi
378
400
  handleCancel();
379
401
  };
380
402
  const breakString = (text) => text.split('\n').map((line, index, arr) => (jsxs("span", { children: [line, index < arr.length - 1 ? jsx("br", {}) : null] }, index)));
381
- return isEditing ? (jsx(AutogrowTextArea, { className: "jer-input-text", name: path.join('.'), value: value, setValue: setValue, isEditing: isEditing, handleKeyPress: handleKeyPress })) : (jsxs("div", { onDoubleClick: () => setIsEditing(true), onClick: (e) => {
403
+ return isEditing ? (jsx(AutogrowTextArea, { className: "jer-input-text", name: path.join('.'), value: value, setValue: setValue, isEditing: isEditing, handleKeyPress: handleKeyPress })) : (jsxs("div", Object.assign({ onDoubleClick: () => setIsEditing(true), onClick: (e) => {
382
404
  if (e.getModifierState('Control') || e.getModifierState('Meta'))
383
405
  setIsEditing(true);
384
- }, className: "jer-value-string", style: styles.string, children: ["\"", breakString(truncate(value, stringTruncate)), "\""] }));
406
+ }, className: "jer-value-string", style: styles.string }, { children: ["\"", breakString(truncate(value, stringTruncate)), "\""] })));
385
407
  };
386
408
  const NumberValue = ({ value, setValue, isEditing, path, setIsEditing, handleEdit, handleCancel, }) => {
387
409
  const { styles } = useTheme();
@@ -391,47 +413,45 @@ const NumberValue = ({ value, setValue, isEditing, path, setIsEditing, handleEdi
391
413
  else if (e.key === 'Escape')
392
414
  handleCancel();
393
415
  };
394
- const validateNumber = (input) => {
395
- return input.replace(/[^0-9.-]/g, '');
396
- };
397
- return isEditing ? (jsx("input", { className: "jer-input-number", type: "text", name: path.join('.'), value: value, onChange: (e) => setValue(validateNumber(e.target.value)), autoFocus: true, onFocus: (e) => e.target.select(), onKeyDown: handleKeyPress, style: { width: `${String(value).length / 1.5 + 2}em` } })) : (jsx("span", { onDoubleClick: () => setIsEditing(true), className: "jer-value-number", style: styles.number, children: value }));
416
+ return isEditing ? (jsx("input", { className: "jer-input-number", type: "text", name: path.join('.'), value: value, onChange: (e) => setValue(e.target.value), autoFocus: true, onFocus: (e) => e.target.select(), onKeyDown: handleKeyPress, style: { width: `${String(value).length / 1.5 + 2}em` } })) : (jsx("span", Object.assign({ onDoubleClick: () => setIsEditing(true), className: "jer-value-number", style: styles.number }, { children: value })));
398
417
  };
399
418
  const BooleanValue = ({ value, setValue, isEditing, path, setIsEditing, }) => {
400
419
  const { styles } = useTheme();
401
- return isEditing ? (jsx("input", { className: "jer-input-boolean", type: "checkbox", name: path.join('.'), checked: value, onChange: () => setValue(!value) })) : (jsx("span", { onDoubleClick: () => setIsEditing(true), className: "jer-value-boolean", style: styles.boolean, children: String(value) }));
420
+ return isEditing ? (jsx("input", { className: "jer-input-boolean", type: "checkbox", name: path.join('.'), checked: value, onChange: () => setValue(!value) })) : (jsx("span", Object.assign({ onDoubleClick: () => setIsEditing(true), className: "jer-value-boolean", style: styles.boolean }, { children: String(value) })));
402
421
  };
403
422
  const NullValue = ({ value, isEditing, setIsEditing }) => {
404
423
  const { styles } = useTheme();
405
- return isEditing ? (jsx("div", { className: "jer-input-null", children: "null" })) : (jsx("div", { onDoubleClick: () => setIsEditing(true), className: "jer-value-null", style: styles.null, children: String(value) }));
424
+ return isEditing ? (jsx("div", Object.assign({ className: "jer-input-null" }, { children: "null" }))) : (jsx("div", Object.assign({ onDoubleClick: () => setIsEditing(true), className: "jer-value-null", style: styles.null }, { children: String(value) })));
406
425
  };
407
426
  const ObjectValue = () => {
408
- return jsx("span", { className: "jer-value-object", children: '{ }' });
427
+ return jsx("span", Object.assign({ className: "jer-value-object" }, { children: '{ }' }));
409
428
  };
410
429
  const ArrayValue = ({ value }) => {
411
- return jsx("span", { className: "jer-value-array", children: `[${value === null ? '' : value}]` });
430
+ return jsx("span", Object.assign({ className: "jer-value-array" }, { children: `[${value === null ? '' : value}]` }));
412
431
  };
413
432
  const InvalidValue = () => {
414
- return jsx("span", { className: "jer-value-invalid", children: "Invalid value" });
433
+ return jsx("span", Object.assign({ className: "jer-value-invalid" }, { children: "Invalid value" }));
415
434
  };
416
435
 
417
436
  const Icon = ({ name, rotate }) => {
437
+ var _a, _b, _c, _d, _e, _f, _g;
418
438
  const { styles, icons } = useTheme();
419
439
  const commonProps = { size: '1.4em', className: 'jer-icon' };
420
440
  switch (name) {
421
441
  case 'add':
422
- return icons?.add ?? jsx(BiPlusCircle, { ...commonProps, style: styles.iconAdd });
442
+ return (_a = icons === null || icons === void 0 ? void 0 : icons.add) !== null && _a !== void 0 ? _a : jsx(BiPlusCircle, Object.assign({}, commonProps, { style: styles.iconAdd }));
423
443
  case 'edit':
424
- return icons?.edit ?? jsx(BiEdit, { ...commonProps, style: styles.iconEdit });
444
+ return (_b = icons === null || icons === void 0 ? void 0 : icons.edit) !== null && _b !== void 0 ? _b : jsx(BiEdit, Object.assign({}, commonProps, { style: styles.iconEdit }));
425
445
  case 'delete':
426
- return (icons?.delete ?? jsx(MdDeleteForever, { ...commonProps, style: styles.iconDelete, size: "1.5em" }));
446
+ return ((_c = icons === null || icons === void 0 ? void 0 : icons.delete) !== null && _c !== void 0 ? _c : jsx(MdDeleteForever, Object.assign({}, commonProps, { style: styles.iconDelete, size: "1.5em" })));
427
447
  case 'copy':
428
- return icons?.copy ?? jsx(HiOutlineClipboardCopy, { ...commonProps, style: styles.iconCopy });
448
+ return (_d = icons === null || icons === void 0 ? void 0 : icons.copy) !== null && _d !== void 0 ? _d : jsx(HiOutlineClipboardCopy, Object.assign({}, commonProps, { style: styles.iconCopy }));
429
449
  case 'ok':
430
- return (icons?.ok ?? (jsx(FiCheckCircle, { ...commonProps, style: { fontSize: '90%', ...styles.iconOk } })));
450
+ return ((_e = icons === null || icons === void 0 ? void 0 : icons.ok) !== null && _e !== void 0 ? _e : (jsx(FiCheckCircle, Object.assign({}, commonProps, { style: Object.assign({ fontSize: '90%' }, styles.iconOk) }))));
431
451
  case 'cancel':
432
- return (icons?.cancel ?? (jsx(TiCancel, { ...commonProps, style: { fontSize: '130%', ...styles.iconCancel } })));
452
+ return ((_f = icons === null || icons === void 0 ? void 0 : icons.cancel) !== null && _f !== void 0 ? _f : (jsx(TiCancel, Object.assign({}, commonProps, { style: Object.assign({ fontSize: '130%' }, styles.iconCancel) }))));
433
453
  case 'chevron':
434
- return (icons?.chevron ?? (jsx(FaChevronDown, { className: `${rotate ? ' jer-rotate-90' : ''}`, style: styles.iconCollection })));
454
+ return ((_g = icons === null || icons === void 0 ? void 0 : icons.chevron) !== null && _g !== void 0 ? _g : (jsx(FaChevronDown, { className: `${rotate ? ' jer-rotate-90' : ''}`, style: styles.iconCollection })));
435
455
  default:
436
456
  return jsx(Fragment, {});
437
457
  }
@@ -471,22 +491,22 @@ const EditButtons = ({ startEdit, handleDelete, handleAdd, enableClipboard, type
471
491
  if (typeof enableClipboard === 'function')
472
492
  enableClipboard({ value, path, key: name, type });
473
493
  };
474
- return (jsxs("div", { className: "jer-edit-buttons", style: isAdding ? { opacity: 1 } : undefined, children: [enableClipboard && (jsx("div", { onClick: handleCopy, className: "jer-copy-pulse", children: jsx(Icon, { name: "copy" }) })), startEdit && (jsx("div", { onClick: startEdit, children: jsx(Icon, { name: "edit" }) })), handleDelete && (jsx("div", { onClick: handleDelete, children: jsx(Icon, { name: "delete" }) })), handleAdd && (jsx("div", { onClick: () => {
494
+ return (jsxs("div", Object.assign({ className: "jer-edit-buttons", style: isAdding ? { opacity: 1 } : undefined }, { children: [enableClipboard && (jsx("div", Object.assign({ onClick: handleCopy, className: "jer-copy-pulse" }, { children: jsx(Icon, { name: "copy" }) }))), startEdit && (jsx("div", Object.assign({ onClick: startEdit }, { children: jsx(Icon, { name: "edit" }) }))), handleDelete && (jsx("div", Object.assign({ onClick: handleDelete }, { children: jsx(Icon, { name: "delete" }) }))), handleAdd && (jsx("div", Object.assign({ onClick: () => {
475
495
  if (type === 'object')
476
496
  setIsAdding(true);
477
497
  else
478
498
  handleAdd('');
479
- }, children: jsx(Icon, { name: "add" }) })), isAdding && handleAdd && type === 'object' && (jsxs(Fragment, { children: [jsx("input", { className: "jer-input-new-key", type: "text", name: "new-object-key", value: newKey, onChange: (e) => setNewKey(e.target.value), autoFocus: true, onFocus: (e) => e.target.select(), onKeyDown: handleKeyPress, style: { ...styles.input } }), jsx(InputButtons, { onOk: () => {
499
+ } }, { children: jsx(Icon, { name: "add" }) }))), isAdding && handleAdd && type === 'object' && (jsxs(Fragment, { children: [jsx("input", { className: "jer-input-new-key", type: "text", name: "new-object-key", value: newKey, onChange: (e) => setNewKey(e.target.value), autoFocus: true, onFocus: (e) => e.target.select(), onKeyDown: handleKeyPress, style: Object.assign({}, styles.input) }), jsx(InputButtons, { onOk: () => {
480
500
  if (!!newKey) {
481
501
  setIsAdding(false);
482
502
  handleAdd(newKey);
483
503
  }
484
504
  }, onCancel: () => {
485
505
  setIsAdding(false);
486
- } })] }))] }));
506
+ } })] }))] })));
487
507
  };
488
508
  const InputButtons = ({ onOk, onCancel }) => {
489
- return (jsxs("div", { className: "jer-confirm-buttons", children: [jsx("div", { onClick: onOk, children: jsx(Icon, { name: "ok" }) }), jsx("div", { onClick: onCancel, children: jsx(Icon, { name: "cancel" }) })] }));
509
+ return (jsxs("div", Object.assign({ className: "jer-confirm-buttons" }, { children: [jsx("div", Object.assign({ onClick: onOk }, { children: jsx(Icon, { name: "ok" }) })), jsx("div", Object.assign({ onClick: onCancel }, { children: jsx(Icon, { name: "cancel" }) }))] })));
490
510
  };
491
511
  const stringifyPath = (path) => path.reduce((str, part) => {
492
512
  if (typeof part === 'number')
@@ -567,11 +587,8 @@ const ValueNodeWrapper = ({ data, name, path, onEdit, onDelete, enableClipboard,
567
587
  path,
568
588
  stringTruncate,
569
589
  };
570
- return (jsx("div", { className: "jer-component jer-value-component", style: { marginLeft: `${indent / 2}em` }, children: jsxs("div", { className: "jer-value-main-row", children: [showArrayIndices && (jsxs("label", { htmlFor: path.join('.'), className: "jer-object-key", style: {
571
- ...styles.property,
572
- minWidth: `${Math.min(String(name).length + 1, 5)}ch`,
573
- }, children: [name, ":", ' '] })), jsx("div", { className: "jer-input-component", children: getInputComponent(dataType, inputProps) }), isEditing ? (jsx(InputButtons, { onOk: handleEdit, onCancel: handleCancel })) : (dataType !== 'invalid' &&
574
- !error && (jsx(EditButtons, { startEdit: canEdit ? () => setIsEditing(true) : undefined, handleDelete: canDelete ? handleDelete : undefined, data: data, enableClipboard: enableClipboard, name: name, path: path, translate: translate }))), isEditing && (jsx("select", { name: `${name}-type-select`, className: "jer-type-select", onChange: (e) => handleChangeDataType(e.target.value), value: dataType, children: DataTypes.map((type) => (jsx("option", { value: type, children: type }, type))) })), !isEditing && error && (jsx("span", { className: "jer-error-slug", style: styles.error, children: error }))] }) }));
590
+ return (jsx("div", Object.assign({ className: "jer-component jer-value-component", style: { marginLeft: `${indent / 2}em` } }, { children: jsxs("div", Object.assign({ className: "jer-value-main-row" }, { children: [showArrayIndices && (jsxs("label", Object.assign({ htmlFor: path.join('.'), className: "jer-object-key", style: Object.assign(Object.assign({}, styles.property), { minWidth: `${Math.min(String(name).length + 1, 5)}ch` }) }, { children: [name, ":", ' '] }))), jsx("div", Object.assign({ className: "jer-input-component" }, { children: getInputComponent(dataType, inputProps) })), isEditing ? (jsx(InputButtons, { onOk: handleEdit, onCancel: handleCancel })) : (dataType !== 'invalid' &&
591
+ !error && (jsx(EditButtons, { startEdit: canEdit ? () => setIsEditing(true) : undefined, handleDelete: canDelete ? handleDelete : undefined, data: data, enableClipboard: enableClipboard, name: name, path: path, translate: translate }))), isEditing && (jsx("select", Object.assign({ name: `${name}-type-select`, className: "jer-type-select", onChange: (e) => handleChangeDataType(e.target.value), value: dataType }, { children: DataTypes.map((type) => (jsx("option", Object.assign({ value: type }, { children: type }), type))) }))), !isEditing && error && (jsx("span", Object.assign({ className: "jer-error-slug", style: styles.error }, { children: error })))] })) })));
575
592
  };
576
593
  const getDataType = (value) => {
577
594
  if (typeof value === 'string')
@@ -588,19 +605,19 @@ const getInputComponent = (dataType, inputProps) => {
588
605
  const value = inputProps.value;
589
606
  switch (dataType) {
590
607
  case 'string':
591
- return jsx(StringValue, { ...inputProps, value: value });
608
+ return jsx(StringValue, Object.assign({}, inputProps, { value: value }));
592
609
  case 'number':
593
- return jsx(NumberValue, { ...inputProps, value: value });
610
+ return jsx(NumberValue, Object.assign({}, inputProps, { value: value }));
594
611
  case 'boolean':
595
- return jsx(BooleanValue, { ...inputProps, value: value });
612
+ return jsx(BooleanValue, Object.assign({}, inputProps, { value: value }));
596
613
  case 'null':
597
- return jsx(NullValue, { ...inputProps });
614
+ return jsx(NullValue, Object.assign({}, inputProps));
598
615
  case 'object':
599
- return jsx(ObjectValue, { ...inputProps });
616
+ return jsx(ObjectValue, Object.assign({}, inputProps));
600
617
  case 'array':
601
- return jsx(ArrayValue, { ...inputProps });
618
+ return jsx(ArrayValue, Object.assign({}, inputProps));
602
619
  default:
603
- return jsx(InvalidValue, { ...inputProps });
620
+ return jsx(InvalidValue, Object.assign({}, inputProps));
604
621
  }
605
622
  };
606
623
  const convertValue = (value, type) => {
@@ -624,7 +641,8 @@ const convertValue = (value, type) => {
624
641
  };
625
642
 
626
643
  const isCollection = (value) => value !== null && typeof value == 'object';
627
- const CollectionNode = ({ data, path, name, ...props }) => {
644
+ const CollectionNode = (_a) => {
645
+ var { data, path, name } = _a, props = __rest(_a, ["data", "path", "name"]);
628
646
  const { styles } = useTheme();
629
647
  const { onEdit, onAdd, onDelete, restrictEditFilter, restrictDeleteFilter, restrictAddFilter, collapseFilter, enableClipboard, indent, keySort, showArrayIndices, defaultValue, translate, } = props;
630
648
  const [isEditing, setIsEditing] = useState(false);
@@ -663,7 +681,7 @@ const CollectionNode = ({ data, path, name, ...props }) => {
663
681
  showError(error);
664
682
  });
665
683
  }
666
- catch {
684
+ catch (_a) {
667
685
  setError(translate('ERROR_INVALID_JSON'));
668
686
  setTimeout(() => setError(null), ERROR_DISPLAY_TIME);
669
687
  console.log('Invalid JSON');
@@ -712,21 +730,21 @@ const CollectionNode = ({ data, path, name, ...props }) => {
712
730
  if (keySort && collectionType === 'object')
713
731
  keyValueArray.sort(typeof keySort === 'function' ? (a, b) => keySort(a[0], b[0]) : undefined);
714
732
  const numOfLines = JSON.stringify(data, null, 2).split('\n').length;
715
- return (jsxs("div", { className: "jer-component fb-collection-component", style: { marginLeft: `${path.length === 0 ? 0 : indent / 2}em` }, children: [jsxs("div", { className: "jer-collection-header-row", children: [jsx("div", { onClick: () => {
733
+ return (jsxs("div", Object.assign({ className: "jer-component fb-collection-component", style: { marginLeft: `${path.length === 0 ? 0 : indent / 2}em` } }, { children: [jsxs("div", Object.assign({ className: "jer-collection-header-row" }, { children: [jsx("div", Object.assign({ onClick: () => {
716
734
  if (!isEditing)
717
735
  setCollapsed(!collapsed);
718
- }, children: jsx(Icon, { name: "chevron", rotate: collapsed }) }), jsxs("div", { className: "jer-collection-name", children: [jsx("span", { style: styles.property, children: showLabel ? `${name}:` : null }), jsx("span", { className: "jer-brackets", style: styles.bracket, children: brackets.open })] }), jsx("div", { className: "jer-collection-item-count", style: styles.itemCount, children: collectionSize === 1
736
+ } }, { children: jsx(Icon, { name: "chevron", rotate: collapsed }) })), jsxs("div", Object.assign({ className: "jer-collection-name" }, { children: [jsx("span", Object.assign({ style: styles.property }, { children: showLabel ? `${name}:` : null })), jsx("span", Object.assign({ className: "jer-brackets", style: styles.bracket }, { children: brackets.open }))] })), jsx("div", Object.assign({ className: "jer-collection-item-count", style: styles.itemCount }, { children: collectionSize === 1
719
737
  ? translate('ITEM_SINGLE', 1)
720
- : translate('ITEMS_MULTIPLE', collectionSize) }), collapsed && (jsx("div", { className: "jer-brackets", style: styles.bracket, children: brackets.close })), !isEditing && (jsx(EditButtons, { startEdit: canEdit
738
+ : translate('ITEMS_MULTIPLE', collectionSize) })), collapsed && (jsx("div", Object.assign({ className: "jer-brackets", style: styles.bracket }, { children: brackets.close }))), !isEditing && (jsx(EditButtons, { startEdit: canEdit
721
739
  ? () => {
722
740
  setIsEditing(true);
723
741
  setCollapsed(false);
724
742
  }
725
- : undefined, handleAdd: canAdd ? handleAdd : undefined, handleDelete: canDelete ? handleDelete : undefined, enableClipboard: enableClipboard, type: collectionType, data: data, name: name, path: path, translate: translate }))] }), jsxs("div", { className: 'jer-collection-inner', style: {
743
+ : undefined, handleAdd: canAdd ? handleAdd : undefined, handleDelete: canDelete ? handleDelete : undefined, enableClipboard: enableClipboard, type: collectionType, data: data, name: name, path: path, translate: translate }))] })), jsxs("div", Object.assign({ className: 'jer-collection-inner', style: {
726
744
  maxHeight: collapsed ? 0 : `${numOfLines * 1.6}em`,
727
745
  overflowY: collapsed ? 'hidden' : 'visible',
728
746
  transition: `max-height ${transitionTime}`,
729
- }, children: [isEditing ? (jsxs("div", { className: "jer-collection-text-edit", children: [jsx(AutogrowTextArea, { className: "jer-collection-text-area", name: path.join('.'), value: stringifiedValue, setValue: setStringifiedValue, isEditing: isEditing, handleKeyPress: handleKeyPress }), jsx("div", { className: "jer-collection-input-button-row", children: jsx(InputButtons, { onOk: handleEdit, onCancel: handleCancel, isCollection: true }) })] })) : (jsx(Fragment, { children: keyValueArray.map(([key, value]) => (jsx("div", { className: "jer-collection-element", children: isCollection(value) ? (jsx(CollectionNode, { data: value, path: [...path, key], name: key, ...props }, key)) : (jsx(ValueNodeWrapper, { data: value, path: [...path, key], name: key, ...props, showArrayIndices: collectionType === 'object' ? true : showArrayIndices }, key)) }, key))) })), jsx("div", { className: isEditing ? 'jer-collection-error-row' : 'jer-collection-error-row-edit', children: error && (jsx("span", { className: "jer-error-slug", style: styles.error, children: error })) })] }), !collapsed && (jsx("div", { className: "jer-brackets", style: styles.bracket, children: brackets.close }))] }));
747
+ } }, { children: [isEditing ? (jsxs("div", Object.assign({ className: "jer-collection-text-edit" }, { children: [jsx(AutogrowTextArea, { className: "jer-collection-text-area", name: path.join('.'), value: stringifiedValue, setValue: setStringifiedValue, isEditing: isEditing, handleKeyPress: handleKeyPress }), jsx("div", Object.assign({ className: "jer-collection-input-button-row" }, { children: jsx(InputButtons, { onOk: handleEdit, onCancel: handleCancel, isCollection: true }) }))] }))) : (jsx(Fragment, { children: keyValueArray.map(([key, value]) => (jsx("div", Object.assign({ className: "jer-collection-element" }, { children: isCollection(value) ? (jsx(CollectionNode, Object.assign({ data: value, path: [...path, key], name: key }, props), key)) : (jsx(ValueNodeWrapper, Object.assign({ data: value, path: [...path, key], name: key }, props, { showArrayIndices: collectionType === 'object' ? true : showArrayIndices }), key)) }), key))) })), jsx("div", Object.assign({ className: isEditing ? 'jer-collection-error-row' : 'jer-collection-error-row-edit' }, { children: error && (jsx("span", Object.assign({ className: "jer-error-slug", style: styles.error }, { children: error }))) }))] })), !collapsed && (jsx("div", Object.assign({ className: "jer-brackets", style: styles.bracket }, { children: brackets.close })))] })));
730
748
  };
731
749
 
732
750
  const localisedStrings = {
@@ -741,7 +759,7 @@ const localisedStrings = {
741
759
  };
742
760
  const translate = (translations, key, count) => {
743
761
  const string = key in translations ? translations[key] : localisedStrings[key];
744
- return count === undefined ? string : string?.replace('{{count}}', String(count));
762
+ return count === undefined ? string : string === null || string === void 0 ? void 0 : string.replace('{{count}}', String(count));
745
763
  };
746
764
  const getTranslateFunction = (translations) => (key, count) => translate(translations, key, count);
747
765
 
@@ -759,10 +777,10 @@ const Editor = ({ data: srcData, rootName = 'root', onUpdate, onEdit: srcEdit =
759
777
  if (icons)
760
778
  setIcons(icons);
761
779
  }, [theme, icons]);
762
- const onEdit = async (value, path) => {
780
+ const onEdit = (value, path) => __awaiter(void 0, void 0, void 0, function* () {
763
781
  const { currentData, newData, currentValue, newValue } = updateDataObject(data, path, value, 'update');
764
782
  if (srcEdit) {
765
- const result = await srcEdit({
783
+ const result = yield srcEdit({
766
784
  currentData,
767
785
  newData,
768
786
  currentValue,
@@ -778,11 +796,11 @@ const Editor = ({ data: srcData, rootName = 'root', onUpdate, onEdit: srcEdit =
778
796
  }
779
797
  else
780
798
  setData(newData);
781
- };
782
- const onDelete = async (value, path) => {
799
+ });
800
+ const onDelete = (value, path) => __awaiter(void 0, void 0, void 0, function* () {
783
801
  const { currentData, newData, currentValue, newValue } = updateDataObject(data, path, value, 'delete');
784
802
  if (srcDelete) {
785
- const result = await srcDelete({
803
+ const result = yield srcDelete({
786
804
  currentData,
787
805
  newData,
788
806
  currentValue,
@@ -798,11 +816,11 @@ const Editor = ({ data: srcData, rootName = 'root', onUpdate, onEdit: srcEdit =
798
816
  }
799
817
  else
800
818
  setData(newData);
801
- };
802
- const onAdd = async (value, path) => {
819
+ });
820
+ const onAdd = (value, path) => __awaiter(void 0, void 0, void 0, function* () {
803
821
  const { currentData, newData, currentValue, newValue } = updateDataObject(data, path, value, 'add');
804
822
  if (srcAdd) {
805
- const result = await srcAdd({
823
+ const result = yield srcAdd({
806
824
  currentData,
807
825
  newData,
808
826
  currentValue,
@@ -818,7 +836,7 @@ const Editor = ({ data: srcData, rootName = 'root', onUpdate, onEdit: srcEdit =
818
836
  }
819
837
  else
820
838
  setData(newData);
821
- };
839
+ });
822
840
  const restrictEditFilter = getFilterFunction(restrictEdit);
823
841
  const restrictDeleteFilter = getFilterFunction(restrictDelete);
824
842
  const restrictAddFilter = getFilterFunction(restrictAdd);
@@ -841,9 +859,9 @@ const Editor = ({ data: srcData, rootName = 'root', onUpdate, onEdit: srcEdit =
841
859
  };
842
860
  if (!styles)
843
861
  return null;
844
- return (jsx("div", { className: 'jer-editor-container ' + className, style: { ...styles.container, minWidth, maxWidth }, children: isCollection(data) && jsx(CollectionNode, { data: data, path: [], ...otherProps }) }));
862
+ return (jsx("div", Object.assign({ className: 'jer-editor-container ' + className, style: Object.assign(Object.assign({}, styles.container), { minWidth, maxWidth }) }, { children: isCollection(data) && jsx(CollectionNode, Object.assign({ data: data, path: [] }, otherProps)) })));
845
863
  };
846
- const JsonEditor = (props) => (jsx(ThemeProvider, { children: jsx(Editor, { ...props }) }));
864
+ const JsonEditor = (props) => (jsx(ThemeProvider, { children: jsx(Editor, Object.assign({}, props)) }));
847
865
  const updateDataObject = (data, path, newValue, action) => {
848
866
  if (path.length === 0) {
849
867
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-edit-react",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "React component for editing or viewing JSON/object data",
5
5
  "main": "build/index.cjs.js",
6
6
  "module": "build/index.esm.js",