json-edit-react 1.13.3 → 1.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,6 +4,9 @@
4
4
 
5
5
  A [React](https://github.com/facebook/react) component for editing or viewing JSON/object data
6
6
 
7
+ > [!IMPORTANT]
8
+ > **Version 1.14.0** has a change which recommends you provide a `setData` prop and not use `onUpdate` for updating your data externally. See [Managing state](#managing-state).
9
+
7
10
  Features include:
8
11
 
9
12
  - edit individual values, or whole objects as JSON text
@@ -24,6 +27,7 @@ Features include:
24
27
  - [Implementation](#implementation)
25
28
  - [Usage](#usage)
26
29
  - [Props overview](#props-overview)
30
+ - [Managing state](#managing-state)
27
31
  - [Update functions](#update-functions)
28
32
  - [OnChange function](#onchange-function)
29
33
  - [OnError function](#onerror-function)
@@ -69,10 +73,8 @@ import { JsonEditor } from 'json-edit-react'
69
73
  return
70
74
  <JsonEditor
71
75
  data={ jsonData }
72
- onUpdate={ ({newData} ) => {
73
- // Do something with the new data, e.g. update jsonData
74
- }}
75
- { ...otherProps } />
76
+ setData={ setJsonData } // optional
77
+ { ...otherProps } />
76
78
  ```
77
79
 
78
80
  ## Usage
@@ -93,11 +95,12 @@ It's pretty self explanatory (click the "edit" icon to edit, etc.), but there ar
93
95
 
94
96
  ## Props overview
95
97
 
96
- The only *required* value is `data`.
98
+ The only *required* value is `data` (although you will need to provide a `setData` method to update your data).
97
99
 
98
100
  | prop | type | default | description |
99
101
  | ----------------------- | --------------------------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
100
102
  | `data` | `object\|array` | | The data to be displayed / edited |
103
+ | `setData` | `object\|array => void` | | Method to update your `data` object. See [Managing state](#managing-state) below for additional notes. |
101
104
  | `rootName` | `string` | `"data"` | A name to display in the editor as the root of the data object. |
102
105
  | `onUpdate` | `UpdateFunction` | | A function to run whenever a value is **updated** (edit, delete *or* add) in the editor. See [Update functions](#update-functions). |
103
106
  | `onEdit` | `UpdateFunction` | | A function to run whenever a value is **edited**. |
@@ -134,10 +137,13 @@ The only *required* value is `data`.
134
137
  | `customNodeDefinitions` | `CustomNodeDefinition[]` | | You can provide customised components to override specific nodes in the data tree, according to a condition function. See see [Custom nodes](#custom-nodes) for more detail. (A simple custom component to turn url strings into active links is provided in the main package -- see [here](#active-hyperlinks)) |
135
138
  | `customText` | `CustomTextDefinitions` | | In addition to [localising the component](#localisation) text strings, you can also *dynamically* alter it, depending on the data. See [Custom Text](#custom-text) for more detail. |
136
139
 
140
+ ## Managing state
141
+
142
+ It is recommended that you manage the `data` state yourself outside this component -- just pass in a `setData` method, which is called internally to update your `data`. However, this is not compulsory -- if you don't provide a `setData` method, the data will be managed internally, which would be fine if you're not doing anything with the data. The alternative is to use the [Update functions](#update-functions) to update your `data` externally, but this is not recommended except in special circumstances as you can run into issues keeping your data in sync with the internal state (which is what is displayed), as well as unnecessary re-renders. Update functions should be ideally be used only for implementing side effects, checking for errors, or mutating the data before setting it with `setData`.
137
143
 
138
144
  ## Update functions
139
145
 
140
- A callback to be executed whenever a data update (edit, delete or add) occurs can be provided. You might wish to use this to update some external state, make an API call, or [validate the data structure](#json-schema-validation) against a JSON schema. If you want the same function for all updates, then just the `onUpdate` prop is sufficient. However, should you require something different for editing, deletion and addition, then you can provide separate Update functions via the `onEdit`, `onDelete` and `onAdd` props.
146
+ A callback to be executed whenever a data update (edit, delete or add) occurs can be provided. You might wish to use this to update some external state, make an API call, modify the data before saving it, or [validate the data structure](#json-schema-validation) against a JSON schema. If you want the same function for all updates, then just the `onUpdate` prop is sufficient. However, should you require something different for editing, deletion and addition, then you can provide separate Update functions via the `onEdit`, `onDelete` and `onAdd` props.
141
147
 
142
148
  The function will receive the following object as a parameter:
143
149
 
@@ -153,7 +159,12 @@ The function will receive the following object as a parameter:
153
159
  }
154
160
  ```
155
161
 
156
- The function needn't return anything, but if it returns `false`, it will be considered an error, in which case an error message will displayed in the UI and the internal data state won't actually be updated. If the return value is a `string`, this will be the error message displayed (i.e. you can define your own error messages for updates). On error, the displayed data will revert to its previous value.
162
+ The function needn't return anything, in which case the data is updated normally. However, you can return either an Error value, or a modified data value, which will be used instead of the input data. The return value can be one of the following:
163
+ - `void` / `undefined`: data continues update as normal
164
+ - `false`: considers the update to be an error, so data is not updated (reverts to previous value), and a generic error message is displayed in the UI
165
+ - `string`: also considered an error, so no data update, but the UI error message will be your provided string
166
+ - `[ "value", <value> ]`: tells the component to use the returned `<value>` instead of the input data. You might use this to automatically modify user input -- for example, sorting an array, or inserting a timestamp field into an object.
167
+ - `[ "error", <value> ]`: same as `string`, but in the longer tuple format.
157
168
 
158
169
  ### OnChange function
159
170
 
@@ -334,7 +345,8 @@ return
334
345
 
335
346
  ### Drag-n-drop
336
347
 
337
- *NOTE: This is a new feature and should be considered "experimental". Please provide [feedback or suggestions](https://github.com/CarlosNZ/json-edit-react/issues) to help improve it.*
348
+ > [!NOTE]
349
+ > *This is a new feature and should be considered "experimental". Please provide [feedback or suggestions](https://github.com/CarlosNZ/json-edit-react/issues) to help improve it.*
338
350
 
339
351
  The `restrictDrag` property controls which items (if any) can be dragged into new positions. By default, this is *off*, so you must set `restrictDrag = false` to enable this functionality. Like the Edit restrictions above, this property can also take a Filter function for fine-grained control. There are a couple of additional considerations, though:
340
352
 
@@ -646,6 +658,7 @@ A few helper functions, components and types that might be useful in your own im
646
658
  - `Theme`: a full [Theme](#themes--styles) object
647
659
  - `ThemeInput`: input type for the `theme` prop
648
660
  - `JsonEditorProps`: all input props for the Json Editor component
661
+ - `JsonData`: main `data` object -- any valid JSON structure
649
662
  - [`UpdateFunction`](#update-functions), [`OnChangeFunction`](#onchange-function), [`OnErrorFunction`](#onerror-function) [`FilterFunction`](#filter-functions), [`CopyFunction`](#copy-function), [`SearchFilterFunction`](#searchfiltering), [`CompareFunction`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort), [`LocalisedString`](#localisation), [`CustomNodeDefinition`](#custom-nodes), [`CustomTextDefinitions`](#custom-text)
650
663
  - `TranslateFunction`: function that takes a [localisation](#localisation) key and returns a translated string
651
664
  - `IconReplacements`: input type for the `icons` prop
@@ -670,6 +683,11 @@ This component is heavily inspired by [react-json-view](https://github.com/mac-s
670
683
 
671
684
  ## Changelog
672
685
 
686
+ - **1.14.0**:
687
+ - Allow [UpdateFunction](#update-functions) to return a modified value, not just an error
688
+ - Add `setData` prop to discourage reliance on internal data [state management](#managing-state)
689
+ - Refactor state/event management to use less `useEffect` hooks
690
+ - **1.13.3**: Bug fix for when root data value is `null` [#90](https://github.com/CarlosNZ/json-edit-react/issues/90)
673
691
  - **1.13.2**: Slightly better error handling when validating [JSON schema](#json-schema-validation)
674
692
  - **1.13.0**:
675
693
  - [Drag-n-drop](#drag-n-drop) editing!
@@ -1 +1 @@
1
- "use strict";var jsxRuntime=require("react/jsx-runtime"),react=require("react"),assign=require("object-property-assigner"),extractProperty=require("object-property-extractor"),JSON5=require("json5");function __awaiter(thisArg,_arguments,P,generator){return new(P||(P=Promise))((function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){var value;result.done?resolve(result.value):(value=result.value,value instanceof P?value:new P((function(resolve){resolve(value)}))).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var e=[],t=[];!function(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}}(":root {\n --jer-select-border: #b6b6b6;\n --jer-select-focus: #777;\n --jer-select-arrow: #777;\n --jer-form-border: 1px solid #ededf0;\n --jer-form-border-focus: 1px solid #e2e2e2;\n --jer-expand-transition-time: 0.5s;\n --jer-highlight-color: #b3d8ff;\n}\n\n.jer-visible {\n opacity: 1;\n transition: var(--jer-expand-transition-time);\n}\n\n.jer-hidden {\n opacity: 0;\n transition: var(--jer-expand-transition-time);\n}\n\n/* Select styled as per:\nhttps://moderncss.dev/custom-select-styles-with-pure-css/\n*/\n\n.jer-select select {\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n background-color: transparent;\n border: none;\n padding: 0 1em 0 0;\n margin: 0;\n /* width: 100%; */\n font-family: inherit;\n font-size: 0.8em;\n color: black;\n cursor: inherit;\n line-height: inherit;\n z-index: 1;\n outline: none;\n}\nselect::-ms-expand {\n display: none;\n}\n\n.jer-select {\n display: grid;\n grid-template-areas: 'select';\n align-items: center;\n position: relative;\n min-width: 12ch;\n max-width: 15ch;\n border: 1px solid var(--jer-select-border);\n border-radius: 0.25em;\n padding: 0.25em 0.5em;\n cursor: pointer;\n line-height: 1.1;\n background-color: #fff;\n background-image: linear-gradient(to top, #f9f9f9, #fff 33%);\n}\n.jer-select select,\n.jer-select::after {\n grid-area: select;\n}\n.jer-select:not(.jer-select--multiple)::after {\n content: '';\n justify-self: end;\n width: 0.8em;\n height: 0.5em;\n background-color: var(--jer-select-arrow);\n -webkit-clip-path: polygon(100% 0%, 0 0%, 50% 100%);\n clip-path: polygon(100% 0%, 0 0%, 50% 100%);\n}\n\nselect:focus + .focus {\n position: absolute;\n top: -1px;\n left: -1px;\n right: -1px;\n bottom: -1px;\n border: 1px solid var(--jer-select-focus);\n border-radius: inherit;\n}\n\n.jer-editor-container {\n position: relative;\n font-size: 16px;\n line-height: 1;\n padding: 1em;\n padding-left: 2em;\n /* margin-top: 1em; */\n /* margin-bottom: 1em; */\n border-radius: 0.5em;\n text-align: left;\n}\n\n.jer-editor-container textarea {\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 font-family: inherit;\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.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-bracket-outside {\n} */\n\n/* .jer-collection-item-count {\n} */\n\n.jer-collapse-icon {\n position: absolute;\n left: -1.2em;\n top: 0.35em;\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 align-items: flex-start;\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 font-family: inherit;\n font-size: 0.85em;\n}\n\n.jer-collection-input-button-row {\n display: flex;\n justify-content: flex-end;\n font-size: 150%;\n margin-top: 0.4em;\n}\n\n/* .jer-collection-element {\n} */\n\n.jer-collection-error-row {\n position: absolute;\n bottom: 0.5em;\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 gap: 0;\n}\n\n.jer-value-and-buttons {\n display: flex;\n justify-content: flex-start;\n align-items: center;\n padding-left: 0.5em;\n}\n\n.jer-value-error-row {\n position: absolute;\n}\n\n.jer-value-string {\n line-height: 1.3em;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n\n.jer-hyperlink {\n text-decoration: underline;\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-top: 0.25em;\n padding-bottom: 0.2em;\n min-width: 6em;\n overflow: hidden;\n line-height: 1.2em;\n font-family: inherit;\n font-size: 0.9em;\n}\n\n/* .jer-value-number {\n} */\n\n/* .jer-value-boolean {\n} */\n\n.jer-input-boolean {\n transform: scale(1.5);\n margin-left: 0.3em;\n margin-right: 0.3em;\n}\n\n/* .jer-value-null {\n} */\n\n.jer-value-object {\n}\n\n.jer-key-text {\n word-break: break-word;\n line-height: 1.1em;\n white-space: pre-wrap;\n}\n\n.jer-key-edit {\n padding: 0 0.3em;\n font-size: inherit;\n font-size: 0.9em;\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-number {\n min-width: 3em;\n font-size: 90%;\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 height: 1em;\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-value-and-buttons:hover > .jer-edit-buttons {\n opacity: 1;\n}\n\n/* .jer-input-buttons {\n} */\n\n.jer-copy-pulse {\n position: relative;\n transition: transform var(--jer-expand-transition-time);\n}\n\n.jer-copy-pulse:hover {\n opacity: 0.85;\n transition: 0.3s;\n transform: scale(1.2);\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-accordion-icon {\n /* font-size: '2em'; */\n transition: transform var(--jer-expand-transition-time);\n}\n\n.jer-icon:hover {\n opacity: 0.85;\n transition: 0.3s;\n transform: scale(1.2);\n}\n\n/* For displaying keys that are purely <empty string> \"\" */\n.jer-empty-string::after {\n content: '<empty string>';\n font-style: italic;\n font-size: 90%;\n}\n\n.jer-drag-n-drop-padding {\n height: 0.5em;\n border: 1px dashed #e0e0e0;\n border-radius: 0.3em;\n}\n",{});const AutogrowTextArea=({className:className,name:name,value:value,setValue:setValue,handleKeyPress:handleKeyPress,styles:styles})=>{if("string"!=typeof value)return null;const dummyValue="\n"===value.slice(-1)?value+".":value;return jsxRuntime.jsxs("div",{style:{display:"grid"},children:[jsxRuntime.jsx("textarea",{id:`${name}_textarea`,style:Object.assign({height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap"},styles),rows:1,className:className,name:`${name}_textarea`,value:value,onChange:e=>setValue(e.target.value),autoFocus:!0,onFocus:e=>{value.length<40&&e.target.select()},onKeyDown:handleKeyPress}),jsxRuntime.jsx("span",{className:className,style:Object.assign({visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent"},styles),children:dummyValue})]})},themes={default:{displayName:"Default",fragments:{edit:"rgb(42, 161, 152)"},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},collection:{},collectionInner:{},collectionElement:{},dropZone:{},property:"#292929",bracket:{color:"rgb(0, 43, 54)",fontWeight:"bold"},itemCount:{color:"rgba(0, 0, 0, 0.3)",fontStyle:"italic"},string:"rgb(203, 75, 22)",number:"rgb(38, 139, 210)",boolean:"green",null:{color:"rgb(220, 50, 47)",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"rgb(0, 43, 54)",iconEdit:"edit",iconDelete:"rgb(203, 75, 22)",iconAdd:"edit",iconCopy:"rgb(38, 139, 210)",iconOk:"green",iconCancel:"rgb(203, 75, 22)"}},githubDark:{displayName:"Github Dark",styles:{container:{backgroundColor:"#0d1117",color:"white"},dropZone:"rgba(165, 214, 255, 0.17)",property:"#E6EDF3",bracket:"#56d364",itemCount:"#8B949E",string:"#A5D6FF",number:"#D2A8FF",boolean:{color:"#FF7B72",fontSize:"90%",fontWeight:"bold"},null:"green",iconCollection:"#D2A8FF",iconEdit:"#D2A8FF",iconDelete:"rgb(203, 75, 22)",iconAdd:"rgb(203, 75, 22)",iconCopy:"#A5D6FF",iconOk:"#56d364",iconCancel:"rgb(203, 75, 22)"}},githubLight:{displayName:"Github Light",styles:{container:"white",property:"#1F2328",bracket:"#00802e",itemCount:"#8B949E",string:"#0A3069",number:"#953800",boolean:{color:"#CF222E",fontSize:"90%",fontWeight:"bold"},null:"#FF7B72",iconCollection:"#8250DF",iconEdit:"#8250DF",iconDelete:"rgb(203, 75, 22)",iconAdd:"#8250DF",iconCopy:"#57606A"}},monoDark:{displayName:"Black & White",fragments:{lightText:{color:"white"},midGrey:"#5c5c5c"},styles:{container:["lightText",{backgroundColor:"black"}],dropZone:"#e0e0e029",property:"lightText",bracket:"midGrey",itemCount:"#4a4a4a",string:"#a8a8a8",number:"#666666",boolean:{color:"#848484",fontStyle:"italic"},null:"#333333",iconCollection:"midGrey",iconEdit:"midGrey",iconDelete:"midGrey",iconAdd:"midGrey",iconCopy:"midGrey",iconOk:"midGrey",iconCancel:"midGrey"}},monoLight:{fragments:{midGrey:"#a3a3a3"},displayName:"White & Black",styles:{container:"white",property:"black",bracket:"midGrey",itemCount:"#b5b5b5",string:"#575757",number:"#999999",boolean:{color:"#7b7b7b",fontStyle:"italic"},null:"#cccccc",iconCollection:"midGrey",iconEdit:"midGrey",iconDelete:"midGrey",iconAdd:"midGrey",iconCopy:"midGrey",iconOk:"midGrey",iconCancel:"midGrey"}},candyWrapper:{displayName:"Candy Wrapper",fragments:{minty:{backgroundColor:"#F1FAEE"},pale:{color:"#A8DADC"},mid:{color:"#457B9D"},dark:{color:"#1D3557"},pop:{color:"#E63946"},darkBlue:{color:"#2B2D42"}},styles:{container:"minty",property:"pop",dropZone:"#eb121217",bracket:"dark",itemCount:"pale",string:"mid",number:["darkBlue",{fontSize:"85%"}],boolean:["mid",{fontStyle:"italic",fontWeight:"bold",fontSize:"80%"}],null:["#cccccc",{fontWeight:"bold"}],input:{border:"1px solid rgb(115, 194, 198)"},iconCollection:"#1D3557",iconEdit:"#457B9D",iconDelete:"#E63946",iconAdd:"#2B2D42",iconCopy:"#1D3557",iconCancel:"#E63946"}},psychedelic:{displayName:"Psychedelic",fragments:{minty:{backgroundColor:"#F1FAEE"},pale:{color:"#A8DADC"},mid:{color:"#457B9D"},dark:{color:"#1D3557"},pop:{color:"#E63946"},fluroYellow:"rgb(242, 228, 21)",fluroGreen:"rgb(68, 255, 62)",hotPink:"#f7379a"},styles:{container:{backgroundColor:"unset",background:"linear-gradient(90deg, hsla(333, 100%, 53%, 1) 0%, hsla(33, 94%, 57%, 1) 100%)",color:"black"},dropZone:"fluroYellow",property:"black",bracket:"fluroYellow",itemCount:["pale",{opacity:.7}],string:"white",number:["#33d9ff",{fontSize:"90%",fontWeight:"bold"}],boolean:["fluroGreen",{fontWeight:"bold",fontSize:"80%"}],null:["black",{fontWeight:"bold",opacity:.3,backgroundColor:"rgb(255, 255, 255, 0.5)",padding:"0 0.4em",borderRadius:"0.4em"}],iconCollection:"fluroYellow",iconEdit:["black"],iconDelete:["white",{opacity:.5}],iconAdd:["white",{opacity:.5}],iconCopy:"rgb(32, 84, 242)",iconOk:"fluroGreen",iconCancel:"hotPink"}}},emptyStyleObject={container:{},collection:{},collectionInner:{},collectionElement:{},dropZone:{},property:{},bracket:{},itemCount:{},string:{},number:{},boolean:{},null:{},input:{},inputHighlight:{},error:{},iconCollection:{},iconEdit:{},iconDelete:{},iconAdd:{},iconCopy:{},iconOk:{},iconCancel:{}},defaultTheme=themes.default,ThemeProviderContext=react.createContext({getStyles:()=>({}),setTheme:_=>{},icons:{},setIcons:()=>{}}),ThemeProvider=({children:children})=>{const[styles,setStyles]=react.useState(emptyStyleObject),[icons,setIcons]=react.useState({});return jsxRuntime.jsx(ThemeProviderContext.Provider,{value:{getStyles:(element,nodeData)=>"function"==typeof styles[element]?styles[element](nodeData):styles[element],setTheme:theme=>{const styles=compileStyles(theme);setStyles(styles)},icons:icons,setIcons:setIcons},children:children})},useTheme=()=>react.useContext(ThemeProviderContext),compileStyles=themeInput=>{var _a,_b,_c,_d;const collectedFunctions={},stylesArray=(Array.isArray(themeInput)?themeInput:[themeInput]).map((theme=>"default"===themeInput?{}:"string"==typeof theme?buildStyleObject(themes[theme],collectedFunctions):isStyleObject(theme)?buildStyleObject({fragments:{},styles:theme},collectedFunctions):buildStyleObject(theme,collectedFunctions))),mergedStyleObject=buildStyleObject(defaultTheme,{});Object.keys(mergedStyleObject).forEach((k=>{const key=k;stylesArray.forEach((styleObj=>{styleObj[key]&&(mergedStyleObject[key]=Object.assign(Object.assign({},mergedStyleObject[key]),styleObj[key]))}))}));const finalStyles=Object.assign({},mergedStyleObject);return Object.entries(collectedFunctions).forEach((([key,func])=>{const element=key;finalStyles[element]=nodeData=>{const funcResult=func(nodeData)||{};return Object.assign(Object.assign({},mergedStyleObject[element]),funcResult)}})),"function"!=typeof(null==finalStyles?void 0:finalStyles.inputHighlight)&&(null===(_a=null==finalStyles?void 0:finalStyles.inputHighlight)||void 0===_a?void 0:_a.backgroundColor)&&document.documentElement.style.setProperty("--jer-highlight-color",null===(_b=null==finalStyles?void 0:finalStyles.inputHighlight)||void 0===_b?void 0:_b.backgroundColor),"function"!=typeof(null==finalStyles?void 0:finalStyles.iconCopy)&&(null===(_c=null==finalStyles?void 0:finalStyles.iconCopy)||void 0===_c?void 0:_c.color)&&document.documentElement.style.setProperty("--jer-icon-copy-color",null===(_d=null==finalStyles?void 0:finalStyles.iconCopy)||void 0===_d?void 0:_d.color),finalStyles},buildStyleObject=(theme,collectedFunctions)=>{const{fragments:fragments,styles:styles}=theme,styleObject={};return Object.entries(styles).forEach((([key,value])=>{const cssStyles=(Array.isArray(value)?value:[value]).reduce(((acc,curr)=>{var _a;if("function"==typeof curr)return collectedFunctions[key]=curr,Object.assign({},acc);if("string"==typeof curr){const style=null!==(_a=null==fragments?void 0:fragments[curr])&&void 0!==_a?_a:curr;return"string"==typeof style?Object.assign(Object.assign({},acc),{[defaultStyleProperties[key]]:style}):Object.assign(Object.assign({},acc),style)}return Object.assign(Object.assign({},acc),curr)}),{});styleObject[key]=cssStyles})),styleObject},isStyleObject=overrideObject=>!("styles"in overrideObject),defaultStyleProperties={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",property:"color",bracket:"color",itemCount:"color",string:"color",number:"color",boolean:"color",null:"color",input:"color",inputHighlight:"backgroundColor",error:"color",iconCollection:"color",iconEdit:"color",iconDelete:"color",iconAdd:"color",iconCopy:"color",iconOk:"color",iconCancel:"color"},truncate=(string,length=200)=>"string"==typeof string?string.length<length?string:`${string.slice(0,length-2).trim()}...`:string,toPathString=path=>path.map((part=>""===part?String.fromCharCode(0):part)).join("."),StringValue=({value:value,setValue:setValue,isEditing:isEditing,path:path,setIsEditing:setIsEditing,handleEdit:handleEdit,handleCancel:handleCancel,stringTruncate:stringTruncate,showStringQuotes:showStringQuotes,nodeData:nodeData})=>{const{getStyles:getStyles}=useTheme(),pathString=toPathString(path),quoteChar=showStringQuotes?'"':"";return isEditing?jsxRuntime.jsx(AutogrowTextArea,{className:"jer-input-text",name:pathString,value:value,setValue:setValue,isEditing:isEditing,handleKeyPress:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&handleCancel():handleEdit()},styles:getStyles("input",nodeData)}):jsxRuntime.jsxs("div",{id:`${pathString}_display`,onDoubleClick:()=>setIsEditing(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&setIsEditing(!0)},className:"jer-value-string",style:getStyles("string",nodeData),children:[quoteChar,truncate(value,stringTruncate),quoteChar]})},NumberValue=({value:value,setValue:setValue,isEditing:isEditing,path:path,setIsEditing:setIsEditing,handleEdit:handleEdit,handleCancel:handleCancel,nodeData:nodeData})=>{const{getStyles:getStyles}=useTheme();return isEditing?jsxRuntime.jsx("input",{className:"jer-input-number",type:"text",name:toPathString(path),value:value,onChange:e=>setValue(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{switch(e.key){case"Enter":handleEdit();break;case"Escape":handleCancel();break;case"ArrowUp":e.preventDefault(),setValue(Number(value)+1);break;case"ArrowDown":e.preventDefault(),setValue(Number(value)-1)}},style:Object.assign({width:String(value).length/1.5+2+"em"},getStyles("input",nodeData))}):jsxRuntime.jsx("span",{onDoubleClick:()=>setIsEditing(!0),className:"jer-value-number",style:getStyles("number",nodeData),children:value})},BooleanValue=({value:value,setValue:setValue,isEditing:isEditing,path:path,setIsEditing:setIsEditing,handleEdit:handleEdit,handleCancel:handleCancel,nodeData:nodeData})=>{const{getStyles:getStyles}=useTheme();react.useEffect((()=>(isEditing&&document.addEventListener("keydown",listenForSubmit),()=>document.removeEventListener("keydown",listenForSubmit))),[isEditing,handleEdit]);const listenForSubmit=event=>{"Enter"===event.key?handleEdit():"Escape"===event.key&&handleCancel()};return isEditing?jsxRuntime.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:toPathString(path),checked:value,onChange:()=>setValue(!value)}):jsxRuntime.jsx("span",{onDoubleClick:()=>setIsEditing(!0),className:"jer-value-boolean",style:getStyles("boolean",nodeData),children:String(value)})},NullValue=({value:value,isEditing:isEditing,setIsEditing:setIsEditing,handleEdit:handleEdit,handleCancel:handleCancel,nodeData:nodeData})=>{const{getStyles:getStyles}=useTheme();react.useEffect((()=>(isEditing&&document.addEventListener("keydown",listenForSubmit),()=>document.removeEventListener("keydown",listenForSubmit))),[isEditing]);const listenForSubmit=event=>{"Enter"===event.key?handleEdit():"Escape"===event.key&&handleCancel()};return jsxRuntime.jsx("div",{onDoubleClick:()=>setIsEditing(!0),className:"jer-value-null",style:getStyles("null",nodeData),children:String(value)})},ObjectValue=({value:value,translate:translate,isEditing:isEditing,handleEdit:handleEdit,handleCancel:handleCancel,nodeData:nodeData})=>{react.useEffect((()=>(isEditing&&document.addEventListener("keydown",listenForSubmit),()=>document.removeEventListener("keydown",listenForSubmit))),[]);const listenForSubmit=event=>{"Enter"===event.key?handleEdit():"Escape"===event.key&&handleCancel()};return jsxRuntime.jsx("span",{className:"jer-value-object",children:`{${translate("DEFAULT_NEW_KEY",nodeData)}: "${String(value)}" }`})},ArrayValue=({value:value,isEditing:isEditing,handleEdit:handleEdit,handleCancel:handleCancel})=>{react.useEffect((()=>(isEditing&&document.addEventListener("keydown",listenForSubmit),()=>document.removeEventListener("keydown",listenForSubmit))),[]);const listenForSubmit=event=>{"Enter"===event.key?handleEdit():"Escape"===event.key&&handleCancel()};return jsxRuntime.jsx("span",{className:"jer-value-array",children:`[${null===value?"":String(value)}]`})},InvalidValue=({value:value})=>{let message="Error!";switch(typeof value){case"string":"**INVALID_FUNCTION**"===value&&(message="Function");break;case"undefined":message="Undefined";break;case"symbol":message="Symbol"}return jsxRuntime.jsx("span",{className:"jer-value-invalid",children:message})},IconAdd=({size:size,style:style,className:className})=>jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:size,height:size,className:className,style:style,children:[jsxRuntime.jsx("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),jsxRuntime.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]}),IconEdit=({size:size,style:style,className:className})=>jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:size,height:size,className:className,style:style,transform:"translate(0, 0.5)",children:[jsxRuntime.jsx("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),jsxRuntime.jsx("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),IconDelete=({size:size,style:style,className:className})=>jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:size,height:size,className:className,style:style,children:jsxRuntime.jsx("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"})}),IconCopy=({size:size,style:style,className:className})=>jsxRuntime.jsxs("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:size,height:size,className:className,style:style,children:[jsxRuntime.jsx("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),jsxRuntime.jsx("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),jsxRuntime.jsx("path",{d:"M15 10l-4 4 4 4"})]}),IconOk=({size:size,style:style,className:className})=>jsxRuntime.jsxs("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:size,height:size,className:className,style:style,children:[jsxRuntime.jsx("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),jsxRuntime.jsx("path",{d:"M22 4L12 14.01l-3-3"})]}),IconCancel=({size:size,style:style,className:className})=>jsxRuntime.jsx("svg",{baseProfile:"tiny",viewBox:"0 0 24 24",fill:"currentColor",width:size,height:size,className:className,style:style,children:jsxRuntime.jsx("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"})}),IconChevron=({size:size,style:style,className:className})=>jsxRuntime.jsx("svg",{viewBox:"0 0 512 512",fill:"currentColor",width:size,height:size,className:className,style:style,children:jsxRuntime.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"})}),Icon=({name:name,nodeData:nodeData,rotate:rotate})=>{var _a,_b,_c,_d,_e,_f,_g;const{getStyles:getStyles,icons:icons}=useTheme(),commonProps={size:"1.4em",className:"jer-icon"};switch(name){case"add":return null!==(_a=null==icons?void 0:icons.add)&&void 0!==_a?_a:jsxRuntime.jsx(IconAdd,Object.assign({},commonProps,{style:getStyles("iconAdd",nodeData)}));case"edit":return null!==(_b=null==icons?void 0:icons.edit)&&void 0!==_b?_b:jsxRuntime.jsx(IconEdit,Object.assign({},commonProps,{style:getStyles("iconEdit",nodeData)}));case"delete":return null!==(_c=null==icons?void 0:icons.delete)&&void 0!==_c?_c:jsxRuntime.jsx(IconDelete,Object.assign({},commonProps,{style:getStyles("iconDelete",nodeData),size:"1.45em"}));case"copy":return null!==(_d=null==icons?void 0:icons.copy)&&void 0!==_d?_d:jsxRuntime.jsx(IconCopy,Object.assign({},commonProps,{style:getStyles("iconCopy",nodeData),size:"1.2em"}));case"ok":return null!==(_e=null==icons?void 0:icons.ok)&&void 0!==_e?_e:jsxRuntime.jsx(IconOk,Object.assign({},commonProps,{style:Object.assign({fontSize:"90%"},getStyles("iconOk",nodeData))}));case"cancel":return null!==(_f=null==icons?void 0:icons.cancel)&&void 0!==_f?_f:jsxRuntime.jsx(IconCancel,Object.assign({},commonProps,{style:Object.assign({fontSize:"130%"},getStyles("iconCancel",nodeData))}));case"chevron":return null!==(_g=null==icons?void 0:icons.chevron)&&void 0!==_g?_g:jsxRuntime.jsx(IconChevron,{className:"jer-accordion-icon"+(rotate?" jer-rotate-90":""),size:"1em",style:getStyles("iconCollection",nodeData)});default:return jsxRuntime.jsx(jsxRuntime.Fragment,{})}},EditButtons=({startEdit:startEdit,handleDelete:handleDelete,handleAdd:handleAdd,enableClipboard:enableClipboard,type:type,nodeData:nodeData,translate:translate})=>{const{getStyles:getStyles}=useTheme(),NEW_KEY_PROMPT=translate("KEY_NEW",nodeData),[isAdding,setIsAdding]=react.useState(!1),[newKey,setNewKey]=react.useState(NEW_KEY_PROMPT),{key:key,path:path,value:data}=nodeData;react.useEffect((()=>{isAdding||setNewKey(NEW_KEY_PROMPT)}),[isAdding]);return jsxRuntime.jsxs("div",{className:"jer-edit-buttons",style:{opacity:isAdding?1:void 0},children:[enableClipboard&&jsxRuntime.jsx("div",{onClick:e=>{let value,copyType="value",stringValue="";if(enableClipboard){if(!0===(e.ctrlKey||e.metaKey))value=stringifyPath(path),stringValue=value,copyType="path";else value=data,stringValue=type?JSON.stringify(data,null,2):String(value);navigator.clipboard.writeText(stringValue)}"function"==typeof enableClipboard&&enableClipboard({value:value,stringValue:stringValue,path:path,key:key,type:copyType})},className:"jer-copy-pulse",children:jsxRuntime.jsx(Icon,{name:"copy",nodeData:nodeData})}),startEdit&&jsxRuntime.jsx("div",{onClick:startEdit,children:jsxRuntime.jsx(Icon,{name:"edit",nodeData:nodeData})}),handleDelete&&jsxRuntime.jsx("div",{onClick:handleDelete,children:jsxRuntime.jsx(Icon,{name:"delete",nodeData:nodeData})}),handleAdd&&jsxRuntime.jsx("div",{onClick:()=>{"object"===type?setIsAdding(!0):handleAdd("")},children:jsxRuntime.jsx(Icon,{name:"add",nodeData:nodeData})}),isAdding&&handleAdd&&"object"===type&&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:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key&&handleAdd?(setIsAdding(!1),handleAdd(newKey)):"Escape"===e.key&&setIsAdding(!1)},style:getStyles("input",nodeData)}),jsxRuntime.jsx(InputButtons,{onOk:()=>{newKey&&(setIsAdding(!1),handleAdd(newKey))},onCancel:()=>{setIsAdding(!1)},nodeData:nodeData})]})]})},InputButtons=({onOk:onOk,onCancel:onCancel,nodeData:nodeData})=>jsxRuntime.jsxs("div",{className:"jer-confirm-buttons",children:[jsxRuntime.jsx("div",{onClick:onOk,children:jsxRuntime.jsx(Icon,{name:"ok",nodeData:nodeData})}),jsxRuntime.jsx("div",{onClick:onCancel,children:jsxRuntime.jsx(Icon,{name:"cancel",nodeData:nodeData})})]}),stringifyPath=path=>path.reduce(((str,part)=>"number"==typeof part?`${str}[${part}]`:""===str?part:`${str}.${part}`),""),DataTypes=["string","number","boolean","null","object","array"],getCustomNode=(customNodeDefinitions=[],nodeData)=>{const matchingDefinitions=customNodeDefinitions.filter((({condition:condition})=>condition(nodeData)));if(0===matchingDefinitions.length)return{};const _a=matchingDefinitions[0],{element:element,wrapperElement:wrapperElement,customNodeProps:customNodeProps,wrapperProps:wrapperProps,hideKey:hideKey=!1,showEditTools:showEditTools=!0,showOnEdit:showOnEdit=!1,showOnView:showOnView=!0,showCollectionWrapper:showCollectionWrapper=!0}=_a,rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(null!=s&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]])}return t}(_a,["element","wrapperElement","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:element,CustomWrapper:wrapperElement,customNodeProps:customNodeProps,wrapperProps:wrapperProps,hideKey:hideKey,showEditTools:showEditTools,showOnEdit:showOnEdit,showOnView:showOnView,showCollectionWrapper:showCollectionWrapper},rest)},isCollection=value=>null!==value&&"object"==typeof value,filterNode=(type,nodeData,searchFilter,searchText="")=>{if(!searchFilter&&!searchText)return!0;switch(type){case"collection":if(searchFilter){if(searchFilter(nodeData,searchText))return!0;if(!filterCollection(searchText,nodeData,searchFilter))return!1}if(!searchFilter&&searchText&&!filterCollection(searchText,nodeData))return!1;break;case"value":if(searchFilter&&!searchFilter(nodeData,searchText))return!1;if(!searchFilter&&searchText&&!matchNode(nodeData,searchText))return!1}return!0},filterCollection=(searchText="",nodeData,matcher=matchNode)=>{const collection=nodeData.value;return Object.entries(collection).some((([key,value])=>{const childPath=[...nodeData.path,key],childNodeData=Object.assign(Object.assign({},nodeData),{key:key,path:childPath,level:nodeData.level+1,value:value,size:childPath.length,parentData:collection});return isCollection(value)?filterCollection(searchText,childNodeData,matcher):matcher(childNodeData,searchText)}))},matchNode=(nodeData,searchText="")=>{const{value:value}=nodeData;if(null===value&&"null".includes(searchText.toLowerCase()))return!0;switch(typeof value){case"string":return value.toLowerCase().includes(searchText.toLowerCase());case"number":return!!String(value).includes(searchText);case"boolean":return value?"true".includes(searchText.toLowerCase())||"1"===searchText:"false".includes(searchText.toLowerCase())||"0"===searchText;default:return!1}},matchNodeKey=({key:key,path:path},searchText="")=>!!matchNode({value:key},searchText)||!!path.some((field=>matchNode({value:field},searchText))),TreeStateProviderContext=react.createContext({collapseState:null,setCollapseState:()=>{},doesPathMatch:()=>!1,currentlyEditingElement:null,setCurrentlyEditingElement:()=>{},areChildrenBeingEdited:()=>!1,dragSource:{path:null,pathString:null},setDragSource:()=>{}}),TreeStateProvider=({children:children})=>{const[collapseState,setCollapseState]=react.useState(null),[currentlyEditingElement,setCurrentlyEditingElement]=react.useState(null),[dragSource,setDragSource]=react.useState({path:null,pathString:null});return jsxRuntime.jsx(TreeStateProviderContext.Provider,{value:{collapseState:collapseState,setCollapseState:setCollapseState,doesPathMatch:path=>{if(null===collapseState)return!1;for(const[index,value]of collapseState.path.entries())if(value!==path[index])return!1;return!0},currentlyEditingElement:currentlyEditingElement,setCurrentlyEditingElement:setCurrentlyEditingElement,areChildrenBeingEdited:pathString=>null!==currentlyEditingElement&&currentlyEditingElement.includes(pathString),dragSource:dragSource,setDragSource:setDragSource},children:children})},useTreeState=()=>react.useContext(TreeStateProviderContext),useDragNDrop=({canDrag:canDrag,canDragOnto:canDragOnto,path:path,nodeData:nodeData,onMove:onMove,onError:onError,translate:translate})=>{const{getStyles:getStyles}=useTheme(),{dragSource:dragSource,setDragSource:setDragSource}=useTreeState(),[isDragTarget,setIsDragTarget]=react.useState(!1),pathString=toPathString(path),dragSourceProps=react.useMemo((()=>canDrag?{onDragStart:e=>{e.stopPropagation(),setDragSource({path:path,pathString:pathString})},onDragEnd:e=>{e.stopPropagation(),setDragSource({path:null,pathString:null})}}:{}),[canDrag]),getDropTargetProps=react.useMemo((()=>position=>canDragOnto?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:e=>{e.stopPropagation(),handleDrop(position),setDragSource({path:null,pathString:null}),setIsDragTarget(!1)},onDragEnter:e=>{var _a;e.stopPropagation(),pathString.startsWith(null!==(_a=dragSource.pathString)&&void 0!==_a?_a:"")||setIsDragTarget(position)},onDragExit:e=>{e.stopPropagation(),setIsDragTarget(!1)}}:{}),[dragSource,canDragOnto]),BottomDropTarget=react.useMemo((()=>canDragOnto&&null!==dragSource.pathString?jsxRuntime.jsx("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:path.length}},getDropTargetProps("below"))):null),[dragSource,canDragOnto]),handleDrop=position=>{var _a,_b;const sourceKey=null===(_a=dragSource.path)||void 0===_a?void 0:_a.slice(-1)[0],sourceBase=null===(_b=dragSource.path)||void 0===_b?void 0:_b.slice(0,-1).join("."),thisBase=path.slice(0,-1).join(""),{parentData:parentData}=nodeData;"string"==typeof sourceKey&&parentData&&!Array.isArray(parentData)&&Object.keys(parentData).includes(sourceKey)&&sourceKey in parentData&&sourceBase!==thisBase?onError({code:"KEY_EXISTS",message:translate("ERROR_KEY_EXISTS",nodeData)},sourceKey):onMove(dragSource.path,path,position).then((error=>{error&&onError({code:"UPDATE_ERROR",message:error},nodeData.value)}))};return{dragSourceProps:dragSourceProps,getDropTargetProps:getDropTargetProps,BottomDropTarget:BottomDropTarget,DropTargetPadding:({position:position,nodeData:nodeData})=>isDragTarget===position?jsxRuntime.jsx("div",{className:"jer-drag-n-drop-padding",style:getStyles("dropZone",nodeData)}):null,handleDrop:handleDrop}},useCommon=({props:props,collapsed:collapsed})=>{const{data:data,nodeData:incomingNodeData,parentData:parentData,onEdit:onEdit,onError:onErrorCallback,showErrorMessages:showErrorMessages,restrictEditFilter:restrictEditFilter,restrictDeleteFilter:restrictDeleteFilter,restrictAddFilter:restrictAddFilter,restrictDragFilter:restrictDragFilter,translate:translate}=props,{currentlyEditingElement:currentlyEditingElement,setCurrentlyEditingElement:setCurrentlyEditingElement}=useTreeState(),[error,setError]=react.useState(null),nodeData=Object.assign(Object.assign({},incomingNodeData),{collapsed:collapsed}),{path:path,key:name,size:size}=nodeData,pathString=toPathString(path),canEdit=react.useMemo((()=>!restrictEditFilter(nodeData)),[nodeData]),canDelete=react.useMemo((()=>!restrictDeleteFilter(nodeData)),[nodeData]),canAdd=react.useMemo((()=>!restrictAddFilter(nodeData)),[nodeData]),canDrag=react.useMemo((()=>!restrictDragFilter(nodeData)&&canDelete&&null===currentlyEditingElement),[nodeData]),showError=errorString=>{showErrorMessages&&(setError(errorString),setTimeout((()=>setError(null)),2500)),console.warn("Error",errorString)},onError=react.useMemo((()=>(error,errorValue)=>{showError(error.message),onErrorCallback&&onErrorCallback({currentData:nodeData.fullData,errorValue:errorValue,currentValue:data,name:name,path:path,error:error})}),[onErrorCallback,showErrorMessages]),isEditing=currentlyEditingElement===pathString,isEditingKey=currentlyEditingElement===`key_${pathString}`,isArray="number"==typeof path.slice(-1)[0];return{pathString:pathString,nodeData:nodeData,path:path,name:name,size:size,canEdit:canEdit,canDelete:canDelete,canAdd:canAdd,canDrag:canDrag,error:error,showError:showError,onError:onError,setError:setError,handleEditKey:newKey=>{if(setCurrentlyEditingElement(null),name===newKey)return;if(!parentData)return;const parentPath=path.slice(0,-1);if(Object.keys(parentData).includes(newKey))return void onError({code:"KEY_EXISTS",message:translate("ERROR_KEY_EXISTS",nodeData)},newKey);const newData=Object.fromEntries(Object.entries(parentData).map((([key,val])=>key===name?[newKey,val]:[key,val])));onEdit(newData,parentPath).then((error=>{error&&onError({code:"UPDATE_ERROR",message:error},newKey)}))},derivedValues:{isEditing:isEditing,isEditingKey:isEditingKey,isArray:isArray,canEditKey:null!==parentData&&canEdit&&canAdd&&canDelete&&!isArray}}},ValueNodeWrapper=props=>{const{data:data,parentData:parentData,onEdit:onEdit,onDelete:onDelete,onChange:onChange,onMove:onMove,enableClipboard:enableClipboard,canDragOnto:canDragOnto,restrictTypeSelection:restrictTypeSelection,searchFilter:searchFilter,searchText:searchText,showLabel:showLabel,stringTruncate:stringTruncate,showStringQuotes:showStringQuotes,indent:indent,translate:translate,customNodeDefinitions:customNodeDefinitions}=props,{getStyles:getStyles}=useTheme(),{setCurrentlyEditingElement:setCurrentlyEditingElement,setCollapseState:setCollapseState}=useTreeState(),[value,setValue]=react.useState("function"==typeof data?"**INVALID_FUNCTION**":data),{pathString:pathString,nodeData:nodeData,path:path,name:name,canEdit:canEdit,canDelete:canDelete,canDrag:canDrag,error:error,onError:onError,handleEditKey:handleEditKey,derivedValues:derivedValues}=useCommon({props:props}),{dragSourceProps:dragSourceProps,getDropTargetProps:getDropTargetProps,BottomDropTarget:BottomDropTarget,DropTargetPadding:DropTargetPadding}=useDragNDrop({canDrag:canDrag,canDragOnto:canDragOnto,path:path,nodeData:nodeData,onMove:onMove,onError:onError,translate:translate}),customNodeData=getCustomNode(customNodeDefinitions,nodeData),[dataType,setDataType]=react.useState(getDataType(data,customNodeData)),updateValue=react.useCallback((newValue=>{if(!onChange)return void setValue(newValue);const modifiedValue=onChange({currentData:nodeData.fullData,newValue:newValue,currentValue:value,name:name,path:path});setValue(modifiedValue)}),[onChange]);react.useEffect((()=>{setValue("function"==typeof data?"**INVALID_FUNCTION**":data),setDataType(getDataType(data,customNodeData))}),[data,error]);const{CustomNode:CustomNode,customNodeProps:customNodeProps,hideKey:hideKey,showEditTools:showEditTools=!0,showOnEdit:showOnEdit,showOnView:showOnView}=customNodeData,allDataTypes=[...DataTypes,...customNodeDefinitions.filter((({showInTypesSelector:showInTypesSelector=!1,name:name})=>showInTypesSelector&&!!name)).map((({name:name})=>name))],allowedDataTypes=react.useMemo((()=>{if("boolean"==typeof restrictTypeSelection)return restrictTypeSelection?[]:allDataTypes;if(Array.isArray(restrictTypeSelection))return restrictTypeSelection;const result=restrictTypeSelection(nodeData);return"boolean"==typeof result?result?[]:allDataTypes:result}),[nodeData,restrictTypeSelection]);if(!filterNode("value",nodeData,searchFilter,searchText))return null;const handleEdit=()=>{let newValue;switch(setCurrentlyEditingElement(null),dataType){case"object":newValue={[translate("DEFAULT_NEW_KEY",nodeData)]:value};break;case"array":newValue=null!=value?value:[];break;case"number":{const n=Number(value);newValue=isNaN(n)?0:n;break}default:newValue=value}onEdit(newValue,path).then((error=>{error&&onError({code:"UPDATE_ERROR",message:error},newValue)}))},handleCancel=()=>{setCurrentlyEditingElement(null),setValue(data),setDataType(getDataType(data,customNodeData))},{isEditing:isEditing,isEditingKey:isEditingKey,canEditKey:canEditKey}=derivedValues,showErrorString=!isEditing&&error,showTypeSelector=isEditing&&allowedDataTypes.length>0,showEditButtons="invalid"!==dataType&&!error&&showEditTools,showKeyEdit=showLabel&&isEditingKey,showKey=showLabel&&!isEditingKey&&!hideKey,inputProps={value:value,parentData:parentData,setValue:updateValue,isEditing:isEditing,setIsEditing:canEdit?()=>setCurrentlyEditingElement(pathString):()=>{},handleEdit:handleEdit,handleCancel:handleCancel,path:path,stringTruncate:stringTruncate,showStringQuotes:showStringQuotes,nodeData:nodeData,translate:translate},ValueComponent=CustomNode&&(isEditing&&showOnEdit||!isEditing&&showOnView)?jsxRuntime.jsx(CustomNode,Object.assign({},props,{value:value,customNodeProps:customNodeProps,setValue:updateValue,handleEdit:handleEdit,handleCancel:handleCancel,handleKeyPress:e=>{"Enter"===e.key?handleEdit():"Escape"===e.key&&handleCancel()},isEditing:isEditing,setIsEditing:()=>setCurrentlyEditingElement(pathString),getStyles:getStyles})):getInputComponent(getDataType(data),inputProps);return jsxRuntime.jsxs("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:indent/2+"em",position:"relative"},draggable:canDrag},dragSourceProps,getDropTargetProps("above"),{children:[BottomDropTarget,jsxRuntime.jsx(DropTargetPadding,{position:"above",nodeData:nodeData}),jsxRuntime.jsxs("div",{className:"jer-value-main-row",style:{flexWrap:name.length>10?"wrap":"nowrap"},children:[showKey&&jsxRuntime.jsxs("span",{className:"jer-key-text",style:Object.assign(Object.assign({},getStyles("property",nodeData)),{minWidth:`${Math.min(String(name).length+1,5)}ch`,flexShrink:name.length>10?1:0}),onDoubleClick:()=>canEditKey&&setCurrentlyEditingElement(`key_${pathString}`),children:[""===name?jsxRuntime.jsx("span",{className:"jer-empty-string"}):name,":"]}),showKeyEdit&&jsxRuntime.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:pathString,defaultValue:name,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?handleEditKey(e.target.value):"Escape"===e.key&&handleCancel()},style:{width:String(name).length/1.5+.5+"em"}}),jsxRuntime.jsxs("div",{className:"jer-value-and-buttons",children:[jsxRuntime.jsx("div",{className:"jer-input-component",children:ValueComponent}),isEditing?jsxRuntime.jsx(InputButtons,{onOk:handleEdit,onCancel:handleCancel,nodeData:nodeData}):showEditButtons&&jsxRuntime.jsx(EditButtons,{startEdit:canEdit?()=>setCurrentlyEditingElement(pathString):void 0,handleDelete:canDelete?()=>{onDelete(value,path).then((error=>{error&&onError({code:"DELETE_ERROR",message:error},value)}))}:void 0,enableClipboard:enableClipboard,translate:translate,nodeData:nodeData}),showTypeSelector&&jsxRuntime.jsxs("div",{className:"jer-select",children:[jsxRuntime.jsx("select",{name:`${name}-type-select`,className:"jer-type-select",onChange:e=>(type=>{const customNode=customNodeDefinitions.find((customNode=>customNode.name===type));if(customNode)onEdit(customNode.defaultValue,path),setDataType(type);else{const newValue=convertValue(value,type,translate("DEFAULT_NEW_KEY",nodeData),(null==customNodeData?void 0:customNodeData.CustomNode)?translate("DEFAULT_STRING",nodeData):void 0);updateValue(newValue),onEdit(newValue,path).then((error=>{error&&(onError({code:"UPDATE_ERROR",message:error},newValue),setCurrentlyEditingElement(null))})),setCollapseState({path:path,collapsed:!1}),setDataType(type)}})(e.target.value),value:dataType,children:allowedDataTypes.map((type=>jsxRuntime.jsx("option",{value:type,children:type},type)))}),jsxRuntime.jsx("span",{className:"focus"})]}),showErrorString&&jsxRuntime.jsx("span",{className:"jer-error-slug",style:getStyles("error",nodeData),children:error})]})]}),jsxRuntime.jsx(DropTargetPadding,{position:"below",nodeData:nodeData})]}))},getDataType=(value,customNodeData)=>(null==customNodeData?void 0:customNodeData.CustomNode)&&(null==customNodeData?void 0:customNodeData.name)&&customNodeData.showInTypesSelector?customNodeData.name:"string"==typeof value?"string":"number"==typeof value?"number":"boolean"==typeof value?"boolean":null===value?"null":"invalid",getInputComponent=(dataType,inputProps)=>{const value=inputProps.value;switch(dataType){case"string":return jsxRuntime.jsx(StringValue,Object.assign({},inputProps,{value:value}));case"number":return jsxRuntime.jsx(NumberValue,Object.assign({},inputProps,{value:value}));case"boolean":return jsxRuntime.jsx(BooleanValue,Object.assign({},inputProps,{value:value}));case"null":return jsxRuntime.jsx(NullValue,Object.assign({},inputProps));case"object":return jsxRuntime.jsx(ObjectValue,Object.assign({},inputProps,{value:value}));case"array":return jsxRuntime.jsx(ArrayValue,Object.assign({},inputProps));default:return jsxRuntime.jsx(InvalidValue,Object.assign({},inputProps))}},convertValue=(value,type,defaultNewKey,defaultString)=>{switch(type){case"string":return null!=defaultString?defaultString:String(value);case"number":{const n=Number(value);return isNaN(n)?0:n}case"boolean":return!!value;case"null":return null;case"object":return{[defaultNewKey]:value};case"array":return[value];default:return String(value)}},CollectionNode=props=>{const{getStyles:getStyles}=useTheme(),{collapseState:collapseState,setCollapseState:setCollapseState,doesPathMatch:doesPathMatch,currentlyEditingElement:currentlyEditingElement,setCurrentlyEditingElement:setCurrentlyEditingElement,areChildrenBeingEdited:areChildrenBeingEdited}=useTreeState(),{data:data,nodeData:incomingNodeData,parentData:parentData,showCollectionCount:showCollectionCount,onEdit:onEdit,onAdd:onAdd,onDelete:onDelete,canDragOnto:canDragOnto,collapseFilter:collapseFilter,onMove:onMove,enableClipboard:enableClipboard,searchFilter:searchFilter,searchText:searchText,indent:indent,keySort:keySort,showArrayIndices:showArrayIndices,defaultValue:defaultValue,translate:translate,customNodeDefinitions:customNodeDefinitions}=props,[stringifiedValue,setStringifiedValue]=react.useState(JSON.stringify(data,null,2)),startCollapsed=collapseFilter(incomingNodeData),[collapsed,setCollapsed]=react.useState(startCollapsed),{pathString:pathString,nodeData:nodeData,path:path,name:name,size:size,canEdit:canEdit,canDelete:canDelete,canAdd:canAdd,canDrag:canDrag,error:error,setError:setError,onError:onError,handleEditKey:handleEditKey,derivedValues:derivedValues}=useCommon({props:props,collapsed:collapsed}),{dragSourceProps:dragSourceProps,getDropTargetProps:getDropTargetProps,BottomDropTarget:BottomDropTarget,DropTargetPadding:DropTargetPadding}=useDragNDrop({canDrag:canDrag,canDragOnto:canDragOnto,path:path,nodeData:nodeData,onMove:onMove,onError:onError,translate:translate}),hasBeenOpened=react.useRef(!startCollapsed),[isAnimating,setIsAnimating]=react.useState(!1);react.useEffect((()=>{setStringifiedValue(JSON.stringify(data,null,2))}),[data]),react.useEffect((()=>{const isCollapsed=collapseFilter(nodeData);hasBeenOpened.current=!isCollapsed,setCollapsed(isCollapsed)}),[collapseFilter]),react.useEffect((()=>{null!==collapseState&&doesPathMatch(path)&&(hasBeenOpened.current=!0,setCollapsed(collapseState.collapsed))}),[collapseState]);const getDefaultNewValue=react.useMemo((()=>nodeData=>"function"!=typeof defaultValue?defaultValue:defaultValue(nodeData)),[defaultValue]),{CustomNode:CustomNode,customNodeProps:customNodeProps,CustomWrapper:CustomWrapper,wrapperProps:wrapperProps={},hideKey:hideKey,showEditTools:showEditTools=!0,showOnEdit:showOnEdit,showOnView:showOnView,showCollectionWrapper:showCollectionWrapper=!0}=react.useMemo((()=>getCustomNode(customNodeDefinitions,nodeData)),[]);if(!filterNode("collection",nodeData,searchFilter,searchText)&&nodeData.level>0)return null;const collectionType=Array.isArray(data)?"array":"object",brackets="array"===collectionType?{open:"[",close:"]"}:{open:"{",close:"}"},transitionTime=getComputedStyle(document.documentElement).getPropertyValue("--jer-expand-transition-time"),handleKeyPress=e=>{"Enter"===e.key&&(e.metaKey||e.shiftKey||e.ctrlKey)?handleEdit():"Escape"===e.key&&handleCancel()},handleEdit=()=>{try{const value=JSON5.parse(stringifiedValue);if(setCurrentlyEditingElement(null),setError(null),JSON.stringify(value)===JSON.stringify(data))return;onEdit(value,path).then((error=>{error&&onError({code:"UPDATE_ERROR",message:error},value)}))}catch(_a){onError({code:"INVALID_JSON",message:translate("ERROR_INVALID_JSON",nodeData)},stringifiedValue)}},handleDelete=path.length>0?()=>{onDelete(data,path).then((error=>{error&&onError({code:"DELETE_ERROR",message:error},extractProperty(data,path))}))}:void 0,handleCancel=()=>{setCurrentlyEditingElement(null),setError(null),setStringifiedValue(JSON.stringify(data,null,2))},{isEditing:isEditing,isEditingKey:isEditingKey,isArray:isArray,canEditKey:canEditKey}=derivedValues,showCount="when-closed"===showCollectionCount?collapsed:showCollectionCount,showEditButtons=!isEditing&&showEditTools,showKey=(showArrayIndices||!isArray)&&!hideKey&&void 0!==name,showCustomNodeContents=CustomNode&&(isEditing&&showOnEdit||!isEditing&&showOnView),sortKeys=keySort&&"object"===collectionType,keyValueArray=Object.entries(data).map((([key,value])=>["array"===collectionType?Number(key):key,value]));sortKeys&&keyValueArray.sort("function"==typeof keySort?(a,b)=>keySort(a[0],b[0]):void 0);const numOfLines=JSON.stringify(data,null,2).replace(/\\n/g,"\n").split("\n").length,CollectionChildren=hasBeenOpened.current?isEditing?jsxRuntime.jsx("div",{className:"jer-collection-text-edit",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(AutogrowTextArea,{className:"jer-collection-text-area",name:pathString,value:stringifiedValue,setValue:setStringifiedValue,isEditing:isEditing,handleKeyPress:handleKeyPress,styles:getStyles("input",nodeData)}),jsxRuntime.jsx("div",{className:"jer-collection-input-button-row",children:jsxRuntime.jsx(InputButtons,{onOk:handleEdit,onCancel:handleCancel,nodeData:nodeData})})]})}):keyValueArray.map((([key,value],index)=>{const childNodeData={key:key,value:value,path:[...path,key],level:path.length+1,index:index,size:isCollection(value)?Object.keys(value).length:1,parentData:data,fullData:nodeData.fullData};return jsxRuntime.jsx("div",{className:"jer-collection-element",style:getStyles("collectionElement",childNodeData),children:isCollection(value)?jsxRuntime.jsx(CollectionNode,Object.assign({},props,{data:value,parentData:data,nodeData:childNodeData,showCollectionCount:showCollectionCount,canDragOnto:canEdit}),key):jsxRuntime.jsx(ValueNodeWrapper,Object.assign({},props,{data:value,parentData:data,nodeData:childNodeData,canDragOnto:canEdit,showLabel:"object"===collectionType||showArrayIndices}),key)},key)})):null,isCollapsed=!!showCollectionWrapper&&collapsed;isCollapsed||(hasBeenOpened.current=!0);const customNodeAllProps=Object.assign(Object.assign({},props),{data:data,value:data,parentData:parentData,nodeData:nodeData,setValue:val=>__awaiter(void 0,void 0,void 0,(function*(){return yield onEdit(val,path)})),handleEdit:handleEdit,handleCancel:handleCancel,handleKeyPress:handleKeyPress,isEditing:isEditing,setIsEditing:()=>setCurrentlyEditingElement(pathString),getStyles:getStyles,canDragOnto:canEdit}),CollectionContents=showCustomNodeContents?jsxRuntime.jsx(CustomNode,Object.assign({customNodeProps:customNodeProps},customNodeAllProps,{children:CollectionChildren})):CollectionChildren,KeyDisplay=isEditingKey?jsxRuntime.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:pathString,defaultValue:name,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?handleEditKey(e.target.value):"Escape"===e.key&&handleCancel()},style:{width:String(name).length/1.5+.5+"em"}}):showKey&&jsxRuntime.jsx("span",{className:"jer-key-text",style:getStyles("property",nodeData),onDoubleClick:()=>canEditKey&&setCurrentlyEditingElement(`key_${pathString}`),children:""===name?jsxRuntime.jsx("span",{className:path.length>0?"jer-empty-string":void 0}):`${name}:`}),EditButtonDisplay=showEditButtons&&jsxRuntime.jsx(EditButtons,{startEdit:canEdit?()=>{hasBeenOpened.current=!0,setCurrentlyEditingElement(pathString),setCollapsed(!1)}:void 0,handleAdd:canAdd?key=>{setCollapsed(!1);const newValue=getDefaultNewValue(nodeData);"array"===collectionType?onAdd(newValue,[...path,data.length]).then((error=>{error&&onError({code:"ADD_ERROR",message:error},newValue)})):key in data?onError({code:"KEY_EXISTS",message:translate("ERROR_KEY_EXISTS",nodeData)},key):onAdd(newValue,[...path,key]).then((error=>{error&&onError({code:"ADD_ERROR",message:error},newValue)}))}:void 0,handleDelete:canDelete?handleDelete:void 0,enableClipboard:enableClipboard,type:collectionType,nodeData:nodeData,translate:translate}),CollectionNodeComponent=jsxRuntime.jsxs("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===path.length?0:indent/2)+"em"},getStyles("collection",nodeData)),{position:"relative"}),draggable:canDrag},dragSourceProps,getDropTargetProps("above"),{children:[!isEditing&&BottomDropTarget,jsxRuntime.jsx(DropTargetPadding,{position:"above",nodeData:nodeData}),showCollectionWrapper?jsxRuntime.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[jsxRuntime.jsxs("div",{className:"jer-collection-name",children:[jsxRuntime.jsx("div",{className:"jer-collapse-icon",onClick:e=>(e=>{if(e.getModifierState("Alt"))return hasBeenOpened.current=!0,void setCollapseState({collapsed:!collapsed,path:path});currentlyEditingElement&&currentlyEditingElement.includes(pathString)||(setIsAnimating(!0),hasBeenOpened.current=!0,setCollapsed(!collapsed),setTimeout((()=>setIsAnimating(!1)),500))})(e),children:jsxRuntime.jsx(Icon,{name:"chevron",rotate:collapsed,nodeData:nodeData})}),KeyDisplay,!isEditing&&jsxRuntime.jsx("span",{className:"jer-brackets jer-bracket-open",style:getStyles("bracket",nodeData),children:brackets.open})]}),!isEditing&&showCount&&jsxRuntime.jsx("div",{className:"jer-collection-item-count"+(showCount?" jer-visible":" jer-hidden"),style:getStyles("itemCount",nodeData),children:1===size?translate("ITEM_SINGLE",Object.assign(Object.assign({},nodeData),{size:1}),1):translate("ITEMS_MULTIPLE",nodeData,size)}),jsxRuntime.jsx("div",{className:"jer-brackets"+(isCollapsed?" jer-visible":" jer-hidden"),style:getStyles("bracket",nodeData),children:brackets.close}),EditButtonDisplay]}):hideKey?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[KeyDisplay,EditButtonDisplay]}),jsxRuntime.jsxs("div",{className:"jer-collection-inner",style:Object.assign({maxHeight:isCollapsed?0:areChildrenBeingEdited(pathString)?void 0:3*numOfLines+"em",overflowY:isCollapsed||isAnimating?"hidden":"visible",transition:`max-height ${transitionTime}`},getStyles("collectionInner",nodeData)),children:[CollectionContents,jsxRuntime.jsx("div",{className:isEditing?"jer-collection-error-row":"jer-collection-error-row-edit",children:error&&jsxRuntime.jsx("span",{className:"jer-error-slug",style:getStyles("error",nodeData),children:error})}),!isEditing&&showCollectionWrapper&&jsxRuntime.jsx("div",{className:"jer-brackets jer-bracket-outside",style:getStyles("bracket",nodeData),children:brackets.close})]}),jsxRuntime.jsx(DropTargetPadding,{position:"below",nodeData:nodeData})]}));return CustomWrapper?jsxRuntime.jsx(CustomWrapper,Object.assign({customNodeProps:wrapperProps},customNodeAllProps,{children:CollectionNodeComponent})):CollectionNodeComponent},localisedStrings={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",KEY_NEW:"Enter new key",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",DEFAULT_STRING:"New data!",DEFAULT_NEW_KEY:"key"},getTranslateFunction=(translations,customText)=>(key,customTextData,count)=>((translations,customText,customTextData,key,count)=>{if(customText[key]){const output=customText[key](customTextData);if(null!==output)return output}const string=key in translations?translations[key]:localisedStrings[key];return void 0===count?string:null==string?void 0:string.replace("{{count}}",String(count))})(translations,customText,customTextData,key,count),Editor=({data:srcData,rootName:rootName="root",onUpdate:onUpdate=(()=>{}),onEdit:srcEdit=onUpdate,onDelete:srcDelete=onUpdate,onAdd:srcAdd=onUpdate,onChange:onChange,onError:onError,showErrorMessages:showErrorMessages=!0,enableClipboard:enableClipboard=!0,theme:theme="default",icons:icons,indent:indent=3,collapse:collapse=!1,showCollectionCount:showCollectionCount=!0,restrictEdit:restrictEdit=!1,restrictDelete:restrictDelete=!1,restrictAdd:restrictAdd=!1,restrictTypeSelection:restrictTypeSelection=!1,restrictDrag:restrictDrag=!0,searchFilter:searchFilterInput,searchText:searchText,searchDebounceTime:searchDebounceTime=350,keySort:keySort=!1,showArrayIndices:showArrayIndices=!0,showStringQuotes:showStringQuotes=!0,defaultValue:defaultValue=null,minWidth:minWidth=250,maxWidth:maxWidth="min(600px, 90vw)",rootFontSize:rootFontSize,stringTruncate:stringTruncate=250,translations:translations={},className:className,id:id,customText:customText={},customNodeDefinitions:customNodeDefinitions=[]})=>{const{getStyles:getStyles,setTheme:setTheme,setIcons:setIcons}=useTheme(),{setCollapseState:setCollapseState}=useTreeState(),collapseFilter=react.useCallback(getFilterFunction(collapse),[collapse]),translate=react.useCallback(getTranslateFunction(translations,customText),[translations,customText]),[debouncedSearchText,setDebouncedSearchText]=react.useState(searchText),[data,setData]=react.useState(srcData);react.useEffect((()=>{theme&&setTheme(theme),icons&&setIcons(icons)}),[theme,icons]),react.useEffect((()=>{setCollapseState(null),setData(srcData)}),[srcData]),react.useEffect((()=>{const debounce=setTimeout((()=>setDebouncedSearchText(searchText)),searchDebounceTime);return()=>clearTimeout(debounce)}),[searchText,searchDebounceTime]);const nodeData={key:rootName,path:[],level:0,index:0,value:data,size:"object"==typeof data&&null!==data?Object.keys(data).length:1,parentData:null,fullData:data},restrictEditFilter=react.useMemo((()=>getFilterFunction(restrictEdit)),[restrictEdit]),restrictDeleteFilter=react.useMemo((()=>getFilterFunction(restrictDelete)),[restrictDelete]),restrictAddFilter=react.useMemo((()=>getFilterFunction(restrictAdd)),[restrictAdd]),restrictDragFilter=react.useMemo((()=>getFilterFunction(restrictDrag)),[restrictDrag]),searchFilter=react.useMemo((()=>getSearchFilter(searchFilterInput)),[searchFilterInput]),otherProps={name:rootName,nodeData:nodeData,onEdit:(value,path)=>__awaiter(void 0,void 0,void 0,(function*(){const{currentData:currentData,newData:newData,currentValue:currentValue,newValue:newValue}=updateDataObject(data,path,value,"update");if(currentValue===newValue)return;const result=yield srcEdit({currentData:currentData,newData:newData,currentValue:currentValue,newValue:newValue,name:path.slice(-1)[0],path:path});if(void 0!==result)return setData(currentData),!1===result?translate("ERROR_UPDATE",nodeData):result;setData(newData)})),onDelete:(value,path)=>__awaiter(void 0,void 0,void 0,(function*(){const{currentData:currentData,newData:newData,currentValue:currentValue,newValue:newValue}=updateDataObject(data,path,value,"delete"),result=yield srcDelete({currentData:currentData,newData:newData,currentValue:currentValue,newValue:newValue,name:path.slice(-1)[0],path:path});if(void 0!==result)return setData(currentData),!1===result?translate("ERROR_UPDATE",nodeData):result;setData(newData)})),onAdd:(value,path)=>__awaiter(void 0,void 0,void 0,(function*(){const{currentData:currentData,newData:newData,currentValue:currentValue,newValue:newValue}=updateDataObject(data,path,value,"add"),result=yield srcAdd({currentData:currentData,newData:newData,currentValue:currentValue,newValue:newValue,name:path.slice(-1)[0],path:path});if(void 0!==result)return setData(currentData),!1===result?translate("ERROR_UPDATE",nodeData):result;setData(newData)})),onChange:onChange,onError:onError,showErrorMessages:showErrorMessages,onMove:(sourcePath,destPath,position)=>__awaiter(void 0,void 0,void 0,(function*(){if(null===sourcePath)return;const{currentData:currentData,newData:newData,currentValue:currentValue}=updateDataObject(data,sourcePath,"","delete"),originalKey=sourcePath.slice(-1)[0],targetPath=destPath.slice(0,-1),insertPos=destPath.slice(-1)[0];let targetKey="number"==typeof insertPos?"above"===position?insertPos:insertPos+1:"number"==typeof originalKey?`arr_${originalKey}`:originalKey;sourcePath.slice(0,-1).join(".")===destPath.slice(0,-1).join(".")&&"number"==typeof originalKey&&"number"==typeof targetKey&&originalKey<targetKey&&(targetKey-=1);const insertOptions="number"==typeof targetKey?{insert:!0}:"above"===position?{insertBefore:insertPos}:{insertAfter:insertPos},{newData:addedData,newValue:addedValue}=updateDataObject(newData,[...targetPath,targetKey],currentValue,"add",insertOptions),result=yield srcEdit({currentData:currentData,newData:addedData,currentValue:currentValue,newValue:addedValue,name:destPath.slice(-1)[0],path:destPath});if(void 0!==result)return setData(currentData),!1===result?translate("ERROR_UPDATE",nodeData):result;setData(addedData)})),showCollectionCount:showCollectionCount,collapseFilter:collapseFilter,restrictEditFilter:restrictEditFilter,restrictDeleteFilter:restrictDeleteFilter,restrictAddFilter:restrictAddFilter,restrictTypeSelection:restrictTypeSelection,restrictDragFilter:restrictDragFilter,canDragOnto:!1,searchFilter:searchFilter,searchText:debouncedSearchText,enableClipboard:enableClipboard,keySort:keySort,showArrayIndices:showArrayIndices,showStringQuotes:showStringQuotes,indent:indent,defaultValue:defaultValue,stringTruncate:stringTruncate,translate:translate,customNodeDefinitions:customNodeDefinitions,parentData:null},mainContainerStyles=Object.assign(Object.assign({},getStyles("container",nodeData)),{minWidth:minWidth,maxWidth:maxWidth});return mainContainerStyles.fontSize=null!=rootFontSize?rootFontSize:mainContainerStyles.fontSize,jsxRuntime.jsx("div",{id:id,className:"jer-editor-container "+className,style:mainContainerStyles,children:isCollection(data)?jsxRuntime.jsx(CollectionNode,Object.assign({data:data},otherProps)):jsxRuntime.jsx(ValueNodeWrapper,Object.assign({data:data,showLabel:!0},otherProps))})},updateDataObject=(data,path,newValue,action,insertOptions={})=>{if(0===path.length)return{currentData:data,newData:newValue,currentValue:data,newValue:newValue};const assignOptions=Object.assign({remove:"delete"===action},insertOptions),currentValue="add"!==action?extractProperty(data,path):void 0;return{currentData:data,newData:assign(data,path,newValue,assignOptions),currentValue:currentValue,newValue:"delete"!==action?newValue:void 0}},getFilterFunction=propValue=>"boolean"==typeof propValue?()=>propValue:"number"==typeof propValue?({level:level})=>level>=propValue:propValue,getSearchFilter=searchFilterInput=>{if(void 0!==searchFilterInput)return"value"===searchFilterInput?matchNode:"key"===searchFilterInput?matchNodeKey:"all"===searchFilterInput?(inputData,searchText)=>matchNode(inputData,searchText)||matchNodeKey(inputData,searchText):searchFilterInput},LinkCustomComponent=({value:value,setIsEditing:setIsEditing,getStyles:getStyles,customNodeProps:customNodeProps,nodeData:nodeData})=>{var _a,_b;const stringTruncateLength=null!==(_a=null==customNodeProps?void 0:customNodeProps.stringTruncate)&&void 0!==_a?_a:100,styles=getStyles("string",nodeData);return jsxRuntime.jsx("div",{onDoubleClick:()=>setIsEditing(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&setIsEditing(!0)},className:"jer-value-string jer-hyperlink",style:styles,children:jsxRuntime.jsxs("a",{href:value,target:"_blank",rel:"noreferrer",style:{color:null!==(_b=styles.color)&&void 0!==_b?_b:void 0},children:['"',truncate(value,stringTruncateLength),'"']})})},LinkCustomNodeDefinition={condition:({value:value})=>"string"==typeof value&&/^https?:\/\/.+\..+$/.test(value),element:LinkCustomComponent,showOnView:!0,showOnEdit:!1};exports.assign=assign,exports.extract=extractProperty,exports.IconAdd=IconAdd,exports.IconCancel=IconCancel,exports.IconChevron=IconChevron,exports.IconCopy=IconCopy,exports.IconDelete=IconDelete,exports.IconEdit=IconEdit,exports.IconOk=IconOk,exports.JsonEditor=props=>jsxRuntime.jsx(ThemeProvider,{children:jsxRuntime.jsx(TreeStateProvider,{children:jsxRuntime.jsx(Editor,Object.assign({},props))})}),exports.LinkCustomComponent=LinkCustomComponent,exports.LinkCustomNodeDefinition=LinkCustomNodeDefinition,exports.isCollection=isCollection,exports.matchNode=matchNode,exports.matchNodeKey=matchNodeKey,exports.themes=themes,exports.truncate=truncate;
1
+ "use strict";var e=require("react/jsx-runtime"),n=require("react"),t=require("object-property-assigner"),r=require("object-property-extractor"),o=require("json5");function a(e,n,t,r){return new(t||(t=Promise))((function(o,a){function i(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(i,s)}l((r=r.apply(e,n||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var i=[],s=[];!function(e,n){if(e&&"undefined"!=typeof document){var t,r=!0===n.prepend?"prepend":"append",o=!0===n.singleTag,a="string"==typeof n.container?document.querySelector(n.container):document.getElementsByTagName("head")[0];if(o){var l=i.indexOf(a);-1===l&&(l=i.push(a)-1,s[l]={}),t=s[l]&&s[l][r]?s[l][r]:s[l][r]=c()}else t=c();65279===e.charCodeAt(0)&&(e=e.substring(1)),t.styleSheet?t.styleSheet.cssText+=e:t.appendChild(document.createTextNode(e))}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),n.attributes)for(var t=Object.keys(n.attributes),o=0;o<t.length;o++)e.setAttribute(t[o],n.attributes[t[o]]);var i="prepend"===r?"afterbegin":"beforeend";return a.insertAdjacentElement(i,e),e}}(":root {\n --jer-select-border: #b6b6b6;\n --jer-select-focus: #777;\n --jer-select-arrow: #777;\n --jer-form-border: 1px solid #ededf0;\n --jer-form-border-focus: 1px solid #e2e2e2;\n --jer-expand-transition-time: 0.5s;\n --jer-highlight-color: #b3d8ff;\n}\n\n.jer-visible {\n opacity: 1;\n transition: var(--jer-expand-transition-time);\n}\n\n.jer-hidden {\n opacity: 0;\n transition: var(--jer-expand-transition-time);\n}\n\n/* Select styled as per:\nhttps://moderncss.dev/custom-select-styles-with-pure-css/\n*/\n\n.jer-select select {\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n background-color: transparent;\n border: none;\n padding: 0 1em 0 0;\n margin: 0;\n /* width: 100%; */\n font-family: inherit;\n font-size: 0.8em;\n color: black;\n cursor: inherit;\n line-height: inherit;\n z-index: 1;\n outline: none;\n}\nselect::-ms-expand {\n display: none;\n}\n\n.jer-select {\n display: grid;\n grid-template-areas: 'select';\n align-items: center;\n position: relative;\n min-width: 12ch;\n max-width: 15ch;\n border: 1px solid var(--jer-select-border);\n border-radius: 0.25em;\n padding: 0.25em 0.5em;\n cursor: pointer;\n line-height: 1.1;\n background-color: #fff;\n background-image: linear-gradient(to top, #f9f9f9, #fff 33%);\n}\n.jer-select select,\n.jer-select::after {\n grid-area: select;\n}\n.jer-select:not(.jer-select--multiple)::after {\n content: '';\n justify-self: end;\n width: 0.8em;\n height: 0.5em;\n background-color: var(--jer-select-arrow);\n -webkit-clip-path: polygon(100% 0%, 0 0%, 50% 100%);\n clip-path: polygon(100% 0%, 0 0%, 50% 100%);\n}\n\nselect:focus + .focus {\n position: absolute;\n top: -1px;\n left: -1px;\n right: -1px;\n bottom: -1px;\n border: 1px solid var(--jer-select-focus);\n border-radius: inherit;\n}\n\n.jer-editor-container {\n position: relative;\n font-size: 16px;\n line-height: 1;\n padding: 1em;\n padding-left: 2em;\n /* margin-top: 1em; */\n /* margin-bottom: 1em; */\n border-radius: 0.5em;\n text-align: left;\n}\n\n.jer-editor-container textarea {\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 font-family: inherit;\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.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-bracket-outside {\n} */\n\n/* .jer-collection-item-count {\n} */\n\n.jer-collapse-icon {\n position: absolute;\n left: -1.2em;\n top: 0.35em;\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 align-items: flex-start;\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 font-family: inherit;\n font-size: 0.85em;\n}\n\n.jer-collection-input-button-row {\n display: flex;\n justify-content: flex-end;\n font-size: 150%;\n margin-top: 0.4em;\n}\n\n/* .jer-collection-element {\n} */\n\n.jer-collection-error-row {\n position: absolute;\n bottom: 0.5em;\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 gap: 0;\n}\n\n.jer-value-and-buttons {\n display: flex;\n justify-content: flex-start;\n align-items: center;\n padding-left: 0.5em;\n}\n\n.jer-value-error-row {\n position: absolute;\n}\n\n.jer-value-string {\n line-height: 1.3em;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n\n.jer-hyperlink {\n text-decoration: underline;\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-top: 0.25em;\n padding-bottom: 0.2em;\n min-width: 6em;\n overflow: hidden;\n line-height: 1.2em;\n font-family: inherit;\n font-size: 0.9em;\n}\n\n/* .jer-value-number {\n} */\n\n/* .jer-value-boolean {\n} */\n\n.jer-input-boolean {\n transform: scale(1.5);\n margin-left: 0.3em;\n margin-right: 0.3em;\n}\n\n/* .jer-value-null {\n} */\n\n.jer-value-object {\n}\n\n.jer-key-text {\n word-break: break-word;\n line-height: 1.1em;\n white-space: pre-wrap;\n}\n\n.jer-key-edit {\n padding: 0 0.3em;\n font-size: inherit;\n font-size: 0.9em;\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-number {\n min-width: 3em;\n font-size: 90%;\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 height: 1em;\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-value-and-buttons:hover > .jer-edit-buttons {\n opacity: 1;\n}\n\n/* .jer-input-buttons {\n} */\n\n.jer-copy-pulse {\n position: relative;\n transition: transform var(--jer-expand-transition-time);\n}\n\n.jer-copy-pulse:hover {\n opacity: 0.85;\n transition: 0.3s;\n transform: scale(1.2);\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-accordion-icon {\n /* font-size: '2em'; */\n transition: transform var(--jer-expand-transition-time);\n}\n\n.jer-icon:hover {\n opacity: 0.85;\n transition: 0.3s;\n transform: scale(1.2);\n}\n\n/* For displaying keys that are purely <empty string> \"\" */\n.jer-empty-string::after {\n content: '<empty string>';\n font-style: italic;\n font-size: 90%;\n}\n\n.jer-drag-n-drop-padding {\n height: 0.5em;\n border: 1px dashed #e0e0e0;\n border-radius: 0.3em;\n}\n",{});const l=({className:n,name:t,value:r,setValue:o,handleKeyPress:a,styles:i})=>{if("string"!=typeof r)return null;const s="\n"===r.slice(-1)?r+".":r;return e.jsxs("div",{style:{display:"grid"},children:[e.jsx("textarea",{id:`${t}_textarea`,style:Object.assign({height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap"},i),rows:1,className:n,name:`${t}_textarea`,value:r,onChange:e=>o(e.target.value),autoFocus:!0,onFocus:e=>{r.length<40&&e.target.select()},onKeyDown:a}),e.jsx("span",{className:n,style:Object.assign({visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent"},i),children:s})]})},c={default:{displayName:"Default",fragments:{edit:"rgb(42, 161, 152)"},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},collection:{},collectionInner:{},collectionElement:{},dropZone:{},property:"#292929",bracket:{color:"rgb(0, 43, 54)",fontWeight:"bold"},itemCount:{color:"rgba(0, 0, 0, 0.3)",fontStyle:"italic"},string:"rgb(203, 75, 22)",number:"rgb(38, 139, 210)",boolean:"green",null:{color:"rgb(220, 50, 47)",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"rgb(0, 43, 54)",iconEdit:"edit",iconDelete:"rgb(203, 75, 22)",iconAdd:"edit",iconCopy:"rgb(38, 139, 210)",iconOk:"green",iconCancel:"rgb(203, 75, 22)"}},githubDark:{displayName:"Github Dark",styles:{container:{backgroundColor:"#0d1117",color:"white"},dropZone:"rgba(165, 214, 255, 0.17)",property:"#E6EDF3",bracket:"#56d364",itemCount:"#8B949E",string:"#A5D6FF",number:"#D2A8FF",boolean:{color:"#FF7B72",fontSize:"90%",fontWeight:"bold"},null:"green",iconCollection:"#D2A8FF",iconEdit:"#D2A8FF",iconDelete:"rgb(203, 75, 22)",iconAdd:"rgb(203, 75, 22)",iconCopy:"#A5D6FF",iconOk:"#56d364",iconCancel:"rgb(203, 75, 22)"}},githubLight:{displayName:"Github Light",styles:{container:"white",property:"#1F2328",bracket:"#00802e",itemCount:"#8B949E",string:"#0A3069",number:"#953800",boolean:{color:"#CF222E",fontSize:"90%",fontWeight:"bold"},null:"#FF7B72",iconCollection:"#8250DF",iconEdit:"#8250DF",iconDelete:"rgb(203, 75, 22)",iconAdd:"#8250DF",iconCopy:"#57606A"}},monoDark:{displayName:"Black & White",fragments:{lightText:{color:"white"},midGrey:"#5c5c5c"},styles:{container:["lightText",{backgroundColor:"black"}],dropZone:"#e0e0e029",property:"lightText",bracket:"midGrey",itemCount:"#4a4a4a",string:"#a8a8a8",number:"#666666",boolean:{color:"#848484",fontStyle:"italic"},null:"#333333",iconCollection:"midGrey",iconEdit:"midGrey",iconDelete:"midGrey",iconAdd:"midGrey",iconCopy:"midGrey",iconOk:"midGrey",iconCancel:"midGrey"}},monoLight:{fragments:{midGrey:"#a3a3a3"},displayName:"White & Black",styles:{container:"white",property:"black",bracket:"midGrey",itemCount:"#b5b5b5",string:"#575757",number:"#999999",boolean:{color:"#7b7b7b",fontStyle:"italic"},null:"#cccccc",iconCollection:"midGrey",iconEdit:"midGrey",iconDelete:"midGrey",iconAdd:"midGrey",iconCopy:"midGrey",iconOk:"midGrey",iconCancel:"midGrey"}},candyWrapper:{displayName:"Candy Wrapper",fragments:{minty:{backgroundColor:"#F1FAEE"},pale:{color:"#A8DADC"},mid:{color:"#457B9D"},dark:{color:"#1D3557"},pop:{color:"#E63946"},darkBlue:{color:"#2B2D42"}},styles:{container:"minty",property:"pop",dropZone:"#eb121217",bracket:"dark",itemCount:"pale",string:"mid",number:["darkBlue",{fontSize:"85%"}],boolean:["mid",{fontStyle:"italic",fontWeight:"bold",fontSize:"80%"}],null:["#cccccc",{fontWeight:"bold"}],input:{border:"1px solid rgb(115, 194, 198)"},iconCollection:"#1D3557",iconEdit:"#457B9D",iconDelete:"#E63946",iconAdd:"#2B2D42",iconCopy:"#1D3557",iconCancel:"#E63946"}},psychedelic:{displayName:"Psychedelic",fragments:{minty:{backgroundColor:"#F1FAEE"},pale:{color:"#A8DADC"},mid:{color:"#457B9D"},dark:{color:"#1D3557"},pop:{color:"#E63946"},fluroYellow:"rgb(242, 228, 21)",fluroGreen:"rgb(68, 255, 62)",hotPink:"#f7379a"},styles:{container:{backgroundColor:"unset",background:"linear-gradient(90deg, hsla(333, 100%, 53%, 1) 0%, hsla(33, 94%, 57%, 1) 100%)",color:"black"},dropZone:"fluroYellow",property:"black",bracket:"fluroYellow",itemCount:["pale",{opacity:.7}],string:"white",number:["#33d9ff",{fontSize:"90%",fontWeight:"bold"}],boolean:["fluroGreen",{fontWeight:"bold",fontSize:"80%"}],null:["black",{fontWeight:"bold",opacity:.3,backgroundColor:"rgb(255, 255, 255, 0.5)",padding:"0 0.4em",borderRadius:"0.4em"}],iconCollection:"fluroYellow",iconEdit:["black"],iconDelete:["white",{opacity:.5}],iconAdd:["white",{opacity:.5}],iconCopy:"rgb(32, 84, 242)",iconOk:"fluroGreen",iconCancel:"hotPink"}}},d=c.default,u=n.createContext({getStyles:()=>({}),icons:{}}),p=({theme:n="default",icons:t={},children:r})=>{const o=h(n);return e.jsx(u.Provider,{value:{getStyles:(e,n)=>"function"==typeof o[e]?o[e](n):o[e],icons:t},children:r})},g=()=>n.useContext(u),h=e=>{var n,t,r,o;const a={},i=(Array.isArray(e)?e:[e]).map((n=>"default"===e?{}:"string"==typeof n?m(c[n],a):y(n)?m({fragments:{},styles:n},a):m(n,a))),s=m(d,{});Object.keys(s).forEach((e=>{const n=e;i.forEach((e=>{e[n]&&(s[n]=Object.assign(Object.assign({},s[n]),e[n]))}))}));const l=Object.assign({},s);return Object.entries(a).forEach((([e,n])=>{const t=e;l[t]=e=>{const r=n(e)||{};return Object.assign(Object.assign({},s[t]),r)}})),"function"!=typeof(null==l?void 0:l.inputHighlight)&&(null===(n=null==l?void 0:l.inputHighlight)||void 0===n?void 0:n.backgroundColor)&&document.documentElement.style.setProperty("--jer-highlight-color",null===(t=null==l?void 0:l.inputHighlight)||void 0===t?void 0:t.backgroundColor),"function"!=typeof(null==l?void 0:l.iconCopy)&&(null===(r=null==l?void 0:l.iconCopy)||void 0===r?void 0:r.color)&&document.documentElement.style.setProperty("--jer-icon-copy-color",null===(o=null==l?void 0:l.iconCopy)||void 0===o?void 0:o.color),l},m=(e,n)=>{const{fragments:t,styles:r}=e,o={};return Object.entries(r).forEach((([e,r])=>{const a=(Array.isArray(r)?r:[r]).reduce(((r,o)=>{var a;if("function"==typeof o)return n[e]=o,Object.assign({},r);if("string"==typeof o){const n=null!==(a=null==t?void 0:t[o])&&void 0!==a?a:o;return"string"==typeof n?Object.assign(Object.assign({},r),{[j[e]]:n}):Object.assign(Object.assign({},r),n)}return Object.assign(Object.assign({},r),o)}),{});o[e]=a})),o},y=e=>!("styles"in e),j={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",property:"color",bracket:"color",itemCount:"color",string:"color",number:"color",boolean:"color",null:"color",input:"color",inputHighlight:"backgroundColor",error:"color",iconCollection:"color",iconEdit:"color",iconDelete:"color",iconAdd:"color",iconCopy:"color",iconOk:"color",iconCancel:"color"},b="**INVALID_FUNCTION**",f=(e,n=200)=>"string"==typeof e?e.length<n?e:`${e.slice(0,n-2).trim()}...`:e,v=e=>e.map((e=>""===e?String.fromCharCode(0):e)).join("."),E=({value:n,setValue:t,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:s,stringTruncate:c,showStringQuotes:d,nodeData:u})=>{const{getStyles:p}=g(),h=v(o),m=d?'"':"";return r?e.jsx(l,{className:"jer-input-text",name:h,value:n,setValue:t,isEditing:r,handleKeyPress:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&s():i()},styles:p("input",u)}):e.jsxs("div",{id:`${h}_display`,onDoubleClick:()=>a(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&a(!0)},className:"jer-value-string",style:p("string",u),children:[m,f(n,c),m]})},x=({value:n,setValue:t,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:s,nodeData:l})=>{const{getStyles:c}=g();return r?e.jsx("input",{className:"jer-input-number",type:"text",name:v(o),value:n,onChange:e=>t(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{switch(e.key){case"Enter":i();break;case"Escape":s();break;case"ArrowUp":e.preventDefault(),t(Number(n)+1);break;case"ArrowDown":e.preventDefault(),t(Number(n)-1)}},style:Object.assign({width:String(n).length/1.5+2+"em"},c("input",l))}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:c("number",l),children:n})},D=({value:n,setValue:t,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:s,nodeData:l})=>{const{getStyles:c}=g();return S(r,i,s),r?e.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:v(o),checked:n,onChange:()=>t(!n)}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:c("boolean",l),children:String(n)})},w=({value:n,isEditing:t,setIsEditing:r,handleEdit:o,handleCancel:a,nodeData:i})=>{const{getStyles:s}=g();return S(t,o,a),e.jsx("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:s("null",i),children:String(n)})},k=({value:n,translate:t,isEditing:r,handleEdit:o,handleCancel:a,nodeData:i})=>(S(r,o,a),e.jsx("span",{className:"jer-value-object",children:`{${t("DEFAULT_NEW_KEY",i)}: "${String(n)}" }`})),C=({value:n,isEditing:t,handleEdit:r,handleCancel:o})=>(S(t,r,o),e.jsx("span",{className:"jer-value-array",children:`[${null===n?"":String(n)}]`})),S=(e,t,r)=>{n.useEffect((()=>(e&&document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o))),[e]);const o=e=>{"Enter"===e.key?t():"Escape"===e.key&&r()}},O=({value:n})=>{let t="Error!";switch(typeof n){case"string":n===b&&(t="Function");break;case"undefined":t="Undefined";break;case"symbol":t="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:t})},N=({size:n,style:t,className:r})=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:r,style:t,children:[e.jsx("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),e.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]}),A=({size:n,style:t,className:r})=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:r,style:t,transform:"translate(0, 0.5)",children:[e.jsx("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),e.jsx("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),T=({size:n,style:t,className:r})=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:r,style:t,children:e.jsx("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"})}),F=({size:n,style:t,className:r})=>e.jsxs("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:n,height:n,className:r,style:t,children:[e.jsx("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),e.jsx("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),e.jsx("path",{d:"M15 10l-4 4 4 4"})]}),V=({size:n,style:t,className:r})=>e.jsxs("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:n,height:n,className:r,style:t,children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),e.jsx("path",{d:"M22 4L12 14.01l-3-3"})]}),R=({size:n,style:t,className:r})=>e.jsx("svg",{baseProfile:"tiny",viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:r,style:t,children:e.jsx("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"})}),M=({size:n,style:t,className:r})=>e.jsx("svg",{viewBox:"0 0 512 512",fill:"currentColor",width:n,height:n,className:r,style:t,children:e.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"})}),z=({name:n,nodeData:t,rotate:r})=>{var o,a,i,s,l,c,d;const{getStyles:u,icons:p}=g(),h={size:"1.4em",className:"jer-icon"};switch(n){case"add":return null!==(o=null==p?void 0:p.add)&&void 0!==o?o:e.jsx(N,Object.assign({},h,{style:u("iconAdd",t)}));case"edit":return null!==(a=null==p?void 0:p.edit)&&void 0!==a?a:e.jsx(A,Object.assign({},h,{style:u("iconEdit",t)}));case"delete":return null!==(i=null==p?void 0:p.delete)&&void 0!==i?i:e.jsx(T,Object.assign({},h,{style:u("iconDelete",t),size:"1.45em"}));case"copy":return null!==(s=null==p?void 0:p.copy)&&void 0!==s?s:e.jsx(F,Object.assign({},h,{style:u("iconCopy",t),size:"1.2em"}));case"ok":return null!==(l=null==p?void 0:p.ok)&&void 0!==l?l:e.jsx(V,Object.assign({},h,{style:Object.assign({fontSize:"90%"},u("iconOk",t))}));case"cancel":return null!==(c=null==p?void 0:p.cancel)&&void 0!==c?c:e.jsx(R,Object.assign({},h,{style:Object.assign({fontSize:"130%"},u("iconCancel",t))}));case"chevron":return null!==(d=null==p?void 0:p.chevron)&&void 0!==d?d:e.jsx(M,{className:"jer-accordion-icon"+(r?" jer-rotate-90":""),size:"1em",style:u("iconCollection",t)});default:return e.jsx(e.Fragment,{})}},P=({startEdit:t,handleDelete:r,handleAdd:o,enableClipboard:a,type:i,nodeData:s,translate:l})=>{const{getStyles:c}=g(),d=l("KEY_NEW",s),[u,p]=n.useState(!1),[h,m]=n.useState(d),{key:y,path:j,value:b}=s;return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:u?1:void 0},children:[a&&e.jsx("div",{onClick:e=>{let n,t="value",r="";if(a){if(!0===(e.ctrlKey||e.metaKey))n=I(j),r=n,t="path";else n=b,r=i?JSON.stringify(b,null,2):String(n);navigator.clipboard.writeText(r)}"function"==typeof a&&a({value:n,stringValue:r,path:j,key:y,type:t})},className:"jer-copy-pulse",children:e.jsx(z,{name:"copy",nodeData:s})}),t&&e.jsx("div",{onClick:t,children:e.jsx(z,{name:"edit",nodeData:s})}),r&&e.jsx("div",{onClick:r,children:e.jsx(z,{name:"delete",nodeData:s})}),o&&e.jsx("div",{onClick:()=>{"object"===i?p(!0):o("")},children:e.jsx(z,{name:"add",nodeData:s})}),u&&o&&"object"===i&&e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:h,onChange:e=>m(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key&&o?(p(!1),o(h),m(d)):"Escape"===e.key&&(p(!1),m(d))},style:c("input",s)}),e.jsx(_,{onOk:()=>{h&&(p(!1),o(h))},onCancel:()=>{p(!1)},nodeData:s})]})]})},_=({onOk:n,onCancel:t,nodeData:r})=>e.jsxs("div",{className:"jer-confirm-buttons",children:[e.jsx("div",{onClick:n,children:e.jsx(z,{name:"ok",nodeData:r})}),e.jsx("div",{onClick:t,children:e.jsx(z,{name:"cancel",nodeData:r})})]}),I=e=>e.reduce(((e,n)=>"number"==typeof n?`${e}[${n}]`:""===e?n:`${e}.${n}`),""),L=["string","number","boolean","null","object","array"],K=(e=[],n)=>{const t=e.filter((({condition:e})=>e(n)));if(0===t.length)return{};const r=t[0],{element:o,wrapperElement:a,customNodeProps:i,wrapperProps:s,hideKey:l=!1,showEditTools:c=!0,showOnEdit:d=!1,showOnView:u=!0,showCollectionWrapper:p=!0}=r,g=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(t[r[o]]=e[r[o]])}return t}(r,["element","wrapperElement","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:o,CustomWrapper:a,customNodeProps:i,wrapperProps:s,hideKey:l,showEditTools:c,showOnEdit:d,showOnView:u,showCollectionWrapper:p},g)},W=e=>null!==e&&"object"==typeof e,B=(e,n,t,r="")=>{if(!t&&!r)return!0;switch(e){case"collection":if(t){if(t(n,r))return!0;if(!G(r,n,t))return!1}if(!t&&r&&!G(r,n))return!1;break;case"value":if(t&&!t(n,r))return!1;if(!t&&r&&!U(n,r))return!1}return!0},G=(e="",n,t=U)=>{const r=n.value;return Object.entries(r).some((([o,a])=>{const i=[...n.path,o],s=Object.assign(Object.assign({},n),{key:o,path:i,level:n.level+1,value:a,size:i.length,parentData:r});return W(a)?G(e,s,t):t(s,e)}))},U=(e,n="")=>{const{value:t}=e;if(null===t&&"null".includes(n.toLowerCase()))return!0;switch(typeof t){case"string":return t.toLowerCase().includes(n.toLowerCase());case"number":return!!String(t).includes(n);case"boolean":return t?"true".includes(n.toLowerCase())||"1"===n:"false".includes(n.toLowerCase())||"0"===n;default:return!1}},Y=({key:e,path:n},t="")=>!!U({value:e},t)||!!n.some((e=>U({value:e},t))),$=n.createContext({collapseState:null,setCollapseState:()=>{},doesPathMatch:()=>!1,currentlyEditingElement:null,setCurrentlyEditingElement:()=>{},areChildrenBeingEdited:()=>!1,dragSource:{path:null,pathString:null},setDragSource:()=>{}}),H=({children:t})=>{const[r,o]=n.useState(null),[a,i]=n.useState(null),[s,l]=n.useState({path:null,pathString:null});return e.jsx($.Provider,{value:{collapseState:r,setCollapseState:e=>{o(e),null!==e&&setTimeout((()=>o(null)),2e3)},doesPathMatch:e=>{if(null===r)return!1;for(const[n,t]of r.path.entries())if(t!==e[n])return!1;return!0},currentlyEditingElement:a,setCurrentlyEditingElement:i,areChildrenBeingEdited:e=>null!==a&&a.includes(e),dragSource:s,setDragSource:l},children:t})},J=()=>n.useContext($),X=({props:e,collapsed:t})=>{const{data:r,nodeData:o,parentData:a,onEdit:i,onError:s,showErrorMessages:l,restrictEditFilter:c,restrictDeleteFilter:d,restrictAddFilter:u,restrictDragFilter:p,translate:g}=e,{currentlyEditingElement:h,setCurrentlyEditingElement:m}=J(),[y,j]=n.useState(null),b=Object.assign(Object.assign({},o),{collapsed:t}),{path:f,key:E,size:x}=b,D=v(f),w=n.useMemo((()=>!c(b)),[b]),k=n.useMemo((()=>!d(b)),[b]),C=n.useMemo((()=>!u(b)),[b]),S=n.useMemo((()=>!p(b)&&k&&null===h),[b]),O=e=>{l&&(j(e),setTimeout((()=>j(null)),2500)),console.warn("Error",e)},N=n.useMemo((()=>(e,n)=>{O(e.message),s&&s({currentData:b.fullData,errorValue:n,currentValue:r,name:E,path:f,error:e})}),[s,l]),A=h===D,T=h===`key_${D}`,F="number"==typeof f.slice(-1)[0];return{pathString:D,nodeData:b,path:f,name:E,size:x,canEdit:w,canDelete:k,canAdd:C,canDrag:S,error:y,showError:O,onError:N,setError:j,handleEditKey:e=>{if(m(null),E===e)return;if(!a)return;const n=f.slice(0,-1);if(Object.keys(a).includes(e))return void N({code:"KEY_EXISTS",message:g("ERROR_KEY_EXISTS",b)},e);const t=Object.fromEntries(Object.entries(a).map((([n,t])=>n===E?[e,t]:[n,t])));i(t,n).then((n=>{n&&N({code:"UPDATE_ERROR",message:n},e)}))},derivedValues:{isEditing:A,isEditingKey:T,isArray:F,canEditKey:null!==a&&w&&C&&k&&!F}}},Z=({canDrag:t,canDragOnto:r,path:o,nodeData:a,onMove:i,onError:s,translate:l})=>{const{getStyles:c}=g(),{dragSource:d,setDragSource:u}=J(),[p,h]=n.useState(!1),m=v(o),y=n.useMemo((()=>t?{onDragStart:e=>{e.stopPropagation(),u({path:o,pathString:m})},onDragEnd:e=>{e.stopPropagation(),u({path:null,pathString:null})}}:{}),[t]),j=n.useMemo((()=>e=>r?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:n=>{n.stopPropagation(),f(e),u({path:null,pathString:null}),h(!1)},onDragEnter:n=>{var t;n.stopPropagation(),m.startsWith(null!==(t=d.pathString)&&void 0!==t?t:"")||h(e)},onDragExit:e=>{e.stopPropagation(),h(!1)}}:{}),[d,r]),b=n.useMemo((()=>r&&null!==d.pathString?e.jsx("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:o.length}},j("below"))):null),[d,r]),f=e=>{var n,t;const r=null===(n=d.path)||void 0===n?void 0:n.slice(-1)[0],c=null===(t=d.path)||void 0===t?void 0:t.slice(0,-1).join("."),u=o.slice(0,-1).join(""),{parentData:p}=a;"string"==typeof r&&p&&!Array.isArray(p)&&Object.keys(p).includes(r)&&r in p&&c!==u?s({code:"KEY_EXISTS",message:l("ERROR_KEY_EXISTS",a)},r):i(d.path,o,e).then((e=>{e&&s({code:"UPDATE_ERROR",message:e},a.value)}))};return{dragSourceProps:y,getDropTargetProps:j,BottomDropTarget:b,DropTargetPadding:({position:n,nodeData:t})=>p===n?e.jsx("div",{className:"jer-drag-n-drop-padding",style:c("dropZone",t)}):null,handleDrop:f}},q=t=>{const{data:r,parentData:o,onEdit:a,onDelete:i,onChange:s,onMove:l,enableClipboard:c,canDragOnto:d,restrictTypeSelection:u,searchFilter:p,searchText:h,showLabel:m,stringTruncate:y,showStringQuotes:j,indent:f,translate:v,customNodeDefinitions:E}=t,{getStyles:x}=g(),{setCurrentlyEditingElement:D}=J(),[w,k]=n.useState("function"==typeof r?b:r),{pathString:C,nodeData:S,path:O,name:N,canEdit:A,canDelete:T,canDrag:F,error:V,onError:R,handleEditKey:M,derivedValues:z}=X({props:t}),{dragSourceProps:I,getDropTargetProps:W,BottomDropTarget:G,DropTargetPadding:U}=Z({canDrag:F,canDragOnto:d,path:O,nodeData:S,onMove:l,onError:R,translate:v}),Y=K(E,S),[$,H]=n.useState(Q(r,Y)),q=n.useCallback((e=>{if(!s)return void k(e);const n=s({currentData:S.fullData,newValue:e,currentValue:w,name:N,path:O});k(n)}),[s]);n.useEffect((()=>{k("function"==typeof r?b:r),H(Q(r,Y))}),[r,V]);const{CustomNode:te,customNodeProps:re,hideKey:oe,showEditTools:ae=!0,showOnEdit:ie,showOnView:se}=Y,le=[...L,...E.filter((({showInTypesSelector:e=!1,name:n})=>e&&!!n)).map((({name:e})=>e))],ce=n.useMemo((()=>{if("boolean"==typeof u)return u?[]:le;if(Array.isArray(u))return u;const e=u(S);return"boolean"==typeof e?e?[]:le:e}),[S,u]);if(!B("value",S,p,h))return null;const de=()=>{let e;switch(D(null),$){case"object":e={[v("DEFAULT_NEW_KEY",S)]:w};break;case"array":e=null!=w?w:[];break;case"number":{const n=Number(w);e=isNaN(n)?0:n;break}default:e=w}a(e,O).then((n=>{n&&R({code:"UPDATE_ERROR",message:n},e)}))},ue=()=>{D(null),k(r),H(Q(r,Y))},{isEditing:pe,isEditingKey:ge,canEditKey:he}=z,me=!pe&&V,ye=pe&&ce.length>0,je="invalid"!==$&&!V&&ae,be=m&&ge,fe=m&&!ge&&!oe,ve={value:w,parentData:o,setValue:q,isEditing:pe,setIsEditing:A?()=>D(C):()=>{},handleEdit:de,handleCancel:ue,path:O,stringTruncate:y,showStringQuotes:j,nodeData:S,translate:v},Ee=te&&(pe&&ie||!pe&&se)?e.jsx(te,Object.assign({},t,{value:w,customNodeProps:re,setValue:q,handleEdit:de,handleCancel:ue,handleKeyPress:e=>{"Enter"===e.key?de():"Escape"===e.key&&ue()},isEditing:pe,setIsEditing:()=>D(C),getStyles:x})):ee(Q(r),ve);return e.jsxs("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:f/2+"em",position:"relative"},draggable:F},I,W("above"),{children:[G,e.jsx(U,{position:"above",nodeData:S}),e.jsxs("div",{className:"jer-value-main-row",style:{flexWrap:N.length>10?"wrap":"nowrap"},children:[fe&&e.jsxs("span",{className:"jer-key-text",style:Object.assign(Object.assign({},x("property",S)),{minWidth:`${Math.min(String(N).length+1,5)}ch`,flexShrink:N.length>10?1:0}),onDoubleClick:()=>he&&D(`key_${C}`),children:[""===N?e.jsx("span",{className:"jer-empty-string"}):N,":"]}),be&&e.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:C,defaultValue:N,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?M(e.target.value):"Escape"===e.key&&ue()},style:{width:String(N).length/1.5+.5+"em"}}),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:Ee}),pe?e.jsx(_,{onOk:de,onCancel:ue,nodeData:S}):je&&e.jsx(P,{startEdit:A?()=>D(C):void 0,handleDelete:T?()=>{i(w,O).then((e=>{e&&R({code:"DELETE_ERROR",message:e},w)}))}:void 0,enableClipboard:c,translate:v,nodeData:S}),ye&&e.jsxs("div",{className:"jer-select",children:[e.jsx("select",{name:`${N}-type-select`,className:"jer-type-select",onChange:e=>(e=>{const n=E.find((n=>n.name===e));if(n)a(n.defaultValue,O),H(e);else{const n=ne(w,e,v("DEFAULT_NEW_KEY",S),(null==Y?void 0:Y.CustomNode)?v("DEFAULT_STRING",S):void 0);q(n),a(n,O).then((e=>{e&&(R({code:"UPDATE_ERROR",message:e},n),D(null))}))}})(e.target.value),value:$,children:ce.map((n=>e.jsx("option",{value:n,children:n},n)))}),e.jsx("span",{className:"focus"})]}),me&&e.jsx("span",{className:"jer-error-slug",style:x("error",S),children:V})]})]}),e.jsx(U,{position:"below",nodeData:S})]}))},Q=(e,n)=>(null==n?void 0:n.CustomNode)&&(null==n?void 0:n.name)&&n.showInTypesSelector?n.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",ee=(n,t)=>{const r=t.value;switch(n){case"string":return e.jsx(E,Object.assign({},t,{value:r}));case"number":return e.jsx(x,Object.assign({},t,{value:r}));case"boolean":return e.jsx(D,Object.assign({},t,{value:r}));case"null":return e.jsx(w,Object.assign({},t));case"object":return e.jsx(k,Object.assign({},t,{value:r}));case"array":return e.jsx(C,Object.assign({},t));default:return e.jsx(O,Object.assign({},t))}},ne=(e,n,t,r)=>{switch(n){case"string":return null!=r?r:String(e);case"number":{const n=Number(e);return isNaN(n)?0:n}case"boolean":return!!e;case"null":return null;case"object":return{[t]:e};case"array":return[e];default:return String(e)}},te=t=>{const{getStyles:i}=g(),{collapseState:s,setCollapseState:c,doesPathMatch:d,currentlyEditingElement:u,setCurrentlyEditingElement:p,areChildrenBeingEdited:h}=J(),{data:m,nodeData:y,parentData:j,showCollectionCount:b,onEdit:f,onAdd:v,onDelete:E,canDragOnto:x,collapseFilter:D,onMove:w,enableClipboard:k,searchFilter:C,searchText:S,indent:O,keySort:N,showArrayIndices:A,defaultValue:T,translate:F,customNodeDefinitions:V}=t,[R,M]=n.useState(JSON.stringify(m,null,2)),I=D(y),[L,G]=n.useState(I),{pathString:U,nodeData:Y,path:$,name:H,size:Q,canEdit:ee,canDelete:ne,canAdd:re,canDrag:oe,error:ae,setError:ie,onError:se,handleEditKey:le,derivedValues:ce}=X({props:t,collapsed:L}),{dragSourceProps:de,getDropTargetProps:ue,BottomDropTarget:pe,DropTargetPadding:ge}=Z({canDrag:oe,canDragOnto:x,path:$,nodeData:Y,onMove:w,onError:se,translate:F}),he=n.useRef(!I),[me,ye]=n.useState(!1);n.useEffect((()=>{M(JSON.stringify(m,null,2))}),[m]),n.useEffect((()=>{const e=D(Y)&&!ce.isEditing;he.current=!e,G(e)}),[D]),n.useEffect((()=>{null!==s&&d($)&&(he.current=!0,G(s.collapsed))}),[s]);const je=n.useMemo((()=>e=>"function"!=typeof T?T:T(e)),[T]),{CustomNode:be,customNodeProps:fe,CustomWrapper:ve,wrapperProps:Ee={},hideKey:xe,showEditTools:De=!0,showOnEdit:we,showOnView:ke,showCollectionWrapper:Ce=!0}=n.useMemo((()=>K(V,Y)),[]);if(!B("collection",Y,C,S)&&Y.level>0)return null;const Se=Array.isArray(m)?"array":"object",Oe="array"===Se?{open:"[",close:"]"}:{open:"{",close:"}"},Ne=getComputedStyle(document.documentElement).getPropertyValue("--jer-expand-transition-time"),Ae=e=>{"Enter"===e.key&&(e.metaKey||e.shiftKey||e.ctrlKey)?Te():"Escape"===e.key&&Ve()},Te=()=>{try{const e=o.parse(R);if(p(null),ie(null),JSON.stringify(e)===JSON.stringify(m))return;f(e,$).then((n=>{n&&se({code:"UPDATE_ERROR",message:n},e)}))}catch(e){se({code:"INVALID_JSON",message:F("ERROR_INVALID_JSON",Y)},R)}},Fe=$.length>0?()=>{E(m,$).then((e=>{e&&se({code:"DELETE_ERROR",message:e},r(m,$))}))}:void 0,Ve=()=>{p(null),ie(null),M(JSON.stringify(m,null,2))},{isEditing:Re,isEditingKey:Me,isArray:ze,canEditKey:Pe}=ce,_e="when-closed"===b?L:b,Ie=!Re&&De,Le=(A||!ze)&&!xe&&void 0!==H,Ke=be&&(Re&&we||!Re&&ke),We=N&&"object"===Se,Be=Object.entries(m).map((([e,n])=>["array"===Se?Number(e):e,n]));We&&Be.sort("function"==typeof N?(e,n)=>N(e[0],n[0]):void 0);const Ge=JSON.stringify(m,null,2).replace(/\\n/g,"\n").split("\n").length,Ue=he.current?Re?e.jsx("div",{className:"jer-collection-text-edit",children:e.jsxs("div",{children:[e.jsx(l,{className:"jer-collection-text-area",name:U,value:R,setValue:M,isEditing:Re,handleKeyPress:Ae,styles:i("input",Y)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(_,{onOk:Te,onCancel:Ve,nodeData:Y})})]})}):Be.map((([n,r],o)=>{const a={key:n,value:r,path:[...$,n],level:$.length+1,index:o,size:W(r)?Object.keys(r).length:1,parentData:m,fullData:Y.fullData};return e.jsx("div",{className:"jer-collection-element",style:i("collectionElement",a),children:W(r)?e.jsx(te,Object.assign({},t,{data:r,parentData:m,nodeData:a,showCollectionCount:b,canDragOnto:ee}),n):e.jsx(q,Object.assign({},t,{data:r,parentData:m,nodeData:a,canDragOnto:ee,showLabel:"object"===Se||A}),n)},n)})):null,Ye=!!Ce&&L;Ye||(he.current=!0);const $e=Object.assign(Object.assign({},t),{data:m,value:m,parentData:j,nodeData:Y,setValue:e=>a(void 0,void 0,void 0,(function*(){return yield f(e,$)})),handleEdit:Te,handleCancel:Ve,handleKeyPress:Ae,isEditing:Re,setIsEditing:()=>p(U),getStyles:i,canDragOnto:ee}),He=Ke?e.jsx(be,Object.assign({customNodeProps:fe},$e,{children:Ue})):Ue,Je=Me?e.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:U,defaultValue:H,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?le(e.target.value):"Escape"===e.key&&Ve()},style:{width:String(H).length/1.5+.5+"em"}}):Le&&e.jsx("span",{className:"jer-key-text",style:i("property",Y),onDoubleClick:()=>Pe&&p(`key_${U}`),children:""===H?e.jsx("span",{className:$.length>0?"jer-empty-string":void 0}):`${H}:`}),Xe=Ie&&e.jsx(P,{startEdit:ee?()=>{he.current=!0,p(U),G(!1)}:void 0,handleAdd:re?e=>{G(!1);const n=je(Y);"array"===Se?v(n,[...$,m.length]).then((e=>{e&&se({code:"ADD_ERROR",message:e},n)})):e in m?se({code:"KEY_EXISTS",message:F("ERROR_KEY_EXISTS",Y)},e):v(n,[...$,e]).then((e=>{e&&se({code:"ADD_ERROR",message:e},n)}))}:void 0,handleDelete:ne?Fe:void 0,enableClipboard:k,type:Se,nodeData:Y,translate:F}),Ze=e.jsxs("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===$.length?0:O/2)+"em"},i("collection",Y)),{position:"relative"}),draggable:oe},de,ue("above"),{children:[!Re&&pe,e.jsx(ge,{position:"above",nodeData:Y}),Ce?e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("div",{className:"jer-collapse-icon",onClick:e=>(e=>{if(e.getModifierState("Alt"))return he.current=!0,void c({collapsed:!L,path:$});u&&u.includes(U)||(ye(!0),he.current=!0,G(!L),c(null),setTimeout((()=>ye(!1)),500))})(e),children:e.jsx(z,{name:"chevron",rotate:L,nodeData:Y})}),Je,!Re&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:i("bracket",Y),children:Oe.open})]}),!Re&&_e&&e.jsx("div",{className:"jer-collection-item-count"+(_e?" jer-visible":" jer-hidden"),style:i("itemCount",Y),children:1===Q?F("ITEM_SINGLE",Object.assign(Object.assign({},Y),{size:1}),1):F("ITEMS_MULTIPLE",Y,Q)}),e.jsx("div",{className:"jer-brackets"+(Ye?" jer-visible":" jer-hidden"),style:i("bracket",Y),children:Oe.close}),Xe]}):xe?e.jsx(e.Fragment,{}):e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[Je,Xe]}),e.jsxs("div",{className:"jer-collection-inner",style:Object.assign({maxHeight:Ye?0:h(U)?void 0:3*Ge+"em",overflowY:Ye||me?"hidden":"visible",transition:`max-height ${Ne}`},i("collectionInner",Y)),children:[He,e.jsx("div",{className:Re?"jer-collection-error-row":"jer-collection-error-row-edit",children:ae&&e.jsx("span",{className:"jer-error-slug",style:i("error",Y),children:ae})}),!Re&&Ce&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:i("bracket",Y),children:Oe.close})]}),e.jsx(ge,{position:"below",nodeData:Y})]}));return ve?e.jsx(ve,Object.assign({customNodeProps:Ee},$e,{children:Ze})):Ze},re={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",KEY_NEW:"Enter new key",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",DEFAULT_STRING:"New data!",DEFAULT_NEW_KEY:"key"},oe=(e,n)=>(t,r,o)=>((e,n,t,r,o)=>{if(n[r]){const e=n[r](t);if(null!==e)return e}const a=r in e?e[r]:re[r];return void 0===o?a:null==a?void 0:a.replace("{{count}}",String(o))})(e,n,r,t,o),ae=({data:t,setData:r,rootName:o="root",onUpdate:i=(()=>{}),onEdit:s=i,onDelete:l=i,onAdd:c=i,onChange:d,onError:u,showErrorMessages:p=!0,enableClipboard:h=!0,indent:m=3,collapse:y=!1,showCollectionCount:j=!0,restrictEdit:b=!1,restrictDelete:f=!1,restrictAdd:v=!1,restrictTypeSelection:E=!1,restrictDrag:x=!0,searchFilter:D,searchText:w,searchDebounceTime:k=350,keySort:C=!1,showArrayIndices:S=!0,showStringQuotes:O=!0,defaultValue:N=null,minWidth:A=250,maxWidth:T="min(600px, 90vw)",rootFontSize:F,stringTruncate:V=250,translations:R={},className:M,id:z,customText:P={},customNodeDefinitions:_=[]})=>{const{getStyles:I}=g(),L=n.useCallback(se(y),[y]),K=n.useCallback(oe(R,P),[R,P]),[B,G]=n.useState(w),[U,Y]=(({setData:e,data:t})=>{const[r,o]=n.useState(e?void 0:t),a=n.useCallback((n=>{e?e(n):o(n)}),[e]);return n.useEffect((()=>{e||o(t)}),[t]),[e?t:r,a]})({setData:r,data:t});n.useEffect((()=>{const e=setTimeout((()=>G(w)),k);return()=>clearTimeout(e)}),[w,k]);const $={key:o,path:[],level:0,index:0,value:U,size:"object"==typeof U&&null!==U?Object.keys(U).length:1,parentData:null,fullData:U},H=(e,n)=>a(void 0,void 0,void 0,(function*(){const t=yield e(n);if(void 0===t)return void Y(n.newData);const r=ce(t)?t:["error",t],[o,a]=r;if("error"===o)return Y(n.currentData),!1===a?K("ERROR_UPDATE",$):String(a);Y(a)})),J=n.useMemo((()=>se(b)),[b]),X=n.useMemo((()=>se(f)),[f]),Z=n.useMemo((()=>se(v)),[v]),Q=n.useMemo((()=>se(x)),[x]),ee=n.useMemo((()=>le(D)),[D]),ne={name:o,nodeData:$,onEdit:(e,n)=>a(void 0,void 0,void 0,(function*(){const{currentData:t,newData:r,currentValue:o,newValue:a}=ie(U,n,e,"update");if(o!==a)return yield H(s,{currentData:t,newData:r,currentValue:o,newValue:a,name:n.slice(-1)[0],path:n})})),onDelete:(e,n)=>a(void 0,void 0,void 0,(function*(){const{currentData:t,newData:r,currentValue:o,newValue:a}=ie(U,n,e,"delete");return yield H(l,{currentData:t,newData:r,currentValue:o,newValue:a,name:n.slice(-1)[0],path:n})})),onAdd:(e,n)=>a(void 0,void 0,void 0,(function*(){const{currentData:t,newData:r,currentValue:o,newValue:a}=ie(U,n,e,"add");return yield H(c,{currentData:t,newData:r,currentValue:o,newValue:a,name:n.slice(-1)[0],path:n})})),onChange:d,onError:u,showErrorMessages:p,onMove:(e,n,t)=>a(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:a}=ie(U,e,"","delete"),i=e.slice(-1)[0],l=n.slice(0,-1),c=n.slice(-1)[0];let d="number"==typeof c?"above"===t?c:c+1:"number"==typeof i?`arr_${i}`:i;e.slice(0,-1).join(".")===n.slice(0,-1).join(".")&&"number"==typeof i&&"number"==typeof d&&i<d&&(d-=1);const u="number"==typeof d?{insert:!0}:"above"===t?{insertBefore:c}:{insertAfter:c},{newData:p,newValue:g}=ie(o,[...l,d],a,"add",u);return yield H(s,{currentData:r,newData:p,currentValue:a,newValue:g,name:n.slice(-1)[0],path:n})})),showCollectionCount:j,collapseFilter:L,restrictEditFilter:J,restrictDeleteFilter:X,restrictAddFilter:Z,restrictTypeSelection:E,restrictDragFilter:Q,canDragOnto:!1,searchFilter:ee,searchText:B,enableClipboard:h,keySort:C,showArrayIndices:S,showStringQuotes:O,indent:m,defaultValue:N,stringTruncate:V,translate:K,customNodeDefinitions:_,parentData:null},re=Object.assign(Object.assign({},I("container",$)),{minWidth:A,maxWidth:T});return re.fontSize=null!=F?F:re.fontSize,e.jsx("div",{id:z,className:"jer-editor-container "+M,style:re,children:W(U)?e.jsx(te,Object.assign({data:U},ne)):e.jsx(q,Object.assign({data:U,showLabel:!0},ne))})},ie=(e,n,o,a,i={})=>{if(0===n.length)return{currentData:e,newData:o,currentValue:e,newValue:o};const s=Object.assign({remove:"delete"===a},i),l="add"!==a?r(e,n):void 0;return{currentData:e,newData:t(e,n,o,s),currentValue:l,newValue:"delete"!==a?o:void 0}},se=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:n})=>n>=e:e,le=e=>{if(void 0!==e)return"value"===e?U:"key"===e?Y:"all"===e?(e,n)=>U(e,n)||Y(e,n):e},ce=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),de=({value:n,setIsEditing:t,getStyles:r,customNodeProps:o,nodeData:a})=>{var i,s;const l=null!==(i=null==o?void 0:o.stringTruncate)&&void 0!==i?i:100,c=r("string",a);return e.jsx("div",{onDoubleClick:()=>t(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&t(!0)},className:"jer-value-string jer-hyperlink",style:c,children:e.jsxs("a",{href:n,target:"_blank",rel:"noreferrer",style:{color:null!==(s=c.color)&&void 0!==s?s:void 0},children:['"',f(n,l),'"']})})},ue={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:de,showOnView:!0,showOnEdit:!1};exports.assign=t,exports.extract=r,exports.IconAdd=N,exports.IconCancel=R,exports.IconChevron=M,exports.IconCopy=F,exports.IconDelete=T,exports.IconEdit=A,exports.IconOk=V,exports.JsonEditor=n=>e.jsx(p,{theme:n.theme,icons:n.icons,children:e.jsx(H,{children:e.jsx(ae,Object.assign({},n))})}),exports.LinkCustomComponent=de,exports.LinkCustomNodeDefinition=ue,exports.isCollection=W,exports.matchNode=U,exports.matchNodeKey=Y,exports.themes=c,exports.truncate=f;
package/build/index.d.ts CHANGED
@@ -18,8 +18,10 @@ declare const localisedStrings: {
18
18
  type LocalisedStrings = typeof localisedStrings;
19
19
  type TranslateFunction = (key: keyof LocalisedStrings, customData: NodeData, count?: number) => string;
20
20
 
21
+ type JsonData = CollectionData | ValueData;
21
22
  interface JsonEditorProps {
22
- data: object;
23
+ data: JsonData;
24
+ setData?: (data: JsonData) => void;
23
25
  rootName?: string;
24
26
  onUpdate?: UpdateFunction;
25
27
  onEdit?: UpdateFunction;
@@ -71,16 +73,17 @@ interface IconReplacements {
71
73
  chevron?: JSX.Element;
72
74
  }
73
75
  interface UpdateFunctionProps {
74
- newData: object;
75
- currentData: object;
76
+ newData: JsonData;
77
+ currentData: JsonData;
76
78
  newValue: unknown;
77
79
  currentValue: unknown;
78
80
  name: CollectionKey;
79
81
  path: CollectionKey[];
80
82
  }
81
- type UpdateFunction = (props: UpdateFunctionProps) => void | ErrorString | false | Promise<false | ErrorString | void>;
83
+ type UpdateFunctionReturn = ['error' | 'value', JsonData];
84
+ type UpdateFunction = (props: UpdateFunctionProps) => void | ErrorString | false | UpdateFunctionReturn | Promise<false | ErrorString | void | UpdateFunctionReturn>;
82
85
  type OnChangeFunction = (props: {
83
- currentData: object;
86
+ currentData: JsonData;
84
87
  newValue: ValueData;
85
88
  currentValue: ValueData;
86
89
  name: CollectionKey;
@@ -91,9 +94,9 @@ interface JerError {
91
94
  message: ErrorString;
92
95
  }
93
96
  type OnErrorFunction = (props: {
94
- currentData: object;
95
- errorValue: ValueData | CollectionData;
96
- currentValue: ValueData | CollectionData;
97
+ currentData: JsonData;
98
+ errorValue: JsonData;
99
+ currentValue: JsonData;
97
100
  name: CollectionKey;
98
101
  path: CollectionKey[];
99
102
  error: JerError;
@@ -122,7 +125,7 @@ interface NodeData {
122
125
  value: unknown;
123
126
  size: number | null;
124
127
  parentData: object | null;
125
- fullData: object;
128
+ fullData: JsonData;
126
129
  collapsed?: boolean;
127
130
  }
128
131
  interface BaseNodeProps {
@@ -166,7 +169,7 @@ interface ValueNodeProps extends BaseNodeProps {
166
169
  onChange?: OnChangeFunction;
167
170
  }
168
171
  interface CustomNodeProps<T = Record<string, unknown>> extends BaseNodeProps {
169
- value: ValueData | CollectionData;
172
+ value: JsonData;
170
173
  customNodeProps?: T;
171
174
  parentData: CollectionData | null;
172
175
  setValue: (value: ValueData) => void;
@@ -234,8 +237,8 @@ declare const LinkCustomNodeDefinition: CustomNodeDefinition;
234
237
 
235
238
  declare const truncate: (string: string, length?: number) => string;
236
239
 
237
- declare const isCollection: (value: unknown) => value is Record<string, unknown> | unknown[];
240
+ declare const isCollection: (value: unknown) => value is unknown[] | Record<string, unknown>;
238
241
  declare const matchNode: (input: Partial<NodeData>, searchText: string) => boolean;
239
242
  declare const matchNodeKey: SearchFilterFunction;
240
243
 
241
- export { CollectionNodeProps, CompareFunction, CopyFunction, CustomNodeDefinition, CustomNodeProps, CustomTextDefinitions, FilterFunction, IconAdd, IconCancel, IconChevron, IconCopy, IconDelete, IconEdit, IconOk, IconReplacements, JerError, JsonEditor, JsonEditorProps, LinkCustomComponent, LinkCustomNodeDefinition, LocalisedStrings, NodeData, OnChangeFunction, OnErrorFunction, SearchFilterFunction, Theme, ThemeInput, ThemeName, TranslateFunction, UpdateFunction, ValueNodeProps, isCollection, matchNode, matchNodeKey, themes, truncate };
244
+ export { CollectionNodeProps, CompareFunction, CopyFunction, CustomNodeDefinition, CustomNodeProps, CustomTextDefinitions, FilterFunction, IconAdd, IconCancel, IconChevron, IconCopy, IconDelete, IconEdit, IconOk, IconReplacements, JerError, JsonData, JsonEditor, JsonEditorProps, LinkCustomComponent, LinkCustomNodeDefinition, LocalisedStrings, NodeData, OnChangeFunction, OnErrorFunction, SearchFilterFunction, Theme, ThemeInput, ThemeName, TranslateFunction, UpdateFunction, ValueNodeProps, isCollection, matchNode, matchNodeKey, themes, truncate };