@rjsf/utils
Advanced tools
Comparing version 5.0.0-beta.13 to 5.0.0-beta.14
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash/isEqualWith"),t=require("lodash/get"),r=require("lodash/isEmpty"),i=require("jsonpointer"),n=require("lodash/omit"),o=require("lodash/set"),s=require("json-schema-merge-allof"),a=require("lodash/union"),u=require("react"),d=require("react-is");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f,c=l(e),p=l(t),m=l(r),y=l(i),g=l(n),h=l(o),x=l(s),O=l(a),b=l(u),v=l(d);function A(e){return!("undefined"!=typeof File&&e instanceof File||"object"!=typeof e||null===e||Array.isArray(e))}function S(e){if(""===e)return;if(null===e)return null;if(/\.$/.test(e))return e;if(/\.0$/.test(e))return e;if(/\.\d*0$/.test(e))return e;const t=Number(e);return"number"!=typeof t||Number.isNaN(t)?e:t}function E(e){return void 0===e&&(e={}),Object.keys(e).filter((e=>0===e.indexOf("ui:"))).reduce(((t,r)=>{const i=e[r];return"ui:widget"===r&&A(i)?(console.error("Setting options via ui:widget object is no longer supported, use ui:options instead"),t):"ui:options"===r&&A(i)?{...t,...i}:{...t,[r.substring(3)]:i}}),{})}function w(e,t){return c.default(e,t,((e,t)=>{if("function"==typeof e&&"function"==typeof t)return!0}))}function _(e,t){const r=t[e];return[g.default(t,[e]),r]}function W(e,t){void 0===t&&(t={});let r=e||"";if(!r.startsWith("#"))throw new Error(`Could not find a definition for ${e}.`);r=decodeURIComponent(r.substring(1));const i=y.default.get(t,r);if(void 0===i)throw new Error(`Could not find a definition for ${e}.`);if(i.$ref){const[e,r]=_("$ref",i),n=W(r,t);return Object.keys(e).length>0?{...e,...n}:n}return i}function I(e,t,r,i){if(void 0===t)return 0;for(let n=0;n<r.length;n++){const o=r[n];if(o.properties){const r={anyOf:Object.keys(o.properties).map((e=>({required:[e]})))};let s;if(o.anyOf){const{...e}=o;e.allOf=e.allOf?e.allOf.slice():[],e.allOf.push(r),s=e}else s=Object.assign({},o,r);if(delete s.required,e.isValid(s,t,i))return n}else if(e.isValid(o,t,i))return n}return 0}function T(e){return Array.isArray(e)?"array":"string"==typeof e?"string":null==e?"null":"boolean"==typeof e?"boolean":isNaN(e)?"object"==typeof e?"object":"string":"number"}function D(e){let{type:t}=e;return!t&&e.const?T(e.const):!t&&e.enum?"string":t||!e.properties&&!e.additionalProperties?(Array.isArray(t)&&2===t.length&&t.includes("null")&&(t=t.find((e=>"null"!==e))),t):"object"}function $(e){return Array.isArray(e.items)&&e.items.length>0&&e.items.every((e=>A(e)))}function P(e,t){if(Array.isArray(t)){const r=Array.isArray(e)?e:[];return t.map(((e,t)=>r[t]?P(r[t],e):e))}if(A(t)){const r=Object.assign({},e);return Object.keys(t).reduce(((r,i)=>(r[i]=P(e?p.default(e,i):{},p.default(t,i)),r)),r)}return t}function j(e,t,r){return void 0===r&&(r=!1),Object.keys(t).reduce(((i,n)=>{const o=e?e[n]:{},s=t[n];return i[n]=e&&n in e&&A(s)?j(o,s,r):r&&Array.isArray(o)&&Array.isArray(s)?o.concat(s):s,i}),Object.assign({},e))}function N(e){return Array.isArray(e.enum)&&1===e.enum.length||"const"in e}function F(e,t){const r=Object.assign({},e);return Object.keys(t).reduce(((r,i)=>{const n=e?e[i]:{},o=t[i];return r[i]=e&&i in e&&A(o)?F(n,o):e&&t&&("object"===D(e)||"object"===D(t))&&"required"===i&&Array.isArray(n)&&Array.isArray(o)?O.default(n,o):o,r}),r)}function R(e,t,r,i){const n=W(t.$ref,r),{$ref:o,...s}=t;return U(e,{...n,...s},r,i)}function U(e,t,r,i){if(void 0===r&&(r={}),!A(t))return{};let n=function(e,t,r,i){if(void 0===r&&(r={}),"$ref"in t)return R(e,t,r,i);if("dependencies"in t){const n=Y(e,t,r,i);return U(e,n,r,i)}return"allOf"in t?{...t,allOf:t.allOf.map((t=>U(e,t,r,i)))}:t}(e,t,r,i);if("if"in t)return function(e,t,r,i){const{if:n,then:o,else:s,...a}=t,u=e.isValid(n,i,r)?o:s;return U(e,u&&"boolean"!=typeof u?F(a,U(e,u,r,i)):a,r,i)}(e,t,r,i);const o=i||{};if(n.properties){const t={};Object.entries(n.properties).forEach((i=>{const s=i[0],a=i[1],u=o[s],d=A(u)?u:{},l=U(e,a,r,d);t[s]=l,a!==l&&n.properties!==t&&(n={...n,properties:t})}))}if("allOf"in t)try{n=x.default({...n,allOf:n.allOf})}catch(e){console.warn("could not merge subschemas in allOf:\n"+e);const{allOf:t,...r}=n;return r}return"additionalProperties"in n&&!1!==n.additionalProperties?function(e,t,r,i){const n={...t,properties:{...t.properties}},o=i&&A(i)?i:{};return Object.keys(o).forEach((t=>{if(t in n.properties)return;let i={};i="boolean"!=typeof n.additionalProperties?"$ref"in n.additionalProperties?U(e,{$ref:p.default(n.additionalProperties,["$ref"])},r,o):"type"in n.additionalProperties?{...n.additionalProperties}:{type:T(p.default(o,[t]))}:{type:T(p.default(o,[t]))},n.properties[t]=i,h.default(n.properties,[t,"__additional_property"],!0)})),n}(e,n,r,o):n}function Y(e,t,r,i){const{dependencies:n,...o}=t;let s=o;return Array.isArray(s.oneOf)?s=s.oneOf[I(e,i,s.oneOf,r)]:Array.isArray(s.anyOf)&&(s=s.anyOf[I(e,i,s.anyOf,r)]),q(e,n,s,r,i)}function q(e,t,r,i,n){let o=r;for(const r in t){if(void 0===p.default(n,[r]))continue;if(o.properties&&!(r in o.properties))continue;const[s,a]=_(r,t);return Array.isArray(a)?o=C(o,a):A(a)&&(o=K(e,o,i,r,a,n)),q(e,s,o,i,n)}return o}function C(e,t){if(!t)return e;const r=Array.isArray(e.required)?Array.from(new Set([...e.required,...t])):t;return{...e,required:r}}function K(e,t,r,i,n,o){const{oneOf:s,...a}=U(e,n,r,o);if(t=F(t,a),void 0===s)return t;const u=s.map((t=>"boolean"!=typeof t&&"$ref"in t?R(e,t,r,o):t));return function(e,t,r,i,n,o){const s=n.filter((t=>{if("boolean"==typeof t||!t||!t.properties)return!1;const{[i]:r}=t.properties;if(r){const t={type:"object",properties:{[i]:r}},{errors:n}=e.validateFormData(o,t);return 0===n.length}return!1}));if(1!==s.length)return console.warn("ignoring oneOf in dependencies because there isn't exactly one subschema that is valid"),t;const a=s[0],[u]=_(i,a.properties),d={...a,properties:u};return F(t,U(e,d,r,o))}(e,t,r,i,u,o)}function k(e,t,r){void 0===r&&(r={});const i=U(e,t,r,void 0),n=i.oneOf||i.anyOf;return!!Array.isArray(i.enum)||!!Array.isArray(n)&&n.every((e=>"boolean"!=typeof e&&N(e)))}function M(e,t,r){return!(!t.uniqueItems||!t.items||"boolean"==typeof t.items)&&k(e,t.items,r)}function L(e,t,r){if(void 0===t&&(t=f.Ignore),void 0===r&&(r=-1),r>=0){if(Array.isArray(e.items)&&r<e.items.length){const t=e.items[r];if("boolean"!=typeof t)return t}}else if(e.items&&!Array.isArray(e.items)&&"boolean"!=typeof e.items)return e.items;return t!==f.Ignore&&A(e.additionalItems)?e.additionalItems:{}}function V(e,t,r,i,n,o){void 0===i&&(i={}),void 0===o&&(o=!1);const s=A(n)?n:{};let a=r;if(A(a)&&A(t.default))a=j(a,t.default);else if("default"in t)a=t.default;else{if("$ref"in t){const r=W(t.$ref,i);return V(e,r,a,i,s,o)}if("dependencies"in t){const r=Y(e,t,i,s);return V(e,r,a,i,s,o)}$(t)?a=t.items.map(((t,n)=>V(e,t,Array.isArray(r)?r[n]:void 0,i,s,o))):"oneOf"in t?t=t.oneOf[I(e,m.default(s)?void 0:s,t.oneOf,i)]:"anyOf"in t&&(t=t.anyOf[I(e,m.default(s)?void 0:s,t.anyOf,i)])}switch(void 0===a&&(a=t.default),D(t)){case"object":return Object.keys(t.properties||{}).reduce(((r,n)=>{const u=V(e,p.default(t,["properties",n]),p.default(a,[n]),i,p.default(s,[n]),o);return(o||void 0!==u)&&(r[n]=u),r}),{});case"array":if(Array.isArray(a)&&(a=a.map(((r,n)=>{const o=L(t,f.Fallback,n);return V(e,o,r,i)}))),Array.isArray(n)){const r=L(t);a=n.map(((t,n)=>V(e,r,p.default(a,[n]),i,t)))}if(t.minItems){if(!M(e,t,i)){const r=Array.isArray(a)?a.length:0;if(t.minItems>r){const n=a||[],o=L(t,f.Invert),s=o.default,u=new Array(t.minItems-r).fill(V(e,o,s,i));return n.concat(u)}}return a||[]}}return a}function B(e,t,r,i,n){if(void 0===n&&(n=!1),!A(t))throw new Error("Invalid schema: "+t);const o=V(e,U(e,t,i,r),void 0,i,r,n);return null==r||"number"==typeof r&&isNaN(r)?o:A(r)||Array.isArray(r)?P(o,r):r}function H(e){return void 0===e&&(e={}),"widget"in E(e)&&"hidden"!==E(e).widget}function G(e,t,r,i){if(void 0===r&&(r={}),"files"===r["ui:widget"])return!0;if(t.items){const r=U(e,t.items,i);return"string"===r.type&&"data-url"===r.format}return!1}function J(e,t,r,i){void 0===r&&(r={});const n=E(r),{label:o=!0}=n;let s=!!o;const a=D(t);return"array"===a&&(s=M(e,t,i)||G(e,t,r,i)||H(r)),"object"===a&&(s=!1),"boolean"!==a||r["ui:widget"]||(s=!1),r["ui:field"]&&(s=!1),s}function Q(e,t,r){if(!r)return t;const{errors:i,errorSchema:n}=t;let o=e.toErrorList(r),s=r;return m.default(n)||(s=j(n,r,!0),o=[...i].concat(o)),{errorSchema:s,errors:o}}function z(e,t,r,i,n,o,s){if(void 0===o&&(o="root"),void 0===s&&(s="_"),"$ref"in t||"dependencies"in t||"allOf"in t)return z(e,U(e,t,i,n),r,i,n,o,s);if("items"in t&&!p.default(t,["items","$ref"]))return z(e,p.default(t,"items"),r,i,n,o,s);const a={$id:r||o};if("object"===t.type&&"properties"in t)for(const r in t.properties){const u=p.default(t,["properties",r]),d=a.$id+s+r;a[r]=z(e,A(u)?u:{},d,i,p.default(n,[r]),o,s)}return a}function X(e,t,r,i,n){if(void 0===r&&(r=""),"$ref"in t||"dependencies"in t||"allOf"in t){const o=U(e,t,i,n);return X(e,o,r,i,n)}const o={$name:r.replace(/^\./,"")};if("additionalProperties"in t&&!0===t.additionalProperties&&h.default(o,"__rjsf_additionalProperties",!0),"items"in t&&Array.isArray(n))n.forEach(((n,s)=>{o[s]=X(e,t.items,`${r}.${s}`,i,n)}));else if("properties"in t)for(const s in t.properties){const a=p.default(t,["properties",s]);o[s]=X(e,a,`${r}.${s}`,i,p.default(n,[s]))}return o}!function(e){e[e.Ignore=0]="Ignore",e[e.Invert=1]="Invert",e[e.Fallback=2]="Fallback"}(f||(f={}));class Z{constructor(e,t){this.rootSchema=void 0,this.validator=void 0,this.rootSchema=t,this.validator=e}getValidator(){return this.validator}doesSchemaUtilsDiffer(e,t){return!(!e||!t||this.validator===e&&w(this.rootSchema,t))}getDefaultFormState(e,t,r){return void 0===r&&(r=!1),B(this.validator,e,t,this.rootSchema,r)}getDisplayLabel(e,t){return J(this.validator,e,t,this.rootSchema)}getMatchingOption(e,t){return I(this.validator,e,t,this.rootSchema)}isFilesArray(e,t){return G(this.validator,e,t,this.rootSchema)}isMultiSelect(e){return M(this.validator,e,this.rootSchema)}isSelect(e){return k(this.validator,e,this.rootSchema)}mergeValidationData(e,t){return Q(this.validator,e,t)}retrieveSchema(e,t){return U(this.validator,e,this.rootSchema,t)}toIdSchema(e,t,r,i,n){return void 0===i&&(i="root"),void 0===n&&(n="_"),z(this.validator,e,t,this.rootSchema,r,i,n)}toPathSchema(e,t,r){return X(this.validator,e,t,this.rootSchema,r)}}function ee(e){const t={};return e.multipleOf&&(t.step=e.multipleOf),(e.minimum||0===e.minimum)&&(t.min=e.minimum),(e.maximum||0===e.maximum)&&(t.max=e.maximum),t}const te={props:{disabled:!1},submitText:"Submit",norender:!1},re={boolean:{checkbox:"CheckboxWidget",radio:"RadioWidget",select:"SelectWidget",hidden:"HiddenWidget"},string:{text:"TextWidget",password:"PasswordWidget",email:"EmailWidget",hostname:"TextWidget",ipv4:"TextWidget",ipv6:"TextWidget",uri:"URLWidget","data-url":"FileWidget",radio:"RadioWidget",select:"SelectWidget",textarea:"TextareaWidget",hidden:"HiddenWidget",date:"DateWidget",datetime:"DateTimeWidget","date-time":"DateTimeWidget","alt-date":"AltDateWidget","alt-datetime":"AltDateTimeWidget",color:"ColorWidget",file:"FileWidget"},number:{text:"TextWidget",select:"SelectWidget",updown:"UpDownWidget",range:"RangeWidget",radio:"RadioWidget",hidden:"HiddenWidget"},integer:{text:"TextWidget",select:"SelectWidget",updown:"UpDownWidget",range:"RangeWidget",radio:"RadioWidget",hidden:"HiddenWidget"},array:{select:"SelectWidget",checkboxes:"CheckboxesWidget",files:"FileWidget",hidden:"HiddenWidget"}};function ie(e,t,r){void 0===r&&(r={});const i=D(e);if("function"==typeof t||t&&v.default.isForwardRef(b.default.createElement(t))||v.default.isMemo(t))return function(e){let t=p.default(e,"MergedWidget");if(!t){const r=e.defaultProps&&e.defaultProps.options||{};t=t=>{let{options:i,...n}=t;return b.default.createElement(e,{options:{...r,...i},...n})},h.default(e,"MergedWidget",t)}return t}(t);if("string"!=typeof t)throw new Error("Unsupported widget definition: "+typeof t);if(t in r)return ie(e,r[t],r);if("string"==typeof i){if(!(i in re))throw new Error(`No widget for type '${i}'`);if(t in re[i])return ie(e,r[re[i][t]],r)}throw new Error(`No widget '${t}' for type '${i}'`)}function ne(e){if("enum"in e&&Array.isArray(e.enum)&&1===e.enum.length)return e.enum[0];if("const"in e)return e.const;throw new Error("schema cannot be inferred as a constant")}function oe(e,t){let r=String(e);for(;r.length<t;)r="0"+r;return r}const se=new Set(["number","integer"]);exports.ADDITIONAL_PROPERTIES_KEY="additionalProperties",exports.ADDITIONAL_PROPERTY_FLAG="__additional_property",exports.ALL_OF_KEY="allOf",exports.ANY_OF_KEY="anyOf",exports.CONST_KEY="const",exports.DEFAULT_KEY="default",exports.DEFINITIONS_KEY="definitions",exports.DEPENDENCIES_KEY="dependencies",exports.ENUM_KEY="enum",exports.ERRORS_KEY="__errors",exports.ID_KEY="$id",exports.ITEMS_KEY="items",exports.NAME_KEY="$name",exports.ONE_OF_KEY="oneOf",exports.PROPERTIES_KEY="properties",exports.REF_KEY="$ref",exports.REQUIRED_KEY="required",exports.RJSF_ADDITONAL_PROPERTIES_FLAG="__rjsf_additionalProperties",exports.SUBMIT_BTN_OPTIONS_KEY="submitButtonOptions",exports.UI_FIELD_KEY="ui:field",exports.UI_OPTIONS_KEY="ui:options",exports.UI_WIDGET_KEY="ui:widget",exports.allowAdditionalItems=function(e){return!0===e.additionalItems&&console.warn("additionalItems=true is currently not supported"),A(e.additionalItems)},exports.asNumber=S,exports.canExpand=function(e,t,r){if(void 0===t&&(t={}),!e.additionalProperties)return!1;const{expandable:i=!0}=E(t);return!1===i?i:void 0===e.maxProperties||!r||Object.keys(r).length<e.maxProperties},exports.createSchemaUtils=function(e,t){return new Z(e,t)},exports.dataURItoBlob=function(e){const t=e.split(","),r=t[0].split(";"),i=r[0].replace("data:",""),n=r.filter((e=>"name"===e.split("=")[0]));let o;o=1!==n.length?"unknown":n[0].split("=")[1];const s=atob(t[1]),a=[];for(let e=0;e<s.length;e++)a.push(s.charCodeAt(e));return{blob:new window.Blob([new Uint8Array(a)],{type:i}),name:o}},exports.deepEquals=w,exports.findSchemaDefinition=W,exports.getDefaultFormState=B,exports.getDisplayLabel=J,exports.getInputProps=function(e,t,r,i){void 0===r&&(r={}),void 0===i&&(i=!0);const n={type:t||"text",...ee(e)};return r.inputType?n.type=r.inputType:t||("number"===e.type?(n.type="number",i&&void 0===n.step&&(n.step="any")):"integer"===e.type&&(n.type="number",void 0===n.step&&(n.step=1))),r.autocomplete&&(n.autoComplete=r.autocomplete),n},exports.getMatchingOption=I,exports.getSchemaType=D,exports.getSubmitButtonOptions=function(e){void 0===e&&(e={});const t=E(e);if(t&&t.submitButtonOptions){const e=t.submitButtonOptions;return{...te,...e}}return te},exports.getTemplate=function(e,t,r){void 0===r&&(r={});const{templates:i}=t;return"ButtonTemplates"===e?i[e]:r[e]||i[e]},exports.getUiOptions=E,exports.getWidget=ie,exports.guessType=T,exports.hasWidget=function(e,t,r){void 0===r&&(r={});try{return ie(e,t,r),!0}catch(e){const t=e;if(t.message&&(t.message.startsWith("No widget")||t.message.startsWith("Unsupported widget")))return!1;throw e}},exports.isConstant=N,exports.isCustomWidget=H,exports.isFilesArray=G,exports.isFixedItems=$,exports.isMultiSelect=M,exports.isObject=A,exports.isSelect=k,exports.localToUTC=function(e){return e?new Date(e).toJSON():void 0},exports.mergeDefaultsWithFormData=P,exports.mergeObjects=j,exports.mergeSchemas=F,exports.mergeValidationData=Q,exports.optionsList=function(e){const t=e;if(e.enum)return e.enum.map(((e,r)=>({label:t.enumNames&&t.enumNames[r]||String(e),value:e})));const r=e.oneOf||e.anyOf;return r&&r.map((e=>{const t=e,r=ne(t);return{schema:t,label:t.title||String(r),value:r}}))},exports.orderProperties=function(e,t){if(!Array.isArray(t))return e;const r=e=>e.reduce(((e,t)=>(e[t]=!0,e)),{}),i=r(e),n=t.filter((e=>"*"===e||i[e])),o=r(n),s=e.filter((e=>!o[e])),a=n.indexOf("*");if(-1===a){if(s.length)throw new Error("uiSchema order list does not contain "+((u=s).length>1?`properties '${u.join("', '")}'`:`property '${u[0]}'`));return n}var u;if(a!==n.lastIndexOf("*"))throw new Error("uiSchema order list contains more than one wildcard item");const d=[...n];return d.splice(a,1,...s),d},exports.pad=oe,exports.parseDateString=function(e,t){if(void 0===t&&(t=!0),!e)return{year:-1,month:-1,day:-1,hour:t?-1:0,minute:t?-1:0,second:t?-1:0};const r=new Date(e);if(Number.isNaN(r.getTime()))throw new Error("Unable to parse date "+e);return{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate(),hour:t?r.getUTCHours():0,minute:t?r.getUTCMinutes():0,second:t?r.getUTCSeconds():0}},exports.processSelectValue=function(e,t,r){const{enum:i,type:n,items:o}=e;if(""===t)return r&&void 0!==r.emptyValue?r.emptyValue:void 0;if("array"===n&&o&&se.has(p.default(o,"type")))return t.map(S);if("boolean"===n)return"true"===t;if(se.has(n))return S(t);if(Array.isArray(i)){if(i.every((e=>se.has(T(e)))))return S(t);if(i.every((e=>"boolean"===T(e))))return"true"===t}return t},exports.rangeSpec=ee,exports.retrieveSchema=U,exports.schemaRequiresTrueValue=function e(t){return!!t.const||!(!t.enum||1!==t.enum.length||!0!==t.enum[0])||(t.anyOf&&1===t.anyOf.length?e(t.anyOf[0]):t.oneOf&&1===t.oneOf.length?e(t.oneOf[0]):!!t.allOf&&t.allOf.some((t=>e(t))))},exports.shouldRender=function(e,t,r){const{props:i,state:n}=e;return!w(i,t)||!w(n,r)},exports.toConstant=ne,exports.toDateString=function(e,t){void 0===t&&(t=!0);const{year:r,month:i,day:n,hour:o=0,minute:s=0,second:a=0}=e,u=Date.UTC(r,i-1,n,o,s,a),d=new Date(u).toJSON();return t?d:d.slice(0,10)},exports.toIdSchema=z,exports.toPathSchema=X,exports.utcToLocal=function(e){if(!e)return"";const t=new Date(e);return`${oe(t.getFullYear(),4)}-${oe(t.getMonth()+1,2)}-${oe(t.getDate(),2)}T${oe(t.getHours(),2)}:${oe(t.getMinutes(),2)}:${oe(t.getSeconds(),2)}.${oe(t.getMilliseconds(),3)}`}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash/isEqualWith"),t=require("lodash/get"),r=require("lodash/isEmpty"),i=require("jsonpointer"),n=require("lodash/omit"),o=require("lodash/set"),s=require("json-schema-merge-allof"),a=require("lodash/union"),u=require("react"),d=require("react-is");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f,c=l(e),p=l(t),m=l(r),y=l(i),g=l(n),h=l(o),x=l(s),O=l(a),b=l(u),v=l(d);function A(e){return!("undefined"!=typeof File&&e instanceof File||"object"!=typeof e||null===e||Array.isArray(e))}function S(e){if(""===e)return;if(null===e)return null;if(/\.$/.test(e))return e;if(/\.0$/.test(e))return e;if(/\.\d*0$/.test(e))return e;const t=Number(e);return"number"!=typeof t||Number.isNaN(t)?e:t}function E(e){return void 0===e&&(e={}),Object.keys(e).filter((e=>0===e.indexOf("ui:"))).reduce(((t,r)=>{const i=e[r];return"ui:widget"===r&&A(i)?(console.error("Setting options via ui:widget object is no longer supported, use ui:options instead"),t):"ui:options"===r&&A(i)?{...t,...i}:{...t,[r.substring(3)]:i}}),{})}function w(e,t){return c.default(e,t,((e,t)=>{if("function"==typeof e&&"function"==typeof t)return!0}))}function _(e,t){const r=t[e];return[g.default(t,[e]),r]}function W(e,t){void 0===t&&(t={});let r=e||"";if(!r.startsWith("#"))throw new Error(`Could not find a definition for ${e}.`);r=decodeURIComponent(r.substring(1));const i=y.default.get(t,r);if(void 0===i)throw new Error(`Could not find a definition for ${e}.`);if(i.$ref){const[e,r]=_("$ref",i),n=W(r,t);return Object.keys(e).length>0?{...e,...n}:n}return i}function I(e,t,r,i){if(void 0===t)return 0;for(let n=0;n<r.length;n++){const o=r[n];if(o.properties){const r={anyOf:Object.keys(o.properties).map((e=>({required:[e]})))};let s;if(o.anyOf){const{...e}=o;e.allOf=e.allOf?e.allOf.slice():[],e.allOf.push(r),s=e}else s=Object.assign({},o,r);if(delete s.required,e.isValid(s,t,i))return n}else if(e.isValid(o,t,i))return n}return 0}function T(e){return Array.isArray(e)?"array":"string"==typeof e?"string":null==e?"null":"boolean"==typeof e?"boolean":isNaN(e)?"object"==typeof e?"object":"string":"number"}function D(e){let{type:t}=e;return!t&&e.const?T(e.const):!t&&e.enum?"string":t||!e.properties&&!e.additionalProperties?(Array.isArray(t)&&2===t.length&&t.includes("null")&&(t=t.find((e=>"null"!==e))),t):"object"}function $(e){return Array.isArray(e.items)&&e.items.length>0&&e.items.every((e=>A(e)))}function j(e,t){if(Array.isArray(t)){const r=Array.isArray(e)?e:[];return t.map(((e,t)=>r[t]?j(r[t],e):e))}if(A(t)){const r=Object.assign({},e);return Object.keys(t).reduce(((r,i)=>(r[i]=j(e?p.default(e,i):{},p.default(t,i)),r)),r)}return t}function P(e,t,r){return void 0===r&&(r=!1),Object.keys(t).reduce(((i,n)=>{const o=e?e[n]:{},s=t[n];if(e&&n in e&&A(s))i[n]=P(o,s,r);else if(r&&Array.isArray(o)&&Array.isArray(s)){let e=s;"preventDuplicates"===r&&(e=s.reduce(((e,t)=>(o.includes(t)||e.push(t),e)),[])),i[n]=o.concat(e)}else i[n]=s;return i}),Object.assign({},e))}function N(e){return Array.isArray(e.enum)&&1===e.enum.length||"const"in e}function F(e,t){const r=Object.assign({},e);return Object.keys(t).reduce(((r,i)=>{const n=e?e[i]:{},o=t[i];return r[i]=e&&i in e&&A(o)?F(n,o):e&&t&&("object"===D(e)||"object"===D(t))&&"required"===i&&Array.isArray(n)&&Array.isArray(o)?O.default(n,o):o,r}),r)}function R(e,t,r,i){const n=W(t.$ref,r),{$ref:o,...s}=t;return U(e,{...n,...s},r,i)}function U(e,t,r,i){if(void 0===r&&(r={}),!A(t))return{};let n=function(e,t,r,i){if(void 0===r&&(r={}),"$ref"in t)return R(e,t,r,i);if("dependencies"in t){const n=Y(e,t,r,i);return U(e,n,r,i)}return"allOf"in t?{...t,allOf:t.allOf.map((t=>U(e,t,r,i)))}:t}(e,t,r,i);if("if"in t)return function(e,t,r,i){const{if:n,then:o,else:s,...a}=t,u=e.isValid(n,i,r)?o:s;return U(e,u&&"boolean"!=typeof u?F(a,U(e,u,r,i)):a,r,i)}(e,t,r,i);const o=i||{};if(n.properties){const t={};Object.entries(n.properties).forEach((i=>{const s=i[0],a=i[1],u=o[s],d=A(u)?u:{},l=U(e,a,r,d);t[s]=l,a!==l&&n.properties!==t&&(n={...n,properties:t})}))}if("allOf"in t)try{n=x.default({...n,allOf:n.allOf})}catch(e){console.warn("could not merge subschemas in allOf:\n"+e);const{allOf:t,...r}=n;return r}return"additionalProperties"in n&&!1!==n.additionalProperties?function(e,t,r,i){const n={...t,properties:{...t.properties}},o=i&&A(i)?i:{};return Object.keys(o).forEach((t=>{if(t in n.properties)return;let i={};i="boolean"!=typeof n.additionalProperties?"$ref"in n.additionalProperties?U(e,{$ref:p.default(n.additionalProperties,["$ref"])},r,o):"type"in n.additionalProperties?{...n.additionalProperties}:{type:T(p.default(o,[t]))}:{type:T(p.default(o,[t]))},n.properties[t]=i,h.default(n.properties,[t,"__additional_property"],!0)})),n}(e,n,r,o):n}function Y(e,t,r,i){const{dependencies:n,...o}=t;let s=o;return Array.isArray(s.oneOf)?s=s.oneOf[I(e,i,s.oneOf,r)]:Array.isArray(s.anyOf)&&(s=s.anyOf[I(e,i,s.anyOf,r)]),C(e,n,s,r,i)}function C(e,t,r,i,n){let o=r;for(const r in t){if(void 0===p.default(n,[r]))continue;if(o.properties&&!(r in o.properties))continue;const[s,a]=_(r,t);return Array.isArray(a)?o=q(o,a):A(a)&&(o=K(e,o,i,r,a,n)),C(e,s,o,i,n)}return o}function q(e,t){if(!t)return e;const r=Array.isArray(e.required)?Array.from(new Set([...e.required,...t])):t;return{...e,required:r}}function K(e,t,r,i,n,o){const{oneOf:s,...a}=U(e,n,r,o);if(t=F(t,a),void 0===s)return t;const u=s.map((t=>"boolean"!=typeof t&&"$ref"in t?R(e,t,r,o):t));return function(e,t,r,i,n,o){const s=n.filter((t=>{if("boolean"==typeof t||!t||!t.properties)return!1;const{[i]:r}=t.properties;if(r){const t={type:"object",properties:{[i]:r}},{errors:n}=e.validateFormData(o,t);return 0===n.length}return!1}));if(1!==s.length)return console.warn("ignoring oneOf in dependencies because there isn't exactly one subschema that is valid"),t;const a=s[0],[u]=_(i,a.properties),d={...a,properties:u};return F(t,U(e,d,r,o))}(e,t,r,i,u,o)}function k(e,t,r){void 0===r&&(r={});const i=U(e,t,r,void 0),n=i.oneOf||i.anyOf;return!!Array.isArray(i.enum)||!!Array.isArray(n)&&n.every((e=>"boolean"!=typeof e&&N(e)))}function M(e,t,r){return!(!t.uniqueItems||!t.items||"boolean"==typeof t.items)&&k(e,t.items,r)}function L(e,t,r){if(void 0===t&&(t=f.Ignore),void 0===r&&(r=-1),r>=0){if(Array.isArray(e.items)&&r<e.items.length){const t=e.items[r];if("boolean"!=typeof t)return t}}else if(e.items&&!Array.isArray(e.items)&&"boolean"!=typeof e.items)return e.items;return t!==f.Ignore&&A(e.additionalItems)?e.additionalItems:{}}function V(e,t,r,i,n,o){void 0===i&&(i={}),void 0===o&&(o=!1);const s=A(n)?n:{};let a=r;if(A(a)&&A(t.default))a=P(a,t.default);else if("default"in t)a=t.default;else{if("$ref"in t){const r=W(t.$ref,i);return V(e,r,a,i,s,o)}if("dependencies"in t){const r=Y(e,t,i,s);return V(e,r,a,i,s,o)}$(t)?a=t.items.map(((t,n)=>V(e,t,Array.isArray(r)?r[n]:void 0,i,s,o))):"oneOf"in t?t=t.oneOf[I(e,m.default(s)?void 0:s,t.oneOf,i)]:"anyOf"in t&&(t=t.anyOf[I(e,m.default(s)?void 0:s,t.anyOf,i)])}switch(void 0===a&&(a=t.default),D(t)){case"object":return Object.keys(t.properties||{}).reduce(((r,n)=>{const u=V(e,p.default(t,["properties",n]),p.default(a,[n]),i,p.default(s,[n]),"excludeObjectChildren"!==o&&o);return o?r[n]=u:A(u)?m.default(u)||(r[n]=u):void 0!==u&&(r[n]=u),r}),{});case"array":if(Array.isArray(a)&&(a=a.map(((r,n)=>{const o=L(t,f.Fallback,n);return V(e,o,r,i)}))),Array.isArray(n)){const r=L(t);a=n.map(((t,n)=>V(e,r,p.default(a,[n]),i,t)))}if(t.minItems){if(!M(e,t,i)){const r=Array.isArray(a)?a.length:0;if(t.minItems>r){const n=a||[],o=L(t,f.Invert),s=o.default,u=new Array(t.minItems-r).fill(V(e,o,s,i));return n.concat(u)}}return a||[]}}return a}function B(e,t,r,i,n){if(void 0===n&&(n=!1),!A(t))throw new Error("Invalid schema: "+t);const o=V(e,U(e,t,i,r),void 0,i,r,n);return null==r||"number"==typeof r&&isNaN(r)?o:A(r)||Array.isArray(r)?j(o,r):r}function H(e){return void 0===e&&(e={}),"widget"in E(e)&&"hidden"!==E(e).widget}function G(e,t,r,i){if(void 0===r&&(r={}),"files"===r["ui:widget"])return!0;if(t.items){const r=U(e,t.items,i);return"string"===r.type&&"data-url"===r.format}return!1}function J(e,t,r,i){void 0===r&&(r={});const n=E(r),{label:o=!0}=n;let s=!!o;const a=D(t);return"array"===a&&(s=M(e,t,i)||G(e,t,r,i)||H(r)),"object"===a&&(s=!1),"boolean"!==a||r["ui:widget"]||(s=!1),r["ui:field"]&&(s=!1),s}function Q(e,t,r){if(!r)return t;const{errors:i,errorSchema:n}=t;let o=e.toErrorList(r),s=r;return m.default(n)||(s=P(n,r,!0),o=[...i].concat(o)),{errorSchema:s,errors:o}}function z(e,t,r,i,n,o,s){if(void 0===o&&(o="root"),void 0===s&&(s="_"),"$ref"in t||"dependencies"in t||"allOf"in t)return z(e,U(e,t,i,n),r,i,n,o,s);if("items"in t&&!p.default(t,["items","$ref"]))return z(e,p.default(t,"items"),r,i,n,o,s);const a={$id:r||o};if("object"===t.type&&"properties"in t)for(const r in t.properties){const u=p.default(t,["properties",r]),d=a.$id+s+r;a[r]=z(e,A(u)?u:{},d,i,p.default(n,[r]),o,s)}return a}function X(e,t,r,i,n){if(void 0===r&&(r=""),"$ref"in t||"dependencies"in t||"allOf"in t){const o=U(e,t,i,n);return X(e,o,r,i,n)}const o={$name:r.replace(/^\./,"")};if("additionalProperties"in t&&!0===t.additionalProperties&&h.default(o,"__rjsf_additionalProperties",!0),"items"in t&&Array.isArray(n))n.forEach(((n,s)=>{o[s]=X(e,t.items,`${r}.${s}`,i,n)}));else if("properties"in t)for(const s in t.properties){const a=p.default(t,["properties",s]);o[s]=X(e,a,`${r}.${s}`,i,p.default(n,[s]))}return o}!function(e){e[e.Ignore=0]="Ignore",e[e.Invert=1]="Invert",e[e.Fallback=2]="Fallback"}(f||(f={}));class Z{constructor(e,t){this.rootSchema=void 0,this.validator=void 0,this.rootSchema=t,this.validator=e}getValidator(){return this.validator}doesSchemaUtilsDiffer(e,t){return!(!e||!t||this.validator===e&&w(this.rootSchema,t))}getDefaultFormState(e,t,r){return void 0===r&&(r=!1),B(this.validator,e,t,this.rootSchema,r)}getDisplayLabel(e,t){return J(this.validator,e,t,this.rootSchema)}getMatchingOption(e,t){return I(this.validator,e,t,this.rootSchema)}isFilesArray(e,t){return G(this.validator,e,t,this.rootSchema)}isMultiSelect(e){return M(this.validator,e,this.rootSchema)}isSelect(e){return k(this.validator,e,this.rootSchema)}mergeValidationData(e,t){return Q(this.validator,e,t)}retrieveSchema(e,t){return U(this.validator,e,this.rootSchema,t)}toIdSchema(e,t,r,i,n){return void 0===i&&(i="root"),void 0===n&&(n="_"),z(this.validator,e,t,this.rootSchema,r,i,n)}toPathSchema(e,t,r){return X(this.validator,e,t,this.rootSchema,r)}}function ee(e){const t={};return e.multipleOf&&(t.step=e.multipleOf),(e.minimum||0===e.minimum)&&(t.min=e.minimum),(e.maximum||0===e.maximum)&&(t.max=e.maximum),t}const te={props:{disabled:!1},submitText:"Submit",norender:!1},re={boolean:{checkbox:"CheckboxWidget",radio:"RadioWidget",select:"SelectWidget",hidden:"HiddenWidget"},string:{text:"TextWidget",password:"PasswordWidget",email:"EmailWidget",hostname:"TextWidget",ipv4:"TextWidget",ipv6:"TextWidget",uri:"URLWidget","data-url":"FileWidget",radio:"RadioWidget",select:"SelectWidget",textarea:"TextareaWidget",hidden:"HiddenWidget",date:"DateWidget",datetime:"DateTimeWidget","date-time":"DateTimeWidget","alt-date":"AltDateWidget","alt-datetime":"AltDateTimeWidget",color:"ColorWidget",file:"FileWidget"},number:{text:"TextWidget",select:"SelectWidget",updown:"UpDownWidget",range:"RangeWidget",radio:"RadioWidget",hidden:"HiddenWidget"},integer:{text:"TextWidget",select:"SelectWidget",updown:"UpDownWidget",range:"RangeWidget",radio:"RadioWidget",hidden:"HiddenWidget"},array:{select:"SelectWidget",checkboxes:"CheckboxesWidget",files:"FileWidget",hidden:"HiddenWidget"}};function ie(e,t,r){void 0===r&&(r={});const i=D(e);if("function"==typeof t||t&&v.default.isForwardRef(b.default.createElement(t))||v.default.isMemo(t))return function(e){let t=p.default(e,"MergedWidget");if(!t){const r=e.defaultProps&&e.defaultProps.options||{};t=t=>{let{options:i,...n}=t;return b.default.createElement(e,{options:{...r,...i},...n})},h.default(e,"MergedWidget",t)}return t}(t);if("string"!=typeof t)throw new Error("Unsupported widget definition: "+typeof t);if(t in r)return ie(e,r[t],r);if("string"==typeof i){if(!(i in re))throw new Error(`No widget for type '${i}'`);if(t in re[i])return ie(e,r[re[i][t]],r)}throw new Error(`No widget '${t}' for type '${i}'`)}function ne(e){if("enum"in e&&Array.isArray(e.enum)&&1===e.enum.length)return e.enum[0];if("const"in e)return e.const;throw new Error("schema cannot be inferred as a constant")}function oe(e,t){let r=String(e);for(;r.length<t;)r="0"+r;return r}const se=new Set(["number","integer"]);exports.ADDITIONAL_PROPERTIES_KEY="additionalProperties",exports.ADDITIONAL_PROPERTY_FLAG="__additional_property",exports.ALL_OF_KEY="allOf",exports.ANY_OF_KEY="anyOf",exports.CONST_KEY="const",exports.DEFAULT_KEY="default",exports.DEFINITIONS_KEY="definitions",exports.DEPENDENCIES_KEY="dependencies",exports.ENUM_KEY="enum",exports.ERRORS_KEY="__errors",exports.ID_KEY="$id",exports.ITEMS_KEY="items",exports.NAME_KEY="$name",exports.ONE_OF_KEY="oneOf",exports.PROPERTIES_KEY="properties",exports.REF_KEY="$ref",exports.REQUIRED_KEY="required",exports.RJSF_ADDITONAL_PROPERTIES_FLAG="__rjsf_additionalProperties",exports.SUBMIT_BTN_OPTIONS_KEY="submitButtonOptions",exports.UI_FIELD_KEY="ui:field",exports.UI_OPTIONS_KEY="ui:options",exports.UI_WIDGET_KEY="ui:widget",exports.allowAdditionalItems=function(e){return!0===e.additionalItems&&console.warn("additionalItems=true is currently not supported"),A(e.additionalItems)},exports.asNumber=S,exports.canExpand=function(e,t,r){if(void 0===t&&(t={}),!e.additionalProperties)return!1;const{expandable:i=!0}=E(t);return!1===i?i:void 0===e.maxProperties||!r||Object.keys(r).length<e.maxProperties},exports.createSchemaUtils=function(e,t){return new Z(e,t)},exports.dataURItoBlob=function(e){const t=e.split(","),r=t[0].split(";"),i=r[0].replace("data:",""),n=r.filter((e=>"name"===e.split("=")[0]));let o;o=1!==n.length?"unknown":n[0].split("=")[1];const s=atob(t[1]),a=[];for(let e=0;e<s.length;e++)a.push(s.charCodeAt(e));return{blob:new window.Blob([new Uint8Array(a)],{type:i}),name:o}},exports.deepEquals=w,exports.findSchemaDefinition=W,exports.getDefaultFormState=B,exports.getDisplayLabel=J,exports.getInputProps=function(e,t,r,i){void 0===r&&(r={}),void 0===i&&(i=!0);const n={type:t||"text",...ee(e)};return r.inputType?n.type=r.inputType:t||("number"===e.type?(n.type="number",i&&void 0===n.step&&(n.step="any")):"integer"===e.type&&(n.type="number",void 0===n.step&&(n.step=1))),r.autocomplete&&(n.autoComplete=r.autocomplete),n},exports.getMatchingOption=I,exports.getSchemaType=D,exports.getSubmitButtonOptions=function(e){void 0===e&&(e={});const t=E(e);if(t&&t.submitButtonOptions){const e=t.submitButtonOptions;return{...te,...e}}return te},exports.getTemplate=function(e,t,r){void 0===r&&(r={});const{templates:i}=t;return"ButtonTemplates"===e?i[e]:r[e]||i[e]},exports.getUiOptions=E,exports.getWidget=ie,exports.guessType=T,exports.hasWidget=function(e,t,r){void 0===r&&(r={});try{return ie(e,t,r),!0}catch(e){const t=e;if(t.message&&(t.message.startsWith("No widget")||t.message.startsWith("Unsupported widget")))return!1;throw e}},exports.isConstant=N,exports.isCustomWidget=H,exports.isFilesArray=G,exports.isFixedItems=$,exports.isMultiSelect=M,exports.isObject=A,exports.isSelect=k,exports.localToUTC=function(e){return e?new Date(e).toJSON():void 0},exports.mergeDefaultsWithFormData=j,exports.mergeObjects=P,exports.mergeSchemas=F,exports.mergeValidationData=Q,exports.optionsList=function(e){const t=e;if(e.enum)return e.enum.map(((e,r)=>({label:t.enumNames&&t.enumNames[r]||String(e),value:e})));const r=e.oneOf||e.anyOf;return r&&r.map((e=>{const t=e,r=ne(t);return{schema:t,label:t.title||String(r),value:r}}))},exports.orderProperties=function(e,t){if(!Array.isArray(t))return e;const r=e=>e.reduce(((e,t)=>(e[t]=!0,e)),{}),i=r(e),n=t.filter((e=>"*"===e||i[e])),o=r(n),s=e.filter((e=>!o[e])),a=n.indexOf("*");if(-1===a){if(s.length)throw new Error("uiSchema order list does not contain "+((u=s).length>1?`properties '${u.join("', '")}'`:`property '${u[0]}'`));return n}var u;if(a!==n.lastIndexOf("*"))throw new Error("uiSchema order list contains more than one wildcard item");const d=[...n];return d.splice(a,1,...s),d},exports.pad=oe,exports.parseDateString=function(e,t){if(void 0===t&&(t=!0),!e)return{year:-1,month:-1,day:-1,hour:t?-1:0,minute:t?-1:0,second:t?-1:0};const r=new Date(e);if(Number.isNaN(r.getTime()))throw new Error("Unable to parse date "+e);return{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate(),hour:t?r.getUTCHours():0,minute:t?r.getUTCMinutes():0,second:t?r.getUTCSeconds():0}},exports.processSelectValue=function(e,t,r){const{enum:i,type:n,items:o}=e;if(""===t)return r&&void 0!==r.emptyValue?r.emptyValue:void 0;if("array"===n&&o&&se.has(p.default(o,"type")))return t.map(S);if("boolean"===n)return"true"===t;if(se.has(n))return S(t);if(Array.isArray(i)){if(i.every((e=>se.has(T(e)))))return S(t);if(i.every((e=>"boolean"===T(e))))return"true"===t}return t},exports.rangeSpec=ee,exports.retrieveSchema=U,exports.schemaRequiresTrueValue=function e(t){return!!t.const||!(!t.enum||1!==t.enum.length||!0!==t.enum[0])||(t.anyOf&&1===t.anyOf.length?e(t.anyOf[0]):t.oneOf&&1===t.oneOf.length?e(t.oneOf[0]):!!t.allOf&&t.allOf.some((t=>e(t))))},exports.shouldRender=function(e,t,r){const{props:i,state:n}=e;return!w(i,t)||!w(n,r)},exports.toConstant=ne,exports.toDateString=function(e,t){void 0===t&&(t=!0);const{year:r,month:i,day:n,hour:o=0,minute:s=0,second:a=0}=e,u=Date.UTC(r,i-1,n,o,s,a),d=new Date(u).toJSON();return t?d:d.slice(0,10)},exports.toIdSchema=z,exports.toPathSchema=X,exports.utcToLocal=function(e){if(!e)return"";const t=new Date(e);return`${oe(t.getFullYear(),4)}-${oe(t.getMonth()+1,2)}-${oe(t.getDate(),2)}T${oe(t.getHours(),2)}:${oe(t.getMinutes(),2)}:${oe(t.getSeconds(),2)}.${oe(t.getMilliseconds(),3)}`}; | ||
//# sourceMappingURL=utils.cjs.production.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("lodash-es/isEqualWith"),require("lodash-es/get"),require("lodash-es/isEmpty"),require("jsonpointer"),require("lodash-es/omit"),require("lodash-es/set"),require("json-schema-merge-allof"),require("lodash-es/union"),require("react"),require("react-is")):"function"==typeof define&&define.amd?define(["exports","lodash-es/isEqualWith","lodash-es/get","lodash-es/isEmpty","jsonpointer","lodash-es/omit","lodash-es/set","json-schema-merge-allof","lodash-es/union","react","react-is"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@rjsf/utils"]={},e.isEqualWith,e.get,e.isEmpty,e.jsonpointer,e.omit,e.set,e.mergeAllOf,e.union,e.React,e.ReactIs)}(this,(function(e,t,r,i,n,o,a,s,u,d,l){"use strict";function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=f(t),p=f(r),m=f(i),y=f(n),g=f(o),h=f(a),b=f(s),O=f(u),v=f(d),A=f(l);function E(e){return!("undefined"!=typeof File&&e instanceof File||"object"!=typeof e||null===e||Array.isArray(e))}function S(e){if(""===e)return;if(null===e)return null;if(/\.$/.test(e))return e;if(/\.0$/.test(e))return e;if(/\.\d*0$/.test(e))return e;const t=Number(e);return"number"!=typeof t||Number.isNaN(t)?e:t}const w="__additional_property",W="additionalProperties",I="allOf",T="anyOf",_="const",D="default",j="dependencies",N="enum",x="items",P="$name",$="oneOf",R="properties",F="required",U="$ref",Y="__rjsf_additionalProperties",q="ui:widget",C="ui:options";function K(e){return void 0===e&&(e={}),Object.keys(e).filter((e=>0===e.indexOf("ui:"))).reduce(((t,r)=>{const i=e[r];return r===q&&E(i)?(console.error("Setting options via ui:widget object is no longer supported, use ui:options instead"),t):r===C&&E(i)?{...t,...i}:{...t,[r.substring(3)]:i}}),{})}function k(e,t){return c.default(e,t,((e,t)=>{if("function"==typeof e&&"function"==typeof t)return!0}))}function M(e,t){const r=t[e];return[g.default(t,[e]),r]}function L(e,t){void 0===t&&(t={});let r=e||"";if(!r.startsWith("#"))throw new Error(`Could not find a definition for ${e}.`);r=decodeURIComponent(r.substring(1));const i=y.default.get(t,r);if(void 0===i)throw new Error(`Could not find a definition for ${e}.`);if(i.$ref){const[e,r]=M(U,i),n=L(r,t);return Object.keys(e).length>0?{...e,...n}:n}return i}function V(e,t,r,i){if(void 0===t)return 0;for(let n=0;n<r.length;n++){const o=r[n];if(o.properties){const r={anyOf:Object.keys(o.properties).map((e=>({required:[e]})))};let a;if(o.anyOf){const{...e}=o;e.allOf=e.allOf?e.allOf.slice():[],e.allOf.push(r),a=e}else a=Object.assign({},o,r);if(delete a.required,e.isValid(a,t,i))return n}else if(e.isValid(o,t,i))return n}return 0}function B(e){return Array.isArray(e)?"array":"string"==typeof e?"string":null==e?"null":"boolean"==typeof e?"boolean":isNaN(e)?"object"==typeof e?"object":"string":"number"}function H(e){let{type:t}=e;return!t&&e.const?B(e.const):!t&&e.enum?"string":t||!e.properties&&!e.additionalProperties?(Array.isArray(t)&&2===t.length&&t.includes("null")&&(t=t.find((e=>"null"!==e))),t):"object"}function G(e){return Array.isArray(e.items)&&e.items.length>0&&e.items.every((e=>E(e)))}function J(e,t){if(Array.isArray(t)){const r=Array.isArray(e)?e:[];return t.map(((e,t)=>r[t]?J(r[t],e):e))}if(E(t)){const r=Object.assign({},e);return Object.keys(t).reduce(((r,i)=>(r[i]=J(e?p.default(e,i):{},p.default(t,i)),r)),r)}return t}function Q(e,t,r){return void 0===r&&(r=!1),Object.keys(t).reduce(((i,n)=>{const o=e?e[n]:{},a=t[n];return i[n]=e&&n in e&&E(a)?Q(o,a,r):r&&Array.isArray(o)&&Array.isArray(a)?o.concat(a):a,i}),Object.assign({},e))}function z(e){return Array.isArray(e.enum)&&1===e.enum.length||_ in e}function X(e,t){const r=Object.assign({},e);return Object.keys(t).reduce(((r,i)=>{const n=e?e[i]:{},o=t[i];return r[i]=e&&i in e&&E(o)?X(n,o):e&&t&&("object"===H(e)||"object"===H(t))&&i===F&&Array.isArray(n)&&Array.isArray(o)?O.default(n,o):o,r}),r)}function Z(e,t,r,i){const n=L(t.$ref,r),{$ref:o,...a}=t;return ee(e,{...n,...a},r,i)}function ee(e,t,r,i){if(void 0===r&&(r={}),!E(t))return{};let n=function(e,t,r,i){if(void 0===r&&(r={}),U in t)return Z(e,t,r,i);if(j in t){const n=te(e,t,r,i);return ee(e,n,r,i)}return I in t?{...t,allOf:t.allOf.map((t=>ee(e,t,r,i)))}:t}(e,t,r,i);if("if"in t)return function(e,t,r,i){const{if:n,then:o,else:a,...s}=t,u=e.isValid(n,i,r)?o:a;return ee(e,u&&"boolean"!=typeof u?X(s,ee(e,u,r,i)):s,r,i)}(e,t,r,i);const o=i||{};if(n.properties){const t={};Object.entries(n.properties).forEach((i=>{const a=i[0],s=i[1],u=o[a],d=E(u)?u:{},l=ee(e,s,r,d);t[a]=l,s!==l&&n.properties!==t&&(n={...n,properties:t})}))}if(I in t)try{n=b.default({...n,allOf:n.allOf})}catch(e){console.warn("could not merge subschemas in allOf:\n"+e);const{allOf:t,...r}=n;return r}return W in n&&!1!==n.additionalProperties?function(e,t,r,i){const n={...t,properties:{...t.properties}},o=i&&E(i)?i:{};return Object.keys(o).forEach((t=>{if(t in n.properties)return;let i={};i="boolean"!=typeof n.additionalProperties?U in n.additionalProperties?ee(e,{$ref:p.default(n.additionalProperties,[U])},r,o):"type"in n.additionalProperties?{...n.additionalProperties}:{type:B(p.default(o,[t]))}:{type:B(p.default(o,[t]))},n.properties[t]=i,h.default(n.properties,[t,w],!0)})),n}(e,n,r,o):n}function te(e,t,r,i){const{dependencies:n,...o}=t;let a=o;return Array.isArray(a.oneOf)?a=a.oneOf[V(e,i,a.oneOf,r)]:Array.isArray(a.anyOf)&&(a=a.anyOf[V(e,i,a.anyOf,r)]),re(e,n,a,r,i)}function re(e,t,r,i,n){let o=r;for(const r in t){if(void 0===p.default(n,[r]))continue;if(o.properties&&!(r in o.properties))continue;const[a,s]=M(r,t);return Array.isArray(s)?o=ie(o,s):E(s)&&(o=ne(e,o,i,r,s,n)),re(e,a,o,i,n)}return o}function ie(e,t){if(!t)return e;const r=Array.isArray(e.required)?Array.from(new Set([...e.required,...t])):t;return{...e,required:r}}function ne(e,t,r,i,n,o){const{oneOf:a,...s}=ee(e,n,r,o);if(t=X(t,s),void 0===a)return t;const u=a.map((t=>"boolean"!=typeof t&&U in t?Z(e,t,r,o):t));return function(e,t,r,i,n,o){const a=n.filter((t=>{if("boolean"==typeof t||!t||!t.properties)return!1;const{[i]:r}=t.properties;if(r){const t={type:"object",properties:{[i]:r}},{errors:n}=e.validateFormData(o,t);return 0===n.length}return!1}));if(1!==a.length)return console.warn("ignoring oneOf in dependencies because there isn't exactly one subschema that is valid"),t;const s=a[0],[u]=M(i,s.properties),d={...s,properties:u};return X(t,ee(e,d,r,o))}(e,t,r,i,u,o)}function oe(e,t,r){void 0===r&&(r={});const i=ee(e,t,r,void 0),n=i.oneOf||i.anyOf;return!!Array.isArray(i.enum)||!!Array.isArray(n)&&n.every((e=>"boolean"!=typeof e&&z(e)))}function ae(e,t,r){return!(!t.uniqueItems||!t.items||"boolean"==typeof t.items)&&oe(e,t.items,r)}var se;function ue(e,t,r){if(void 0===t&&(t=se.Ignore),void 0===r&&(r=-1),r>=0){if(Array.isArray(e.items)&&r<e.items.length){const t=e.items[r];if("boolean"!=typeof t)return t}}else if(e.items&&!Array.isArray(e.items)&&"boolean"!=typeof e.items)return e.items;return t!==se.Ignore&&E(e.additionalItems)?e.additionalItems:{}}function de(e,t,r,i,n,o){void 0===i&&(i={}),void 0===o&&(o=!1);const a=E(n)?n:{};let s=r;if(E(s)&&E(t.default))s=Q(s,t.default);else if(D in t)s=t.default;else{if(U in t){const r=L(t.$ref,i);return de(e,r,s,i,a,o)}if(j in t){const r=te(e,t,i,a);return de(e,r,s,i,a,o)}G(t)?s=t.items.map(((t,n)=>de(e,t,Array.isArray(r)?r[n]:void 0,i,a,o))):$ in t?t=t.oneOf[V(e,m.default(a)?void 0:a,t.oneOf,i)]:T in t&&(t=t.anyOf[V(e,m.default(a)?void 0:a,t.anyOf,i)])}switch(void 0===s&&(s=t.default),H(t)){case"object":return Object.keys(t.properties||{}).reduce(((r,n)=>{const u=de(e,p.default(t,[R,n]),p.default(s,[n]),i,p.default(a,[n]),o);return(o||void 0!==u)&&(r[n]=u),r}),{});case"array":if(Array.isArray(s)&&(s=s.map(((r,n)=>{const o=ue(t,se.Fallback,n);return de(e,o,r,i)}))),Array.isArray(n)){const r=ue(t);s=n.map(((t,n)=>de(e,r,p.default(s,[n]),i,t)))}if(t.minItems){if(!ae(e,t,i)){const r=Array.isArray(s)?s.length:0;if(t.minItems>r){const n=s||[],o=ue(t,se.Invert),a=o.default,u=new Array(t.minItems-r).fill(de(e,o,a,i));return n.concat(u)}}return s||[]}}return s}function le(e,t,r,i,n){if(void 0===n&&(n=!1),!E(t))throw new Error("Invalid schema: "+t);const o=de(e,ee(e,t,i,r),void 0,i,r,n);return null==r||"number"==typeof r&&isNaN(r)?o:E(r)||Array.isArray(r)?J(o,r):r}function fe(e){return void 0===e&&(e={}),"widget"in K(e)&&"hidden"!==K(e).widget}function ce(e,t,r,i){if(void 0===r&&(r={}),"files"===r["ui:widget"])return!0;if(t.items){const r=ee(e,t.items,i);return"string"===r.type&&"data-url"===r.format}return!1}function pe(e,t,r,i){void 0===r&&(r={});const n=K(r),{label:o=!0}=n;let a=!!o;const s=H(t);return"array"===s&&(a=ae(e,t,i)||ce(e,t,r,i)||fe(r)),"object"===s&&(a=!1),"boolean"!==s||r["ui:widget"]||(a=!1),r["ui:field"]&&(a=!1),a}function me(e,t,r){if(!r)return t;const{errors:i,errorSchema:n}=t;let o=e.toErrorList(r),a=r;return m.default(n)||(a=Q(n,r,!0),o=[...i].concat(o)),{errorSchema:a,errors:o}}function ye(e,t,r,i,n,o,a){if(void 0===o&&(o="root"),void 0===a&&(a="_"),U in t||j in t||I in t)return ye(e,ee(e,t,i,n),r,i,n,o,a);if(x in t&&!p.default(t,[x,U]))return ye(e,p.default(t,x),r,i,n,o,a);const s={$id:r||o};if("object"===t.type&&R in t)for(const r in t.properties){const u=p.default(t,[R,r]),d=s.$id+a+r;s[r]=ye(e,E(u)?u:{},d,i,p.default(n,[r]),o,a)}return s}function ge(e,t,r,i,n){if(void 0===r&&(r=""),U in t||j in t||I in t){const o=ee(e,t,i,n);return ge(e,o,r,i,n)}const o={[P]:r.replace(/^\./,"")};if(W in t&&!0===t.additionalProperties&&h.default(o,Y,!0),x in t&&Array.isArray(n))n.forEach(((n,a)=>{o[a]=ge(e,t.items,`${r}.${a}`,i,n)}));else if(R in t)for(const a in t.properties){const s=p.default(t,[R,a]);o[a]=ge(e,s,`${r}.${a}`,i,p.default(n,[a]))}return o}!function(e){e[e.Ignore=0]="Ignore",e[e.Invert=1]="Invert",e[e.Fallback=2]="Fallback"}(se||(se={}));class he{constructor(e,t){this.rootSchema=void 0,this.validator=void 0,this.rootSchema=t,this.validator=e}getValidator(){return this.validator}doesSchemaUtilsDiffer(e,t){return!(!e||!t||this.validator===e&&k(this.rootSchema,t))}getDefaultFormState(e,t,r){return void 0===r&&(r=!1),le(this.validator,e,t,this.rootSchema,r)}getDisplayLabel(e,t){return pe(this.validator,e,t,this.rootSchema)}getMatchingOption(e,t){return V(this.validator,e,t,this.rootSchema)}isFilesArray(e,t){return ce(this.validator,e,t,this.rootSchema)}isMultiSelect(e){return ae(this.validator,e,this.rootSchema)}isSelect(e){return oe(this.validator,e,this.rootSchema)}mergeValidationData(e,t){return me(this.validator,e,t)}retrieveSchema(e,t){return ee(this.validator,e,this.rootSchema,t)}toIdSchema(e,t,r,i,n){return void 0===i&&(i="root"),void 0===n&&(n="_"),ye(this.validator,e,t,this.rootSchema,r,i,n)}toPathSchema(e,t,r){return ge(this.validator,e,t,this.rootSchema,r)}}function be(e){const t={};return e.multipleOf&&(t.step=e.multipleOf),(e.minimum||0===e.minimum)&&(t.min=e.minimum),(e.maximum||0===e.maximum)&&(t.max=e.maximum),t}const Oe={props:{disabled:!1},submitText:"Submit",norender:!1},ve={boolean:{checkbox:"CheckboxWidget",radio:"RadioWidget",select:"SelectWidget",hidden:"HiddenWidget"},string:{text:"TextWidget",password:"PasswordWidget",email:"EmailWidget",hostname:"TextWidget",ipv4:"TextWidget",ipv6:"TextWidget",uri:"URLWidget","data-url":"FileWidget",radio:"RadioWidget",select:"SelectWidget",textarea:"TextareaWidget",hidden:"HiddenWidget",date:"DateWidget",datetime:"DateTimeWidget","date-time":"DateTimeWidget","alt-date":"AltDateWidget","alt-datetime":"AltDateTimeWidget",color:"ColorWidget",file:"FileWidget"},number:{text:"TextWidget",select:"SelectWidget",updown:"UpDownWidget",range:"RangeWidget",radio:"RadioWidget",hidden:"HiddenWidget"},integer:{text:"TextWidget",select:"SelectWidget",updown:"UpDownWidget",range:"RangeWidget",radio:"RadioWidget",hidden:"HiddenWidget"},array:{select:"SelectWidget",checkboxes:"CheckboxesWidget",files:"FileWidget",hidden:"HiddenWidget"}};function Ae(e,t,r){void 0===r&&(r={});const i=H(e);if("function"==typeof t||t&&A.default.isForwardRef(v.default.createElement(t))||A.default.isMemo(t))return function(e){let t=p.default(e,"MergedWidget");if(!t){const r=e.defaultProps&&e.defaultProps.options||{};t=t=>{let{options:i,...n}=t;return v.default.createElement(e,{options:{...r,...i},...n})},h.default(e,"MergedWidget",t)}return t}(t);if("string"!=typeof t)throw new Error("Unsupported widget definition: "+typeof t);if(t in r)return Ae(e,r[t],r);if("string"==typeof i){if(!(i in ve))throw new Error(`No widget for type '${i}'`);if(t in ve[i])return Ae(e,r[ve[i][t]],r)}throw new Error(`No widget '${t}' for type '${i}'`)}function Ee(e){if(N in e&&Array.isArray(e.enum)&&1===e.enum.length)return e.enum[0];if(_ in e)return e.const;throw new Error("schema cannot be inferred as a constant")}function Se(e,t){let r=String(e);for(;r.length<t;)r="0"+r;return r}const we=new Set(["number","integer"]);e.ADDITIONAL_PROPERTIES_KEY=W,e.ADDITIONAL_PROPERTY_FLAG=w,e.ALL_OF_KEY=I,e.ANY_OF_KEY=T,e.CONST_KEY=_,e.DEFAULT_KEY=D,e.DEFINITIONS_KEY="definitions",e.DEPENDENCIES_KEY=j,e.ENUM_KEY=N,e.ERRORS_KEY="__errors",e.ID_KEY="$id",e.ITEMS_KEY=x,e.NAME_KEY=P,e.ONE_OF_KEY=$,e.PROPERTIES_KEY=R,e.REF_KEY=U,e.REQUIRED_KEY=F,e.RJSF_ADDITONAL_PROPERTIES_FLAG=Y,e.SUBMIT_BTN_OPTIONS_KEY="submitButtonOptions",e.UI_FIELD_KEY="ui:field",e.UI_OPTIONS_KEY=C,e.UI_WIDGET_KEY=q,e.allowAdditionalItems=function(e){return!0===e.additionalItems&&console.warn("additionalItems=true is currently not supported"),E(e.additionalItems)},e.asNumber=S,e.canExpand=function(e,t,r){if(void 0===t&&(t={}),!e.additionalProperties)return!1;const{expandable:i=!0}=K(t);return!1===i?i:void 0===e.maxProperties||!r||Object.keys(r).length<e.maxProperties},e.createSchemaUtils=function(e,t){return new he(e,t)},e.dataURItoBlob=function(e){const t=e.split(","),r=t[0].split(";"),i=r[0].replace("data:",""),n=r.filter((e=>"name"===e.split("=")[0]));let o;o=1!==n.length?"unknown":n[0].split("=")[1];const a=atob(t[1]),s=[];for(let e=0;e<a.length;e++)s.push(a.charCodeAt(e));return{blob:new window.Blob([new Uint8Array(s)],{type:i}),name:o}},e.deepEquals=k,e.findSchemaDefinition=L,e.getDefaultFormState=le,e.getDisplayLabel=pe,e.getInputProps=function(e,t,r,i){void 0===r&&(r={}),void 0===i&&(i=!0);const n={type:t||"text",...be(e)};return r.inputType?n.type=r.inputType:t||("number"===e.type?(n.type="number",i&&void 0===n.step&&(n.step="any")):"integer"===e.type&&(n.type="number",void 0===n.step&&(n.step=1))),r.autocomplete&&(n.autoComplete=r.autocomplete),n},e.getMatchingOption=V,e.getSchemaType=H,e.getSubmitButtonOptions=function(e){void 0===e&&(e={});const t=K(e);if(t&&t.submitButtonOptions){const e=t.submitButtonOptions;return{...Oe,...e}}return Oe},e.getTemplate=function(e,t,r){void 0===r&&(r={});const{templates:i}=t;return"ButtonTemplates"===e?i[e]:r[e]||i[e]},e.getUiOptions=K,e.getWidget=Ae,e.guessType=B,e.hasWidget=function(e,t,r){void 0===r&&(r={});try{return Ae(e,t,r),!0}catch(e){const t=e;if(t.message&&(t.message.startsWith("No widget")||t.message.startsWith("Unsupported widget")))return!1;throw e}},e.isConstant=z,e.isCustomWidget=fe,e.isFilesArray=ce,e.isFixedItems=G,e.isMultiSelect=ae,e.isObject=E,e.isSelect=oe,e.localToUTC=function(e){return e?new Date(e).toJSON():void 0},e.mergeDefaultsWithFormData=J,e.mergeObjects=Q,e.mergeSchemas=X,e.mergeValidationData=me,e.optionsList=function(e){const t=e;if(e.enum)return e.enum.map(((e,r)=>({label:t.enumNames&&t.enumNames[r]||String(e),value:e})));const r=e.oneOf||e.anyOf;return r&&r.map((e=>{const t=e,r=Ee(t);return{schema:t,label:t.title||String(r),value:r}}))},e.orderProperties=function(e,t){if(!Array.isArray(t))return e;const r=e=>e.reduce(((e,t)=>(e[t]=!0,e)),{}),i=r(e),n=t.filter((e=>"*"===e||i[e])),o=r(n),a=e.filter((e=>!o[e])),s=n.indexOf("*");if(-1===s){if(a.length)throw new Error("uiSchema order list does not contain "+((u=a).length>1?`properties '${u.join("', '")}'`:`property '${u[0]}'`));return n}var u;if(s!==n.lastIndexOf("*"))throw new Error("uiSchema order list contains more than one wildcard item");const d=[...n];return d.splice(s,1,...a),d},e.pad=Se,e.parseDateString=function(e,t){if(void 0===t&&(t=!0),!e)return{year:-1,month:-1,day:-1,hour:t?-1:0,minute:t?-1:0,second:t?-1:0};const r=new Date(e);if(Number.isNaN(r.getTime()))throw new Error("Unable to parse date "+e);return{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate(),hour:t?r.getUTCHours():0,minute:t?r.getUTCMinutes():0,second:t?r.getUTCSeconds():0}},e.processSelectValue=function(e,t,r){const{enum:i,type:n,items:o}=e;if(""===t)return r&&void 0!==r.emptyValue?r.emptyValue:void 0;if("array"===n&&o&&we.has(p.default(o,"type")))return t.map(S);if("boolean"===n)return"true"===t;if(we.has(n))return S(t);if(Array.isArray(i)){if(i.every((e=>we.has(B(e)))))return S(t);if(i.every((e=>"boolean"===B(e))))return"true"===t}return t},e.rangeSpec=be,e.retrieveSchema=ee,e.schemaRequiresTrueValue=function e(t){return!!t.const||!(!t.enum||1!==t.enum.length||!0!==t.enum[0])||(t.anyOf&&1===t.anyOf.length?e(t.anyOf[0]):t.oneOf&&1===t.oneOf.length?e(t.oneOf[0]):!!t.allOf&&t.allOf.some((t=>e(t))))},e.shouldRender=function(e,t,r){const{props:i,state:n}=e;return!k(i,t)||!k(n,r)},e.toConstant=Ee,e.toDateString=function(e,t){void 0===t&&(t=!0);const{year:r,month:i,day:n,hour:o=0,minute:a=0,second:s=0}=e,u=Date.UTC(r,i-1,n,o,a,s),d=new Date(u).toJSON();return t?d:d.slice(0,10)},e.toIdSchema=ye,e.toPathSchema=ge,e.utcToLocal=function(e){if(!e)return"";const t=new Date(e);return`${Se(t.getFullYear(),4)}-${Se(t.getMonth()+1,2)}-${Se(t.getDate(),2)}T${Se(t.getHours(),2)}:${Se(t.getMinutes(),2)}:${Se(t.getSeconds(),2)}.${Se(t.getMilliseconds(),3)}`},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("lodash-es/isEqualWith"),require("lodash-es/get"),require("lodash-es/isEmpty"),require("jsonpointer"),require("lodash-es/omit"),require("lodash-es/set"),require("json-schema-merge-allof"),require("lodash-es/union"),require("react"),require("react-is")):"function"==typeof define&&define.amd?define(["exports","lodash-es/isEqualWith","lodash-es/get","lodash-es/isEmpty","jsonpointer","lodash-es/omit","lodash-es/set","json-schema-merge-allof","lodash-es/union","react","react-is"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@rjsf/utils"]={},e.isEqualWith,e.get,e.isEmpty,e.jsonpointer,e.omit,e.set,e.mergeAllOf,e.union,e.React,e.ReactIs)}(this,(function(e,t,r,i,n,o,a,s,u,d,l){"use strict";function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=f(t),p=f(r),m=f(i),y=f(n),g=f(o),h=f(a),b=f(s),O=f(u),v=f(d),A=f(l);function E(e){return!("undefined"!=typeof File&&e instanceof File||"object"!=typeof e||null===e||Array.isArray(e))}function S(e){if(""===e)return;if(null===e)return null;if(/\.$/.test(e))return e;if(/\.0$/.test(e))return e;if(/\.\d*0$/.test(e))return e;const t=Number(e);return"number"!=typeof t||Number.isNaN(t)?e:t}const w="__additional_property",W="additionalProperties",I="allOf",T="anyOf",_="const",D="default",j="dependencies",x="enum",N="items",P="$name",$="oneOf",R="properties",F="required",U="$ref",Y="__rjsf_additionalProperties",q="ui:widget",C="ui:options";function K(e){return void 0===e&&(e={}),Object.keys(e).filter((e=>0===e.indexOf("ui:"))).reduce(((t,r)=>{const i=e[r];return r===q&&E(i)?(console.error("Setting options via ui:widget object is no longer supported, use ui:options instead"),t):r===C&&E(i)?{...t,...i}:{...t,[r.substring(3)]:i}}),{})}function k(e,t){return c.default(e,t,((e,t)=>{if("function"==typeof e&&"function"==typeof t)return!0}))}function M(e,t){const r=t[e];return[g.default(t,[e]),r]}function L(e,t){void 0===t&&(t={});let r=e||"";if(!r.startsWith("#"))throw new Error(`Could not find a definition for ${e}.`);r=decodeURIComponent(r.substring(1));const i=y.default.get(t,r);if(void 0===i)throw new Error(`Could not find a definition for ${e}.`);if(i.$ref){const[e,r]=M(U,i),n=L(r,t);return Object.keys(e).length>0?{...e,...n}:n}return i}function V(e,t,r,i){if(void 0===t)return 0;for(let n=0;n<r.length;n++){const o=r[n];if(o.properties){const r={anyOf:Object.keys(o.properties).map((e=>({required:[e]})))};let a;if(o.anyOf){const{...e}=o;e.allOf=e.allOf?e.allOf.slice():[],e.allOf.push(r),a=e}else a=Object.assign({},o,r);if(delete a.required,e.isValid(a,t,i))return n}else if(e.isValid(o,t,i))return n}return 0}function B(e){return Array.isArray(e)?"array":"string"==typeof e?"string":null==e?"null":"boolean"==typeof e?"boolean":isNaN(e)?"object"==typeof e?"object":"string":"number"}function H(e){let{type:t}=e;return!t&&e.const?B(e.const):!t&&e.enum?"string":t||!e.properties&&!e.additionalProperties?(Array.isArray(t)&&2===t.length&&t.includes("null")&&(t=t.find((e=>"null"!==e))),t):"object"}function G(e){return Array.isArray(e.items)&&e.items.length>0&&e.items.every((e=>E(e)))}function J(e,t){if(Array.isArray(t)){const r=Array.isArray(e)?e:[];return t.map(((e,t)=>r[t]?J(r[t],e):e))}if(E(t)){const r=Object.assign({},e);return Object.keys(t).reduce(((r,i)=>(r[i]=J(e?p.default(e,i):{},p.default(t,i)),r)),r)}return t}function Q(e,t,r){return void 0===r&&(r=!1),Object.keys(t).reduce(((i,n)=>{const o=e?e[n]:{},a=t[n];if(e&&n in e&&E(a))i[n]=Q(o,a,r);else if(r&&Array.isArray(o)&&Array.isArray(a)){let e=a;"preventDuplicates"===r&&(e=a.reduce(((e,t)=>(o.includes(t)||e.push(t),e)),[])),i[n]=o.concat(e)}else i[n]=a;return i}),Object.assign({},e))}function z(e){return Array.isArray(e.enum)&&1===e.enum.length||_ in e}function X(e,t){const r=Object.assign({},e);return Object.keys(t).reduce(((r,i)=>{const n=e?e[i]:{},o=t[i];return r[i]=e&&i in e&&E(o)?X(n,o):e&&t&&("object"===H(e)||"object"===H(t))&&i===F&&Array.isArray(n)&&Array.isArray(o)?O.default(n,o):o,r}),r)}function Z(e,t,r,i){const n=L(t.$ref,r),{$ref:o,...a}=t;return ee(e,{...n,...a},r,i)}function ee(e,t,r,i){if(void 0===r&&(r={}),!E(t))return{};let n=function(e,t,r,i){if(void 0===r&&(r={}),U in t)return Z(e,t,r,i);if(j in t){const n=te(e,t,r,i);return ee(e,n,r,i)}return I in t?{...t,allOf:t.allOf.map((t=>ee(e,t,r,i)))}:t}(e,t,r,i);if("if"in t)return function(e,t,r,i){const{if:n,then:o,else:a,...s}=t,u=e.isValid(n,i,r)?o:a;return ee(e,u&&"boolean"!=typeof u?X(s,ee(e,u,r,i)):s,r,i)}(e,t,r,i);const o=i||{};if(n.properties){const t={};Object.entries(n.properties).forEach((i=>{const a=i[0],s=i[1],u=o[a],d=E(u)?u:{},l=ee(e,s,r,d);t[a]=l,s!==l&&n.properties!==t&&(n={...n,properties:t})}))}if(I in t)try{n=b.default({...n,allOf:n.allOf})}catch(e){console.warn("could not merge subschemas in allOf:\n"+e);const{allOf:t,...r}=n;return r}return W in n&&!1!==n.additionalProperties?function(e,t,r,i){const n={...t,properties:{...t.properties}},o=i&&E(i)?i:{};return Object.keys(o).forEach((t=>{if(t in n.properties)return;let i={};i="boolean"!=typeof n.additionalProperties?U in n.additionalProperties?ee(e,{$ref:p.default(n.additionalProperties,[U])},r,o):"type"in n.additionalProperties?{...n.additionalProperties}:{type:B(p.default(o,[t]))}:{type:B(p.default(o,[t]))},n.properties[t]=i,h.default(n.properties,[t,w],!0)})),n}(e,n,r,o):n}function te(e,t,r,i){const{dependencies:n,...o}=t;let a=o;return Array.isArray(a.oneOf)?a=a.oneOf[V(e,i,a.oneOf,r)]:Array.isArray(a.anyOf)&&(a=a.anyOf[V(e,i,a.anyOf,r)]),re(e,n,a,r,i)}function re(e,t,r,i,n){let o=r;for(const r in t){if(void 0===p.default(n,[r]))continue;if(o.properties&&!(r in o.properties))continue;const[a,s]=M(r,t);return Array.isArray(s)?o=ie(o,s):E(s)&&(o=ne(e,o,i,r,s,n)),re(e,a,o,i,n)}return o}function ie(e,t){if(!t)return e;const r=Array.isArray(e.required)?Array.from(new Set([...e.required,...t])):t;return{...e,required:r}}function ne(e,t,r,i,n,o){const{oneOf:a,...s}=ee(e,n,r,o);if(t=X(t,s),void 0===a)return t;const u=a.map((t=>"boolean"!=typeof t&&U in t?Z(e,t,r,o):t));return function(e,t,r,i,n,o){const a=n.filter((t=>{if("boolean"==typeof t||!t||!t.properties)return!1;const{[i]:r}=t.properties;if(r){const t={type:"object",properties:{[i]:r}},{errors:n}=e.validateFormData(o,t);return 0===n.length}return!1}));if(1!==a.length)return console.warn("ignoring oneOf in dependencies because there isn't exactly one subschema that is valid"),t;const s=a[0],[u]=M(i,s.properties),d={...s,properties:u};return X(t,ee(e,d,r,o))}(e,t,r,i,u,o)}function oe(e,t,r){void 0===r&&(r={});const i=ee(e,t,r,void 0),n=i.oneOf||i.anyOf;return!!Array.isArray(i.enum)||!!Array.isArray(n)&&n.every((e=>"boolean"!=typeof e&&z(e)))}function ae(e,t,r){return!(!t.uniqueItems||!t.items||"boolean"==typeof t.items)&&oe(e,t.items,r)}var se;function ue(e,t,r){if(void 0===t&&(t=se.Ignore),void 0===r&&(r=-1),r>=0){if(Array.isArray(e.items)&&r<e.items.length){const t=e.items[r];if("boolean"!=typeof t)return t}}else if(e.items&&!Array.isArray(e.items)&&"boolean"!=typeof e.items)return e.items;return t!==se.Ignore&&E(e.additionalItems)?e.additionalItems:{}}function de(e,t,r,i,n,o){void 0===i&&(i={}),void 0===o&&(o=!1);const a=E(n)?n:{};let s=r;if(E(s)&&E(t.default))s=Q(s,t.default);else if(D in t)s=t.default;else{if(U in t){const r=L(t.$ref,i);return de(e,r,s,i,a,o)}if(j in t){const r=te(e,t,i,a);return de(e,r,s,i,a,o)}G(t)?s=t.items.map(((t,n)=>de(e,t,Array.isArray(r)?r[n]:void 0,i,a,o))):$ in t?t=t.oneOf[V(e,m.default(a)?void 0:a,t.oneOf,i)]:T in t&&(t=t.anyOf[V(e,m.default(a)?void 0:a,t.anyOf,i)])}switch(void 0===s&&(s=t.default),H(t)){case"object":return Object.keys(t.properties||{}).reduce(((r,n)=>{const u=de(e,p.default(t,[R,n]),p.default(s,[n]),i,p.default(a,[n]),"excludeObjectChildren"!==o&&o);return o?r[n]=u:E(u)?m.default(u)||(r[n]=u):void 0!==u&&(r[n]=u),r}),{});case"array":if(Array.isArray(s)&&(s=s.map(((r,n)=>{const o=ue(t,se.Fallback,n);return de(e,o,r,i)}))),Array.isArray(n)){const r=ue(t);s=n.map(((t,n)=>de(e,r,p.default(s,[n]),i,t)))}if(t.minItems){if(!ae(e,t,i)){const r=Array.isArray(s)?s.length:0;if(t.minItems>r){const n=s||[],o=ue(t,se.Invert),a=o.default,u=new Array(t.minItems-r).fill(de(e,o,a,i));return n.concat(u)}}return s||[]}}return s}function le(e,t,r,i,n){if(void 0===n&&(n=!1),!E(t))throw new Error("Invalid schema: "+t);const o=de(e,ee(e,t,i,r),void 0,i,r,n);return null==r||"number"==typeof r&&isNaN(r)?o:E(r)||Array.isArray(r)?J(o,r):r}function fe(e){return void 0===e&&(e={}),"widget"in K(e)&&"hidden"!==K(e).widget}function ce(e,t,r,i){if(void 0===r&&(r={}),"files"===r["ui:widget"])return!0;if(t.items){const r=ee(e,t.items,i);return"string"===r.type&&"data-url"===r.format}return!1}function pe(e,t,r,i){void 0===r&&(r={});const n=K(r),{label:o=!0}=n;let a=!!o;const s=H(t);return"array"===s&&(a=ae(e,t,i)||ce(e,t,r,i)||fe(r)),"object"===s&&(a=!1),"boolean"!==s||r["ui:widget"]||(a=!1),r["ui:field"]&&(a=!1),a}function me(e,t,r){if(!r)return t;const{errors:i,errorSchema:n}=t;let o=e.toErrorList(r),a=r;return m.default(n)||(a=Q(n,r,!0),o=[...i].concat(o)),{errorSchema:a,errors:o}}function ye(e,t,r,i,n,o,a){if(void 0===o&&(o="root"),void 0===a&&(a="_"),U in t||j in t||I in t)return ye(e,ee(e,t,i,n),r,i,n,o,a);if(N in t&&!p.default(t,[N,U]))return ye(e,p.default(t,N),r,i,n,o,a);const s={$id:r||o};if("object"===t.type&&R in t)for(const r in t.properties){const u=p.default(t,[R,r]),d=s.$id+a+r;s[r]=ye(e,E(u)?u:{},d,i,p.default(n,[r]),o,a)}return s}function ge(e,t,r,i,n){if(void 0===r&&(r=""),U in t||j in t||I in t){const o=ee(e,t,i,n);return ge(e,o,r,i,n)}const o={[P]:r.replace(/^\./,"")};if(W in t&&!0===t.additionalProperties&&h.default(o,Y,!0),N in t&&Array.isArray(n))n.forEach(((n,a)=>{o[a]=ge(e,t.items,`${r}.${a}`,i,n)}));else if(R in t)for(const a in t.properties){const s=p.default(t,[R,a]);o[a]=ge(e,s,`${r}.${a}`,i,p.default(n,[a]))}return o}!function(e){e[e.Ignore=0]="Ignore",e[e.Invert=1]="Invert",e[e.Fallback=2]="Fallback"}(se||(se={}));class he{constructor(e,t){this.rootSchema=void 0,this.validator=void 0,this.rootSchema=t,this.validator=e}getValidator(){return this.validator}doesSchemaUtilsDiffer(e,t){return!(!e||!t||this.validator===e&&k(this.rootSchema,t))}getDefaultFormState(e,t,r){return void 0===r&&(r=!1),le(this.validator,e,t,this.rootSchema,r)}getDisplayLabel(e,t){return pe(this.validator,e,t,this.rootSchema)}getMatchingOption(e,t){return V(this.validator,e,t,this.rootSchema)}isFilesArray(e,t){return ce(this.validator,e,t,this.rootSchema)}isMultiSelect(e){return ae(this.validator,e,this.rootSchema)}isSelect(e){return oe(this.validator,e,this.rootSchema)}mergeValidationData(e,t){return me(this.validator,e,t)}retrieveSchema(e,t){return ee(this.validator,e,this.rootSchema,t)}toIdSchema(e,t,r,i,n){return void 0===i&&(i="root"),void 0===n&&(n="_"),ye(this.validator,e,t,this.rootSchema,r,i,n)}toPathSchema(e,t,r){return ge(this.validator,e,t,this.rootSchema,r)}}function be(e){const t={};return e.multipleOf&&(t.step=e.multipleOf),(e.minimum||0===e.minimum)&&(t.min=e.minimum),(e.maximum||0===e.maximum)&&(t.max=e.maximum),t}const Oe={props:{disabled:!1},submitText:"Submit",norender:!1},ve={boolean:{checkbox:"CheckboxWidget",radio:"RadioWidget",select:"SelectWidget",hidden:"HiddenWidget"},string:{text:"TextWidget",password:"PasswordWidget",email:"EmailWidget",hostname:"TextWidget",ipv4:"TextWidget",ipv6:"TextWidget",uri:"URLWidget","data-url":"FileWidget",radio:"RadioWidget",select:"SelectWidget",textarea:"TextareaWidget",hidden:"HiddenWidget",date:"DateWidget",datetime:"DateTimeWidget","date-time":"DateTimeWidget","alt-date":"AltDateWidget","alt-datetime":"AltDateTimeWidget",color:"ColorWidget",file:"FileWidget"},number:{text:"TextWidget",select:"SelectWidget",updown:"UpDownWidget",range:"RangeWidget",radio:"RadioWidget",hidden:"HiddenWidget"},integer:{text:"TextWidget",select:"SelectWidget",updown:"UpDownWidget",range:"RangeWidget",radio:"RadioWidget",hidden:"HiddenWidget"},array:{select:"SelectWidget",checkboxes:"CheckboxesWidget",files:"FileWidget",hidden:"HiddenWidget"}};function Ae(e,t,r){void 0===r&&(r={});const i=H(e);if("function"==typeof t||t&&A.default.isForwardRef(v.default.createElement(t))||A.default.isMemo(t))return function(e){let t=p.default(e,"MergedWidget");if(!t){const r=e.defaultProps&&e.defaultProps.options||{};t=t=>{let{options:i,...n}=t;return v.default.createElement(e,{options:{...r,...i},...n})},h.default(e,"MergedWidget",t)}return t}(t);if("string"!=typeof t)throw new Error("Unsupported widget definition: "+typeof t);if(t in r)return Ae(e,r[t],r);if("string"==typeof i){if(!(i in ve))throw new Error(`No widget for type '${i}'`);if(t in ve[i])return Ae(e,r[ve[i][t]],r)}throw new Error(`No widget '${t}' for type '${i}'`)}function Ee(e){if(x in e&&Array.isArray(e.enum)&&1===e.enum.length)return e.enum[0];if(_ in e)return e.const;throw new Error("schema cannot be inferred as a constant")}function Se(e,t){let r=String(e);for(;r.length<t;)r="0"+r;return r}const we=new Set(["number","integer"]);e.ADDITIONAL_PROPERTIES_KEY=W,e.ADDITIONAL_PROPERTY_FLAG=w,e.ALL_OF_KEY=I,e.ANY_OF_KEY=T,e.CONST_KEY=_,e.DEFAULT_KEY=D,e.DEFINITIONS_KEY="definitions",e.DEPENDENCIES_KEY=j,e.ENUM_KEY=x,e.ERRORS_KEY="__errors",e.ID_KEY="$id",e.ITEMS_KEY=N,e.NAME_KEY=P,e.ONE_OF_KEY=$,e.PROPERTIES_KEY=R,e.REF_KEY=U,e.REQUIRED_KEY=F,e.RJSF_ADDITONAL_PROPERTIES_FLAG=Y,e.SUBMIT_BTN_OPTIONS_KEY="submitButtonOptions",e.UI_FIELD_KEY="ui:field",e.UI_OPTIONS_KEY=C,e.UI_WIDGET_KEY=q,e.allowAdditionalItems=function(e){return!0===e.additionalItems&&console.warn("additionalItems=true is currently not supported"),E(e.additionalItems)},e.asNumber=S,e.canExpand=function(e,t,r){if(void 0===t&&(t={}),!e.additionalProperties)return!1;const{expandable:i=!0}=K(t);return!1===i?i:void 0===e.maxProperties||!r||Object.keys(r).length<e.maxProperties},e.createSchemaUtils=function(e,t){return new he(e,t)},e.dataURItoBlob=function(e){const t=e.split(","),r=t[0].split(";"),i=r[0].replace("data:",""),n=r.filter((e=>"name"===e.split("=")[0]));let o;o=1!==n.length?"unknown":n[0].split("=")[1];const a=atob(t[1]),s=[];for(let e=0;e<a.length;e++)s.push(a.charCodeAt(e));return{blob:new window.Blob([new Uint8Array(s)],{type:i}),name:o}},e.deepEquals=k,e.findSchemaDefinition=L,e.getDefaultFormState=le,e.getDisplayLabel=pe,e.getInputProps=function(e,t,r,i){void 0===r&&(r={}),void 0===i&&(i=!0);const n={type:t||"text",...be(e)};return r.inputType?n.type=r.inputType:t||("number"===e.type?(n.type="number",i&&void 0===n.step&&(n.step="any")):"integer"===e.type&&(n.type="number",void 0===n.step&&(n.step=1))),r.autocomplete&&(n.autoComplete=r.autocomplete),n},e.getMatchingOption=V,e.getSchemaType=H,e.getSubmitButtonOptions=function(e){void 0===e&&(e={});const t=K(e);if(t&&t.submitButtonOptions){const e=t.submitButtonOptions;return{...Oe,...e}}return Oe},e.getTemplate=function(e,t,r){void 0===r&&(r={});const{templates:i}=t;return"ButtonTemplates"===e?i[e]:r[e]||i[e]},e.getUiOptions=K,e.getWidget=Ae,e.guessType=B,e.hasWidget=function(e,t,r){void 0===r&&(r={});try{return Ae(e,t,r),!0}catch(e){const t=e;if(t.message&&(t.message.startsWith("No widget")||t.message.startsWith("Unsupported widget")))return!1;throw e}},e.isConstant=z,e.isCustomWidget=fe,e.isFilesArray=ce,e.isFixedItems=G,e.isMultiSelect=ae,e.isObject=E,e.isSelect=oe,e.localToUTC=function(e){return e?new Date(e).toJSON():void 0},e.mergeDefaultsWithFormData=J,e.mergeObjects=Q,e.mergeSchemas=X,e.mergeValidationData=me,e.optionsList=function(e){const t=e;if(e.enum)return e.enum.map(((e,r)=>({label:t.enumNames&&t.enumNames[r]||String(e),value:e})));const r=e.oneOf||e.anyOf;return r&&r.map((e=>{const t=e,r=Ee(t);return{schema:t,label:t.title||String(r),value:r}}))},e.orderProperties=function(e,t){if(!Array.isArray(t))return e;const r=e=>e.reduce(((e,t)=>(e[t]=!0,e)),{}),i=r(e),n=t.filter((e=>"*"===e||i[e])),o=r(n),a=e.filter((e=>!o[e])),s=n.indexOf("*");if(-1===s){if(a.length)throw new Error("uiSchema order list does not contain "+((u=a).length>1?`properties '${u.join("', '")}'`:`property '${u[0]}'`));return n}var u;if(s!==n.lastIndexOf("*"))throw new Error("uiSchema order list contains more than one wildcard item");const d=[...n];return d.splice(s,1,...a),d},e.pad=Se,e.parseDateString=function(e,t){if(void 0===t&&(t=!0),!e)return{year:-1,month:-1,day:-1,hour:t?-1:0,minute:t?-1:0,second:t?-1:0};const r=new Date(e);if(Number.isNaN(r.getTime()))throw new Error("Unable to parse date "+e);return{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate(),hour:t?r.getUTCHours():0,minute:t?r.getUTCMinutes():0,second:t?r.getUTCSeconds():0}},e.processSelectValue=function(e,t,r){const{enum:i,type:n,items:o}=e;if(""===t)return r&&void 0!==r.emptyValue?r.emptyValue:void 0;if("array"===n&&o&&we.has(p.default(o,"type")))return t.map(S);if("boolean"===n)return"true"===t;if(we.has(n))return S(t);if(Array.isArray(i)){if(i.every((e=>we.has(B(e)))))return S(t);if(i.every((e=>"boolean"===B(e))))return"true"===t}return t},e.rangeSpec=be,e.retrieveSchema=ee,e.schemaRequiresTrueValue=function e(t){return!!t.const||!(!t.enum||1!==t.enum.length||!0!==t.enum[0])||(t.anyOf&&1===t.anyOf.length?e(t.anyOf[0]):t.oneOf&&1===t.oneOf.length?e(t.oneOf[0]):!!t.allOf&&t.allOf.some((t=>e(t))))},e.shouldRender=function(e,t,r){const{props:i,state:n}=e;return!k(i,t)||!k(n,r)},e.toConstant=Ee,e.toDateString=function(e,t){void 0===t&&(t=!0);const{year:r,month:i,day:n,hour:o=0,minute:a=0,second:s=0}=e,u=Date.UTC(r,i-1,n,o,a,s),d=new Date(u).toJSON();return t?d:d.slice(0,10)},e.toIdSchema=ye,e.toPathSchema=ge,e.utcToLocal=function(e){if(!e)return"";const t=new Date(e);return`${Se(t.getFullYear(),4)}-${Se(t.getMonth()+1,2)}-${Se(t.getDate(),2)}T${Se(t.getHours(),2)}:${Se(t.getMinutes(),2)}:${Se(t.getSeconds(),2)}.${Se(t.getMilliseconds(),3)}`},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=utils.umd.production.min.js.map |
{ | ||
"name": "@rjsf/utils", | ||
"version": "5.0.0-beta.13", | ||
"version": "5.0.0-beta.14", | ||
"main": "dist/index.js", | ||
@@ -78,3 +78,3 @@ "module": "dist/utils.esm.js", | ||
"license": "Apache-2.0", | ||
"gitHead": "c06ccc2d11f998a3df74d3104e768f3dfeb3212d" | ||
"gitHead": "a0f9a938e4551a42d5c94f8673b13b937279cdc5" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1116927
7270