@dartech/arsenal-ui 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/package.json +5 -2
- package/src/interfaces/definition.d.ts +16 -29
- package/src/interfaces/ui.d.ts +3 -2
- package/src/lib/Definition/CreateDefinition/CreateDefinition.d.ts +1 -2
- package/src/lib/Forms/BackButton.d.ts +1 -1
- package/src/lib/Forms/ControlAceEditor.d.ts +1 -1
- package/src/lib/Forms/ControlAutocomplete.d.ts +38 -18
- package/src/lib/Forms/ControlCheckbox.d.ts +30 -9
- package/src/lib/Forms/ControlDebouncedInput.d.ts +1 -1
- package/src/lib/Forms/ControlInput.d.ts +22 -18
- package/src/lib/Forms/ControlNumberInput.d.ts +22 -15
- package/src/lib/Forms/ControlQueryAutocomplete.d.ts +12 -4
- package/src/lib/Forms/ControlRadio.d.ts +66 -0
- package/src/lib/Forms/ControlSelect.d.ts +33 -32
- package/src/lib/Forms/ControlSwitch.d.ts +4 -3
- package/src/lib/Forms/index.d.ts +1 -1
- package/src/lib/Forms/useAutocomplete.d.ts +10 -0
- package/src/lib/JsonPathPicker/JsonPathPicker.d.ts +2 -2
- package/src/lib/Property/PropertyFiller/usePropertyFiller.d.ts +1 -1
- package/src/lib/Property/PropertyValueField/index.d.ts +0 -1
- package/src/lib/Property/UpsertProperty/CreatePropertiesList.d.ts +1 -2
- package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.d.ts +1 -2
- package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.d.ts +2 -2
- package/src/lib/TemplateContent/TemplateContentEditor.d.ts +2 -2
- package/src/utils/dem.d.ts +2 -2
- package/src/utils/validators.d.ts +1 -1
- package/src/lib/Forms/ControlRadioBtn.d.ts +0 -26
- package/src/lib/Property/PropertyValueField/PropertyValue.d.ts +0 -10
- package/src/lib/Property/PropertyValueField/ValueComponent.d.ts +0 -14
package/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{jsx as e,jsxs as r,Fragment as t}from"react/jsx-runtime";import n from"@mui/material/Button";import i from"@mui/material/Dialog";import a from"@mui/material/DialogActions";import l from"@mui/material/DialogContent";import o from"@mui/material/DialogContentText";import s from"@mui/material/DialogTitle";import c from"@mui/material/Box";import d from"@mui/material/CircularProgress";import{__rest as p,__awaiter as u}from"tslib";import{useController as m,useWatch as h,useFormContext as g,Controller as b}from"react-hook-form";import f from"@mui/material/TextField";import y,{useRef as v,useEffect as O,useState as T,useMemo as E,useCallback as C,memo as x}from"react";import j from"@mui/material/MenuItem";import N from"@mui/material/Checkbox";import S from"@mui/material/FormControlLabel";import I from"@mui/material/Radio";import k from"@mui/material/RadioGroup";import w from"@mui/lab/Autocomplete";import P from"@mui/icons-material/FileCopyOutlined";import A from"@mui/material/Tooltip";import V from"@mui/material/IconButton";import q from"@mui/icons-material/ArrowBack";import{useHistory as L,useLocation as R,Link as M}from"react-router-dom";import $ from"react-ace";import D from"@mui/material/Typography";import F from"@mui/material/FormHelperText";import z from"@mui/material/Switch";import{DatePicker as B}from"@mui/x-date-pickers/DatePicker";import{format as J,isMatch as G,isValid as Y,parse as _}from"date-fns";import{DateTimePicker as W}from"@mui/x-date-pickers/DateTimePicker";import{TimePicker as H}from"@mui/x-date-pickers/TimePicker";import U from"@mui/lab/Pagination";import K from"@mui/material/TablePagination";import{useGridApiContext as X,useGridSelector as Z,gridPageSelector as Q,gridPageCountSelector as ee,gridRowCountSelector as re,gridPageSizeSelector as te,GridColumnMenuContainer as ne,GridFilterMenuItem as ie,DataGrid as ae,GridActionsCellItem as le}from"@mui/x-data-grid";import{makeStyles as oe}from"@mui/styles";import se from"@mui/material/Paper";import ce from"@mui/material/Tab";import de from"@mui/material/Tabs";import pe from"@mui/material/Unstable_Grid2";import ue from"@mui/material/Accordion";import me from"@mui/material/AccordionSummary";import he from"@mui/material/AccordionDetails";import ge from"@mui/material/AccordionActions";import be from"@mui/icons-material/ExpandMore";import fe from"@mui/material/Stepper";import ye from"@mui/material/Step";import ve from"@mui/material/StepLabel";import Oe from"@mui/material/StepContent";import Te from"@mui/material/StepConnector";import Ee from"@mui/material/Chip";import Ce from"@mui/icons-material/Add";import xe from"@mui/material/Select";import je from"@mui/material/FormControl";import Ne from"@mui/material/InputLabel";import Se from"@mui/icons-material/Close";import Ie from"@mui/material/Table";import ke from"@mui/material/TableBody";import we from"@mui/material/TableRow";import Pe from"@mui/material/TableCell";import Ae from"@mui/icons-material/CheckCircle";import Ve from"classnames";import{toast as qe}from"react-toastify";import Le from"mui-rte";import{createTheme as Re,ThemeProvider as Me}from"@mui/material/styles";import{convertToRaw as $e,EditorState as De,convertFromHTML as Fe,ContentState as ze,Modifier as Be}from"draft-js";import Je from"@mui/icons-material/Functions";import Ge from"@mui/icons-material/NotInterested";var Ye;!function(e){e.STRING="STRING",e.INTEGER="INTEGER",e.BIG_INTEGER="BIG_INTEGER",e.BIG_DECIMAL="BIG_DECIMAL",e.FLOAT="FLOAT",e.LONG="LONG",e.DOUBLE="DOUBLE",e.BOOLEAN="BOOLEAN",e.ENTITY_REFERENCE="ENTITY_REFERENCE",e.ENTITY="ENTITY",e.JSON="JSON",e.DATE="DATE",e.TIME="TIME",e.DATE_TIME="DATE_TIME"}(Ye||(Ye={}));const _e="yyyy-MM-dd",We="HH:mm:ss",He="yyyy-MM-dd'T'HH:mm:ss.SSSXXX";var Ue;!function(e){e.UP="UP",e.DOWN="DOWN",e.CEILING="CEILING",e.FLOOR="FLOOR",e.HALF_UP="HALF_UP",e.HALF_DOWN="HALF_DOWN",e.HALF_EVEN="HALF_EVEN",e.UNNECESSARY="UNNECESSARY"}(Ue||(Ue={}));const Ke=({transparent:r,position:t})=>e(c,Object.assign({position:null!=t?t:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",bgcolor:r?"none":"rgba(255, 255, 255, .3)",zIndex:10},{children:e(d,{})})),Xe=({open:t,title:d,description:p,closeButtonTitle:u="Close",onClose:m,confirmButtonTitle:h="Confirm",confirmButtonDisabled:g=!1,onConfirm:b,children:f,dialogProps:y,loading:v,maxWidth:O="xs"})=>e("div",{children:r(i,Object.assign({open:t,onClose:m,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:O},y,{children:[v&&e(Ke,{}),e(s,Object.assign({id:"alert-dialog-title"},{children:d})),r(l,{children:[p&&e(o,Object.assign({id:"alert-dialog-description"},{children:p})),e(c,Object.assign({maxWidth:"100%",overflow:"hidden"},{children:f}))]}),r(a,{children:[e(n,Object.assign({onClick:m,color:"primary",variant:"contained"},{children:u})),h&&b?e(n,Object.assign({onClick:b,color:"secondary",variant:"contained",autoFocus:!0,disabled:g},{children:h})):null]})]}))}),Ze=({inputProps:r,name:t,control:n,required:i,validate:a,label:l="",variant:o="outlined",type:s="text",defaultValue:c="",disabled:d,InputLabelProps:u,textarea:g,hideErrorMessage:b=!1})=>{const y=m({name:t,control:n,defaultValue:c,rules:{required:i&&"Please, fill this field",validate:a}}),v=y.field,{ref:O}=v,T=p(v,["ref"]),{fieldState:{error:E}}=y,C=h({control:n,name:t});return e(f,Object.assign({fullWidth:!0,size:"small",inputRef:O,type:s,label:l,error:!!E,helperText:!b&&(null==E?void 0:E.message),disabled:d,variant:o,InputLabelProps:u,inputProps:r,multiline:g,minRows:g?3:1,value:C||""},T))};function Qe(e,r){const t=v();O((()=>()=>{t.current&&clearTimeout(t.current)}),[]);return(...n)=>{clearTimeout(t.current),t.current=setTimeout((()=>{e(...n)}),r)}}const er=()=>{const[e,r]=T(!1);return{open:e,toggle:()=>{r((e=>!e))},onClose:()=>{r(!1)},onOpen:()=>{r(!0)}}},rr=({inputProps:r,name:t,required:n,validate:i,label:a="",variant:l="outlined",type:o="text",defaultValue:s="",disabled:c,InputLabelProps:d,textarea:u})=>{const{setValue:m,control:h,getValues:y}=g(),[v,O]=T(""),x=Qe((e=>{m(t,e.target.value)}),350);E((()=>{const e=y(t);O(e)}),[y,t]);const j=C((e=>{O(e.target.value),x(e)}),[x]);return e(b,{name:t,control:h,defaultValue:s,rules:{required:n&&"Required field",validate:i},render:t=>{var n=t.field,{ref:i,value:s}=n,m=p(n,["ref","value"]),{fieldState:{error:h}}=t;return e(f,Object.assign({fullWidth:!0,size:"small",inputRef:i,type:o,label:a,error:!!h,helperText:null==h?void 0:h.message,disabled:c,variant:l,InputLabelProps:d,inputProps:r,multiline:u,minRows:u?3:1},m,{onChange:j,value:v}))}})},tr=({inputProps:r,selectProps:t,name:n,control:i,required:a,defaultValue:l,options:o,variant:s="outlined",validate:c,labelKey:d,valueKey:u,label:h="",disabled:g=!1})=>{const b=m({name:n,defaultValue:l,control:i,rules:{required:a&&"Required field",validate:c}}),y=b.field,{ref:v,value:O}=y,T=p(y,["ref","value"]),{fieldState:{error:E}}=b,x=C((e=>"string"==typeof e?e:u?e[u]:e.value),[u]),N=C((e=>"string"==typeof e?e:d?e[d]:e.label),[d]);return e(f,Object.assign({size:"small",select:!0,fullWidth:!0,error:!!E,inputRef:v,ref:v,helperText:null==E?void 0:E.message,SelectProps:t,variant:s,label:h,disabled:g,inputProps:Object.assign({},r),value:O||""},T,{children:null==o?void 0:o.map((r=>e(j,Object.assign({value:x(r)},{children:N(r)}),x(r))))}))},nr=({name:r,control:t,label:n,disabled:i,onChange:a})=>e(S,{label:n,control:e(b,{control:t,name:r,render:({field:r})=>e(N,Object.assign({color:"primary",size:"small"},r,{onChange:(e,t)=>a?a(r.name,t):r.onChange(e),checked:r.value,disabled:i}))})}),ir=({name:r,values:t,control:n})=>e(b,{control:n,name:r,render:({field:r})=>e(k,Object.assign({row:!0},r,{children:t.map((r=>e(S,{value:r,control:e(I,{}),label:r})))}))}),ar=({control:r,name:t,options:n,label:i,placeholder:a,multiple:l,required:o,disableCloseOnSelect:s=!1,labelKey:c,valueKey:d,loading:p,onChange:u,getOptionDisabled:m})=>{C(((e,r)=>{if(e&&r){if("string"==typeof e)return e===r;if(d)return e[d]===r[d]||e[d]===r;if(e.value)return e.value===r.value||e.value===r}return!1}),[]);const h=C((e=>e?"string"==typeof e?e:c&&e[c]?e[c]:e.label||e.name||e.value||e.code||"":""),[n]);return e(b,{name:t,control:r,rules:{required:o&&"Required field"},render:({field:r,fieldState:t})=>e(w,Object.assign({},r,{multiple:l,size:"small",disableCloseOnSelect:s||l,filterSelectedOptions:l,disablePortal:!0,loading:p,options:n,getOptionLabel:h,getOptionDisabled:m||null,value:r.value||null,onChange:(e,t)=>u?u(r.name,t):r.onChange(t),renderInput:r=>{var n;return e(f,Object.assign({},r,{label:i,variant:"outlined",helperText:null===(n=t.error)||void 0===n?void 0:n.message,placeholder:a,error:!!t.error}))}}))})},lr=({name:t,label:n,placeholder:i,queryFunction:a})=>{const{control:l,setValue:o}=g(),[s,c]=T(!1),[p,u]=T(""),[m,h]=T(""),[v,E]=T(null),[x,j]=T([]),[N,S]=T(0),[I,k]=T(1),P=Qe((e=>{u(e),k(1),j([])}),500),A=C(((e,r)=>{h(r),P(r)}),[P]),V=C(((e,r)=>{E(r),o(t,r)}),[t,o]),q=e=>{const r=e.currentTarget;r.scrollTop+r.clientHeight===r.scrollHeight&&x.length<N&&k(I+1)};return O((()=>{a(p,I).then((({options:e,totalItems:r})=>{j((r=>[...r,...e])),S(r)})).catch((e=>console.log(e))).finally((()=>c(!1)))}),[I,a,p]),e(b,{control:l,name:t,render:({field:t})=>e(w,{style:{width:300,margin:"auto"},size:"small",options:x,inputValue:m,filterOptions:e=>e,loading:s,value:v,onChange:V,clearOnBlur:!1,onInputChange:A,ListboxProps:{onScroll:q},renderInput:t=>e(f,Object.assign({},t,{label:n,variant:"outlined",placeholder:i,InputProps:Object.assign(Object.assign({},t.InputProps),{endAdornment:r(y.Fragment,{children:[s?e(d,{color:"inherit",size:20}):null,t.InputProps.endAdornment]})})}))})})},or=({copyText:r,helpText:t="Copy"})=>{const[n,i]=T(t);return n?e(A,Object.assign({title:n,placement:"top"},{children:e(V,Object.assign({onClick:()=>{navigator.clipboard.writeText(r),i("Copied!"),setTimeout((()=>{i(t)}),1e3)}},{children:e(P,{fontSize:"small"})}))})):null},sr=({text:r,buttonProps:t={}})=>{const i=L(),{state:a}=R(),l=E((()=>null==a?void 0:a.from),[a]),o=C((()=>{l?i.push(l):i.goBack()}),[i,l]);return e(c,Object.assign({mr:2},{children:r?e(n,Object.assign({color:"inherit",onClick:l?null:o,component:M,to:null!=l?l:""},t,{children:r})):e(V,Object.assign({onClick:o},{children:e(q,{})}))}))},cr=({control:n,name:i,mode:a="json",label:l,width:o="100%",height:s="200px",theme:d="monokai",readOnly:p,required:u=!1,validateJson:b=!1,fontSize:f=16,validate:y=!0})=>{const{setError:v,clearErrors:O}=g(),{field:{onChange:T},fieldState:{error:E}}=m({control:n,name:i}),C=h({control:n,name:i});return r(c,Object.assign({display:"flex",flexDirection:"column",width:"100%"},{children:[e(c,{children:l&&e(D,Object.assign({variant:"subtitle1",display:"inline",style:{marginRight:10}},{children:l}))}),r(t,{children:[e($,{focus:!0,wrapEnabled:!0,width:o,height:s,showPrintMargin:!1,theme:d,fontSize:f,setOptions:{enableLiveAutocompletion:!0,enableBasicAutocompletion:!0,showLineNumbers:!0,tabSize:2},style:{lineHeight:1.4,zIndex:0,isolation:"isolate"},readOnly:p,value:"json"===a&&"string"!=typeof C?null===C?"":JSON.stringify(C):C,onChange:e=>{if(!e&&u?v(i,{message:"Required field"}):O(i),b)try{JSON.parse(e),O(i)}catch(e){return void v(i,{message:"Invalid JSON"})}T(e)},mode:a,onLoad:e=>{y&&b||e.getSession().setUseWorker(!1)}}),E&&e(F,Object.assign({error:!0},{children:E.message}))]})]}))},dr=(e,r)=>{const t=[...e];return t.splice(r,1),t},pr=e=>{try{JSON.parse(e)}catch(e){return!1}return!0};function ur(e){return e.replace(/(^\w)|([-\s]\w)/g,(e=>e.toUpperCase()))}const mr=(e,r,t,n="asc")=>{const i=e[t],a=r[t];return i<a?"asc"===n?-1:1:i>a?"asc"===n?1:-1:0},hr=e=>{if(!e)return"";if("string"!=typeof e)try{return JSON.stringify(e,null,"\t")}catch(e){return"Failed to stringify JSON"}return e},gr=e=>{try{return JSON.parse(e)}catch(e){return null}},br=e=>{try{const r=JSON.parse(e);return Object.keys(r).forEach((e=>{r[e]=br(r[e])})),r}catch(r){return e}},fr=({value:t,type:n,copyText:i,status:a})=>{switch(n){case"JSON_copy":return r(c,Object.assign({width:"100%"},{children:[e(c,Object.assign({display:"flex",alignItems:"center",justifyContent:"flex-end",pt:1,mb:2},{children:e(or,{copyText:hr(t)})})),e(Nt,{value:t})]}));case"JSON":return e(Nt,{value:t});case"JSON_text":return e(c,Object.assign({width:"100%"},{children:e(c,Object.assign({overflow:"hidden",whiteSpace:"nowrap"},{children:"object"==typeof t?JSON.stringify(t):t}))}));case"copy":return r(c,Object.assign({display:"flex",alignItems:"center",width:"100%"},{children:[e(c,Object.assign({mr:"auto"},{children:t})),e(or,{copyText:i||t})]}));case"boolean":return t?e(Ae,{color:"primary",fontSize:"small"}):e(Ge,{fontSize:"small"});case"date":return t?r("div",{children:[e("div",{children:J(new Date(t),"dd.MM.yyyy")}),e("div",{children:J(new Date(t),"HH:mm:ss")})]}):"";case"status":return e(Dt,{text:t,status:a});case"array":return e(c,{children:t.map(((r,t)=>e(c,{children:r},t)))});default:return e("div",{children:t})}},yr=new RegExp("^[-+]?[0-9]+$"),vr=new RegExp(/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/),Or=e=>"string"==typeof e&&e.includes("$("),Tr=e=>e===Ye.DATE||e===Ye.DATE_TIME||e===Ye.TIME,Er=e=>!e&&0!==e&&!1!==e,Cr=(e,r,t)=>{if(null==r&&e!==Ye.BOOLEAN)return null;let n=r;switch(e){case Ye.BOOLEAN:n=!!r;break;case Ye.INTEGER:case Ye.BIG_INTEGER:case Ye.BIG_DECIMAL:case Ye.FLOAT:case Ye.LONG:case Ye.DOUBLE:n=Number(r);break;case Ye.DATE:case Ye.DATE_TIME:case Ye.TIME:n=J(new Date(r.toString()),t.formatText);break;case Ye.JSON:case"ANY":try{"string"!=typeof r&&(n=JSON.stringify(r)),n=JSON.parse(n)}catch(e){console.log(e),n=null}break;case Ye.ENTITY:n=xr(t.properties,r)}return n},xr=(e,r)=>{if(r){const t={};return e.forEach((e=>{const{key:n,propertyType:i}=e,a=r[n];Array.isArray(a)?t[n]=a.map((r=>Cr(i,r,{formatText:e.format,properties:e.properties}))):t[n]=Cr(i,a,{formatText:e.format,properties:e.properties})})),t}return null},jr=(e,r)=>{const t={};return e.forEach((e=>{const{key:n,name:i,isRequired:a,isMultiple:l,sortOrder:o,isEnabled:s,uiSettings:c,validationNode:d}=e,p="string"==typeof e.propertyType?e.propertyType:e.propertyType.value,u=Object.assign({name:i,propertyType:p,isRequired:a,isMultiple:l,sortOrder:o,isEnabled:s,validationNode:d,uiSettings:c},((e,r)=>{const t={};let n,i="";return r?e.isMultiple?(i="values",n=e.value):(i="value",n=e.value):e.isMultiple?(i="defaultValues",n=e.defaultValue):(i="defaultValue",n=e.defaultValue),t[i]=Cr(e.propertyType,n,{formatText:e.format,properties:e.properties}),t})(Object.assign(Object.assign({},e),{propertyType:p}),r));if("isViewableInList"in e&&(u.isViewableInList=e.isViewableInList),c)try{u.uiSettings=JSON.parse(c)}catch(e){console.log(e)}else u.uiSettings=null;p===Ye.BIG_DECIMAL&&(u.precisionScale=e.precisionScale,u.roundingMode=e.roundingMode),p!==Ye.DATE&&p!==Ye.TIME&&p!==Ye.DATE_TIME||(u.format=e.format),p===Ye.STRING&&(u.restrictedValues=e.restrictedValues),p===Ye.ENTITY_REFERENCE&&(u.definitionCode=e.definitionCode,u.definitionVersion=e.definitionVersion,u.labelPropertyCode=e.labelPropertyCode,u.valuePropertyCode=e.valuePropertyCode),p===Ye.ENTITY&&(u.properties=jr(e.properties,r)),t[n]=u})),t};function Nr(e,r){return Object.keys(e).map((t=>{const n=Object.assign(Object.assign({key:t},e[t]),r||{});if(n.propertyType===Ye.ENTITY&&(n.properties=Nr(n.properties,r)),n.propertyType===Ye.JSON)try{null==n.defaultValue?n.defaultValue="":n.defaultValue=JSON.stringify(n.defaultValue)}catch(e){n.defaultValue=""}if(n.uiSettings)try{n.uiSettings=JSON.stringify(n.uiSettings)}catch(e){n.uiSettings=""}return n.isMultiple&&("defaultValues"in n&&(n.defaultValue=n.defaultValues),"values"in n&&(n.value=n.values)),n})).sort(((e,r)=>mr(e,r,"sortOrder")))}const Sr=(e,r)=>{if(r)try{const e=r.replace(/Z/g,"XXX");return J(new Date,e),e}catch(r){return console.error("Incorrect format",r),e}return e},Ir=e=>{let r=[];return r=Array.isArray(e.properties)?e.properties:Nr(e.properties),r.reduce(((e,r)=>{const t=JSON.parse(JSON.stringify(e));return r.propertyType===Ye.ENTITY?t[r.key]=Ir(r):t[r.key]=r.propertyType,t}),{})},kr=({propertyType:e,useExpression:r,required:t})=>{let n=[{value:"widget",label:"Fill array (widget)",sortOrder:1}];return t||n.push({value:"null",label:"NULL",sortOrder:0}),r&&(e===Ye.JSON||e===Ye.ENTITY||"ANY"===e?n.push({value:"expression",label:"Expression (JSON editor)",sortOrder:3}):n.push({value:"expression",label:"Expression",sortOrder:3})),e!==Ye.JSON&&"ANY"!==e&&e!==Ye.ENTITY||n.push({value:"json_valid",label:"JSON editor",sortOrder:2}),n=n.sort(((e,r)=>mr(e,r,"sortOrder"))),n},wr=({propertyType:e,useExpression:r,required:t})=>{let n=[{value:"widget",label:"Widget",sortOrder:1}];switch(t||n.push({value:"null",label:"NULL",sortOrder:0}),r&&(e===Ye.JSON||e===Ye.ENTITY||"ANY"===e?n.push({value:"expression",label:"Expression (JSON editor)",sortOrder:3}):n.push({value:"expression",label:"Expression",sortOrder:3})),e){case Ye.STRING:n[0].label="Text input";break;case Ye.INTEGER:case Ye.BIG_INTEGER:case Ye.BIG_DECIMAL:case Ye.FLOAT:case Ye.LONG:case Ye.DOUBLE:n[0].label="Number input";break;case Ye.BOOLEAN:n[0].label="Switch";break;case Ye.ENTITY_REFERENCE:n[0].label="Entity reference fields";break;case Ye.JSON:n[0].label="JSON editor";break;case Ye.DATE:n[0].label="Date picker",n.push({value:"string",label:"Text input",sortOrder:2});break;case Ye.DATE_TIME:n[0].label="Date & Time picker",n.push({value:"string",label:"Text input",sortOrder:2});break;case Ye.TIME:n[0].label="Time picker",n.push({value:"string",label:"Text input",sortOrder:2});break;case"ANY":n[0].label="Textarea"}return n=n.sort(((e,r)=>mr(e,r,"sortOrder"))),n},Pr=({inputProps:r,name:t,label:n="",control:i,required:a,defaultValue:l,disabled:o,variant:s="outlined",InputLabelProps:c,decimal:d=!1,hideErrorMessage:u=!1})=>{const g=m({name:t,control:i,defaultValue:l,rules:{required:a&&"Please, fill this field",validate:e=>d&&!vr.test(e)?"Not valid number":!(!d&&!yr.test(e))||"Not valid integer"}}),b=g.field,{ref:y,onChange:v}=b,O=p(b,["ref","onChange"]),{fieldState:{error:T}}=g,E=h({control:i,name:t});return e(f,Object.assign({fullWidth:!0,size:"small",inputRef:y,label:n,error:!!T,helperText:!u&&(null==T?void 0:T.message),disabled:o,variant:s,InputLabelProps:c,inputProps:r,onChange:v,value:null!=E?E:""},O))},Ar=({control:n,name:i,label:a})=>{const{field:{onChange:l}}=m({control:n,name:i}),o=h({control:n,name:i});O((()=>{null===o&&l(!1)}),[o]);return r(t,{children:[a&&e(D,{children:a}),e(S,{label:(!!o+"").toUpperCase(),name:i,control:e(z,{color:"primary",size:"small",onChange:e=>{const{checked:r}=e.target;l(r)},checked:!!o+""=="true"})})]})},Vr=({control:r,name:t,required:n,label:i,format:a=_e,hideErrorMessage:l=!1})=>{const{field:{onChange:o,ref:s},fieldState:{error:c}}=m({control:r,name:t,rules:{required:n&&"Please, fill this field",validate:e=>!!G(e,a)||"Incorrect date format"}}),d=h({control:r,name:t});return e(B,{mask:"",label:i,inputRef:s,inputFormat:a,value:d||null,onChange:e=>{o(Y(e)?J(e,a):e)},renderInput:r=>e(f,Object.assign({},r,{fullWidth:!0,size:"small",variant:"outlined",name:t,error:!!c,helperText:!l&&(null==c?void 0:c.message)}))})},qr=({control:r,name:t,required:n,label:i,format:a=He,hideErrorMessage:l=!1})=>{const{field:{onChange:o,ref:s},fieldState:{error:c}}=m({control:r,name:t,rules:{required:n&&"Please, fill this field",validate:e=>!!G(e,a)||"Incorrect date format"}}),d=h({control:r,name:t});return e(W,{mask:"",ampm:!1,inputRef:s,label:i,value:d||null,inputFormat:a,onChange:e=>{o(Y(e)?J(e,a):e)},renderInput:r=>e(f,Object.assign({},r,{fullWidth:!0,size:"small",variant:"outlined",name:t,error:!!c,helperText:!l&&(null==c?void 0:c.message)}))})},Lr=({control:r,name:t,required:n,label:i,format:a=We,hideErrorMessage:l=!1})=>{const{field:{onChange:o,ref:s},fieldState:{error:c}}=m({control:r,name:t,rules:{required:n&&"Please, fill this field",validate:e=>!!G(e,a)||"Incorrect date format"}}),d=h({control:r,name:t}),[p,u]=T(null);return O((()=>{if(d&&a){let e=_(d,a,new Date);Y(e)||(e=_(d,"HH:mm:ss.SSS",new Date)),u(e)}}),[d,a]),e(H,{mask:"",inputRef:s,label:i,ampm:!1,value:p,inputFormat:a,onChange:e=>{u(e),o(Y(e)?J(e,a):e)},renderInput:r=>e(f,Object.assign({},r,{fullWidth:!0,size:"small",variant:"outlined",name:t,error:!!c,helperText:!l&&(null==c?void 0:c.message)}))})};var Rr=()=>{const n=X(),i=Z(n,Q),a=Z(n,ee),l=Z(n,re),o=Z(n,te),s=e=>n.current.setPage(e);return r(c,Object.assign({px:2,display:"flex",alignItems:"center"},{children:[e(K,{component:"div",page:i,count:l,rowsPerPage:o,rowsPerPageOptions:[10,20,50,100],onPageChange:(e,r)=>s(r),onRowsPerPageChange:e=>n.current.setPageSize(parseInt(e.target.value,10)),ActionsComponent:()=>e(t,{})}),e(U,{count:a,page:i+1,onChange:(e,r)=>s(r-1)})]}))};var Mr=r=>{var{hideMenu:t,currentColumn:n,onUnsort:i}=r,a=p(r,["hideMenu","currentColumn","onUnsort"]);return e(ne,Object.assign({hideMenu:t,currentColumn:n},a,{children:e(ie,{onClick:t,column:n})}))};var $r=({mode:e})=>{const r=L(),{search:t,state:n}=R(),i=E((()=>new URLSearchParams(t)),[t]),a=+i.get("page")||0,l=+i.get("size")||10;return O((()=>{"server"===e&&(i.has("page")||i.set("page","0"),i.has("size")||i.set("size","10"),r.replace({pathname:r.location.pathname,search:i.toString()},n))}),[t,e]),{page:a,size:l,onPageChange:e=>{i.set("page",`${e}`),r.replace({pathname:r.location.pathname,search:i.toString()})},onSizeChange:e=>{i.set("size",`${e}`),r.replace({pathname:r.location.pathname,search:i.toString()})}}};var Dr=()=>{const e=L(),{search:r,state:t}=R(),n=E((()=>new URLSearchParams(r)),[r]),i=n.getAll("sort").map((e=>e.split(",")));return{onColumnHeaderClick:({field:r})=>{let i=!1;const a=n.getAll("sort");n.delete("sort"),a.forEach((e=>{const[t,a]=e.split(",");t===r?(i=!0,"asc"===a&&n.append("sort",`${t},desc`)):n.append("sort",`${t},${a}`)})),i||n.append("sort",`${r},asc`),e.replace({pathname:e.location.pathname,search:n.toString()},t)},getSortedColumns:e=>e.map((e=>{const r=i.find((r=>r[0]===e.field));return e.headerClassName=r?`Sorted --${r[1]} `:"",e}))}};var Fr=e=>{const[r,t]=T(10);O((()=>{t(e)}),[e]);return{pageSize:r,handlePageSizeChange:e=>t(e)}},zr=oe({root:{width:"100%","& .MuiDataGrid-virtualScrollerContent":{height:"auto !important",minHeight:"56px !important"},"& .MuiDataGrid-virtualScrollerRenderZone":{position:"static"},"& .MuiDataGrid-renderingZone":{maxHeight:"none !important"},"& .MuiDataGrid-cell":{maxHeight:"none !important",lineHeight:"unset !important",whiteSpace:"normal !important",textOverflow:"ellipsis",wordBreak:"break-all","& .MuiDataGrid-actionsCell":{width:"100%",gridGap:"4px",flexWrap:"wrap",'& > button[aria-label="more"]':{marginLeft:"auto"}}},"& .MuiDataGrid-row":{maxHeight:"none !important"},"& .Sorted":{"& .MuiDataGrid-iconButtonContainer":{visibility:"visible",width:"auto","& svg":{opacity:"1 !important"}},"&.--desc":{"& svg":{transform:"rotate(180deg)"}}}}});const Br=({columns:r,rows:t,rowCount:n,loading:i,disableMargin:a,mode:l="server",initialPageSize:o=10,pagination:s=!0,onCellClick:d})=>{const p=zr(),{page:u,size:m,onPageChange:h,onSizeChange:g}=$r({mode:l}),{onColumnHeaderClick:b,getSortedColumns:f}=Dr(),{pageSize:y,handlePageSizeChange:v}=Fr(o),O={sortingMode:l,paginationMode:l,pageSize:"server"===l?m:s?y:n,onPageSizeChange:"server"===l?g:v,components:{Pagination:Rr}};return"server"===l&&(O.sortModel=[],O.onColumnHeaderClick=b,O.page=u,O.onPageChange=h,O.components.ColumnMenu=Mr),e(c,Object.assign({mt:a?0:2},{children:e(ae,Object.assign({autoHeight:!0,hideFooterPagination:!s,hideFooter:!s,disableSelectionOnClick:!0,showColumnRightBorder:!0,showCellRightBorder:!0,className:p.root,loading:i,rows:t,columns:f(r),rowCount:n,rowsPerPageOptions:[10,20,50,100],onCellClick:d},O))}))},Jr=({icon:r,label:t,showInMenu:n,onClick:i,location:a})=>a?e(V,Object.assign({component:M,to:a,size:"small"},{children:e(A,Object.assign({title:t,arrow:!0},{children:y.cloneElement(r,{fontSize:"small"})}))})):e(le,{nonce:!1,onResize:!1,onResizeCapture:!1,icon:e(A,Object.assign({title:t,arrow:!0},{children:r})),onClick:i,label:t,showInMenu:n}),Gr=r=>{const{children:t,value:n,index:i}=r,a=p(r,["children","value","index"]);return e("div",Object.assign({role:"tabpanel",hidden:n!==i,id:`simple-tabpanel-${i}`,"aria-labelledby":`simple-tab-${i}`},a,{children:n===i?t:null}))},Yr=t=>{var n;const{tabs:i}=t,a=L(),l=R(),o=E((()=>new URLSearchParams(l.search)),[l.search]),s=o.get("tab");return r(c,{children:[e(se,{children:e(de,Object.assign({value:s||(null===(n=i[0])||void 0===n?void 0:n.name),indicatorColor:"primary",textColor:"primary",onChange:(e,r)=>{o.set("tab",r),a.replace({pathname:a.location.pathname,search:o.toString()})}},{children:i.map((r=>e(ce,{value:r.name,label:r.label},r.name)))}))}),e(c,Object.assign({mt:2},{children:i.map((r=>{var t;return e(Gr,Object.assign({value:s||(null===(t=i[0])||void 0===t?void 0:t.name),index:r.name},{children:r.component}),r.name)}))}))]})},_r=({open:t,onClose:o,value:s})=>r(i,Object.assign({disableEscapeKeyDown:!0,open:t,onClose:o,fullWidth:!0,maxWidth:"md",style:{width:800,left:"30%"}},{children:[e(l,{children:e($,{readOnly:!0,value:s,mode:"json",width:"100%",fontSize:"16",setOptions:{enableSnippets:!1,copyWithEmptySelection:!0,showLineNumbers:!0,tabSize:2}})}),r(a,{children:[e(or,{copyText:s}),e(n,Object.assign({onClick:o,variant:"contained",color:"secondary"},{children:"Close"}))]})]}));var Wr=oe((()=>({container:{borderBottom:"1px solid #ccc",paddingBottom:"8px"},title:{fontSize:"14px",fontWeight:600,color:"#536DFE"},text:{fontSize:"18px",wordWrap:"break-word"}})));const Hr=({title:t,text:n,json:i})=>{const a=Wr();return r("div",Object.assign({className:a.container},{children:[e("div",Object.assign({className:a.title},{children:t})),n&&e("div",Object.assign({className:a.text},{children:n})),i&&e($,{readOnly:!0,value:i,mode:"json",height:"300px",width:"100%",fontSize:"16",setOptions:{enableSnippets:!1,copyWithEmptySelection:!0,showLineNumbers:!0,tabSize:2}})]}))},Ur=Object.values(Ue).sort(((e,r)=>e.localeCompare(r)));var Kr=({propertyFieldName:n})=>{const{control:i}=g();return r(t,{children:[e(pe,{children:e(Pr,{required:!0,control:i,defaultValue:2,name:`${n}.precisionScale`,label:"Precision Scale"})}),e(pe,{children:e(tr,{required:!0,control:i,name:`${n}.roundingMode`,label:"Rounding Mode",defaultValue:Ue.HALF_UP,options:Ur})})]})};var Xr=({propertyFieldName:r,defaultValue:t=""})=>{const{control:n}=g();return e(pe,{children:e(Ze,{required:!0,control:n,defaultValue:t,name:`${r}.format`,label:"Format"})})};const Zr=oe((()=>({content:{marginLeft:"4px"},connector:{marginLeft:"4px"},stepper:{padding:"12px"},label:{display:"flex",alignItems:"flex-start"}}))),Qr=()=>e("div",{style:{display:"inline-block",width:"10px",height:"10px",borderRadius:"50%",backgroundColor:"#536DFE",marginTop:"5px"}}),et=({data:t})=>{const n=Zr();return r(fe,Object.assign({nonLinear:!0,orientation:"vertical",className:n.stepper,connector:e(Te,{className:n.connector})},{children:[t.map(((t,i)=>r(ye,Object.assign({expanded:!0},{children:[e(ve,Object.assign({className:n.label,StepIconComponent:Qr,StepIconProps:{icon:"",completed:!1,active:!0}},{children:t.label})),e(Oe,Object.assign({className:n.content},{children:t.content}))]}),i))),e(ye,{})]}))},rt=({properties:t=[]})=>{const n=E((()=>t?t.map((t=>{const n="string"==typeof t.propertyType?t.propertyType:t.propertyType.value;return{label:r(c,Object.assign({display:"flex",flexDirection:"column"},{children:[r("b",{children:[t.name,t.isRequired?"*":""]}),r("span",{children:[t.key," | ",t.isMultiple?"multiple":"single"," | ",n]})]})),content:"ENTITY"===t.propertyType&&e(rt,{properties:t.properties})}})):[]),[t]);return e(et,{data:n})};var tt=rt;const nt={key:"",propertyType:"",name:"",defaultValue:"",isRequired:!0,isMultiple:!1,sortOrder:0,isEnabled:!0};var it=({parentPropertyFieldName:o,entityDefinition:c=!1,globalParameter:d=!1})=>{const{control:p,setValue:m,getValues:b,trigger:f}=g(),y=h({control:p,name:`${o}.properties`,defaultValue:b(`${o}.properties`)||[]}),v=h({control:p,name:`${o}.name`}),O=er(),[E,x]=T(0),j=C((()=>{if(y){const e=y.length;m(`${o}.properties.${e}`,nt),x(e)}else m(`${o}.properties`,[nt])}),[y,o,m]),N=()=>u(void 0,void 0,void 0,(function*(){(yield f(`${o}.properties`))&&O.onClose()}));return r(t,{children:[e(pe,{children:e(D,Object.assign({variant:"h6"},{children:"Properties"}))}),e(pe,{children:e(tt,{properties:y})}),e(pe,{children:e(n,Object.assign({variant:"contained",color:"primary",onClick:O.onOpen},{children:"Edit properties"}))}),r(i,Object.assign({disableEscapeKeyDown:!0,open:O.open,onClose:N,fullWidth:!0,maxWidth:"md"},{children:[r(s,{children:[v||"Entity"," Properties"]}),e(l,Object.assign({style:{height:"500px",overflow:"hidden"}},{children:r(pe,Object.assign({container:!0,direction:"row",spacing:2,style:{height:"100%"}},{children:[r(pe,Object.assign({xs:3,style:{backgroundColor:"#f9f9f9"}},{children:[e(fe,Object.assign({nonLinear:!0,activeStep:E,orientation:"vertical",style:{paddingLeft:"4px"}},{children:y.map(((t,n)=>r(ye,Object.assign({onClick:()=>(e=>x(e))(n),style:{cursor:"pointer"}},{children:[e(ve,Object.assign({StepIconProps:{icon:""},style:{wordBreak:"break-word"}},{children:t.name||"(no name)"})),e(Oe,{})]}),n)))})),e(n,Object.assign({variant:"contained",size:"small",color:"primary",onClick:j},{children:"Add property"}))]})),e(pe,Object.assign({container:!0,wrap:"nowrap",direction:"column",xs:9,spacing:2,style:{height:"100%",overflowY:"auto"}},{children:e(xt,{hideAddButton:!0,parentFieldName:o,focusOnIndex:E,entityDefinition:c,globalParameter:d})}))]}))})),e(a,{children:e(n,Object.assign({variant:"contained",color:"primary",onClick:N},{children:"Ok"}))})]}))]})};var at=({propertyFieldName:n})=>{const{control:i}=g();return r(t,{children:[e(pe,{children:e(Ze,{required:!0,control:i,name:`${n}.definitionCode`,label:"Definition Code"})}),e(pe,{children:e(Ze,{required:!0,control:i,name:`${n}.definitionVersion`,label:"Definition Version"})}),e(pe,{children:e(Ze,{required:!0,control:i,name:`${n}.labelPropertyCode`,label:"Label Property Code"})}),e(pe,{children:e(Ze,{required:!0,control:i,name:`${n}.valuePropertyCode`,label:"Value Property Code"})})]})};var lt=({propertyFieldName:n})=>{const i=E((()=>`${n}.restrictedValues`),[n]),{control:a,setValue:l,getValues:o}=g(),s=h({control:a,name:i,defaultValue:o(`${n}.restrictedValues`)||[]}),[d,p]=T(""),[u,m]=T(""),b=C((e=>{l(i,dr(s,e))}),[s,i,l]),y=()=>{d&&(l(i,[...s,d]),p(""))};return r(t,{children:[e(pe,{children:e(D,Object.assign({variant:"h6"},{children:"Restricted Values"}))}),e(pe,{children:e(c,Object.assign({display:"flex",flexWrap:"wrap"},{children:null==s?void 0:s.map(((r,t)=>e(Ee,{variant:"outlined",label:r,onDelete:()=>b(t)},t)))}))}),e(pe,{children:e(f,{fullWidth:!0,variant:"outlined",size:"small",label:"Add restricted value",value:d,onChange:e=>{const{value:r}=e.target;p(r),s.includes(r)?m("This value already exists"):m("")},error:!!u,helperText:u,name:"restrictedValues",inputProps:{onKeyDown:e=>{"Enter"===e.key&&y()}},InputProps:{endAdornment:e(V,Object.assign({size:"small",onClick:y,disabled:!!u},{children:e(Ce,{})}))}})})]})};const ot=({propertyType:r,propertyFieldName:t,entityDefinition:n=!1,globalParameter:i=!1})=>{switch(r){case Ye.STRING:return e(lt,{propertyFieldName:t});case Ye.BIG_DECIMAL:return e(Kr,{propertyFieldName:t});case Ye.DATE:return e(Xr,{propertyFieldName:t,defaultValue:_e});case Ye.TIME:return e(Xr,{propertyFieldName:t,defaultValue:We});case Ye.DATE_TIME:return e(Xr,{propertyFieldName:t,defaultValue:He});case Ye.ENTITY_REFERENCE:return e(at,{propertyFieldName:t});case Ye.ENTITY:return e(it,{parentPropertyFieldName:t,globalParameter:i,entityDefinition:n});default:return null}};var st=({validate:r=!1,name:t,inputRef:n})=>{const{control:i,setValue:a,setError:l,clearErrors:o}=g(),s=h({control:i,name:t});return e($,{wrapEnabled:!0,width:"100%",height:"200px",theme:"monokai",fontSize:14,showPrintMargin:!1,style:{lineHeight:1.4,zIndex:0,isolation:"isolate"},setOptions:{enableLiveAutocompletion:!0,enableBasicAutocompletion:!0,showLineNumbers:!0,tabSize:2},ref:n,name:t,value:"string"!=typeof s?null===s?"":JSON.stringify(s):s,onChange:e=>{if(a(t,e),r)try{JSON.parse(e),o(t)}catch(e){l(t,{message:"Invalid JSON"})}},mode:"json",onLoad:e=>{r||e.getSession().setUseWorker(!1)}})};var ct=({name:t,label:n,required:i,restrictedValues:a})=>{const{control:l}=g(),{field:{onChange:o,ref:s},fieldState:{error:c}}=m({control:l,name:t,rules:{required:i&&(Array.isArray(a)&&a.length?"Please, select a value":"Please, fill this field")}}),d=h({control:l,name:t});return Array.isArray(a)&&a.length?r(je,Object.assign({fullWidth:!0,size:"small",variant:"outlined",error:!!c},{children:[e(Ne,Object.assign({htmlFor:"type-select"},{children:n})),e(xe,Object.assign({labelId:"type-select",label:n,value:d||"",onChange:o,ref:s},{children:a.map((r=>e(j,Object.assign({value:r},{children:r}),r)))}))]})):e(Ze,{hideErrorMessage:!0,required:i,control:l,name:t,label:n})};const dt=({property:r,name:t,label:n,useExpression:i,inputRef:a})=>{const{control:l}=g();switch(E((()=>"string"==typeof r.propertyType?r.propertyType:r.propertyType.value),[r])){case Ye.BIG_DECIMAL:case Ye.FLOAT:case Ye.DOUBLE:return e(Pr,{decimal:!0,required:!0,hideErrorMessage:!0,control:l,name:t,label:n});case Ye.INTEGER:case Ye.BIG_INTEGER:case Ye.LONG:return e(Pr,{required:!0,hideErrorMessage:!0,control:l,name:t,label:n});case Ye.BOOLEAN:return e(Ar,{control:l,name:t});case Ye.DATE:return e(Vr,{required:!0,hideErrorMessage:!0,control:l,name:t,label:n,format:r.format});case Ye.TIME:return e(Lr,{required:!0,hideErrorMessage:!0,control:l,name:t,label:n,format:r.format});case Ye.DATE_TIME:return e(qr,{required:!0,hideErrorMessage:!0,control:l,name:t,label:n,format:r.format});case Ye.JSON:return e(st,{validate:!0,name:t,inputRef:a});case Ye.STRING:return e(ct,{required:!0,name:t,label:n,restrictedValues:r.restrictedValues});case Ye.ENTITY_REFERENCE:return e(Ze,{required:!0,hideErrorMessage:!0,name:t,label:n,control:l});case"ANY":return e(st,{name:t,inputRef:a});case Ye.ENTITY:return e(qt,{properties:r.properties,dataFieldName:t,useExpression:i});default:return e("div",{children:"No widget"})}};var pt=({property:e,name:r,label:t,isDirty:n,required:i=!1,useExpression:a=!1,multipleOptions:l=!1})=>{const{control:o}=g(),s=h({control:o,name:r}),c=E((()=>t?`${t} (value)`:`${e.name} (value)`),[t,e]),d=E((()=>t?`${t} (widget)`:`${e.name} (widget)`),[t,e]),p=E((()=>"string"==typeof e.propertyType?e.propertyType:e.propertyType.value),[e]),[u,m]=T(null),b=E((()=>l?kr({propertyType:p,required:i,useExpression:a}):wr({propertyType:p,required:i,useExpression:a})),[a,i,p,l]);return O((()=>{u?n||(Or(s)&&"expression"!==u?m("expression"):null===s||Or(s)||"widget"===u||m("widget")):Er(s)&&(null==b?void 0:b.length)?m(b[0].value):a&&Or(s)?m("expression"):m("widget")}),[s,u,b,a,n]),{propertyType:p,valueLabel:c,fillOptionLabel:d,fillOption:u,fillOptions:b,setFillOption:m}};var ut=oe((()=>({inputLabel:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",width:"100%"}})));const mt=({property:t,name:n,useExpression:i,label:a,required:l,title:o})=>{const{control:s,clearErrors:d}=g(),{field:{ref:p,onChange:u},fieldState:{error:b,isDirty:f}}=m({name:n,rules:{validate:{required:e=>!l||!Er(e)||"Please, fill this field"}}}),y=h({control:s,name:n}),{propertyType:v,valueLabel:T,fillOptionLabel:E,fillOption:C,fillOptions:x,setFillOption:N}=pt({property:t,name:n,isDirty:f,label:a,required:l,useExpression:i});O((()=>{void 0===y&&u(null)}),[y,u]);const S=ut();return r(pe,Object.assign({xs:12},{children:[o&&e(c,Object.assign({mb:2},{children:e(D,Object.assign({variant:"h6"},{children:o}))})),x?e(c,Object.assign({mb:2},{children:r(je,Object.assign({fullWidth:!0,size:"small",variant:"outlined"},{children:[e(Ne,Object.assign({htmlFor:"type-select",className:S.inputLabel},{children:E})),e(xe,Object.assign({labelId:"type-select",label:E,value:C||"",onChange:e=>{const r=e.target.value;"null"===r||"widget"===r?u(null):"expression"!==r&&"string"!==r||u(""),N(r),d(n)}},{children:x.map((r=>e(j,Object.assign({value:r.value},{children:r.label}),r.value)))}))]}))})):null,"expression"===C&&(v===Ye.JSON||v===Ye.ENTITY||"ANY"===v?e(st,{name:n,inputRef:p}):e(Ze,{control:s,name:n,label:T,required:!0,hideErrorMessage:!0})),"string"===C&&e(Ze,{control:s,name:n,label:T,required:!0,hideErrorMessage:!0}),"json_notvalid"===C&&e(st,{name:n,inputRef:p}),"widget"===C&&e(dt,{property:t,name:n,useExpression:i,label:T,inputRef:p,required:l}),b&&e(D,Object.assign({color:"secondary"},{children:b.message}))]}))};var ht=({name:t,property:i,useExpression:a,required:l,label:o})=>{const{control:s,setValue:d,clearErrors:p}=g();m({control:s,name:t,rules:{validate:e=>!(!e||Array.isArray(e)&&!e.length)||"Please, fill array"}});const u=h({control:s,name:t}),b=C((()=>{u&&Array.isArray(u)?d(`${t}.${u.length}`,null):d(t,[null]),p(t)}),[t,u,d]),f=C((e=>{d(t,dr(u,e))}),[t,u,d]);return r(pe,Object.assign({container:!0,spacing:2,direction:"column",xs:12},{children:[u&&Array.isArray(u)?u.map(((n,s)=>e(pe,Object.assign({xs:12},{children:r(c,Object.assign({display:"flex",alignItems:"flex-start",width:"100%",p:2,style:{backgroundColor:"#f1f1f1"}},{children:[e(mt,{required:l,property:i,useExpression:a,name:`${t}.${s}`,label:`${o||i.name} (${s+1})`}),e(c,Object.assign({mt:"8px",ml:"4px"},{children:e(V,Object.assign({size:"small",onClick:()=>f(s)},{children:e(Se,{fontSize:"small"})}))}))]}))}),s))):null,e(pe,{children:e(n,Object.assign({variant:"contained",size:"small",color:"primary",onClick:b},{children:"Add value"}))})]}))};const gt=({property:t,name:n,useExpression:i,required:a,label:l,title:o})=>{const{control:s,clearErrors:d}=g(),{field:{ref:p,onChange:u},fieldState:{error:b,isDirty:f}}=m({control:s,name:n,rules:{validate:e=>!(a&&!e)||"Please, fill this field"}}),y=h({control:s,name:n}),{propertyType:v,valueLabel:T,fillOptionLabel:E,fillOption:C,fillOptions:x,setFillOption:N}=pt({property:t,name:n,isDirty:f,label:l,required:a,useExpression:i,multipleOptions:!0});O((()=>{void 0===y&&u(null)}),[y,u]);const S=ut();return r(pe,{children:[o&&e(c,Object.assign({mb:2},{children:e(D,Object.assign({variant:"h6"},{children:o}))})),x?e(c,Object.assign({mb:2},{children:r(je,Object.assign({fullWidth:!0,size:"small",variant:"outlined"},{children:[e(Ne,Object.assign({htmlFor:"type-select",className:S.inputLabel},{children:E})),e(xe,Object.assign({labelId:"type-select",label:E,value:C||"",onChange:e=>{const r=e.target.value;"null"===r?u(null):"expression"===r||"json_valid"===r||"json_notvalid"===r?u(""):"widget"===r&&u([]),N(r),d(n)}},{children:x.map((r=>e(j,Object.assign({value:r.value},{children:r.label}),r.value)))}))]}))})):null,"expression"===C&&(v===Ye.JSON||v===Ye.ENTITY||"ANY"===v?e(st,{name:n,inputRef:p}):e(Ze,{required:!0,hideErrorMessage:!0,control:s,name:n,label:T})),"json_valid"===C&&e(st,{validate:!0,name:n,inputRef:p}),"widget"===C&&e(ht,{property:t,name:n,useExpression:i,required:a,label:l}),b&&e(D,Object.assign({color:"secondary"},{children:b.message}))]})},bt=({propertyFieldName:r,name:t,label:n="",required:i})=>{const{control:a}=g(),l=h({control:a,name:`${r}.propertyType`}),o=h({control:a,name:`${r}.isMultiple`}),s=h({control:a,name:`${r}.format`}),c=h({control:a,name:`${r}.restrictedValues`}),d=h({control:a,name:`${r}.properties`}),p=h({control:a,name:`${r}.isRequired`}),u=E((()=>{const e="string"==typeof l?l:l.value;return{name:n,isRequired:p,isMultiple:o,format:s,restrictedValues:c,properties:d,propertyType:e,defaultValue:null,defaultValues:[],sortOrder:0,isEnabled:!0,uiSettings:null,validationNode:null}}),[l,s,c,o,n,p,d]);return e(o?gt:mt,{name:t,property:u,title:n,required:i})};var ft=({propertyType:e,control:r,name:t,label:n,required:i,format:a,restrictedValues:l,properties:o})=>null;const yt=({property:i,name:a,label:l,required:o="byProperty"})=>{const{control:s,setValue:d}=g(),p=h({control:s,name:a}),u=C((e=>{d(a,dr(p,e))}),[a,p,d]),m=C((()=>{p&&Array.isArray(p)?d(`${a}.${p.length}`,null):d(a,[null])}),[a,p,d]),b=E((()=>({control:s,name:a,label:l,required:"byProperty"===o?i.isRequired:o,propertyType:"string"==typeof i.propertyType?i.propertyType:i.propertyType.value,format:i.format,restrictedValues:i.restrictedValues,properties:i.properties})),[a,l,o,i,s]);return i.isMultiple?r(pe,Object.assign({container:!0,spacing:2,direction:"column"},{children:[p&&Array.isArray(p)?e(t,{children:p.map(((t,n)=>e(pe,{children:r(c,Object.assign({display:"flex",alignItems:"center",width:"100%"},{children:[e(ft,Object.assign({},b,{label:`${i.name} (${n+1})`,name:`${a}.${n}`})),e(V,Object.assign({size:"small",onClick:()=>u(n)},{children:e(Se,{fontSize:"small"})}))]}))},n)))}):null,e(pe,{children:e(n,Object.assign({variant:"contained",size:"small",color:"primary",onClick:m},{children:"Add value"}))})]})):e(ft,Object.assign({},b))};var vt=({name:r,label:t="",propertyFieldName:n,type:i,decimal:a=!1,options:l=[],required:o=!1})=>{const{control:s}=g(),c=E((()=>`${n}.${r}`),[r,n]);switch(i){case"text":return e(Ze,{control:s,name:c,label:t,required:o});case"number":return e(Pr,{control:s,name:c,label:t,decimal:a,required:o});case"select":return e(tr,{control:s,name:c,label:t,options:l,required:o});case"autocomplete":return e(ar,{control:s,name:c,label:t,options:l,required:o});case"json":return e(cr,{control:s,name:c,label:t,mode:"json",required:o});default:return null}};var Ot=e=>({customCheckboxes:E((()=>e.length?e.filter((e=>"checkbox"===e.type)):[]),[e]),customFields:E((()=>e.length?e.filter((e=>"checkbox"!==e.type)):[]),[e])});const Tt=Object.values(Ye).sort(((e,r)=>e.localeCompare(r))).map((e=>({value:e,label:e.replace("_"," ").toLowerCase().replace(/(^\w)|([-\s]\w)/g,(e=>e.toUpperCase()))})));var Et=({propertyFieldName:n,entityDefinition:i=!1,globalParameter:a=!1,customPropertyFields:l=[],hasAny:o=!1})=>{const{control:s,setValue:c}=g();h({control:s,name:n});const d=h({control:s,name:`${n}.propertyType`}),p=h({control:s,name:`${n}.isMultiple`}),u=h({control:s,name:`${n}.isRequired`}),{customCheckboxes:m,customFields:b}=Ot(l),f=E((()=>o?[{value:"ANY",label:"Any"},...Tt]:Tt),[o]),y=E((()=>{let e=a?"Value":"Default Value";return p&&(e+="s"),e}),[a,p]);return r(pe,Object.assign({container:!0,direction:"column",spacing:2},{children:[e(pe,{children:e(rr,{required:!0,control:s,name:`${n}.key`,label:"Key"})}),e(pe,{children:e(rr,{required:!0,control:s,name:`${n}.name`,label:"Name"})}),e(pe,{children:e(ar,{required:!0,control:s,name:`${n}.propertyType`,label:"Type",options:f,onChange:(e,r)=>{const t=`${n}.${a?"value":"defaultValue"}`;c(t,p?[]:null),c(e,r)}})}),e(pe,{children:e(Pr,{required:!0,control:s,name:`${n}.sortOrder`,label:"Sort Order"})}),e(pe,{children:e(cr,{control:s,name:`${n}.uiSettings`,label:"UI Settings",validateJson:!0})}),r(pe,{children:[e(nr,{control:s,name:`${n}.isMultiple`,label:"Multiple"}),e(nr,{control:s,name:`${n}.isEnabled`,label:"Enabled"}),e(nr,{control:s,name:`${n}.isRequired`,label:"Required"}),i&&e(nr,{control:s,name:`${n}.isViewableInList`,label:"Is viewable in list"}),m.length?e(t,{children:m.map(((r,t)=>e(nr,{control:s,name:`${n}.${r.name}`,label:r.label},t)))}):null]}),d&&r(t,{children:[e(ot,{propertyType:"string"==typeof d?d:d.value,propertyFieldName:n,globalParameter:a,entityDefinition:i}),e(pe,{children:e(bt,{propertyFieldName:n,name:`${n}.${a?"value":"defaultValue"}`,label:y,required:!!a&&u})})]}),b.length?e(t,{children:b.map(((r,t)=>e(pe,{children:e(vt,Object.assign({},r,{propertyFieldName:n}))},t)))}):null]}))};const Ct={key:"",propertyType:"",name:"",defaultValue:"",defaultValues:[],isRequired:!0,isMultiple:!1,sortOrder:0,isEnabled:!0,executeValue:"",uiSettings:""},xt=({parentFieldName:i,hideAddButton:a,focusOnIndex:l,required:o,entityDefinition:s=!1,globalParameter:c=!1,customPropertyFields:d=[],hasAny:p})=>{const u=E((()=>i?`${i}.properties`:"properties"),[i]),{setValue:b,clearErrors:f,control:y}=g(),{fieldState:{error:T}}=m({control:y,name:u,rules:{required:o&&"Please, add properties"}}),x=h({control:y,name:u}),j=v([]);O((()=>{"number"==typeof l&&j.current[l]&&j.current[l].scrollIntoView({behavior:"smooth",block:"start"})}),[l,j]);const N=C((()=>{x?b(`${u}.${x.length}`,Ct):b(u,[Ct]),f(u)}),[x,u,f,b]),S=C((e=>{b(`${u}`,dr(x,e))}),[x,u,b]);return r(t,{children:[T&&T.message&&e(pe,Object.assign({sm:12,md:8,lg:6},{children:e(D,Object.assign({color:"secondary"},{children:T.message}))})),x&&x.map(((t,i)=>e(pe,Object.assign({sm:12,md:8,lg:6,ref:e=>j.current[i]=e},{children:r(ue,Object.assign({defaultExpanded:!0,elevation:3},{children:[e(me,Object.assign({expandIcon:e(be,{})},{children:e(D,Object.assign({color:T&&T[i]?"secondary":"initial",style:{wordBreak:"break-word"}},{children:t.name||`Property ${i+1}`}))})),e(he,{children:e(Et,{propertyFieldName:`${u}.${i}`,entityDefinition:s,globalParameter:c,customPropertyFields:d,hasAny:p})}),e(ge,{children:e(n,Object.assign({variant:"contained",size:"small",color:"secondary",onClick:()=>S(i)},{children:"Remove"}))})]}))}),i))),!a&&e(pe,Object.assign({xs:12},{children:e(n,Object.assign({variant:"contained",size:"small",color:"primary",onClick:N},{children:"Add property"}))}))]})},jt=({definitionFieldName:t,title:n,hideCodeField:i,hideVersionField:a,hideNameField:l,required:o=!1,hasAny:s})=>{const{control:d}=g();return r(pe,Object.assign({container:!0,direction:"column",spacing:2},{children:[n&&e(pe,Object.assign({sm:12,md:8,lg:6},{children:e(c,Object.assign({my:2},{children:e(D,Object.assign({variant:"h4"},{children:n}))}))})),!l&&e(pe,Object.assign({sm:12,md:8,lg:6},{children:e(Ze,{required:!0,control:d,name:t?`${t}.name`:"name",label:"Name"})})),!i&&e(pe,Object.assign({sm:12,md:8,lg:6},{children:e(Ze,{required:!0,control:d,name:t?`${t}.code`:"code",label:"Code"})})),!a&&e(pe,Object.assign({sm:12,md:8,lg:6},{children:e(Pr,{required:!0,control:d,decimal:!1,name:t?`${t}.version`:"version",label:"Version"})})),e(xt,{required:o,parentFieldName:t,hasAny:s})]}))},Nt=({value:r,height:t="200px"})=>{const n=E((()=>{if("string"==typeof r)return r;if("object"==typeof r)try{return JSON.stringify(r,null,"\t")}catch(e){return"Failed to parse JSON"}return null}),[r]);return e($,{readOnly:!0,value:n,mode:"json",width:"100%",height:t,fontSize:"16",setOptions:{enableSnippets:!1,copyWithEmptySelection:!0,showLineNumbers:!0,tabSize:2}})},St={name:"Name",key:"Key",propertyType:"Property Type",defaultValue:"Default Value",defaultValues:"Default Values",sortOrder:"Sort Order",isRequired:"Required",isMultiple:"Multiple",isEnabled:"Enabled",isViewableInList:"Is Viewable In List",precisionScale:"Precision Scale",roundingMode:"Rounding Mode",format:"Format",definitionCode:"Definition Code",definitionVersion:"Definition Version",labelPropertyCode:"Label Property Code",valuePropertyCode:"Value Property Code",restrictedValues:"Restricted Values",value:"Value",values:"Values",uiSettings:"UI Settings"},It=({value:r,type:t})=>t!==Ye.JSON&&t!==Ye.ENTITY&&"ANY"!==t||!r?e(D,Object.assign({variant:"subtitle1",display:"inline",style:{wordBreak:"break-word"}},{children:null===r?"null":r.toString()})):e(Nt,{value:r}),kt=(r,t,n)=>{switch(t){case"isRequired":case"isMultiple":case"isEnabled":case"isViewableInList":return r?e(Ae,{color:"primary",fontSize:"small"}):null;case"restrictedValues":return r?e(c,Object.assign({display:"flex",flexWrap:"wrap"},{children:r.map((r=>e(Ee,{label:r,style:{wordBreak:"break-word",maxWidth:"500px"}},r)))})):null;case"defaultValue":case"value":return e(It,{value:r,type:n});case"values":case"defaultValues":return Array.isArray(r)&&n!==Ye.ENTITY&&n!==Ye.JSON&&"ANY"!==n?e("div",{children:null==r?void 0:r.map(((r,t)=>e("div",{children:e(It,{value:r,type:n})},t)))}):e(Nt,{value:r});case"uiSettings":return r?e(Nt,{value:r}):null;default:return e(D,Object.assign({variant:"subtitle1",display:"inline",style:{wordBreak:"break-word"}},{children:r}))}};var wt=({property:t})=>{const n=E((()=>(t&&(t.isMultiple?(delete t.defaultValue,delete t.value):(delete t.defaultValues,delete t.values)),t)),[t]);return e(Ie,Object.assign({size:"small"},{children:e(ke,{children:Object.keys(St).map((t=>t in n?r(we,{children:[e(Pe,Object.assign({width:"30%"},{children:e(D,{children:St[t]})})),e(Pe,{children:kt(n[t],t,n.propertyType)})]},t):null))})}))};var Pt=x((({properties:t,parentNames:n=[]})=>{const i=E((()=>{let e=!1;return t.every((r=>r.propertyType!==Ye.ENTITY||(e=!0,!1))),e}),[t]);return r(c,Object.assign({mt:4},{children:[e(D,Object.assign({variant:"h6"},{children:"Properties"})),r(fe,Object.assign({orientation:"vertical",style:{paddingLeft:"4px"}},{children:[t.map((t=>r(ye,Object.assign({expanded:!0},{children:[e(ve,{StepIconProps:{icon:"",completed:!1,active:!0}}),e(Oe,{children:e(At,{property:t,parentNames:[...n],defaultExpanded:!1})})]}),t.key))),i&&e(ye,{})]}))]}))}));const At=({property:t,parentNames:n=[],defaultExpanded:i=!0})=>{const[a,l]=T(!0);return O((()=>{l(i)}),[i]),r(ue,Object.assign({elevation:3,style:{backgroundColor:n.length%2==1?"#f1f1f1":"#fff"},expanded:a,onChange:()=>l((e=>!e))},{children:[e(me,Object.assign({expandIcon:e(be,{})},{children:e(D,Object.assign({style:{wordBreak:"break-word",fontWeight:"600"}},{children:t.name}))})),e(he,{children:r(c,Object.assign({width:"100%"},{children:[e(wt,{property:t}),t.propertyType===Ye.ENTITY&&e(Pt,{properties:Nr(t.properties),parentNames:[...n,t.name]})]}))})]}))},Vt=({properties:r,expandAll:t=!0})=>{const n=E((()=>Array.isArray(r)?r:r?Nr(r):[]),[r]);return e(c,Object.assign({display:"flex",flexDirection:"column"},{children:n.length?n.map((r=>e(At,{property:r,defaultExpanded:t},r.key))):e(D,{children:"No properties"})}))},qt=({properties:t,dataFieldName:n,useExpression:i=!1,title:a})=>{const l=E((()=>t?t.map((t=>{const a="string"==typeof t.propertyType?t.propertyType:t.propertyType.value;return{label:r(c,Object.assign({display:"flex",flexDirection:"column"},{children:[r("b",{children:[t.name,t.isRequired?"*":""]}),r("span",{children:[t.key," | ",t.isMultiple?"multiple":"single"," | ",a]})]})),content:t.isMultiple?e(gt,{property:t,name:`${n}.${t.key}`,useExpression:i,label:t.name,required:t.isRequired}):e(mt,{property:t,name:`${n}.${t.key}`,useExpression:i,label:t.name,required:t.isRequired})}})):[]),[t,n,i]);return r(pe,Object.assign({container:!0,direction:"column",spacing:2},{children:[a&&e(pe,Object.assign({xs:12},{children:e("div",Object.assign({style:{fontWeight:"600"}},{children:a}))})),e(et,{data:l})]}))},Lt=({property:r,data:t,properties:n})=>{if(Or(t))return e(c,Object.assign({style:{backgroundColor:"#fff",border:"1px solid #ccc",borderRadius:"4px",padding:"4px"}},{children:null===t?"null":null==t?void 0:t.toString()}));switch(r.propertyType){case Ye.JSON:return e(Nt,{value:t});case Ye.ENTITY:return e(Mt,{properties:n,data:t});case"ANY":return e(Nt,{value:t});default:return e(c,Object.assign({style:{backgroundColor:"#fff",border:"1px solid #ccc",borderRadius:"4px",padding:"4px"}},{children:null===t?"null":null==t?void 0:t.toString()}))}};var Rt=({property:r,data:t,hasBackground:n=!1})=>{const i=E((()=>r.propertyType===Ye.ENTITY?Array.isArray(r.properties)?r.properties:Nr(r.properties):[]),[r]);return e(c,Object.assign({style:{backgroundColor:n?"#f1f1f1":"none"}},{children:e(Lt,{property:r,data:t,properties:i})}))};const Mt=({properties:n,data:i})=>{const a=E((()=>n&&i?n.map((n=>{const{key:a,name:l,isMultiple:o,propertyType:s}=n,d=i[n.key];return{label:r(c,Object.assign({display:"flex",flexDirection:"column"},{children:[e("b",{children:l}),r("span",{children:[a," | ",o?"multiple":"single"," | ",s]})]})),content:o&&Array.isArray(d)?e(t,{children:d.map(((r,t)=>e(c,Object.assign({mb:2},{children:e(Rt,{property:n,data:r,hasBackground:!0})}),t)))}):e(Rt,{property:n,data:d})}})):[]),[n,i]);return e(pe,Object.assign({container:!0,direction:"column",spacing:2},{children:e(et,{data:a})}))};var $t=oe((e=>({root:{backgroundColor:"#eee",fontSize:"14px",padding:"0 8px",borderRadius:"10px","&.success":{backgroundColor:"#a9dfa9"},"&.error":{backgroundColor:"#ff7e7e"},"&.warning":{backgroundColor:e.palette.warning.main}}})));const Dt=({text:r,status:t="default"})=>{const n=$t();return e("div",Object.assign({className:Ve(n.root,{[t]:!0})},{children:r}))},Ft=oe((()=>({propertyStepLabel:{"&:hover":{fontWeight:"600",cursor:"pointer"}}}))),zt=({properties:t,parentKey:n="",activePath:i="",prefix:a="",onClick:l})=>{const o=Ft();return e(fe,Object.assign({orientation:"vertical",onClick:e=>e.stopPropagation()},{children:t&&t.map((t=>{var s;const c=n?`${n}.${t.key}`:t.key,d=null!==(s=t.propertyType.value)&&void 0!==s?s:t.propertyType;return r(ye,Object.assign({expanded:!0,onClick:()=>{return e=c,void l(a?`${a}.${e}`:e);var e}},{children:[e(ve,Object.assign({StepIconProps:{icon:"",completed:!1,active:i===c}},{children:r("div",Object.assign({className:o.propertyStepLabel},{children:[t.name," - ",t.key," - ",d]}))})),e(Oe,{children:e("div",{children:d===Ye.ENTITY&&e(zt,{onClick:l,activePath:i,properties:t.properties,parentKey:c},t.key)})})]}),t.key)}))}))};var Bt=zt;const Jt=({open:t=!1,onClose:o,onPaste:c,properties:d})=>{const[p,u]=T("");return r(i,Object.assign({open:t,onClose:o,fullWidth:!0,maxWidth:"md"},{children:[e(s,{children:"JSON path picker"}),r(l,{children:[r(D,Object.assign({variant:"h6",gutterBottom:!0},{children:["Path : $(",p,")"]})),(null==d?void 0:d.length)?d.map(((t,n)=>r("div",{children:[e(D,Object.assign({variant:"h6"},{children:t.title})),e(Bt,{properties:t.properties,prefix:t.pathPrefix,onClick:u,activePath:p})]},n))):e(D,{children:"Please, add properties"})]}),r(a,{children:[e(n,Object.assign({variant:"contained",color:"primary",onClick:()=>{navigator.clipboard.writeText(`$(${p})`),qe.success("Copied!")}},{children:"Copy"})),e(n,Object.assign({variant:"contained",color:"primary",onClick:()=>{qe.success("Pasted!"),c(`$(${p})`)}},{children:"Paste"})),e(n,Object.assign({variant:"contained",color:"secondary",onClick:o},{children:"Close"}))]})]}))};var Gt=({children:r})=>e("span",Object.assign({style:{backgroundColor:"#e4ecff"}},{children:r}));const Yt=Re();Object.assign(Yt,{overrides:{MUIRichTextEditor:{root:{marginTop:20,width:"100%",border:"1px solid gray",padding:"8px"},editor:{minHeight:"300px"},toolbar:{backgroundColor:"#eee"}}}});const _t=({fieldName:t,getProperties:n,initialText:i})=>{const{control:a,setValue:l,clearErrors:o}=g(),{fieldState:{error:s}}=m({control:a,name:t,rules:{required:"Please, fill content"}}),c=$e(De.createEmpty().getCurrentContent()),{open:d,onOpen:p,onClose:u}=er(),[h,b]=T(JSON.stringify(c)),[f,y]=T([]),[v,E]=T(null);O((()=>{if(i){const e=Fe(i),r=e&&ze.createFromBlockArray(e.contentBlocks,e.entityMap);b(JSON.stringify($e(r)))}}),[i]);return r(Me,Object.assign({theme:Yt},{children:[e(Le,{defaultValue:h,label:"Start here...",controls:["title","bold","italic","strikethrough","numberList","bulletList","code","jsonPathPicker"],onChange:e=>{const r=e.getCurrentContent(),n=e.getSelection();De.push(e,Be.replaceText(r,n,""),"remove-range");const i=!e.getCurrentContent().hasText(),a=r.getPlainText();l(t,i?"":a),o(t)},customControls:[{name:"jsonPathPicker",icon:e(Je,{}),type:"callback",onClick:e=>{E(e),y(n()),p()}}],decorators:[{component:Gt,regex:/\$\([^\s]*\)/g}]}),e(D,Object.assign({color:"secondary"},{children:null==s?void 0:s.message})),d&&e(Jt,{open:d,properties:f,onClose:u,onPaste:e=>{const r=v.getCurrentContent(),t=v.getSelection(),n=De.push(v,Be.insertText(r,t,e),"insert-characters").getCurrentContent();b(JSON.stringify($e(n))),u()}})]}))};export{Xe as AlertDialog,sr as BackButton,cr as ControlAceEditor,ar as ControlAutocomplete,nr as ControlCheckbox,Vr as ControlDate,qr as ControlDateTime,rr as ControlDebouncedInput,Ze as ControlInput,Pr as ControlNumberInput,lr as ControlQueryAutocomplete,ir as ControlRadioBtn,tr as ControlSelect,Ar as ControlSwitch,Lr as ControlTime,or as CopyButton,jt as CreateDefinition,xt as CreatePropertiesList,_e as DATE_DEFAULT_FORMAT,He as DATE_TIME_DEFAULT_FORMAT,qt as DefinitionFiller,Mt as DefinitionValueView,Hr as InfoItem,_r as JsonModalView,Jt as JsonPathPicker,Nt as JsonView,Ke as Loader,gt as MultiplePropertyFiller,mt as PropertyFiller,Ye as PropertyType,yt as PropertyValue,bt as PropertyValueField,Ue as RoundingMode,Yr as RouteTabs,Dt as Status,et as StepperView,We as TIME_DEFAULT_FORMAT,Gr as TabPanel,Br as Table,Jr as TableAction,_t as TemplateContentEditor,Vt as ViewPropertiesList,At as ViewProperty,ur as capitalize,br as deepParseJson,yr as digitsOnly,vr as floatsOnly,xr as formatDefinitionData,fr as formatTableRowValue,Sr as getDemPropertyDateFormat,Ir as getEntityStarterValue,hr as getJsonStringValue,kr as getMultiplePropertyFillOptions,wr as getSinglePropertyFillOptions,Tr as isDateType,Or as isExpression,Er as isPropertyValueEmpty,jr as propertiesArrayToObject,Nr as propertiesObjectToArray,dr as removeArrayItem,gr as safeParseJson,mr as sortArrayOfObjects,Qe as useDebounce,er as useToggle,pr as validateJson};
|
1
|
+
import{jsx as e,jsxs as r,Fragment as t}from"react/jsx-runtime";import n from"@mui/material/Button";import a from"@mui/material/Dialog";import i from"@mui/material/DialogActions";import l from"@mui/material/DialogContent";import o from"@mui/material/DialogContentText";import s from"@mui/material/DialogTitle";import c from"@mui/material/Box";import d from"@mui/material/CircularProgress";import{__rest as u,__awaiter as p}from"tslib";import{useController as m,useWatch as g,useFormContext as h}from"react-hook-form";import b from"@mui/material/TextField";import f,{useRef as y,useEffect as v,useState as O,useCallback as C,useMemo as E,createElement as T,memo as x}from"react";import j from"@mui/material/MenuItem";import N from"@mui/icons-material/Clear";import{InputAdornment as S,IconButton as I,FormHelperText as k,Box as w}from"@mui/material";import P from"@mui/material/FormControl";import V from"@mui/material/FormControlLabel";import q from"@mui/material/FormHelperText";import A from"@mui/material/Checkbox";import M from"@mui/material/Radio";import R from"@mui/material/RadioGroup";import L from"@mui/material/FormLabel";import F from"@mui/material/Autocomplete";import{useQuery as $}from"react-query";import D from"qs";import z from"@mui/icons-material/FileCopyOutlined";import B from"@mui/material/Tooltip";import J from"@mui/material/IconButton";import G from"@mui/icons-material/ArrowBack";import{useHistory as Y,useLocation as W,Link as _}from"react-router-dom";import H from"react-ace";import K from"@mui/material/Typography";import U from"@mui/material/Switch";import{DatePicker as X}from"@mui/x-date-pickers/DatePicker";import{format as Z,isMatch as Q,isValid as ee,parse as re}from"date-fns";import{DateTimePicker as te}from"@mui/x-date-pickers/DateTimePicker";import{TimePicker as ne}from"@mui/x-date-pickers/TimePicker";import ae from"@mui/material/Pagination";import ie from"@mui/material/TablePagination";import{useGridApiContext as le,useGridSelector as oe,gridPageSelector as se,gridPageCountSelector as ce,gridRowCountSelector as de,gridPageSizeSelector as ue,GridColumnMenuContainer as pe,GridFilterMenuItem as me,DataGrid as ge,GridActionsCellItem as he}from"@mui/x-data-grid";import{makeStyles as be}from"@mui/styles";import fe from"@mui/material/Paper";import ye from"@mui/material/Tab";import ve from"@mui/material/Tabs";import Oe from"@mui/material/Unstable_Grid2";import Ce from"@mui/material/Accordion";import Ee from"@mui/material/AccordionSummary";import Te from"@mui/material/AccordionDetails";import xe from"@mui/material/AccordionActions";import je from"@mui/icons-material/ExpandMore";import Ne from"@mui/material/Stepper";import Se from"@mui/material/Step";import Ie from"@mui/material/StepLabel";import ke from"@mui/material/StepContent";import we from"@mui/material/StepConnector";import Pe from"@mui/material/Chip";import Ve from"@mui/icons-material/Add";import qe from"@mui/material/Select";import Ae from"@mui/material/InputLabel";import Me from"@mui/icons-material/Close";import Re from"@mui/material/Table";import Le from"@mui/material/TableBody";import Fe from"@mui/material/TableRow";import $e from"@mui/material/TableCell";import De from"@mui/icons-material/CheckCircle";import ze from"classnames";import{toast as Be}from"react-toastify";import Je from"mui-rte";import{createTheme as Ge,ThemeProvider as Ye}from"@mui/material/styles";import{convertToRaw as We,EditorState as _e,convertFromHTML as He,ContentState as Ke,Modifier as Ue}from"draft-js";import Xe from"@mui/icons-material/Functions";import Ze from"@mui/icons-material/NotInterested";var Qe;!function(e){e.STRING="STRING",e.INTEGER="INTEGER",e.BIG_INTEGER="BIG_INTEGER",e.BIG_DECIMAL="BIG_DECIMAL",e.FLOAT="FLOAT",e.LONG="LONG",e.DOUBLE="DOUBLE",e.BOOLEAN="BOOLEAN",e.ENTITY_REFERENCE="ENTITY_REFERENCE",e.ENTITY="ENTITY",e.JSON="JSON",e.DATE="DATE",e.TIME="TIME",e.DATE_TIME="DATE_TIME",e.ANY="ANY"}(Qe||(Qe={}));const er="yyyy-MM-dd",rr="HH:mm:ss",tr="yyyy-MM-dd'T'HH:mm:ss.SSSXXX";var nr;!function(e){e.UP="UP",e.DOWN="DOWN",e.CEILING="CEILING",e.FLOOR="FLOOR",e.HALF_UP="HALF_UP",e.HALF_DOWN="HALF_DOWN",e.HALF_EVEN="HALF_EVEN",e.UNNECESSARY="UNNECESSARY"}(nr||(nr={}));const ar=({transparent:r,position:t})=>e(c,Object.assign({position:null!=t?t:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",bgcolor:r?"none":"rgba(255, 255, 255, .3)",zIndex:10},{children:e(d,{})})),ir=({open:t,title:d,description:u,closeButtonTitle:p="Close",onClose:m,confirmButtonTitle:g="Confirm",confirmButtonDisabled:h=!1,onConfirm:b,children:f,dialogProps:y,loading:v,maxWidth:O="xs"})=>e("div",{children:r(a,Object.assign({open:t,onClose:m,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:O},y,{children:[v&&e(ar,{}),e(s,Object.assign({id:"alert-dialog-title"},{children:d})),r(l,{children:[u&&e(o,Object.assign({id:"alert-dialog-description"},{children:u})),e(c,Object.assign({maxWidth:"100%",overflow:"hidden"},{children:f}))]}),r(i,{children:[e(n,Object.assign({onClick:m,color:"primary",variant:"contained"},{children:p})),g&&b?e(n,Object.assign({onClick:b,color:"secondary",variant:"contained",autoFocus:!0,disabled:h},{children:g})):null]})]}))}),lr=r=>{var t,{control:n,validate:a,name:i="",label:l="",required:o=!1,defaultValue:s="",disabled:c=!1,textarea:d=!1,hideErrorMessage:p=!1,onChange:h}=r,f=u(r,["control","validate","name","label","required","defaultValue","disabled","textarea","hideErrorMessage","onChange"]);const{field:{ref:y,onChange:v},fieldState:{error:O}}=m({name:i,control:n,defaultValue:s,rules:{required:o&&"Please, fill this field",validate:a}}),C=g({control:n,name:i});return e(b,Object.assign({fullWidth:!0,size:"small",variant:"outlined",type:"text",inputRef:y,name:i,label:l,error:!!O,helperText:!p&&(null==O?void 0:O.message),disabled:c,multiline:d,minRows:d?3:1,value:null!=C?C:"",onChange:h||v},f,{inputProps:Object.assign(Object.assign({},null!==(t=null==f?void 0:f.inputProps)&&void 0!==t?t:{}),{value:null!=C?C:""})}))};function or(e,r){const t=y();v((()=>()=>{t.current&&clearTimeout(t.current)}),[]);return(...n)=>{clearTimeout(t.current),t.current=setTimeout((()=>{e(...n)}),r)}}const sr=()=>{const[e,r]=O(!1);return{open:e,toggle:()=>{r((e=>!e))},onClose:()=>{r(!1)},onOpen:()=>{r(!0)}}},cr=r=>{var t,{control:n,validate:a,name:i="",label:l="",required:o=!1,defaultValue:s="",disabled:c=!1,textarea:d=!1,hideErrorMessage:p=!1,onChange:h}=r,f=u(r,["control","validate","name","label","required","defaultValue","disabled","textarea","hideErrorMessage","onChange"]);const{field:{ref:y,onChange:E},fieldState:{error:T}}=m({name:i,control:n,defaultValue:s,rules:{required:o&&"Please, fill this field",validate:a}}),x=g({control:n,name:i}),[j,N]=O("");v((()=>{!j&&x&&N(x)}),[j,x]);const S=or((e=>{E(e)}),200),I=C((e=>{N(e.target.value),S(e.target.value)}),[S]);return e(b,Object.assign({fullWidth:!0,size:"small",variant:"outlined",type:"text",inputRef:y,name:i,label:l,error:!!T,helperText:!p&&(null==T?void 0:T.message),disabled:c,multiline:d,minRows:d?3:1,value:null!=j?j:"",onChange:I},f,{inputProps:Object.assign(Object.assign({},null!==(t=null==f?void 0:f.inputProps)&&void 0!==t?t:{}),{value:null!=j?j:""})}))},dr=r=>{var t,{control:n,validate:a,name:i="",label:l="",required:o=!1,defaultValue:s="",disabled:c=!1,hideErrorMessage:d=!1,onChange:p,labelKey:h,valueKey:f,options:y=[]}=r,v=u(r,["control","validate","name","label","required","defaultValue","disabled","hideErrorMessage","onChange","labelKey","valueKey","options"]);const{field:{ref:O,onChange:E},fieldState:{error:T}}=m({name:i,control:n,defaultValue:s,rules:{required:o&&"Please, fill this field",validate:a}}),x=g({control:n,name:i}),k=C((e=>"string"==typeof e?e:f?e[f]:e.value),[f]),w=C((e=>"string"==typeof e?e:h?e[h]:e.label),[h]),P=C((()=>{E(null)}),[E]);return e(b,Object.assign({select:!0,fullWidth:!0,size:"small",variant:"outlined",type:"text",inputRef:O,name:i,label:l,error:!!T,helperText:!d&&(null==T?void 0:T.message),disabled:c,value:null!=x?x:"",onChange:p||E},v,{inputProps:Object.assign(Object.assign({},null!==(t=null==v?void 0:v.inputProps)&&void 0!==t?t:{}),{value:null!=x?x:""}),InputProps:Object.assign({endAdornment:!o&&x?e(S,Object.assign({position:"end",sx:{mr:2}},{children:e(I,Object.assign({onClick:P,size:"small"},{children:e(N,{fontSize:"small"})}))})):null},null==v?void 0:v.InputProps)},{children:y.map(((r,t)=>e(j,Object.assign({value:k(r)},{children:w(r)}),t)))}))},ur=t=>{var{control:n,validate:a,name:i="",label:l="",required:o=!1,defaultValue:s="",disabled:c=!1,hideErrorMessage:d=!1,onChange:p}=t,h=u(t,["control","validate","name","label","required","defaultValue","disabled","hideErrorMessage","onChange"]);const{field:{ref:b,onChange:f},fieldState:{error:y}}=m({name:i,control:n,defaultValue:s}),v=g({control:n,name:i}),O=E((()=>{if("boolean"==typeof v)return v;if("string"==typeof v){if("false"===v)return f(!1),!1;if("true"===v)return f(!0),!0}return!1}),[v,f]);return r(P,Object.assign({error:!!y,component:"fieldset",variant:"standard",disabled:c},{children:[e(V,{control:e(A,Object.assign({checked:O,onChange:p||f,name:i,inputRef:b,disabled:c},h)),label:l}),!d&&(null==y?void 0:y.message)&&e(q,{children:y.message})]}))},pr=({name:t,label:n,values:a=[],control:i,required:l,defaultValue:o,disabled:s,hideErrorMessage:c,labelKey:d,valueKey:u,validate:p,onChange:h})=>{const{field:{ref:b,onChange:f},fieldState:{error:y}}=m({name:t,control:i,defaultValue:o,rules:{required:l&&"Please, fill this field",validate:p}}),v=g({control:i,name:t}),O=C((e=>"string"==typeof e?e:u?e[u]:e.value),[u]),E=C((e=>"string"==typeof e?e:d?e[d]:e.label),[d]);return r(P,Object.assign({disabled:s,error:!!y},{children:[e(L,Object.assign({id:"radio-buttons-group"},{children:n})),e(R,Object.assign({"aria-labelledby":"radio-buttons-group",ref:b,name:t,value:v,onChange:h||f},{children:a.map((r=>e(V,{value:O(r),control:e(M,{}),label:E(r)})))})),!c&&(null==y?void 0:y.message)&&e(k,{children:y.message})]}))};var mr=({valueKey:e,labelKey:r})=>{const t=C(((r,t)=>{if(r&&t){if("string"==typeof r)return r===t;if(e)return r[e]===t[e]||r[e]===t;if(r.value)return r.value===t.value||r.value===t}return!1}),[e]),n=C((e=>"string"==typeof e?e:r?e[r]+"":e.label?e.label+"":"--no label--"),[r]),a=C(((e,r)=>T(w,Object.assign({},e,{component:"li",key:e.id}),n(r))),[n]);return{isOptionEqualToValue:t,getOptionLabel:n,renderOption:a}};const gr=r=>{var{control:t,validate:n,name:a="",label:i="",required:l=!1,defaultValue:o="",disabled:s=!1,hideErrorMessage:c=!1,onChange:d,labelKey:p,valueKey:h,options:f=[],multiple:y,textFieldProps:v={},disableCloseOnSelect:O}=r,C=u(r,["control","validate","name","label","required","defaultValue","disabled","hideErrorMessage","onChange","labelKey","valueKey","options","multiple","textFieldProps","disableCloseOnSelect"]);const{field:{ref:T,onChange:x},fieldState:{error:j}}=m({name:a,control:t,defaultValue:o,rules:{required:l&&"Please, fill this field",validate:n}}),N=g({control:t,name:a}),{getOptionLabel:S,isOptionEqualToValue:I,renderOption:k}=mr({valueKey:h,labelKey:p}),w=E((()=>{if((null==f?void 0:f.length)&&N){const e=f.find((e=>I(e,N)));if(e)return e}else if(N)return N;return y?[]:null}),[N,y,f,I]);return e(F,Object.assign({fullWidth:!0,disablePortal:!0,size:"small",readOnly:s,options:f,multiple:y,getOptionLabel:S,isOptionEqualToValue:I,disableCloseOnSelect:O||y,filterSelectedOptions:y,value:w,onChange:d||((e,r)=>{x(r)}),renderOption:k,renderInput:r=>e(b,Object.assign({},r,{variant:"outlined",name:a,label:i,error:!!j,inputRef:T,helperText:!c&&(null==j?void 0:j.message)},v))},C))},hr=t=>{var{name:n,label:a,control:i,searchBy:l,labelKey:o,multiple:s=!1,disabled:c,valueKey:p,sortBy:h="",hideErrorMessage:y,disableCloseOnSelect:T,textFieldProps:x,onChange:j,queryFunction:N}=t,S=u(t,["name","label","control","searchBy","labelKey","multiple","disabled","valueKey","sortBy","hideErrorMessage","disableCloseOnSelect","textFieldProps","onChange","queryFunction"]);const{field:{ref:I,onChange:k},fieldState:{error:w}}=m({control:i,name:n}),P=g({control:i,name:n}),{getOptionLabel:V,isOptionEqualToValue:q,renderOption:A}=mr({valueKey:p,labelKey:o}),[M,R]=O(!1),[L,z]=O(""),[B,J]=O(""),[G,Y]=O(0),[W,_]=O(0),[H,K]=O([]),U=E((()=>{if(""===P||void 0===P||!(null==H?void 0:H.length))return s?[]:null;if(H&&P){return H.find((e=>q(e,P)))}return P}),[P,s,H,q]),X=or((e=>{J(e),_(0),K([])}),500),Z=C(((e,r)=>{z(r),X(r)}),[X]),Q=C(((e,r)=>{k(r),j&&j(e,r)}),[k,j]),ee=C((e=>{const r=e.currentTarget;r.scrollTop+r.clientHeight===r.scrollHeight&&H.length<G&&_((e=>e+1))}),[G,H]),{data:re,isFetching:te}=$(["options",W,B],(()=>{const e=D.parse({page:`${W}`,size:"20",sort:h,[l]:B},{ignoreQueryPrefix:!0});return N(e)}));return v((()=>{re?(K((e=>[...e,...re.collection])),Y(re.totalItems)):(K([]),Y(0))}),[re]),e(F,Object.assign({fullWidth:!0,disablePortal:!0,size:"small",readOnly:c,options:H,multiple:s,getOptionLabel:V,isOptionEqualToValue:q,disableCloseOnSelect:T||s,filterSelectedOptions:s,inputValue:L,value:U,onChange:Q,loading:te,clearOnBlur:!1,open:M,filterOptions:e=>e,onOpen:()=>{R(!0)},onClose:()=>{R(!1),_(0),J("")},onInputChange:Z,ListboxProps:{onScroll:ee},renderOption:A,renderInput:t=>e(b,Object.assign({},t,{label:a,variant:"outlined",error:!!w,inputRef:I,helperText:!y&&(null==w?void 0:w.message),InputProps:Object.assign(Object.assign({},t.InputProps),{endAdornment:r(f.Fragment,{children:[te?e(d,{color:"inherit",size:20}):null,t.InputProps.endAdornment]})})},x))},S))},br=({copyText:r,helpText:t="Copy"})=>{const[n,a]=O(t);return n?e(B,Object.assign({title:n,placement:"top"},{children:e(J,Object.assign({onClick:()=>{navigator.clipboard.writeText(r),a("Copied!"),setTimeout((()=>{a(t)}),1e3)}},{children:e(z,{fontSize:"small"})}))})):null},fr=({text:r,buttonProps:t={}})=>{const a=Y(),{state:i}=W(),l=E((()=>null==i?void 0:i.from),[i]),o=C((()=>{l?a.push(l):a.goBack()}),[a,l]);return e(c,Object.assign({mr:2},{children:r?e(n,Object.assign({color:"inherit",onClick:l?null:o,component:_,to:null!=l?l:""},t,{children:r})):e(J,Object.assign({onClick:o},{children:e(G,{})}))}))},yr=({control:n,name:a,mode:i="json",label:l,width:o="100%",height:s="200px",theme:d="monokai",readOnly:u,required:p=!1,validateJson:b=!1,fontSize:f=16,validate:y=!0})=>{const{setError:v,clearErrors:O}=h(),{field:{onChange:C},fieldState:{error:E}}=m({control:n,name:a}),T=g({control:n,name:a});return r(c,Object.assign({display:"flex",flexDirection:"column",width:"100%"},{children:[e(c,{children:l&&e(K,Object.assign({variant:"subtitle1",display:"inline",style:{marginRight:10}},{children:l}))}),r(t,{children:[e(H,{focus:!0,wrapEnabled:!0,width:o,height:s,showPrintMargin:!1,theme:d,fontSize:f,setOptions:{enableLiveAutocompletion:!0,enableBasicAutocompletion:!0,showLineNumbers:!0,tabSize:2},style:{lineHeight:1.4,zIndex:0,isolation:"isolate"},readOnly:u,value:"json"===i&&"string"!=typeof T?null===T?"":JSON.stringify(T):T,onChange:e=>{if(!e&&p?v(a,{message:"Required field"}):O(a),b)try{JSON.parse(e),O(a)}catch(e){return void v(a,{message:"Invalid JSON"})}C(e)},mode:i,onLoad:e=>{y&&b||e.getSession().setUseWorker(!1)}}),E&&e(q,Object.assign({error:!0},{children:E.message}))]})]}))},vr=(e,r)=>{const t=[...e];return t.splice(r,1),t},Or=e=>{try{JSON.parse(e)}catch(e){return!1}return!0};function Cr(e){return e.replace(/(^\w)|([-\s]\w)/g,(e=>e.toUpperCase()))}const Er=(e,r,t,n="asc")=>{const a=e[t],i=r[t];return a<i?"asc"===n?-1:1:a>i?"asc"===n?1:-1:0},Tr=e=>{if(!e)return"";if("string"!=typeof e)try{return JSON.stringify(e,null,"\t")}catch(e){return"Failed to stringify JSON"}return e},xr=e=>{try{return JSON.parse(e)}catch(e){return null}},jr=e=>{try{const r=JSON.parse(e);return Object.keys(r).forEach((e=>{r[e]=jr(r[e])})),r}catch(r){return e}},Nr=({value:t,type:n,copyText:a,status:i})=>{switch(n){case"JSON_copy":return r(c,Object.assign({width:"100%"},{children:[e(c,Object.assign({display:"flex",alignItems:"center",justifyContent:"flex-end",pt:1,mb:2},{children:e(br,{copyText:Tr(t)})})),e(qt,{value:t})]}));case"JSON":return e(qt,{value:t});case"JSON_text":return e(c,Object.assign({width:"100%"},{children:e(c,Object.assign({overflow:"hidden",whiteSpace:"nowrap"},{children:"object"==typeof t?JSON.stringify(t):t}))}));case"copy":return r(c,Object.assign({display:"flex",alignItems:"center",width:"100%"},{children:[e(c,Object.assign({mr:"auto"},{children:t})),e(br,{copyText:a||t})]}));case"boolean":return t?e(De,{color:"primary",fontSize:"small"}):e(Ze,{fontSize:"small"});case"date":return t?r("div",{children:[e("div",{children:Z(new Date(t),"dd.MM.yyyy")}),e("div",{children:Z(new Date(t),"HH:mm:ss")})]}):"";case"status":return e(Wt,{text:t,status:i});case"array":return e(c,{children:t.map(((r,t)=>e(c,{children:r},t)))});default:return e("div",{children:t})}},Sr=new RegExp("^[-+]?[0-9]+$"),Ir=new RegExp(/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/),kr=e=>"string"==typeof e&&e.includes("$("),wr=e=>e===Qe.DATE||e===Qe.DATE_TIME||e===Qe.TIME,Pr=e=>!e&&0!==e&&!1!==e,Vr=(e,r,t)=>{if(null==r&&e!==Qe.BOOLEAN)return null;let n=r;switch(e){case Qe.BOOLEAN:n=!!r;break;case Qe.INTEGER:case Qe.BIG_INTEGER:case Qe.BIG_DECIMAL:case Qe.FLOAT:case Qe.LONG:case Qe.DOUBLE:n=Number(r);break;case Qe.DATE:case Qe.DATE_TIME:case Qe.TIME:n=Z(new Date(r.toString()),t.formatText);break;case Qe.JSON:case Qe.ANY:try{"string"!=typeof r&&(n=JSON.stringify(r)),n=JSON.parse(n)}catch(e){console.log(e),n=null}break;case Qe.ENTITY:n=qr(t.properties,r)}return n},qr=(e,r)=>{if(r){const t={};return e.forEach((e=>{const{key:n,propertyType:a}=e,i=r[n];Array.isArray(i)?t[n]=i.map((r=>Vr(a,r,{formatText:e.format,properties:e.properties}))):t[n]=Vr(a,i,{formatText:e.format,properties:e.properties})})),t}return null},Ar=(e,r)=>{const t={};return e.forEach((e=>{const{key:n,name:a,isRequired:i,isMultiple:l,sortOrder:o,isEnabled:s,uiSettings:c,validationNode:d}=e,u="string"==typeof e.propertyType?e.propertyType:e.propertyType.value,p=Object.assign({name:a,propertyType:u,isRequired:i,isMultiple:l,sortOrder:o,isEnabled:s,validationNode:d,uiSettings:c},((e,r)=>{const t={};let n,a="";return r?e.isMultiple?(a="values",n=e.value):(a="value",n=e.value):e.isMultiple?(a="defaultValues",n=e.defaultValue):(a="defaultValue",n=e.defaultValue),t[a]=Vr(e.propertyType,n,{formatText:e.format,properties:e.properties}),t})(Object.assign(Object.assign({},e),{propertyType:u}),r));if("isViewableInList"in e&&(p.isViewableInList=e.isViewableInList),c)try{p.uiSettings=JSON.parse(c)}catch(e){console.log(e)}else p.uiSettings=null;u===Qe.BIG_DECIMAL&&(p.precisionScale=e.precisionScale,p.roundingMode=e.roundingMode),u!==Qe.DATE&&u!==Qe.TIME&&u!==Qe.DATE_TIME||(p.format=e.format),u===Qe.STRING&&(p.restrictedValues=e.restrictedValues),u===Qe.ENTITY_REFERENCE&&(p.definitionCode=e.definitionCode,p.definitionVersion=e.definitionVersion,p.labelPropertyCode=e.labelPropertyCode,p.valuePropertyCode=e.valuePropertyCode),u===Qe.ENTITY&&(p.properties=Ar(e.properties,r)),t[n]=p})),t};function Mr(e,r){return Object.keys(e).map((t=>{const n=Object.assign(Object.assign({key:t},e[t]),r||{});if(n.propertyType===Qe.ENTITY&&(n.properties=Mr(n.properties,r)),n.propertyType===Qe.JSON)try{null==n.defaultValue?n.defaultValue="":n.defaultValue=JSON.stringify(n.defaultValue)}catch(e){n.defaultValue=""}if(n.uiSettings)try{n.uiSettings=JSON.stringify(n.uiSettings)}catch(e){n.uiSettings=""}return n.isMultiple&&("defaultValues"in n&&(n.defaultValue=n.defaultValues),"values"in n&&(n.value=n.values)),n})).sort(((e,r)=>Er(e,r,"sortOrder")))}const Rr=(e,r)=>{if(r)try{const e=r.replace(/Z/g,"XXX");return Z(new Date,e),e}catch(r){return console.error("Incorrect format",r),e}return e},Lr=e=>{let r=[];return r=Array.isArray(e.properties)?e.properties:Mr(e.properties),r.reduce(((e,r)=>{const t=JSON.parse(JSON.stringify(e));return r.propertyType===Qe.ENTITY?t[r.key]=Lr(r):t[r.key]=r.propertyType,t}),{})},Fr=({propertyType:e,useExpression:r,required:t})=>{let n=[{value:"widget",label:"Fill array (widget)",sortOrder:1}];return t||n.push({value:"null",label:"NULL",sortOrder:0}),r&&(e===Qe.JSON||e===Qe.ENTITY||e===Qe.ANY?n.push({value:"expression",label:"Expression (JSON editor)",sortOrder:3}):n.push({value:"expression",label:"Expression",sortOrder:3})),e!==Qe.JSON&&e!==Qe.ANY&&e!==Qe.ENTITY||n.push({value:"json_valid",label:"JSON editor",sortOrder:2}),n=n.sort(((e,r)=>Er(e,r,"sortOrder"))),n},$r=({propertyType:e,useExpression:r,required:t})=>{let n=[{value:"widget",label:"Widget",sortOrder:1}];switch(t||n.push({value:"null",label:"NULL",sortOrder:0}),r&&(e===Qe.JSON||e===Qe.ENTITY||e===Qe.ANY?n.push({value:"expression",label:"Expression (JSON editor)",sortOrder:3}):n.push({value:"expression",label:"Expression",sortOrder:3})),e){case Qe.STRING:n[0].label="Text input";break;case Qe.INTEGER:case Qe.BIG_INTEGER:case Qe.BIG_DECIMAL:case Qe.FLOAT:case Qe.LONG:case Qe.DOUBLE:n[0].label="Number input";break;case Qe.BOOLEAN:n[0].label="Switch";break;case Qe.ENTITY_REFERENCE:n[0].label="Entity reference fields";break;case Qe.JSON:n[0].label="JSON editor";break;case Qe.DATE:n[0].label="Date picker",n.push({value:"string",label:"Text input",sortOrder:2});break;case Qe.DATE_TIME:n[0].label="Date & Time picker",n.push({value:"string",label:"Text input",sortOrder:2});break;case Qe.TIME:n[0].label="Time picker",n.push({value:"string",label:"Text input",sortOrder:2});break;case Qe.ANY:n[0].label="Textarea"}return n=n.sort(((e,r)=>Er(e,r,"sortOrder"))),n},Dr=r=>{var t,{control:n,validate:a,name:i="",label:l="",required:o=!1,defaultValue:s,disabled:c=!1,hideErrorMessage:d=!1,onChange:p,decimal:h=!1}=r,f=u(r,["control","validate","name","label","required","defaultValue","disabled","hideErrorMessage","onChange","decimal"]);const{field:{ref:y,onChange:v},fieldState:{error:O}}=m({name:i,control:n,defaultValue:s,rules:{required:o&&"Please, fill this field",validate:e=>h&&!Ir.test(e)?"Not valid number":!(!h&&!Sr.test(e))||"Not valid integer"}}),C=g({control:n,name:i});return e(b,Object.assign({fullWidth:!0,size:"small",variant:"outlined",type:"text",inputRef:y,name:i,label:l,error:!!O,helperText:!d&&(null==O?void 0:O.message),disabled:c,value:null!=C?C:"",onChange:e=>{const r=e.nativeEvent.data;(!isNaN(r)||h&&"."===r)&&(p?p(e):v(e.target.value))}},f,{inputProps:Object.assign(Object.assign({},null!==(t=null==f?void 0:f.inputProps)&&void 0!==t?t:{}),{value:null!=C?C:""})}))},zr=r=>{var{control:t,name:n,label:a}=r,i=u(r,["control","name","label"]);const{field:{ref:l,onChange:o}}=m({control:t,name:n}),s=g({control:t,name:n}),c=E((()=>{if("boolean"==typeof s)return s;if("string"==typeof s){if("false"===s)return o(!1),!1;if("true"===s)return o(!0),!0}return!1}),[s,o]);v((()=>{null===s&&o(!1)}),[s,o]);return e(V,{label:a,name:n,control:e(U,Object.assign({color:"primary",size:"small",inputRef:l,onChange:e=>{const{checked:r}=e.target;o(r)},checked:c},i))})},Br=({control:r,name:t,required:n,label:a,format:i=er,hideErrorMessage:l=!1})=>{const{field:{onChange:o,ref:s},fieldState:{error:c}}=m({control:r,name:t,rules:{required:n&&"Please, fill this field",validate:e=>!!Q(e,i)||"Incorrect date format"}}),d=g({control:r,name:t});return e(X,{mask:"",label:a,inputRef:s,inputFormat:i,value:d||null,onChange:e=>{o(ee(e)?Z(e,i):e)},renderInput:r=>e(b,Object.assign({},r,{fullWidth:!0,size:"small",variant:"outlined",name:t,error:!!c,helperText:!l&&(null==c?void 0:c.message)}))})},Jr=({control:r,name:t,required:n,label:a,format:i=tr,hideErrorMessage:l=!1})=>{const{field:{onChange:o,ref:s},fieldState:{error:c}}=m({control:r,name:t,rules:{required:n&&"Please, fill this field",validate:e=>!!Q(e,i)||"Incorrect date format"}}),d=g({control:r,name:t});return e(te,{mask:"",ampm:!1,inputRef:s,label:a,value:d||null,inputFormat:i,onChange:e=>{o(ee(e)?Z(e,i):e)},renderInput:r=>e(b,Object.assign({},r,{fullWidth:!0,size:"small",variant:"outlined",name:t,error:!!c,helperText:!l&&(null==c?void 0:c.message)}))})},Gr=({control:r,name:t,required:n,label:a,format:i=rr,hideErrorMessage:l=!1})=>{const{field:{onChange:o,ref:s},fieldState:{error:c}}=m({control:r,name:t,rules:{required:n&&"Please, fill this field",validate:e=>!!Q(e,i)||"Incorrect date format"}}),d=g({control:r,name:t}),[u,p]=O(null);return v((()=>{if(d&&i){let e=re(d,i,new Date);ee(e)||(e=re(d,"HH:mm:ss.SSS",new Date)),p(e)}}),[d,i]),e(ne,{mask:"",inputRef:s,label:a,ampm:!1,value:u,inputFormat:i,onChange:e=>{p(e),o(ee(e)?Z(e,i):e)},renderInput:r=>e(b,Object.assign({},r,{fullWidth:!0,size:"small",variant:"outlined",name:t,error:!!c,helperText:!l&&(null==c?void 0:c.message)}))})};var Yr=()=>{const n=le(),a=oe(n,se),i=oe(n,ce),l=oe(n,de),o=oe(n,ue),s=e=>n.current.setPage(e);return r(c,Object.assign({px:2,display:"flex",alignItems:"center"},{children:[e(ie,{component:"div",page:a,count:l,rowsPerPage:o,rowsPerPageOptions:[10,20,50,100],onPageChange:(e,r)=>s(r),onRowsPerPageChange:e=>n.current.setPageSize(parseInt(e.target.value,10)),ActionsComponent:()=>e(t,{})}),e(ae,{count:i,page:a+1,onChange:(e,r)=>s(r-1)})]}))};var Wr=r=>{var{hideMenu:t,currentColumn:n,onUnsort:a}=r,i=u(r,["hideMenu","currentColumn","onUnsort"]);return e(pe,Object.assign({hideMenu:t,currentColumn:n},i,{children:e(me,{onClick:t,column:n})}))};var _r=({mode:e})=>{const r=Y(),{search:t,state:n}=W(),a=E((()=>new URLSearchParams(t)),[t]),i=+a.get("page")||0,l=+a.get("size")||10;return v((()=>{"server"===e&&(a.has("page")||a.set("page","0"),a.has("size")||a.set("size","10"),r.replace({pathname:r.location.pathname,search:a.toString()},n))}),[t,e]),{page:i,size:l,onPageChange:e=>{a.set("page",`${e}`),r.replace({pathname:r.location.pathname,search:a.toString()})},onSizeChange:e=>{a.set("size",`${e}`),r.replace({pathname:r.location.pathname,search:a.toString()})}}};var Hr=()=>{const e=Y(),{search:r,state:t}=W(),n=E((()=>new URLSearchParams(r)),[r]),a=n.getAll("sort").map((e=>e.split(",")));return{onColumnHeaderClick:({field:r})=>{let a=!1;const i=n.getAll("sort");n.delete("sort"),i.forEach((e=>{const[t,i]=e.split(",");t===r?(a=!0,"asc"===i&&n.append("sort",`${t},desc`)):n.append("sort",`${t},${i}`)})),a||n.append("sort",`${r},asc`),e.replace({pathname:e.location.pathname,search:n.toString()},t)},getSortedColumns:e=>e.map((e=>{const r=a.find((r=>r[0]===e.field));return e.headerClassName=r?`Sorted --${r[1]} `:"",e}))}};var Kr=e=>{const[r,t]=O(10);v((()=>{t(e)}),[e]);return{pageSize:r,handlePageSizeChange:e=>t(e)}},Ur=be({root:{width:"100%","& .MuiDataGrid-virtualScrollerContent":{height:"auto !important",minHeight:"56px !important"},"& .MuiDataGrid-virtualScrollerRenderZone":{position:"static"},"& .MuiDataGrid-renderingZone":{maxHeight:"none !important"},"& .MuiDataGrid-cell":{maxHeight:"none !important",lineHeight:"unset !important",whiteSpace:"normal !important",textOverflow:"ellipsis",wordBreak:"break-all","& .MuiDataGrid-actionsCell":{width:"100%",gridGap:"4px",flexWrap:"wrap",'& > button[aria-label="more"]':{marginLeft:"auto"}}},"& .MuiDataGrid-row":{maxHeight:"none !important"},"& .Sorted":{"& .MuiDataGrid-iconButtonContainer":{visibility:"visible",width:"auto","& svg":{opacity:"1 !important"}},"&.--desc":{"& svg":{transform:"rotate(180deg)"}}}}});const Xr=({columns:r,rows:t,rowCount:n,loading:a,disableMargin:i,mode:l="server",initialPageSize:o=10,pagination:s=!0,onCellClick:d})=>{const u=Ur(),{page:p,size:m,onPageChange:g,onSizeChange:h}=_r({mode:l}),{onColumnHeaderClick:b,getSortedColumns:f}=Hr(),{pageSize:y,handlePageSizeChange:v}=Kr(o),O={sortingMode:l,paginationMode:l,pageSize:"server"===l?m:s?y:n,onPageSizeChange:"server"===l?h:v,components:{Pagination:Yr}};return"server"===l&&(O.sortModel=[],O.onColumnHeaderClick=b,O.page=p,O.onPageChange=g,O.components.ColumnMenu=Wr),e(c,Object.assign({mt:i?0:2},{children:e(ge,Object.assign({autoHeight:!0,hideFooterPagination:!s,hideFooter:!s,disableSelectionOnClick:!0,showColumnRightBorder:!0,showCellRightBorder:!0,className:u.root,loading:a,rows:t,columns:f(r),rowCount:n,rowsPerPageOptions:[10,20,50,100],onCellClick:d},O))}))},Zr=({icon:r,label:t,showInMenu:n,onClick:a,location:i})=>i?e(J,Object.assign({component:_,to:i,size:"small"},{children:e(B,Object.assign({title:t,arrow:!0},{children:f.cloneElement(r,{fontSize:"small"})}))})):e(he,{nonce:!1,onResize:!1,onResizeCapture:!1,icon:e(B,Object.assign({title:t,arrow:!0},{children:r})),onClick:a,label:t,showInMenu:n}),Qr=r=>{const{children:t,value:n,index:a}=r,i=u(r,["children","value","index"]);return e("div",Object.assign({role:"tabpanel",hidden:n!==a,id:`simple-tabpanel-${a}`,"aria-labelledby":`simple-tab-${a}`},i,{children:n===a?t:null}))},et=t=>{var n;const{tabs:a}=t,i=Y(),l=W(),o=E((()=>new URLSearchParams(l.search)),[l.search]),s=o.get("tab");return r(c,{children:[e(fe,{children:e(ve,Object.assign({value:s||(null===(n=a[0])||void 0===n?void 0:n.name),indicatorColor:"primary",textColor:"primary",onChange:(e,r)=>{o.set("tab",r),i.replace({pathname:i.location.pathname,search:o.toString()})}},{children:a.map((r=>e(ye,{value:r.name,label:r.label},r.name)))}))}),e(c,Object.assign({mt:2},{children:a.map((r=>{var t;return e(Qr,Object.assign({value:s||(null===(t=a[0])||void 0===t?void 0:t.name),index:r.name},{children:r.component}),r.name)}))}))]})},rt=({open:t,onClose:o,value:s})=>r(a,Object.assign({disableEscapeKeyDown:!0,open:t,onClose:o,fullWidth:!0,maxWidth:"md",style:{width:800,left:"30%"}},{children:[e(l,{children:e(H,{readOnly:!0,value:s,mode:"json",width:"100%",fontSize:"16",setOptions:{enableSnippets:!1,copyWithEmptySelection:!0,showLineNumbers:!0,tabSize:2}})}),r(i,{children:[e(br,{copyText:s}),e(n,Object.assign({onClick:o,variant:"contained",color:"secondary"},{children:"Close"}))]})]}));var tt=be((()=>({container:{borderBottom:"1px solid #ccc",paddingBottom:"8px"},title:{fontSize:"14px",fontWeight:600,color:"#536DFE"},text:{fontSize:"18px",wordWrap:"break-word"}})));const nt=({title:t,text:n,json:a})=>{const i=tt();return r("div",Object.assign({className:i.container},{children:[e("div",Object.assign({className:i.title},{children:t})),n&&e("div",Object.assign({className:i.text},{children:n})),a&&e(H,{readOnly:!0,value:a,mode:"json",height:"300px",width:"100%",fontSize:"16",setOptions:{enableSnippets:!1,copyWithEmptySelection:!0,showLineNumbers:!0,tabSize:2}})]}))},at=Object.values(nr).sort(((e,r)=>e.localeCompare(r)));var it=({propertyFieldName:n})=>{const{control:a}=h();return r(t,{children:[e(Oe,{children:e(Dr,{required:!0,control:a,defaultValue:2,name:`${n}.precisionScale`,label:"Precision Scale"})}),e(Oe,{children:e(dr,{required:!0,control:a,name:`${n}.roundingMode`,label:"Rounding Mode",defaultValue:nr.HALF_UP,options:at})})]})};var lt=({propertyFieldName:r,defaultValue:t=""})=>{const{control:n}=h();return e(Oe,{children:e(lr,{required:!0,control:n,defaultValue:t,name:`${r}.format`,label:"Format"})})};const ot=be((()=>({content:{marginLeft:"4px"},connector:{marginLeft:"4px"},stepper:{padding:"12px"},label:{display:"flex",alignItems:"flex-start"}}))),st=()=>e("div",{style:{display:"inline-block",width:"10px",height:"10px",borderRadius:"50%",backgroundColor:"#536DFE",marginTop:"5px"}}),ct=({data:t})=>{const n=ot();return r(Ne,Object.assign({nonLinear:!0,orientation:"vertical",className:n.stepper,connector:e(we,{className:n.connector})},{children:[t.map(((t,a)=>r(Se,Object.assign({expanded:!0},{children:[e(Ie,Object.assign({className:n.label,StepIconComponent:st,StepIconProps:{icon:"",completed:!1,active:!0}},{children:t.label})),e(ke,Object.assign({className:n.content},{children:t.content}))]}),a))),e(Se,{})]}))},dt=({properties:t=[]})=>{const n=E((()=>t?t.map((t=>{const n="string"==typeof t.propertyType?t.propertyType:t.propertyType.value;return{label:r(c,Object.assign({display:"flex",flexDirection:"column"},{children:[r("b",{children:[t.name,t.isRequired?"*":""]}),r("span",{children:[t.key," | ",t.isMultiple?"multiple":"single"," | ",n]})]})),content:"ENTITY"===t.propertyType&&e(dt,{properties:t.properties})}})):[]),[t]);return e(ct,{data:n})};var ut=dt;const pt={key:"",propertyType:"",name:"",defaultValue:"",isRequired:!0,isMultiple:!1,sortOrder:0,isEnabled:!0};var mt=({parentPropertyFieldName:o,entityDefinition:c=!1,globalParameter:d=!1})=>{const{control:u,setValue:m,getValues:b,trigger:f}=h(),y=g({control:u,name:`${o}.properties`,defaultValue:b(`${o}.properties`)||[]}),v=g({control:u,name:`${o}.name`}),E=sr(),[T,x]=O(0),j=C((()=>{if(y){const e=y.length;m(`${o}.properties.${e}`,pt),x(e)}else m(`${o}.properties`,[pt])}),[y,o,m]),N=()=>p(void 0,void 0,void 0,(function*(){(yield f(`${o}.properties`))&&E.onClose()}));return r(t,{children:[e(Oe,{children:e(K,Object.assign({variant:"h6"},{children:"Properties"}))}),e(Oe,{children:e(ut,{properties:y})}),e(Oe,{children:e(n,Object.assign({variant:"contained",color:"primary",onClick:E.onOpen},{children:"Edit properties"}))}),r(a,Object.assign({disableEscapeKeyDown:!0,open:E.open,onClose:N,fullWidth:!0,maxWidth:"md"},{children:[r(s,{children:[v||"Entity"," Properties"]}),e(l,Object.assign({style:{height:"500px",overflow:"hidden"}},{children:r(Oe,Object.assign({container:!0,direction:"row",spacing:2,style:{height:"100%"}},{children:[r(Oe,Object.assign({xs:3,style:{backgroundColor:"#f9f9f9"}},{children:[e(Ne,Object.assign({nonLinear:!0,activeStep:T,orientation:"vertical",style:{paddingLeft:"4px"}},{children:y.map(((t,n)=>r(Se,Object.assign({onClick:()=>(e=>x(e))(n),style:{cursor:"pointer"}},{children:[e(Ie,Object.assign({StepIconProps:{icon:""},style:{wordBreak:"break-word"}},{children:t.name||"(no name)"})),e(ke,{})]}),n)))})),e(n,Object.assign({variant:"contained",size:"small",color:"primary",onClick:j},{children:"Add property"}))]})),e(Oe,Object.assign({container:!0,wrap:"nowrap",direction:"column",xs:9,spacing:2,style:{height:"100%",overflowY:"auto"}},{children:e(Pt,{hideAddButton:!0,parentFieldName:o,focusOnIndex:T,entityDefinition:c,globalParameter:d})}))]}))})),e(i,{children:e(n,Object.assign({variant:"contained",color:"primary",onClick:N},{children:"Ok"}))})]}))]})};var gt=({propertyFieldName:n})=>{const{control:a}=h();return r(t,{children:[e(Oe,{children:e(lr,{required:!0,control:a,name:`${n}.definitionCode`,label:"Definition Code"})}),e(Oe,{children:e(lr,{required:!0,control:a,name:`${n}.definitionVersion`,label:"Definition Version"})}),e(Oe,{children:e(lr,{required:!0,control:a,name:`${n}.labelPropertyCode`,label:"Label Property Code"})}),e(Oe,{children:e(lr,{required:!0,control:a,name:`${n}.valuePropertyCode`,label:"Value Property Code"})})]})};var ht=({propertyFieldName:n})=>{const a=E((()=>`${n}.restrictedValues`),[n]),{control:i,setValue:l,getValues:o}=h(),s=g({control:i,name:a,defaultValue:o(`${n}.restrictedValues`)||[]}),[d,u]=O(""),[p,m]=O(""),f=C((e=>{l(a,vr(s,e))}),[s,a,l]),y=()=>{d&&(l(a,[...s,d]),u(""))};return r(t,{children:[e(Oe,{children:e(K,Object.assign({variant:"h6"},{children:"Restricted Values"}))}),e(Oe,{children:e(c,Object.assign({display:"flex",flexWrap:"wrap"},{children:null==s?void 0:s.map(((r,t)=>e(Pe,{variant:"outlined",label:r,onDelete:()=>f(t)},t)))}))}),e(Oe,{children:e(b,{fullWidth:!0,variant:"outlined",size:"small",label:"Add restricted value",value:d,onChange:e=>{const{value:r}=e.target;u(r),s.includes(r)?m("This value already exists"):m("")},error:!!p,helperText:p,name:"restrictedValues",inputProps:{onKeyDown:e=>{"Enter"===e.key&&y()}},InputProps:{endAdornment:e(J,Object.assign({size:"small",onClick:y,disabled:!!p},{children:e(Ve,{})}))}})})]})};const bt=({propertyType:r,propertyFieldName:t,entityDefinition:n=!1,globalParameter:a=!1})=>{switch(r){case Qe.STRING:return e(ht,{propertyFieldName:t});case Qe.BIG_DECIMAL:return e(it,{propertyFieldName:t});case Qe.DATE:return e(lt,{propertyFieldName:t,defaultValue:er});case Qe.TIME:return e(lt,{propertyFieldName:t,defaultValue:rr});case Qe.DATE_TIME:return e(lt,{propertyFieldName:t,defaultValue:tr});case Qe.ENTITY_REFERENCE:return e(gt,{propertyFieldName:t});case Qe.ENTITY:return e(mt,{parentPropertyFieldName:t,globalParameter:a,entityDefinition:n});default:return null}};var ft=({validate:r=!1,name:t,inputRef:n})=>{const{control:a,setValue:i,setError:l,clearErrors:o}=h(),s=g({control:a,name:t});return e(H,{wrapEnabled:!0,width:"100%",height:"200px",theme:"monokai",fontSize:14,showPrintMargin:!1,style:{lineHeight:1.4,zIndex:0,isolation:"isolate"},setOptions:{enableLiveAutocompletion:!0,enableBasicAutocompletion:!0,showLineNumbers:!0,tabSize:2},ref:n,name:t,value:"string"!=typeof s?null===s?"":JSON.stringify(s):s,onChange:e=>{if(i(t,e),r)try{JSON.parse(e),o(t)}catch(e){l(t,{message:"Invalid JSON"})}},mode:"json",onLoad:e=>{r||e.getSession().setUseWorker(!1)}})};var yt=({name:t,label:n,required:a,restrictedValues:i})=>{const{control:l}=h(),{field:{onChange:o,ref:s},fieldState:{error:c}}=m({control:l,name:t,rules:{required:a&&(Array.isArray(i)&&i.length?"Please, select a value":"Please, fill this field")}}),d=g({control:l,name:t});return Array.isArray(i)&&i.length?r(P,Object.assign({fullWidth:!0,size:"small",variant:"outlined",error:!!c},{children:[e(Ae,Object.assign({htmlFor:"type-select"},{children:n})),e(qe,Object.assign({labelId:"type-select",label:n,value:d||"",onChange:o,ref:s},{children:i.map((r=>e(j,Object.assign({value:r},{children:r}),r)))}))]})):e(lr,{hideErrorMessage:!0,required:a,control:l,name:t,label:n})};const vt=({property:r,name:t,label:n,useExpression:a,inputRef:i})=>{const{control:l}=h();switch(E((()=>"string"==typeof r.propertyType?r.propertyType:r.propertyType.value),[r])){case Qe.BIG_DECIMAL:case Qe.FLOAT:case Qe.DOUBLE:return e(Dr,{decimal:!0,required:!0,hideErrorMessage:!0,control:l,name:t,label:n});case Qe.INTEGER:case Qe.BIG_INTEGER:case Qe.LONG:return e(Dr,{required:!0,hideErrorMessage:!0,control:l,name:t,label:n});case Qe.BOOLEAN:return e(zr,{control:l,name:t});case Qe.DATE:return e(Br,{required:!0,hideErrorMessage:!0,control:l,name:t,label:n,format:r.format});case Qe.TIME:return e(Gr,{required:!0,hideErrorMessage:!0,control:l,name:t,label:n,format:r.format});case Qe.DATE_TIME:return e(Jr,{required:!0,hideErrorMessage:!0,control:l,name:t,label:n,format:r.format});case Qe.JSON:return e(ft,{validate:!0,name:t,inputRef:i});case Qe.STRING:return e(yt,{required:!0,name:t,label:n,restrictedValues:r.restrictedValues});case Qe.ENTITY_REFERENCE:return e(lr,{required:!0,hideErrorMessage:!0,name:t,label:n,control:l});case Qe.ANY:return e(ft,{name:t,inputRef:i});case Qe.ENTITY:return e(zt,{properties:r.properties,dataFieldName:t,useExpression:a});default:return e("div",{children:"No widget"})}};var Ot=({property:e,name:r,label:t,isDirty:n,required:a=!1,useExpression:i=!1,multipleOptions:l=!1})=>{const{control:o}=h(),s=g({control:o,name:r}),c=E((()=>t?`${t} (value)`:`${e.name} (value)`),[t,e]),d=E((()=>t?`${t} (widget)`:`${e.name} (widget)`),[t,e]),u=E((()=>"string"==typeof e.propertyType?e.propertyType:e.propertyType.value),[e]),[p,m]=O(null),b=E((()=>l?Fr({propertyType:u,required:a,useExpression:i}):$r({propertyType:u,required:a,useExpression:i})),[i,a,u,l]);return v((()=>{p?n||(kr(s)&&"expression"!==p?m("expression"):null===s||kr(s)||"widget"===p||m("widget")):Pr(s)&&(null==b?void 0:b.length)?m(b[0].value):i&&kr(s)?m("expression"):m("widget")}),[s,p,b,i,n]),{propertyType:u,valueLabel:c,fillOptionLabel:d,fillOption:p,fillOptions:b,setFillOption:m}};var Ct=be((()=>({inputLabel:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",width:"100%"}})));const Et=({property:t,name:n,useExpression:a,label:i,required:l,title:o})=>{const{control:s,clearErrors:d}=h(),{field:{ref:u,onChange:p},fieldState:{error:b,isDirty:f}}=m({name:n,rules:{validate:{required:e=>!l||!Pr(e)||"Please, fill this field"}}}),y=g({control:s,name:n}),{propertyType:O,valueLabel:C,fillOptionLabel:E,fillOption:T,fillOptions:x,setFillOption:N}=Ot({property:t,name:n,isDirty:f,label:i,required:l,useExpression:a});v((()=>{void 0===y&&p(null)}),[y,p]);const S=Ct();return r(Oe,Object.assign({xs:12},{children:[o&&e(c,Object.assign({mb:2},{children:e(K,Object.assign({variant:"h6"},{children:o}))})),x?e(c,Object.assign({mb:2},{children:r(P,Object.assign({fullWidth:!0,size:"small",variant:"outlined"},{children:[e(Ae,Object.assign({htmlFor:"type-select",className:S.inputLabel},{children:E})),e(qe,Object.assign({labelId:"type-select",label:E,value:T||"",onChange:e=>{const r=e.target.value;"null"===r||"widget"===r?p(null):"expression"!==r&&"string"!==r||p(""),N(r),d(n)}},{children:x.map((r=>e(j,Object.assign({value:r.value},{children:r.label}),r.value)))}))]}))})):null,"expression"===T&&(O===Qe.JSON||O===Qe.ENTITY||O===Qe.ANY?e(ft,{name:n,inputRef:u}):e(lr,{control:s,name:n,label:C,required:!0,hideErrorMessage:!0})),"string"===T&&e(lr,{control:s,name:n,label:C,required:!0,hideErrorMessage:!0}),"json_notvalid"===T&&e(ft,{name:n,inputRef:u}),"widget"===T&&e(vt,{property:t,name:n,useExpression:a,label:C,inputRef:u,required:l}),b&&e(K,Object.assign({color:"secondary"},{children:b.message}))]}))};var Tt=({name:t,property:a,useExpression:i,required:l,label:o})=>{const{control:s,setValue:d,clearErrors:u}=h();m({control:s,name:t,rules:{validate:e=>!(!e||Array.isArray(e)&&!e.length)||"Please, fill array"}});const p=g({control:s,name:t}),b=C((()=>{p&&Array.isArray(p)?d(`${t}.${p.length}`,null):d(t,[null]),u(t)}),[t,p,d]),f=C((e=>{d(t,vr(p,e))}),[t,p,d]);return r(Oe,Object.assign({container:!0,spacing:2,direction:"column",xs:12},{children:[p&&Array.isArray(p)?p.map(((n,s)=>e(Oe,Object.assign({xs:12},{children:r(c,Object.assign({display:"flex",alignItems:"flex-start",width:"100%",p:2,style:{backgroundColor:"#f1f1f1"}},{children:[e(Et,{required:l,property:a,useExpression:i,name:`${t}.${s}`,label:`${o||a.name} (${s+1})`}),e(c,Object.assign({mt:"8px",ml:"4px"},{children:e(J,Object.assign({size:"small",onClick:()=>f(s)},{children:e(Me,{fontSize:"small"})}))}))]}))}),s))):null,e(Oe,{children:e(n,Object.assign({variant:"contained",size:"small",color:"primary",onClick:b},{children:"Add value"}))})]}))};const xt=({property:t,name:n,useExpression:a,required:i,label:l,title:o})=>{const{control:s,clearErrors:d}=h(),{field:{ref:u,onChange:p},fieldState:{error:b,isDirty:f}}=m({control:s,name:n,rules:{validate:e=>!(i&&!e)||"Please, fill this field"}}),y=g({control:s,name:n}),{propertyType:O,valueLabel:C,fillOptionLabel:E,fillOption:T,fillOptions:x,setFillOption:N}=Ot({property:t,name:n,isDirty:f,label:l,required:i,useExpression:a,multipleOptions:!0});v((()=>{void 0===y&&p(null)}),[y,p]);const S=Ct();return r(Oe,{children:[o&&e(c,Object.assign({mb:2},{children:e(K,Object.assign({variant:"h6"},{children:o}))})),x?e(c,Object.assign({mb:2},{children:r(P,Object.assign({fullWidth:!0,size:"small",variant:"outlined"},{children:[e(Ae,Object.assign({htmlFor:"type-select",className:S.inputLabel},{children:E})),e(qe,Object.assign({labelId:"type-select",label:E,value:T||"",onChange:e=>{const r=e.target.value;"null"===r?p(null):"expression"===r||"json_valid"===r||"json_notvalid"===r?p(""):"widget"===r&&p([]),N(r),d(n)}},{children:x.map((r=>e(j,Object.assign({value:r.value},{children:r.label}),r.value)))}))]}))})):null,"expression"===T&&(O===Qe.JSON||O===Qe.ENTITY||O===Qe.ANY?e(ft,{name:n,inputRef:u}):e(lr,{required:!0,hideErrorMessage:!0,control:s,name:n,label:C})),"json_valid"===T&&e(ft,{validate:!0,name:n,inputRef:u}),"widget"===T&&e(Tt,{property:t,name:n,useExpression:a,required:i,label:l}),b&&e(K,Object.assign({color:"secondary"},{children:b.message}))]})},jt=({propertyFieldName:r,name:t,label:n="",required:a})=>{const{control:i}=h(),l=g({control:i,name:`${r}.propertyType`}),o=g({control:i,name:`${r}.isMultiple`}),s=g({control:i,name:`${r}.format`}),c=g({control:i,name:`${r}.restrictedValues`}),d=g({control:i,name:`${r}.properties`}),u=g({control:i,name:`${r}.isRequired`}),p=E((()=>{const e="string"==typeof l?l:l.value;return{name:n,isRequired:u,isMultiple:o,format:s,restrictedValues:c,properties:d,propertyType:e,defaultValue:null,defaultValues:[],sortOrder:0,isEnabled:!0,uiSettings:null,validationNode:null}}),[l,s,c,o,n,u,d]);return e(o?xt:Et,{name:t,property:p,title:n,required:a})};var Nt=({name:r,label:t="",propertyFieldName:n,type:a,decimal:i=!1,options:l=[],required:o=!1})=>{const{control:s}=h(),c=E((()=>`${n}.${r}`),[r,n]);switch(a){case"text":return e(lr,{control:s,name:c,label:t,required:o});case"number":return e(Dr,{control:s,name:c,label:t,decimal:i,required:o});case"select":return e(dr,{control:s,name:c,label:t,options:l,required:o});case"autocomplete":return e(gr,{control:s,name:c,label:t,options:l,required:o});case"json":return e(yr,{control:s,name:c,label:t,mode:"json",required:o});default:return null}};var St=e=>({customCheckboxes:E((()=>e.length?e.filter((e=>"checkbox"===e.type)):[]),[e]),customFields:E((()=>e.length?e.filter((e=>"checkbox"!==e.type)):[]),[e])});const It=Object.values(Qe).sort(((e,r)=>e.localeCompare(r))).map((e=>({value:e,label:e.replace("_"," ").toLowerCase().replace(/(^\w)|([-\s]\w)/g,(e=>e.toUpperCase()))})));var kt=({propertyFieldName:n,entityDefinition:a=!1,globalParameter:i=!1,customPropertyFields:l=[]})=>{const{control:o,setValue:s}=h(),c=g({control:o,name:`${n}.propertyType`}),d=g({control:o,name:`${n}.isMultiple`}),u=g({control:o,name:`${n}.isRequired`}),{customCheckboxes:p,customFields:m}=St(l),b=E((()=>{let e=i?"Value":"Default Value";return d&&(e+="s"),e}),[i,d]);return r(Oe,Object.assign({container:!0,direction:"column",spacing:2},{children:[e(Oe,{children:e(cr,{required:!0,control:o,name:`${n}.key`,label:"Key"})}),e(Oe,{children:e(cr,{required:!0,control:o,name:`${n}.name`,label:"Name"})}),e(Oe,{children:e(gr,{required:!0,control:o,name:`${n}.propertyType`,label:"Type",options:It,onChange:(e,r)=>{const t=`${n}.propertyType`,a=`${n}.${i?"value":"defaultValue"}`;s(a,d?[]:null),s(t,r)}})}),e(Oe,{children:e(Dr,{required:!0,control:o,name:`${n}.sortOrder`,label:"Sort Order"})}),e(Oe,{children:e(yr,{control:o,name:`${n}.uiSettings`,label:"UI Settings",validateJson:!0})}),r(Oe,{children:[e(ur,{control:o,name:`${n}.isMultiple`,label:"Multiple"}),e(ur,{control:o,name:`${n}.isEnabled`,label:"Enabled"}),e(ur,{control:o,name:`${n}.isRequired`,label:"Required"}),a&&e(ur,{control:o,name:`${n}.isViewableInList`,label:"Is viewable in list"}),p.length?e(t,{children:p.map(((r,t)=>e(ur,{control:o,name:`${n}.${r.name}`,label:r.label},t)))}):null]}),c&&r(t,{children:[e(bt,{propertyType:"string"==typeof c?c:c.value,propertyFieldName:n,globalParameter:i,entityDefinition:a}),e(Oe,{children:e(jt,{propertyFieldName:n,name:`${n}.${i?"value":"defaultValue"}`,label:b,required:!!i&&u})})]}),m.length?e(t,{children:m.map(((r,t)=>e(Oe,{children:e(Nt,Object.assign({},r,{propertyFieldName:n}))},t)))}):null]}))};const wt={key:"",propertyType:null,name:"",defaultValue:"",defaultValues:[],isRequired:!0,isMultiple:!1,sortOrder:0,isEnabled:!0,executeValue:"",uiSettings:""},Pt=({parentFieldName:a,hideAddButton:i,focusOnIndex:l,required:o,entityDefinition:s=!1,globalParameter:c=!1,customPropertyFields:d=[]})=>{const u=E((()=>a?`${a}.properties`:"properties"),[a]),{setValue:p,clearErrors:b,control:f}=h(),{fieldState:{error:O}}=m({control:f,name:u,rules:{required:o&&"Please, add properties"}}),T=g({control:f,name:u}),x=y([]);v((()=>{"number"==typeof l&&x.current[l]&&x.current[l].scrollIntoView({behavior:"smooth",block:"start"})}),[l,x]);const j=C((()=>{T?p(`${u}.${T.length}`,wt):p(u,[wt]),b(u)}),[T,u,b,p]),N=C((e=>{p(`${u}`,vr(T,e))}),[T,u,p]);return r(t,{children:[O&&O.message&&e(Oe,Object.assign({sm:12,md:8,lg:6},{children:e(K,Object.assign({color:"secondary"},{children:O.message}))})),T&&T.map(((t,a)=>e(Oe,Object.assign({sm:12,md:8,lg:6,ref:e=>x.current[a]=e},{children:r(Ce,Object.assign({defaultExpanded:!0,elevation:3},{children:[e(Ee,Object.assign({expandIcon:e(je,{})},{children:e(K,Object.assign({color:O&&O[a]?"secondary":"initial",style:{wordBreak:"break-word"}},{children:t.name||`Property ${a+1}`}))})),e(Te,{children:e(kt,{propertyFieldName:`${u}.${a}`,entityDefinition:s,globalParameter:c,customPropertyFields:d})}),e(xe,{children:e(n,Object.assign({variant:"contained",size:"small",color:"secondary",onClick:()=>N(a)},{children:"Remove"}))})]}))}),a))),!i&&e(Oe,Object.assign({xs:12},{children:e(n,Object.assign({variant:"contained",size:"small",color:"primary",onClick:j},{children:"Add property"}))}))]})},Vt=({definitionFieldName:t,title:n,hideCodeField:a,hideVersionField:i,hideNameField:l,required:o=!1})=>{const{control:s}=h();return r(Oe,Object.assign({container:!0,direction:"column",spacing:2},{children:[n&&e(Oe,Object.assign({sm:12,md:8,lg:6},{children:e(c,Object.assign({my:2},{children:e(K,Object.assign({variant:"h4"},{children:n}))}))})),!l&&e(Oe,Object.assign({sm:12,md:8,lg:6},{children:e(lr,{required:!0,control:s,name:t?`${t}.name`:"name",label:"Name"})})),!a&&e(Oe,Object.assign({sm:12,md:8,lg:6},{children:e(lr,{required:!0,control:s,name:t?`${t}.code`:"code",label:"Code"})})),!i&&e(Oe,Object.assign({sm:12,md:8,lg:6},{children:e(Dr,{required:!0,control:s,name:t?`${t}.version`:"version",label:"Version"})})),e(Pt,{required:o,parentFieldName:t})]}))},qt=({value:r,height:t="200px"})=>{const n=E((()=>{if("string"==typeof r)return r;if("object"==typeof r)try{return JSON.stringify(r,null,"\t")}catch(e){return"Failed to parse JSON"}return null}),[r]);return e(H,{readOnly:!0,value:n,mode:"json",width:"100%",height:t,fontSize:"16",setOptions:{enableSnippets:!1,copyWithEmptySelection:!0,showLineNumbers:!0,tabSize:2}})},At={name:"Name",key:"Key",propertyType:"Property Type",defaultValue:"Default Value",defaultValues:"Default Values",sortOrder:"Sort Order",isRequired:"Required",isMultiple:"Multiple",isEnabled:"Enabled",isViewableInList:"Is Viewable In List",precisionScale:"Precision Scale",roundingMode:"Rounding Mode",format:"Format",definitionCode:"Definition Code",definitionVersion:"Definition Version",labelPropertyCode:"Label Property Code",valuePropertyCode:"Value Property Code",restrictedValues:"Restricted Values",value:"Value",values:"Values",uiSettings:"UI Settings"},Mt=({value:r,type:t})=>t!==Qe.JSON&&t!==Qe.ENTITY&&t!==Qe.ANY||!r?e(K,Object.assign({variant:"subtitle1",display:"inline",style:{wordBreak:"break-word"}},{children:null===r?"null":r.toString()})):e(qt,{value:r}),Rt=(r,t,n)=>{switch(t){case"isRequired":case"isMultiple":case"isEnabled":case"isViewableInList":return r?e(De,{color:"primary",fontSize:"small"}):null;case"restrictedValues":return r?e(c,Object.assign({display:"flex",flexWrap:"wrap"},{children:r.map((r=>e(Pe,{label:r,style:{wordBreak:"break-word",maxWidth:"500px"}},r)))})):null;case"defaultValue":case"value":return e(Mt,{value:r,type:n});case"values":case"defaultValues":return Array.isArray(r)&&n!==Qe.ENTITY&&n!==Qe.JSON&&n!==Qe.ANY?e("div",{children:null==r?void 0:r.map(((r,t)=>e("div",{children:e(Mt,{value:r,type:n})},t)))}):e(qt,{value:r});case"uiSettings":return r?e(qt,{value:r}):null;default:return e(K,Object.assign({variant:"subtitle1",display:"inline",style:{wordBreak:"break-word"}},{children:r}))}};var Lt=({property:t})=>{const n=E((()=>(t&&(t.isMultiple?(delete t.defaultValue,delete t.value):(delete t.defaultValues,delete t.values)),t)),[t]);return e(Re,Object.assign({size:"small"},{children:e(Le,{children:Object.keys(At).map((t=>t in n?r(Fe,{children:[e($e,Object.assign({width:"30%"},{children:e(K,{children:At[t]})})),e($e,{children:Rt(n[t],t,n.propertyType)})]},t):null))})}))};var Ft=x((({properties:t,parentNames:n=[]})=>{const a=E((()=>{let e=!1;return t.every((r=>r.propertyType!==Qe.ENTITY||(e=!0,!1))),e}),[t]);return r(c,Object.assign({mt:4},{children:[e(K,Object.assign({variant:"h6"},{children:"Properties"})),r(Ne,Object.assign({orientation:"vertical",style:{paddingLeft:"4px"}},{children:[t.map((t=>r(Se,Object.assign({expanded:!0},{children:[e(Ie,{StepIconProps:{icon:"",completed:!1,active:!0}}),e(ke,{children:e($t,{property:t,parentNames:[...n],defaultExpanded:!1})})]}),t.key))),a&&e(Se,{})]}))]}))}));const $t=({property:t,parentNames:n=[],defaultExpanded:a=!0})=>{const[i,l]=O(!0);return v((()=>{l(a)}),[a]),r(Ce,Object.assign({elevation:3,style:{backgroundColor:n.length%2==1?"#f1f1f1":"#fff"},expanded:i,onChange:()=>l((e=>!e))},{children:[e(Ee,Object.assign({expandIcon:e(je,{})},{children:e(K,Object.assign({style:{wordBreak:"break-word",fontWeight:"600"}},{children:t.name}))})),e(Te,{children:r(c,Object.assign({width:"100%"},{children:[e(Lt,{property:t}),t.propertyType===Qe.ENTITY&&e(Ft,{properties:Mr(t.properties),parentNames:[...n,t.name]})]}))})]}))},Dt=({properties:r,expandAll:t=!0})=>{const n=E((()=>Array.isArray(r)?r:r?Mr(r):[]),[r]);return e(c,Object.assign({display:"flex",flexDirection:"column"},{children:n.length?n.map((r=>e($t,{property:r,defaultExpanded:t},r.key))):e(K,{children:"No properties"})}))},zt=({properties:t,dataFieldName:n,useExpression:a=!1,title:i})=>{const l=E((()=>t?t.map((t=>{const i="string"==typeof t.propertyType?t.propertyType:t.propertyType.value;return{label:r(c,Object.assign({display:"flex",flexDirection:"column"},{children:[r("b",{children:[t.name,t.isRequired?"*":""]}),r("span",{children:[t.key," | ",t.isMultiple?"multiple":"single"," | ",i]})]})),content:t.isMultiple?e(xt,{property:t,name:`${n}.${t.key}`,useExpression:a,label:t.name,required:t.isRequired}):e(Et,{property:t,name:`${n}.${t.key}`,useExpression:a,label:t.name,required:t.isRequired})}})):[]),[t,n,a]);return r(Oe,Object.assign({container:!0,direction:"column",spacing:2},{children:[i&&e(Oe,Object.assign({xs:12},{children:e("div",Object.assign({style:{fontWeight:"600"}},{children:i}))})),e(ct,{data:l})]}))},Bt=({property:r,data:t,properties:n})=>{if(kr(t))return e(c,Object.assign({style:{backgroundColor:"#fff",border:"1px solid #ccc",borderRadius:"4px",padding:"4px"}},{children:null===t?"null":null==t?void 0:t.toString()}));switch(r.propertyType){case Qe.JSON:return e(qt,{value:t});case Qe.ENTITY:return e(Gt,{properties:n,data:t});case Qe.ANY:return e(qt,{value:t});default:return e(c,Object.assign({style:{backgroundColor:"#fff",border:"1px solid #ccc",borderRadius:"4px",padding:"4px"}},{children:null===t?"null":null==t?void 0:t.toString()}))}};var Jt=({property:r,data:t,hasBackground:n=!1})=>{const a=E((()=>r.propertyType===Qe.ENTITY?Array.isArray(r.properties)?r.properties:Mr(r.properties):[]),[r]);return e(c,Object.assign({style:{backgroundColor:n?"#f1f1f1":"none"}},{children:e(Bt,{property:r,data:t,properties:a})}))};const Gt=({properties:n,data:a})=>{const i=E((()=>n&&a?n.map((n=>{const{key:i,name:l,isMultiple:o,propertyType:s}=n,d=a[n.key];return{label:r(c,Object.assign({display:"flex",flexDirection:"column"},{children:[e("b",{children:l}),r("span",{children:[i," | ",o?"multiple":"single"," | ",s]})]})),content:o&&Array.isArray(d)?e(t,{children:d.map(((r,t)=>e(c,Object.assign({mb:2},{children:e(Jt,{property:n,data:r,hasBackground:!0})}),t)))}):e(Jt,{property:n,data:d})}})):[]),[n,a]);return e(Oe,Object.assign({container:!0,direction:"column",spacing:2},{children:e(ct,{data:i})}))};var Yt=be((e=>({root:{backgroundColor:"#eee",fontSize:"14px",padding:"0 8px",borderRadius:"10px","&.success":{backgroundColor:"#a9dfa9"},"&.error":{backgroundColor:"#ff7e7e"},"&.warning":{backgroundColor:e.palette.warning.main}}})));const Wt=({text:r,status:t="default"})=>{const n=Yt();return e("div",Object.assign({className:ze(n.root,{[t]:!0})},{children:r}))},_t=be((()=>({propertyStepLabel:{"&:hover":{fontWeight:"600",cursor:"pointer"}}}))),Ht=({properties:t,parentKey:n="",activePath:a="",prefix:i="",onClick:l})=>{const o=_t();return e(Ne,Object.assign({orientation:"vertical",onClick:e=>e.stopPropagation()},{children:t&&t.map((t=>{var s;const c=n?`${n}.${t.key}`:t.key,d=null!==(s=t.propertyType.value)&&void 0!==s?s:t.propertyType;return r(Se,Object.assign({expanded:!0,onClick:()=>{return e=c,void l(i?`${i}.${e}`:e);var e}},{children:[e(Ie,Object.assign({StepIconProps:{icon:"",completed:!1,active:a===c}},{children:r("div",Object.assign({className:o.propertyStepLabel},{children:[t.name," - ",t.key," - ",d]}))})),e(ke,{children:e("div",{children:d===Qe.ENTITY&&e(Ht,{onClick:l,activePath:a,properties:t.properties,parentKey:c},t.key)})})]}),t.key)}))}))};var Kt=Ht;const Ut=({open:t=!1,onClose:o,onPaste:c,properties:d})=>{const[u,p]=O("");return r(a,Object.assign({open:t,onClose:o,fullWidth:!0,maxWidth:"md"},{children:[e(s,{children:"JSON path picker"}),r(l,{children:[(null==d?void 0:d.length)?d.map(((t,n)=>r("div",{children:[e(K,Object.assign({variant:"h6"},{children:t.title})),e(Kt,{properties:t.properties,prefix:t.pathPrefix,onClick:p,activePath:u})]},n))):e(K,{children:"Please, add properties"}),u&&r(K,Object.assign({variant:"h6",gutterBottom:!0},{children:["Selected path : $(",u,")"]}))]}),r(i,{children:[e(n,Object.assign({variant:"contained",color:"primary",onClick:()=>{navigator.clipboard.writeText(`$(${u})`),Be.success("Copied!")}},{children:"Copy"})),e(n,Object.assign({variant:"contained",color:"primary",onClick:()=>{c(`$(${u})`),Be.success("Pasted!")}},{children:"Paste"})),e(n,Object.assign({variant:"contained",color:"secondary",onClick:o},{children:"Close"}))]})]}))};var Xt=({children:r})=>e("span",Object.assign({style:{backgroundColor:"#e4ecff"}},{children:r}));const Zt=Ge();Object.assign(Zt,{overrides:{MUIRichTextEditor:{root:{marginTop:20,width:"100%",border:"1px solid gray",padding:"8px"},editor:{minHeight:"300px"},toolbar:{backgroundColor:"#eee"}}}});const Qt=({fieldName:t,getProperties:n,initialText:a})=>{const{control:i,setValue:l,clearErrors:o}=h(),{fieldState:{error:s}}=m({control:i,name:t,rules:{required:"Please, fill content"}}),c=We(_e.createEmpty().getCurrentContent()),{open:d,onOpen:u,onClose:p}=sr(),[g,b]=O(JSON.stringify(c)),[f,y]=O([]),[C,E]=O(null);v((()=>{if(a){const e=He(a),r=e&&Ke.createFromBlockArray(e.contentBlocks,e.entityMap);b(JSON.stringify(We(r)))}}),[a]);return r(Ye,Object.assign({theme:Zt},{children:[e(Je,{defaultValue:g,label:"Start here...",controls:["title","bold","italic","strikethrough","numberList","bulletList","code","jsonPathPicker"],onChange:e=>{const r=e.getCurrentContent(),n=e.getSelection();_e.push(e,Ue.replaceText(r,n,""),"remove-range");const a=!e.getCurrentContent().hasText(),i=r.getPlainText();l(t,a?"":i),o(t)},customControls:[{name:"jsonPathPicker",icon:e(Xe,{}),type:"callback",onClick:e=>{E(e),y(n()),u()}}],decorators:[{component:Xt,regex:/\$\([^\s]*\)/g}]}),e(K,Object.assign({color:"secondary"},{children:null==s?void 0:s.message})),d&&e(Ut,{open:d,properties:f,onClose:p,onPaste:e=>{const r=C.getCurrentContent(),t=C.getSelection(),n=_e.push(C,Ue.insertText(r,t,e),"insert-characters").getCurrentContent();b(JSON.stringify(We(n))),p()}})]}))};export{ir as AlertDialog,fr as BackButton,yr as ControlAceEditor,gr as ControlAutocomplete,ur as ControlCheckbox,Br as ControlDate,Jr as ControlDateTime,cr as ControlDebouncedInput,lr as ControlInput,Dr as ControlNumberInput,hr as ControlQueryAutocomplete,pr as ControlRadio,dr as ControlSelect,zr as ControlSwitch,Gr as ControlTime,br as CopyButton,Vt as CreateDefinition,Pt as CreatePropertiesList,er as DATE_DEFAULT_FORMAT,tr as DATE_TIME_DEFAULT_FORMAT,zt as DefinitionFiller,Gt as DefinitionValueView,nt as InfoItem,rt as JsonModalView,Ut as JsonPathPicker,qt as JsonView,ar as Loader,xt as MultiplePropertyFiller,Et as PropertyFiller,Qe as PropertyType,jt as PropertyValueField,nr as RoundingMode,et as RouteTabs,Wt as Status,ct as StepperView,rr as TIME_DEFAULT_FORMAT,Qr as TabPanel,Xr as Table,Zr as TableAction,Qt as TemplateContentEditor,Dt as ViewPropertiesList,$t as ViewProperty,Cr as capitalize,jr as deepParseJson,Sr as digitsOnly,Ir as floatsOnly,qr as formatDefinitionData,Nr as formatTableRowValue,Rr as getDemPropertyDateFormat,Lr as getEntityStarterValue,Tr as getJsonStringValue,Fr as getMultiplePropertyFillOptions,$r as getSinglePropertyFillOptions,wr as isDateType,kr as isExpression,Pr as isPropertyValueEmpty,Ar as propertiesArrayToObject,Mr as propertiesObjectToArray,vr as removeArrayItem,xr as safeParseJson,Er as sortArrayOfObjects,or as useDebounce,sr as useToggle,Or as validateJson};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dartech/arsenal-ui",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.3",
|
4
4
|
"author": "DAR",
|
5
5
|
"publishConfig": {
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
@@ -23,7 +23,8 @@
|
|
23
23
|
"react-router-dom": "5.3.0",
|
24
24
|
"react-toastify": "^8.2.0",
|
25
25
|
"classnames": "^2.3.1",
|
26
|
-
"mui-rte": "^2.0.1"
|
26
|
+
"mui-rte": "^2.0.1",
|
27
|
+
"react-query": "^3.39.1"
|
27
28
|
},
|
28
29
|
"module": "./index.js",
|
29
30
|
"main": "./index.js",
|
@@ -31,6 +32,8 @@
|
|
31
32
|
"types": "./index.d.ts",
|
32
33
|
"peerDependencies": {
|
33
34
|
"@rollup/plugin-node-resolve": "13.3.0",
|
35
|
+
"qs": "6.11.0",
|
36
|
+
"@dartech/dpo": "1.1.6",
|
34
37
|
"draft-js": "0.11.7"
|
35
38
|
}
|
36
39
|
}
|
@@ -13,26 +13,27 @@ export declare enum PropertyType {
|
|
13
13
|
JSON = "JSON",
|
14
14
|
DATE = "DATE",
|
15
15
|
TIME = "TIME",
|
16
|
-
DATE_TIME = "DATE_TIME"
|
16
|
+
DATE_TIME = "DATE_TIME",
|
17
|
+
ANY = "ANY"
|
17
18
|
}
|
18
|
-
export interface Definition {
|
19
|
+
export interface Definition<T = Record<string, never>> {
|
19
20
|
code: string;
|
20
21
|
version: number;
|
21
22
|
name: string;
|
22
|
-
properties: PropertiesObjectType
|
23
|
+
properties: PropertiesObjectType<T>;
|
23
24
|
}
|
24
|
-
export type PropertiesObjectType<T =
|
25
|
-
export type PropertiesArrayType<T =
|
26
|
-
export interface CreateDefinitionType extends Omit<Definition
|
27
|
-
properties: PropertiesArrayType
|
25
|
+
export type PropertiesObjectType<T = Record<string, never>> = Record<string, PropertyUnion & T>;
|
26
|
+
export type PropertiesArrayType<T = Record<string, never>> = Array<PropertyUnion & T>;
|
27
|
+
export interface CreateDefinitionType<T = Record<string, never>> extends Omit<Definition<T>, 'properties'> {
|
28
|
+
properties: PropertiesArrayType<T>;
|
28
29
|
}
|
29
|
-
export interface UpdateDefinitionType extends Omit<Definition
|
30
|
-
properties: PropertiesArrayType
|
30
|
+
export interface UpdateDefinitionType<T = Record<string, never>> extends Omit<Definition<T>, 'properties'> {
|
31
|
+
properties: PropertiesArrayType<T>;
|
31
32
|
}
|
32
33
|
export interface Property {
|
33
34
|
propertyType: keyof typeof PropertyType | {
|
34
|
-
value: keyof typeof PropertyType
|
35
|
-
}
|
35
|
+
value: keyof typeof PropertyType;
|
36
|
+
};
|
36
37
|
name: string;
|
37
38
|
defaultValue: unknown;
|
38
39
|
defaultValues: unknown[];
|
@@ -66,9 +67,9 @@ export interface DateTimeProperty extends Property {
|
|
66
67
|
export interface DoubleProperty extends Property {
|
67
68
|
propertyType: PropertyType.DOUBLE;
|
68
69
|
}
|
69
|
-
export interface EntityTypeProperty extends Property {
|
70
|
+
export interface EntityTypeProperty<T = Record<string, never>> extends Property {
|
70
71
|
propertyType: PropertyType.ENTITY;
|
71
|
-
properties: PropertiesObjectType | PropertiesArrayType
|
72
|
+
properties: PropertiesObjectType<T> | PropertiesArrayType<T>;
|
72
73
|
}
|
73
74
|
export interface EntityReferenceProperty extends Property {
|
74
75
|
propertyType: PropertyType.ENTITY_REFERENCE;
|
@@ -98,23 +99,9 @@ export interface TimeProperty extends Property {
|
|
98
99
|
format: string;
|
99
100
|
}
|
100
101
|
export interface AnyProperty extends Property {
|
101
|
-
propertyType:
|
102
|
+
propertyType: PropertyType.ANY;
|
102
103
|
}
|
103
|
-
export type PropertyUnion = BigDecimalProperty | BigIntegerProperty | BooleanProperty | DateProperty | DateTimeProperty | DoubleProperty | EntityTypeProperty | EntityReferenceProperty | FloatProperty | StringProperty | IntegerProperty | JsonProperty | LongProperty | TimeProperty | AnyProperty;
|
104
|
+
export type PropertyUnion<T = Record<string, never>> = BigDecimalProperty | BigIntegerProperty | BooleanProperty | DateProperty | DateTimeProperty | DoubleProperty | EntityTypeProperty<T> | EntityReferenceProperty | FloatProperty | StringProperty | IntegerProperty | JsonProperty | LongProperty | TimeProperty | AnyProperty;
|
104
105
|
export declare const DATE_DEFAULT_FORMAT = "yyyy-MM-dd";
|
105
106
|
export declare const TIME_DEFAULT_FORMAT = "HH:mm:ss";
|
106
107
|
export declare const DATE_TIME_DEFAULT_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
|
107
|
-
export type GPBPropertiesObjectType = PropertiesObjectType<{
|
108
|
-
value: unknown;
|
109
|
-
values: unknown[];
|
110
|
-
}>;
|
111
|
-
export type GPBPropertiesArrayType = PropertiesArrayType<{
|
112
|
-
value: unknown;
|
113
|
-
values: unknown[];
|
114
|
-
}>;
|
115
|
-
export type EntityDefinitionPropertyObjectType = PropertiesObjectType<{
|
116
|
-
isViewableInList: boolean;
|
117
|
-
}>;
|
118
|
-
export type EntityDefinitionPropertyArrayType = PropertiesArrayType<{
|
119
|
-
isViewableInList: boolean;
|
120
|
-
}>;
|
package/src/interfaces/ui.d.ts
CHANGED
@@ -15,11 +15,11 @@ export interface Option {
|
|
15
15
|
label: string;
|
16
16
|
}
|
17
17
|
export type TableDataType = 'JSON' | 'JSON_text' | 'JSON_copy' | 'copy' | 'boolean' | 'date' | 'status' | 'array';
|
18
|
-
export type
|
18
|
+
export type JsonPathPickerProperty = {
|
19
19
|
properties: PropertiesArrayType;
|
20
20
|
pathPrefix: string;
|
21
21
|
title: string;
|
22
|
-
}
|
22
|
+
};
|
23
23
|
export type CustomPropertyFieldProps = {
|
24
24
|
name: string;
|
25
25
|
label?: string;
|
@@ -33,3 +33,4 @@ export type CustomPropertyFieldProps = {
|
|
33
33
|
};
|
34
34
|
export type PropertyFillType = 'expression' | 'widget' | 'null' | 'string' | 'json_valid' | 'json_notvalid';
|
35
35
|
export type StatusVariant = 'default' | 'success' | 'error' | 'warning';
|
36
|
+
export type ValidateFunc = (value: string) => boolean | string;
|
@@ -6,7 +6,6 @@ type Props = {
|
|
6
6
|
hideVersionField?: boolean;
|
7
7
|
hideNameField?: boolean;
|
8
8
|
required?: boolean;
|
9
|
-
hasAny?: boolean;
|
10
9
|
};
|
11
|
-
export declare const CreateDefinition: ({ definitionFieldName, title, hideCodeField, hideVersionField, hideNameField, required,
|
10
|
+
export declare const CreateDefinition: ({ definitionFieldName, title, hideCodeField, hideVersionField, hideNameField, required, }: Props) => JSX.Element;
|
12
11
|
export default CreateDefinition;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import { Control } from 'react-hook-form';
|
3
2
|
import 'ace-builds/src-noconflict/mode-python';
|
4
3
|
import 'ace-builds/src-noconflict/theme-monokai';
|
5
4
|
import 'ace-builds/src-noconflict/ext-language_tools';
|
5
|
+
import { Control } from 'react-hook-form';
|
6
6
|
export interface ControlAceEditorProps {
|
7
7
|
name: string;
|
8
8
|
control: Control<any>;
|
@@ -1,49 +1,69 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
+
import { AutocompleteProps } from '@mui/material/Autocomplete';
|
3
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
2
4
|
import { Control } from 'react-hook-form';
|
5
|
+
import { ValidateFunc } from '../../interfaces';
|
3
6
|
/**
|
4
7
|
* This interface is referencing the [[ControlAutocomplete]] component props.
|
5
8
|
* @category Forms
|
6
9
|
*/
|
7
|
-
export
|
10
|
+
export type ControlAutocompleteProps = Omit<AutocompleteProps<unknown, boolean, boolean, boolean, React.ElementType<any>>, 'renderInput'> & {
|
8
11
|
/**
|
9
12
|
* React Hook Form control `name` propery
|
10
13
|
*/
|
11
14
|
name: string;
|
15
|
+
/**
|
16
|
+
* Label for MUI TextField select component
|
17
|
+
*/
|
18
|
+
label?: string;
|
12
19
|
/**
|
13
20
|
* React Hook Form `control`
|
14
21
|
*/
|
15
22
|
control: Control<any>;
|
16
23
|
/**
|
17
|
-
*
|
24
|
+
* Is input required flag
|
25
|
+
*/
|
26
|
+
required?: boolean;
|
27
|
+
/**
|
28
|
+
* React Hook Form `defaultValue`
|
18
29
|
*/
|
19
|
-
|
30
|
+
defaultValue?: unknown;
|
20
31
|
/**
|
21
|
-
*
|
32
|
+
* Is disabled input flag
|
22
33
|
*/
|
23
|
-
|
34
|
+
disabled?: boolean;
|
24
35
|
/**
|
25
|
-
*
|
36
|
+
* React Hook Form validate function
|
37
|
+
* ```typescript
|
38
|
+
* type ValidateFunc = (value: string) => boolean | string;
|
39
|
+
* ```
|
26
40
|
*/
|
27
|
-
|
41
|
+
validate?: ValidateFunc | Record<string, ValidateFunc>;
|
28
42
|
/**
|
29
|
-
*
|
43
|
+
* Hide error message flag
|
30
44
|
*/
|
45
|
+
hideErrorMessage?: boolean;
|
31
46
|
/**
|
32
|
-
* onChange
|
47
|
+
* Custom onChange functionƒ
|
48
|
+
*/
|
49
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>, value: unknown) => void;
|
50
|
+
/**
|
51
|
+
* Key for option label
|
33
52
|
*/
|
34
|
-
onChange?: (name: string, value: unknown) => void;
|
35
|
-
multiple?: boolean;
|
36
|
-
required?: boolean;
|
37
|
-
disableCloseOnSelect?: boolean;
|
38
|
-
filterSelectedOptions?: boolean;
|
39
53
|
labelKey?: string;
|
54
|
+
/**
|
55
|
+
* Key for option value
|
56
|
+
*/
|
40
57
|
valueKey?: string;
|
41
|
-
|
42
|
-
|
43
|
-
|
58
|
+
/**
|
59
|
+
* Select options
|
60
|
+
*/
|
61
|
+
options: string[] | unknown[];
|
62
|
+
textFieldProps?: TextFieldProps;
|
63
|
+
};
|
44
64
|
/**
|
45
65
|
* Material UI `Autocomplete` controlled component. Used with react-hook-form
|
46
66
|
* @category Forms
|
47
67
|
*/
|
48
|
-
export declare const ControlAutocomplete: ({ control,
|
68
|
+
export declare const ControlAutocomplete: ({ control, validate, name, label, required, defaultValue, disabled, hideErrorMessage, onChange: customOnChange, labelKey, valueKey, options, multiple, textFieldProps, disableCloseOnSelect, ...autocompleteProps }: ControlAutocompleteProps) => JSX.Element;
|
49
69
|
export default ControlAutocomplete;
|
@@ -1,30 +1,51 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
+
import { CheckboxProps } from '@mui/material/Checkbox';
|
3
|
+
import { Control } from 'react-hook-form';
|
4
|
+
import { ValidateFunc } from '../../interfaces';
|
2
5
|
/**
|
3
6
|
* This interface is referencing the [[ControlCheckbox]] component props.
|
4
7
|
* @category Forms
|
5
8
|
*/
|
6
|
-
export
|
7
|
-
/**
|
8
|
-
* React Hook Form `control`
|
9
|
-
*/
|
10
|
-
control: any;
|
9
|
+
export type ControlCheckboxProps = CheckboxProps & {
|
11
10
|
/**
|
12
11
|
* React Hook Form control `name` propery
|
13
12
|
*/
|
14
13
|
name: string;
|
15
14
|
/**
|
16
|
-
*
|
15
|
+
* Label for MUI TextField component
|
17
16
|
*/
|
18
17
|
label?: string;
|
18
|
+
/**
|
19
|
+
* React Hook Form `control`
|
20
|
+
*/
|
21
|
+
control: Control<any>;
|
22
|
+
/**
|
23
|
+
* React Hook Form `defaultValue`
|
24
|
+
*/
|
25
|
+
defaultValue?: unknown;
|
19
26
|
/**
|
20
27
|
* Is disabled input flag
|
21
28
|
*/
|
22
29
|
disabled?: boolean;
|
23
|
-
|
24
|
-
|
30
|
+
/**
|
31
|
+
* React Hook Form validate function
|
32
|
+
* ```typescript
|
33
|
+
* type ValidateFunc = (value: string) => boolean | string;
|
34
|
+
* ```
|
35
|
+
*/
|
36
|
+
validate?: ValidateFunc | Record<string, ValidateFunc>;
|
37
|
+
/**
|
38
|
+
* Hide error message flag
|
39
|
+
*/
|
40
|
+
hideErrorMessage?: boolean;
|
41
|
+
/**
|
42
|
+
* Custom onChange functionƒ
|
43
|
+
*/
|
44
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
45
|
+
};
|
25
46
|
/**
|
26
47
|
* Material UI `Checkbox` controlled component. Used with react-hook-form
|
27
48
|
* @category Forms
|
28
49
|
*/
|
29
|
-
export declare const ControlCheckbox: ({
|
50
|
+
export declare const ControlCheckbox: ({ control, validate, name, label, required, defaultValue, disabled, hideErrorMessage, onChange: customOnChange, ...checkboxProps }: ControlCheckboxProps) => JSX.Element;
|
30
51
|
export default ControlCheckbox;
|
@@ -1,4 +1,4 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { ControlInputProps } from './ControlInput';
|
3
|
-
export declare const ControlDebouncedInput: ({
|
3
|
+
export declare const ControlDebouncedInput: ({ control, validate, name, label, required, defaultValue, disabled, textarea, hideErrorMessage, onChange: customOnChange, ...textFieldProps }: ControlInputProps) => JSX.Element;
|
4
4
|
export default ControlDebouncedInput;
|
@@ -1,24 +1,20 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { Control } from 'react-hook-form';
|
3
|
-
|
4
|
-
|
3
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
4
|
+
import { ValidateFunc } from '../../interfaces';
|
5
5
|
/**
|
6
6
|
* This interface is referencing the [[ControlInput]] component props.
|
7
7
|
* @category Forms
|
8
8
|
*/
|
9
|
-
export
|
10
|
-
/**
|
11
|
-
* Props for MUI TextField component
|
12
|
-
*/
|
13
|
-
inputProps?: Record<string, string | number | boolean | onChangeCallback | {
|
14
|
-
[key: string]: any;
|
15
|
-
}>;
|
9
|
+
export type ControlInputProps = TextFieldProps & {
|
16
10
|
/**
|
17
11
|
* React Hook Form control `name` propery
|
18
12
|
*/
|
19
13
|
name: string;
|
14
|
+
/**
|
15
|
+
* Label for MUI TextField component
|
16
|
+
*/
|
20
17
|
label?: string;
|
21
|
-
type?: 'text' | 'date' | 'password' | 'search' | 'number' | 'email' | 'datetime-local';
|
22
18
|
/**
|
23
19
|
* React Hook Form `control`
|
24
20
|
*/
|
@@ -27,15 +23,14 @@ export interface ControlInputProps {
|
|
27
23
|
* Is input required flag
|
28
24
|
*/
|
29
25
|
required?: boolean;
|
30
|
-
defaultValue?: any;
|
31
26
|
/**
|
32
|
-
*
|
27
|
+
* React Hook Form `defaultValue`
|
33
28
|
*/
|
34
|
-
|
29
|
+
defaultValue?: unknown;
|
35
30
|
/**
|
36
|
-
*
|
31
|
+
* Is disabled input flag
|
37
32
|
*/
|
38
|
-
|
33
|
+
disabled?: boolean;
|
39
34
|
/**
|
40
35
|
* React Hook Form validate function
|
41
36
|
* ```typescript
|
@@ -43,13 +38,22 @@ export interface ControlInputProps {
|
|
43
38
|
* ```
|
44
39
|
*/
|
45
40
|
validate?: ValidateFunc | Record<string, ValidateFunc>;
|
46
|
-
|
41
|
+
/**
|
42
|
+
* Is input textarea flag
|
43
|
+
*/
|
47
44
|
textarea?: boolean;
|
45
|
+
/**
|
46
|
+
* Hide error message flag
|
47
|
+
*/
|
48
48
|
hideErrorMessage?: boolean;
|
49
|
-
|
49
|
+
/**
|
50
|
+
* Custom onChange functionƒ
|
51
|
+
*/
|
52
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
53
|
+
};
|
50
54
|
/**
|
51
55
|
* Material UI `TextField` controlled component. Used with react-hook-form
|
52
56
|
* @category Forms
|
53
57
|
*/
|
54
|
-
export declare const ControlInput: ({
|
58
|
+
export declare const ControlInput: ({ control, validate, name, label, required, defaultValue, disabled, textarea, hideErrorMessage, onChange: customOnChange, ...textFieldProps }: ControlInputProps) => JSX.Element;
|
55
59
|
export default ControlInput;
|
@@ -1,17 +1,15 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
2
3
|
import { Control } from 'react-hook-form';
|
3
|
-
|
4
|
-
type Props = {
|
5
|
-
/**
|
6
|
-
* Props for MUI TextField component
|
7
|
-
*/
|
8
|
-
inputProps?: Record<string, string | number | boolean | onChangeCallback | {
|
9
|
-
[key: string]: any;
|
10
|
-
}>;
|
4
|
+
import { ValidateFunc } from '../../interfaces';
|
5
|
+
type Props = TextFieldProps & {
|
11
6
|
/**
|
12
7
|
* React Hook Form control `name` propery
|
13
8
|
*/
|
14
9
|
name: string;
|
10
|
+
/**
|
11
|
+
* Label for MUI TextField component
|
12
|
+
*/
|
15
13
|
label?: string;
|
16
14
|
/**
|
17
15
|
* React Hook Form `control`
|
@@ -21,24 +19,33 @@ type Props = {
|
|
21
19
|
* Is input required flag
|
22
20
|
*/
|
23
21
|
required?: boolean;
|
22
|
+
/**
|
23
|
+
* React Hook Form `defaultValue`
|
24
|
+
*/
|
24
25
|
defaultValue?: number;
|
25
26
|
/**
|
26
27
|
* Is disabled input flag
|
27
28
|
*/
|
28
29
|
disabled?: boolean;
|
29
|
-
/**
|
30
|
-
* Material-UI TextField `variant` prop
|
31
|
-
*/
|
32
|
-
variant?: 'filled' | 'outlined' | 'standard';
|
33
30
|
/**
|
34
31
|
* React Hook Form validate function
|
35
32
|
* ```typescript
|
36
33
|
* type ValidateFunc = (value: string) => boolean | string;
|
37
34
|
* ```
|
38
35
|
*/
|
39
|
-
|
40
|
-
|
36
|
+
validate?: ValidateFunc | Record<string, ValidateFunc>;
|
37
|
+
/**
|
38
|
+
* Hide error message flag
|
39
|
+
*/
|
41
40
|
hideErrorMessage?: boolean;
|
41
|
+
/**
|
42
|
+
* Custom onChange function
|
43
|
+
*/
|
44
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
45
|
+
/**
|
46
|
+
* Is number decimal or integer flag
|
47
|
+
*/
|
48
|
+
decimal?: boolean;
|
42
49
|
};
|
43
|
-
export declare const ControlNumberInput: ({
|
50
|
+
export declare const ControlNumberInput: ({ control, validate, name, label, required, defaultValue, disabled, hideErrorMessage, onChange: customOnChange, decimal, ...textFieldProps }: Props) => JSX.Element;
|
44
51
|
export default ControlNumberInput;
|
@@ -1,7 +1,15 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { ControlAutocompleteProps } from './ControlAutocomplete';
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
import { PaginateData } from '@dartech/dpo';
|
4
|
+
type PaginateParams = {
|
5
|
+
page: string;
|
6
|
+
size: string;
|
7
|
+
[key: string]: string;
|
8
|
+
};
|
9
|
+
type ControlQueryAutocompleteProps = Omit<ControlAutocompleteProps, 'options'> & {
|
10
|
+
searchBy: string;
|
11
|
+
sortBy?: string;
|
12
|
+
queryFunction: (params: PaginateParams) => Promise<PaginateData<unknown>>;
|
13
|
+
};
|
14
|
+
export declare const ControlQueryAutocomplete: ({ name, label, control, searchBy, labelKey, multiple, disabled, valueKey, sortBy, hideErrorMessage, disableCloseOnSelect, textFieldProps, onChange, queryFunction, ...autocompleteProps }: ControlQueryAutocompleteProps) => JSX.Element;
|
7
15
|
export default ControlQueryAutocomplete;
|
@@ -0,0 +1,66 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
import { Control } from 'react-hook-form';
|
3
|
+
import { ValidateFunc } from '../../interfaces';
|
4
|
+
/**
|
5
|
+
* This interface is referencing the [[ControlRadioBtn]] component props.
|
6
|
+
* @category Forms
|
7
|
+
*/
|
8
|
+
export interface ControlRadioProps {
|
9
|
+
/**
|
10
|
+
* React Hook Form `control`
|
11
|
+
*/
|
12
|
+
control: Control<any>;
|
13
|
+
/**
|
14
|
+
* React Hook Form control `name` propery
|
15
|
+
*/
|
16
|
+
name: string;
|
17
|
+
/**
|
18
|
+
* Label for component
|
19
|
+
*/
|
20
|
+
label?: string;
|
21
|
+
/**
|
22
|
+
* Radio group values
|
23
|
+
*/
|
24
|
+
values: string[] | unknown[];
|
25
|
+
/**
|
26
|
+
* Is input required flag
|
27
|
+
*/
|
28
|
+
required?: boolean;
|
29
|
+
/**
|
30
|
+
* React Hook Form `defaultValue`
|
31
|
+
*/
|
32
|
+
defaultValue?: unknown;
|
33
|
+
/**
|
34
|
+
* Is disabled input flag
|
35
|
+
*/
|
36
|
+
disabled?: boolean;
|
37
|
+
/**
|
38
|
+
* Hide error message flag
|
39
|
+
*/
|
40
|
+
hideErrorMessage?: boolean;
|
41
|
+
/**
|
42
|
+
* Custom onChange functionƒ
|
43
|
+
*/
|
44
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
45
|
+
/**
|
46
|
+
* React Hook Form validate function
|
47
|
+
* ```typescript
|
48
|
+
* type ValidateFunc = (value: string) => boolean | string;
|
49
|
+
* ```
|
50
|
+
*/
|
51
|
+
validate?: ValidateFunc | Record<string, ValidateFunc>;
|
52
|
+
/**
|
53
|
+
* Key for option label
|
54
|
+
*/
|
55
|
+
labelKey?: string;
|
56
|
+
/**
|
57
|
+
* Key for option value
|
58
|
+
*/
|
59
|
+
valueKey?: string;
|
60
|
+
}
|
61
|
+
/**
|
62
|
+
* Material UI `Radio` controlled component. Used with react-hook-form
|
63
|
+
* @category Forms
|
64
|
+
*/
|
65
|
+
export declare const ControlRadio: ({ name, label, values, control, required, defaultValue, disabled, hideErrorMessage, labelKey, valueKey, validate, onChange: customOnChange, }: ControlRadioProps) => JSX.Element;
|
66
|
+
export default ControlRadio;
|
@@ -1,41 +1,51 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
2
3
|
import { Control } from 'react-hook-form';
|
3
|
-
|
4
|
-
type onChangeCallback = (e: any) => void;
|
4
|
+
import { ValidateFunc } from '../../interfaces';
|
5
5
|
/**
|
6
6
|
* This interface is referencing the [[ControlSelect]] component props.
|
7
7
|
* @category Forms
|
8
8
|
*/
|
9
|
-
export
|
10
|
-
/**
|
11
|
-
* Props for MUI TextField component
|
12
|
-
*/
|
13
|
-
inputProps?: Record<string, string | number | boolean | onChangeCallback | {
|
14
|
-
[key: string]: any;
|
15
|
-
}>;
|
16
|
-
/**
|
17
|
-
* Props for MUI SelectProps component
|
18
|
-
*/
|
19
|
-
selectProps?: Record<string, string | number | boolean | onChangeCallback | {
|
20
|
-
[key: string]: any;
|
21
|
-
}>;
|
9
|
+
export type ControlSelectProps = TextFieldProps & {
|
22
10
|
/**
|
23
11
|
* React Hook Form control `name` propery
|
24
12
|
*/
|
25
13
|
name: string;
|
14
|
+
/**
|
15
|
+
* Label for MUI TextField select component
|
16
|
+
*/
|
17
|
+
label?: string;
|
26
18
|
/**
|
27
19
|
* React Hook Form `control`
|
28
20
|
*/
|
29
21
|
control: Control<any>;
|
30
|
-
defaultValue?: any;
|
31
22
|
/**
|
32
|
-
* Is
|
23
|
+
* Is input required flag
|
33
24
|
*/
|
34
25
|
required?: boolean;
|
35
26
|
/**
|
36
|
-
*
|
27
|
+
* React Hook Form `defaultValue`
|
28
|
+
*/
|
29
|
+
defaultValue?: unknown;
|
30
|
+
/**
|
31
|
+
* Is disabled input flag
|
32
|
+
*/
|
33
|
+
disabled?: boolean;
|
34
|
+
/**
|
35
|
+
* React Hook Form validate function
|
36
|
+
* ```typescript
|
37
|
+
* type ValidateFunc = (value: string) => boolean | string;
|
38
|
+
* ```
|
39
|
+
*/
|
40
|
+
validate?: ValidateFunc | Record<string, ValidateFunc>;
|
41
|
+
/**
|
42
|
+
* Hide error message flag
|
37
43
|
*/
|
38
|
-
|
44
|
+
hideErrorMessage?: boolean;
|
45
|
+
/**
|
46
|
+
* Custom onChange functionƒ
|
47
|
+
*/
|
48
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
39
49
|
/**
|
40
50
|
* Key for option label
|
41
51
|
*/
|
@@ -45,22 +55,13 @@ export interface ControlSelectProps {
|
|
45
55
|
*/
|
46
56
|
valueKey?: string;
|
47
57
|
/**
|
48
|
-
*
|
49
|
-
*/
|
50
|
-
variant?: 'filled' | 'outlined' | 'standard';
|
51
|
-
/**
|
52
|
-
* React Hook Form validate function
|
53
|
-
* ```typescript
|
54
|
-
* type ValidateFunc = (value: string) => boolean | string;
|
55
|
-
* ```
|
58
|
+
* Select options
|
56
59
|
*/
|
57
|
-
|
58
|
-
|
59
|
-
disabled?: boolean;
|
60
|
-
}
|
60
|
+
options: string[] | unknown[];
|
61
|
+
};
|
61
62
|
/**
|
62
63
|
* Material UI `Select` controlled component. Used with react-hook-form
|
63
64
|
* @category Forms
|
64
65
|
*/
|
65
|
-
export declare const ControlSelect: ({
|
66
|
+
export declare const ControlSelect: ({ control, validate, name, label, required, defaultValue, disabled, hideErrorMessage, onChange: customOnChange, labelKey, valueKey, options, ...textFieldProps }: ControlSelectProps) => JSX.Element;
|
66
67
|
export default ControlSelect;
|
@@ -1,10 +1,11 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
+
import { SwitchProps } from '@mui/material/Switch';
|
2
3
|
import { Control } from 'react-hook-form';
|
3
|
-
type Props = {
|
4
|
+
type Props = SwitchProps & {
|
4
5
|
/**
|
5
6
|
* React Hook Form `control`
|
6
7
|
*/
|
7
|
-
control: Control
|
8
|
+
control: Control<any>;
|
8
9
|
/**
|
9
10
|
* React Hook Form control `name` propery
|
10
11
|
*/
|
@@ -14,5 +15,5 @@ type Props = {
|
|
14
15
|
*/
|
15
16
|
label?: string;
|
16
17
|
};
|
17
|
-
export declare const ControlSwitch: ({ control, name, label }: Props) => JSX.Element;
|
18
|
+
export declare const ControlSwitch: ({ control, name, label, ...switchProps }: Props) => JSX.Element;
|
18
19
|
export default ControlSwitch;
|
package/src/lib/Forms/index.d.ts
CHANGED
@@ -2,7 +2,7 @@ export * from './ControlInput';
|
|
2
2
|
export * from './ControlDebouncedInput';
|
3
3
|
export * from './ControlSelect';
|
4
4
|
export * from './ControlCheckbox';
|
5
|
-
export * from './
|
5
|
+
export * from './ControlRadio';
|
6
6
|
export * from './ControlAutocomplete';
|
7
7
|
export * from './ControlQueryAutocomplete';
|
8
8
|
export * from './CopyButton';
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
declare const useAutocomplete: ({ valueKey, labelKey }: {
|
3
|
+
valueKey: any;
|
4
|
+
labelKey: any;
|
5
|
+
}) => {
|
6
|
+
isOptionEqualToValue: (option: any, value: any) => boolean;
|
7
|
+
getOptionLabel: (option: any) => string;
|
8
|
+
renderOption: (props: any, option: any) => JSX.Element;
|
9
|
+
};
|
10
|
+
export default useAutocomplete;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import {
|
2
|
+
import { JsonPathPickerProperty } from '../../interfaces';
|
3
3
|
type Props = {
|
4
|
-
properties:
|
4
|
+
properties: JsonPathPickerProperty[];
|
5
5
|
open: boolean;
|
6
6
|
onClose: () => void;
|
7
7
|
onPaste: (path: string) => void;
|
@@ -10,7 +10,7 @@ type Props = {
|
|
10
10
|
multipleOptions?: boolean;
|
11
11
|
};
|
12
12
|
declare const usePropertyFiller: ({ property, name, label, isDirty, required, useExpression, multipleOptions, }: Props) => {
|
13
|
-
propertyType: import("../../../interfaces").PropertyType
|
13
|
+
propertyType: import("../../../interfaces").PropertyType;
|
14
14
|
valueLabel: string;
|
15
15
|
fillOptionLabel: string;
|
16
16
|
fillOption: PropertyFillType;
|
@@ -8,7 +8,6 @@ type Props = {
|
|
8
8
|
entityDefinition?: boolean;
|
9
9
|
globalParameter?: boolean;
|
10
10
|
customPropertyFields?: CustomPropertyFieldProps[];
|
11
|
-
hasAny?: boolean;
|
12
11
|
};
|
13
|
-
export declare const CreatePropertiesList: ({ parentFieldName, hideAddButton, focusOnIndex, required, entityDefinition, globalParameter, customPropertyFields,
|
12
|
+
export declare const CreatePropertiesList: ({ parentFieldName, hideAddButton, focusOnIndex, required, entityDefinition, globalParameter, customPropertyFields, }: Props) => JSX.Element;
|
14
13
|
export default CreatePropertiesList;
|
@@ -5,7 +5,6 @@ type Props = {
|
|
5
5
|
entityDefinition?: boolean;
|
6
6
|
globalParameter?: boolean;
|
7
7
|
customPropertyFields?: CustomPropertyFieldProps[];
|
8
|
-
hasAny?: boolean;
|
9
8
|
};
|
10
|
-
declare const CreatePropertyFormFields: ({ propertyFieldName, entityDefinition, globalParameter, customPropertyFields,
|
9
|
+
declare const CreatePropertyFormFields: ({ propertyFieldName, entityDefinition, globalParameter, customPropertyFields, }: Props) => JSX.Element;
|
11
10
|
export default CreatePropertyFormFields;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import {
|
2
|
+
import { PropertiesArrayType, PropertiesObjectType } from '../../../interfaces';
|
3
3
|
type Props = {
|
4
|
-
properties: PropertiesObjectType | PropertiesArrayType
|
4
|
+
properties: PropertiesObjectType<unknown> | PropertiesArrayType<unknown>;
|
5
5
|
expandAll?: boolean;
|
6
6
|
};
|
7
7
|
export declare const ViewPropertiesList: ({ properties, expandAll }: Props) => JSX.Element;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import {
|
2
|
+
import { JsonPathPickerProperty } from '../../interfaces';
|
3
3
|
type Props = {
|
4
4
|
fieldName: string;
|
5
|
-
getProperties?: () =>
|
5
|
+
getProperties?: () => JsonPathPickerProperty[];
|
6
6
|
initialText?: string;
|
7
7
|
};
|
8
8
|
export declare const TemplateContentEditor: ({ fieldName, getProperties, initialText }: Props) => JSX.Element;
|
package/src/utils/dem.d.ts
CHANGED
@@ -8,7 +8,7 @@ export declare function propertiesObjectToArray(properties: any, fields?: {
|
|
8
8
|
export declare const getDemPropertyDateFormat: (defaultFormat: string, propertyFormat: string) => string;
|
9
9
|
export declare const getEntityStarterValue: (property: EntityTypeProperty) => any;
|
10
10
|
export declare const getMultiplePropertyFillOptions: ({ propertyType, useExpression, required, }: {
|
11
|
-
propertyType: PropertyType
|
11
|
+
propertyType: PropertyType;
|
12
12
|
required: boolean;
|
13
13
|
useExpression?: boolean;
|
14
14
|
}) => {
|
@@ -17,7 +17,7 @@ export declare const getMultiplePropertyFillOptions: ({ propertyType, useExpress
|
|
17
17
|
sortOrder: number;
|
18
18
|
}[];
|
19
19
|
export declare const getSinglePropertyFillOptions: ({ propertyType, useExpression, required, }: {
|
20
|
-
propertyType: PropertyType
|
20
|
+
propertyType: PropertyType;
|
21
21
|
required: boolean;
|
22
22
|
useExpression?: boolean;
|
23
23
|
}) => {
|
@@ -2,4 +2,4 @@ import { PropertyType } from '../interfaces';
|
|
2
2
|
export declare const digitsOnly: RegExp;
|
3
3
|
export declare const floatsOnly: RegExp;
|
4
4
|
export declare const isExpression: (value: unknown) => boolean;
|
5
|
-
export declare const isDateType: (propertyType: PropertyType
|
5
|
+
export declare const isDateType: (propertyType: PropertyType) => boolean;
|
@@ -1,26 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
import { Control } from 'react-hook-form';
|
3
|
-
/**
|
4
|
-
* This interface is referencing the [[ControlRadioBtn]] component props.
|
5
|
-
* @category Forms
|
6
|
-
*/
|
7
|
-
export interface ControlRadioBtnProps {
|
8
|
-
/**
|
9
|
-
* React Hook Form `control`
|
10
|
-
*/
|
11
|
-
control: Control<any>;
|
12
|
-
/**
|
13
|
-
* React Hook Form control `name` propery
|
14
|
-
*/
|
15
|
-
name: string;
|
16
|
-
/**
|
17
|
-
* Radio group values
|
18
|
-
*/
|
19
|
-
values: any[];
|
20
|
-
}
|
21
|
-
/**
|
22
|
-
* Material UI `Radio` controlled component. Used with react-hook-form
|
23
|
-
* @category Forms
|
24
|
-
*/
|
25
|
-
export declare const ControlRadioBtn: ({ name, values, control }: ControlRadioBtnProps) => JSX.Element;
|
26
|
-
export default ControlRadioBtn;
|
@@ -1,10 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
import { PropertyUnion } from '../../../interfaces';
|
3
|
-
type Props = {
|
4
|
-
property: PropertyUnion;
|
5
|
-
name: string;
|
6
|
-
label?: string;
|
7
|
-
required?: boolean | 'byProperty';
|
8
|
-
};
|
9
|
-
export declare const PropertyValue: ({ property, name, label, required }: Props) => JSX.Element;
|
10
|
-
export default PropertyValue;
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { PropertiesArrayType, PropertyType } from '../../../interfaces';
|
2
|
-
import { Control } from 'react-hook-form';
|
3
|
-
export type ValueComponentProps = {
|
4
|
-
control: Control;
|
5
|
-
propertyType: PropertyType | 'ANY';
|
6
|
-
name: string;
|
7
|
-
label: string;
|
8
|
-
required: boolean;
|
9
|
-
format?: string;
|
10
|
-
restrictedValues?: string[];
|
11
|
-
properties?: PropertiesArrayType;
|
12
|
-
};
|
13
|
-
declare const ValueComponent: ({ propertyType, control, name, label, required, format, restrictedValues, properties, }: ValueComponentProps) => any;
|
14
|
-
export default ValueComponent;
|