diff --git a/dist/react-json-form.cjs b/dist/react-json-form.cjs index e3034f1..ca76262 100644 --- a/dist/react-json-form.cjs +++ b/dist/react-json-form.cjs @@ -390,7 +390,9 @@ function getSyncedArray(data, schema, getRef) { let minItems = schema.minItems || schema.min_items || 0; - while (data.length < minItems) data.push(FILLER); + if (schema.items.widget !== 'multiselect') { + while (data.length < minItems) data.push(FILLER); + } for (let i = 0; i < data.length; i++) { let item = data[i]; @@ -2718,6 +2720,7 @@ function FormField(props) { case 'number': if (type === 'range') inputProps.type = 'range';else inputProps.type = 'number'; + inputProps.step = 'any'; InputField = FormInput; if (props.schema.minimum || props.schema.minimum === 0) inputProps.min = props.schema.minimum; if (props.schema.maximum || props.schema.maximum === 0) inputProps.max = props.schema.maximum; @@ -3150,12 +3153,10 @@ class OneOfTopLevel extends React__default["default"].Component { }; this.getOptions = () => { - return this.props.args.schema[this.schemaName].map((option, index) => { - return { - label: option.title || 'Option ' + (index + 1), - value: index - }; - }); + return Array.from(this.props.args.schema[this.schemaName].keys(), index => ({ + label: this.getSchema(index).title || 'Option ' + (index + 1), + value: index + })); }; this.getSchema = index => { @@ -4171,7 +4172,7 @@ function DataValidator(schema) { let next_schema = schema.items; if (next_schema.hasOwnProperty('$ref')) next_schema = this.getRef(next_schema.$ref); - let next_type = normalizeKeyword(next_schema.type); + let next_type = getSchemaType(next_schema); let minItems = getKeyword(schema, 'minItems', 'min_items'); let maxItems = getKeyword(schema, 'maxItems', 'max_items'); let choices = getKeyword(schema.items, 'choices', 'enum'); @@ -4193,15 +4194,9 @@ function DataValidator(schema) { if (typeof invalid_choice !== 'undefined') this.addError(coords, 'Invalid choice + "' + invalid_choice + '"'); } - let next_validator = this.getValidator(next_type); + let next_validator = this.getValidator(next_type); // currently allOf is not supported in array items - if (!next_validator) { - if (next_schema.hasOwnProperty('oneOf')) { - next_validator = this.validateOneOf; - } else if (next_schema.hasOwnProperty('anyOf')) { - next_validator = this.validateAnyOf; - } else if (next_schema.hasOwnProperty('anyOf')) ; - } + if (next_type === 'allOf') next_validator = null; if (next_validator) { for (let i = 0; i < data.length; i++) next_validator(next_schema, data[i], this.joinCoords([coords, i])); @@ -4239,7 +4234,7 @@ function DataValidator(schema) { if (schema.required.indexOf(key) > -1 && !next_schema.hasOwnProperty('required')) next_schema['required'] = true; } - let next_type = normalizeKeyword(next_schema.type); + let next_type = getSchemaType(next_schema); let next_validator = this.getValidator(next_type); if (next_validator) next_validator(next_schema, data[key], this.joinCoords([coords, key]));else { this.addError(coords, 'Unsupported type "' + next_type + '" for object properties (keys).'); diff --git a/dist/react-json-form.js b/dist/react-json-form.js index d5f09bc..50e9f13 100644 --- a/dist/react-json-form.js +++ b/dist/react-json-form.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-modal"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-modal","react-dom"],t):t((e||self).reactJsonForm={},e.React,e.ReactModal,e.ReactDOM)}(this,function(e,t,a,r){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/n(t),l=/*#__PURE__*/n(a),o=/*#__PURE__*/n(r);function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0||(n[a]=e[a]);return n}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,r=new Array(t);a=a)return e.default;var r=[];if(e.default&&(r=[].concat(e.default)),0===a)return r;e.items.hasOwnProperty("$ref")&&(e.items=s({},t(e.items.$ref),e.items),delete e.items.$ref);var n=k(e.items.type);if(n||(Array.isArray(e.items.oneOf)?n=E(e.items.oneOf[0]):Array.isArray(e.items.anyOf)?n=E(e.items.anyOf[0]):Array.isArray(e.items.allOf)?n=E(e.items.allOf[0]):e.items.hasOwnProperty("const")&&(n=y(e.items.const))),"array"===n){for(;r.length=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(e);!(a=r()).done;)if(!t.has(a.value))return!1;return!0}(keyset2,keyset1))return!1}else if(r=keyset2,n=keyset1,r.size!==n.size||!Array.from(r).every(function(e){return n.has(e)}))return!1;for(var l in i)if(i.hasOwnProperty(l)){if(!e.hasOwnProperty(l))return!1;if(i[l].hasOwnProperty("const")&&i[l].const!==e[l])return!1;var o=k(i[l].type),s=y(e[l]);if("number"===o&&-1===["number","integer","null"].indexOf(s))return!1;if("integer"===o&&-1===["number","integer","null"].indexOf(s))return!1;if("boolean"===o&&-1===["boolean","null"].indexOf(s))return!1;if("string"===o&&"string"!==s)return!1}return!0}function F(e,t){var a=y(e);if(E(t)!==a)return!1;for(var r=t.items.type,n=0;n12?1:"hh"!==e&&t>59?0:t},t.handleChange=function(e){var a,r=e.target.dataset.name,n=e.target.value;if(!isNaN(n)){var i=t.validateValue(r,parseInt(n)||0);"hh"!==r||"0"!==n&&""!==n&&"00"!==n||1!==i||(i=0),n.startsWith("0")&&i<10&&0!==i&&(i=i.toString().padStart(2,"0")),t.sendValue(((a={})[r]=""!==n?i.toString():"",a))}},t.handleKeyDown=function(e){var a;if(38===e.keyCode||40===e.keyCode){var r=e.target.dataset.name,n=parseInt(e.target.value)||0;38===e.keyCode?n++:40===e.keyCode&&n--,t.sendValue(((a={})[r]=t.validateValue(r,n).toString().padStart(2,"0"),a))}},t.handleSpin=function(e,a){var r,n=t.props[e];"ampm"===e?n="am"===n?"pm":"am":(n=parseInt(n)||0,"up"===a?n++:n--,n=t.validateValue(e,n).toString().padStart(2,"0")),t.sendValue(((r={})[e]=n,r))},t.handleBlur=function(e){var a,r=t.validateValue(e.target.dataset.name,parseInt(e.target.value)||0);r<10&&t.sendValue(((a={})[e.target.dataset.name]=r.toString().padStart(2,"0"),a))},t}u(t,e);var a=t.prototype;return a.componentWillUnmount=function(){var e={hh:this.validateValue("hh",this.props.hh).toString().padStart(2,"0"),mm:this.validateValue("mm",this.props.mm).toString().padStart(2,"0"),ss:this.validateValue("ss",this.props.ss).toString().padStart(2,"0")};this.sendValue(e)},a.render=function(){var e=this;/*#__PURE__*/return i.default.createElement("div",{className:"rjf-time-picker"},/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-row rjf-time-picker-labels"},/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},"Hrs"),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},"Min"),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},"Sec"),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},"am/pm")),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-row"},/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement(H,{onClick:function(){return e.handleSpin("hh","up")}},/*#__PURE__*/i.default.createElement(J,{name:"chevron-up"}))),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement(H,{onClick:function(){return e.handleSpin("mm","up")}},/*#__PURE__*/i.default.createElement(J,{name:"chevron-up"}))),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement(H,{onClick:function(){return e.handleSpin("ss","up")}},/*#__PURE__*/i.default.createElement(J,{name:"chevron-up"}))),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement(H,{onClick:function(){return e.handleSpin("ampm","up")}},/*#__PURE__*/i.default.createElement(J,{name:"chevron-up"})))),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-row rjf-time-picker-values"},/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement("input",{type:"text","data-name":"hh",value:this.props.hh,onChange:this.handleChange,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown})),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"},":"),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement("input",{type:"text","data-name":"mm",value:this.props.mm,onChange:this.handleChange,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown})),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"},":"),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement("input",{type:"text","data-name":"ss",value:this.props.ss,onChange:this.handleChange,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown})),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},this.props.ampm)),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-row"},/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement(H,{onClick:function(){return e.handleSpin("hh","down")}},/*#__PURE__*/i.default.createElement(J,{name:"chevron-down"}))),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement(H,{onClick:function(){return e.handleSpin("mm","down")}},/*#__PURE__*/i.default.createElement(J,{name:"chevron-down"}))),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement(H,{onClick:function(){return e.handleSpin("ss","down")}},/*#__PURE__*/i.default.createElement(J,{name:"chevron-down"}))),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement(H,{onClick:function(){return e.handleSpin("ampm","down")}},/*#__PURE__*/i.default.createElement(J,{name:"chevron-down"})))))},t}(i.default.Component),Q=["label","help_text","error","inputRef"],ee=["label","help_text","error","value"],te=["label","help_text","error","value","options"],ae=["label","help_text","error","value","options"],re=["label","value"],ne=["label","help_text","error","inputRef"];function ie(e){return e.label?/*#__PURE__*/i.default.createElement("label",{className:e.required?"rjf-required":null},e.children,e.children&&" ",e.label):null}function le(e){var t=e.label,a=e.help_text,r=e.error,n=e.inputRef,l=d(e,Q);"string"===l.type&&(l.type="text"),n&&(l.ref=n),null===l.value&&(l.value="");var o={};return"hidden"==l.type&&(o.style={display:"none"}),l.readOnly&&null==l.disabled&&(l.disabled=!0),/*#__PURE__*/i.default.createElement("div",o,/*#__PURE__*/i.default.createElement(ie,{label:t,required:l.required}),/*#__PURE__*/i.default.createElement("div",{className:r?"rjf-input-group has-error":"rjf-input-group"},l.children||/*#__PURE__*/i.default.createElement("input",l),r&&r.map(function(e,t){/*#__PURE__*/return i.default.createElement("span",{className:"rjf-error-text",key:t},e)}),a&&/*#__PURE__*/i.default.createElement("span",{className:"rjf-help-text"},a)))}function oe(e){var t=e.label,a=e.help_text,r=e.error,n=e.value,l=d(e,ee);return t||(t=l.name.toUpperCase()),"bool"===l.type&&(l.type="checkbox"),void 0===l.checked&&(l.checked=n),""!==l.checked&&null!=l.checked||(l.checked=!1),l.readOnly&&(l.disabled=!0),/*#__PURE__*/i.default.createElement("div",{className:r?"rjf-check-input has-error":"rjf-check-input"},/*#__PURE__*/i.default.createElement(ie,{label:t,required:l.required},/*#__PURE__*/i.default.createElement("input",l)),r&&r.map(function(e,t){/*#__PURE__*/return i.default.createElement("span",{className:"rjf-error-text",key:t},e)}),a&&/*#__PURE__*/i.default.createElement("span",{className:"rjf-help-text"},a))}function se(e){var t=e.label,a=e.help_text,r=e.error,n=e.value,l=e.options,o=d(e,te);return o.readOnly&&(o.disabled=!0),/*#__PURE__*/i.default.createElement("div",{className:r?"rjf-check-input has-error":"rjf-check-input"},/*#__PURE__*/i.default.createElement(ie,{label:t,required:o.required}),l.map(function(e,t){var a,r;return"object"==typeof e?(a=e.title||e.label,r=e.value):("boolean"==typeof(a=e)&&(a=v(a.toString())),r=e),/*#__PURE__*/i.default.createElement("label",{className:"rjf-radio-option",key:a+"_"+r+"_"+t},/*#__PURE__*/i.default.createElement("input",s({},o,{value:r,checked:r===n}))," ",a)}),r&&r.map(function(e,t){/*#__PURE__*/return i.default.createElement("span",{className:"rjf-error-text",key:t},e)}),a&&/*#__PURE__*/i.default.createElement("span",{className:"rjf-help-text"},a))}function ue(e){var t=e.label,a=e.help_text,r=e.error,n=e.value,l=e.options,o=d(e,ae);return o.readOnly&&(o.disabled=!0),n||!1===n||0===n||(n=""),/*#__PURE__*/i.default.createElement("div",null,/*#__PURE__*/i.default.createElement(ie,{label:t,required:o.required}),/*#__PURE__*/i.default.createElement("div",{className:r?"rjf-input-group has-error":"rjf-input-group"},/*#__PURE__*/i.default.createElement("select",s({value:n},o),/*#__PURE__*/i.default.createElement("option",{disabled:!0,value:"",key:"__placeholder"},"Select..."),l.map(function(e,t){var a,r;return"object"==typeof e?(a=e.title||e.label,r=e.value):("boolean"==typeof(a=e)&&(a=v(a.toString())),r=e),/*#__PURE__*/i.default.createElement("option",{value:r,key:a+"_"+r+"_"+t},a)})),r&&r.map(function(e,t){/*#__PURE__*/return i.default.createElement("span",{className:"rjf-error-text",key:t},e)}),a&&/*#__PURE__*/i.default.createElement("span",{className:"rjf-help-text"},a)))}var ce=/*#__PURE__*/function(e){function t(t){var a;return(a=e.call(this,t)||this).handleChange=function(e){var t=[].concat(a.props.value),r=e.target.value;typeof r!==a.props.valueType&&(r=g(r,a.props.valueType)),e.target.checked?t.push(r):t=t.filter(function(e){return e!==r}),a.props.onChange({target:{type:a.props.type,value:t,name:a.props.name}})},a.showOptions=function(e){a.state.showOptions||a.setState({showOptions:!0})},a.hideOptions=function(e){a.setState({showOptions:!1})},a.toggleOptions=function(e){a.setState(function(e){return{showOptions:!e.showOptions}})},a.state={showOptions:!1},a.optionsContainer=/*#__PURE__*/i.default.createRef(),a.input=/*#__PURE__*/i.default.createRef(),a}return u(t,e),t.prototype.render=function(){/*#__PURE__*/return i.default.createElement("div",{className:this.props.readOnly?"rjf-multiselect-field readonly":"rjf-multiselect-field"},/*#__PURE__*/i.default.createElement(le,{label:this.props.label,help_text:this.props.help_text,error:this.props.error},/*#__PURE__*/i.default.createElement(de,{inputRef:this.input,onClick:this.toggleOptions,value:this.props.value,options:this.props.options,onChange:this.handleChange,disabled:this.props.readOnly,placeholder:this.props.placeholder})),this.state.showOptions&&/*#__PURE__*/i.default.createElement(pe,{options:this.props.options,value:this.props.value,hideOptions:this.hideOptions,onChange:this.handleChange,containerRef:this.optionsContainer,inputRef:this.input,disabled:this.props.readOnly,hasHelpText:(this.props.help_text||this.props.error)&&1}))},t}(i.default.Component),de=/*#__PURE__*/function(e){function t(){for(var t,a=arguments.length,r=new Array(a),n=0;n-1,o="rjf-multiselect-field-option";return l&&(o+=" selected"),e.props.disabled&&(o+=" disabled"),/*#__PURE__*/i.default.createElement("div",{key:r+"_"+n+"_"+a,className:o},/*#__PURE__*/i.default.createElement("label",null,/*#__PURE__*/i.default.createElement("input",{type:"checkbox",onChange:e.props.onChange,value:n,checked:l,disabled:e.props.disabled})," ",r))})))},t}(i.default.Component),fe=/*#__PURE__*/function(e){function t(t){var a;return(a=e.call(this,t)||this).getFileName=function(){return a.props.value?"data-url"===a.props.type?a.extractFileInfo(a.props.value).name:"file-url"===a.props.type?a.props.value:"Unknown file":""},a.extractFileInfo=function(e){var t=function(e){var t,a=e.split(","),r=a[0].split(";"),n=r[0].replace("data:",""),i=r.filter(function(e){return"name"===e.split("=")[0]});t=1!==i.length?"unknown":i[0].split("=")[1];for(var l=atob(a[1]),o=[],s=0;s12&&(t-=12,l="pm"),r=o.getMinutes(),n=o.getSeconds(),i=o.getMilliseconds(),t=t.toString().padStart(2,"0"),r=r.toString().padStart(2,"0"),n=n.toString().padStart(2,"0")}return{date:e,hh:t,mm:r,ss:n,ms:i,ampm:l}},a.handleClickOutside=function(e){a.state.showTimePicker&&(!a.timePickerContainer.current||a.timePickerContainer.current.contains(e.target)||a.timeInput.current.contains(e.target)||a.setState({showTimePicker:!1}))},a.sendValue=function(){var e={target:{type:"text",value:"",name:a.props.name}};if(""===a.state.date||null===a.state.date)return a.props.onChange(e);var t=parseInt(a.state.hh);0===t&&(t=NaN),"am"===a.state.ampm?12===t&&(t=0):"pm"===a.state.ampm&&12!==t&&(t+=12),t=t.toString().padStart(2,"0");var r=a.state.mm.padStart(2,"0"),n=a.state.ss.padStart(2,"0");try{var i=new Date(a.state.date+"T"+t+":"+r+":"+n+"."+a.state.ms);e.target.value=i.toISOString().replace("Z","+00:00")}catch(t){return a.props.onChange(e)}a.props.onChange(e)},a.handleDateChange=function(e){a.setState({date:e.target.value},a.sendValue)},a.handleTimeChange=function(e){a.setState(s({},e),a.sendValue)},a.showTimePicker=function(){a.setState({showTimePicker:!a.props.readOnly&&!0})},a.state=s({},a.getStateFromProps(),{showTimePicker:!1}),a.timeInput=/*#__PURE__*/i.default.createRef(),a.timePickerContainer=/*#__PURE__*/i.default.createRef(),a}u(t,e);var a=t.prototype;return a.componentDidUpdate=function(e,t){if(e.value!==this.props.value&&""!==this.state.hh&&"0"!==this.state.hh&&"00"!==this.state.hh){var a=!1,r=this.getStateFromProps();for(var n in r)if(r[n]!==this.state[n]){a=!0;break}a&&this.setState(s({},r))}},a.componentDidMount=function(){document.addEventListener("mousedown",this.handleClickOutside)},a.componentWillUnmount=function(){document.removeEventListener("mousedown",this.handleClickOutside)},a.render=function(){/*#__PURE__*/return i.default.createElement("div",{className:this.props.error?"rjf-datetime-field has-error":"rjf-datetime-field"},/*#__PURE__*/i.default.createElement(ie,{label:this.props.label,required:this.props.required}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-datetime-field-inner"},/*#__PURE__*/i.default.createElement("div",{className:this.props.readOnly?"rjf-datetime-field-inputs readonly":"rjf-datetime-field-inputs"},/*#__PURE__*/i.default.createElement("div",{className:"rjf-datetime-field-date"},/*#__PURE__*/i.default.createElement(le,{label:"Date",type:"date",value:this.state.date,onChange:this.handleDateChange,readOnly:this.props.readOnly})),/*#__PURE__*/i.default.createElement("div",{className:"rjf-datetime-field-time"},/*#__PURE__*/i.default.createElement(le,{label:"Time",type:"text",value:this.state.hh+":"+this.state.mm+":"+this.state.ss+" "+this.state.ampm,onFocus:this.showTimePicker,readOnly:!0,disabled:this.props.readOnly||!1,inputRef:this.timeInput}),/*#__PURE__*/i.default.createElement("div",{ref:this.timePickerContainer},this.state.showTimePicker&&/*#__PURE__*/i.default.createElement(Z,{onChange:this.handleTimeChange,hh:this.state.hh,mm:this.state.mm,ss:this.state.ss,ampm:this.state.ampm})))),this.props.error&&this.props.error.map(function(e,t){/*#__PURE__*/return i.default.createElement("span",{className:"rjf-error-text",key:t},e)}),this.props.help_text&&/*#__PURE__*/i.default.createElement("span",{className:"rjf-help-text"},this.props.help_text)))},t}(i.default.Component);function ve(e){/*#__PURE__*/return i.default.createElement("div",{className:e.label?"rjf-url-field has-label":"rjf-url-field"},/*#__PURE__*/i.default.createElement(le,s({},e,{type:"url",className:"rjf-url-field-input"})),e.value&&/*#__PURE__*/i.default.createElement("a",{href:e.value,target:"_blank",rel:"noopener noreferrer",className:"rjf-url-field-link",title:"Open in new tab"},/*#__PURE__*/i.default.createElement(J,{name:"box-arrow-up-right"})," ",/*#__PURE__*/i.default.createElement("span",null,"Open link")))}var ge=/*#__PURE__*/function(e){function t(t){var a,r,n;return(a=e.call(this,t)||this).handleSelect=function(e){a.props.multiselect&&(e=Array.isArray(a.props.value)?a.props.value.concat([e]):[e]);var t={target:{type:a.props.type,value:e,name:a.props.name}};a.props.multiselect||a.hideOptions(),a.props.onChange(t)},a.handleMultiselectRemove=function(e){var t=a.props.value.filter(function(t){return t!==e});a.props.onChange({target:{type:a.props.type,value:t,name:a.props.name}})},a.clearValue=function(e){a.handleSelect(a.defaultEmptyValue)},a.hasValue=function(){return!(Array.isArray(a.props.value)&&!a.props.value.length)&&""!==a.props.value&&null!==a.props.value},a.handleSearchInputChange=function(e){var t=e.target.value;t?a.setState({searchInputValue:t,loading:!0},a.debouncedFetchOptions):a.setState({searchInputValue:t,loading:!1,options:[]})},a.fetchOptions=function(){if(""!==a.state.searchInputValue){var e=a.props.handler;if(!e)return console.error("Error: No 'handler' endpoint provided for autocomplete input."),void a.setState({loading:!1});var t=e+"?"+new URLSearchParams({field_name:a.context.fieldName,model_name:a.context.modelName,coords:j(a.props.name),query:a.state.searchInputValue});fetch(t,{method:"GET"}).then(function(e){return e.json()}).then(function(e){Array.isArray(e.results)||(e.results=[]),a.setState(function(t){return{loading:!1,options:[].concat(e.results)}})}).catch(function(e){alert("Something went wrong while fetching options"),console.error("Error:",e),a.setState({loading:!1})})}},a.showOptions=function(e){a.state.showOptions||a.setState({showOptions:!0})},a.hideOptions=function(e){a.setState({showOptions:!1,searchInputValue:"",options:[],loading:!1})},a.toggleOptions=function(e){a.setState(function(e){return e.showOptions?{showOptions:!1,searchInputValue:"",options:[],loading:!1}:{showOptions:!0}})},a.state={searchInputValue:"",showOptions:!1,options:[],loading:!1},a.optionsContainer=/*#__PURE__*/i.default.createRef(),a.searchInputRef=/*#__PURE__*/i.default.createRef(),a.input=/*#__PURE__*/i.default.createRef(),a.debouncedFetchOptions=(r=a.fetchOptions,function(){clearTimeout(n);var e=arguments,t=this;n=setTimeout(function(){r.apply(t,e)},500)}),a.defaultEmptyValue=t.multiselect?[]:"",a}u(t,e);var a=t.prototype;return a.componentDidUpdate=function(e,t){this.state.showOptions&&this.state.showOptions!==t.showOptions&&this.searchInputRef.current&&this.searchInputRef.current.focus()},a.render=function(){var e=this;/*#__PURE__*/return i.default.createElement("div",{className:this.props.label?"rjf-autocomplete-field has-label":"rjf-autocomplete-field"},this.props.multiselect?/*#__PURE__*/i.default.createElement(le,{label:this.props.label,help_text:this.props.help_text,error:this.props.error},/*#__PURE__*/i.default.createElement(de,{inputRef:this.input,onClick:this.toggleOptions,onChange:function(t){return e.handleMultiselectRemove(t.target.value)},value:this.props.value,placeholder:this.props.placeholder||" ",disabled:this.props.readOnly||!1})):/*#__PURE__*/i.default.createElement(i.default.Fragment,null,/*#__PURE__*/i.default.createElement(le,{label:this.props.label,type:"text",value:this.props.value,help_text:this.props.help_text,error:this.props.error,readOnly:!0,disabled:this.props.readOnly||!1,onClick:this.toggleOptions,inputRef:this.input,placeholder:this.props.placeholder,name:this.props.name,className:"rjf-autocomplete-field-input"}),this.hasValue()&&!this.props.readOnly&&/*#__PURE__*/i.default.createElement(H,{className:"autocomplete-field-clear",title:"Clear",onClick:this.clearValue},/*#__PURE__*/i.default.createElement(J,{name:"x-circle"})," ",/*#__PURE__*/i.default.createElement("span",null,"Clear"))),this.state.showOptions&&!this.props.readOnly&&/*#__PURE__*/i.default.createElement(ye,{options:this.state.options,value:this.props.value,hideOptions:this.hideOptions,onSelect:this.handleSelect,onSearchInputChange:this.handleSearchInputChange,searchInputValue:this.state.searchInputValue,containerRef:this.optionsContainer,searchInputRef:this.searchInputRef,inputRef:this.input,loading:this.state.loading,hasHelpText:(this.props.help_text||this.props.error)&&1,multiselect:this.props.multiselect}))},t}(i.default.Component);ge.contextType=h;var ye=/*#__PURE__*/function(e){function t(){for(var t,a=arguments.length,r=new Array(a),n=0;n-1:e.value===n)&&(o+=" selected"),/*#__PURE__*/i.default.createElement("div",{key:r+"_"+n+"_"+a,className:o,tabIndex:0,role:"button",onClick:function(){return e.multiselect&&l?null:e.onSelect(n)}},r)}))}function be(e){return e.children?/*#__PURE__*/i.default.createElement("div",{className:"rjf-form-group-title"},e.children,e.editable&&/*#__PURE__*/i.default.createElement(i.default.Fragment,null," ",/*#__PURE__*/i.default.createElement(H,{className:"edit",onClick:e.onEdit,title:"Edit"},"Edit")),e.collapsible&&/*#__PURE__*/i.default.createElement(i.default.Fragment,null," ",/*#__PURE__*/i.default.createElement(H,{className:"collapse",onClick:e.onCollapse,title:e.collapsed?"Expand":"Collapse"},e.collapsed?"[+]":"[-]"))):null}function we(e){return e.children?/*#__PURE__*/i.default.createElement("div",{className:"rjf-form-group-description"},e.children):null}function je(e,t,a){var r=e.target.parentElement.parentElement,n=r.previousElementSibling,i=r.nextElementSibling;if(r.classList.add("rjf-animate","rjf-"+t),"move-up"===t){var l=n.getBoundingClientRect().y,o=l,s=l=r.getBoundingClientRect().y;n.classList.add("rjf-animate"),n.style.opacity=0,n.style.transform="translateY("+(s-o)+"px)",r.style.opacity=0,r.style.transform="translateY(-"+(s-o)+"px)"}else if("move-down"===t){var u=r.getBoundingClientRect().y,c=u,d=u=i.getBoundingClientRect().y;i.classList.add("rjf-animate"),i.style.opacity=0,i.style.transform="translateY(-"+(d-c)+"px)",r.style.opacity=0,r.style.transform="translateY("+(d-c)+"px)"}setTimeout(function(){a(),r.classList.remove("rjf-animate","rjf-"+t),r.style=null,"move-up"===t?(n.classList.remove("rjf-animate"),n.style=null):"move-down"===t&&(i.classList.remove("rjf-animate"),i.style=null)},200)}function ke(e){/*#__PURE__*/return i.default.createElement("div",{className:"rjf-form-row-controls"},e.onMoveUp&&/*#__PURE__*/i.default.createElement(H,{className:"move-up",onClick:function(t){return je(t,"move-up",e.onMoveUp)},title:"Move up"},/*#__PURE__*/i.default.createElement("span",null,"↑")),e.onMoveDown&&/*#__PURE__*/i.default.createElement(H,{className:"move-down",onClick:function(t){return je(t,"move-down",e.onMoveDown)},title:"Move down"},/*#__PURE__*/i.default.createElement("span",null,"↓")),e.onRemove&&/*#__PURE__*/i.default.createElement(H,{className:"remove",onClick:function(t){return je(t,"remove",e.onRemove)},title:"Remove"},/*#__PURE__*/i.default.createElement("span",null,"×")))}function Ne(e){var t="rjf-form-row";return e.hidden&&(t+=" rjf-form-row-hidden"),/*#__PURE__*/i.default.createElement("div",{className:t},/*#__PURE__*/i.default.createElement(ke,e),/*#__PURE__*/i.default.createElement("div",{className:"rjf-form-row-inner"},e.children))}function Se(e){var t=i.default.useState(!1),a=t[0],r=t[1],n=E(e.schema);i.default.Children.count(e.children);var l,o,s=0===e.level&&"groups"===e.childrenType?"":"rjf-form-group-inner";return"object"===n?(l="Add key",o="Add new key"):(l="Add item",o="Add new item"),/*#__PURE__*/i.default.createElement("div",{className:"rjf-form-group"},0===e.level&&/*#__PURE__*/i.default.createElement(be,{editable:e.editable,onEdit:e.onEdit,collapsible:e.collapsible,onCollapse:function(){return r(!a)},collapsed:a},e.schema.title),0===e.level&&/*#__PURE__*/i.default.createElement(we,null,e.schema.description),/*#__PURE__*/i.default.createElement("div",{className:s},e.level>0&&/*#__PURE__*/i.default.createElement(be,{editable:e.editable,onEdit:e.onEdit,collapsible:e.collapsible,onCollapse:function(){return r(!a)},collapsed:a},e.schema.title),e.level>0&&/*#__PURE__*/i.default.createElement(we,null,e.schema.description),a&&/*#__PURE__*/i.default.createElement("div",{className:"rjf-collapsed-indicator"},/*#__PURE__*/i.default.createElement("span",null,"Collapsed")),/*#__PURE__*/i.default.createElement("div",{className:a?"rjf-form-group-children rjf-collapsed":"rjf-form-group-children"},e.children),!a&&e.addable&&/*#__PURE__*/i.default.createElement(H,{className:"add",onClick:function(t){return e.onAdd()},title:o},l)))}var Ce=/*#__PURE__*/function(e){function t(t){var a;return(a=e.call(this,t)||this).openModal=function(e){a.setState({open:!0})},a.closeModal=function(e){a.setState({open:!1,pane:"upload"})},a.togglePane=function(e){a.setState({pane:e})},a.handleFileSelect=function(e){a.props.onChange({target:{type:"text",value:e,name:a.props.name}}),a.closeModal()},a.handleFileUpload=function(e){a.newFiles.push(e.target.value),a.addExitEventListeners(),a.props.onChange(e),a.closeModal()},a.addExitEventListeners=function(){a.exitListenersAdded||a.hiddenInputRef.current&&a.hiddenInputRef.current.form&&(window.addEventListener("beforeunload",a.promptOnExit),window.addEventListener("unload",a.sendDeleteRequestOnExit),a.hiddenInputRef.current.form.addEventListener("submit",function(e){window.removeEventListener("beforeunload",a.promptOnExit),window.removeEventListener("unload",a.sendDeleteRequestOnExit)}),a.exitListenersAdded=!0)},a.promptOnExit=function(e){a.newFiles.length&&(e.preventDefault(),e.returnValue="")},a.sendDeleteRequestOnExit=function(e){a.newFiles.length&&a.sendDeleteRequest([a.newFiles],"unsaved_form_page_exit",!0)},a.clearFile=function(){window.confirm("Do you want to remove this file?")&&a.props.onChange({target:{type:"text",value:"",name:a.props.name}})},a.sendDeleteRequest=function(e,t,r){for(var n=a.props.handler||a.context.fileHandler,i=new URLSearchParams(s({},a.context.fileHandlerArgs,{coords:j(a.props.name),trigger:t})),l=0;l0?t.page+1:t.page,hasMore:e.results.length>0}})}).catch(function(e){alert("Something went wrong while retrieving media files"),console.error("Error:",e),a.setState({loading:!1})})},a.onLoadMore=function(e){a.setState({loading:!0},a.fetchList)},a.onFileDelete=function(){a.setState({page:0,files:[]},a.onLoadMore)},a.state={loading:!0,files:[],page:0,hasMore:!0},a}u(t,e);var a=t.prototype;return a.componentDidMount=function(){this.fetchList()},a.render=function(){var e=this;/*#__PURE__*/return i.default.createElement("div",{className:"rjf-upload-modal__pane"},/*#__PURE__*/i.default.createElement("h3",null,"Media library"),/*#__PURE__*/i.default.createElement("div",{className:"rjf-upload-modal__media-container"},this.state.files.map(function(t){/*#__PURE__*/return i.default.createElement(Re,s({},t,{onClick:e.props.onFileSelect,sendDeleteRequest:e.props.sendDeleteRequest,onFileDelete:e.onFileDelete}))})),this.state.loading&&/*#__PURE__*/i.default.createElement(U,{className:"rjf-upload-modal__media-loader"}),!this.state.loading&&this.state.hasMore&&/*#__PURE__*/i.default.createElement("div",null,/*#__PURE__*/i.default.createElement(H,{onClick:this.onLoadMore,className:"upload-modal__media-load"},/*#__PURE__*/i.default.createElement(J,{name:"arrow-down"})," View more")),!this.state.hasMore&&/*#__PURE__*/i.default.createElement("div",{className:"rjf-upload-modal__media-end-message"},this.state.files.length?"End of list":"No files found"))},t}(i.default.Component);function Re(e){var t=e.metadata||{};/*#__PURE__*/return i.default.createElement("div",{className:"rjf-upload-modal__media-tile"},/*#__PURE__*/i.default.createElement(_e,{value:e.value,sendDeleteRequest:e.sendDeleteRequest,onFileDelete:e.onFileDelete}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-upload-modal__media-tile-inner",tabIndex:"0",onClick:function(){return e.onClick(e.value)}},/*#__PURE__*/i.default.createElement("img",{src:e.thumbnail?e.thumbnail:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23999999' viewBox='0 0 16 16'%3E%3Cpath d='M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5L14 4.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5h-2z'/%3E%3C/svg%3E"}),e.metadata&&/*#__PURE__*/i.default.createElement("div",{className:"rjf-upload-modal__media-tile-metadata"},Object.getOwnPropertyNames(t).map(function(e){/*#__PURE__*/return i.default.createElement("span",null,t[e])}))))}var _e=/*#__PURE__*/function(e){function t(t){var a;return(a=e.call(this,t)||this).toggleMenu=function(e){a.setState(function(e){return{open:!e.open}})},a.handleDeleteClick=function(e){window.confirm("Do you want to delete this file?")&&(a.setState({loading:!0}),a.props.sendDeleteRequest([a.props.value],"delete_button").then(function(e){var t,r=e.status;200===r||(400===r?t="Bad request":401===r||403===r?t="You don't have permission to delete this file":404===r?t="This file does not exist on server":405===r?t="This operation is not permitted":r>405&&(t="Something went wrong while deleting file")),a.setState({loading:!1,open:!1}),t?alert(t):a.props.onFileDelete()}).catch(function(e){alert("Something went wrong while deleting file"),console.error("Error:",e),a.setState({loading:!1})}))},a.state={open:!1,loading:!1},a}return u(t,e),t.prototype.render=function(){/*#__PURE__*/return i.default.createElement("div",{className:this.state.open?"rjf-dropdown open":"rjf-dropdown"},/*#__PURE__*/i.default.createElement(H,{className:"rjf-dropdown-toggler",alterClassName:!1,title:this.state.open?"Close menu":"Open menu",onClick:this.toggleMenu},/*#__PURE__*/i.default.createElement(J,{name:this.state.open?"x-lg":"three-dots-vertical"})),this.state.open&&/*#__PURE__*/i.default.createElement("div",{className:"rjf-dropdown-items"},/*#__PURE__*/i.default.createElement(H,{className:"rjf-dropdown-item rjf-text-danger",alterClassName:!1,onClick:this.handleDeleteClick},this.state.loading&&/*#__PURE__*/i.default.createElement(U,null),this.state.loading?" Deleting...":"Delete")))},t}(i.default.Component),Me=["data","schema","name","onChange","onRemove","removable","onEdit","onKeyEdit","editable","onMoveUp","onMoveDown","parentType","errorMap"];function Ie(e){var t,a={name:e.name,value:e.data,readOnly:N(e.schema,"readOnly","readonly"),help_text:N(e.schema,"help_text","helpText"),error:e.errorMap[j(e.name)],required:e.schema.required||!1};"string"==typeof a.error&&(a.error=[a.error]),e.schema.placeholder&&(a.placeholder=e.schema.placeholder),e.schema.handler&&(a.handler=e.schema.handler),e.schema.hasOwnProperty("const")?(t=y(e.schema.const),a.readOnly=!0):t=k(e.schema.type);var r,n=N(e.schema,"choices","enum");switch(n&&(a.options=n,t="select"),e.schema.widget&&("multiselect"===e.schema.widget&&"array"!==e.parentType||(t="hidden"===e.schema.widget?"string":e.schema.widget)),t){case"string":if(r=le,e.schema.format){var l=e.schema.format;"data-url"===l?r=fe:"file-url"===l?r=Ce:"date-time"===k(l)?r=he:"uri"!==l&&"uri-reference"!==l||(r=ve),a.type=l}else a.type="hidden"===e.schema.widget?"hidden":"text";(e.schema.minLength||0===e.schema.minLength)&&(a.minLength=e.schema.minLength),(e.schema.maxLength||0===e.schema.maxLength)&&(a.maxLength=e.schema.maxLength);break;case"fileinput":r=fe,e.schema.format&&(a.type=e.schema.format);break;case"range":case"integer":a.step="1";case"number":a.type="range"===t?"range":"number",r=le,(e.schema.minimum||0===e.schema.minimum)&&(a.min=e.schema.minimum),(e.schema.maximum||0===e.schema.maximum)&&(a.max=e.schema.maximum);break;case"boolean":case"checkbox":a.type="checkbox",r=oe;break;case"radio":a.type="radio",r=se;break;case"select":r=ue;break;case"multiselect":a.valueType=e.schema.type,r=ce;break;case"autocomplete":r=ge;break;case"multiselect-autocomplete":r=ge,a.multiselect=!0;break;case"textarea":r=me,(e.schema.minLength||0===e.schema.minLength)&&(a.minLength=e.schema.minLength),(e.schema.maxLength||0===e.schema.maxLength)&&(a.maxLength=e.schema.maxLength);break;default:a.type="text",r=le}/*#__PURE__*/return i.default.createElement(r,s({},a,{label:e.editable?/*#__PURE__*/i.default.createElement("span",null,e.schema.title," ",/*#__PURE__*/i.default.createElement(H,{className:"edit",onClick:e.onEdit,title:"Edit"},"Edit")):e.schema.title,onChange:function(t){return function(e,t,a){var r;r="checkbox"===e.target.type?e.target.checked:e.target.value,r=Array.isArray(r)?r.map(function(e){return g(e,t)}):g(r,t),a(e.target.name,r)}(t,e.schema.type,e.onChange)}}))}function Ve(e){var t=e.data,a=e.schema,r=e.name,n=e.onChange,l=e.onRemove,o=e.removable,u=e.onKeyEdit,c=e.editable,p=e.onMoveUp,f=e.onMoveDown,m=e.parentType,h=e.errorMap,v=d(e,Me);/*#__PURE__*/return i.default.createElement(Ne,{key:r,onRemove:o?function(e){return l(r)}:null,onMoveUp:p,onMoveDown:f,hidden:"hidden"===a.widget},/*#__PURE__*/i.default.createElement(Ie,s({data:t,schema:a,name:r,onChange:n,onEdit:u,editable:c,parentType:m,errorMap:h},v)))}function De(e){var t=e.data,a=e.schema,r=e.name,n=e.onChange,l=e.onAdd,o=e.onRemove,u=e.onMove,c=e.onEdit,d=e.level,p=[],f=[],m=N(a,"readonly","readOnly",!1),h=!0,v=N(a,"min_items","minItems")||0;(t.length<=v||m)&&(h=!1);var g=!0,y=N(a,"max_items","maxItems")||100;(t.length>=y||m)&&(g=!1),a.items.hasOwnProperty("$ref")&&(a.items=s({},e.getRef(a.items.$ref),a.items),delete a.items.$ref);var E=k(a.items.type),O={schema:a.items,onChange:n,onAdd:l,onRemove:o,level:d+1,removable:h,onMove:u,onEdit:c,onKeyEdit:e.onKeyEdit,parentType:"array",getRef:e.getRef,errorMap:e.errorMap};if(m&&(O.schema.readOnly=!0),"multiselect"===O.schema.widget||"multiselect-autocomplete"===O.schema.widget)O.data=t,O.name=r,O.removable=!1,O.onMoveUp=null,O.onMoveDown=null,g=!1,p.push(Ve(O));else for(var w=function(n){O.data=t[n],O.name=b(r,n),O.onMoveUp=0===n||m?null:function(e){return u(b(r,n),b(r,n-1))},O.onMoveDown=n===t.length-1||m?null:function(e){return u(b(r,n),b(r,n+1))},"array"===E?f.push(De(O)):"object"===E?f.push(Le(O)):a.items.hasOwnProperty("oneOf")?f.push(/*#__PURE__*/i.default.createElement(He,{parentArgs:e,nextArgs:s({},O),key:"oneOf_"+r+"_"+n})):a.items.hasOwnProperty("anyOf")?f.push(/*#__PURE__*/i.default.createElement(Ue,{parentArgs:e,nextArgs:s({},O),key:"anyOf_"+r+"_"+n})):p.push(Ve(O))},S=0;S0,childrenType:"rows"},C&&C.map(function(e,t){/*#__PURE__*/return i.default.createElement("div",{className:"rjf-error-text",key:t},e)}),p),"object"===e.parentType&&e.removable&&(p=/*#__PURE__*/i.default.createElement("div",{className:"rjf-form-group-wrapper",key:"row_group_wrapper_"+r},/*#__PURE__*/i.default.createElement(ke,{onRemove:function(e){return o(r)}}),p))),f.length){var A=e.errorMap[j(x)];"string"==typeof A&&(A=[A]),f=/*#__PURE__*/i.default.createElement("div",{key:"group_"+r,className:"rjf-form-group-wrapper"},"object"===e.parentType&&e.removable&&/*#__PURE__*/i.default.createElement(ke,{onRemove:function(e){return o(r)}}),/*#__PURE__*/i.default.createElement(Se,{level:d,schema:a,addable:g,onAdd:function(){return l(R(a.items,e.getRef),x)},editable:e.editable,onEdit:e.onKeyEdit,collapsible:t.length>0,childrenType:"groups"},A&&A.map(function(e,t){/*#__PURE__*/return i.default.createElement("div",{className:"rjf-error-text",key:t},e)}),f.map(function(e,t){/*#__PURE__*/return i.default.createElement("div",{className:"rjf-form-group-wrapper",key:"group_wrapper_"+r+"_"+t},/*#__PURE__*/i.default.createElement(ke,{onRemove:h?function(e){return o(b(r,t))}:null,onMoveUp:t>0&&!m?function(e){return u(b(r,t),b(r,t-1))}:null,onMoveDown:t-1&&(j.required=!0);var x={data:E,schema:j,name:O,onChange:n,onAdd:l,onRemove:o,level:d+1,removable:C,onMove:u,onEdit:c,parentType:"object",getRef:e.getRef,errorMap:e.errorMap,onKeyEdit:function(){return function(e,t,a,r,n){var i=prompt("Rename key",t);if(null!==i&&(i=i.trim())!==t){if(!i)return alert("(!) Key name can't be empty.\r\n\r\n‎");if(e.hasOwnProperty(i))return alert("(!) Duplicate keys not allowed. This key already exists.\r\n\r\n‎");var l=w(r);l.pop(),l.push(i),n(a,l=b.apply(null,l),r)}}(t,y,E,O,c)}};x.editable=C,"array"===S?p.push(De(x)):"object"===S?p.push(Le(x)):x.schema.hasOwnProperty("oneOf")?p.push(/*#__PURE__*/i.default.createElement(He,{parentArgs:e,nextArgs:s({},x),key:"oneOf_"+r+"_"+h})):x.schema.hasOwnProperty("anyOf")?p.push(/*#__PURE__*/i.default.createElement(Ue,{parentArgs:e,nextArgs:s({},x),key:"anyOf_"+r+"_"+h})):p.push(Ve(x))},E=0;E0,childrenType:"rows"},S&&S.map(function(e,t){/*#__PURE__*/return i.default.createElement("div",{className:"rjf-error-text",key:t},e)}),p),"object"===e.parentType&&e.removable&&(p=/*#__PURE__*/i.default.createElement("div",{className:"rjf-form-group-wrapper",key:"row_group_wrapper_"+r},/*#__PURE__*/i.default.createElement(ke,{onRemove:function(e){return o(r)}}),p))}return p}function Te(e){/*#__PURE__*/return i.default.createElement(qe,{args:e})}function $e(e){/*#__PURE__*/return i.default.createElement(qe,{args:e,schemaName:"anyOf"})}function Fe(e){return Le(e)}var qe=/*#__PURE__*/function(e){function t(t){var a;return(a=e.call(this,t)||this).findSelectedOption=function(){return y(a.props.args.data),T(a.props.args.data,a.props.args.schema,a.props.args.getRef,a.schemaName)},a.getOptions=function(){return a.props.args.schema[a.schemaName].map(function(e,t){return{label:e.title||"Option "+(t+1),value:t}})},a.getSchema=function(e){void 0===e&&(e=a.state.option);var t=a.props.args.schema[a.schemaName][e];return t.hasOwnProperty("$ref")&&delete(t=s({},a.props.args.getRef(t.$ref),{schema:t})).$ref,t},a.handleOptionChange=function(e){a.updateData(a.getSchema(e.target.value))},a.schemaName=a.props.schemaName||"oneOf",a}u(t,e);var a=t.prototype;return a.updateData=function(e){this.props.args.onChange(this.props.args.name,R(e,this.props.args.getRef))},a.render=function(){var e,t=this.findSelectedOption(),a=this.getSchema(t),r=E(a),n=this.props.args;"object"===r?e=Le:"array"===r?e=De:(e=Ve,n.removable=!1,n.onMoveUp=null,n.onMoveDown=null,(Array.isArray(n.data)||"object"==typeof n.data)&&(n.data=null));var l=e(s({},n,{schema:a})),o=this.props.args.schema.title||null;/*#__PURE__*/return i.default.createElement("div",{className:"rjf-form-group rjf-oneof-group rjf-oneof-group-top-level"},/*#__PURE__*/i.default.createElement("div",{className:"rjf-oneof-selector"},/*#__PURE__*/i.default.createElement(ue,{value:t,options:this.getOptions(),onChange:this.handleOptionChange,className:"rjf-oneof-selector-input",label:o})),l)},t}(i.default.Component),He=/*#__PURE__*/function(e){function t(t){var a;return(a=e.call(this,t)||this).findSelectedOption=function(){var e=0;if(a.props.nextArgs)for(var t=y(a.props.nextArgs.data),r=a.props.nextArgs.schema[a.schemaName],n=0;n-1){e=n;break}if("object"===t){if($(a.props.nextArgs.data,i)){e=n;break}}else if("array"===t){if(F(a.props.nextArgs.data,i)){e=n;break}}else if(t===l){e=n;break}}}else{var o=a.props.parentArgs.data,u=y(o),c=a.props.parentArgs.schema[a.schemaName];if(void 0===c)return e;for(var d=0;d-1||(c[d]=l[d]));u.forEach(function(e,t){c[e]=R(o[e],a.props.parentArgs.getRef)}),this.props.parentArgs.onChange(n,c)}},a.render=function(){var e,t=this,a=this.findSelectedOption(),r=this.getSchema(a),n=E(r),l=this.props.nextArgs?this.props.nextArgs:this.props.parentArgs;"object"===n?(e=Le,"object"==typeof l.data&&null!==l.data||(l.data={})):"array"===n?(e=De,Array.isArray(l.data)||(l.data=[])):(e=Ve,l.removable=!1,l.onMoveUp=null,l.onMoveDown=null,(Array.isArray(l.data)||"object"==typeof l.data)&&(l.data=null));var o=e(s({},l,{schema:r})),u=null;return this.props.nextArgs&&(u=this.props.nextArgs.schema.title||null),/*#__PURE__*/i.default.createElement("div",{className:"rjf-form-group rjf-oneof-group"},/*#__PURE__*/i.default.createElement("div",{className:"rjf-oneof-selector"},/*#__PURE__*/i.default.createElement(ue,{value:a,options:this.getOptions(),onChange:function(e){return t.handleOptionChange(e,a)},className:"rjf-oneof-selector-input",label:u})),o)},t}(i.default.Component);function Ue(e){/*#__PURE__*/return i.default.createElement(He,s({},e,{schemaName:"anyOf"}))}function Je(e){if(!(e instanceof Object))return{isValid:!1,msg:"Schema must be an object"};var t,a=E(e);return(t="object"===a?Be(e):"array"===a?ze(e):e.hasOwnProperty("allOf")?Ge(e):e.hasOwnProperty("oneOf")?We(e):e.hasOwnProperty("anyOf")?Ye(e):e.hasOwnProperty("$ref")?{isValid:!0}:{isValid:!1,msg:"Outermost schema can only be of type array, list, object or dict"}).isValid&&e.hasOwnProperty("$defs")&&!e.$defs instanceof Object?{isValid:!1,msg:"'$defs' must be a valid JavaScript Object"}:t}function Be(e){if(!(e.hasOwnProperty("keys")||e.hasOwnProperty("properties")||e.hasOwnProperty("oneOf")||e.hasOwnProperty("anyOf")||e.hasOwnProperty("allOf")))return{isValid:!1,msg:"Schema of type '"+e.type+"' must have at least one of these keys: ['properties' or 'keys' or 'oneOf' or 'anyOf' or 'allOf']"};var t,a=e.properties||e.keys;if(a&&(t=function(e){if(!(e instanceof Object))return{isValid:!1,msg:"The 'keys' or 'properties' key must be a valid JavaScript Object"};for(var t in e)if(e.hasOwnProperty(t)){var a=e[t];if(!(a instanceof Object))return{isValid:!1,msg:"Key '"+t+"' must be a valid JavaScript Object"};var r={isValid:!0},n=k(a.type);if(n?"object"===n?r=Be(a):"array"===n&&(r=ze(a)):r=a.hasOwnProperty("$ref")?Ke(a):a.hasOwnProperty("oneOf")?We(a):a.hasOwnProperty("anyOf")?Ye(a):a.hasOwnProperty("allOf")?Ge(a):a.hasOwnProperty("const")?{isValid:!0,msg:""}:{isValid:!1,msg:"Key '"+t+"' must have a 'type' or a '$ref"},!r.isValid)return r}return{isValid:!0,msg:""}}(a),!t.isValid))return t;if(e.hasOwnProperty("additionalProperties")){if(!(e.additionalProperties instanceof Object)&&"boolean"!=typeof e.additionalProperties)return{isValid:!1,msg:"'additionalProperties' must be either a JavaScript boolean or a JavaScript object"};if(e.additionalProperties instanceof Object)if(e.additionalProperties.hasOwnProperty("$ref")){if(!(t=Ke(e.additionalProperties)).isValid)return t}else{var r=k(e.additionalProperties.type);if("object"===r)return Be(e.additionalProperties);if("array"===r)return Je(e.additionalProperties)}}return e.hasOwnProperty("oneOf")&&!(t=We(e)).isValid||e.hasOwnProperty("anyOf")&&!(t=Ye(e)).isValid||e.hasOwnProperty("allOf")&&!(t=Ge(e)).isValid?t:{isValid:!0,msg:""}}function ze(e){if(!e.hasOwnProperty("items"))return{isValid:!1,msg:"Schema of type '"+e.type+"' must have a key called 'items'"};if(!(e.items instanceof Object))return{isValid:!1,msg:"The 'items' key must be a valid JavaScript Object'"};var t=k(e.items.type);if(t){if("object"===t)return Be(e.items);if("array"===t)return ze(e.items)}else{if(e.items.hasOwnProperty("$ref"))return Ke(e.items);if(!(e.items.hasOwnProperty("oneOf")||e.items.hasOwnProperty("anyOf")||e.items.hasOwnProperty("allOf")||e.items.hasOwnProperty("const")))return{isValid:!1,msg:"Array 'items' must have a 'type' or '$ref' or 'oneOf' or 'anyOf'"}}return e.items.hasOwnProperty("oneOf")&&(validation=We(e.items),!validation.isValid)||e.items.hasOwnProperty("anyOf")&&(validation=Ye(e.items),!validation.isValid)?validation:e.items.hasOwnProperty("allOf")?{isValid:!1,msg:"Currently, 'allOf' inside array items is not supported"}:e.items.hasOwnProperty("const")&&(validation={isValid:!0,msg:""},!validation.isValid)?validation:{isValid:!0,msg:""}}function Ke(e){return"string"!=typeof e.$ref?{isValid:!1,msg:"'$ref' keyword must be a string"}:e.$ref.startsWith("#")?e.$ref.lenght>1&&!e.$ref.startsWith("#/")?{isValid:!1,msg:"Invalid '$ref' path"}:{isValid:!0,msg:""}:{isValid:!1,msg:"'$ref' value must begin with a hash (#) character"}}function We(e){return Xe(e,"oneOf")}function Ye(e){return Xe(e,"anyOf")}function Ge(e){var t=Xe(e,"allOf");if(!t.isValid)return t;for(var a=e.allOf,r=0;rparseInt(l)&&this.addError(a,"Maximum "+l+" items allowed."),S(e,"uniqueItems")&&("array"===n||"object"===n?t.length!==new Set(t.map(function(e){return JSON.stringify(e)})).size&&this.addError(a,"All items in this list must be unique."):t.length!==new Set(t).size&&this.addError(a,"All items in this list must be unique.")),o){var s=t.find(function(e){return-1===o.indexOf(e)});void 0!==s&&this.addError(a,'Invalid choice + "'+s+'"')}var u=this.getValidator(n);if(u||(r.hasOwnProperty("oneOf")?u=this.validateOneOf:r.hasOwnProperty("anyOf")?u=this.validateAnyOf:r.hasOwnProperty("anyOf")),u)for(var c=0;c-1&&!o.hasOwnProperty("required")&&(o.required=!0);var s=k(o.type),u=this.getValidator(s);if(!u)return void this.addError(a,'Unsupported type "'+s+'" for object properties (keys).');u(o,t[l],this.joinCoords([a,l]))}e.hasOwnProperty("allOf")&&this.validateAllOf(e,t,a)}}},this.validateAllOf=function(e,t,a){for(var r={type:"object",properties:{}},n=0;nparseInt(e.maxLength)&&this.addError(a,"This value may not be longer than "+e.maxLength+" characters."),C(e,t)){var r;switch(k(e.format)){case"email":r=this.validateEmail;break;case"date":r=this.validateDate;break;case"time":r=this.validateTime;break;case"date-time":r=this.validateDateTime}r&&r.call(this,e,t,a)}else this.addError(a,'Invalid choice "'+t+'"')}else this.addError(a,"This value is invalid. Must be a valid string.");else this.addError(a,"This field is required.")},this.validateBoolean=function(e,t,a){e.required&&null==t?this.addError(a,"This field is required."):"boolean"!=typeof t&&null!=t&&this.addError(a,"Invalid value.")},this.validateInteger=function(e,t,a){e.required&&null==t?this.addError(a,"This field is required."):null!==t&&("number"==typeof t&&t===parseInt(t)?this.validateNumber(e,t,a):this.addError(a,"Invalid value. Only integers allowed."))},this.validateNumber=function(e,t,a){e.required&&null==t?this.addError(a,"This field is required."):null!==t&&("number"==typeof t?((e.minimum||0===e.minimum)&&te.maximum&&this.addError(a,"This value must not be greater than "+e.maximum),(e.exclusiveMinimum||0===e.exclusiveMinimum)&&t<=e.exclusiveMinimum&&this.addError(a,"This value must be greater than "+e.exclusiveMinimum),(e.exclusiveMaximum||0===e.exclusiveMaximum)&&t>=e.exclusiveMaximum&&this.addError(a,"This value must be less than "+e.exclusiveMaximum),(e.multipleOf||0===e.multipleOf)&&100*t%(100*e.multipleOf)/100&&this.addError(a,"This value must be a multiple of "+e.multipleOf),C(e,t)||this.addError(a,'Invalid choice "'+t+'"')):this.addError(a,"Invalid value. Only numbers allowed."))},this.validateEmail=function(e,t,a){t.indexOf(" ")>-1?this.addError(a,"Enter a valid email address."):t.length>320&&this.addError(a,"Email may not be longer than 320 characters")},this.validateDate=function(e,t,a){},this.validateTime=function(e,t,a){},this.validateDateTime=function(e,t,a){}}function it(e){this.containerId=e.containerId,this.dataInputId=e.dataInputId,this.schema=e.schema,this.data=e.data,this.errorMap=e.errorMap,this.fileHandler=e.fileHandler,this.fileHandlerArgs=e.fileHandlerArgs||{},this.readonly=e.readonly||!1,this.eventListeners=null,this._dataSynced=!1,this.addEventListener=function(e,t){null===this.eventListeners&&(this.eventListeners={}),this.eventListeners.hasOwnProperty(e)||(this.eventListeners[e]=new Set),this.eventListeners[e].add(t)},this.onChange=function(e){this.data=e.data,this._dataSynced?this.eventListeners&&this.eventListeners.hasOwnProperty("change")&&this.eventListeners.change.size&&this.eventListeners.change.forEach(function(t){return t(e)}):this._dataSynced=!0},this.onChange=this.onChange.bind(this),this.render=function(){o.default.hasOwnProperty("createRoot")?this._renderReact18():this._renderReact17()},this._renderReact17=function(){try{o.default.render(this._getFormContainerComponent(),document.getElementById(this.containerId))}catch(e){o.default.render(/*#__PURE__*/i.default.createElement(st,{error:e}),document.getElementById(this.containerId))}},this._renderReact18=function(){var e=o.default.createRoot(document.getElementById(this.containerId));try{e.render(this._getFormContainerComponent())}catch(t){e.render(/*#__PURE__*/i.default.createElement(st,{error:t}))}},this._getFormContainerComponent=function(){/*#__PURE__*/return i.default.createElement(ot,{schema:this.schema,dataInputId:this.dataInputId,data:this.data,errorMap:this.errorMap,fileHandler:this.fileHandler,fileHandlerArgs:this.fileHandlerArgs,onChange:this.onChange,readonly:this.readonly})},this.update=function(e){this.schema=e.schema||this.schema,this.data=e.data||this.data,this.errorMap=e.errorMap||this.errorMap,this.render()},this.getSchema=function(){return this.schema},this.getData=function(){return this.data},this.validate=function(){return new nt(this.getSchema()).validate(this.getData())}}var lt={},ot=/*#__PURE__*/function(e){function t(t){var a;return(a=e.call(this,t)||this).populateDataInput=function(e){a.dataInput.value=JSON.stringify(e)},a.handleChange=function(e){a.setState({editorState:e})},a.state={editorState:Ze.create(t.schema,t.data)},a.prevEditorState=a.state.editorState,a.dataInput=document.getElementById(t.dataInputId),a}u(t,e);var a=t.prototype;return a.componentDidMount=function(){this.props.onChange({data:this.state.editorState.getData()}),this.populateDataInput(this.state.editorState.getData())},a.componentDidUpdate=function(e,t){if(this.props.schema===e.schema)this.props.data===e.data?(this.state.editorState!==t.editorState&&this.populateDataInput(this.state.editorState.getData()),this.props.onChange&&this.state.editorState!==t.editorState&&this.props.onChange({schema:this.state.editorState.getSchema(),data:this.state.editorState.getData(),prevSchema:t.editorState.getSchema(),prevData:t.editorState.getData()})):this.setState({editorState:Ze.update(this.state.editorState,this.props.data)});else{var a=this.props.schema,r=this.props.data!==e.data?this.props.data:this.state.editorState.getData();this.setState({editorState:Ze.create(a,r)})}},a.render=function(){/*#__PURE__*/return i.default.createElement(Qe,{editorState:this.state.editorState,onChange:this.handleChange,fileHandler:this.props.fileHandler,fileHandlerArgs:this.props.fileHandlerArgs,errorMap:this.props.errorMap,readonly:this.props.readonly})},t}(i.default.Component);function st(e){/*#__PURE__*/return i.default.createElement("div",{style:{color:"#f00"}},/*#__PURE__*/i.default.createElement("p",null,"(!) ",e.error.toString()),/*#__PURE__*/i.default.createElement("p",null,"Check browser console for more details about the error."))}e.DataValidator=nt,e.EditorState=Ze,e.ReactJSONForm=Qe,e.createForm=function(e){var t=new it(e);return lt[e.containerId]=t,t},e.getFormInstance=function(e){return lt[e]}}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-modal"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-modal","react-dom"],t):t((e||self).reactJsonForm={},e.React,e.ReactModal,e.ReactDOM)}(this,function(e,t,a,r){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/n(t),l=/*#__PURE__*/n(a),o=/*#__PURE__*/n(r);function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0||(n[a]=e[a]);return n}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,r=new Array(t);a=a)return e.default;var r=[];if(e.default&&(r=[].concat(e.default)),0===a)return r;e.items.hasOwnProperty("$ref")&&(e.items=s({},t(e.items.$ref),e.items),delete e.items.$ref);var n=k(e.items.type);if(n||(Array.isArray(e.items.oneOf)?n=E(e.items.oneOf[0]):Array.isArray(e.items.anyOf)?n=E(e.items.anyOf[0]):Array.isArray(e.items.allOf)?n=E(e.items.allOf[0]):e.items.hasOwnProperty("const")&&(n=y(e.items.const))),"array"===n){for(;r.length=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(e);!(a=r()).done;)if(!t.has(a.value))return!1;return!0}(keyset2,keyset1))return!1}else if(r=keyset2,n=keyset1,r.size!==n.size||!Array.from(r).every(function(e){return n.has(e)}))return!1;for(var l in i)if(i.hasOwnProperty(l)){if(!e.hasOwnProperty(l))return!1;if(i[l].hasOwnProperty("const")&&i[l].const!==e[l])return!1;var o=k(i[l].type),s=y(e[l]);if("number"===o&&-1===["number","integer","null"].indexOf(s))return!1;if("integer"===o&&-1===["number","integer","null"].indexOf(s))return!1;if("boolean"===o&&-1===["boolean","null"].indexOf(s))return!1;if("string"===o&&"string"!==s)return!1}return!0}function F(e,t){var a=y(e);if(E(t)!==a)return!1;for(var r=t.items.type,n=0;n12?1:"hh"!==e&&t>59?0:t},t.handleChange=function(e){var a,r=e.target.dataset.name,n=e.target.value;if(!isNaN(n)){var i=t.validateValue(r,parseInt(n)||0);"hh"!==r||"0"!==n&&""!==n&&"00"!==n||1!==i||(i=0),n.startsWith("0")&&i<10&&0!==i&&(i=i.toString().padStart(2,"0")),t.sendValue(((a={})[r]=""!==n?i.toString():"",a))}},t.handleKeyDown=function(e){var a;if(38===e.keyCode||40===e.keyCode){var r=e.target.dataset.name,n=parseInt(e.target.value)||0;38===e.keyCode?n++:40===e.keyCode&&n--,t.sendValue(((a={})[r]=t.validateValue(r,n).toString().padStart(2,"0"),a))}},t.handleSpin=function(e,a){var r,n=t.props[e];"ampm"===e?n="am"===n?"pm":"am":(n=parseInt(n)||0,"up"===a?n++:n--,n=t.validateValue(e,n).toString().padStart(2,"0")),t.sendValue(((r={})[e]=n,r))},t.handleBlur=function(e){var a,r=t.validateValue(e.target.dataset.name,parseInt(e.target.value)||0);r<10&&t.sendValue(((a={})[e.target.dataset.name]=r.toString().padStart(2,"0"),a))},t}u(t,e);var a=t.prototype;return a.componentWillUnmount=function(){var e={hh:this.validateValue("hh",this.props.hh).toString().padStart(2,"0"),mm:this.validateValue("mm",this.props.mm).toString().padStart(2,"0"),ss:this.validateValue("ss",this.props.ss).toString().padStart(2,"0")};this.sendValue(e)},a.render=function(){var e=this;/*#__PURE__*/return i.default.createElement("div",{className:"rjf-time-picker"},/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-row rjf-time-picker-labels"},/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},"Hrs"),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},"Min"),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},"Sec"),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},"am/pm")),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-row"},/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement(H,{onClick:function(){return e.handleSpin("hh","up")}},/*#__PURE__*/i.default.createElement(J,{name:"chevron-up"}))),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement(H,{onClick:function(){return e.handleSpin("mm","up")}},/*#__PURE__*/i.default.createElement(J,{name:"chevron-up"}))),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement(H,{onClick:function(){return e.handleSpin("ss","up")}},/*#__PURE__*/i.default.createElement(J,{name:"chevron-up"}))),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement(H,{onClick:function(){return e.handleSpin("ampm","up")}},/*#__PURE__*/i.default.createElement(J,{name:"chevron-up"})))),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-row rjf-time-picker-values"},/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement("input",{type:"text","data-name":"hh",value:this.props.hh,onChange:this.handleChange,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown})),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"},":"),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement("input",{type:"text","data-name":"mm",value:this.props.mm,onChange:this.handleChange,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown})),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"},":"),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement("input",{type:"text","data-name":"ss",value:this.props.ss,onChange:this.handleChange,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown})),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},this.props.ampm)),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-row"},/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement(H,{onClick:function(){return e.handleSpin("hh","down")}},/*#__PURE__*/i.default.createElement(J,{name:"chevron-down"}))),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement(H,{onClick:function(){return e.handleSpin("mm","down")}},/*#__PURE__*/i.default.createElement(J,{name:"chevron-down"}))),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement(H,{onClick:function(){return e.handleSpin("ss","down")}},/*#__PURE__*/i.default.createElement(J,{name:"chevron-down"}))),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col rjf-time-picker-col-sm"}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-time-picker-col"},/*#__PURE__*/i.default.createElement(H,{onClick:function(){return e.handleSpin("ampm","down")}},/*#__PURE__*/i.default.createElement(J,{name:"chevron-down"})))))},t}(i.default.Component),Q=["label","help_text","error","inputRef"],ee=["label","help_text","error","value"],te=["label","help_text","error","value","options"],ae=["label","help_text","error","value","options"],re=["label","value"],ne=["label","help_text","error","inputRef"];function ie(e){return e.label?/*#__PURE__*/i.default.createElement("label",{className:e.required?"rjf-required":null},e.children,e.children&&" ",e.label):null}function le(e){var t=e.label,a=e.help_text,r=e.error,n=e.inputRef,l=d(e,Q);"string"===l.type&&(l.type="text"),n&&(l.ref=n),null===l.value&&(l.value="");var o={};return"hidden"==l.type&&(o.style={display:"none"}),l.readOnly&&null==l.disabled&&(l.disabled=!0),/*#__PURE__*/i.default.createElement("div",o,/*#__PURE__*/i.default.createElement(ie,{label:t,required:l.required}),/*#__PURE__*/i.default.createElement("div",{className:r?"rjf-input-group has-error":"rjf-input-group"},l.children||/*#__PURE__*/i.default.createElement("input",l),r&&r.map(function(e,t){/*#__PURE__*/return i.default.createElement("span",{className:"rjf-error-text",key:t},e)}),a&&/*#__PURE__*/i.default.createElement("span",{className:"rjf-help-text"},a)))}function oe(e){var t=e.label,a=e.help_text,r=e.error,n=e.value,l=d(e,ee);return t||(t=l.name.toUpperCase()),"bool"===l.type&&(l.type="checkbox"),void 0===l.checked&&(l.checked=n),""!==l.checked&&null!=l.checked||(l.checked=!1),l.readOnly&&(l.disabled=!0),/*#__PURE__*/i.default.createElement("div",{className:r?"rjf-check-input has-error":"rjf-check-input"},/*#__PURE__*/i.default.createElement(ie,{label:t,required:l.required},/*#__PURE__*/i.default.createElement("input",l)),r&&r.map(function(e,t){/*#__PURE__*/return i.default.createElement("span",{className:"rjf-error-text",key:t},e)}),a&&/*#__PURE__*/i.default.createElement("span",{className:"rjf-help-text"},a))}function se(e){var t=e.label,a=e.help_text,r=e.error,n=e.value,l=e.options,o=d(e,te);return o.readOnly&&(o.disabled=!0),/*#__PURE__*/i.default.createElement("div",{className:r?"rjf-check-input has-error":"rjf-check-input"},/*#__PURE__*/i.default.createElement(ie,{label:t,required:o.required}),l.map(function(e,t){var a,r;return"object"==typeof e?(a=e.title||e.label,r=e.value):("boolean"==typeof(a=e)&&(a=v(a.toString())),r=e),/*#__PURE__*/i.default.createElement("label",{className:"rjf-radio-option",key:a+"_"+r+"_"+t},/*#__PURE__*/i.default.createElement("input",s({},o,{value:r,checked:r===n}))," ",a)}),r&&r.map(function(e,t){/*#__PURE__*/return i.default.createElement("span",{className:"rjf-error-text",key:t},e)}),a&&/*#__PURE__*/i.default.createElement("span",{className:"rjf-help-text"},a))}function ue(e){var t=e.label,a=e.help_text,r=e.error,n=e.value,l=e.options,o=d(e,ae);return o.readOnly&&(o.disabled=!0),n||!1===n||0===n||(n=""),/*#__PURE__*/i.default.createElement("div",null,/*#__PURE__*/i.default.createElement(ie,{label:t,required:o.required}),/*#__PURE__*/i.default.createElement("div",{className:r?"rjf-input-group has-error":"rjf-input-group"},/*#__PURE__*/i.default.createElement("select",s({value:n},o),/*#__PURE__*/i.default.createElement("option",{disabled:!0,value:"",key:"__placeholder"},"Select..."),l.map(function(e,t){var a,r;return"object"==typeof e?(a=e.title||e.label,r=e.value):("boolean"==typeof(a=e)&&(a=v(a.toString())),r=e),/*#__PURE__*/i.default.createElement("option",{value:r,key:a+"_"+r+"_"+t},a)})),r&&r.map(function(e,t){/*#__PURE__*/return i.default.createElement("span",{className:"rjf-error-text",key:t},e)}),a&&/*#__PURE__*/i.default.createElement("span",{className:"rjf-help-text"},a)))}var ce=/*#__PURE__*/function(e){function t(t){var a;return(a=e.call(this,t)||this).handleChange=function(e){var t=[].concat(a.props.value),r=e.target.value;typeof r!==a.props.valueType&&(r=g(r,a.props.valueType)),e.target.checked?t.push(r):t=t.filter(function(e){return e!==r}),a.props.onChange({target:{type:a.props.type,value:t,name:a.props.name}})},a.showOptions=function(e){a.state.showOptions||a.setState({showOptions:!0})},a.hideOptions=function(e){a.setState({showOptions:!1})},a.toggleOptions=function(e){a.setState(function(e){return{showOptions:!e.showOptions}})},a.state={showOptions:!1},a.optionsContainer=/*#__PURE__*/i.default.createRef(),a.input=/*#__PURE__*/i.default.createRef(),a}return u(t,e),t.prototype.render=function(){/*#__PURE__*/return i.default.createElement("div",{className:this.props.readOnly?"rjf-multiselect-field readonly":"rjf-multiselect-field"},/*#__PURE__*/i.default.createElement(le,{label:this.props.label,help_text:this.props.help_text,error:this.props.error},/*#__PURE__*/i.default.createElement(de,{inputRef:this.input,onClick:this.toggleOptions,value:this.props.value,options:this.props.options,onChange:this.handleChange,disabled:this.props.readOnly,placeholder:this.props.placeholder})),this.state.showOptions&&/*#__PURE__*/i.default.createElement(pe,{options:this.props.options,value:this.props.value,hideOptions:this.hideOptions,onChange:this.handleChange,containerRef:this.optionsContainer,inputRef:this.input,disabled:this.props.readOnly,hasHelpText:(this.props.help_text||this.props.error)&&1}))},t}(i.default.Component),de=/*#__PURE__*/function(e){function t(){for(var t,a=arguments.length,r=new Array(a),n=0;n-1,o="rjf-multiselect-field-option";return l&&(o+=" selected"),e.props.disabled&&(o+=" disabled"),/*#__PURE__*/i.default.createElement("div",{key:r+"_"+n+"_"+a,className:o},/*#__PURE__*/i.default.createElement("label",null,/*#__PURE__*/i.default.createElement("input",{type:"checkbox",onChange:e.props.onChange,value:n,checked:l,disabled:e.props.disabled})," ",r))})))},t}(i.default.Component),fe=/*#__PURE__*/function(e){function t(t){var a;return(a=e.call(this,t)||this).getFileName=function(){return a.props.value?"data-url"===a.props.type?a.extractFileInfo(a.props.value).name:"file-url"===a.props.type?a.props.value:"Unknown file":""},a.extractFileInfo=function(e){var t=function(e){var t,a=e.split(","),r=a[0].split(";"),n=r[0].replace("data:",""),i=r.filter(function(e){return"name"===e.split("=")[0]});t=1!==i.length?"unknown":i[0].split("=")[1];for(var l=atob(a[1]),o=[],s=0;s12&&(t-=12,l="pm"),r=o.getMinutes(),n=o.getSeconds(),i=o.getMilliseconds(),t=t.toString().padStart(2,"0"),r=r.toString().padStart(2,"0"),n=n.toString().padStart(2,"0")}return{date:e,hh:t,mm:r,ss:n,ms:i,ampm:l}},a.handleClickOutside=function(e){a.state.showTimePicker&&(!a.timePickerContainer.current||a.timePickerContainer.current.contains(e.target)||a.timeInput.current.contains(e.target)||a.setState({showTimePicker:!1}))},a.sendValue=function(){var e={target:{type:"text",value:"",name:a.props.name}};if(""===a.state.date||null===a.state.date)return a.props.onChange(e);var t=parseInt(a.state.hh);0===t&&(t=NaN),"am"===a.state.ampm?12===t&&(t=0):"pm"===a.state.ampm&&12!==t&&(t+=12),t=t.toString().padStart(2,"0");var r=a.state.mm.padStart(2,"0"),n=a.state.ss.padStart(2,"0");try{var i=new Date(a.state.date+"T"+t+":"+r+":"+n+"."+a.state.ms);e.target.value=i.toISOString().replace("Z","+00:00")}catch(t){return a.props.onChange(e)}a.props.onChange(e)},a.handleDateChange=function(e){a.setState({date:e.target.value},a.sendValue)},a.handleTimeChange=function(e){a.setState(s({},e),a.sendValue)},a.showTimePicker=function(){a.setState({showTimePicker:!a.props.readOnly&&!0})},a.state=s({},a.getStateFromProps(),{showTimePicker:!1}),a.timeInput=/*#__PURE__*/i.default.createRef(),a.timePickerContainer=/*#__PURE__*/i.default.createRef(),a}u(t,e);var a=t.prototype;return a.componentDidUpdate=function(e,t){if(e.value!==this.props.value&&""!==this.state.hh&&"0"!==this.state.hh&&"00"!==this.state.hh){var a=!1,r=this.getStateFromProps();for(var n in r)if(r[n]!==this.state[n]){a=!0;break}a&&this.setState(s({},r))}},a.componentDidMount=function(){document.addEventListener("mousedown",this.handleClickOutside)},a.componentWillUnmount=function(){document.removeEventListener("mousedown",this.handleClickOutside)},a.render=function(){/*#__PURE__*/return i.default.createElement("div",{className:this.props.error?"rjf-datetime-field has-error":"rjf-datetime-field"},/*#__PURE__*/i.default.createElement(ie,{label:this.props.label,required:this.props.required}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-datetime-field-inner"},/*#__PURE__*/i.default.createElement("div",{className:this.props.readOnly?"rjf-datetime-field-inputs readonly":"rjf-datetime-field-inputs"},/*#__PURE__*/i.default.createElement("div",{className:"rjf-datetime-field-date"},/*#__PURE__*/i.default.createElement(le,{label:"Date",type:"date",value:this.state.date,onChange:this.handleDateChange,readOnly:this.props.readOnly})),/*#__PURE__*/i.default.createElement("div",{className:"rjf-datetime-field-time"},/*#__PURE__*/i.default.createElement(le,{label:"Time",type:"text",value:this.state.hh+":"+this.state.mm+":"+this.state.ss+" "+this.state.ampm,onFocus:this.showTimePicker,readOnly:!0,disabled:this.props.readOnly||!1,inputRef:this.timeInput}),/*#__PURE__*/i.default.createElement("div",{ref:this.timePickerContainer},this.state.showTimePicker&&/*#__PURE__*/i.default.createElement(Z,{onChange:this.handleTimeChange,hh:this.state.hh,mm:this.state.mm,ss:this.state.ss,ampm:this.state.ampm})))),this.props.error&&this.props.error.map(function(e,t){/*#__PURE__*/return i.default.createElement("span",{className:"rjf-error-text",key:t},e)}),this.props.help_text&&/*#__PURE__*/i.default.createElement("span",{className:"rjf-help-text"},this.props.help_text)))},t}(i.default.Component);function ve(e){/*#__PURE__*/return i.default.createElement("div",{className:e.label?"rjf-url-field has-label":"rjf-url-field"},/*#__PURE__*/i.default.createElement(le,s({},e,{type:"url",className:"rjf-url-field-input"})),e.value&&/*#__PURE__*/i.default.createElement("a",{href:e.value,target:"_blank",rel:"noopener noreferrer",className:"rjf-url-field-link",title:"Open in new tab"},/*#__PURE__*/i.default.createElement(J,{name:"box-arrow-up-right"})," ",/*#__PURE__*/i.default.createElement("span",null,"Open link")))}var ge=/*#__PURE__*/function(e){function t(t){var a,r,n;return(a=e.call(this,t)||this).handleSelect=function(e){a.props.multiselect&&(e=Array.isArray(a.props.value)?a.props.value.concat([e]):[e]);var t={target:{type:a.props.type,value:e,name:a.props.name}};a.props.multiselect||a.hideOptions(),a.props.onChange(t)},a.handleMultiselectRemove=function(e){var t=a.props.value.filter(function(t){return t!==e});a.props.onChange({target:{type:a.props.type,value:t,name:a.props.name}})},a.clearValue=function(e){a.handleSelect(a.defaultEmptyValue)},a.hasValue=function(){return!(Array.isArray(a.props.value)&&!a.props.value.length)&&""!==a.props.value&&null!==a.props.value},a.handleSearchInputChange=function(e){var t=e.target.value;t?a.setState({searchInputValue:t,loading:!0},a.debouncedFetchOptions):a.setState({searchInputValue:t,loading:!1,options:[]})},a.fetchOptions=function(){if(""!==a.state.searchInputValue){var e=a.props.handler;if(!e)return console.error("Error: No 'handler' endpoint provided for autocomplete input."),void a.setState({loading:!1});var t=e+"?"+new URLSearchParams({field_name:a.context.fieldName,model_name:a.context.modelName,coords:j(a.props.name),query:a.state.searchInputValue});fetch(t,{method:"GET"}).then(function(e){return e.json()}).then(function(e){Array.isArray(e.results)||(e.results=[]),a.setState(function(t){return{loading:!1,options:[].concat(e.results)}})}).catch(function(e){alert("Something went wrong while fetching options"),console.error("Error:",e),a.setState({loading:!1})})}},a.showOptions=function(e){a.state.showOptions||a.setState({showOptions:!0})},a.hideOptions=function(e){a.setState({showOptions:!1,searchInputValue:"",options:[],loading:!1})},a.toggleOptions=function(e){a.setState(function(e){return e.showOptions?{showOptions:!1,searchInputValue:"",options:[],loading:!1}:{showOptions:!0}})},a.state={searchInputValue:"",showOptions:!1,options:[],loading:!1},a.optionsContainer=/*#__PURE__*/i.default.createRef(),a.searchInputRef=/*#__PURE__*/i.default.createRef(),a.input=/*#__PURE__*/i.default.createRef(),a.debouncedFetchOptions=(r=a.fetchOptions,function(){clearTimeout(n);var e=arguments,t=this;n=setTimeout(function(){r.apply(t,e)},500)}),a.defaultEmptyValue=t.multiselect?[]:"",a}u(t,e);var a=t.prototype;return a.componentDidUpdate=function(e,t){this.state.showOptions&&this.state.showOptions!==t.showOptions&&this.searchInputRef.current&&this.searchInputRef.current.focus()},a.render=function(){var e=this;/*#__PURE__*/return i.default.createElement("div",{className:this.props.label?"rjf-autocomplete-field has-label":"rjf-autocomplete-field"},this.props.multiselect?/*#__PURE__*/i.default.createElement(le,{label:this.props.label,help_text:this.props.help_text,error:this.props.error},/*#__PURE__*/i.default.createElement(de,{inputRef:this.input,onClick:this.toggleOptions,onChange:function(t){return e.handleMultiselectRemove(t.target.value)},value:this.props.value,placeholder:this.props.placeholder||" ",disabled:this.props.readOnly||!1})):/*#__PURE__*/i.default.createElement(i.default.Fragment,null,/*#__PURE__*/i.default.createElement(le,{label:this.props.label,type:"text",value:this.props.value,help_text:this.props.help_text,error:this.props.error,readOnly:!0,disabled:this.props.readOnly||!1,onClick:this.toggleOptions,inputRef:this.input,placeholder:this.props.placeholder,name:this.props.name,className:"rjf-autocomplete-field-input"}),this.hasValue()&&!this.props.readOnly&&/*#__PURE__*/i.default.createElement(H,{className:"autocomplete-field-clear",title:"Clear",onClick:this.clearValue},/*#__PURE__*/i.default.createElement(J,{name:"x-circle"})," ",/*#__PURE__*/i.default.createElement("span",null,"Clear"))),this.state.showOptions&&!this.props.readOnly&&/*#__PURE__*/i.default.createElement(ye,{options:this.state.options,value:this.props.value,hideOptions:this.hideOptions,onSelect:this.handleSelect,onSearchInputChange:this.handleSearchInputChange,searchInputValue:this.state.searchInputValue,containerRef:this.optionsContainer,searchInputRef:this.searchInputRef,inputRef:this.input,loading:this.state.loading,hasHelpText:(this.props.help_text||this.props.error)&&1,multiselect:this.props.multiselect}))},t}(i.default.Component);ge.contextType=h;var ye=/*#__PURE__*/function(e){function t(){for(var t,a=arguments.length,r=new Array(a),n=0;n-1:e.value===n)&&(o+=" selected"),/*#__PURE__*/i.default.createElement("div",{key:r+"_"+n+"_"+a,className:o,tabIndex:0,role:"button",onClick:function(){return e.multiselect&&l?null:e.onSelect(n)}},r)}))}function Oe(e){return e.children?/*#__PURE__*/i.default.createElement("div",{className:"rjf-form-group-title"},e.children,e.editable&&/*#__PURE__*/i.default.createElement(i.default.Fragment,null," ",/*#__PURE__*/i.default.createElement(H,{className:"edit",onClick:e.onEdit,title:"Edit"},"Edit")),e.collapsible&&/*#__PURE__*/i.default.createElement(i.default.Fragment,null," ",/*#__PURE__*/i.default.createElement(H,{className:"collapse",onClick:e.onCollapse,title:e.collapsed?"Expand":"Collapse"},e.collapsed?"[+]":"[-]"))):null}function we(e){return e.children?/*#__PURE__*/i.default.createElement("div",{className:"rjf-form-group-description"},e.children):null}function je(e,t,a){var r=e.target.parentElement.parentElement,n=r.previousElementSibling,i=r.nextElementSibling;if(r.classList.add("rjf-animate","rjf-"+t),"move-up"===t){var l=n.getBoundingClientRect().y,o=l,s=l=r.getBoundingClientRect().y;n.classList.add("rjf-animate"),n.style.opacity=0,n.style.transform="translateY("+(s-o)+"px)",r.style.opacity=0,r.style.transform="translateY(-"+(s-o)+"px)"}else if("move-down"===t){var u=r.getBoundingClientRect().y,c=u,d=u=i.getBoundingClientRect().y;i.classList.add("rjf-animate"),i.style.opacity=0,i.style.transform="translateY(-"+(d-c)+"px)",r.style.opacity=0,r.style.transform="translateY("+(d-c)+"px)"}setTimeout(function(){a(),r.classList.remove("rjf-animate","rjf-"+t),r.style=null,"move-up"===t?(n.classList.remove("rjf-animate"),n.style=null):"move-down"===t&&(i.classList.remove("rjf-animate"),i.style=null)},200)}function ke(e){/*#__PURE__*/return i.default.createElement("div",{className:"rjf-form-row-controls"},e.onMoveUp&&/*#__PURE__*/i.default.createElement(H,{className:"move-up",onClick:function(t){return je(t,"move-up",e.onMoveUp)},title:"Move up"},/*#__PURE__*/i.default.createElement("span",null,"↑")),e.onMoveDown&&/*#__PURE__*/i.default.createElement(H,{className:"move-down",onClick:function(t){return je(t,"move-down",e.onMoveDown)},title:"Move down"},/*#__PURE__*/i.default.createElement("span",null,"↓")),e.onRemove&&/*#__PURE__*/i.default.createElement(H,{className:"remove",onClick:function(t){return je(t,"remove",e.onRemove)},title:"Remove"},/*#__PURE__*/i.default.createElement("span",null,"×")))}function Ne(e){var t="rjf-form-row";return e.hidden&&(t+=" rjf-form-row-hidden"),/*#__PURE__*/i.default.createElement("div",{className:t},/*#__PURE__*/i.default.createElement(ke,e),/*#__PURE__*/i.default.createElement("div",{className:"rjf-form-row-inner"},e.children))}function Se(e){var t=i.default.useState(!1),a=t[0],r=t[1],n=E(e.schema);i.default.Children.count(e.children);var l,o,s=0===e.level&&"groups"===e.childrenType?"":"rjf-form-group-inner";return"object"===n?(l="Add key",o="Add new key"):(l="Add item",o="Add new item"),/*#__PURE__*/i.default.createElement("div",{className:"rjf-form-group"},0===e.level&&/*#__PURE__*/i.default.createElement(Oe,{editable:e.editable,onEdit:e.onEdit,collapsible:e.collapsible,onCollapse:function(){return r(!a)},collapsed:a},e.schema.title),0===e.level&&/*#__PURE__*/i.default.createElement(we,null,e.schema.description),/*#__PURE__*/i.default.createElement("div",{className:s},e.level>0&&/*#__PURE__*/i.default.createElement(Oe,{editable:e.editable,onEdit:e.onEdit,collapsible:e.collapsible,onCollapse:function(){return r(!a)},collapsed:a},e.schema.title),e.level>0&&/*#__PURE__*/i.default.createElement(we,null,e.schema.description),a&&/*#__PURE__*/i.default.createElement("div",{className:"rjf-collapsed-indicator"},/*#__PURE__*/i.default.createElement("span",null,"Collapsed")),/*#__PURE__*/i.default.createElement("div",{className:a?"rjf-form-group-children rjf-collapsed":"rjf-form-group-children"},e.children),!a&&e.addable&&/*#__PURE__*/i.default.createElement(H,{className:"add",onClick:function(t){return e.onAdd()},title:o},l)))}var Ce=/*#__PURE__*/function(e){function t(t){var a;return(a=e.call(this,t)||this).openModal=function(e){a.setState({open:!0})},a.closeModal=function(e){a.setState({open:!1,pane:"upload"})},a.togglePane=function(e){a.setState({pane:e})},a.handleFileSelect=function(e){a.props.onChange({target:{type:"text",value:e,name:a.props.name}}),a.closeModal()},a.handleFileUpload=function(e){a.newFiles.push(e.target.value),a.addExitEventListeners(),a.props.onChange(e),a.closeModal()},a.addExitEventListeners=function(){a.exitListenersAdded||a.hiddenInputRef.current&&a.hiddenInputRef.current.form&&(window.addEventListener("beforeunload",a.promptOnExit),window.addEventListener("unload",a.sendDeleteRequestOnExit),a.hiddenInputRef.current.form.addEventListener("submit",function(e){window.removeEventListener("beforeunload",a.promptOnExit),window.removeEventListener("unload",a.sendDeleteRequestOnExit)}),a.exitListenersAdded=!0)},a.promptOnExit=function(e){a.newFiles.length&&(e.preventDefault(),e.returnValue="")},a.sendDeleteRequestOnExit=function(e){a.newFiles.length&&a.sendDeleteRequest([a.newFiles],"unsaved_form_page_exit",!0)},a.clearFile=function(){window.confirm("Do you want to remove this file?")&&a.props.onChange({target:{type:"text",value:"",name:a.props.name}})},a.sendDeleteRequest=function(e,t,r){for(var n=a.props.handler||a.context.fileHandler,i=new URLSearchParams(s({},a.context.fileHandlerArgs,{coords:j(a.props.name),trigger:t})),l=0;l0?t.page+1:t.page,hasMore:e.results.length>0}})}).catch(function(e){alert("Something went wrong while retrieving media files"),console.error("Error:",e),a.setState({loading:!1})})},a.onLoadMore=function(e){a.setState({loading:!0},a.fetchList)},a.onFileDelete=function(){a.setState({page:0,files:[]},a.onLoadMore)},a.state={loading:!0,files:[],page:0,hasMore:!0},a}u(t,e);var a=t.prototype;return a.componentDidMount=function(){this.fetchList()},a.render=function(){var e=this;/*#__PURE__*/return i.default.createElement("div",{className:"rjf-upload-modal__pane"},/*#__PURE__*/i.default.createElement("h3",null,"Media library"),/*#__PURE__*/i.default.createElement("div",{className:"rjf-upload-modal__media-container"},this.state.files.map(function(t){/*#__PURE__*/return i.default.createElement(Re,s({},t,{onClick:e.props.onFileSelect,sendDeleteRequest:e.props.sendDeleteRequest,onFileDelete:e.onFileDelete}))})),this.state.loading&&/*#__PURE__*/i.default.createElement(U,{className:"rjf-upload-modal__media-loader"}),!this.state.loading&&this.state.hasMore&&/*#__PURE__*/i.default.createElement("div",null,/*#__PURE__*/i.default.createElement(H,{onClick:this.onLoadMore,className:"upload-modal__media-load"},/*#__PURE__*/i.default.createElement(J,{name:"arrow-down"})," View more")),!this.state.hasMore&&/*#__PURE__*/i.default.createElement("div",{className:"rjf-upload-modal__media-end-message"},this.state.files.length?"End of list":"No files found"))},t}(i.default.Component);function Re(e){var t=e.metadata||{};/*#__PURE__*/return i.default.createElement("div",{className:"rjf-upload-modal__media-tile"},/*#__PURE__*/i.default.createElement(_e,{value:e.value,sendDeleteRequest:e.sendDeleteRequest,onFileDelete:e.onFileDelete}),/*#__PURE__*/i.default.createElement("div",{className:"rjf-upload-modal__media-tile-inner",tabIndex:"0",onClick:function(){return e.onClick(e.value)}},/*#__PURE__*/i.default.createElement("img",{src:e.thumbnail?e.thumbnail:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23999999' viewBox='0 0 16 16'%3E%3Cpath d='M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5L14 4.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5h-2z'/%3E%3C/svg%3E"}),e.metadata&&/*#__PURE__*/i.default.createElement("div",{className:"rjf-upload-modal__media-tile-metadata"},Object.getOwnPropertyNames(t).map(function(e){/*#__PURE__*/return i.default.createElement("span",null,t[e])}))))}var _e=/*#__PURE__*/function(e){function t(t){var a;return(a=e.call(this,t)||this).toggleMenu=function(e){a.setState(function(e){return{open:!e.open}})},a.handleDeleteClick=function(e){window.confirm("Do you want to delete this file?")&&(a.setState({loading:!0}),a.props.sendDeleteRequest([a.props.value],"delete_button").then(function(e){var t,r=e.status;200===r||(400===r?t="Bad request":401===r||403===r?t="You don't have permission to delete this file":404===r?t="This file does not exist on server":405===r?t="This operation is not permitted":r>405&&(t="Something went wrong while deleting file")),a.setState({loading:!1,open:!1}),t?alert(t):a.props.onFileDelete()}).catch(function(e){alert("Something went wrong while deleting file"),console.error("Error:",e),a.setState({loading:!1})}))},a.state={open:!1,loading:!1},a}return u(t,e),t.prototype.render=function(){/*#__PURE__*/return i.default.createElement("div",{className:this.state.open?"rjf-dropdown open":"rjf-dropdown"},/*#__PURE__*/i.default.createElement(H,{className:"rjf-dropdown-toggler",alterClassName:!1,title:this.state.open?"Close menu":"Open menu",onClick:this.toggleMenu},/*#__PURE__*/i.default.createElement(J,{name:this.state.open?"x-lg":"three-dots-vertical"})),this.state.open&&/*#__PURE__*/i.default.createElement("div",{className:"rjf-dropdown-items"},/*#__PURE__*/i.default.createElement(H,{className:"rjf-dropdown-item rjf-text-danger",alterClassName:!1,onClick:this.handleDeleteClick},this.state.loading&&/*#__PURE__*/i.default.createElement(U,null),this.state.loading?" Deleting...":"Delete")))},t}(i.default.Component),Me=["data","schema","name","onChange","onRemove","removable","onEdit","onKeyEdit","editable","onMoveUp","onMoveDown","parentType","errorMap"];function Ie(e){var t,a={name:e.name,value:e.data,readOnly:N(e.schema,"readOnly","readonly"),help_text:N(e.schema,"help_text","helpText"),error:e.errorMap[j(e.name)],required:e.schema.required||!1};"string"==typeof a.error&&(a.error=[a.error]),e.schema.placeholder&&(a.placeholder=e.schema.placeholder),e.schema.handler&&(a.handler=e.schema.handler),e.schema.hasOwnProperty("const")?(t=y(e.schema.const),a.readOnly=!0):t=k(e.schema.type);var r,n=N(e.schema,"choices","enum");switch(n&&(a.options=n,t="select"),e.schema.widget&&("multiselect"===e.schema.widget&&"array"!==e.parentType||(t="hidden"===e.schema.widget?"string":e.schema.widget)),t){case"string":if(r=le,e.schema.format){var l=e.schema.format;"data-url"===l?r=fe:"file-url"===l?r=Ce:"date-time"===k(l)?r=he:"uri"!==l&&"uri-reference"!==l||(r=ve),a.type=l}else a.type="hidden"===e.schema.widget?"hidden":"text";(e.schema.minLength||0===e.schema.minLength)&&(a.minLength=e.schema.minLength),(e.schema.maxLength||0===e.schema.maxLength)&&(a.maxLength=e.schema.maxLength);break;case"fileinput":r=fe,e.schema.format&&(a.type=e.schema.format);break;case"range":case"integer":a.step="1";case"number":a.type="range"===t?"range":"number",a.step="any",r=le,(e.schema.minimum||0===e.schema.minimum)&&(a.min=e.schema.minimum),(e.schema.maximum||0===e.schema.maximum)&&(a.max=e.schema.maximum);break;case"boolean":case"checkbox":a.type="checkbox",r=oe;break;case"radio":a.type="radio",r=se;break;case"select":r=ue;break;case"multiselect":a.valueType=e.schema.type,r=ce;break;case"autocomplete":r=ge;break;case"multiselect-autocomplete":r=ge,a.multiselect=!0;break;case"textarea":r=me,(e.schema.minLength||0===e.schema.minLength)&&(a.minLength=e.schema.minLength),(e.schema.maxLength||0===e.schema.maxLength)&&(a.maxLength=e.schema.maxLength);break;default:a.type="text",r=le}/*#__PURE__*/return i.default.createElement(r,s({},a,{label:e.editable?/*#__PURE__*/i.default.createElement("span",null,e.schema.title," ",/*#__PURE__*/i.default.createElement(H,{className:"edit",onClick:e.onEdit,title:"Edit"},"Edit")):e.schema.title,onChange:function(t){return function(e,t,a){var r;r="checkbox"===e.target.type?e.target.checked:e.target.value,r=Array.isArray(r)?r.map(function(e){return g(e,t)}):g(r,t),a(e.target.name,r)}(t,e.schema.type,e.onChange)}}))}function Ve(e){var t=e.data,a=e.schema,r=e.name,n=e.onChange,l=e.onRemove,o=e.removable,u=e.onKeyEdit,c=e.editable,p=e.onMoveUp,f=e.onMoveDown,m=e.parentType,h=e.errorMap,v=d(e,Me);/*#__PURE__*/return i.default.createElement(Ne,{key:r,onRemove:o?function(e){return l(r)}:null,onMoveUp:p,onMoveDown:f,hidden:"hidden"===a.widget},/*#__PURE__*/i.default.createElement(Ie,s({data:t,schema:a,name:r,onChange:n,onEdit:u,editable:c,parentType:m,errorMap:h},v)))}function De(e){var t=e.data,a=e.schema,r=e.name,n=e.onChange,l=e.onAdd,o=e.onRemove,u=e.onMove,c=e.onEdit,d=e.level,p=[],f=[],m=N(a,"readonly","readOnly",!1),h=!0,v=N(a,"min_items","minItems")||0;(t.length<=v||m)&&(h=!1);var g=!0,y=N(a,"max_items","maxItems")||100;(t.length>=y||m)&&(g=!1),a.items.hasOwnProperty("$ref")&&(a.items=s({},e.getRef(a.items.$ref),a.items),delete a.items.$ref);var E=k(a.items.type),b={schema:a.items,onChange:n,onAdd:l,onRemove:o,level:d+1,removable:h,onMove:u,onEdit:c,onKeyEdit:e.onKeyEdit,parentType:"array",getRef:e.getRef,errorMap:e.errorMap};if(m&&(b.schema.readOnly=!0),"multiselect"===b.schema.widget||"multiselect-autocomplete"===b.schema.widget)b.data=t,b.name=r,b.removable=!1,b.onMoveUp=null,b.onMoveDown=null,g=!1,p.push(Ve(b));else for(var w=function(n){b.data=t[n],b.name=O(r,n),b.onMoveUp=0===n||m?null:function(e){return u(O(r,n),O(r,n-1))},b.onMoveDown=n===t.length-1||m?null:function(e){return u(O(r,n),O(r,n+1))},"array"===E?f.push(De(b)):"object"===E?f.push(Le(b)):a.items.hasOwnProperty("oneOf")?f.push(/*#__PURE__*/i.default.createElement(He,{parentArgs:e,nextArgs:s({},b),key:"oneOf_"+r+"_"+n})):a.items.hasOwnProperty("anyOf")?f.push(/*#__PURE__*/i.default.createElement(Ue,{parentArgs:e,nextArgs:s({},b),key:"anyOf_"+r+"_"+n})):p.push(Ve(b))},S=0;S0,childrenType:"rows"},C&&C.map(function(e,t){/*#__PURE__*/return i.default.createElement("div",{className:"rjf-error-text",key:t},e)}),p),"object"===e.parentType&&e.removable&&(p=/*#__PURE__*/i.default.createElement("div",{className:"rjf-form-group-wrapper",key:"row_group_wrapper_"+r},/*#__PURE__*/i.default.createElement(ke,{onRemove:function(e){return o(r)}}),p))),f.length){var A=e.errorMap[j(x)];"string"==typeof A&&(A=[A]),f=/*#__PURE__*/i.default.createElement("div",{key:"group_"+r,className:"rjf-form-group-wrapper"},"object"===e.parentType&&e.removable&&/*#__PURE__*/i.default.createElement(ke,{onRemove:function(e){return o(r)}}),/*#__PURE__*/i.default.createElement(Se,{level:d,schema:a,addable:g,onAdd:function(){return l(R(a.items,e.getRef),x)},editable:e.editable,onEdit:e.onKeyEdit,collapsible:t.length>0,childrenType:"groups"},A&&A.map(function(e,t){/*#__PURE__*/return i.default.createElement("div",{className:"rjf-error-text",key:t},e)}),f.map(function(e,t){/*#__PURE__*/return i.default.createElement("div",{className:"rjf-form-group-wrapper",key:"group_wrapper_"+r+"_"+t},/*#__PURE__*/i.default.createElement(ke,{onRemove:h?function(e){return o(O(r,t))}:null,onMoveUp:t>0&&!m?function(e){return u(O(r,t),O(r,t-1))}:null,onMoveDown:t-1&&(j.required=!0);var x={data:E,schema:j,name:b,onChange:n,onAdd:l,onRemove:o,level:d+1,removable:C,onMove:u,onEdit:c,parentType:"object",getRef:e.getRef,errorMap:e.errorMap,onKeyEdit:function(){return function(e,t,a,r,n){var i=prompt("Rename key",t);if(null!==i&&(i=i.trim())!==t){if(!i)return alert("(!) Key name can't be empty.\r\n\r\n‎");if(e.hasOwnProperty(i))return alert("(!) Duplicate keys not allowed. This key already exists.\r\n\r\n‎");var l=w(r);l.pop(),l.push(i),n(a,l=O.apply(null,l),r)}}(t,y,E,b,c)}};x.editable=C,"array"===S?p.push(De(x)):"object"===S?p.push(Le(x)):x.schema.hasOwnProperty("oneOf")?p.push(/*#__PURE__*/i.default.createElement(He,{parentArgs:e,nextArgs:s({},x),key:"oneOf_"+r+"_"+h})):x.schema.hasOwnProperty("anyOf")?p.push(/*#__PURE__*/i.default.createElement(Ue,{parentArgs:e,nextArgs:s({},x),key:"anyOf_"+r+"_"+h})):p.push(Ve(x))},E=0;E0,childrenType:"rows"},S&&S.map(function(e,t){/*#__PURE__*/return i.default.createElement("div",{className:"rjf-error-text",key:t},e)}),p),"object"===e.parentType&&e.removable&&(p=/*#__PURE__*/i.default.createElement("div",{className:"rjf-form-group-wrapper",key:"row_group_wrapper_"+r},/*#__PURE__*/i.default.createElement(ke,{onRemove:function(e){return o(r)}}),p))}return p}function Te(e){/*#__PURE__*/return i.default.createElement(qe,{args:e})}function $e(e){/*#__PURE__*/return i.default.createElement(qe,{args:e,schemaName:"anyOf"})}function Fe(e){return Le(e)}var qe=/*#__PURE__*/function(e){function t(t){var a;return(a=e.call(this,t)||this).findSelectedOption=function(){return y(a.props.args.data),T(a.props.args.data,a.props.args.schema,a.props.args.getRef,a.schemaName)},a.getOptions=function(){return Array.from(a.props.args.schema[a.schemaName].keys(),function(e){return{label:a.getSchema(e).title||"Option "+(e+1),value:e}})},a.getSchema=function(e){void 0===e&&(e=a.state.option);var t=a.props.args.schema[a.schemaName][e];return t.hasOwnProperty("$ref")&&delete(t=s({},a.props.args.getRef(t.$ref),{schema:t})).$ref,t},a.handleOptionChange=function(e){a.updateData(a.getSchema(e.target.value))},a.schemaName=a.props.schemaName||"oneOf",a}u(t,e);var a=t.prototype;return a.updateData=function(e){this.props.args.onChange(this.props.args.name,R(e,this.props.args.getRef))},a.render=function(){var e,t=this.findSelectedOption(),a=this.getSchema(t),r=E(a),n=this.props.args;"object"===r?e=Le:"array"===r?e=De:(e=Ve,n.removable=!1,n.onMoveUp=null,n.onMoveDown=null,(Array.isArray(n.data)||"object"==typeof n.data)&&(n.data=null));var l=e(s({},n,{schema:a})),o=this.props.args.schema.title||null;/*#__PURE__*/return i.default.createElement("div",{className:"rjf-form-group rjf-oneof-group rjf-oneof-group-top-level"},/*#__PURE__*/i.default.createElement("div",{className:"rjf-oneof-selector"},/*#__PURE__*/i.default.createElement(ue,{value:t,options:this.getOptions(),onChange:this.handleOptionChange,className:"rjf-oneof-selector-input",label:o})),l)},t}(i.default.Component),He=/*#__PURE__*/function(e){function t(t){var a;return(a=e.call(this,t)||this).findSelectedOption=function(){var e=0;if(a.props.nextArgs)for(var t=y(a.props.nextArgs.data),r=a.props.nextArgs.schema[a.schemaName],n=0;n-1){e=n;break}if("object"===t){if($(a.props.nextArgs.data,i)){e=n;break}}else if("array"===t){if(F(a.props.nextArgs.data,i)){e=n;break}}else if(t===l){e=n;break}}}else{var o=a.props.parentArgs.data,u=y(o),c=a.props.parentArgs.schema[a.schemaName];if(void 0===c)return e;for(var d=0;d-1||(c[d]=l[d]));u.forEach(function(e,t){c[e]=R(o[e],a.props.parentArgs.getRef)}),this.props.parentArgs.onChange(n,c)}},a.render=function(){var e,t=this,a=this.findSelectedOption(),r=this.getSchema(a),n=E(r),l=this.props.nextArgs?this.props.nextArgs:this.props.parentArgs;"object"===n?(e=Le,"object"==typeof l.data&&null!==l.data||(l.data={})):"array"===n?(e=De,Array.isArray(l.data)||(l.data=[])):(e=Ve,l.removable=!1,l.onMoveUp=null,l.onMoveDown=null,(Array.isArray(l.data)||"object"==typeof l.data)&&(l.data=null));var o=e(s({},l,{schema:r})),u=null;return this.props.nextArgs&&(u=this.props.nextArgs.schema.title||null),/*#__PURE__*/i.default.createElement("div",{className:"rjf-form-group rjf-oneof-group"},/*#__PURE__*/i.default.createElement("div",{className:"rjf-oneof-selector"},/*#__PURE__*/i.default.createElement(ue,{value:a,options:this.getOptions(),onChange:function(e){return t.handleOptionChange(e,a)},className:"rjf-oneof-selector-input",label:u})),o)},t}(i.default.Component);function Ue(e){/*#__PURE__*/return i.default.createElement(He,s({},e,{schemaName:"anyOf"}))}function Je(e){if(!(e instanceof Object))return{isValid:!1,msg:"Schema must be an object"};var t,a=E(e);return(t="object"===a?Be(e):"array"===a?ze(e):e.hasOwnProperty("allOf")?Ge(e):e.hasOwnProperty("oneOf")?We(e):e.hasOwnProperty("anyOf")?Ye(e):e.hasOwnProperty("$ref")?{isValid:!0}:{isValid:!1,msg:"Outermost schema can only be of type array, list, object or dict"}).isValid&&e.hasOwnProperty("$defs")&&!e.$defs instanceof Object?{isValid:!1,msg:"'$defs' must be a valid JavaScript Object"}:t}function Be(e){if(!(e.hasOwnProperty("keys")||e.hasOwnProperty("properties")||e.hasOwnProperty("oneOf")||e.hasOwnProperty("anyOf")||e.hasOwnProperty("allOf")))return{isValid:!1,msg:"Schema of type '"+e.type+"' must have at least one of these keys: ['properties' or 'keys' or 'oneOf' or 'anyOf' or 'allOf']"};var t,a=e.properties||e.keys;if(a&&(t=function(e){if(!(e instanceof Object))return{isValid:!1,msg:"The 'keys' or 'properties' key must be a valid JavaScript Object"};for(var t in e)if(e.hasOwnProperty(t)){var a=e[t];if(!(a instanceof Object))return{isValid:!1,msg:"Key '"+t+"' must be a valid JavaScript Object"};var r={isValid:!0},n=k(a.type);if(n?"object"===n?r=Be(a):"array"===n&&(r=ze(a)):r=a.hasOwnProperty("$ref")?Ke(a):a.hasOwnProperty("oneOf")?We(a):a.hasOwnProperty("anyOf")?Ye(a):a.hasOwnProperty("allOf")?Ge(a):a.hasOwnProperty("const")?{isValid:!0,msg:""}:{isValid:!1,msg:"Key '"+t+"' must have a 'type' or a '$ref"},!r.isValid)return r}return{isValid:!0,msg:""}}(a),!t.isValid))return t;if(e.hasOwnProperty("additionalProperties")){if(!(e.additionalProperties instanceof Object)&&"boolean"!=typeof e.additionalProperties)return{isValid:!1,msg:"'additionalProperties' must be either a JavaScript boolean or a JavaScript object"};if(e.additionalProperties instanceof Object)if(e.additionalProperties.hasOwnProperty("$ref")){if(!(t=Ke(e.additionalProperties)).isValid)return t}else{var r=k(e.additionalProperties.type);if("object"===r)return Be(e.additionalProperties);if("array"===r)return Je(e.additionalProperties)}}return e.hasOwnProperty("oneOf")&&!(t=We(e)).isValid||e.hasOwnProperty("anyOf")&&!(t=Ye(e)).isValid||e.hasOwnProperty("allOf")&&!(t=Ge(e)).isValid?t:{isValid:!0,msg:""}}function ze(e){if(!e.hasOwnProperty("items"))return{isValid:!1,msg:"Schema of type '"+e.type+"' must have a key called 'items'"};if(!(e.items instanceof Object))return{isValid:!1,msg:"The 'items' key must be a valid JavaScript Object'"};var t=k(e.items.type);if(t){if("object"===t)return Be(e.items);if("array"===t)return ze(e.items)}else{if(e.items.hasOwnProperty("$ref"))return Ke(e.items);if(!(e.items.hasOwnProperty("oneOf")||e.items.hasOwnProperty("anyOf")||e.items.hasOwnProperty("allOf")||e.items.hasOwnProperty("const")))return{isValid:!1,msg:"Array 'items' must have a 'type' or '$ref' or 'oneOf' or 'anyOf'"}}return e.items.hasOwnProperty("oneOf")&&(validation=We(e.items),!validation.isValid)||e.items.hasOwnProperty("anyOf")&&(validation=Ye(e.items),!validation.isValid)?validation:e.items.hasOwnProperty("allOf")?{isValid:!1,msg:"Currently, 'allOf' inside array items is not supported"}:e.items.hasOwnProperty("const")&&(validation={isValid:!0,msg:""},!validation.isValid)?validation:{isValid:!0,msg:""}}function Ke(e){return"string"!=typeof e.$ref?{isValid:!1,msg:"'$ref' keyword must be a string"}:e.$ref.startsWith("#")?e.$ref.lenght>1&&!e.$ref.startsWith("#/")?{isValid:!1,msg:"Invalid '$ref' path"}:{isValid:!0,msg:""}:{isValid:!1,msg:"'$ref' value must begin with a hash (#) character"}}function We(e){return Xe(e,"oneOf")}function Ye(e){return Xe(e,"anyOf")}function Ge(e){var t=Xe(e,"allOf");if(!t.isValid)return t;for(var a=e.allOf,r=0;rparseInt(l)&&this.addError(a,"Maximum "+l+" items allowed."),S(e,"uniqueItems")&&("array"===n||"object"===n?t.length!==new Set(t.map(function(e){return JSON.stringify(e)})).size&&this.addError(a,"All items in this list must be unique."):t.length!==new Set(t).size&&this.addError(a,"All items in this list must be unique.")),o){var s=t.find(function(e){return-1===o.indexOf(e)});void 0!==s&&this.addError(a,'Invalid choice + "'+s+'"')}var u=this.getValidator(n);if("allOf"===n&&(u=null),u)for(var c=0;c-1&&!o.hasOwnProperty("required")&&(o.required=!0);var s=E(o),u=this.getValidator(s);if(!u)return void this.addError(a,'Unsupported type "'+s+'" for object properties (keys).');u(o,t[l],this.joinCoords([a,l]))}e.hasOwnProperty("allOf")&&this.validateAllOf(e,t,a)}}},this.validateAllOf=function(e,t,a){for(var r={type:"object",properties:{}},n=0;nparseInt(e.maxLength)&&this.addError(a,"This value may not be longer than "+e.maxLength+" characters."),C(e,t)){var r;switch(k(e.format)){case"email":r=this.validateEmail;break;case"date":r=this.validateDate;break;case"time":r=this.validateTime;break;case"date-time":r=this.validateDateTime}r&&r.call(this,e,t,a)}else this.addError(a,'Invalid choice "'+t+'"')}else this.addError(a,"This value is invalid. Must be a valid string.");else this.addError(a,"This field is required.")},this.validateBoolean=function(e,t,a){e.required&&null==t?this.addError(a,"This field is required."):"boolean"!=typeof t&&null!=t&&this.addError(a,"Invalid value.")},this.validateInteger=function(e,t,a){e.required&&null==t?this.addError(a,"This field is required."):null!==t&&("number"==typeof t&&t===parseInt(t)?this.validateNumber(e,t,a):this.addError(a,"Invalid value. Only integers allowed."))},this.validateNumber=function(e,t,a){e.required&&null==t?this.addError(a,"This field is required."):null!==t&&("number"==typeof t?((e.minimum||0===e.minimum)&&te.maximum&&this.addError(a,"This value must not be greater than "+e.maximum),(e.exclusiveMinimum||0===e.exclusiveMinimum)&&t<=e.exclusiveMinimum&&this.addError(a,"This value must be greater than "+e.exclusiveMinimum),(e.exclusiveMaximum||0===e.exclusiveMaximum)&&t>=e.exclusiveMaximum&&this.addError(a,"This value must be less than "+e.exclusiveMaximum),(e.multipleOf||0===e.multipleOf)&&100*t%(100*e.multipleOf)/100&&this.addError(a,"This value must be a multiple of "+e.multipleOf),C(e,t)||this.addError(a,'Invalid choice "'+t+'"')):this.addError(a,"Invalid value. Only numbers allowed."))},this.validateEmail=function(e,t,a){t.indexOf(" ")>-1?this.addError(a,"Enter a valid email address."):t.length>320&&this.addError(a,"Email may not be longer than 320 characters")},this.validateDate=function(e,t,a){},this.validateTime=function(e,t,a){},this.validateDateTime=function(e,t,a){}}function it(e){this.containerId=e.containerId,this.dataInputId=e.dataInputId,this.schema=e.schema,this.data=e.data,this.errorMap=e.errorMap,this.fileHandler=e.fileHandler,this.fileHandlerArgs=e.fileHandlerArgs||{},this.readonly=e.readonly||!1,this.eventListeners=null,this._dataSynced=!1,this.addEventListener=function(e,t){null===this.eventListeners&&(this.eventListeners={}),this.eventListeners.hasOwnProperty(e)||(this.eventListeners[e]=new Set),this.eventListeners[e].add(t)},this.onChange=function(e){this.data=e.data,this._dataSynced?this.eventListeners&&this.eventListeners.hasOwnProperty("change")&&this.eventListeners.change.size&&this.eventListeners.change.forEach(function(t){return t(e)}):this._dataSynced=!0},this.onChange=this.onChange.bind(this),this.render=function(){o.default.hasOwnProperty("createRoot")?this._renderReact18():this._renderReact17()},this._renderReact17=function(){try{o.default.render(this._getFormContainerComponent(),document.getElementById(this.containerId))}catch(e){o.default.render(/*#__PURE__*/i.default.createElement(st,{error:e}),document.getElementById(this.containerId))}},this._renderReact18=function(){var e=o.default.createRoot(document.getElementById(this.containerId));try{e.render(this._getFormContainerComponent())}catch(t){e.render(/*#__PURE__*/i.default.createElement(st,{error:t}))}},this._getFormContainerComponent=function(){/*#__PURE__*/return i.default.createElement(ot,{schema:this.schema,dataInputId:this.dataInputId,data:this.data,errorMap:this.errorMap,fileHandler:this.fileHandler,fileHandlerArgs:this.fileHandlerArgs,onChange:this.onChange,readonly:this.readonly})},this.update=function(e){this.schema=e.schema||this.schema,this.data=e.data||this.data,this.errorMap=e.errorMap||this.errorMap,this.render()},this.getSchema=function(){return this.schema},this.getData=function(){return this.data},this.validate=function(){return new nt(this.getSchema()).validate(this.getData())}}var lt={},ot=/*#__PURE__*/function(e){function t(t){var a;return(a=e.call(this,t)||this).populateDataInput=function(e){a.dataInput.value=JSON.stringify(e)},a.handleChange=function(e){a.setState({editorState:e})},a.state={editorState:Ze.create(t.schema,t.data)},a.prevEditorState=a.state.editorState,a.dataInput=document.getElementById(t.dataInputId),a}u(t,e);var a=t.prototype;return a.componentDidMount=function(){this.props.onChange({data:this.state.editorState.getData()}),this.populateDataInput(this.state.editorState.getData())},a.componentDidUpdate=function(e,t){if(this.props.schema===e.schema)this.props.data===e.data?(this.state.editorState!==t.editorState&&this.populateDataInput(this.state.editorState.getData()),this.props.onChange&&this.state.editorState!==t.editorState&&this.props.onChange({schema:this.state.editorState.getSchema(),data:this.state.editorState.getData(),prevSchema:t.editorState.getSchema(),prevData:t.editorState.getData()})):this.setState({editorState:Ze.update(this.state.editorState,this.props.data)});else{var a=this.props.schema,r=this.props.data!==e.data?this.props.data:this.state.editorState.getData();this.setState({editorState:Ze.create(a,r)})}},a.render=function(){/*#__PURE__*/return i.default.createElement(Qe,{editorState:this.state.editorState,onChange:this.handleChange,fileHandler:this.props.fileHandler,fileHandlerArgs:this.props.fileHandlerArgs,errorMap:this.props.errorMap,readonly:this.props.readonly})},t}(i.default.Component);function st(e){/*#__PURE__*/return i.default.createElement("div",{style:{color:"#f00"}},/*#__PURE__*/i.default.createElement("p",null,"(!) ",e.error.toString()),/*#__PURE__*/i.default.createElement("p",null,"Check browser console for more details about the error."))}e.DataValidator=nt,e.EditorState=Ze,e.ReactJSONForm=Qe,e.createForm=function(e){var t=new it(e);return lt[e.containerId]=t,t},e.getFormInstance=function(e){return lt[e]}}); diff --git a/dist/react-json-form.modern.js b/dist/react-json-form.modern.js index 1e78883..7155b24 100644 --- a/dist/react-json-form.modern.js +++ b/dist/react-json-form.modern.js @@ -384,7 +384,9 @@ function getSyncedArray(data, schema, getRef) { let minItems = schema.minItems || schema.min_items || 0; - while (data.length < minItems) data.push(FILLER); + if (schema.items.widget !== 'multiselect') { + while (data.length < minItems) data.push(FILLER); + } for (let i = 0; i < data.length; i++) { let item = data[i]; @@ -2712,6 +2714,7 @@ function FormField(props) { case 'number': if (type === 'range') inputProps.type = 'range';else inputProps.type = 'number'; + inputProps.step = 'any'; InputField = FormInput; if (props.schema.minimum || props.schema.minimum === 0) inputProps.min = props.schema.minimum; if (props.schema.maximum || props.schema.maximum === 0) inputProps.max = props.schema.maximum; @@ -3144,12 +3147,10 @@ class OneOfTopLevel extends React$1.Component { }; this.getOptions = () => { - return this.props.args.schema[this.schemaName].map((option, index) => { - return { - label: option.title || 'Option ' + (index + 1), - value: index - }; - }); + return Array.from(this.props.args.schema[this.schemaName].keys(), index => ({ + label: this.getSchema(index).title || 'Option ' + (index + 1), + value: index + })); }; this.getSchema = index => { @@ -4165,7 +4166,7 @@ function DataValidator(schema) { let next_schema = schema.items; if (next_schema.hasOwnProperty('$ref')) next_schema = this.getRef(next_schema.$ref); - let next_type = normalizeKeyword(next_schema.type); + let next_type = getSchemaType(next_schema); let minItems = getKeyword(schema, 'minItems', 'min_items'); let maxItems = getKeyword(schema, 'maxItems', 'max_items'); let choices = getKeyword(schema.items, 'choices', 'enum'); @@ -4187,15 +4188,9 @@ function DataValidator(schema) { if (typeof invalid_choice !== 'undefined') this.addError(coords, 'Invalid choice + "' + invalid_choice + '"'); } - let next_validator = this.getValidator(next_type); + let next_validator = this.getValidator(next_type); // currently allOf is not supported in array items - if (!next_validator) { - if (next_schema.hasOwnProperty('oneOf')) { - next_validator = this.validateOneOf; - } else if (next_schema.hasOwnProperty('anyOf')) { - next_validator = this.validateAnyOf; - } else if (next_schema.hasOwnProperty('anyOf')) ; - } + if (next_type === 'allOf') next_validator = null; if (next_validator) { for (let i = 0; i < data.length; i++) next_validator(next_schema, data[i], this.joinCoords([coords, i])); @@ -4233,7 +4228,7 @@ function DataValidator(schema) { if (schema.required.indexOf(key) > -1 && !next_schema.hasOwnProperty('required')) next_schema['required'] = true; } - let next_type = normalizeKeyword(next_schema.type); + let next_type = getSchemaType(next_schema); let next_validator = this.getValidator(next_type); if (next_validator) next_validator(next_schema, data[key], this.joinCoords([coords, key]));else { this.addError(coords, 'Unsupported type "' + next_type + '" for object properties (keys).'); diff --git a/dist/react-json-form.module.js b/dist/react-json-form.module.js index 1e78883..7155b24 100644 --- a/dist/react-json-form.module.js +++ b/dist/react-json-form.module.js @@ -384,7 +384,9 @@ function getSyncedArray(data, schema, getRef) { let minItems = schema.minItems || schema.min_items || 0; - while (data.length < minItems) data.push(FILLER); + if (schema.items.widget !== 'multiselect') { + while (data.length < minItems) data.push(FILLER); + } for (let i = 0; i < data.length; i++) { let item = data[i]; @@ -2712,6 +2714,7 @@ function FormField(props) { case 'number': if (type === 'range') inputProps.type = 'range';else inputProps.type = 'number'; + inputProps.step = 'any'; InputField = FormInput; if (props.schema.minimum || props.schema.minimum === 0) inputProps.min = props.schema.minimum; if (props.schema.maximum || props.schema.maximum === 0) inputProps.max = props.schema.maximum; @@ -3144,12 +3147,10 @@ class OneOfTopLevel extends React$1.Component { }; this.getOptions = () => { - return this.props.args.schema[this.schemaName].map((option, index) => { - return { - label: option.title || 'Option ' + (index + 1), - value: index - }; - }); + return Array.from(this.props.args.schema[this.schemaName].keys(), index => ({ + label: this.getSchema(index).title || 'Option ' + (index + 1), + value: index + })); }; this.getSchema = index => { @@ -4165,7 +4166,7 @@ function DataValidator(schema) { let next_schema = schema.items; if (next_schema.hasOwnProperty('$ref')) next_schema = this.getRef(next_schema.$ref); - let next_type = normalizeKeyword(next_schema.type); + let next_type = getSchemaType(next_schema); let minItems = getKeyword(schema, 'minItems', 'min_items'); let maxItems = getKeyword(schema, 'maxItems', 'max_items'); let choices = getKeyword(schema.items, 'choices', 'enum'); @@ -4187,15 +4188,9 @@ function DataValidator(schema) { if (typeof invalid_choice !== 'undefined') this.addError(coords, 'Invalid choice + "' + invalid_choice + '"'); } - let next_validator = this.getValidator(next_type); + let next_validator = this.getValidator(next_type); // currently allOf is not supported in array items - if (!next_validator) { - if (next_schema.hasOwnProperty('oneOf')) { - next_validator = this.validateOneOf; - } else if (next_schema.hasOwnProperty('anyOf')) { - next_validator = this.validateAnyOf; - } else if (next_schema.hasOwnProperty('anyOf')) ; - } + if (next_type === 'allOf') next_validator = null; if (next_validator) { for (let i = 0; i < data.length; i++) next_validator(next_schema, data[i], this.joinCoords([coords, i])); @@ -4233,7 +4228,7 @@ function DataValidator(schema) { if (schema.required.indexOf(key) > -1 && !next_schema.hasOwnProperty('required')) next_schema['required'] = true; } - let next_type = normalizeKeyword(next_schema.type); + let next_type = getSchemaType(next_schema); let next_validator = this.getValidator(next_type); if (next_validator) next_validator(next_schema, data[key], this.joinCoords([coords, key]));else { this.addError(coords, 'Unsupported type "' + next_type + '" for object properties (keys).'); diff --git a/package.json b/package.json index 29c82ad..0107438 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bhch/react-json-form", - "version": "2.14.0", + "version": "2.14.1", "description": "Create forms using JSON Schema", "publishConfig": { "access": "public"