@abgov/ui-components-common 1.4.0 → 1.5.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +38 -1
- package/index.d.ts +1 -0
- package/index.js +1595 -180
- package/lib/use-public-form-controller.d.ts +15 -0
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -1 +1,38 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var yt=Object.defineProperty;var st=f=>{throw TypeError(f)};var gt=(f,n,i)=>n in f?yt(f,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):f[n]=i;var ae=(f,n,i)=>gt(f,typeof n!="symbol"?n+"":n,i),Et=(f,n,i)=>n.has(f)||st("Cannot "+i);var it=(f,n,i)=>n.has(f)?st("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(f):n.set(f,i);var at=(f,n,i)=>(Et(f,n,"access private method"),i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class _t{constructor(n){ae(this,"validators");this.validators=n||{}}add(n,...i){this.validators[n]=i}validate(n){const i={};return Object.entries(this.validators).forEach(([d,v])=>{const m=v.map(b=>b(n[d])).find(b=>!!b);m&&(i[d]=m)}),i}}function bt(){return[Se("Day is required"),Ne({min:1,max:31,minMsg:"Day must be between 1 and 31",maxMsg:"Day must be between 1 and 31"})]}function wt(){return[Se("Month is required"),Ne({min:0,max:11,minMsg:"Month must be between Jan and Dec",maxMsg:"Month must be between Jan and Dec"})]}function Ct(){const f=new Date().getFullYear();return[Se("Year is required"),Ne({min:1900,max:f,minMsg:"Year must be greater than 1900",maxMsg:`Year must be less than ${f}`})]}function Se(f){return n=>(f=f||"Required",typeof n=="number"&&!isNaN(n)||n?"":f)}function Rt(f){const n=new RegExp(/^\+?[\d-() ]{10,18}$/);return je(n,f||"Invalid phone number")}function Tt(f){const n=new RegExp(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);return je(n,f||"Invalid email address")}function At(){return f=>{if(!f)return"";const n="121212121".split("").map(v=>parseInt(v)),i=f.replace(/\D/g,"");return i.length!==9?"SIN must contain 9 numbers":i.split("").map(v=>parseInt(v)).map((v,m)=>{const b=v*n[m];return b<10?b:`${b}`.split("").map(k=>parseInt(k)).reduce((k,P)=>k+P,0)}).reduce((v,m)=>v+m,0)%10===0?"":"Invalid SIN"}}function Ot(){return je(/^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ -]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,"Invalid postal code")}function je(f,n){return i=>!i||i.match(f)?"":n}function St({invalidMsg:f,minMsg:n,maxMsg:i,min:d,max:v}={}){return m=>{let b=new Date(-1);return`${m||""}`.length===0?"":(typeof m=="string"&&(b=new Date(m)),typeof m=="number"&&(b=new Date(m)),m.toDateString&&(b=m),b.getDate()===-1?f||"Invalid date":d&&b<d?n||`Must be after ${d}`:v&&b>v?i||`Must be before ${v}`:"")}}function Ne({invalidTypeMsg:f,minMsg:n,maxMsg:i,min:d=-Number.MAX_VALUE,max:v=Number.MAX_VALUE}={}){return m=>{let b=Number.MAX_VALUE;return`${m??""}`.length===0?"":(typeof m=="string"&&(b=parseFloat(m)),typeof m=="number"&&(b=m),isNaN(b)?f||"Must be a numeric value":b>v?i||`Must be less than or equal to ${v}`:b<d?n||`Must be greater than or equal to ${d}`:"")}}function jt({invalidTypeMsg:f,minMsg:n,maxMsg:i,min:d=-Number.MAX_VALUE,max:v=Number.MAX_VALUE}){return m=>`${m||""}`.length===0?"":typeof m!="string"?f||"Invalid type":m.length>v?i||`Must be less than ${v} characters`:m.length<d?n||`Must be greater than ${d} characters`:""}var le,Nt,dt;class lt{constructor(n){it(this,le);ae(this,"state");ae(this,"_formData");ae(this,"_formRef");this.type=n}init(n){if(this._formRef){console.warn("init: form element has already been set");return}this._formRef=n.el,this.state={uuid:crypto.randomUUID(),form:{},history:[],editting:"",status:"not-started"}}initList(n){this._formRef=n.detail.el,this.state=[]}initState(n,i){ce(this._formRef,"external::init:state",n),typeof n=="string"?this.state=JSON.parse(n):Array.isArray(n)||(this.state=n),i&&setTimeout(i,200)}updateListState(n){const i=n.detail;Array.isArray(i.data)&&(this.state=i.data)}updateObjectState(n){var d,v;if(Array.isArray(this.state))return;const i=n.detail;i.type==="list"?this.state={...this.state,form:{...((d=this.state)==null?void 0:d.form)||{},[i.id]:i.data}}:this.state={...this.state,...i.data,form:{...((v=this.state)==null?void 0:v.form)||{},...i.data.form},history:i.data.history}}getStateList(){return this.state?Array.isArray(this.state)?this.state.length===0?[]:this.state.map(n=>Object.values(n.form).filter(i=>{var d;return((d=i==null?void 0:i.data)==null?void 0:d.type)==="details"}).map(i=>{var d;return i.data.type==="details"&&((d=i.data)==null?void 0:d.fieldsets)||{}}).reduce((i,d)=>{for(const[v,m]of Object.entries(d))i[v]=m.value;return i},{})):(console.warn("Utils:getStateList: unable to update the state of a non-multi form type",this.state),[]):[]}getStateValue(n,i){if(Array.isArray(this.state))return console.error("getStateValue: unable to update the state of a multi form type"),"";if(!this.state)return console.error("getStateValue: state has not yet been set"),"";const d=this.state.form[n].data;return d.type!=="details"?"":d.fieldsets[i].value}continueTo(n){if(!n){console.error("continueTo [name] is undefined");return}ce(this._formRef,"external::continue",{next:n})}validate(n,i,d,v){var L;const{el:m,state:b,cancelled:k}=n,P=(L=b==null?void 0:b[i])==null?void 0:L.value;if(window.scrollTo({top:0,behavior:"smooth"}),k)return[!0,P];for(const M of d){const R=M(P);if(at(this,le,dt).call(this,m,i,R,v),R)return[!1,""]}return[!0,P]}validateGroup(n,i,d){let v=0;const m={};for(const b of i){const[k]=this.validate(n,b,d,{grouped:!0});k&&(m[b]=!0,v++)}return[v,m]}edit(n){ce(this._formRef,"external::alter:state",{index:n,operation:"edit"})}remove(n){ce(this._formRef,"external::alter:state",{index:n,operation:"remove"})}clean(n){return n.history.reduce((i,d)=>(i[d]=n.form[d],i),{})}}le=new WeakSet,Nt=function(n){var i;Array.isArray(n.data)&&(Array.isArray(this.state)||(this.state={...this.state,form:{...((i=this.state)==null?void 0:i.form)||{},[n.id]:n.data}}))},dt=function(n,i,d,v){n.dispatchEvent(new CustomEvent("msg",{composed:!0,detail:{action:"external::set:error",data:{name:i,msg:d,grouped:v==null?void 0:v.grouped}}}))};function kt(f,n,i,d){if(!f){console.error("dispatch element is null");return}f.dispatchEvent(new CustomEvent(n,{composed:!0,bubbles:d==null?void 0:d.bubbles,detail:i}))}function ce(f,n,i,d){if(!f){console.error("dispatch element is null");return}f.dispatchEvent(new CustomEvent("msg",{composed:!0,bubbles:d==null?void 0:d.bubbles,detail:{action:n,data:i}}))}var Ve={exports:{}},y={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var ct;function Mt(){if(ct)return y;ct=1;var f=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),d=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),m=Symbol.for("react.consumer"),b=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),L=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),R=Symbol.iterator;function N(r){return r===null||typeof r!="object"?null:(r=R&&r[R]||r["@@iterator"],typeof r=="function"?r:null)}var Y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},K=Object.assign,D={};function x(r,u,p){this.props=r,this.context=u,this.refs=D,this.updater=p||Y}x.prototype.isReactComponent={},x.prototype.setState=function(r,u){if(typeof r!="object"&&typeof r!="function"&&r!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,r,u,"setState")},x.prototype.forceUpdate=function(r){this.updater.enqueueForceUpdate(this,r,"forceUpdate")};function Z(){}Z.prototype=x.prototype;function G(r,u,p){this.props=r,this.context=u,this.refs=D,this.updater=p||Y}var J=G.prototype=new Z;J.constructor=G,K(J,x.prototype),J.isPureReactComponent=!0;var de=Array.isArray,T={H:null,A:null,T:null,S:null},F=Object.prototype.hasOwnProperty;function re(r,u,p,h,_,A){return p=A.ref,{$$typeof:f,type:r,key:u,ref:p!==void 0?p:null,props:A}}function pe(r,u){return re(r.type,u,void 0,void 0,void 0,r.props)}function U(r){return typeof r=="object"&&r!==null&&r.$$typeof===f}function he(r){var u={"=":"=0",":":"=2"};return"$"+r.replace(/[=:]/g,function(p){return u[p]})}var me=/\/+/g;function ne(r,u){return typeof r=="object"&&r!==null&&r.key!=null?he(""+r.key):u.toString(36)}function ee(){}function ve(r){switch(r.status){case"fulfilled":return r.value;case"rejected":throw r.reason;default:switch(typeof r.status=="string"?r.then(ee,ee):(r.status="pending",r.then(function(u){r.status==="pending"&&(r.status="fulfilled",r.value=u)},function(u){r.status==="pending"&&(r.status="rejected",r.reason=u)})),r.status){case"fulfilled":return r.value;case"rejected":throw r.reason}}throw r}function B(r,u,p,h,_){var A=typeof r;(A==="undefined"||A==="boolean")&&(r=null);var g=!1;if(r===null)g=!0;else switch(A){case"bigint":case"string":case"number":g=!0;break;case"object":switch(r.$$typeof){case f:case n:g=!0;break;case M:return g=r._init,B(g(r._payload),u,p,h,_)}}if(g)return _=_(r),g=h===""?"."+ne(r,0):h,de(_)?(p="",g!=null&&(p=g.replace(me,"$&/")+"/"),B(_,u,p,"",function(oe){return oe})):_!=null&&(U(_)&&(_=pe(_,p+(_.key==null||r&&r.key===_.key?"":(""+_.key).replace(me,"$&/")+"/")+g)),u.push(_)),1;g=0;var V=h===""?".":h+":";if(de(r))for(var O=0;O<r.length;O++)h=r[O],A=V+ne(h,O),g+=B(h,u,p,A,_);else if(O=N(r),typeof O=="function")for(r=O.call(r),O=0;!(h=r.next()).done;)h=h.value,A=V+ne(h,O++),g+=B(h,u,p,A,_);else if(A==="object"){if(typeof r.then=="function")return B(ve(r),u,p,h,_);throw u=String(r),Error("Objects are not valid as a React child (found: "+(u==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":u)+"). If you meant to render a collection of children, use an array instead.")}return g}function H(r,u,p){if(r==null)return r;var h=[],_=0;return B(r,h,"","",function(A){return u.call(p,A,_++)}),h}function te(r){if(r._status===-1){var u=r._result;u=u(),u.then(function(p){(r._status===0||r._status===-1)&&(r._status=1,r._result=p)},function(p){(r._status===0||r._status===-1)&&(r._status=2,r._result=p)}),r._status===-1&&(r._status=0,r._result=u)}if(r._status===1)return r._result.default;throw r._result}var ye=typeof reportError=="function"?reportError:function(r){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var u=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof r=="object"&&r!==null&&typeof r.message=="string"?String(r.message):String(r),error:r});if(!window.dispatchEvent(u))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",r);return}console.error(r)};function j(){}return y.Children={map:H,forEach:function(r,u,p){H(r,function(){u.apply(this,arguments)},p)},count:function(r){var u=0;return H(r,function(){u++}),u},toArray:function(r){return H(r,function(u){return u})||[]},only:function(r){if(!U(r))throw Error("React.Children.only expected to receive a single React element child.");return r}},y.Component=x,y.Fragment=i,y.Profiler=v,y.PureComponent=G,y.StrictMode=d,y.Suspense=P,y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,y.act=function(){throw Error("act(...) is not supported in production builds of React.")},y.cache=function(r){return function(){return r.apply(null,arguments)}},y.cloneElement=function(r,u,p){if(r==null)throw Error("The argument must be a React element, but you passed "+r+".");var h=K({},r.props),_=r.key,A=void 0;if(u!=null)for(g in u.ref!==void 0&&(A=void 0),u.key!==void 0&&(_=""+u.key),u)!F.call(u,g)||g==="key"||g==="__self"||g==="__source"||g==="ref"&&u.ref===void 0||(h[g]=u[g]);var g=arguments.length-2;if(g===1)h.children=p;else if(1<g){for(var V=Array(g),O=0;O<g;O++)V[O]=arguments[O+2];h.children=V}return re(r.type,_,void 0,void 0,A,h)},y.createContext=function(r){return r={$$typeof:b,_currentValue:r,_currentValue2:r,_threadCount:0,Provider:null,Consumer:null},r.Provider=r,r.Consumer={$$typeof:m,_context:r},r},y.createElement=function(r,u,p){var h,_={},A=null;if(u!=null)for(h in u.key!==void 0&&(A=""+u.key),u)F.call(u,h)&&h!=="key"&&h!=="__self"&&h!=="__source"&&(_[h]=u[h]);var g=arguments.length-2;if(g===1)_.children=p;else if(1<g){for(var V=Array(g),O=0;O<g;O++)V[O]=arguments[O+2];_.children=V}if(r&&r.defaultProps)for(h in g=r.defaultProps,g)_[h]===void 0&&(_[h]=g[h]);return re(r,A,void 0,void 0,null,_)},y.createRef=function(){return{current:null}},y.forwardRef=function(r){return{$$typeof:k,render:r}},y.isValidElement=U,y.lazy=function(r){return{$$typeof:M,_payload:{_status:-1,_result:r},_init:te}},y.memo=function(r,u){return{$$typeof:L,type:r,compare:u===void 0?null:u}},y.startTransition=function(r){var u=T.T,p={};T.T=p;try{var h=r(),_=T.S;_!==null&&_(p,h),typeof h=="object"&&h!==null&&typeof h.then=="function"&&h.then(j,ye)}catch(A){ye(A)}finally{T.T=u}},y.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},y.use=function(r){return T.H.use(r)},y.useActionState=function(r,u,p){return T.H.useActionState(r,u,p)},y.useCallback=function(r,u){return T.H.useCallback(r,u)},y.useContext=function(r){return T.H.useContext(r)},y.useDebugValue=function(){},y.useDeferredValue=function(r,u){return T.H.useDeferredValue(r,u)},y.useEffect=function(r,u){return T.H.useEffect(r,u)},y.useId=function(){return T.H.useId()},y.useImperativeHandle=function(r,u,p){return T.H.useImperativeHandle(r,u,p)},y.useInsertionEffect=function(r,u){return T.H.useInsertionEffect(r,u)},y.useLayoutEffect=function(r,u){return T.H.useLayoutEffect(r,u)},y.useMemo=function(r,u){return T.H.useMemo(r,u)},y.useOptimistic=function(r,u){return T.H.useOptimistic(r,u)},y.useReducer=function(r,u,p){return T.H.useReducer(r,u,p)},y.useRef=function(r){return T.H.useRef(r)},y.useState=function(r){return T.H.useState(r)},y.useSyncExternalStore=function(r,u,p){return T.H.useSyncExternalStore(r,u,p)},y.useTransition=function(){return T.H.useTransition()},y.version="19.0.0",y}var fe={exports:{}};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/fe.exports;var ft;function $t(){return ft||(ft=1,function(f,n){process.env.NODE_ENV!=="production"&&function(){function i(e,t){Object.defineProperty(m.prototype,e,{get:function(){console.warn("%s(...) is deprecated in plain JavaScript React classes. %s",t[0],t[1])}})}function d(e){return e===null||typeof e!="object"?null:(e=De&&e[De]||e["@@iterator"],typeof e=="function"?e:null)}function v(e,t){e=(e=e.constructor)&&(e.displayName||e.name)||"ReactClass";var o=e+"."+t;Ie[o]||(console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",t,e),Ie[o]=!0)}function m(e,t,o){this.props=e,this.context=t,this.refs=Pe,this.updater=o||qe}function b(){}function k(e,t,o){this.props=e,this.context=t,this.refs=Pe,this.updater=o||qe}function P(e){return""+e}function L(e){try{P(e);var t=!1}catch{t=!0}if(t){t=console;var o=t.error,s=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return o.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",s),P(e)}}function M(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ht?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case O:return"Fragment";case V:return"Portal";case ke:return"Profiler";case oe:return"StrictMode";case _e:return"Suspense";case $e:return"SuspenseList"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case Me:return(e.displayName||"Context")+".Provider";case ge:return(e._context.displayName||"Context")+".Consumer";case Ee:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ue:return t=e.displayName||null,t!==null?t:M(e.type)||"Memo";case se:t=e._payload,e=e._init;try{return M(e(t))}catch{}}return null}function R(e){return typeof e=="string"||typeof e=="function"||e===O||e===ke||e===oe||e===_e||e===$e||e===pt||typeof e=="object"&&e!==null&&(e.$$typeof===se||e.$$typeof===ue||e.$$typeof===Me||e.$$typeof===ge||e.$$typeof===Ee||e.$$typeof===mt||e.getModuleId!==void 0)}function N(){}function Y(){if(ie===0){xe=console.log,We=console.info,ze=console.warn,Ge=console.error,Be=console.group,Ke=console.groupCollapsed,Xe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:N,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}ie++}function K(){if(ie--,ie===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:W({},e,{value:xe}),info:W({},e,{value:We}),warn:W({},e,{value:ze}),error:W({},e,{value:Ge}),group:W({},e,{value:Be}),groupCollapsed:W({},e,{value:Ke}),groupEnd:W({},e,{value:Xe})})}0>ie&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}function D(e){if(Ye===void 0)try{throw Error()}catch(o){var t=o.stack.trim().match(/\n( *(at )?)/);Ye=t&&t[1]||"",Qe=-1<o.stack.indexOf(`
|
|
18
|
+
at`)?" (<anonymous>)":-1<o.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
19
|
+
`+Ye+e+Qe}function x(e,t){if(!e||Le)return"";var o=Ue.get(e);if(o!==void 0)return o;Le=!0,o=Error.prepareStackTrace,Error.prepareStackTrace=void 0;var s=null;s=E.H,E.H=null,Y();try{var a={DetermineComponentFrameRoot:function(){try{if(t){var I=function(){throw Error()};if(Object.defineProperty(I.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(I,[])}catch(z){var Oe=z}Reflect.construct(e,[],I)}else{try{I.call()}catch(z){Oe=z}e.call(I.prototype)}}else{try{throw Error()}catch(z){Oe=z}(I=e())&&typeof I.catch=="function"&&I.catch(function(){})}}catch(z){if(z&&Oe&&typeof z.stack=="string")return[z.stack,Oe.stack]}return[null,null]}};a.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var l=Object.getOwnPropertyDescriptor(a.DetermineComponentFrameRoot,"name");l&&l.configurable&&Object.defineProperty(a.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var c=a.DetermineComponentFrameRoot(),C=c[0],w=c[1];if(C&&w){var S=C.split(`
|
|
20
|
+
`),$=w.split(`
|
|
21
|
+
`);for(c=l=0;l<S.length&&!S[l].includes("DetermineComponentFrameRoot");)l++;for(;c<$.length&&!$[c].includes("DetermineComponentFrameRoot");)c++;if(l===S.length||c===$.length)for(l=S.length-1,c=$.length-1;1<=l&&0<=c&&S[l]!==$[c];)c--;for(;1<=l&&0<=c;l--,c--)if(S[l]!==$[c]){if(l!==1||c!==1)do if(l--,c--,0>c||S[l]!==$[c]){var Q=`
|
|
22
|
+
`+S[l].replace(" at new "," at ");return e.displayName&&Q.includes("<anonymous>")&&(Q=Q.replace("<anonymous>",e.displayName)),typeof e=="function"&&Ue.set(e,Q),Q}while(1<=l&&0<=c);break}}}finally{Le=!1,E.H=s,K(),Error.prepareStackTrace=o}return S=(S=e?e.displayName||e.name:"")?D(S):"",typeof e=="function"&&Ue.set(e,S),S}function Z(e){if(e==null)return"";if(typeof e=="function"){var t=e.prototype;return x(e,!(!t||!t.isReactComponent))}if(typeof e=="string")return D(e);switch(e){case _e:return D("Suspense");case $e:return D("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case Ee:return e=x(e.render,!1),e;case ue:return Z(e.type);case se:t=e._payload,e=e._init;try{return Z(e(t))}catch{}}return""}function G(){var e=E.A;return e===null?null:e.getOwner()}function J(e){if(Ce.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function de(e,t){function o(){Ze||(Ze=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}o.isReactWarning=!0,Object.defineProperty(e,"key",{get:o,configurable:!0})}function T(){var e=M(this.type);return Fe[e]||(Fe[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function F(e,t,o,s,a,l){return o=l.ref,e={$$typeof:g,type:e,key:t,props:l,_owner:a},(o!==void 0?o:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:T}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function re(e,t){return t=F(e.type,t,void 0,void 0,e._owner,e.props),t._store.validated=e._store.validated,t}function pe(e,t){if(typeof e=="object"&&e&&e.$$typeof!==vt){if(we(e))for(var o=0;o<e.length;o++){var s=e[o];U(s)&&he(s,t)}else if(U(e))e._store&&(e._store.validated=1);else if(o=d(e),typeof o=="function"&&o!==e.entries&&(o=o.call(e),o!==e))for(;!(e=o.next()).done;)U(e.value)&&he(e.value,t)}}function U(e){return typeof e=="object"&&e!==null&&e.$$typeof===g}function he(e,t){if(e._store&&!e._store.validated&&e.key==null&&(e._store.validated=1,t=me(t),!et[t])){et[t]=!0;var o="";e&&e._owner!=null&&e._owner!==G()&&(o=null,typeof e._owner.tag=="number"?o=M(e._owner.type):typeof e._owner.name=="string"&&(o=e._owner.name),o=" It was passed a child from "+o+".");var s=E.getCurrentStack;E.getCurrentStack=function(){var a=Z(e.type);return s&&(a+=s()||""),a},console.error('Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',t,o),E.getCurrentStack=s}}function me(e){var t="",o=G();return o&&(o=M(o.type))&&(t=`
|
|
23
|
+
|
|
24
|
+
Check the render method of \``+o+"`."),t||(e=M(e))&&(t=`
|
|
25
|
+
|
|
26
|
+
Check the top-level render call using <`+e+">."),t}function ne(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(o){return t[o]})}function ee(e,t){return typeof e=="object"&&e!==null&&e.key!=null?(L(e.key),ne(""+e.key)):t.toString(36)}function ve(){}function B(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(ve,ve):(e.status="pending",e.then(function(t){e.status==="pending"&&(e.status="fulfilled",e.value=t)},function(t){e.status==="pending"&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}function H(e,t,o,s,a){var l=typeof e;(l==="undefined"||l==="boolean")&&(e=null);var c=!1;if(e===null)c=!0;else switch(l){case"bigint":case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case g:case V:c=!0;break;case se:return c=e._init,H(c(e._payload),t,o,s,a)}}if(c){c=e,a=a(c);var C=s===""?"."+ee(c,0):s;return we(a)?(o="",C!=null&&(o=C.replace(rt,"$&/")+"/"),H(a,t,o,"",function(S){return S})):a!=null&&(U(a)&&(a.key!=null&&(c&&c.key===a.key||L(a.key)),o=re(a,o+(a.key==null||c&&c.key===a.key?"":(""+a.key).replace(rt,"$&/")+"/")+C),s!==""&&c!=null&&U(c)&&c.key==null&&c._store&&!c._store.validated&&(o._store.validated=2),a=o),t.push(a)),1}if(c=0,C=s===""?".":s+":",we(e))for(var w=0;w<e.length;w++)s=e[w],l=C+ee(s,w),c+=H(s,t,o,l,a);else if(w=d(e),typeof w=="function")for(w===e.entries&&(tt||console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),tt=!0),e=w.call(e),w=0;!(s=e.next()).done;)s=s.value,l=C+ee(s,w++),c+=H(s,t,o,l,a);else if(l==="object"){if(typeof e.then=="function")return H(B(e),t,o,s,a);throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return c}function te(e,t,o){if(e==null)return e;var s=[],a=0;return H(e,s,"","",function(l){return t.call(o,l,a++)}),s}function ye(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(o){(e._status===0||e._status===-1)&&(e._status=1,e._result=o)},function(o){(e._status===0||e._status===-1)&&(e._status=2,e._result=o)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return t=e._result,t===void 0&&console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
27
|
+
|
|
28
|
+
Your code should look like:
|
|
29
|
+
const MyComponent = lazy(() => import('./MyComponent'))
|
|
30
|
+
|
|
31
|
+
Did you accidentally put curly braces around the import?`,t),"default"in t||console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
32
|
+
|
|
33
|
+
Your code should look like:
|
|
34
|
+
const MyComponent = lazy(() => import('./MyComponent'))`,t),t.default;throw e._result}function j(){var e=E.H;return e===null&&console.error(`Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
|
|
35
|
+
1. You might have mismatching versions of React and the renderer (such as React DOM)
|
|
36
|
+
2. You might be breaking the Rules of Hooks
|
|
37
|
+
3. You might have more than one copy of React in the same app
|
|
38
|
+
See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),e}function r(){}function u(e){if(Re===null)try{var t=("require"+Math.random()).slice(0,7);Re=(f&&f[t]).call(f,"timers").setImmediate}catch{Re=function(s){ot===!1&&(ot=!0,typeof MessageChannel>"u"&&console.error("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."));var a=new MessageChannel;a.port1.onmessage=s,a.port2.postMessage(void 0)}}return Re(e)}function p(e){return 1<e.length&&typeof AggregateError=="function"?new AggregateError(e):e[0]}function h(e,t){t!==Te-1&&console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "),Te=t}function _(e,t,o){var s=E.actQueue;if(s!==null)if(s.length!==0)try{A(s),u(function(){return _(e,t,o)});return}catch(a){E.thrownErrors.push(a)}else E.actQueue=null;0<E.thrownErrors.length?(s=p(E.thrownErrors),E.thrownErrors.length=0,o(s)):t(e)}function A(e){if(!He){He=!0;var t=0;try{for(;t<e.length;t++){var o=e[t];do{E.didUsePromise=!1;var s=o(!1);if(s!==null){if(E.didUsePromise){e[t]=o,e.splice(0,t);return}o=s}else break}while(!0)}e.length=0}catch(a){e.splice(0,t+1),E.thrownErrors.push(a)}finally{He=!1}}}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var g=Symbol.for("react.transitional.element"),V=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),oe=Symbol.for("react.strict_mode"),ke=Symbol.for("react.profiler"),ge=Symbol.for("react.consumer"),Me=Symbol.for("react.context"),Ee=Symbol.for("react.forward_ref"),_e=Symbol.for("react.suspense"),$e=Symbol.for("react.suspense_list"),ue=Symbol.for("react.memo"),se=Symbol.for("react.lazy"),pt=Symbol.for("react.offscreen"),De=Symbol.iterator,Ie={},qe={isMounted:function(){return!1},enqueueForceUpdate:function(e){v(e,"forceUpdate")},enqueueReplaceState:function(e){v(e,"replaceState")},enqueueSetState:function(e){v(e,"setState")}},W=Object.assign,Pe={};Object.freeze(Pe),m.prototype.isReactComponent={},m.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},m.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};var X={isMounted:["isMounted","Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],replaceState:["replaceState","Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]},be;for(be in X)X.hasOwnProperty(be)&&i(be,X[be]);b.prototype=m.prototype,X=k.prototype=new b,X.constructor=k,W(X,m.prototype),X.isPureReactComponent=!0;var we=Array.isArray,ht=Symbol.for("react.client.reference"),E={H:null,A:null,T:null,S:null,actQueue:null,isBatchingLegacy:!1,didScheduleLegacyUpdate:!1,didUsePromise:!1,thrownErrors:[],getCurrentStack:null},Ce=Object.prototype.hasOwnProperty,mt=Symbol.for("react.client.reference"),ie=0,xe,We,ze,Ge,Be,Ke,Xe;N.__reactDisabledLog=!0;var Ye,Qe,Le=!1,Ue=new(typeof WeakMap=="function"?WeakMap:Map),vt=Symbol.for("react.client.reference"),Ze,Je,Fe={},et={},tt=!1,rt=/\/+/g,nt=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},ot=!1,Re=null,Te=0,Ae=!1,He=!1,ut=typeof queueMicrotask=="function"?function(e){queueMicrotask(function(){return queueMicrotask(e)})}:u;n.Children={map:te,forEach:function(e,t,o){te(e,function(){t.apply(this,arguments)},o)},count:function(e){var t=0;return te(e,function(){t++}),t},toArray:function(e){return te(e,function(t){return t})||[]},only:function(e){if(!U(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},n.Component=m,n.Fragment=O,n.Profiler=ke,n.PureComponent=k,n.StrictMode=oe,n.Suspense=_e,n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=E,n.act=function(e){var t=E.actQueue,o=Te;Te++;var s=E.actQueue=t!==null?t:[],a=!1;try{var l=e()}catch(w){E.thrownErrors.push(w)}if(0<E.thrownErrors.length)throw h(t,o),e=p(E.thrownErrors),E.thrownErrors.length=0,e;if(l!==null&&typeof l=="object"&&typeof l.then=="function"){var c=l;return ut(function(){a||Ae||(Ae=!0,console.error("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"))}),{then:function(w,S){a=!0,c.then(function($){if(h(t,o),o===0){try{A(s),u(function(){return _($,w,S)})}catch(I){E.thrownErrors.push(I)}if(0<E.thrownErrors.length){var Q=p(E.thrownErrors);E.thrownErrors.length=0,S(Q)}}else w($)},function($){h(t,o),0<E.thrownErrors.length&&($=p(E.thrownErrors),E.thrownErrors.length=0),S($)})}}}var C=l;if(h(t,o),o===0&&(A(s),s.length!==0&&ut(function(){a||Ae||(Ae=!0,console.error("A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"))}),E.actQueue=null),0<E.thrownErrors.length)throw e=p(E.thrownErrors),E.thrownErrors.length=0,e;return{then:function(w,S){a=!0,o===0?(E.actQueue=s,u(function(){return _(C,w,S)})):w(C)}}},n.cache=function(e){return function(){return e.apply(null,arguments)}},n.cloneElement=function(e,t,o){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var s=W({},e.props),a=e.key,l=e._owner;if(t!=null){var c;e:{if(Ce.call(t,"ref")&&(c=Object.getOwnPropertyDescriptor(t,"ref").get)&&c.isReactWarning){c=!1;break e}c=t.ref!==void 0}c&&(l=G()),J(t)&&(L(t.key),a=""+t.key);for(C in t)!Ce.call(t,C)||C==="key"||C==="__self"||C==="__source"||C==="ref"&&t.ref===void 0||(s[C]=t[C])}var C=arguments.length-2;if(C===1)s.children=o;else if(1<C){c=Array(C);for(var w=0;w<C;w++)c[w]=arguments[w+2];s.children=c}for(s=F(e.type,a,void 0,void 0,l,s),a=2;a<arguments.length;a++)pe(arguments[a],s.type);return s},n.createContext=function(e){return e={$$typeof:Me,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:ge,_context:e},e._currentRenderer=null,e._currentRenderer2=null,e},n.createElement=function(e,t,o){if(R(e))for(var s=2;s<arguments.length;s++)pe(arguments[s],e);else{if(s="",(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(s+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),e===null)var a="null";else we(e)?a="array":e!==void 0&&e.$$typeof===g?(a="<"+(M(e.type)||"Unknown")+" />",s=" Did you accidentally export a JSX literal instead of a component?"):a=typeof e;console.error("React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",a,s)}var l;if(s={},a=null,t!=null)for(l in Je||!("__self"in t)||"key"in t||(Je=!0,console.warn("Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform")),J(t)&&(L(t.key),a=""+t.key),t)Ce.call(t,l)&&l!=="key"&&l!=="__self"&&l!=="__source"&&(s[l]=t[l]);var c=arguments.length-2;if(c===1)s.children=o;else if(1<c){for(var C=Array(c),w=0;w<c;w++)C[w]=arguments[w+2];Object.freeze&&Object.freeze(C),s.children=C}if(e&&e.defaultProps)for(l in c=e.defaultProps,c)s[l]===void 0&&(s[l]=c[l]);return a&&de(s,typeof e=="function"?e.displayName||e.name||"Unknown":e),F(e,a,void 0,void 0,G(),s)},n.createRef=function(){var e={current:null};return Object.seal(e),e},n.forwardRef=function(e){e!=null&&e.$$typeof===ue?console.error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."):typeof e!="function"?console.error("forwardRef requires a render function but was given %s.",e===null?"null":typeof e):e.length!==0&&e.length!==2&&console.error("forwardRef render functions accept exactly two parameters: props and ref. %s",e.length===1?"Did you forget to use the ref parameter?":"Any additional parameter will be undefined."),e!=null&&e.defaultProps!=null&&console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");var t={$$typeof:Ee,render:e},o;return Object.defineProperty(t,"displayName",{enumerable:!1,configurable:!0,get:function(){return o},set:function(s){o=s,e.name||e.displayName||(Object.defineProperty(e,"name",{value:s}),e.displayName=s)}}),t},n.isValidElement=U,n.lazy=function(e){return{$$typeof:se,_payload:{_status:-1,_result:e},_init:ye}},n.memo=function(e,t){R(e)||console.error("memo: The first argument must be a component. Instead received: %s",e===null?"null":typeof e),t={$$typeof:ue,type:e,compare:t===void 0?null:t};var o;return Object.defineProperty(t,"displayName",{enumerable:!1,configurable:!0,get:function(){return o},set:function(s){o=s,e.name||e.displayName||(Object.defineProperty(e,"name",{value:s}),e.displayName=s)}}),t},n.startTransition=function(e){var t=E.T,o={};E.T=o,o._updatedFibers=new Set;try{var s=e(),a=E.S;a!==null&&a(o,s),typeof s=="object"&&s!==null&&typeof s.then=="function"&&s.then(r,nt)}catch(l){nt(l)}finally{t===null&&o._updatedFibers&&(e=o._updatedFibers.size,o._updatedFibers.clear(),10<e&&console.warn("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.")),E.T=t}},n.unstable_useCacheRefresh=function(){return j().useCacheRefresh()},n.use=function(e){return j().use(e)},n.useActionState=function(e,t,o){return j().useActionState(e,t,o)},n.useCallback=function(e,t){return j().useCallback(e,t)},n.useContext=function(e){var t=j();return e.$$typeof===ge&&console.error("Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"),t.useContext(e)},n.useDebugValue=function(e,t){return j().useDebugValue(e,t)},n.useDeferredValue=function(e,t){return j().useDeferredValue(e,t)},n.useEffect=function(e,t){return j().useEffect(e,t)},n.useId=function(){return j().useId()},n.useImperativeHandle=function(e,t,o){return j().useImperativeHandle(e,t,o)},n.useInsertionEffect=function(e,t){return j().useInsertionEffect(e,t)},n.useLayoutEffect=function(e,t){return j().useLayoutEffect(e,t)},n.useMemo=function(e,t){return j().useMemo(e,t)},n.useOptimistic=function(e,t){return j().useOptimistic(e,t)},n.useReducer=function(e,t,o){return j().useReducer(e,t,o)},n.useRef=function(e){return j().useRef(e)},n.useState=function(e){return j().useState(e)},n.useSyncExternalStore=function(e,t,o){return j().useSyncExternalStore(e,t,o)},n.useTransition=function(){return j().useTransition()},n.version="19.0.0",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()}(fe,fe.exports)),fe.exports}process.env.NODE_ENV==="production"?Ve.exports=Mt():Ve.exports=$t();var q=Ve.exports;function Pt(f="details"){const n=q.useRef(new lt(f)),[i,d]=q.useState(void 0);q.useEffect(()=>{var Y,K;const R=(Y=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(n.current),"state"))==null?void 0:Y.get,N=(K=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(n.current),"state"))==null?void 0:K.set;R&&N&&Object.defineProperty(n.current,"state",{get:function(){return R.call(this)},set:function(D){N.call(this,D),d(D)},configurable:!0})},[]);const v=q.useCallback(R=>{if(!(R!=null&&R.el)){console.error("El is null during initialization");return}n.current.init(R)},[]),m=q.useCallback(R=>{var Y;const N=R;if(!((Y=N==null?void 0:N.detail)!=null&&Y.el)){console.error("El is null during list initialization");return}n.current.initList(R)},[]),b=q.useCallback((R,N)=>{if(!n.current._formRef){console.error("Form ref not set.");return}n.current.initState(R,N)},[]),k=q.useCallback(R=>{n.current.continueTo(R)},[]),P=q.useCallback((R,N,Y)=>n.current.validate(R,N,Y),[]),L=q.useCallback((R,N)=>n.current.getStateValue(R,N),[]),M=q.useCallback(()=>n.current.getStateList(),[]);return{state:i,init:v,initList:m,initState:b,continueTo:k,validate:P,getStateValue:L,getStateList:M,controller:n.current}}exports.FormValidator=_t;exports.PublicFormController=lt;exports.SINValidator=At;exports.birthDayValidator=bt;exports.birthMonthValidator=wt;exports.birthYearValidator=Ct;exports.dateValidator=St;exports.dispatch=kt;exports.emailValidator=Tt;exports.lengthValidator=jt;exports.numericValidator=Ne;exports.phoneNumberValidator=Rt;exports.postalCodeValidator=Ot;exports.regexValidator=je;exports.relay=ce;exports.requiredValidator=Se;exports.usePublicFormController=Pt;
|
package/index.d.ts
CHANGED