json-edit-react 1.15.12 → 1.16.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 +4 -3
- package/build/index.cjs.js +1 -1
- package/build/index.d.ts +3 -5
- package/build/index.esm.js +1 -1
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
A [React](https://github.com/facebook/react) component for editing or viewing JSON/object data
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
## [Explore the Demo](https://carlosnz.github.io/json-edit-react/) <!-- omit in toc -->
|
|
8
9
|
|
|
9
10
|

|
|
10
11
|

|
|
@@ -27,8 +28,7 @@ A [React](https://github.com/facebook/react) component for editing or viewing JS
|
|
|
27
28
|
> [!IMPORTANT]
|
|
28
29
|
> **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).
|
|
29
30
|
|
|
30
|
-
## Contents
|
|
31
|
-
- [Contents](#contents)
|
|
31
|
+
## Contents <!-- omit in toc -->
|
|
32
32
|
- [Installation](#installation)
|
|
33
33
|
- [Implementation](#implementation)
|
|
34
34
|
- [Usage](#usage)
|
|
@@ -706,6 +706,7 @@ This component is heavily inspired by [react-json-view](https://github.com/mac-s
|
|
|
706
706
|
|
|
707
707
|
## Changelog
|
|
708
708
|
|
|
709
|
+
- **1.16.0**: Extend the "click" zone for collapsing nodes to the header bar and left margin (not just the collapse icon)
|
|
709
710
|
- **1.15.12**:
|
|
710
711
|
- [Custom buttons](#custom-buttons)
|
|
711
712
|
- Misc small bug fixes
|
package/build/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),n=require("react"),t=require("object-property-assigner"),r=require("object-property-extractor");function o(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 a=[],i=[];!function(e,n){if(e&&"undefined"!=typeof document){var t,r=!0===n.prepend?"prepend":"append",o=!0===n.singleTag,s="string"==typeof n.container?document.querySelector(n.container):document.getElementsByTagName("head")[0];if(o){var l=a.indexOf(s);-1===l&&(l=a.push(s)-1,i[l]={}),t=i[l]&&i[l][r]?i[l][r]:i[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 a="prepend"===r?"afterbegin":"beforeend";return s.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.3s;\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 transition: var(--jer-expand-transition-time);\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 s=({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})]})},l={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"}}},c=l.default,d=n.createContext({getStyles:()=>({}),icons:{}}),u=({theme:n="default",icons:t={},children:r})=>{const o=g(n);return e.jsx(d.Provider,{value:{getStyles:(e,n)=>"function"==typeof o[e]?o[e](n):o[e],icons:t},children:r})},p=()=>n.useContext(d),g=e=>{var n,t,r,o;const a={},i=(Array.isArray(e)?e:[e]).map((n=>"default"===e?{}:"string"==typeof n?m(l[n],a):h(n)?m({fragments:{},styles:n},a):m(n,a))),s=m(c,{});Object.keys(s).forEach((e=>{const n=e;i.forEach((e=>{e[n]&&(s[n]=Object.assign(Object.assign({},s[n]),e[n]))}))}));const d=Object.assign({},s);return Object.entries(a).forEach((([e,n])=>{const t=e;d[t]=e=>{const r=n(e)||{};return Object.assign(Object.assign({},s[t]),r)}})),"function"!=typeof(null==d?void 0:d.inputHighlight)&&(null===(n=null==d?void 0:d.inputHighlight)||void 0===n?void 0:n.backgroundColor)&&document.documentElement.style.setProperty("--jer-highlight-color",null===(t=null==d?void 0:d.inputHighlight)||void 0===t?void 0:t.backgroundColor),"function"!=typeof(null==d?void 0:d.iconCopy)&&(null===(r=null==d?void 0:d.iconCopy)||void 0===r?void 0:r.color)&&document.documentElement.style.setProperty("--jer-icon-copy-color",null===(o=null==d?void 0:d.iconCopy)||void 0===o?void 0:o.color),d},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),{[y[e]]:n}):Object.assign(Object.assign({},r),n)}return Object.assign(Object.assign({},r),o)}),{});o[e]=a})),o},h=e=>!("styles"in e),y={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"},j="**INVALID_FUNCTION**",b=(e,n=200)=>"string"==typeof e?e.length<n?e:`${e.slice(0,n-2).trim()}...`:e,f=e=>e.map((e=>""===e?String.fromCharCode(0):e)).join("."),v=({value:n,setValue:t,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:l,stringTruncate:c,showStringQuotes:d,nodeData:u})=>{const{getStyles:g}=p(),m=f(o),h=d?'"':"";return r?e.jsx(s,{className:"jer-input-text",name:m,value:n,setValue:t,isEditing:r,handleKeyPress:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&l():i()},styles:g("input",u)}):e.jsxs("div",{id:`${m}_display`,onDoubleClick:()=>a(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&a(!0)},className:"jer-value-string",style:g("string",u),children:[h,b(n,c),h]})},x=({value:n,setValue:t,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:s,nodeData:l})=>{const{getStyles:c}=p();return r?e.jsx("input",{className:"jer-input-number",type:"text",name:f(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})},E=({value:n,setValue:t,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:s,nodeData:l})=>{const{getStyles:c}=p();return r?e.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:f(o),checked:n,onChange:()=>t(!n),onKeyDown:e=>{"Enter"===e.key?i():"Escape"===e.key&&s()},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:c("boolean",l),children:String(n)})},D=({value:t,isEditing:r,setIsEditing:o,handleEdit:a,handleCancel:i,nodeData:s})=>{const{getStyles:l}=p();n.useEffect((()=>(r&&document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c))),[r]);const c=e=>{"Enter"===e.key?a():"Escape"===e.key&&i()};return e.jsx("div",{onDoubleClick:()=>o(!0),className:"jer-value-null",style:l("null",s),children:String(t)})},w=({value:n})=>{let t="Error!";switch(typeof n){case"string":n===j&&(t="Function");break;case"undefined":t="Undefined";break;case"symbol":t="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:t})},k=({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"})]}),C=({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"})]}),S=({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"})}),O=({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"})]}),N=({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"})]}),A=({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"})}),T=({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"})}),R=({name:n,nodeData:t,rotate:r})=>{var o,a,i,s,l,c,d;const{getStyles:u,icons:g}=p(),m={size:"1.4em",className:"jer-icon"};switch(n){case"add":return null!==(o=null==g?void 0:g.add)&&void 0!==o?o:e.jsx(k,Object.assign({},m,{style:u("iconAdd",t)}));case"edit":return null!==(a=null==g?void 0:g.edit)&&void 0!==a?a:e.jsx(C,Object.assign({},m,{style:u("iconEdit",t)}));case"delete":return null!==(i=null==g?void 0:g.delete)&&void 0!==i?i:e.jsx(S,Object.assign({},m,{style:u("iconDelete",t),size:"1.45em"}));case"copy":return null!==(s=null==g?void 0:g.copy)&&void 0!==s?s:e.jsx(O,Object.assign({},m,{style:u("iconCopy",t),size:"1.2em"}));case"ok":return null!==(l=null==g?void 0:g.ok)&&void 0!==l?l:e.jsx(N,Object.assign({},m,{style:Object.assign({fontSize:"90%"},u("iconOk",t))}));case"cancel":return null!==(c=null==g?void 0:g.cancel)&&void 0!==c?c:e.jsx(A,Object.assign({},m,{style:Object.assign({fontSize:"130%"},u("iconCancel",t))}));case"chevron":return null!==(d=null==g?void 0:g.chevron)&&void 0!==d?d:e.jsx(T,{size:"1em",style:u("iconCollection",t)});default:return e.jsx(e.Fragment,{})}},F=({startEdit:t,handleDelete:r,handleAdd:o,enableClipboard:a,type:i,customButtons:s,nodeData:l,translate:c})=>{const{getStyles:d}=p(),u=c("KEY_NEW",l),[g,m]=n.useState(!1),[h,y]=n.useState(u),{key:j,path:b,value:f}=l;return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:g?1:void 0},children:[a&&e.jsx("div",{onClick:e=>{let n,t="value",r="";if(a){if(!0===(e.ctrlKey||e.metaKey))n=V(b),r=n,t="path";else n=f,r=i?JSON.stringify(f,null,2):String(n);navigator.clipboard.writeText(r)}"function"==typeof a&&a({value:n,stringValue:r,path:b,key:j,type:t})},className:"jer-copy-pulse",children:e.jsx(R,{name:"copy",nodeData:l})}),t&&e.jsx("div",{onClick:t,children:e.jsx(R,{name:"edit",nodeData:l})}),r&&e.jsx("div",{onClick:r,children:e.jsx(R,{name:"delete",nodeData:l})}),o&&e.jsx("div",{onClick:()=>{"object"===i?m(!0):o("")},children:e.jsx(R,{name:"add",nodeData:l})}),null==s?void 0:s.map((({Element:n,onClick:t},r)=>e.jsx("div",{onClick:e=>t(l,e),children:e.jsx(n,{})},r))),g&&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=>y(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key&&o?(m(!1),o(h),y(u)):"Escape"===e.key&&(m(!1),y(u))},style:d("input",l)}),e.jsx(P,{onOk:()=>{h&&(m(!1),o(h))},onCancel:()=>{m(!1)},nodeData:l})]})]})},P=({onOk:n,onCancel:t,nodeData:r})=>e.jsxs("div",{className:"jer-confirm-buttons",children:[e.jsx("div",{onClick:n,children:e.jsx(R,{name:"ok",nodeData:r})}),e.jsx("div",{onClick:t,children:e.jsx(R,{name:"cancel",nodeData:r})})]}),V=e=>e.reduce(((e,n)=>"number"==typeof n?`${e}[${n}]`:""===e?n:`${e}.${n}`),""),M=["string","number","boolean","null","object","array"],z=(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)},I=e=>null!==e&&"object"==typeof e,_=(e,n,t,r="")=>{if(!t&&!r)return!0;switch(e){case"collection":if(t){if(t(n,r))return!0;if(!L(r,n,t))return!1}if(!t&&r&&!L(r,n))return!1;break;case"value":if(t&&!t(n,r))return!1;if(!t&&r&&!K(n,r))return!1}return!0},L=(e="",n,t=K)=>{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 I(a)?L(e,s,t):t(s,e)}))},K=(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}},B=({key:e,path:n},t="")=>!!K({value:e},t)||!!n.some((e=>K({value:e},t))),W=n.createContext({collapseState:null,setCollapseState:()=>{},doesPathMatch:()=>!1,currentlyEditingElement:null,setCurrentlyEditingElement:()=>{},areChildrenBeingEdited:()=>!1,dragSource:{path:null,pathString:null},setDragSource:()=>{}}),G=({children:t})=>{const[r,o]=n.useState(null),[a,i]=n.useState(null),[s,l]=n.useState({path:null,pathString:null});return e.jsx(W.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})},H=()=>n.useContext(W),U=({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:m,setCurrentlyEditingElement:h}=H(),[y,j]=n.useState(null),b=Object.assign(Object.assign({},o),{collapsed:t}),{path:v,key:x,size:E}=b,D=f(v),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===m),[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:x,path:v,error:e})}),[s,l]),A=m===D,T=m===`key_${D}`,R="number"==typeof v.slice(-1)[0];return{pathString:D,nodeData:b,path:v,name:x,size:E,canEdit:w,canDelete:k,canAdd:C,canDrag:S,error:y,showError:O,onError:N,setError:j,handleEditKey:e=>{if(h(null),x===e)return;if(!a)return;const n=v.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===x?[e,t]:[n,t])));i(t,n).then((n=>{n&&N({code:"UPDATE_ERROR",message:n},e)}))},derivedValues:{isEditing:A,isEditingKey:T,isArray:R,canEditKey:null!==a&&w&&C&&k&&!R}}},Y=({canDrag:t,canDragOnto:r,path:o,nodeData:a,onMove:i,onError:s,translate:l})=>{const{getStyles:c}=p(),{dragSource:d,setDragSource:u}=H(),[g,m]=n.useState(!1),h=f(o),y=n.useMemo((()=>t?{onDragStart:e=>{e.stopPropagation(),u({path:o,pathString:h})},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(),v(e),u({path:null,pathString:null}),m(!1)},onDragEnter:n=>{var t;n.stopPropagation(),h.startsWith(null!==(t=d.pathString)&&void 0!==t?t:"")||m(e)},onDragExit:e=>{e.stopPropagation(),m(!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]),v=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})=>g===n?e.jsx("div",{className:"jer-drag-n-drop-padding",style:c("dropZone",t)}):null,handleDrop:v}},$=(e,n)=>{var t,r;const o=document.getElementsByClassName("jer-editor-container"),a=parseInt(o.length>0?getComputedStyle(o[0]).getPropertyValue("line-height"):"16px"),i=(null!==(r=null===(t=n.current)||void 0===t?void 0:t.offsetWidth)&&void 0!==r?r:0)/(.5*a),s=JSON.stringify(e,null,2).replace(/\\n/g,"\n").split("\n").map((e=>Math.ceil(e.length/i))).reduce(((e,n)=>e+n),0)*a;return Math.min(s+30,window.innerHeight-50)},J=t=>{const{data:r,parentData:o,onEdit:a,onDelete:i,onChange:s,onMove:l,enableClipboard:c,canDragOnto:d,restrictTypeSelection:u,searchFilter:g,searchText:m,showLabel:h,stringTruncate:y,showStringQuotes:b,indent:f,translate:v,customNodeDefinitions:x}=t,{getStyles:E}=p(),{setCurrentlyEditingElement:D,setCollapseState:w}=H(),[k,C]=n.useState("function"==typeof r?j:r),{pathString:S,nodeData:O,path:N,name:A,canEdit:T,canDelete:R,canDrag:V,error:I,onError:L,handleEditKey:K,derivedValues:B}=U({props:t}),{dragSourceProps:W,getDropTargetProps:G,BottomDropTarget:$,DropTargetPadding:J}=Y({canDrag:V,canDragOnto:d,path:N,nodeData:O,onMove:l,onError:L,translate:v}),Q=z(x,O),[ee,ne]=n.useState(X(r,Q)),te=n.useCallback((e=>{if(!s)return void C(e);const n=s({currentData:O.fullData,newValue:e,currentValue:k,name:A,path:N});C(n)}),[s]);n.useEffect((()=>{C("function"==typeof r?j:r),ne(X(r,Q))}),[r,I]);const{CustomNode:re,customNodeProps:oe,hideKey:ae,showEditTools:ie=!0,showOnEdit:se,showOnView:le}=Q,ce=[...M,...x.filter((({showInTypesSelector:e=!1,name:n})=>e&&!!n)).map((({name:e})=>e))],de=n.useMemo((()=>{if("boolean"==typeof u)return u?[]:ce;if(Array.isArray(u))return u;const e=u(O);return"boolean"==typeof e?e?[]:ce:e}),[O,u]);if(!_("value",O,g,m))return null;const ue=()=>{let e;switch(D(null),ee){case"object":e={[v("DEFAULT_NEW_KEY",O)]:k};break;case"array":e=null!=k?k:[];break;case"number":{const n=Number(k);e=isNaN(n)?0:n;break}default:e=k}a(e,N).then((n=>{n&&L({code:"UPDATE_ERROR",message:n},e)}))},pe=()=>{D(null),C(r),ne(X(r,Q))},{isEditing:ge,isEditingKey:me,canEditKey:he}=B,ye=!ge&&I,je=ge&&de.length>0,be="invalid"!==ee&&!I&&ie,fe=h&&me,ve=h&&!me&&!ae,xe={value:k,parentData:o,setValue:te,isEditing:ge,setIsEditing:T?()=>D(S):()=>{},handleEdit:ue,handleCancel:pe,path:N,stringTruncate:y,showStringQuotes:b,nodeData:O,translate:v},Ee=re&&(ge&&se||!ge&&le)?e.jsx(re,Object.assign({},t,{value:k,customNodeProps:oe,setValue:te,handleEdit:ue,handleCancel:pe,handleKeyPress:e=>{"Enter"===e.key?ue():"Escape"===e.key&&pe()},isEditing:ge,setIsEditing:()=>D(S),getStyles:E})):Z(X(r),xe);return e.jsxs("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:f/2+"em",position:"relative"},draggable:V},W,G("above"),{children:[$,e.jsx(J,{position:"above",nodeData:O}),e.jsxs("div",{className:"jer-value-main-row",style:{flexWrap:A.length>10?"wrap":"nowrap"},children:[ve&&e.jsx("span",{className:"jer-key-text",style:Object.assign(Object.assign({},E("property",O)),{minWidth:`${Math.min(String(A).length+1,5)}ch`,flexShrink:A.length>10?1:0}),onDoubleClick:()=>he&&D(`key_${S}`),children:""===A?e.jsx("span",{className:N.length>0?"jer-empty-string":void 0}):`${A}:`}),fe&&e.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:S,defaultValue:A,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?K(e.target.value):"Escape"===e.key&&pe()},style:{width:String(A).length/1.5+.5+"em"}}),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:Ee}),ge?e.jsx(P,{onOk:ue,onCancel:pe,nodeData:O}):be&&e.jsx(F,{startEdit:T?()=>D(S):void 0,handleDelete:R?()=>{i(k,N).then((e=>{e&&L({code:"DELETE_ERROR",message:e},k)}))}:void 0,enableClipboard:c,translate:v,customButtons:t.customButtons,nodeData:O}),je&&e.jsxs("div",{className:"jer-select",children:[e.jsx("select",{name:`${A}-type-select`,className:"jer-type-select",onChange:e=>(e=>{const n=x.find((n=>n.name===e));if(n)a(n.defaultValue,N),ne(e),D(null),w({path:N,collapsed:!1});else{const n=q(k,e,v("DEFAULT_NEW_KEY",O),(null==Q?void 0:Q.CustomNode)?v("DEFAULT_STRING",O):void 0);te(n),a(n,N).then((e=>{e&&(L({code:"UPDATE_ERROR",message:e},n),D(null))}))}})(e.target.value),value:ee,children:de.map((n=>e.jsx("option",{value:n,children:n},n)))}),e.jsx("span",{className:"focus"})]}),ye&&e.jsx("span",{className:"jer-error-slug",style:E("error",O),children:I})]})]}),e.jsx(J,{position:"below",nodeData:O})]}))},X=(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",Z=(n,t)=>{const r=t.value;switch(n){case"string":return e.jsx(v,Object.assign({},t,{value:r}));case"number":return e.jsx(x,Object.assign({},t,{value:r}));case"boolean":return e.jsx(E,Object.assign({},t,{value:r}));case"null":return e.jsx(D,Object.assign({},t));default:return e.jsx(w,Object.assign({},t))}},q=(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)}},Q=t=>{const{getStyles:a}=p(),{collapseState:i,setCollapseState:l,doesPathMatch:c,currentlyEditingElement:d,setCurrentlyEditingElement:u,areChildrenBeingEdited:g}=H(),{data:m,nodeData:h,parentData:y,showCollectionCount:j,onEdit:b,onAdd:f,onDelete:v,canDragOnto:x,collapseFilter:E,collapseAnimationTime:D,onMove:w,enableClipboard:k,searchFilter:C,searchText:S,indent:O,keySort:N,showArrayIndices:A,defaultValue:T,translate:V,customNodeDefinitions:M,jsonParse:L,jsonStringify:K}=t,[B,W]=n.useState(K(m)),G=E(h),{contentRef:X,isAnimating:Z,maxHeight:q,collapsed:ee,animateCollapse:ne}=((e,t,r)=>{const[o,a]=n.useState(r?0:void 0),[i,s]=n.useState(r),l=n.useRef(!1),c=n.useRef(null),d=n.useRef(0),u=n.useRef();return{contentRef:c,isAnimating:l.current,animateCollapse:n=>{var r,o;if(i!==n){switch(window.clearTimeout(u.current),l.current=!0,n){case!0:{const e=null!==(o=null===(r=c.current)||void 0===r?void 0:r.offsetHeight)&&void 0!==o?o:0;d.current=e,a(e),setTimeout((()=>{a(0)}),5);break}case!1:a(d.current||$(e,c))}s(!i),u.current=window.setTimeout((()=>{l.current=!1,n||a(void 0)}),t)}},maxHeight:o,collapsed:i}})(m,D,G),{pathString:te,nodeData:re,path:oe,name:ae,size:ie,canEdit:se,canDelete:le,canAdd:ce,canDrag:de,error:ue,setError:pe,onError:ge,handleEditKey:me,derivedValues:he}=U({props:t,collapsed:ee}),{dragSourceProps:ye,getDropTargetProps:je,BottomDropTarget:be,DropTargetPadding:fe}=Y({canDrag:de,canDragOnto:x,path:oe,nodeData:re,onMove:w,onError:ge,translate:V}),ve=n.useRef(!G);n.useEffect((()=>{W(K(m))}),[m]),n.useEffect((()=>{const e=E(re)&&!he.isEditing;ve.current=!e,ne(e)}),[E]),n.useEffect((()=>{null!==i&&c(oe)&&(ve.current=!0,ne(i.collapsed))}),[i]);const xe=n.useMemo((()=>e=>"function"!=typeof T?T:T(e)),[T]),{CustomNode:Ee,customNodeProps:De,CustomWrapper:we,wrapperProps:ke={},hideKey:Ce,showEditTools:Se=!0,showOnEdit:Oe,showOnView:Ne,showCollectionWrapper:Ae=!0}=n.useMemo((()=>z(M,re)),[]);if(!_("collection",re,C,S)&&re.level>0)return null;const Te=Array.isArray(m)?"array":"object",Re="array"===Te?{open:"[",close:"]"}:{open:"{",close:"}"},Fe=e=>{"Enter"===e.key&&(e.metaKey||e.shiftKey||e.ctrlKey)?Pe():"Escape"===e.key&&Me()},Pe=()=>{try{const e=L(B);if(u(null),pe(null),JSON.stringify(e)===JSON.stringify(m))return;b(e,oe).then((n=>{n&&ge({code:"UPDATE_ERROR",message:n},e)}))}catch(e){ge({code:"INVALID_JSON",message:V("ERROR_INVALID_JSON",re)},B)}},Ve=oe.length>0?()=>{v(m,oe).then((e=>{e&&ge({code:"DELETE_ERROR",message:e},r(m,oe))}))}:void 0,Me=()=>{u(null),pe(null),W(K(m))},{isEditing:ze,isEditingKey:Ie,isArray:_e,canEditKey:Le}=he,Ke="when-closed"===j?ee:j,Be=!ze&&Se,We=(A||!_e)&&!Ce&&void 0!==ae,Ge=Ee&&(ze&&Oe||!ze&&Ne),He=N&&"object"===Te,Ue=Object.entries(m).map((([e,n])=>["array"===Te?Number(e):e,n]));He&&Ue.sort("function"==typeof N?(e,n)=>N(e[0],n[0]):void 0);const Ye=ve.current?ze?e.jsx("div",{className:"jer-collection-text-edit",children:e.jsxs("div",{children:[e.jsx(s,{className:"jer-collection-text-area",name:te,value:B,setValue:W,isEditing:ze,handleKeyPress:Fe,styles:a("input",re)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(P,{onOk:Pe,onCancel:Me,nodeData:re})})]})}):Ue.map((([n,r],o)=>{const i={key:n,value:r,path:[...oe,n],level:oe.length+1,index:o,size:I(r)?Object.keys(r).length:1,parentData:m,fullData:re.fullData};return e.jsx("div",{className:"jer-collection-element",style:a("collectionElement",i),children:I(r)?e.jsx(Q,Object.assign({},t,{data:r,parentData:m,nodeData:i,showCollectionCount:j,canDragOnto:se}),n):e.jsx(J,Object.assign({},t,{data:r,parentData:m,nodeData:i,canDragOnto:se,showLabel:"object"===Te||A}),n)},n)})):null,$e=!!Ae&ⅇ$e||(ve.current=!0);const Je=Object.assign(Object.assign({},t),{data:m,value:m,parentData:y,nodeData:re,setValue:e=>o(void 0,void 0,void 0,(function*(){return yield b(e,oe)})),handleEdit:Pe,handleCancel:Me,handleKeyPress:Fe,isEditing:ze,setIsEditing:()=>u(te),getStyles:a,canDragOnto:se}),Xe=Ge?e.jsx(Ee,Object.assign({customNodeProps:De},Je,{children:Ye})):Ye,Ze=Ie?e.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:te,defaultValue:ae,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?me(e.target.value):"Escape"===e.key&&Me()},style:{width:String(ae).length/1.5+.5+"em"}}):We&&e.jsx("span",{className:"jer-key-text",style:a("property",re),onDoubleClick:()=>Le&&u(`key_${te}`),children:""===ae?e.jsx("span",{className:oe.length>0?"jer-empty-string":void 0}):`${ae}:`}),qe=Be&&e.jsx(F,{startEdit:se?()=>{ve.current=!0,u(te)}:void 0,handleAdd:ce?e=>{ne(!1);const n=xe(re);"array"===Te?f(n,[...oe,m.length]).then((e=>{e&&ge({code:"ADD_ERROR",message:e},n)})):e in m?ge({code:"KEY_EXISTS",message:V("ERROR_KEY_EXISTS",re)},e):f(n,[...oe,e]).then((e=>{e&&ge({code:"ADD_ERROR",message:e},n)}))}:void 0,handleDelete:le?Ve:void 0,enableClipboard:k,type:Te,nodeData:re,translate:V,customButtons:t.customButtons}),Qe=e.jsxs("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===oe.length?0:O/2)+"em"},a("collection",re)),{position:"relative"}),draggable:de},ye,je("above"),{children:[!ze&&be,e.jsx(fe,{position:"above",nodeData:re}),Ae?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 jer-accordion-icon"+(ee?" jer-rotate-90":""),onClick:e=>(e=>{if(e.getModifierState("Alt"))return ve.current=!0,void l({collapsed:!ee,path:oe});d&&d.includes(te)||(ve.current=!0,l(null),ne(!ee))})(e),children:e.jsx(R,{name:"chevron",rotate:ee,nodeData:re})}),Ze,!ze&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:a("bracket",re),children:Re.open})]}),!ze&&Ke&&e.jsx("div",{className:"jer-collection-item-count"+(Ke?" jer-visible":" jer-hidden"),style:a("itemCount",re),children:1===ie?V("ITEM_SINGLE",Object.assign(Object.assign({},re),{size:1}),1):V("ITEMS_MULTIPLE",re,ie)}),e.jsx("div",{className:"jer-brackets"+($e?" jer-visible":" jer-hidden"),style:a("bracket",re),children:Re.close}),qe]}):Ce?e.jsx(e.Fragment,{}):e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[Ze,qe]}),e.jsxs("div",{className:"jer-collection-inner",style:Object.assign({overflowY:$e||Z?"clip":"visible",maxHeight:g(te)?void 0:q},a("collectionInner",re)),ref:X,children:[Xe,e.jsx("div",{className:ze?"jer-collection-error-row":"jer-collection-error-row-edit",children:ue&&e.jsx("span",{className:"jer-error-slug",style:a("error",re),children:ue})}),!ze&&Ae&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},a("bracket",re)),{marginLeft:(O<3?-1:O<6?-.5:0)+"em"}),children:Re.close})]}),e.jsx(fe,{position:"below",nodeData:re})]}));return we?e.jsx(we,Object.assign({customNodeProps:ke},Je,{children:Qe})):Qe},ee={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"},ne=(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]:ee[r];return void 0===o?a:null==a?void 0:a.replace("{{count}}",String(o))})(e,n,r,t,o),te=({data:t,setData:r,rootName:a="root",onUpdate:i=(()=>{}),onEdit:s=i,onDelete:l=i,onAdd:c=i,onChange:d,onError:u,showErrorMessages:g=!0,enableClipboard:m=!0,indent:h=2,collapse:y=!1,collapseAnimationTime:j=300,showCollectionCount:b=!0,restrictEdit:f=!1,restrictDelete:v=!1,restrictAdd:x=!1,restrictTypeSelection:E=!1,restrictDrag:D=!0,searchFilter:w,searchText:k,searchDebounceTime:C=350,keySort:S=!1,showArrayIndices:O=!0,showStringQuotes:N=!0,defaultValue:A=null,minWidth:T=250,maxWidth:R="min(600px, 90vw)",rootFontSize:F,stringTruncate:P=250,translations:V={},className:M,id:z,customText:_={},customNodeDefinitions:L=[],customButtons:K=[],jsonParse:B=JSON.parse,jsonStringify:W=(e=>JSON.stringify(e,null,2))})=>{const{getStyles:G}=p(),H=n.useCallback(oe(y),[y]),U=n.useCallback(ne(V,_),[V,_]),[Y,$]=n.useState(k),[X,Z]=(({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}),q=document.querySelector(":root"),ee=getComputedStyle(document.documentElement).getPropertyValue("--jer-expand-transition-time");1e3*parseFloat(ee)!==j&&(null==q||q.style.setProperty("--jer-expand-transition-time",j/1e3+"s")),n.useEffect((()=>{const e=setTimeout((()=>$(k)),C);return()=>clearTimeout(e)}),[k,C]);const te={key:a,path:[],level:0,index:0,value:X,size:"object"==typeof X&&null!==X?Object.keys(X).length:1,parentData:null,fullData:X},se=(e,n)=>o(void 0,void 0,void 0,(function*(){const t=yield e(n);if(!0===t||void 0===t)return void Z(n.newData);const r=ie(t)?t:["error",t],[o,a]=r;if("error"===o)return Z(n.currentData),!1===a?U("ERROR_UPDATE",te):String(a);Z(a)})),le=n.useMemo((()=>oe(f)),[f]),ce=n.useMemo((()=>oe(v)),[v]),de=n.useMemo((()=>oe(x)),[x]),ue=n.useMemo((()=>oe(D)),[D]),pe=n.useMemo((()=>ae(w)),[w]),ge={name:a,nodeData:te,onEdit:(e,n)=>o(void 0,void 0,void 0,(function*(){const{currentData:t,newData:r,currentValue:o,newValue:a}=re(X,n,e,"update");if(o!==a)return yield se(s,{currentData:t,newData:r,currentValue:o,newValue:a,name:n.slice(-1)[0],path:n})})),onDelete:(e,n)=>o(void 0,void 0,void 0,(function*(){const{currentData:t,newData:r,currentValue:o,newValue:a}=re(X,n,e,"delete");return yield se(l,{currentData:t,newData:r,currentValue:o,newValue:a,name:n.slice(-1)[0],path:n})})),onAdd:(e,n)=>o(void 0,void 0,void 0,(function*(){const{currentData:t,newData:r,currentValue:o,newValue:a}=re(X,n,e,"add");return yield se(c,{currentData:t,newData:r,currentValue:o,newValue:a,name:n.slice(-1)[0],path:n})})),onChange:d,onError:u,showErrorMessages:g,onMove:(e,n,t)=>o(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:a}=re(X,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}=re(o,[...l,d],a,"add",u);return yield se(s,{currentData:r,newData:p,currentValue:a,newValue:g,name:n.slice(-1)[0],path:n})})),showCollectionCount:b,collapseFilter:H,collapseAnimationTime:j,restrictEditFilter:le,restrictDeleteFilter:ce,restrictAddFilter:de,restrictTypeSelection:E,restrictDragFilter:ue,canDragOnto:!1,searchFilter:pe,searchText:Y,enableClipboard:m,keySort:S,showArrayIndices:O,showStringQuotes:N,indent:h,defaultValue:A,stringTruncate:P,translate:U,customNodeDefinitions:L,customButtons:K,parentData:null,jsonParse:B,jsonStringify:W},me=Object.assign(Object.assign({},G("container",te)),{minWidth:T,maxWidth:R});return me.fontSize=null!=F?F:me.fontSize,e.jsx("div",{id:z,className:"jer-editor-container "+M,style:me,children:I(X)?e.jsx(Q,Object.assign({data:X},ge)):e.jsx(J,Object.assign({data:X,showLabel:!0},ge))})},re=(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}},oe=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:n})=>n>=e:e,ae=e=>{if(void 0!==e)return"value"===e?K:"key"===e?B:"all"===e?(e,n)=>K(e,n)||B(e,n):e},ie=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),se=({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:['"',b(n,l),'"']})})},le={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:se,showOnView:!0,showOnEdit:!1};exports.assign=t,exports.extract=r,exports.IconAdd=k,exports.IconCancel=A,exports.IconChevron=T,exports.IconCopy=O,exports.IconDelete=S,exports.IconEdit=C,exports.IconOk=N,exports.JsonEditor=n=>e.jsx(u,{theme:n.theme,icons:n.icons,children:e.jsx(G,{children:e.jsx(te,Object.assign({},n))})}),exports.LinkCustomComponent=se,exports.LinkCustomNodeDefinition=le,exports.isCollection=I,exports.matchNode=K,exports.matchNodeKey=B,exports.themes=l,exports.truncate=b;
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),n=require("object-property-assigner"),r=require("object-property-extractor");function o(e,t,n,r){return new(n||(n=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 t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}l((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const a=({className:t,name:n,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:`${n}_textarea`,style:Object.assign({height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap"},i),rows:1,className:t,name:`${n}_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:t,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})]})},i=e=>null!==e&&"object"==typeof e,s=(e,t,n,r="")=>{if(!n&&!r)return!0;switch(e){case"collection":if(n){if(n(t,r))return!0;if(!l(r,t,n))return!1}if(!n&&r&&!l(r,t))return!1;break;case"value":if(n&&!n(t,r))return!1;if(!n&&r&&!c(t,r))return!1}return!0},l=(e="",t,n=c)=>{const r=t.value;return Object.entries(r).some((([o,a])=>{const s=[...t.path,o],c=Object.assign(Object.assign({},t),{key:o,path:s,level:t.level+1,value:a,size:s.length,parentData:r});return i(a)?l(e,c,n):n(c,e)}))},c=(e,t="")=>{const{value:n}=e;if(null===n&&"null".includes(t.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(t.toLowerCase());case"number":return!!String(n).includes(t);case"boolean":return n?"true".includes(t.toLowerCase())||"1"===t:"false".includes(t.toLowerCase())||"0"===t;default:return!1}},d=({key:e,path:t},n="")=>!!c({value:e},n)||!!t.some((e=>c({value:e},n))),u=(e,t=200)=>"string"==typeof e?e.length<t?e:`${e.slice(0,t-2).trim()}...`:e,p=e=>e.map((e=>""===e?String.fromCharCode(0):e)).join("."),g={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"}}},m=g.default,h=t.createContext({getStyles:()=>({}),icons:{}}),y=({theme:t="default",icons:n={},children:r})=>{const o=b(t);return e.jsx(h.Provider,{value:{getStyles:(e,t)=>"function"==typeof o[e]?o[e](t):o[e],icons:n},children:r})},j=()=>t.useContext(h),b=e=>{var t,n,r,o;const a={},i=(Array.isArray(e)?e:[e]).map((t=>"default"===e?{}:"string"==typeof t?f(g[t],a):v(t)?f({fragments:{},styles:t},a):f(t,a))),s=f(m,{});Object.keys(s).forEach((e=>{const t=e;i.forEach((e=>{e[t]&&(s[t]=Object.assign(Object.assign({},s[t]),e[t]))}))}));const l=Object.assign({},s);return Object.entries(a).forEach((([e,t])=>{const n=e;l[n]=e=>{const r=t(e)||{};return Object.assign(Object.assign({},s[n]),r)}})),"function"!=typeof(null==l?void 0:l.inputHighlight)&&(null===(t=null==l?void 0:l.inputHighlight)||void 0===t?void 0:t.backgroundColor)&&document.documentElement.style.setProperty("--jer-highlight-color",null===(n=null==l?void 0:l.inputHighlight)||void 0===n?void 0:n.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},f=(e,t)=>{const{fragments:n,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 t[e]=o,Object.assign({},r);if("string"==typeof o){const t=null!==(a=null==n?void 0:n[o])&&void 0!==a?a:o;return"string"==typeof t?Object.assign(Object.assign({},r),{[x[e]]:t}):Object.assign(Object.assign({},r),t)}return Object.assign(Object.assign({},r),o)}),{});o[e]=a})),o},v=e=>!("styles"in e),x={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"},E="**INVALID_FUNCTION**",D=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:i,handleEdit:s,handleCancel:l,stringTruncate:c,showStringQuotes:d,nodeData:g})=>{const{getStyles:m}=j(),h=p(o),y=d?'"':"";return r?e.jsx(a,{className:"jer-input-text",name:h,value:t,setValue:n,isEditing:r,handleKeyPress:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&l():s()},styles:m("input",g)}):e.jsxs("div",{id:`${h}_display`,onDoubleClick:()=>i(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&i(!0)},className:"jer-value-string",style:m("string",g),children:[y,u(t,c),y]})},w=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:s,nodeData:l})=>{const{getStyles:c}=j();return r?e.jsx("input",{className:"jer-input-number",type:"text",name:p(o),value:t,onChange:e=>n(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(),n(Number(t)+1);break;case"ArrowDown":e.preventDefault(),n(Number(t)-1)}},style:Object.assign({width:String(t).length/1.5+2+"em"},c("input",l))}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:c("number",l),children:t})},k=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:s,nodeData:l})=>{const{getStyles:c}=j();return r?e.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:p(o),checked:t,onChange:()=>n(!t),onKeyDown:e=>{"Enter"===e.key?i():"Escape"===e.key&&s()},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:c("boolean",l),children:String(t)})},C=({value:n,isEditing:r,setIsEditing:o,handleEdit:a,handleCancel:i,nodeData:s})=>{const{getStyles:l}=j();t.useEffect((()=>(r&&document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c))),[r]);const c=e=>{"Enter"===e.key?a():"Escape"===e.key&&i()};return e.jsx("div",{onDoubleClick:()=>o(!0),className:"jer-value-null",style:l("null",s),children:String(n)})},S=({value:t})=>{let n="Error!";switch(typeof t){case"string":t===E&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:n})},O=({size:t,style:n,className:r})=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:r,style:n,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"})]}),N=({size:t,style:n,className:r})=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:r,style:n,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"})]}),A=({size:t,style:n,className:r})=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:r,style:n,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"})}),T=({size:t,style:n,className:r})=>e.jsxs("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:t,height:t,className:r,style:n,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"})]}),P=({size:t,style:n,className:r})=>e.jsxs("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:t,height:t,className:r,style:n,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:t,style:n,className:r})=>e.jsx("svg",{baseProfile:"tiny",viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:r,style:n,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"})}),V=({size:t,style:n,className:r})=>e.jsx("svg",{viewBox:"0 0 512 512",fill:"currentColor",width:t,height:t,className:r,style:n,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"})}),F=({name:t,nodeData:n,rotate:r})=>{var o,a,i,s,l,c,d;const{getStyles:u,icons:p}=j(),g={size:"1.4em",className:"jer-icon"};switch(t){case"add":return null!==(o=null==p?void 0:p.add)&&void 0!==o?o:e.jsx(O,Object.assign({},g,{style:u("iconAdd",n)}));case"edit":return null!==(a=null==p?void 0:p.edit)&&void 0!==a?a:e.jsx(N,Object.assign({},g,{style:u("iconEdit",n)}));case"delete":return null!==(i=null==p?void 0:p.delete)&&void 0!==i?i:e.jsx(A,Object.assign({},g,{style:u("iconDelete",n),size:"1.45em"}));case"copy":return null!==(s=null==p?void 0:p.copy)&&void 0!==s?s:e.jsx(T,Object.assign({},g,{style:u("iconCopy",n),size:"1.2em"}));case"ok":return null!==(l=null==p?void 0:p.ok)&&void 0!==l?l:e.jsx(P,Object.assign({},g,{style:Object.assign({fontSize:"90%"},u("iconOk",n))}));case"cancel":return null!==(c=null==p?void 0:p.cancel)&&void 0!==c?c:e.jsx(R,Object.assign({},g,{style:Object.assign({fontSize:"130%"},u("iconCancel",n))}));case"chevron":return null!==(d=null==p?void 0:p.chevron)&&void 0!==d?d:e.jsx(V,{size:"1em",style:u("iconCollection",n)});default:return e.jsx(e.Fragment,{})}},z=({startEdit:n,handleDelete:r,handleAdd:o,enableClipboard:a,type:i,customButtons:s,nodeData:l,translate:c})=>{const{getStyles:d}=j(),u=c("KEY_NEW",l),[p,g]=t.useState(!1),[m,h]=t.useState(u),{key:y,path:b,value:f}=l;return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:p?1:void 0},children:[a&&e.jsx("div",{onClick:e=>{e.stopPropagation();let t,n="value",r="";if(a){if(!0===(e.ctrlKey||e.metaKey))t=I(b),r=t,n="path";else t=f,r=i?JSON.stringify(f,null,2):String(t);navigator.clipboard.writeText(r)}"function"==typeof a&&a({value:t,stringValue:r,path:b,key:y,type:n})},className:"jer-copy-pulse",children:e.jsx(F,{name:"copy",nodeData:l})}),n&&e.jsx("div",{onClick:e=>{e.stopPropagation(),n()},children:e.jsx(F,{name:"edit",nodeData:l})}),r&&e.jsx("div",{onClick:e=>{e.stopPropagation(),r()},children:e.jsx(F,{name:"delete",nodeData:l})}),o&&e.jsx("div",{onClick:e=>{e.stopPropagation(),"object"===i?g(!0):o("")},children:e.jsx(F,{name:"add",nodeData:l})}),null==s?void 0:s.map((({Element:t,onClick:n},r)=>e.jsx("div",{onClick:e=>n(l,e),children:e.jsx(t,{})},r))),p&&o&&"object"===i&&e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:m,onChange:e=>h(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key&&o?(g(!1),o(m),h(u)):"Escape"===e.key&&(g(!1),h(u))},style:d("input",l)}),e.jsx(M,{onOk:()=>{m&&(g(!1),o(m))},onCancel:()=>{g(!1)},nodeData:l})]})]})},M=({onOk:t,onCancel:n,nodeData:r})=>e.jsxs("div",{className:"jer-confirm-buttons",children:[e.jsx("div",{onClick:t,children:e.jsx(F,{name:"ok",nodeData:r})}),e.jsx("div",{onClick:n,children:e.jsx(F,{name:"cancel",nodeData:r})})]}),I=e=>e.reduce(((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`),""),_=["string","number","boolean","null","object","array"],L=(e=[],t)=>{const n=e.filter((({condition:e})=>e(t)));if(0===n.length)return{};const r=n[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,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(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)},K=t.createContext({collapseState:null,setCollapseState:()=>{},doesPathMatch:()=>!1,currentlyEditingElement:null,setCurrentlyEditingElement:()=>{},areChildrenBeingEdited:()=>!1,dragSource:{path:null,pathString:null},setDragSource:()=>{}}),B=({children:n})=>{const[r,o]=t.useState(null),[a,i]=t.useState(null),[s,l]=t.useState({path:null,pathString:null});return e.jsx(K.Provider,{value:{collapseState:r,setCollapseState:e=>{o(e),null!==e&&setTimeout((()=>o(null)),2e3)},doesPathMatch:e=>{if(null===r)return!1;for(const[t,n]of r.path.entries())if(n!==e[t])return!1;return!0},currentlyEditingElement:a,setCurrentlyEditingElement:i,areChildrenBeingEdited:e=>null!==a&&a.includes(e),dragSource:s,setDragSource:l},children:n})},W=()=>t.useContext(K),G=({props:e,collapsed:n})=>{const{data:r,nodeData:o,parentData:a,onEdit:i,onError:s,showErrorMessages:l,restrictEditFilter:c,restrictDeleteFilter:d,restrictAddFilter:u,restrictDragFilter:g,translate:m}=e,{currentlyEditingElement:h,setCurrentlyEditingElement:y}=W(),[j,b]=t.useState(null),f=Object.assign(Object.assign({},o),{collapsed:n}),{path:v,key:x,size:E}=f,D=p(v),w=t.useMemo((()=>!c(f)),[f]),k=t.useMemo((()=>!d(f)),[f]),C=t.useMemo((()=>!u(f)),[f]),S=t.useMemo((()=>!g(f)&&k&&null===h),[f]),O=e=>{l&&(b(e),setTimeout((()=>b(null)),2500)),console.warn("Error",e)},N=t.useMemo((()=>(e,t)=>{O(e.message),s&&s({currentData:f.fullData,errorValue:t,currentValue:r,name:x,path:v,error:e})}),[s,l]),A=h===D,T=h===`key_${D}`,P="number"==typeof v.slice(-1)[0];return{pathString:D,nodeData:f,path:v,name:x,size:E,canEdit:w,canDelete:k,canAdd:C,canDrag:S,error:j,showError:O,onError:N,setError:b,handleEditKey:e=>{if(y(null),x===e)return;if(!a)return;const t=v.slice(0,-1);if(Object.keys(a).includes(e))return void N({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",f)},e);const n=Object.fromEntries(Object.entries(a).map((([t,n])=>t===x?[e,n]:[t,n])));i(n,t).then((t=>{t&&N({code:"UPDATE_ERROR",message:t},e)}))},derivedValues:{isEditing:A,isEditingKey:T,isArray:P,canEditKey:null!==a&&w&&C&&k&&!P}}},H=({canDrag:n,canDragOnto:r,path:o,nodeData:a,onMove:i,onError:s,translate:l})=>{const{getStyles:c}=j(),{dragSource:d,setDragSource:u}=W(),[g,m]=t.useState(!1),h=p(o),y=t.useMemo((()=>n?{onDragStart:e=>{e.stopPropagation(),u({path:o,pathString:h})},onDragEnd:e=>{e.stopPropagation(),u({path:null,pathString:null})}}:{}),[n]),b=t.useMemo((()=>e=>r?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),v(e),u({path:null,pathString:null}),m(!1)},onDragEnter:t=>{var n;t.stopPropagation(),h.startsWith(null!==(n=d.pathString)&&void 0!==n?n:"")||m(e)},onDragExit:e=>{e.stopPropagation(),m(!1)}}:{}),[d,r]),f=t.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}},b("below"))):null),[d,r]),v=e=>{var t,n;const r=null===(t=d.path)||void 0===t?void 0:t.slice(-1)[0],c=null===(n=d.path)||void 0===n?void 0:n.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:b,BottomDropTarget:f,DropTargetPadding:({position:t,nodeData:n})=>g===t?e.jsx("div",{className:"jer-drag-n-drop-padding",style:c("dropZone",n)}):null,handleDrop:v}},U=(e,t)=>{var n,r;const o=document.getElementsByClassName("jer-editor-container"),a=parseInt(o.length>0?getComputedStyle(o[0]).getPropertyValue("line-height"):"16px"),i=(null!==(r=null===(n=t.current)||void 0===n?void 0:n.offsetWidth)&&void 0!==r?r:0)/(.5*a),s=JSON.stringify(e,null,2).replace(/\\n/g,"\n").split("\n").map((e=>Math.ceil(e.length/i))).reduce(((e,t)=>e+t),0)*a;return Math.min(s+30,window.innerHeight-50)},Y=n=>{const{data:r,parentData:o,onEdit:a,onDelete:i,onChange:l,onMove:c,enableClipboard:d,canDragOnto:u,restrictTypeSelection:p,searchFilter:g,searchText:m,showLabel:h,stringTruncate:y,showStringQuotes:b,indent:f,translate:v,customNodeDefinitions:x}=n,{getStyles:D}=j(),{setCurrentlyEditingElement:w,setCollapseState:k}=W(),[C,S]=t.useState("function"==typeof r?E:r),{pathString:O,nodeData:N,path:A,name:T,canEdit:P,canDelete:R,canDrag:V,error:F,onError:I,handleEditKey:K,derivedValues:B}=G({props:n}),{dragSourceProps:U,getDropTargetProps:Y,BottomDropTarget:Z,DropTargetPadding:q}=H({canDrag:V,canDragOnto:u,path:A,nodeData:N,onMove:c,onError:I,translate:v}),Q=L(x,N),[ee,te]=t.useState($(r,Q)),ne=t.useCallback((e=>{if(!l)return void S(e);const t=l({currentData:N.fullData,newValue:e,currentValue:C,name:T,path:A});S(t)}),[l]);t.useEffect((()=>{S("function"==typeof r?E:r),te($(r,Q))}),[r,F]);const{CustomNode:re,customNodeProps:oe,hideKey:ae,showEditTools:ie=!0,showOnEdit:se,showOnView:le}=Q,ce=[..._,...x.filter((({showInTypesSelector:e=!1,name:t})=>e&&!!t)).map((({name:e})=>e))],de=t.useMemo((()=>{if("boolean"==typeof p)return p?[]:ce;if(Array.isArray(p))return p;const e=p(N);return"boolean"==typeof e?e?[]:ce:e}),[N,p]);if(!s("value",N,g,m))return null;const ue=()=>{let e;switch(w(null),ee){case"object":e={[v("DEFAULT_NEW_KEY",N)]:C};break;case"array":e=null!=C?C:[];break;case"number":{const t=Number(C);e=isNaN(t)?0:t;break}default:e=C}a(e,A).then((t=>{t&&I({code:"UPDATE_ERROR",message:t},e)}))},pe=()=>{w(null),S(r),te($(r,Q))},{isEditing:ge,isEditingKey:me,canEditKey:he}=B,ye=!ge&&F,je=ge&&de.length>0,be="invalid"!==ee&&!F&&ie,fe=h&&me,ve=h&&!me&&!ae,xe={value:C,parentData:o,setValue:ne,isEditing:ge,setIsEditing:P?()=>w(O):()=>{},handleEdit:ue,handleCancel:pe,path:A,stringTruncate:y,showStringQuotes:b,nodeData:N,translate:v},Ee=re&&(ge&&se||!ge&&le)?e.jsx(re,Object.assign({},n,{value:C,customNodeProps:oe,setValue:ne,handleEdit:ue,handleCancel:pe,handleKeyPress:e=>{"Enter"===e.key?ue():"Escape"===e.key&&pe()},isEditing:ge,setIsEditing:()=>w(O),getStyles:D})):J($(r),xe);return e.jsxs("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:f/2+"em",position:"relative"},draggable:V},U,Y("above"),{children:[Z,e.jsx(q,{position:"above",nodeData:N}),e.jsxs("div",{className:"jer-value-main-row",style:{flexWrap:T.length>10?"wrap":"nowrap"},children:[ve&&e.jsx("span",{className:"jer-key-text",style:Object.assign(Object.assign({},D("property",N)),{minWidth:`${Math.min(String(T).length+1,5)}ch`,flexShrink:T.length>10?1:0}),onDoubleClick:()=>he&&w(`key_${O}`),children:""===T?e.jsx("span",{className:A.length>0?"jer-empty-string":void 0}):`${T}:`}),fe&&e.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:O,defaultValue:T,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?K(e.target.value):"Escape"===e.key&&pe()},style:{width:String(T).length/1.5+.5+"em"}}),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:Ee}),ge?e.jsx(M,{onOk:ue,onCancel:pe,nodeData:N}):be&&e.jsx(z,{startEdit:P?()=>w(O):void 0,handleDelete:R?()=>{i(C,A).then((e=>{e&&I({code:"DELETE_ERROR",message:e},C)}))}:void 0,enableClipboard:d,translate:v,customButtons:n.customButtons,nodeData:N}),je&&e.jsxs("div",{className:"jer-select",children:[e.jsx("select",{name:`${T}-type-select`,className:"jer-type-select",onChange:e=>(e=>{const t=x.find((t=>t.name===e));if(t)a(t.defaultValue,A),te(e),w(null),k({path:A,collapsed:!1});else{const t=X(C,e,v("DEFAULT_NEW_KEY",N),(null==Q?void 0:Q.CustomNode)?v("DEFAULT_STRING",N):void 0);ne(t),a(t,A).then((e=>{e&&(I({code:"UPDATE_ERROR",message:e},t),w(null))}))}})(e.target.value),value:ee,children:de.map((t=>e.jsx("option",{value:t,children:t},t)))}),e.jsx("span",{className:"focus"})]}),ye&&e.jsx("span",{className:"jer-error-slug",style:D("error",N),children:F})]})]}),e.jsx(q,{position:"below",nodeData:N})]}))},$=(e,t)=>(null==t?void 0:t.CustomNode)&&(null==t?void 0:t.name)&&t.showInTypesSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",J=(t,n)=>{const r=n.value;switch(t){case"string":return e.jsx(D,Object.assign({},n,{value:r}));case"number":return e.jsx(w,Object.assign({},n,{value:r}));case"boolean":return e.jsx(k,Object.assign({},n,{value:r}));case"null":return e.jsx(C,Object.assign({},n));default:return e.jsx(S,Object.assign({},n))}},X=(e,t,n,r)=>{switch(t){case"string":return null!=r?r:String(e);case"number":{const t=Number(e);return isNaN(t)?0:t}case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},Z=n=>{const{getStyles:l}=j(),{collapseState:c,setCollapseState:d,doesPathMatch:u,currentlyEditingElement:p,setCurrentlyEditingElement:g,areChildrenBeingEdited:m}=W(),{data:h,nodeData:y,parentData:b,showCollectionCount:f,onEdit:v,onAdd:x,onDelete:E,canDragOnto:D,collapseFilter:w,collapseAnimationTime:k,onMove:C,enableClipboard:S,searchFilter:O,searchText:N,indent:A,keySort:T,showArrayIndices:P,defaultValue:R,translate:V,customNodeDefinitions:I,jsonParse:_,jsonStringify:K}=n,[B,$]=t.useState(K(h)),J=w(y),{contentRef:X,isAnimating:q,maxHeight:Q,collapsed:ee,animateCollapse:te}=((e,n,r)=>{const[o,a]=t.useState(r?0:void 0),[i,s]=t.useState(r),l=t.useRef(!1),c=t.useRef(null),d=t.useRef(0),u=t.useRef();return{contentRef:c,isAnimating:l.current,animateCollapse:t=>{var r,o;if(i!==t){switch(window.clearTimeout(u.current),l.current=!0,t){case!0:{const e=null!==(o=null===(r=c.current)||void 0===r?void 0:r.offsetHeight)&&void 0!==o?o:0;d.current=e,a(e),setTimeout((()=>{a(0)}),5);break}case!1:a(d.current||U(e,c))}s(!i),u.current=window.setTimeout((()=>{l.current=!1,t||a(void 0)}),n)}},maxHeight:o,collapsed:i}})(h,k,J),{pathString:ne,nodeData:re,path:oe,name:ae,size:ie,canEdit:se,canDelete:le,canAdd:ce,canDrag:de,error:ue,setError:pe,onError:ge,handleEditKey:me,derivedValues:he}=G({props:n,collapsed:ee}),{dragSourceProps:ye,getDropTargetProps:je,BottomDropTarget:be,DropTargetPadding:fe}=H({canDrag:de,canDragOnto:D,path:oe,nodeData:re,onMove:C,onError:ge,translate:V}),ve=t.useRef(!J);t.useEffect((()=>{$(K(h))}),[h]),t.useEffect((()=>{const e=w(re)&&!he.isEditing;ve.current=!e,te(e)}),[w]),t.useEffect((()=>{null!==c&&u(oe)&&(ve.current=!0,te(c.collapsed))}),[c]);const xe=t.useMemo((()=>e=>"function"!=typeof R?R:R(e)),[R]),{CustomNode:Ee,customNodeProps:De,CustomWrapper:we,wrapperProps:ke={},hideKey:Ce,showEditTools:Se=!0,showOnEdit:Oe,showOnView:Ne,showCollectionWrapper:Ae=!0}=t.useMemo((()=>L(I,re)),[]);if(!s("collection",re,O,N)&&re.level>0)return null;const Te=Array.isArray(h)?"array":"object",Pe="array"===Te?{open:"[",close:"]"}:{open:"{",close:"}"},Re=e=>{"Enter"===e.key&&(e.metaKey||e.shiftKey||e.ctrlKey)?Fe():"Escape"===e.key&&Me()},Ve=e=>{if(e.getModifierState("Alt"))return ve.current=!0,void d({collapsed:!ee,path:oe});p&&p.includes(ne)||(ve.current=!0,d(null),te(!ee))},Fe=()=>{try{const e=_(B);if(g(null),pe(null),JSON.stringify(e)===JSON.stringify(h))return;v(e,oe).then((t=>{t&&ge({code:"UPDATE_ERROR",message:t},e)}))}catch(e){ge({code:"INVALID_JSON",message:V("ERROR_INVALID_JSON",re)},B)}},ze=oe.length>0?()=>{E(h,oe).then((e=>{e&&ge({code:"DELETE_ERROR",message:e},r(h,oe))}))}:void 0,Me=()=>{g(null),pe(null),$(K(h))},{isEditing:Ie,isEditingKey:_e,isArray:Le,canEditKey:Ke}=he,Be="when-closed"===f?ee:f,We=!Ie&&Se,Ge=(P||!Le)&&!Ce&&void 0!==ae,He=Ee&&(Ie&&Oe||!Ie&&Ne),Ue=T&&"object"===Te,Ye=Object.entries(h).map((([e,t])=>["array"===Te?Number(e):e,t]));Ue&&Ye.sort("function"==typeof T?(e,t)=>T(e[0],t[0]):void 0);const $e=ve.current?Ie?e.jsx("div",{className:"jer-collection-text-edit",children:e.jsxs("div",{children:[e.jsx(a,{className:"jer-collection-text-area",name:ne,value:B,setValue:$,isEditing:Ie,handleKeyPress:Re,styles:l("input",re)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(M,{onOk:Fe,onCancel:Me,nodeData:re})})]})}):Ye.map((([t,r],o)=>{const a={key:t,value:r,path:[...oe,t],level:oe.length+1,index:o,size:i(r)?Object.keys(r).length:1,parentData:h,fullData:re.fullData};return e.jsx("div",{className:"jer-collection-element",style:l("collectionElement",a),children:i(r)?e.jsx(Z,Object.assign({},n,{data:r,parentData:h,nodeData:a,showCollectionCount:f,canDragOnto:se}),t):e.jsx(Y,Object.assign({},n,{data:r,parentData:h,nodeData:a,canDragOnto:se,showLabel:"object"===Te||P}),t)},t)})):null,Je=!!Ae&ⅇJe||(ve.current=!0);const Xe=Object.assign(Object.assign({},n),{data:h,value:h,parentData:b,nodeData:re,setValue:e=>o(void 0,void 0,void 0,(function*(){return yield v(e,oe)})),handleEdit:Fe,handleCancel:Me,handleKeyPress:Re,isEditing:Ie,setIsEditing:()=>g(ne),getStyles:l,canDragOnto:se}),Ze=He?e.jsx(Ee,Object.assign({customNodeProps:De},Xe,{children:$e})):$e,qe=_e?e.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:ne,defaultValue:ae,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?me(e.target.value):"Escape"===e.key&&Me()},style:{width:String(ae).length/1.5+.5+"em"}}):Ge&&e.jsx("span",{className:"jer-key-text",style:l("property",re),onClick:e=>e.stopPropagation(),onDoubleClick:()=>Ke&&g(`key_${ne}`),children:""===ae?e.jsx("span",{className:oe.length>0?"jer-empty-string":void 0}):`${ae}:`}),Qe=We&&e.jsx(z,{startEdit:se?()=>{ve.current=!0,g(ne)}:void 0,handleAdd:ce?e=>{te(!1);const t=xe(re);"array"===Te?x(t,[...oe,h.length]).then((e=>{e&&ge({code:"ADD_ERROR",message:e},t)})):e in h?ge({code:"KEY_EXISTS",message:V("ERROR_KEY_EXISTS",re)},e):x(t,[...oe,e]).then((e=>{e&&ge({code:"ADD_ERROR",message:e},t)}))}:void 0,handleDelete:le?ze:void 0,enableClipboard:S,type:Te,nodeData:re,translate:V,customButtons:n.customButtons}),et=e.jsxs("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===oe.length?0:A/2)+"em"},l("collection",re)),{position:"relative"}),draggable:de},ye,je("above"),{children:[e.jsx("div",{className:"jer-clickzone",style:{width:A/2+1+"em",zIndex:10+2*re.level},onClick:e=>Ve(e)}),!Ie&&be,e.jsx(fe,{position:"above",nodeData:re}),Ae?e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:e=>Ve(e),children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("div",{className:"jer-collapse-icon jer-accordion-icon"+(ee?" jer-rotate-90":""),style:{zIndex:11+2*re.level},onClick:e=>Ve(e),children:e.jsx(F,{name:"chevron",rotate:ee,nodeData:re})}),qe,!Ie&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:l("bracket",re),children:Pe.open})]}),!Ie&&Be&&e.jsx("div",{className:"jer-collection-item-count"+(Be?" jer-visible":" jer-hidden"),style:l("itemCount",re),children:1===ie?V("ITEM_SINGLE",Object.assign(Object.assign({},re),{size:1}),1):V("ITEMS_MULTIPLE",re,ie)}),e.jsx("div",{className:"jer-brackets"+(Je?" jer-visible":" jer-hidden"),style:l("bracket",re),children:Pe.close}),Qe]}):Ce?e.jsx(e.Fragment,{}):e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[qe,Qe]}),e.jsxs("div",{className:"jer-collection-inner",style:Object.assign({overflowY:Je||q?"clip":"visible",maxHeight:m(ne)?void 0:Q},l("collectionInner",re)),ref:X,children:[Ze,e.jsx("div",{className:Ie?"jer-collection-error-row":"jer-collection-error-row-edit",children:ue&&e.jsx("span",{className:"jer-error-slug",style:l("error",re),children:ue})}),!Ie&&Ae&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},l("bracket",re)),{marginLeft:(A<3?-1:A<6?-.5:0)+"em"}),children:Pe.close})]}),e.jsx(fe,{position:"below",nodeData:re})]}));return we?e.jsx(we,Object.assign({customNodeProps:ke},Xe,{children:et})):et},q={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"},Q=(e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}const a=r in e?e[r]:q[r];return void 0===o?a:null==a?void 0:a.replace("{{count}}",String(o))})(e,t,r,n,o);var ee=[],te=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,a="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var i=ee.indexOf(a);-1===i&&(i=ee.push(a)-1,te[i]={}),n=te[i]&&te[i][r]?te[i][r]:te[i][r]=s()}else n=s();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function s(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var i="prepend"===r?"afterbegin":"beforeend";return a.insertAdjacentElement(i,e),e}}(':root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-expand-transition-time:0.3s;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden,.jer-visible{transition:var(--jer-expand-transition-time)}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{display:flex;flex-wrap:wrap}.jer-collapse-icon{left:-1.2em;position:absolute;top:.35em}.jer-collection-inner{position:relative;transition:var(--jer-expand-transition-time)}.jer-collection-text-edit{align-items:flex-start;display:flex;flex-direction:column;gap:.3em}.jer-collection-text-area{font-family:inherit;font-size:.85em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em}.jer-collection-error-row{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-main-row{display:flex;gap:0}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap}.jer-hyperlink{text-decoration:underline}.jer-input-text{font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:transform var(--jer-expand-transition-time)}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-rotate-90{transform:rotate(-90deg)}.jer-accordion-icon,.jer-rotate-90{transition:transform var(--jer-expand-transition-time)}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string:after{content:"<empty string>:";font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #e0e0e0;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const ne=({data:n,setData:r,rootName:a="root",onUpdate:s=(()=>{}),onEdit:l=s,onDelete:c=s,onAdd:d=s,onChange:u,onError:p,showErrorMessages:g=!0,enableClipboard:m=!0,indent:h=2,collapse:y=!1,collapseAnimationTime:b=300,showCollectionCount:f=!0,restrictEdit:v=!1,restrictDelete:x=!1,restrictAdd:E=!1,restrictTypeSelection:D=!1,restrictDrag:w=!0,searchFilter:k,searchText:C,searchDebounceTime:S=350,keySort:O=!1,showArrayIndices:N=!0,showStringQuotes:A=!0,defaultValue:T=null,minWidth:P=250,maxWidth:R="min(600px, 90vw)",rootFontSize:V,stringTruncate:F=250,translations:z={},className:M,id:I,customText:_={},customNodeDefinitions:L=[],customButtons:K=[],jsonParse:B=JSON.parse,jsonStringify:W=(e=>JSON.stringify(e,null,2))})=>{const{getStyles:G}=j(),H=t.useCallback(oe(y),[y]),U=t.useCallback(Q(z,_),[z,_]),[$,J]=t.useState(C),[X,q]=(({setData:e,data:n})=>{const[r,o]=t.useState(e?void 0:n),a=t.useCallback((t=>{e?e(t):o(t)}),[e]);return t.useEffect((()=>{e||o(n)}),[n]),[e?n:r,a]})({setData:r,data:n}),ee=document.querySelector(":root"),te=getComputedStyle(document.documentElement).getPropertyValue("--jer-expand-transition-time");1e3*parseFloat(te)!==b&&(null==ee||ee.style.setProperty("--jer-expand-transition-time",b/1e3+"s")),t.useEffect((()=>{const e=setTimeout((()=>J(C)),S);return()=>clearTimeout(e)}),[C,S]);const ne={key:a,path:[],level:0,index:0,value:X,size:"object"==typeof X&&null!==X?Object.keys(X).length:1,parentData:null,fullData:X},se=(e,t)=>o(void 0,void 0,void 0,(function*(){const n=yield e(t);if(!0===n||void 0===n)return void q(t.newData);const r=ie(n)?n:["error",n],[o,a]=r;if("error"===o)return q(t.currentData),!1===a?U("ERROR_UPDATE",ne):String(a);q(a)})),le=t.useMemo((()=>oe(v)),[v]),ce=t.useMemo((()=>oe(x)),[x]),de=t.useMemo((()=>oe(E)),[E]),ue=t.useMemo((()=>oe(w)),[w]),pe=t.useMemo((()=>ae(k)),[k]),ge={name:a,nodeData:ne,onEdit:(e,t)=>o(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=re(X,t,e,"update");if(o!==a)return yield se(l,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onDelete:(e,t)=>o(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=re(X,t,e,"delete");return yield se(c,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onAdd:(e,t)=>o(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=re(X,t,e,"add");return yield se(d,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onChange:u,onError:p,showErrorMessages:g,onMove:(e,t,n)=>o(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:a}=re(X,e,"","delete"),i=e.slice(-1)[0],s=t.slice(0,-1),c=t.slice(-1)[0];let d="number"==typeof c?"above"===n?c:c+1:"number"==typeof i?`arr_${i}`:i;e.slice(0,-1).join(".")===t.slice(0,-1).join(".")&&"number"==typeof i&&"number"==typeof d&&i<d&&(d-=1);const u="number"==typeof d?{insert:!0}:"above"===n?{insertBefore:c}:{insertAfter:c},{newData:p,newValue:g}=re(o,[...s,d],a,"add",u);return yield se(l,{currentData:r,newData:p,currentValue:a,newValue:g,name:t.slice(-1)[0],path:t})})),showCollectionCount:f,collapseFilter:H,collapseAnimationTime:b,restrictEditFilter:le,restrictDeleteFilter:ce,restrictAddFilter:de,restrictTypeSelection:D,restrictDragFilter:ue,canDragOnto:!1,searchFilter:pe,searchText:$,enableClipboard:m,keySort:O,showArrayIndices:N,showStringQuotes:A,indent:h,defaultValue:T,stringTruncate:F,translate:U,customNodeDefinitions:L,customButtons:K,parentData:null,jsonParse:B,jsonStringify:W},me=Object.assign(Object.assign({},G("container",ne)),{minWidth:P,maxWidth:R});return me.fontSize=null!=V?V:me.fontSize,e.jsx("div",{id:I,className:"jer-editor-container "+M,style:me,children:i(X)?e.jsx(Z,Object.assign({data:X},ge)):e.jsx(Y,Object.assign({data:X,showLabel:!0},ge))})},re=(e,t,o,a,i={})=>{if(0===t.length)return{currentData:e,newData:o,currentValue:e,newValue:o};const s=Object.assign({remove:"delete"===a},i),l="add"!==a?r(e,t):void 0;return{currentData:e,newData:n(e,t,o,s),currentValue:l,newValue:"delete"!==a?o:void 0}},oe=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,ae=e=>{if(void 0!==e)return"value"===e?c:"key"===e?d:"all"===e?(e,t)=>c(e,t)||d(e,t):e},ie=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),se=({value:t,setIsEditing:n,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:()=>n(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&n(!0)},className:"jer-value-string jer-hyperlink",style:c,children:e.jsxs("a",{href:t,target:"_blank",rel:"noreferrer",style:{color:null!==(s=c.color)&&void 0!==s?s:void 0},children:['"',u(t,l),'"']})})},le={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:se,showOnView:!0,showOnEdit:!1};exports.assign=n,exports.extract=r,exports.IconAdd=O,exports.IconCancel=R,exports.IconChevron=V,exports.IconCopy=T,exports.IconDelete=A,exports.IconEdit=N,exports.IconOk=P,exports.JsonEditor=t=>e.jsx(y,{theme:t.theme,icons:t.icons,children:e.jsx(B,{children:e.jsx(ne,Object.assign({},t))})}),exports.LinkCustomComponent=se,exports.LinkCustomNodeDefinition=le,exports.isCollection=i,exports.matchNode=c,exports.matchNodeKey=d,exports.themes=g,exports.truncate=u;
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import React$1 from 'react';
|
|
3
2
|
export { default as assign } from 'object-property-assigner';
|
|
4
3
|
export { default as extract } from 'object-property-extractor';
|
|
@@ -248,10 +247,9 @@ declare const LinkCustomComponent: React$1.FC<CustomNodeProps<{
|
|
|
248
247
|
}>>;
|
|
249
248
|
declare const LinkCustomNodeDefinition: CustomNodeDefinition;
|
|
250
249
|
|
|
251
|
-
declare const
|
|
252
|
-
|
|
253
|
-
declare const isCollection: (value: unknown) => value is unknown[] | Record<string, unknown>;
|
|
250
|
+
declare const isCollection: (value: unknown) => value is Record<string, unknown> | unknown[];
|
|
254
251
|
declare const matchNode: (input: Partial<NodeData>, searchText: string) => boolean;
|
|
255
252
|
declare const matchNodeKey: SearchFilterFunction;
|
|
253
|
+
declare const truncate: (string: string, length?: number) => string;
|
|
256
254
|
|
|
257
|
-
export { CollectionNodeProps, CompareFunction, CopyFunction, CustomNodeDefinition, CustomNodeProps, CustomTextDefinitions, CustomTextFunction, DataType, DefaultValueFunction, FilterFunction, IconAdd, IconCancel, IconChevron, IconCopy, IconDelete, IconEdit, IconOk, IconReplacements, JerError, JsonData, JsonEditor, JsonEditorProps, LinkCustomComponent, LinkCustomNodeDefinition, LocalisedStrings, NodeData, OnChangeFunction, OnErrorFunction, SearchFilterFunction, Theme, ThemeInput, ThemeName, TranslateFunction, TypeFilterFunction, UpdateFunction, ValueNodeProps, isCollection, matchNode, matchNodeKey, themes, truncate };
|
|
255
|
+
export { CollectionNodeProps, CompareFunction, CopyFunction, CustomNodeDefinition, CustomNodeProps, CustomTextDefinitions, CustomTextFunction, DataType, DefaultValueFunction, FilterFunction, IconAdd, IconCancel, IconChevron, IconCopy, IconDelete, IconEdit, IconOk, IconReplacements, JerError, JsonData, JsonEditor, JsonEditorProps, LinkCustomComponent, LinkCustomNodeDefinition, LocalisedStrings, NodeData, OnChangeFunction, OnErrorFunction, SearchFilterFunction, Theme, ThemeInput, ThemeName, ThemeStyles, TranslateFunction, TypeFilterFunction, UpdateFunction, ValueNodeProps, isCollection, matchNode, matchNodeKey, themes, truncate };
|
package/build/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as n,Fragment as t}from"react/jsx-runtime";import{createContext as r,useContext as o,useEffect as a,useState as i,useMemo as l,useCallback as s,useRef as c}from"react";import d from"object-property-assigner";export{default as assign}from"object-property-assigner";import u from"object-property-extractor";export{default as extract}from"object-property-extractor";function p(e,n,t,r){return new(t||(t=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function l(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(i,l)}s((r=r.apply(e,n||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var g=[],m=[];!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 i=g.indexOf(a);-1===i&&(i=g.push(a)-1,m[i]={}),t=m[i]&&m[i][r]?m[i][r]:m[i][r]=l()}else t=l();65279===e.charCodeAt(0)&&(e=e.substring(1)),t.styleSheet?t.styleSheet.cssText+=e:t.appendChild(document.createTextNode(e))}function l(){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.3s;\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 transition: var(--jer-expand-transition-time);\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 h=({className:t,name:r,value:o,setValue:a,handleKeyPress:i,styles:l})=>{if("string"!=typeof o)return null;const s="\n"===o.slice(-1)?o+".":o;return e("div",{style:{display:"grid"},children:[n("textarea",{id:`${r}_textarea`,style:Object.assign({height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap"},l),rows:1,className:t,name:`${r}_textarea`,value:o,onChange:e=>a(e.target.value),autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:i}),n("span",{className:t,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"},l),children:s})]})},y={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"}}},b=y.default,f=r({getStyles:()=>({}),icons:{}}),v=({theme:e="default",icons:t={},children:r})=>{const o=E(e);return n(f.Provider,{value:{getStyles:(e,n)=>"function"==typeof o[e]?o[e](n):o[e],icons:t},children:r})},j=()=>o(f),E=e=>{var n,t,r,o;const a={},i=(Array.isArray(e)?e:[e]).map((n=>"default"===e?{}:"string"==typeof n?D(y[n],a):w(n)?D({fragments:{},styles:n},a):D(n,a))),l=D(b,{});Object.keys(l).forEach((e=>{const n=e;i.forEach((e=>{e[n]&&(l[n]=Object.assign(Object.assign({},l[n]),e[n]))}))}));const s=Object.assign({},l);return Object.entries(a).forEach((([e,n])=>{const t=e;s[t]=e=>{const r=n(e)||{};return Object.assign(Object.assign({},l[t]),r)}})),"function"!=typeof(null==s?void 0:s.inputHighlight)&&(null===(n=null==s?void 0:s.inputHighlight)||void 0===n?void 0:n.backgroundColor)&&document.documentElement.style.setProperty("--jer-highlight-color",null===(t=null==s?void 0:s.inputHighlight)||void 0===t?void 0:t.backgroundColor),"function"!=typeof(null==s?void 0:s.iconCopy)&&(null===(r=null==s?void 0:s.iconCopy)||void 0===r?void 0:r.color)&&document.documentElement.style.setProperty("--jer-icon-copy-color",null===(o=null==s?void 0:s.iconCopy)||void 0===o?void 0:o.color),s},D=(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),{[k[e]]:n}):Object.assign(Object.assign({},r),n)}return Object.assign(Object.assign({},r),o)}),{});o[e]=a})),o},w=e=>!("styles"in e),k={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"},C="**INVALID_FUNCTION**",O=(e,n=200)=>"string"==typeof e?e.length<n?e:`${e.slice(0,n-2).trim()}...`:e,S=e=>e.map((e=>""===e?String.fromCharCode(0):e)).join("."),N=({value:t,setValue:r,isEditing:o,path:a,setIsEditing:i,handleEdit:l,handleCancel:s,stringTruncate:c,showStringQuotes:d,nodeData:u})=>{const{getStyles:p}=j(),g=S(a),m=d?'"':"";return o?n(h,{className:"jer-input-text",name:g,value:t,setValue:r,isEditing:o,handleKeyPress:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&s():l()},styles:p("input",u)}):e("div",{id:`${g}_display`,onDoubleClick:()=>i(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&i(!0)},className:"jer-value-string",style:p("string",u),children:[m,O(t,c),m]})},x=({value:e,setValue:t,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:l,nodeData:s})=>{const{getStyles:c}=j();return r?n("input",{className:"jer-input-number",type:"text",name:S(o),value:e,onChange:e=>t(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:n=>{switch(n.key){case"Enter":i();break;case"Escape":l();break;case"ArrowUp":n.preventDefault(),t(Number(e)+1);break;case"ArrowDown":n.preventDefault(),t(Number(e)-1)}},style:Object.assign({width:String(e).length/1.5+2+"em"},c("input",s))}):n("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:c("number",s),children:e})},A=({value:e,setValue:t,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:l,nodeData:s})=>{const{getStyles:c}=j();return r?n("input",{className:"jer-input-boolean",type:"checkbox",name:S(o),checked:e,onChange:()=>t(!e),onKeyDown:e=>{"Enter"===e.key?i():"Escape"===e.key&&l()},autoFocus:!0}):n("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:c("boolean",s),children:String(e)})},T=({value:e,isEditing:t,setIsEditing:r,handleEdit:o,handleCancel:i,nodeData:l})=>{const{getStyles:s}=j();a((()=>(t&&document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c))),[t]);const c=e=>{"Enter"===e.key?o():"Escape"===e.key&&i()};return n("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:s("null",l),children:String(e)})},P=({value:e})=>{let t="Error!";switch(typeof e){case"string":e===C&&(t="Function");break;case"undefined":t="Undefined";break;case"symbol":t="Symbol"}return n("span",{className:"jer-value-invalid",children:t})},V=({size:t,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:o,style:r,children:[n("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),n("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"})]}),R=({size:t,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:o,style:r,transform:"translate(0, 0.5)",children:[n("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"}),n("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"})]}),F=({size:e,style:t,className:r})=>n("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:e,height:e,className:r,style:t,children:n("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"})}),z=({size:t,style:r,className:o})=>e("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:t,height:t,className:o,style:r,children:[n("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"}),n("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),n("path",{d:"M15 10l-4 4 4 4"})]}),_=({size:t,style:r,className:o})=>e("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:t,height:t,className:o,style:r,children:[n("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),n("path",{d:"M22 4L12 14.01l-3-3"})]}),I=({size:e,style:t,className:r})=>n("svg",{baseProfile:"tiny",viewBox:"0 0 24 24",fill:"currentColor",width:e,height:e,className:r,style:t,children:n("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"})}),L=({size:e,style:t,className:r})=>n("svg",{viewBox:"0 0 512 512",fill:"currentColor",width:e,height:e,className:r,style:t,children:n("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"})}),M=({name:e,nodeData:r,rotate:o})=>{var a,i,l,s,c,d,u;const{getStyles:p,icons:g}=j(),m={size:"1.4em",className:"jer-icon"};switch(e){case"add":return null!==(a=null==g?void 0:g.add)&&void 0!==a?a:n(V,Object.assign({},m,{style:p("iconAdd",r)}));case"edit":return null!==(i=null==g?void 0:g.edit)&&void 0!==i?i:n(R,Object.assign({},m,{style:p("iconEdit",r)}));case"delete":return null!==(l=null==g?void 0:g.delete)&&void 0!==l?l:n(F,Object.assign({},m,{style:p("iconDelete",r),size:"1.45em"}));case"copy":return null!==(s=null==g?void 0:g.copy)&&void 0!==s?s:n(z,Object.assign({},m,{style:p("iconCopy",r),size:"1.2em"}));case"ok":return null!==(c=null==g?void 0:g.ok)&&void 0!==c?c:n(_,Object.assign({},m,{style:Object.assign({fontSize:"90%"},p("iconOk",r))}));case"cancel":return null!==(d=null==g?void 0:g.cancel)&&void 0!==d?d:n(I,Object.assign({},m,{style:Object.assign({fontSize:"130%"},p("iconCancel",r))}));case"chevron":return null!==(u=null==g?void 0:g.chevron)&&void 0!==u?u:n(L,{size:"1em",style:p("iconCollection",r)});default:return n(t,{})}},K=({startEdit:r,handleDelete:o,handleAdd:a,enableClipboard:l,type:s,customButtons:c,nodeData:d,translate:u})=>{const{getStyles:p}=j(),g=u("KEY_NEW",d),[m,h]=i(!1),[y,b]=i(g),{key:f,path:v,value:E}=d;return e("div",{className:"jer-edit-buttons",style:{opacity:m?1:void 0},children:[l&&n("div",{onClick:e=>{let n,t="value",r="";if(l){if(!0===(e.ctrlKey||e.metaKey))n=W(v),r=n,t="path";else n=E,r=s?JSON.stringify(E,null,2):String(n);navigator.clipboard.writeText(r)}"function"==typeof l&&l({value:n,stringValue:r,path:v,key:f,type:t})},className:"jer-copy-pulse",children:n(M,{name:"copy",nodeData:d})}),r&&n("div",{onClick:r,children:n(M,{name:"edit",nodeData:d})}),o&&n("div",{onClick:o,children:n(M,{name:"delete",nodeData:d})}),a&&n("div",{onClick:()=>{"object"===s?h(!0):a("")},children:n(M,{name:"add",nodeData:d})}),null==c?void 0:c.map((({Element:e,onClick:t},r)=>n("div",{onClick:e=>t(d,e),children:n(e,{})},r))),m&&a&&"object"===s&&e(t,{children:[n("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:y,onChange:e=>b(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key&&a?(h(!1),a(y),b(g)):"Escape"===e.key&&(h(!1),b(g))},style:p("input",d)}),n(B,{onOk:()=>{y&&(h(!1),a(y))},onCancel:()=>{h(!1)},nodeData:d})]})]})},B=({onOk:t,onCancel:r,nodeData:o})=>e("div",{className:"jer-confirm-buttons",children:[n("div",{onClick:t,children:n(M,{name:"ok",nodeData:o})}),n("div",{onClick:r,children:n(M,{name:"cancel",nodeData:o})})]}),W=e=>e.reduce(((e,n)=>"number"==typeof n?`${e}[${n}]`:""===e?n:`${e}.${n}`),""),G=["string","number","boolean","null","object","array"],H=(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:l,hideKey:s=!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:l,hideKey:s,showEditTools:c,showOnEdit:d,showOnView:u,showCollectionWrapper:p},g)},U=e=>null!==e&&"object"==typeof e,Y=(e,n,t,r="")=>{if(!t&&!r)return!0;switch(e){case"collection":if(t){if(t(n,r))return!0;if(!$(r,n,t))return!1}if(!t&&r&&!$(r,n))return!1;break;case"value":if(t&&!t(n,r))return!1;if(!t&&r&&!J(n,r))return!1}return!0},$=(e="",n,t=J)=>{const r=n.value;return Object.entries(r).some((([o,a])=>{const i=[...n.path,o],l=Object.assign(Object.assign({},n),{key:o,path:i,level:n.level+1,value:a,size:i.length,parentData:r});return U(a)?$(e,l,t):t(l,e)}))},J=(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}},X=({key:e,path:n},t="")=>!!J({value:e},t)||!!n.some((e=>J({value:e},t))),Z=r({collapseState:null,setCollapseState:()=>{},doesPathMatch:()=>!1,currentlyEditingElement:null,setCurrentlyEditingElement:()=>{},areChildrenBeingEdited:()=>!1,dragSource:{path:null,pathString:null},setDragSource:()=>{}}),Q=({children:e})=>{const[t,r]=i(null),[o,a]=i(null),[l,s]=i({path:null,pathString:null});return n(Z.Provider,{value:{collapseState:t,setCollapseState:e=>{r(e),null!==e&&setTimeout((()=>r(null)),2e3)},doesPathMatch:e=>{if(null===t)return!1;for(const[n,r]of t.path.entries())if(r!==e[n])return!1;return!0},currentlyEditingElement:o,setCurrentlyEditingElement:a,areChildrenBeingEdited:e=>null!==o&&o.includes(e),dragSource:l,setDragSource:s},children:e})},q=()=>o(Z),ee=({props:e,collapsed:n})=>{const{data:t,nodeData:r,parentData:o,onEdit:a,onError:s,showErrorMessages:c,restrictEditFilter:d,restrictDeleteFilter:u,restrictAddFilter:p,restrictDragFilter:g,translate:m}=e,{currentlyEditingElement:h,setCurrentlyEditingElement:y}=q(),[b,f]=i(null),v=Object.assign(Object.assign({},r),{collapsed:n}),{path:j,key:E,size:D}=v,w=S(j),k=l((()=>!d(v)),[v]),C=l((()=>!u(v)),[v]),O=l((()=>!p(v)),[v]),N=l((()=>!g(v)&&C&&null===h),[v]),x=e=>{c&&(f(e),setTimeout((()=>f(null)),2500)),console.warn("Error",e)},A=l((()=>(e,n)=>{x(e.message),s&&s({currentData:v.fullData,errorValue:n,currentValue:t,name:E,path:j,error:e})}),[s,c]),T=h===w,P=h===`key_${w}`,V="number"==typeof j.slice(-1)[0];return{pathString:w,nodeData:v,path:j,name:E,size:D,canEdit:k,canDelete:C,canAdd:O,canDrag:N,error:b,showError:x,onError:A,setError:f,handleEditKey:e=>{if(y(null),E===e)return;if(!o)return;const n=j.slice(0,-1);if(Object.keys(o).includes(e))return void A({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",v)},e);const t=Object.fromEntries(Object.entries(o).map((([n,t])=>n===E?[e,t]:[n,t])));a(t,n).then((n=>{n&&A({code:"UPDATE_ERROR",message:n},e)}))},derivedValues:{isEditing:T,isEditingKey:P,isArray:V,canEditKey:null!==o&&k&&O&&C&&!V}}},ne=({canDrag:e,canDragOnto:t,path:r,nodeData:o,onMove:a,onError:s,translate:c})=>{const{getStyles:d}=j(),{dragSource:u,setDragSource:p}=q(),[g,m]=i(!1),h=S(r),y=l((()=>e?{onDragStart:e=>{e.stopPropagation(),p({path:r,pathString:h})},onDragEnd:e=>{e.stopPropagation(),p({path:null,pathString:null})}}:{}),[e]),b=l((()=>e=>t?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:n=>{n.stopPropagation(),v(e),p({path:null,pathString:null}),m(!1)},onDragEnter:n=>{var t;n.stopPropagation(),h.startsWith(null!==(t=u.pathString)&&void 0!==t?t:"")||m(e)},onDragExit:e=>{e.stopPropagation(),m(!1)}}:{}),[u,t]),f=l((()=>t&&null!==u.pathString?n("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:r.length}},b("below"))):null),[u,t]),v=e=>{var n,t;const i=null===(n=u.path)||void 0===n?void 0:n.slice(-1)[0],l=null===(t=u.path)||void 0===t?void 0:t.slice(0,-1).join("."),d=r.slice(0,-1).join(""),{parentData:p}=o;"string"==typeof i&&p&&!Array.isArray(p)&&Object.keys(p).includes(i)&&i in p&&l!==d?s({code:"KEY_EXISTS",message:c("ERROR_KEY_EXISTS",o)},i):a(u.path,r,e).then((e=>{e&&s({code:"UPDATE_ERROR",message:e},o.value)}))};return{dragSourceProps:y,getDropTargetProps:b,BottomDropTarget:f,DropTargetPadding:({position:e,nodeData:t})=>g===e?n("div",{className:"jer-drag-n-drop-padding",style:d("dropZone",t)}):null,handleDrop:v}},te=(e,n)=>{var t,r;const o=document.getElementsByClassName("jer-editor-container"),a=parseInt(o.length>0?getComputedStyle(o[0]).getPropertyValue("line-height"):"16px"),i=(null!==(r=null===(t=n.current)||void 0===t?void 0:t.offsetWidth)&&void 0!==r?r:0)/(.5*a),l=JSON.stringify(e,null,2).replace(/\\n/g,"\n").split("\n").map((e=>Math.ceil(e.length/i))).reduce(((e,n)=>e+n),0)*a;return Math.min(l+30,window.innerHeight-50)},re=t=>{const{data:r,parentData:o,onEdit:c,onDelete:d,onChange:u,onMove:p,enableClipboard:g,canDragOnto:m,restrictTypeSelection:h,searchFilter:y,searchText:b,showLabel:f,stringTruncate:v,showStringQuotes:E,indent:D,translate:w,customNodeDefinitions:k}=t,{getStyles:O}=j(),{setCurrentlyEditingElement:S,setCollapseState:N}=q(),[x,A]=i("function"==typeof r?C:r),{pathString:T,nodeData:P,path:V,name:R,canEdit:F,canDelete:z,canDrag:_,error:I,onError:L,handleEditKey:M,derivedValues:W}=ee({props:t}),{dragSourceProps:U,getDropTargetProps:$,BottomDropTarget:J,DropTargetPadding:X}=ne({canDrag:_,canDragOnto:m,path:V,nodeData:P,onMove:p,onError:L,translate:w}),Z=H(k,P),[Q,te]=i(oe(r,Z)),re=s((e=>{if(!u)return void A(e);const n=u({currentData:P.fullData,newValue:e,currentValue:x,name:R,path:V});A(n)}),[u]);a((()=>{A("function"==typeof r?C:r),te(oe(r,Z))}),[r,I]);const{CustomNode:le,customNodeProps:se,hideKey:ce,showEditTools:de=!0,showOnEdit:ue,showOnView:pe}=Z,ge=[...G,...k.filter((({showInTypesSelector:e=!1,name:n})=>e&&!!n)).map((({name:e})=>e))],me=l((()=>{if("boolean"==typeof h)return h?[]:ge;if(Array.isArray(h))return h;const e=h(P);return"boolean"==typeof e?e?[]:ge:e}),[P,h]);if(!Y("value",P,y,b))return null;const he=()=>{let e;switch(S(null),Q){case"object":e={[w("DEFAULT_NEW_KEY",P)]:x};break;case"array":e=null!=x?x:[];break;case"number":{const n=Number(x);e=isNaN(n)?0:n;break}default:e=x}c(e,V).then((n=>{n&&L({code:"UPDATE_ERROR",message:n},e)}))},ye=()=>{S(null),A(r),te(oe(r,Z))},{isEditing:be,isEditingKey:fe,canEditKey:ve}=W,je=!be&&I,Ee=be&&me.length>0,De="invalid"!==Q&&!I&&de,we=f&&fe,ke=f&&!fe&&!ce,Ce={value:x,parentData:o,setValue:re,isEditing:be,setIsEditing:F?()=>S(T):()=>{},handleEdit:he,handleCancel:ye,path:V,stringTruncate:v,showStringQuotes:E,nodeData:P,translate:w},Oe=le&&(be&&ue||!be&&pe)?n(le,Object.assign({},t,{value:x,customNodeProps:se,setValue:re,handleEdit:he,handleCancel:ye,handleKeyPress:e=>{"Enter"===e.key?he():"Escape"===e.key&&ye()},isEditing:be,setIsEditing:()=>S(T),getStyles:O})):ae(oe(r),Ce);return e("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:D/2+"em",position:"relative"},draggable:_},U,$("above"),{children:[J,n(X,{position:"above",nodeData:P}),e("div",{className:"jer-value-main-row",style:{flexWrap:R.length>10?"wrap":"nowrap"},children:[ke&&n("span",{className:"jer-key-text",style:Object.assign(Object.assign({},O("property",P)),{minWidth:`${Math.min(String(R).length+1,5)}ch`,flexShrink:R.length>10?1:0}),onDoubleClick:()=>ve&&S(`key_${T}`),children:""===R?n("span",{className:V.length>0?"jer-empty-string":void 0}):`${R}:`}),we&&n("input",{className:"jer-input-text jer-key-edit",type:"text",name:T,defaultValue:R,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?M(e.target.value):"Escape"===e.key&&ye()},style:{width:String(R).length/1.5+.5+"em"}}),e("div",{className:"jer-value-and-buttons",children:[n("div",{className:"jer-input-component",children:Oe}),be?n(B,{onOk:he,onCancel:ye,nodeData:P}):De&&n(K,{startEdit:F?()=>S(T):void 0,handleDelete:z?()=>{d(x,V).then((e=>{e&&L({code:"DELETE_ERROR",message:e},x)}))}:void 0,enableClipboard:g,translate:w,customButtons:t.customButtons,nodeData:P}),Ee&&e("div",{className:"jer-select",children:[n("select",{name:`${R}-type-select`,className:"jer-type-select",onChange:e=>(e=>{const n=k.find((n=>n.name===e));if(n)c(n.defaultValue,V),te(e),S(null),N({path:V,collapsed:!1});else{const n=ie(x,e,w("DEFAULT_NEW_KEY",P),(null==Z?void 0:Z.CustomNode)?w("DEFAULT_STRING",P):void 0);re(n),c(n,V).then((e=>{e&&(L({code:"UPDATE_ERROR",message:e},n),S(null))}))}})(e.target.value),value:Q,children:me.map((e=>n("option",{value:e,children:e},e)))}),n("span",{className:"focus"})]}),je&&n("span",{className:"jer-error-slug",style:O("error",P),children:I})]})]}),n(X,{position:"below",nodeData:P})]}))},oe=(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",ae=(e,t)=>{const r=t.value;switch(e){case"string":return n(N,Object.assign({},t,{value:r}));case"number":return n(x,Object.assign({},t,{value:r}));case"boolean":return n(A,Object.assign({},t,{value:r}));case"null":return n(T,Object.assign({},t));default:return n(P,Object.assign({},t))}},ie=(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)}},le=r=>{const{getStyles:o}=j(),{collapseState:s,setCollapseState:d,doesPathMatch:g,currentlyEditingElement:m,setCurrentlyEditingElement:y,areChildrenBeingEdited:b}=q(),{data:f,nodeData:v,parentData:E,showCollectionCount:D,onEdit:w,onAdd:k,onDelete:C,canDragOnto:O,collapseFilter:S,collapseAnimationTime:N,onMove:x,enableClipboard:A,searchFilter:T,searchText:P,indent:V,keySort:R,showArrayIndices:F,defaultValue:z,translate:_,customNodeDefinitions:I,jsonParse:L,jsonStringify:W}=r,[G,$]=i(W(f)),J=S(v),{contentRef:X,isAnimating:Z,maxHeight:Q,collapsed:oe,animateCollapse:ae}=((e,n,t)=>{const[r,o]=i(t?0:void 0),[a,l]=i(t),s=c(!1),d=c(null),u=c(0),p=c();return{contentRef:d,isAnimating:s.current,animateCollapse:t=>{var r,i;if(a!==t){switch(window.clearTimeout(p.current),s.current=!0,t){case!0:{const e=null!==(i=null===(r=d.current)||void 0===r?void 0:r.offsetHeight)&&void 0!==i?i:0;u.current=e,o(e),setTimeout((()=>{o(0)}),5);break}case!1:o(u.current||te(e,d))}l(!a),p.current=window.setTimeout((()=>{s.current=!1,t||o(void 0)}),n)}},maxHeight:r,collapsed:a}})(f,N,J),{pathString:ie,nodeData:se,path:ce,name:de,size:ue,canEdit:pe,canDelete:ge,canAdd:me,canDrag:he,error:ye,setError:be,onError:fe,handleEditKey:ve,derivedValues:je}=ee({props:r,collapsed:oe}),{dragSourceProps:Ee,getDropTargetProps:De,BottomDropTarget:we,DropTargetPadding:ke}=ne({canDrag:he,canDragOnto:O,path:ce,nodeData:se,onMove:x,onError:fe,translate:_}),Ce=c(!J);a((()=>{$(W(f))}),[f]),a((()=>{const e=S(se)&&!je.isEditing;Ce.current=!e,ae(e)}),[S]),a((()=>{null!==s&&g(ce)&&(Ce.current=!0,ae(s.collapsed))}),[s]);const Oe=l((()=>e=>"function"!=typeof z?z:z(e)),[z]),{CustomNode:Se,customNodeProps:Ne,CustomWrapper:xe,wrapperProps:Ae={},hideKey:Te,showEditTools:Pe=!0,showOnEdit:Ve,showOnView:Re,showCollectionWrapper:Fe=!0}=l((()=>H(I,se)),[]);if(!Y("collection",se,T,P)&&se.level>0)return null;const ze=Array.isArray(f)?"array":"object",_e="array"===ze?{open:"[",close:"]"}:{open:"{",close:"}"},Ie=e=>{"Enter"===e.key&&(e.metaKey||e.shiftKey||e.ctrlKey)?Le():"Escape"===e.key&&Ke()},Le=()=>{try{const e=L(G);if(y(null),be(null),JSON.stringify(e)===JSON.stringify(f))return;w(e,ce).then((n=>{n&&fe({code:"UPDATE_ERROR",message:n},e)}))}catch(e){fe({code:"INVALID_JSON",message:_("ERROR_INVALID_JSON",se)},G)}},Me=ce.length>0?()=>{C(f,ce).then((e=>{e&&fe({code:"DELETE_ERROR",message:e},u(f,ce))}))}:void 0,Ke=()=>{y(null),be(null),$(W(f))},{isEditing:Be,isEditingKey:We,isArray:Ge,canEditKey:He}=je,Ue="when-closed"===D?oe:D,Ye=!Be&&Pe,$e=(F||!Ge)&&!Te&&void 0!==de,Je=Se&&(Be&&Ve||!Be&&Re),Xe=R&&"object"===ze,Ze=Object.entries(f).map((([e,n])=>["array"===ze?Number(e):e,n]));Xe&&Ze.sort("function"==typeof R?(e,n)=>R(e[0],n[0]):void 0);const Qe=Ce.current?Be?n("div",{className:"jer-collection-text-edit",children:e("div",{children:[n(h,{className:"jer-collection-text-area",name:ie,value:G,setValue:$,isEditing:Be,handleKeyPress:Ie,styles:o("input",se)}),n("div",{className:"jer-collection-input-button-row",children:n(B,{onOk:Le,onCancel:Ke,nodeData:se})})]})}):Ze.map((([e,t],a)=>{const i={key:e,value:t,path:[...ce,e],level:ce.length+1,index:a,size:U(t)?Object.keys(t).length:1,parentData:f,fullData:se.fullData};return n("div",{className:"jer-collection-element",style:o("collectionElement",i),children:U(t)?n(le,Object.assign({},r,{data:t,parentData:f,nodeData:i,showCollectionCount:D,canDragOnto:pe}),e):n(re,Object.assign({},r,{data:t,parentData:f,nodeData:i,canDragOnto:pe,showLabel:"object"===ze||F}),e)},e)})):null,qe=!!Fe&&oe;qe||(Ce.current=!0);const en=Object.assign(Object.assign({},r),{data:f,value:f,parentData:E,nodeData:se,setValue:e=>p(void 0,void 0,void 0,(function*(){return yield w(e,ce)})),handleEdit:Le,handleCancel:Ke,handleKeyPress:Ie,isEditing:Be,setIsEditing:()=>y(ie),getStyles:o,canDragOnto:pe}),nn=Je?n(Se,Object.assign({customNodeProps:Ne},en,{children:Qe})):Qe,tn=We?n("input",{className:"jer-input-text jer-key-edit",type:"text",name:ie,defaultValue:de,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?ve(e.target.value):"Escape"===e.key&&Ke()},style:{width:String(de).length/1.5+.5+"em"}}):$e&&n("span",{className:"jer-key-text",style:o("property",se),onDoubleClick:()=>He&&y(`key_${ie}`),children:""===de?n("span",{className:ce.length>0?"jer-empty-string":void 0}):`${de}:`}),rn=Ye&&n(K,{startEdit:pe?()=>{Ce.current=!0,y(ie)}:void 0,handleAdd:me?e=>{ae(!1);const n=Oe(se);"array"===ze?k(n,[...ce,f.length]).then((e=>{e&&fe({code:"ADD_ERROR",message:e},n)})):e in f?fe({code:"KEY_EXISTS",message:_("ERROR_KEY_EXISTS",se)},e):k(n,[...ce,e]).then((e=>{e&&fe({code:"ADD_ERROR",message:e},n)}))}:void 0,handleDelete:ge?Me:void 0,enableClipboard:A,type:ze,nodeData:se,translate:_,customButtons:r.customButtons}),on=e("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===ce.length?0:V/2)+"em"},o("collection",se)),{position:"relative"}),draggable:he},Ee,De("above"),{children:[!Be&&we,n(ke,{position:"above",nodeData:se}),Fe?e("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[e("div",{className:"jer-collection-name",children:[n("div",{className:"jer-collapse-icon jer-accordion-icon"+(oe?" jer-rotate-90":""),onClick:e=>(e=>{if(e.getModifierState("Alt"))return Ce.current=!0,void d({collapsed:!oe,path:ce});m&&m.includes(ie)||(Ce.current=!0,d(null),ae(!oe))})(e),children:n(M,{name:"chevron",rotate:oe,nodeData:se})}),tn,!Be&&n("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",se),children:_e.open})]}),!Be&&Ue&&n("div",{className:"jer-collection-item-count"+(Ue?" jer-visible":" jer-hidden"),style:o("itemCount",se),children:1===ue?_("ITEM_SINGLE",Object.assign(Object.assign({},se),{size:1}),1):_("ITEMS_MULTIPLE",se,ue)}),n("div",{className:"jer-brackets"+(qe?" jer-visible":" jer-hidden"),style:o("bracket",se),children:_e.close}),rn]}):Te?n(t,{}):e("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[tn,rn]}),e("div",{className:"jer-collection-inner",style:Object.assign({overflowY:qe||Z?"clip":"visible",maxHeight:b(ie)?void 0:Q},o("collectionInner",se)),ref:X,children:[nn,n("div",{className:Be?"jer-collection-error-row":"jer-collection-error-row-edit",children:ye&&n("span",{className:"jer-error-slug",style:o("error",se),children:ye})}),!Be&&Fe&&n("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},o("bracket",se)),{marginLeft:(V<3?-1:V<6?-.5:0)+"em"}),children:_e.close})]}),n(ke,{position:"below",nodeData:se})]}));return xe?n(xe,Object.assign({customNodeProps:Ae},en,{children:on})):on},se={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"},ce=(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]:se[r];return void 0===o?a:null==a?void 0:a.replace("{{count}}",String(o))})(e,n,r,t,o),de=({data:e,setData:t,rootName:r="root",onUpdate:o=(()=>{}),onEdit:c=o,onDelete:d=o,onAdd:u=o,onChange:g,onError:m,showErrorMessages:h=!0,enableClipboard:y=!0,indent:b=2,collapse:f=!1,collapseAnimationTime:v=300,showCollectionCount:E=!0,restrictEdit:D=!1,restrictDelete:w=!1,restrictAdd:k=!1,restrictTypeSelection:C=!1,restrictDrag:O=!0,searchFilter:S,searchText:N,searchDebounceTime:x=350,keySort:A=!1,showArrayIndices:T=!0,showStringQuotes:P=!0,defaultValue:V=null,minWidth:R=250,maxWidth:F="min(600px, 90vw)",rootFontSize:z,stringTruncate:_=250,translations:I={},className:L,id:M,customText:K={},customNodeDefinitions:B=[],customButtons:W=[],jsonParse:G=JSON.parse,jsonStringify:H=(e=>JSON.stringify(e,null,2))})=>{const{getStyles:Y}=j(),$=s(ge(f),[f]),J=s(ce(I,K),[I,K]),[X,Z]=i(N),[Q,q]=(({setData:e,data:n})=>{const[t,r]=i(e?void 0:n),o=s((n=>{e?e(n):r(n)}),[e]);return a((()=>{e||r(n)}),[n]),[e?n:t,o]})({setData:t,data:e}),ee=document.querySelector(":root"),ne=getComputedStyle(document.documentElement).getPropertyValue("--jer-expand-transition-time");1e3*parseFloat(ne)!==v&&(null==ee||ee.style.setProperty("--jer-expand-transition-time",v/1e3+"s")),a((()=>{const e=setTimeout((()=>Z(N)),x);return()=>clearTimeout(e)}),[N,x]);const te={key:r,path:[],level:0,index:0,value:Q,size:"object"==typeof Q&&null!==Q?Object.keys(Q).length:1,parentData:null,fullData:Q},oe=(e,n)=>p(void 0,void 0,void 0,(function*(){const t=yield e(n);if(!0===t||void 0===t)return void q(n.newData);const r=he(t)?t:["error",t],[o,a]=r;if("error"===o)return q(n.currentData),!1===a?J("ERROR_UPDATE",te):String(a);q(a)})),ae=l((()=>ge(D)),[D]),ie=l((()=>ge(w)),[w]),se=l((()=>ge(k)),[k]),de=l((()=>ge(O)),[O]),ue=l((()=>me(S)),[S]),ye={name:r,nodeData:te,onEdit:(e,n)=>p(void 0,void 0,void 0,(function*(){const{currentData:t,newData:r,currentValue:o,newValue:a}=pe(Q,n,e,"update");if(o!==a)return yield oe(c,{currentData:t,newData:r,currentValue:o,newValue:a,name:n.slice(-1)[0],path:n})})),onDelete:(e,n)=>p(void 0,void 0,void 0,(function*(){const{currentData:t,newData:r,currentValue:o,newValue:a}=pe(Q,n,e,"delete");return yield oe(d,{currentData:t,newData:r,currentValue:o,newValue:a,name:n.slice(-1)[0],path:n})})),onAdd:(e,n)=>p(void 0,void 0,void 0,(function*(){const{currentData:t,newData:r,currentValue:o,newValue:a}=pe(Q,n,e,"add");return yield oe(u,{currentData:t,newData:r,currentValue:o,newValue:a,name:n.slice(-1)[0],path:n})})),onChange:g,onError:m,showErrorMessages:h,onMove:(e,n,t)=>p(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:a}=pe(Q,e,"","delete"),i=e.slice(-1)[0],l=n.slice(0,-1),s=n.slice(-1)[0];let d="number"==typeof s?"above"===t?s:s+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:s}:{insertAfter:s},{newData:p,newValue:g}=pe(o,[...l,d],a,"add",u);return yield oe(c,{currentData:r,newData:p,currentValue:a,newValue:g,name:n.slice(-1)[0],path:n})})),showCollectionCount:E,collapseFilter:$,collapseAnimationTime:v,restrictEditFilter:ae,restrictDeleteFilter:ie,restrictAddFilter:se,restrictTypeSelection:C,restrictDragFilter:de,canDragOnto:!1,searchFilter:ue,searchText:X,enableClipboard:y,keySort:A,showArrayIndices:T,showStringQuotes:P,indent:b,defaultValue:V,stringTruncate:_,translate:J,customNodeDefinitions:B,customButtons:W,parentData:null,jsonParse:G,jsonStringify:H},be=Object.assign(Object.assign({},Y("container",te)),{minWidth:R,maxWidth:F});return be.fontSize=null!=z?z:be.fontSize,n("div",{id:M,className:"jer-editor-container "+L,style:be,children:U(Q)?n(le,Object.assign({data:Q},ye)):n(re,Object.assign({data:Q,showLabel:!0},ye))})},ue=e=>n(v,{theme:e.theme,icons:e.icons,children:n(Q,{children:n(de,Object.assign({},e))})}),pe=(e,n,t,r,o={})=>{if(0===n.length)return{currentData:e,newData:t,currentValue:e,newValue:t};const a=Object.assign({remove:"delete"===r},o),i="add"!==r?u(e,n):void 0;return{currentData:e,newData:d(e,n,t,a),currentValue:i,newValue:"delete"!==r?t:void 0}},ge=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:n})=>n>=e:e,me=e=>{if(void 0!==e)return"value"===e?J:"key"===e?X:"all"===e?(e,n)=>J(e,n)||X(e,n):e},he=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),ye=({value:t,setIsEditing:r,getStyles:o,customNodeProps:a,nodeData:i})=>{var l,s;const c=null!==(l=null==a?void 0:a.stringTruncate)&&void 0!==l?l:100,d=o("string",i);return n("div",{onDoubleClick:()=>r(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&r(!0)},className:"jer-value-string jer-hyperlink",style:d,children:e("a",{href:t,target:"_blank",rel:"noreferrer",style:{color:null!==(s=d.color)&&void 0!==s?s:void 0},children:['"',O(t,c),'"']})})},be={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:ye,showOnView:!0,showOnEdit:!1};export{V as IconAdd,I as IconCancel,L as IconChevron,z as IconCopy,F as IconDelete,R as IconEdit,_ as IconOk,ue as JsonEditor,ye as LinkCustomComponent,be as LinkCustomNodeDefinition,U as isCollection,J as matchNode,X as matchNodeKey,y as themes,O as truncate};
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{createContext as r,useContext as o,useEffect as a,useState as i,useMemo as l,useCallback as s,useRef as c}from"react";import d from"object-property-assigner";export{default as assign}from"object-property-assigner";import u from"object-property-extractor";export{default as extract}from"object-property-extractor";function p(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function l(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,l)}s((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const g=({className:n,name:r,value:o,setValue:a,handleKeyPress:i,styles:l})=>{if("string"!=typeof o)return null;const s="\n"===o.slice(-1)?o+".":o;return e("div",{style:{display:"grid"},children:[t("textarea",{id:`${r}_textarea`,style:Object.assign({height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap"},l),rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>a(e.target.value),autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:i}),t("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"},l),children:s})]})},h=e=>null!==e&&"object"==typeof e,m=(e,t,n,r="")=>{if(!n&&!r)return!0;switch(e){case"collection":if(n){if(n(t,r))return!0;if(!y(r,t,n))return!1}if(!n&&r&&!y(r,t))return!1;break;case"value":if(n&&!n(t,r))return!1;if(!n&&r&&!b(t,r))return!1}return!0},y=(e="",t,n=b)=>{const r=t.value;return Object.entries(r).some((([o,a])=>{const i=[...t.path,o],l=Object.assign(Object.assign({},t),{key:o,path:i,level:t.level+1,value:a,size:i.length,parentData:r});return h(a)?y(e,l,n):n(l,e)}))},b=(e,t="")=>{const{value:n}=e;if(null===n&&"null".includes(t.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(t.toLowerCase());case"number":return!!String(n).includes(t);case"boolean":return n?"true".includes(t.toLowerCase())||"1"===t:"false".includes(t.toLowerCase())||"0"===t;default:return!1}},f=({key:e,path:t},n="")=>!!b({value:e},n)||!!t.some((e=>b({value:e},n))),v=(e,t=200)=>"string"==typeof e?e.length<t?e:`${e.slice(0,t-2).trim()}...`:e,j=e=>e.map((e=>""===e?String.fromCharCode(0):e)).join("."),E={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=E.default,w=r({getStyles:()=>({}),icons:{}}),k=({theme:e="default",icons:n={},children:r})=>{const o=O(e);return t(w.Provider,{value:{getStyles:(e,t)=>"function"==typeof o[e]?o[e](t):o[e],icons:n},children:r})},C=()=>o(w),O=e=>{var t,n,r,o;const a={},i=(Array.isArray(e)?e:[e]).map((t=>"default"===e?{}:"string"==typeof t?S(E[t],a):N(t)?S({fragments:{},styles:t},a):S(t,a))),l=S(D,{});Object.keys(l).forEach((e=>{const t=e;i.forEach((e=>{e[t]&&(l[t]=Object.assign(Object.assign({},l[t]),e[t]))}))}));const s=Object.assign({},l);return Object.entries(a).forEach((([e,t])=>{const n=e;s[n]=e=>{const r=t(e)||{};return Object.assign(Object.assign({},l[n]),r)}})),"function"!=typeof(null==s?void 0:s.inputHighlight)&&(null===(t=null==s?void 0:s.inputHighlight)||void 0===t?void 0:t.backgroundColor)&&document.documentElement.style.setProperty("--jer-highlight-color",null===(n=null==s?void 0:s.inputHighlight)||void 0===n?void 0:n.backgroundColor),"function"!=typeof(null==s?void 0:s.iconCopy)&&(null===(r=null==s?void 0:s.iconCopy)||void 0===r?void 0:r.color)&&document.documentElement.style.setProperty("--jer-icon-copy-color",null===(o=null==s?void 0:s.iconCopy)||void 0===o?void 0:o.color),s},S=(e,t)=>{const{fragments:n,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 t[e]=o,Object.assign({},r);if("string"==typeof o){const t=null!==(a=null==n?void 0:n[o])&&void 0!==a?a:o;return"string"==typeof t?Object.assign(Object.assign({},r),{[x[e]]:t}):Object.assign(Object.assign({},r),t)}return Object.assign(Object.assign({},r),o)}),{});o[e]=a})),o},N=e=>!("styles"in e),x={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"},A="**INVALID_FUNCTION**",T=({value:n,setValue:r,isEditing:o,path:a,setIsEditing:i,handleEdit:l,handleCancel:s,stringTruncate:c,showStringQuotes:d,nodeData:u})=>{const{getStyles:p}=C(),h=j(a),m=d?'"':"";return o?t(g,{className:"jer-input-text",name:h,value:n,setValue:r,isEditing:o,handleKeyPress:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&s():l()},styles:p("input",u)}):e("div",{id:`${h}_display`,onDoubleClick:()=>i(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&i(!0)},className:"jer-value-string",style:p("string",u),children:[m,v(n,c),m]})},P=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:l,nodeData:s})=>{const{getStyles:c}=C();return r?t("input",{className:"jer-input-number",type:"text",name:j(o),value:e,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:t=>{switch(t.key){case"Enter":i();break;case"Escape":l();break;case"ArrowUp":t.preventDefault(),n(Number(e)+1);break;case"ArrowDown":t.preventDefault(),n(Number(e)-1)}},style:Object.assign({width:String(e).length/1.5+2+"em"},c("input",s))}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:c("number",s),children:e})},V=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:l,nodeData:s})=>{const{getStyles:c}=C();return r?t("input",{className:"jer-input-boolean",type:"checkbox",name:j(o),checked:e,onChange:()=>n(!e),onKeyDown:e=>{"Enter"===e.key?i():"Escape"===e.key&&l()},autoFocus:!0}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:c("boolean",s),children:String(e)})},R=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,handleCancel:i,nodeData:l})=>{const{getStyles:s}=C();a((()=>(n&&document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c))),[n]);const c=e=>{"Enter"===e.key?o():"Escape"===e.key&&i()};return t("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:s("null",l),children:String(e)})},z=({value:e})=>{let n="Error!";switch(typeof e){case"string":e===A&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return t("span",{className:"jer-value-invalid",children:n})},F=({size:n,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:o,style:r,children:[t("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),t("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"})]}),_=({size:n,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:o,style:r,transform:"translate(0, 0.5)",children:[t("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"}),t("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"})]}),I=({size:e,style:n,className:r})=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("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"})}),L=({size:n,style:r,className:o})=>e("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:n,height:n,className:o,style:r,children:[t("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"}),t("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),t("path",{d:"M15 10l-4 4 4 4"})]}),M=({size:n,style:r,className:o})=>e("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:n,height:n,className:o,style:r,children:[t("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),t("path",{d:"M22 4L12 14.01l-3-3"})]}),K=({size:e,style:n,className:r})=>t("svg",{baseProfile:"tiny",viewBox:"0 0 24 24",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("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"})}),B=({size:e,style:n,className:r})=>t("svg",{viewBox:"0 0 512 512",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("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"})}),W=({name:e,nodeData:r,rotate:o})=>{var a,i,l,s,c,d,u;const{getStyles:p,icons:g}=C(),h={size:"1.4em",className:"jer-icon"};switch(e){case"add":return null!==(a=null==g?void 0:g.add)&&void 0!==a?a:t(F,Object.assign({},h,{style:p("iconAdd",r)}));case"edit":return null!==(i=null==g?void 0:g.edit)&&void 0!==i?i:t(_,Object.assign({},h,{style:p("iconEdit",r)}));case"delete":return null!==(l=null==g?void 0:g.delete)&&void 0!==l?l:t(I,Object.assign({},h,{style:p("iconDelete",r),size:"1.45em"}));case"copy":return null!==(s=null==g?void 0:g.copy)&&void 0!==s?s:t(L,Object.assign({},h,{style:p("iconCopy",r),size:"1.2em"}));case"ok":return null!==(c=null==g?void 0:g.ok)&&void 0!==c?c:t(M,Object.assign({},h,{style:Object.assign({fontSize:"90%"},p("iconOk",r))}));case"cancel":return null!==(d=null==g?void 0:g.cancel)&&void 0!==d?d:t(K,Object.assign({},h,{style:Object.assign({fontSize:"130%"},p("iconCancel",r))}));case"chevron":return null!==(u=null==g?void 0:g.chevron)&&void 0!==u?u:t(B,{size:"1em",style:p("iconCollection",r)});default:return t(n,{})}},G=({startEdit:r,handleDelete:o,handleAdd:a,enableClipboard:l,type:s,customButtons:c,nodeData:d,translate:u})=>{const{getStyles:p}=C(),g=u("KEY_NEW",d),[h,m]=i(!1),[y,b]=i(g),{key:f,path:v,value:j}=d;return e("div",{className:"jer-edit-buttons",style:{opacity:h?1:void 0},children:[l&&t("div",{onClick:e=>{e.stopPropagation();let t,n="value",r="";if(l){if(!0===(e.ctrlKey||e.metaKey))t=U(v),r=t,n="path";else t=j,r=s?JSON.stringify(j,null,2):String(t);navigator.clipboard.writeText(r)}"function"==typeof l&&l({value:t,stringValue:r,path:v,key:f,type:n})},className:"jer-copy-pulse",children:t(W,{name:"copy",nodeData:d})}),r&&t("div",{onClick:e=>{e.stopPropagation(),r()},children:t(W,{name:"edit",nodeData:d})}),o&&t("div",{onClick:e=>{e.stopPropagation(),o()},children:t(W,{name:"delete",nodeData:d})}),a&&t("div",{onClick:e=>{e.stopPropagation(),"object"===s?m(!0):a("")},children:t(W,{name:"add",nodeData:d})}),null==c?void 0:c.map((({Element:e,onClick:n},r)=>t("div",{onClick:e=>n(d,e),children:t(e,{})},r))),h&&a&&"object"===s&&e(n,{children:[t("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:y,onChange:e=>b(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key&&a?(m(!1),a(y),b(g)):"Escape"===e.key&&(m(!1),b(g))},style:p("input",d)}),t(H,{onOk:()=>{y&&(m(!1),a(y))},onCancel:()=>{m(!1)},nodeData:d})]})]})},H=({onOk:n,onCancel:r,nodeData:o})=>e("div",{className:"jer-confirm-buttons",children:[t("div",{onClick:n,children:t(W,{name:"ok",nodeData:o})}),t("div",{onClick:r,children:t(W,{name:"cancel",nodeData:o})})]}),U=e=>e.reduce(((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`),""),Y=["string","number","boolean","null","object","array"],$=(e=[],t)=>{const n=e.filter((({condition:e})=>e(t)));if(0===n.length)return{};const r=n[0],{element:o,wrapperElement:a,customNodeProps:i,wrapperProps:l,hideKey:s=!1,showEditTools:c=!0,showOnEdit:d=!1,showOnView:u=!0,showCollectionWrapper:p=!0}=r,g=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(r,["element","wrapperElement","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:o,CustomWrapper:a,customNodeProps:i,wrapperProps:l,hideKey:s,showEditTools:c,showOnEdit:d,showOnView:u,showCollectionWrapper:p},g)},J=r({collapseState:null,setCollapseState:()=>{},doesPathMatch:()=>!1,currentlyEditingElement:null,setCurrentlyEditingElement:()=>{},areChildrenBeingEdited:()=>!1,dragSource:{path:null,pathString:null},setDragSource:()=>{}}),X=({children:e})=>{const[n,r]=i(null),[o,a]=i(null),[l,s]=i({path:null,pathString:null});return t(J.Provider,{value:{collapseState:n,setCollapseState:e=>{r(e),null!==e&&setTimeout((()=>r(null)),2e3)},doesPathMatch:e=>{if(null===n)return!1;for(const[t,r]of n.path.entries())if(r!==e[t])return!1;return!0},currentlyEditingElement:o,setCurrentlyEditingElement:a,areChildrenBeingEdited:e=>null!==o&&o.includes(e),dragSource:l,setDragSource:s},children:e})},Z=()=>o(J),Q=({props:e,collapsed:t})=>{const{data:n,nodeData:r,parentData:o,onEdit:a,onError:s,showErrorMessages:c,restrictEditFilter:d,restrictDeleteFilter:u,restrictAddFilter:p,restrictDragFilter:g,translate:h}=e,{currentlyEditingElement:m,setCurrentlyEditingElement:y}=Z(),[b,f]=i(null),v=Object.assign(Object.assign({},r),{collapsed:t}),{path:E,key:D,size:w}=v,k=j(E),C=l((()=>!d(v)),[v]),O=l((()=>!u(v)),[v]),S=l((()=>!p(v)),[v]),N=l((()=>!g(v)&&O&&null===m),[v]),x=e=>{c&&(f(e),setTimeout((()=>f(null)),2500)),console.warn("Error",e)},A=l((()=>(e,t)=>{x(e.message),s&&s({currentData:v.fullData,errorValue:t,currentValue:n,name:D,path:E,error:e})}),[s,c]),T=m===k,P=m===`key_${k}`,V="number"==typeof E.slice(-1)[0];return{pathString:k,nodeData:v,path:E,name:D,size:w,canEdit:C,canDelete:O,canAdd:S,canDrag:N,error:b,showError:x,onError:A,setError:f,handleEditKey:e=>{if(y(null),D===e)return;if(!o)return;const t=E.slice(0,-1);if(Object.keys(o).includes(e))return void A({code:"KEY_EXISTS",message:h("ERROR_KEY_EXISTS",v)},e);const n=Object.fromEntries(Object.entries(o).map((([t,n])=>t===D?[e,n]:[t,n])));a(n,t).then((t=>{t&&A({code:"UPDATE_ERROR",message:t},e)}))},derivedValues:{isEditing:T,isEditingKey:P,isArray:V,canEditKey:null!==o&&C&&S&&O&&!V}}},q=({canDrag:e,canDragOnto:n,path:r,nodeData:o,onMove:a,onError:s,translate:c})=>{const{getStyles:d}=C(),{dragSource:u,setDragSource:p}=Z(),[g,h]=i(!1),m=j(r),y=l((()=>e?{onDragStart:e=>{e.stopPropagation(),p({path:r,pathString:m})},onDragEnd:e=>{e.stopPropagation(),p({path:null,pathString:null})}}:{}),[e]),b=l((()=>e=>n?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),v(e),p({path:null,pathString:null}),h(!1)},onDragEnter:t=>{var n;t.stopPropagation(),m.startsWith(null!==(n=u.pathString)&&void 0!==n?n:"")||h(e)},onDragExit:e=>{e.stopPropagation(),h(!1)}}:{}),[u,n]),f=l((()=>n&&null!==u.pathString?t("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:r.length}},b("below"))):null),[u,n]),v=e=>{var t,n;const i=null===(t=u.path)||void 0===t?void 0:t.slice(-1)[0],l=null===(n=u.path)||void 0===n?void 0:n.slice(0,-1).join("."),d=r.slice(0,-1).join(""),{parentData:p}=o;"string"==typeof i&&p&&!Array.isArray(p)&&Object.keys(p).includes(i)&&i in p&&l!==d?s({code:"KEY_EXISTS",message:c("ERROR_KEY_EXISTS",o)},i):a(u.path,r,e).then((e=>{e&&s({code:"UPDATE_ERROR",message:e},o.value)}))};return{dragSourceProps:y,getDropTargetProps:b,BottomDropTarget:f,DropTargetPadding:({position:e,nodeData:n})=>g===e?t("div",{className:"jer-drag-n-drop-padding",style:d("dropZone",n)}):null,handleDrop:v}},ee=(e,t)=>{var n,r;const o=document.getElementsByClassName("jer-editor-container"),a=parseInt(o.length>0?getComputedStyle(o[0]).getPropertyValue("line-height"):"16px"),i=(null!==(r=null===(n=t.current)||void 0===n?void 0:n.offsetWidth)&&void 0!==r?r:0)/(.5*a),l=JSON.stringify(e,null,2).replace(/\\n/g,"\n").split("\n").map((e=>Math.ceil(e.length/i))).reduce(((e,t)=>e+t),0)*a;return Math.min(l+30,window.innerHeight-50)},te=n=>{const{data:r,parentData:o,onEdit:c,onDelete:d,onChange:u,onMove:p,enableClipboard:g,canDragOnto:h,restrictTypeSelection:y,searchFilter:b,searchText:f,showLabel:v,stringTruncate:j,showStringQuotes:E,indent:D,translate:w,customNodeDefinitions:k}=n,{getStyles:O}=C(),{setCurrentlyEditingElement:S,setCollapseState:N}=Z(),[x,T]=i("function"==typeof r?A:r),{pathString:P,nodeData:V,path:R,name:z,canEdit:F,canDelete:_,canDrag:I,error:L,onError:M,handleEditKey:K,derivedValues:B}=Q({props:n}),{dragSourceProps:W,getDropTargetProps:U,BottomDropTarget:J,DropTargetPadding:X}=q({canDrag:I,canDragOnto:h,path:R,nodeData:V,onMove:p,onError:M,translate:w}),ee=$(k,V),[te,ae]=i(ne(r,ee)),ie=s((e=>{if(!u)return void T(e);const t=u({currentData:V.fullData,newValue:e,currentValue:x,name:z,path:R});T(t)}),[u]);a((()=>{T("function"==typeof r?A:r),ae(ne(r,ee))}),[r,L]);const{CustomNode:le,customNodeProps:se,hideKey:ce,showEditTools:de=!0,showOnEdit:ue,showOnView:pe}=ee,ge=[...Y,...k.filter((({showInTypesSelector:e=!1,name:t})=>e&&!!t)).map((({name:e})=>e))],he=l((()=>{if("boolean"==typeof y)return y?[]:ge;if(Array.isArray(y))return y;const e=y(V);return"boolean"==typeof e?e?[]:ge:e}),[V,y]);if(!m("value",V,b,f))return null;const me=()=>{let e;switch(S(null),te){case"object":e={[w("DEFAULT_NEW_KEY",V)]:x};break;case"array":e=null!=x?x:[];break;case"number":{const t=Number(x);e=isNaN(t)?0:t;break}default:e=x}c(e,R).then((t=>{t&&M({code:"UPDATE_ERROR",message:t},e)}))},ye=()=>{S(null),T(r),ae(ne(r,ee))},{isEditing:be,isEditingKey:fe,canEditKey:ve}=B,je=!be&&L,Ee=be&&he.length>0,De="invalid"!==te&&!L&&de,we=v&&fe,ke=v&&!fe&&!ce,Ce={value:x,parentData:o,setValue:ie,isEditing:be,setIsEditing:F?()=>S(P):()=>{},handleEdit:me,handleCancel:ye,path:R,stringTruncate:j,showStringQuotes:E,nodeData:V,translate:w},Oe=le&&(be&&ue||!be&&pe)?t(le,Object.assign({},n,{value:x,customNodeProps:se,setValue:ie,handleEdit:me,handleCancel:ye,handleKeyPress:e=>{"Enter"===e.key?me():"Escape"===e.key&&ye()},isEditing:be,setIsEditing:()=>S(P),getStyles:O})):re(ne(r),Ce);return e("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:D/2+"em",position:"relative"},draggable:I},W,U("above"),{children:[J,t(X,{position:"above",nodeData:V}),e("div",{className:"jer-value-main-row",style:{flexWrap:z.length>10?"wrap":"nowrap"},children:[ke&&t("span",{className:"jer-key-text",style:Object.assign(Object.assign({},O("property",V)),{minWidth:`${Math.min(String(z).length+1,5)}ch`,flexShrink:z.length>10?1:0}),onDoubleClick:()=>ve&&S(`key_${P}`),children:""===z?t("span",{className:R.length>0?"jer-empty-string":void 0}):`${z}:`}),we&&t("input",{className:"jer-input-text jer-key-edit",type:"text",name:P,defaultValue:z,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?K(e.target.value):"Escape"===e.key&&ye()},style:{width:String(z).length/1.5+.5+"em"}}),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:Oe}),be?t(H,{onOk:me,onCancel:ye,nodeData:V}):De&&t(G,{startEdit:F?()=>S(P):void 0,handleDelete:_?()=>{d(x,R).then((e=>{e&&M({code:"DELETE_ERROR",message:e},x)}))}:void 0,enableClipboard:g,translate:w,customButtons:n.customButtons,nodeData:V}),Ee&&e("div",{className:"jer-select",children:[t("select",{name:`${z}-type-select`,className:"jer-type-select",onChange:e=>(e=>{const t=k.find((t=>t.name===e));if(t)c(t.defaultValue,R),ae(e),S(null),N({path:R,collapsed:!1});else{const t=oe(x,e,w("DEFAULT_NEW_KEY",V),(null==ee?void 0:ee.CustomNode)?w("DEFAULT_STRING",V):void 0);ie(t),c(t,R).then((e=>{e&&(M({code:"UPDATE_ERROR",message:e},t),S(null))}))}})(e.target.value),value:te,children:he.map((e=>t("option",{value:e,children:e},e)))}),t("span",{className:"focus"})]}),je&&t("span",{className:"jer-error-slug",style:O("error",V),children:L})]})]}),t(X,{position:"below",nodeData:V})]}))},ne=(e,t)=>(null==t?void 0:t.CustomNode)&&(null==t?void 0:t.name)&&t.showInTypesSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",re=(e,n)=>{const r=n.value;switch(e){case"string":return t(T,Object.assign({},n,{value:r}));case"number":return t(P,Object.assign({},n,{value:r}));case"boolean":return t(V,Object.assign({},n,{value:r}));case"null":return t(R,Object.assign({},n));default:return t(z,Object.assign({},n))}},oe=(e,t,n,r)=>{switch(t){case"string":return null!=r?r:String(e);case"number":{const t=Number(e);return isNaN(t)?0:t}case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},ae=r=>{const{getStyles:o}=C(),{collapseState:s,setCollapseState:d,doesPathMatch:y,currentlyEditingElement:b,setCurrentlyEditingElement:f,areChildrenBeingEdited:v}=Z(),{data:j,nodeData:E,parentData:D,showCollectionCount:w,onEdit:k,onAdd:O,onDelete:S,canDragOnto:N,collapseFilter:x,collapseAnimationTime:A,onMove:T,enableClipboard:P,searchFilter:V,searchText:R,indent:z,keySort:F,showArrayIndices:_,defaultValue:I,translate:L,customNodeDefinitions:M,jsonParse:K,jsonStringify:B}=r,[U,Y]=i(B(j)),J=x(E),{contentRef:X,isAnimating:ne,maxHeight:re,collapsed:oe,animateCollapse:ie}=((e,t,n)=>{const[r,o]=i(n?0:void 0),[a,l]=i(n),s=c(!1),d=c(null),u=c(0),p=c();return{contentRef:d,isAnimating:s.current,animateCollapse:n=>{var r,i;if(a!==n){switch(window.clearTimeout(p.current),s.current=!0,n){case!0:{const e=null!==(i=null===(r=d.current)||void 0===r?void 0:r.offsetHeight)&&void 0!==i?i:0;u.current=e,o(e),setTimeout((()=>{o(0)}),5);break}case!1:o(u.current||ee(e,d))}l(!a),p.current=window.setTimeout((()=>{s.current=!1,n||o(void 0)}),t)}},maxHeight:r,collapsed:a}})(j,A,J),{pathString:le,nodeData:se,path:ce,name:de,size:ue,canEdit:pe,canDelete:ge,canAdd:he,canDrag:me,error:ye,setError:be,onError:fe,handleEditKey:ve,derivedValues:je}=Q({props:r,collapsed:oe}),{dragSourceProps:Ee,getDropTargetProps:De,BottomDropTarget:we,DropTargetPadding:ke}=q({canDrag:me,canDragOnto:N,path:ce,nodeData:se,onMove:T,onError:fe,translate:L}),Ce=c(!J);a((()=>{Y(B(j))}),[j]),a((()=>{const e=x(se)&&!je.isEditing;Ce.current=!e,ie(e)}),[x]),a((()=>{null!==s&&y(ce)&&(Ce.current=!0,ie(s.collapsed))}),[s]);const Oe=l((()=>e=>"function"!=typeof I?I:I(e)),[I]),{CustomNode:Se,customNodeProps:Ne,CustomWrapper:xe,wrapperProps:Ae={},hideKey:Te,showEditTools:Pe=!0,showOnEdit:Ve,showOnView:Re,showCollectionWrapper:ze=!0}=l((()=>$(M,se)),[]);if(!m("collection",se,V,R)&&se.level>0)return null;const Fe=Array.isArray(j)?"array":"object",_e="array"===Fe?{open:"[",close:"]"}:{open:"{",close:"}"},Ie=e=>{"Enter"===e.key&&(e.metaKey||e.shiftKey||e.ctrlKey)?Me():"Escape"===e.key&&Be()},Le=e=>{if(e.getModifierState("Alt"))return Ce.current=!0,void d({collapsed:!oe,path:ce});b&&b.includes(le)||(Ce.current=!0,d(null),ie(!oe))},Me=()=>{try{const e=K(U);if(f(null),be(null),JSON.stringify(e)===JSON.stringify(j))return;k(e,ce).then((t=>{t&&fe({code:"UPDATE_ERROR",message:t},e)}))}catch(e){fe({code:"INVALID_JSON",message:L("ERROR_INVALID_JSON",se)},U)}},Ke=ce.length>0?()=>{S(j,ce).then((e=>{e&&fe({code:"DELETE_ERROR",message:e},u(j,ce))}))}:void 0,Be=()=>{f(null),be(null),Y(B(j))},{isEditing:We,isEditingKey:Ge,isArray:He,canEditKey:Ue}=je,Ye="when-closed"===w?oe:w,$e=!We&&Pe,Je=(_||!He)&&!Te&&void 0!==de,Xe=Se&&(We&&Ve||!We&&Re),Ze=F&&"object"===Fe,Qe=Object.entries(j).map((([e,t])=>["array"===Fe?Number(e):e,t]));Ze&&Qe.sort("function"==typeof F?(e,t)=>F(e[0],t[0]):void 0);const qe=Ce.current?We?t("div",{className:"jer-collection-text-edit",children:e("div",{children:[t(g,{className:"jer-collection-text-area",name:le,value:U,setValue:Y,isEditing:We,handleKeyPress:Ie,styles:o("input",se)}),t("div",{className:"jer-collection-input-button-row",children:t(H,{onOk:Me,onCancel:Be,nodeData:se})})]})}):Qe.map((([e,n],a)=>{const i={key:e,value:n,path:[...ce,e],level:ce.length+1,index:a,size:h(n)?Object.keys(n).length:1,parentData:j,fullData:se.fullData};return t("div",{className:"jer-collection-element",style:o("collectionElement",i),children:h(n)?t(ae,Object.assign({},r,{data:n,parentData:j,nodeData:i,showCollectionCount:w,canDragOnto:pe}),e):t(te,Object.assign({},r,{data:n,parentData:j,nodeData:i,canDragOnto:pe,showLabel:"object"===Fe||_}),e)},e)})):null,et=!!ze&&oe;et||(Ce.current=!0);const tt=Object.assign(Object.assign({},r),{data:j,value:j,parentData:D,nodeData:se,setValue:e=>p(void 0,void 0,void 0,(function*(){return yield k(e,ce)})),handleEdit:Me,handleCancel:Be,handleKeyPress:Ie,isEditing:We,setIsEditing:()=>f(le),getStyles:o,canDragOnto:pe}),nt=Xe?t(Se,Object.assign({customNodeProps:Ne},tt,{children:qe})):qe,rt=Ge?t("input",{className:"jer-input-text jer-key-edit",type:"text",name:le,defaultValue:de,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?ve(e.target.value):"Escape"===e.key&&Be()},style:{width:String(de).length/1.5+.5+"em"}}):Je&&t("span",{className:"jer-key-text",style:o("property",se),onClick:e=>e.stopPropagation(),onDoubleClick:()=>Ue&&f(`key_${le}`),children:""===de?t("span",{className:ce.length>0?"jer-empty-string":void 0}):`${de}:`}),ot=$e&&t(G,{startEdit:pe?()=>{Ce.current=!0,f(le)}:void 0,handleAdd:he?e=>{ie(!1);const t=Oe(se);"array"===Fe?O(t,[...ce,j.length]).then((e=>{e&&fe({code:"ADD_ERROR",message:e},t)})):e in j?fe({code:"KEY_EXISTS",message:L("ERROR_KEY_EXISTS",se)},e):O(t,[...ce,e]).then((e=>{e&&fe({code:"ADD_ERROR",message:e},t)}))}:void 0,handleDelete:ge?Ke:void 0,enableClipboard:P,type:Fe,nodeData:se,translate:L,customButtons:r.customButtons}),at=e("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===ce.length?0:z/2)+"em"},o("collection",se)),{position:"relative"}),draggable:me},Ee,De("above"),{children:[t("div",{className:"jer-clickzone",style:{width:z/2+1+"em",zIndex:10+2*se.level},onClick:e=>Le(e)}),!We&&we,t(ke,{position:"above",nodeData:se}),ze?e("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:e=>Le(e),children:[e("div",{className:"jer-collection-name",children:[t("div",{className:"jer-collapse-icon jer-accordion-icon"+(oe?" jer-rotate-90":""),style:{zIndex:11+2*se.level},onClick:e=>Le(e),children:t(W,{name:"chevron",rotate:oe,nodeData:se})}),rt,!We&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",se),children:_e.open})]}),!We&&Ye&&t("div",{className:"jer-collection-item-count"+(Ye?" jer-visible":" jer-hidden"),style:o("itemCount",se),children:1===ue?L("ITEM_SINGLE",Object.assign(Object.assign({},se),{size:1}),1):L("ITEMS_MULTIPLE",se,ue)}),t("div",{className:"jer-brackets"+(et?" jer-visible":" jer-hidden"),style:o("bracket",se),children:_e.close}),ot]}):Te?t(n,{}):e("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[rt,ot]}),e("div",{className:"jer-collection-inner",style:Object.assign({overflowY:et||ne?"clip":"visible",maxHeight:v(le)?void 0:re},o("collectionInner",se)),ref:X,children:[nt,t("div",{className:We?"jer-collection-error-row":"jer-collection-error-row-edit",children:ye&&t("span",{className:"jer-error-slug",style:o("error",se),children:ye})}),!We&&ze&&t("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},o("bracket",se)),{marginLeft:(z<3?-1:z<6?-.5:0)+"em"}),children:_e.close})]}),t(ke,{position:"below",nodeData:se})]}));return xe?t(xe,Object.assign({customNodeProps:Ae},tt,{children:at})):at},ie={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"},le=(e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}const a=r in e?e[r]:ie[r];return void 0===o?a:null==a?void 0:a.replace("{{count}}",String(o))})(e,t,r,n,o);var se=[],ce=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,a="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var i=se.indexOf(a);-1===i&&(i=se.push(a)-1,ce[i]={}),n=ce[i]&&ce[i][r]?ce[i][r]:ce[i][r]=l()}else n=l();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function l(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var i="prepend"===r?"afterbegin":"beforeend";return a.insertAdjacentElement(i,e),e}}(':root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-expand-transition-time:0.3s;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden,.jer-visible{transition:var(--jer-expand-transition-time)}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{display:flex;flex-wrap:wrap}.jer-collapse-icon{left:-1.2em;position:absolute;top:.35em}.jer-collection-inner{position:relative;transition:var(--jer-expand-transition-time)}.jer-collection-text-edit{align-items:flex-start;display:flex;flex-direction:column;gap:.3em}.jer-collection-text-area{font-family:inherit;font-size:.85em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em}.jer-collection-error-row{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-main-row{display:flex;gap:0}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap}.jer-hyperlink{text-decoration:underline}.jer-input-text{font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:transform var(--jer-expand-transition-time)}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-rotate-90{transform:rotate(-90deg)}.jer-accordion-icon,.jer-rotate-90{transition:transform var(--jer-expand-transition-time)}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string:after{content:"<empty string>:";font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #e0e0e0;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const de=({data:e,setData:n,rootName:r="root",onUpdate:o=(()=>{}),onEdit:c=o,onDelete:d=o,onAdd:u=o,onChange:g,onError:m,showErrorMessages:y=!0,enableClipboard:b=!0,indent:f=2,collapse:v=!1,collapseAnimationTime:j=300,showCollectionCount:E=!0,restrictEdit:D=!1,restrictDelete:w=!1,restrictAdd:k=!1,restrictTypeSelection:O=!1,restrictDrag:S=!0,searchFilter:N,searchText:x,searchDebounceTime:A=350,keySort:T=!1,showArrayIndices:P=!0,showStringQuotes:V=!0,defaultValue:R=null,minWidth:z=250,maxWidth:F="min(600px, 90vw)",rootFontSize:_,stringTruncate:I=250,translations:L={},className:M,id:K,customText:B={},customNodeDefinitions:W=[],customButtons:G=[],jsonParse:H=JSON.parse,jsonStringify:U=(e=>JSON.stringify(e,null,2))})=>{const{getStyles:Y}=C(),$=s(ge(v),[v]),J=s(le(L,B),[L,B]),[X,Z]=i(x),[Q,q]=(({setData:e,data:t})=>{const[n,r]=i(e?void 0:t),o=s((t=>{e?e(t):r(t)}),[e]);return a((()=>{e||r(t)}),[t]),[e?t:n,o]})({setData:n,data:e}),ee=document.querySelector(":root"),ne=getComputedStyle(document.documentElement).getPropertyValue("--jer-expand-transition-time");1e3*parseFloat(ne)!==j&&(null==ee||ee.style.setProperty("--jer-expand-transition-time",j/1e3+"s")),a((()=>{const e=setTimeout((()=>Z(x)),A);return()=>clearTimeout(e)}),[x,A]);const re={key:r,path:[],level:0,index:0,value:Q,size:"object"==typeof Q&&null!==Q?Object.keys(Q).length:1,parentData:null,fullData:Q},oe=(e,t)=>p(void 0,void 0,void 0,(function*(){const n=yield e(t);if(!0===n||void 0===n)return void q(t.newData);const r=me(n)?n:["error",n],[o,a]=r;if("error"===o)return q(t.currentData),!1===a?J("ERROR_UPDATE",re):String(a);q(a)})),ie=l((()=>ge(D)),[D]),se=l((()=>ge(w)),[w]),ce=l((()=>ge(k)),[k]),de=l((()=>ge(S)),[S]),ue=l((()=>he(N)),[N]),ye={name:r,nodeData:re,onEdit:(e,t)=>p(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=pe(Q,t,e,"update");if(o!==a)return yield oe(c,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onDelete:(e,t)=>p(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=pe(Q,t,e,"delete");return yield oe(d,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onAdd:(e,t)=>p(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=pe(Q,t,e,"add");return yield oe(u,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onChange:g,onError:m,showErrorMessages:y,onMove:(e,t,n)=>p(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:a}=pe(Q,e,"","delete"),i=e.slice(-1)[0],l=t.slice(0,-1),s=t.slice(-1)[0];let d="number"==typeof s?"above"===n?s:s+1:"number"==typeof i?`arr_${i}`:i;e.slice(0,-1).join(".")===t.slice(0,-1).join(".")&&"number"==typeof i&&"number"==typeof d&&i<d&&(d-=1);const u="number"==typeof d?{insert:!0}:"above"===n?{insertBefore:s}:{insertAfter:s},{newData:p,newValue:g}=pe(o,[...l,d],a,"add",u);return yield oe(c,{currentData:r,newData:p,currentValue:a,newValue:g,name:t.slice(-1)[0],path:t})})),showCollectionCount:E,collapseFilter:$,collapseAnimationTime:j,restrictEditFilter:ie,restrictDeleteFilter:se,restrictAddFilter:ce,restrictTypeSelection:O,restrictDragFilter:de,canDragOnto:!1,searchFilter:ue,searchText:X,enableClipboard:b,keySort:T,showArrayIndices:P,showStringQuotes:V,indent:f,defaultValue:R,stringTruncate:I,translate:J,customNodeDefinitions:W,customButtons:G,parentData:null,jsonParse:H,jsonStringify:U},be=Object.assign(Object.assign({},Y("container",re)),{minWidth:z,maxWidth:F});return be.fontSize=null!=_?_:be.fontSize,t("div",{id:K,className:"jer-editor-container "+M,style:be,children:h(Q)?t(ae,Object.assign({data:Q},ye)):t(te,Object.assign({data:Q,showLabel:!0},ye))})},ue=e=>t(k,{theme:e.theme,icons:e.icons,children:t(X,{children:t(de,Object.assign({},e))})}),pe=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const a=Object.assign({remove:"delete"===r},o),i="add"!==r?u(e,t):void 0;return{currentData:e,newData:d(e,t,n,a),currentValue:i,newValue:"delete"!==r?n:void 0}},ge=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,he=e=>{if(void 0!==e)return"value"===e?b:"key"===e?f:"all"===e?(e,t)=>b(e,t)||f(e,t):e},me=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),ye=({value:n,setIsEditing:r,getStyles:o,customNodeProps:a,nodeData:i})=>{var l,s;const c=null!==(l=null==a?void 0:a.stringTruncate)&&void 0!==l?l:100,d=o("string",i);return t("div",{onDoubleClick:()=>r(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&r(!0)},className:"jer-value-string jer-hyperlink",style:d,children:e("a",{href:n,target:"_blank",rel:"noreferrer",style:{color:null!==(s=d.color)&&void 0!==s?s:void 0},children:['"',v(n,c),'"']})})},be={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:ye,showOnView:!0,showOnEdit:!1};export{F as IconAdd,K as IconCancel,B as IconChevron,L as IconCopy,I as IconDelete,_ as IconEdit,M as IconOk,ue as JsonEditor,ye as LinkCustomComponent,be as LinkCustomNodeDefinition,h as isCollection,b as matchNode,f as matchNodeKey,E as themes,v as truncate};
|
package/package.json
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-edit-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"description": "React component for editing or viewing JSON/object data",
|
|
5
5
|
"main": "build/index.cjs.js",
|
|
6
6
|
"module": "build/index.esm.js",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
7
9
|
"types": "build/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
"types": "./build/index.d.ts",
|
|
12
|
+
"import": "./build/index.esm.js",
|
|
13
|
+
"require": "./dist/index.cjs.js"
|
|
14
|
+
},
|
|
8
15
|
"files": [
|
|
9
16
|
"build/**/*"
|
|
10
17
|
],
|
|
@@ -16,7 +23,7 @@
|
|
|
16
23
|
"demo": "cd demo && node ./scripts/getVersion.js && yarn && yarn start",
|
|
17
24
|
"build": "rimraf ./build && rollup -c && rimraf ./build/dts",
|
|
18
25
|
"lint": "npx eslint \"src/**\"",
|
|
19
|
-
"postbuild": "node ./scripts/cleanBuildTypes.
|
|
26
|
+
"postbuild": "node ./scripts/cleanBuildTypes.cjs",
|
|
20
27
|
"prepublish": "yarn build",
|
|
21
28
|
"compile": "rimraf ./build && tsc",
|
|
22
29
|
"release": "yarn publish",
|