UNPKG

sveltejs-forms

Version:
3 lines (2 loc) 23.3 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).SveltejsForms={})}(this,(function(t){"use strict";function e(){}function n(t,e){for(const n in e)t[n]=e[n];return t}function r(t){return t()}function o(){return Object.create(null)}function i(t){t.forEach(r)}function u(t){return"function"==typeof t}function l(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function c(t,...n){if(null==t)return e;const r=t.subscribe(...n);return r.unsubscribe?()=>r.unsubscribe():r}function a(t,e,n){t.$$.on_destroy.push(c(e,n))}function s(t,e,r,o){return t[1]&&o?n(r.ctx.slice(),t[1](o(e))):r.ctx}function f(t){const e={};for(const n in t)"$"!==n[0]&&(e[n]=t[n]);return e}function d(t,e){const n={};e=new Set(e);for(const r in t)e.has(r)||"$"===r[0]||(n[r]=t[r]);return n}function p(t,e,n=e){return t.set(n),e}function h(t,e){t.appendChild(e)}function v(t,e,n){t.insertBefore(e,n||null)}function m(t){t.parentNode.removeChild(t)}function _(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}function y(t){return document.createElement(t)}function g(t){return document.createTextNode(t)}function b(){return g(" ")}function $(t,e,n,r){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n,r)}function O(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function x(t,e){const n=Object.getOwnPropertyDescriptors(t.__proto__);for(const r in e)null==e[r]?t.removeAttribute(r):"style"===r?t.style.cssText=e[r]:"__value"===r||n[r]&&n[r].set?t[r]=e[r]:O(t,r,e[r])}function j(t,e){e=""+e,t.data!==e&&(t.data=e)}function w(t,e,n){t.classList[n?"add":"remove"](e)}let S;function E(t){S=t}function A(){if(!S)throw new Error("Function called outside component initialization");return S}function k(){const t=A();return(e,n)=>{const r=t.$$.callbacks[e];if(r){const o=function(t,e){const n=document.createEvent("CustomEvent");return n.initCustomEvent(t,!1,!1,e),n}(e,n);r.slice().forEach(e=>{e.call(t,o)})}}}function C(t){return A().$$.context.get(t)}const F=[],P=[],z=[],V=[],T=Promise.resolve();let N=!1;function B(t){z.push(t)}let M=!1;const L=new Set;function q(){if(!M){M=!0;do{for(let t=0;t<F.length;t+=1){const e=F[t];E(e),D(e.$$)}for(F.length=0;P.length;)P.pop()();for(let t=0;t<z.length;t+=1){const e=z[t];L.has(e)||(L.add(e),e())}z.length=0}while(F.length);for(;V.length;)V.pop()();N=!1,M=!1,L.clear()}}function D(t){if(null!==t.fragment){t.update(),i(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(B)}}const I=new Set;function J(t,e){t&&t.i&&(I.delete(t),t.i(e))}function R(t,e){const n={},r={},o={$$scope:1};let i=t.length;for(;i--;){const u=t[i],l=e[i];if(l){for(const t in u)t in l||(r[t]=1);for(const t in l)o[t]||(n[t]=l[t],o[t]=1);t[i]=l}else for(const t in u)o[t]=1}for(const t in r)t in n||(n[t]=void 0);return n}function U(t,e){-1===t.$$.dirty[0]&&(F.push(t),N||(N=!0,T.then(q)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function G(t,n,l,c,a,s,f=[-1]){const d=S;E(t);const p=n.props||{},h=t.$$={fragment:null,ctx:null,props:s,update:e,not_equal:a,bound:o(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(d?d.$$.context:[]),callbacks:o(),dirty:f};let v=!1;if(h.ctx=l?l(t,p,(e,n,...r)=>{const o=r.length?r[0]:n;return h.ctx&&a(h.ctx[e],h.ctx[e]=o)&&(h.bound[e]&&h.bound[e](o),v&&U(t,e)),n}):[],h.update(),v=!0,i(h.before_update),h.fragment=!!c&&c(h.ctx),n.target){if(n.hydrate){const t=function(t){return Array.from(t.childNodes)}(n.target);h.fragment&&h.fragment.l(t),t.forEach(m)}else h.fragment&&h.fragment.c();n.intro&&J(t.$$.fragment),function(t,e,n){const{fragment:o,on_mount:l,on_destroy:c,after_update:a}=t.$$;o&&o.m(e,n),B(()=>{const e=l.map(r).filter(u);c?c.push(...e):i(e),t.$$.on_mount=[]}),a.forEach(B)}(t,n.target,n.anchor),q()}E(d)}class H{$destroy(){!function(t,e){const n=t.$$;null!==n.fragment&&(i(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}(this,1),this.$destroy=e}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(){}}const K=[];function Q(t,n=e){let r;const o=[];function i(e){if(l(t,e)&&(t=e,r)){const e=!K.length;for(let e=0;e<o.length;e+=1){const n=o[e];n[1](),K.push(n,t)}if(e){for(let t=0;t<K.length;t+=2)K[t][0](K[t+1]);K.length=0}}}return{set:i,update:function(e){i(e(t))},subscribe:function(u,l=e){const c=[u,l];return o.push(c),1===o.length&&(r=n(i)||e),u(t),()=>{const t=o.indexOf(c);-1!==t&&o.splice(t,1),0===o.length&&(r(),r=null)}}}}function W(t,n,r){const o=!Array.isArray(t),l=o?[t]:t,a=n.length<2;return{subscribe:Q(r,t=>{let r=!1;const s=[];let f=0,d=e;const p=()=>{if(f)return;d();const r=n(o?s[0]:s,t);a?t(r):d=u(r)?r:e},h=l.map((t,e)=>c(t,t=>{s[e]=t,f&=~(1<<e),r&&p()},()=>{f|=1<<e}));return r=!0,p(),function(){i(h),d()}}).subscribe}}var X="object"==typeof global&&global&&global.Object===Object&&global,Y="object"==typeof self&&self&&self.Object===Object&&self,Z=X||Y||Function("return this")(),tt=Z.Symbol,et=Object.prototype,nt=et.hasOwnProperty,rt=et.toString,ot=tt?tt.toStringTag:void 0;var it=Object.prototype.toString;var ut=tt?tt.toStringTag:void 0;function lt(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":ut&&ut in Object(t)?function(t){var e=nt.call(t,ot),n=t[ot];try{t[ot]=void 0;var r=!0}catch(t){}var o=rt.call(t);return r&&(e?t[ot]=n:delete t[ot]),o}(t):function(t){return it.call(t)}(t)}function ct(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}var at,st=Z["__core-js_shared__"],ft=(at=/[^.]+$/.exec(st&&st.keys&&st.keys.IE_PROTO||""))?"Symbol(src)_1."+at:"";var dt=Function.prototype.toString;var pt=/^\[object .+?Constructor\]$/,ht=Function.prototype,vt=Object.prototype,mt=ht.toString,_t=vt.hasOwnProperty,yt=RegExp("^"+mt.call(_t).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function gt(t){return!(!ct(t)||(e=t,ft&&ft in e))&&(function(t){if(!ct(t))return!1;var e=lt(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}(t)?yt:pt).test(function(t){if(null!=t){try{return dt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function bt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return gt(n)?n:void 0}var $t=function(){try{var t=bt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Ot(t,e){return t===e||t!=t&&e!=e}var xt=Object.prototype.hasOwnProperty;function jt(t,e,n){var r=t[e];xt.call(t,e)&&Ot(r,n)&&(void 0!==n||e in t)||function(t,e,n){"__proto__"==e&&$t?$t(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}(t,e,n)}var wt=Array.isArray;function St(t){return"symbol"==typeof t||function(t){return null!=t&&"object"==typeof t}(t)&&"[object Symbol]"==lt(t)}var Et=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,At=/^\w*$/;var kt=bt(Object,"create");var Ct=Object.prototype.hasOwnProperty;var Ft=Object.prototype.hasOwnProperty;function Pt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function zt(t,e){for(var n=t.length;n--;)if(Ot(t[n][0],e))return n;return-1}Pt.prototype.clear=function(){this.__data__=kt?kt(null):{},this.size=0},Pt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Pt.prototype.get=function(t){var e=this.__data__;if(kt){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return Ct.call(e,t)?e[t]:void 0},Pt.prototype.has=function(t){var e=this.__data__;return kt?void 0!==e[t]:Ft.call(e,t)},Pt.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=kt&&void 0===e?"__lodash_hash_undefined__":e,this};var Vt=Array.prototype.splice;function Tt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Tt.prototype.clear=function(){this.__data__=[],this.size=0},Tt.prototype.delete=function(t){var e=this.__data__,n=zt(e,t);return!(n<0)&&(n==e.length-1?e.pop():Vt.call(e,n,1),--this.size,!0)},Tt.prototype.get=function(t){var e=this.__data__,n=zt(e,t);return n<0?void 0:e[n][1]},Tt.prototype.has=function(t){return zt(this.__data__,t)>-1},Tt.prototype.set=function(t,e){var n=this.__data__,r=zt(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this};var Nt=bt(Z,"Map");function Bt(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function Mt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Mt.prototype.clear=function(){this.size=0,this.__data__={hash:new Pt,map:new(Nt||Tt),string:new Pt}},Mt.prototype.delete=function(t){var e=Bt(this,t).delete(t);return this.size-=e?1:0,e},Mt.prototype.get=function(t){return Bt(this,t).get(t)},Mt.prototype.has=function(t){return Bt(this,t).has(t)},Mt.prototype.set=function(t,e){var n=Bt(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this};function Lt(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var u=t.apply(this,r);return n.cache=i.set(o,u)||i,u};return n.cache=new(Lt.Cache||Mt),n}Lt.Cache=Mt;var qt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Dt=/\\(\\)?/g,It=function(t){var e=Lt(t,(function(t){return 500===n.size&&n.clear(),t})),n=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(qt,(function(t,n,r,o){e.push(r?o.replace(Dt,"$1"):n||t)})),e}));var Jt=tt?tt.prototype:void 0,Rt=Jt?Jt.toString:void 0;function Ut(t){if("string"==typeof t)return t;if(wt(t))return function(t,e){for(var n=-1,r=null==t?0:t.length,o=Array(r);++n<r;)o[n]=e(t[n],n,t);return o}(t,Ut)+"";if(St(t))return Rt?Rt.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Gt(t,e){return wt(t)?t:function(t,e){if(wt(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!St(t))||(At.test(t)||!Et.test(t)||null!=e&&t in Object(e))}(t,e)?[t]:It(function(t){return null==t?"":Ut(t)}(t))}var Ht=/^(?:0|[1-9]\d*)$/;function Kt(t,e){var n=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&Ht.test(t))&&t>-1&&t%1==0&&t<e}function Qt(t){if("string"==typeof t||St(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Wt(t,e,n){return null==t?t:function(t,e,n,r){if(!ct(t))return t;for(var o=-1,i=(e=Gt(e,t)).length,u=i-1,l=t;null!=l&&++o<i;){var c=Qt(e[o]),a=n;if(o!=u){var s=l[c];void 0===(a=r?r(s,c,l):void 0)&&(a=ct(s)?s:Kt(e[o+1])?[]:{})}jt(l,c,a),l=l[c]}return t}(t,e,n)}function Xt(t,e,n){var r=null==t?void 0:function(t,e){for(var n=0,r=(e=Gt(e,t)).length;null!=t&&n<r;)t=t[Qt(e[n++])];return n&&n==r?t:void 0}(t,e);return void 0===r?n:r}const Yt=t=>({isSubmitting:32&t,isValid:1&t,values:4&t,errors:16&t,touched:8&t}),Zt=t=>({isSubmitting:t[5],isValid:t[0],setValue:t[13],touchField:t[12],validate:t[11],values:t[2],errors:t[4],touched:t[3]});function te(t){let e,n,r;const o=t[25].default,u=function(t,e,n,r){if(t){const o=s(t,e,n,r);return t[0](o)}}(o,t,t[24],Zt);return{c(){e=y("form"),u&&u.c(),O(e,"class","sveltejs-forms")},m(o,l,c){var a;v(o,e,l),u&&u.m(e,null),t[26](e),n=!0,c&&i(r),r=[$(e,"submit",(a=t[15],function(t){return t.preventDefault(),a.call(this,t)})),$(e,"reset",t[14])]},p(t,[e]){u&&u.p&&16777277&e&&u.p(s(o,t,t[24],Zt),function(t,e,n,r){if(t[2]&&r){const o=t[2](r(n));if(void 0===e.dirty)return o;if("object"==typeof o){const t=[],n=Math.max(e.dirty.length,o.length);for(let r=0;r<n;r+=1)t[r]=e.dirty[r]|o[r];return t}return e.dirty|o}return e.dirty}(o,t[24],e,Yt))},i(t){n||(J(u,t),n=!0)},o(t){!function(t,e,n,r){if(t&&t.o){if(I.has(t))return;I.add(t),(void 0).c.push(()=>{I.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}}(u,t),n=!1},d(n){n&&m(e),u&&u.d(n),t[26](null),i(r)}}}const ee={};function ne(t,e,n){let r,o,i,u,l,{initialValues:c={}}=e,{schema:s=null}=e,{validateOnChange:f=!0}=e,{validateOnBlur:d=!0}=e;const h=k(),v=Q(function(t=""){return new Proxy({},{get:function(e,n){return Object.prototype.hasOwnProperty.call(e,n)?e[n]:t}})}());a(t,v,t=>n(2,r=t));const m=Q({});a(t,m,t=>n(21,u=t));const _=Q({});a(t,_,t=>n(4,i=t));const y=Q({});a(t,y,t=>n(3,o=t));const g=Q(!1);let b,$,O;var x,j,w;function S(t){O.forEach(({path:e,multiple:n})=>{p(v,r=Wt(r,e,Xt(t||c,e,n?[]:""))),p(y,o=Wt(o,e,!1))}),p(_,i={}),p(m,u={}),n(0,b=void 0)}async function E(){var t;if(s)try{p(m,u=await s.validate((t=r,JSON.parse(JSON.stringify(t))),{abortEarly:!1,stripUnknown:!0})),p(_,i={}),n(0,b=!0)}catch(t){p(_,i={}),t.inner.forEach(t=>{p(_,i=Wt(i,t.path,t.message))}),n(0,b=!1)}else n(0,b=!0)}function C(t,e=!1){(d||e)&&(p(y,o=Wt(o,t,!0)),E())}function F(t,e,n=!0){p(v,r=Wt(r,t,e)),p(y,o=Wt(o,t,!0)),n&&f&&E()}a(t,g,t=>n(5,l=t)),x=()=>{O=Array.from($.querySelectorAll("input,textarea,select")).filter(t=>!!t.name).map(t=>({path:t.name})).reduce((t,e)=>{const n=t=>t.path===e.path,r=!!t.find(n);return[...t.filter(t=>!n(t)),{...e,multiple:r}]},[]),S()},A().$$.on_mount.push(x),j=ee,w={touchField:C,setValue:F,validate:E,values:v,errors:_,touched:y,isSubmitting:g,validateOnBlur:d,validateOnChange:f},A().$$.context.set(j,w);let{$$slots:z={},$$scope:V}=e;return t.$set=t=>{"initialValues"in t&&n(16,c=t.initialValues),"schema"in t&&n(17,s=t.schema),"validateOnChange"in t&&n(18,f=t.validateOnChange),"validateOnBlur"in t&&n(19,d=t.validateOnBlur),"$$scope"in t&&n(24,V=t.$$scope)},[b,$,r,o,i,l,v,m,_,y,g,E,C,F,function(){S(),h("reset")},async function(){O.forEach(({path:t})=>p(y,o=Wt(o,t,!0))),await E(),s&&!b||(p(g,l=!0),h("submit",{values:s?{...u}:{...r},setSubmitting:t=>p(g,l=t),resetForm:S}))},c,s,f,d,O,u,h,S,V,z,function(t){P[t?"unshift":"push"](()=>{n(1,$=t)})}]}function re(t){let e,n;return{c(){e=y("label"),n=g(t[1]),O(e,"for",t[0])},m(t,r){v(t,e,r),h(e,n)},p(t,r){2&r&&j(n,t[1]),1&r&&O(e,"for",t[0])},d(t){t&&m(e)}}}function oe(t){let e,r,o=[{name:t[0]},{type:t[2]},{id:t[0]},{value:Xt(t[6],t[0])},t[12]],l={};for(let t=0;t<o.length;t+=1)l=n(l,o[t]);return{c(){e=y("input"),x(e,l)},m(n,o,l){v(n,e,o),l&&i(r),r=[$(e,"blur",t[11]),$(e,"change",t[10]),$(e,"input",(function(){u(Xt(t[4],t[0])&&t[10])&&(Xt(t[4],t[0])&&t[10]).apply(this,arguments)}))]},p(n,r){t=n,x(e,R(o,[1&r&&{name:t[0]},4&r&&{type:t[2]},1&r&&{id:t[0]},65&r&&{value:Xt(t[6],t[0])},4096&r&&t[12]]))},d(t){t&&m(e),i(r)}}}function ie(t){let e,r,o=[{name:t[0]},{id:t[0]},{value:Xt(t[6],t[0])},t[12]],l={};for(let t=0;t<o.length;t+=1)l=n(l,o[t]);return{c(){e=y("textarea"),x(e,l)},m(n,o,l){v(n,e,o),l&&i(r),r=[$(e,"blur",t[11]),$(e,"change",t[10]),$(e,"input",(function(){u(Xt(t[4],t[0])&&t[10])&&(Xt(t[4],t[0])&&t[10]).apply(this,arguments)}))]},p(n,r){t=n,x(e,R(o,[1&r&&{name:t[0]},1&r&&{id:t[0]},65&r&&{value:Xt(t[6],t[0])},4096&r&&t[12]]))},d(t){t&&m(e),i(r)}}}function ue(t){let e,n,r=Xt(t[5],t[0])+"";return{c(){e=y("div"),n=g(r),O(e,"class","message")},m(t,r){v(t,e,r),h(e,n)},p(t,e){33&e&&r!==(r=Xt(t[5],t[0])+"")&&j(n,r)},d(t){t&&m(e)}}}function le(t){let n,r,o,i=Xt(t[4],t[0])&&Xt(t[5],t[0]),u=t[1]&&re(t);function l(t,e){return t[3]?ie:oe}let c=l(t),a=c(t),s=i&&ue(t);return{c(){n=y("div"),u&&u.c(),r=b(),a.c(),o=b(),s&&s.c(),O(n,"class","field"),w(n,"error",Xt(t[4],t[0])&&Xt(t[5],t[0]))},m(t,e){v(t,n,e),u&&u.m(n,null),h(n,r),a.m(n,null),h(n,o),s&&s.m(n,null)},p(t,[e]){t[1]?u?u.p(t,e):(u=re(t),u.c(),u.m(n,r)):u&&(u.d(1),u=null),c===(c=l(t))&&a?a.p(t,e):(a.d(1),a=c(t),a&&(a.c(),a.m(n,o))),49&e&&(i=Xt(t[4],t[0])&&Xt(t[5],t[0])),i?s?s.p(t,e):(s=ue(t),s.c(),s.m(n,null)):s&&(s.d(1),s=null),49&e&&w(n,"error",Xt(t[4],t[0])&&Xt(t[5],t[0]))},i:e,o:e,d(t){t&&m(n),u&&u.d(),a.d(),s&&s.d()}}}function ce(t,e,r){const o=["name","label","type","multiline"];let i,u,l,c=d(e,o),{name:s}=e,{label:p=""}=e,{type:h="text"}=e,{multiline:v=!1}=e;const{touchField:m,setValue:_,values:y,errors:g,touched:b}=C(ee);return a(t,y,t=>r(6,l=t)),a(t,g,t=>r(5,u=t)),a(t,b,t=>r(4,i=t)),Object.keys(c).includes("value")&&setTimeout(()=>_(s,c.value,!1),0),t.$set=t=>{e=n(n({},e),f(t)),r(12,c=d(e,o)),"name"in t&&r(0,s=t.name),"label"in t&&r(1,p=t.label),"type"in t&&r(2,h=t.type),"multiline"in t&&r(3,v=t.multiline)},[s,p,h,v,i,u,l,y,g,b,function(t){_(s,t.target.value)},function(){m(s)},c]}function ae(t,e,n){const r=t.slice();return r[14]=e[n],r}function se(t){let e,n;return{c(){e=y("label"),n=g(t[1]),O(e,"for",t[0])},m(t,r){v(t,e,r),h(e,n)},p(t,r){2&r&&j(n,t[1]),1&r&&O(e,"for",t[0])},d(t){t&&m(e)}}}function fe(t){let e,n,r,o,i,u=t[14].title+"";return{c(){e=y("option"),n=g(u),r=b(),e.__value=o=t[14].id,e.value=e.__value,e.selected=i=Xt(t[5],t[0])===t[14].id},m(t,o){v(t,e,o),h(e,n),h(e,r)},p(t,r){4&r&&u!==(u=t[14].title+"")&&j(n,u),4&r&&o!==(o=t[14].id)&&(e.__value=o),e.value=e.__value,37&r&&i!==(i=Xt(t[5],t[0])===t[14].id)&&(e.selected=i)},d(t){t&&m(e)}}}function de(t){let e,n,r=Xt(t[4],t[0])+"";return{c(){e=y("div"),n=g(r),O(e,"class","message")},m(t,r){v(t,e,r),h(e,n)},p(t,e){17&e&&r!==(r=Xt(t[4],t[0])+"")&&j(n,r)},d(t){t&&m(e)}}}function pe(t){let r,o,u,l,c,a,s=Xt(t[3],t[0])&&Xt(t[4],t[0]),f=t[1]&&se(t),d=t[2],p=[];for(let e=0;e<d.length;e+=1)p[e]=fe(ae(t,d,e));let g=[{name:t[0]},{id:t[0]},{value:Xt(t[5],t[0])},t[11]],j={};for(let t=0;t<g.length;t+=1)j=n(j,g[t]);let S=s&&de(t);return{c(){r=y("div"),f&&f.c(),o=b(),u=y("select"),l=y("option");for(let t=0;t<p.length;t+=1)p[t].c();c=b(),S&&S.c(),l.__value="",l.value=l.__value,x(u,j),O(r,"class","field"),w(r,"error",Xt(t[3],t[0])&&Xt(t[4],t[0]))},m(e,n,s){v(e,r,n),f&&f.m(r,null),h(r,o),h(r,u),h(u,l);for(let t=0;t<p.length;t+=1)p[t].m(u,null);h(r,c),S&&S.m(r,null),s&&i(a),a=[$(u,"change",t[9]),$(u,"blur",t[10])]},p(t,[e]){if(t[1]?f?f.p(t,e):(f=se(t),f.c(),f.m(r,o)):f&&(f.d(1),f=null),37&e){let n;for(d=t[2],n=0;n<d.length;n+=1){const r=ae(t,d,n);p[n]?p[n].p(r,e):(p[n]=fe(r),p[n].c(),p[n].m(u,null))}for(;n<p.length;n+=1)p[n].d(1);p.length=d.length}x(u,R(g,[1&e&&{name:t[0]},1&e&&{id:t[0]},33&e&&{value:Xt(t[5],t[0])},2048&e&&t[11]])),25&e&&(s=Xt(t[3],t[0])&&Xt(t[4],t[0])),s?S?S.p(t,e):(S=de(t),S.c(),S.m(r,null)):S&&(S.d(1),S=null),25&e&&w(r,"error",Xt(t[3],t[0])&&Xt(t[4],t[0]))},i:e,o:e,d(t){t&&m(r),f&&f.d(),_(p,t),S&&S.d(),i(a)}}}function he(t,e,r){const o=["name","label","options"];let i,u,l,c=d(e,o),{name:s}=e,{label:p=""}=e,{options:h}=e;const{touchField:v,setValue:m,values:_,errors:y,touched:g}=C(ee);return a(t,_,t=>r(5,l=t)),a(t,y,t=>r(4,u=t)),a(t,g,t=>r(3,i=t)),Object.keys(c).includes("value")&&setTimeout(()=>m(s,c.value,!1),0),t.$set=t=>{e=n(n({},e),f(t)),r(11,c=d(e,o)),"name"in t&&r(0,s=t.name),"label"in t&&r(1,p=t.label),"options"in t&&r(2,h=t.options)},[s,p,h,i,u,l,_,y,g,function(t){m(s,t.target.value)},function(){v(s)},c]}function ve(t,e,n,r){var o,i,u=!0,l="withOld"in n,c=W(t,(t,n)=>{if(o=n,l&&(i=t),u){let r=e(t,n);if(!(e.length<2))return r;n(r)}},r),a=!Array.isArray(t),s=e=>{u=!1,a?t.set(e):e.forEach((e,n)=>{t[n].set(e)}),u=!0};l&&(n=n.withOld);var f=n.length>=(l?3:2),d=null;var p=0;function h(t){var e,r,u=!1,a=p+1,h=c.subscribe(t=>{u?e=!0:r=t}),v=t(r);u=!0,o(v),h(),e&&a>p&&(p=a,function(t){if(d&&(d(),d=null),l)var e=n(t,i,s);else e=n(t,s);f?"function"==typeof e&&(d=e):s(e)}(v))}return{subscribe:c.subscribe,set(t){h(()=>t)},update:h}}function me(t,e,n){const r=t.slice();return r[20]=e[n],r}function _e(t){let e,r,o=[{id:t[0]+"-"+t[20].id},{type:"radio"},{name:t[0]},{__value:t[20].id},t[12]],u={};for(let t=0;t<o.length;t+=1)u=n(u,o[t]);return{c(){e=y("input"),x(e,u),t[18][0].push(e)},m(n,o,u){v(n,e,o),e.checked=e.__value===t[5],u&&i(r),r=[$(e,"change",t[19]),$(e,"change",t[10]),$(e,"blur",t[11])]},p(t,n){x(e,R(o,[3&n&&{id:t[0]+"-"+t[20].id},{type:"radio"},1&n&&{name:t[0]},2&n&&{__value:t[20].id},4096&n&&t[12]])),32&n&&(e.checked=e.__value===t[5])},d(n){n&&m(e),t[18][0].splice(t[18][0].indexOf(e),1),i(r)}}}function ye(t){let e,r,o=[{id:t[0]+"-"+t[20].id},{type:"checkbox"},{name:t[0]},{__value:t[20].id},t[12]],u={};for(let t=0;t<o.length;t+=1)u=n(u,o[t]);return{c(){e=y("input"),x(e,u),t[18][0].push(e)},m(n,o,u){v(n,e,o),e.checked=~t[5].indexOf(e.__value),u&&i(r),r=[$(e,"change",t[17]),$(e,"change",t[10]),$(e,"blur",t[11])]},p(t,n){x(e,R(o,[3&n&&{id:t[0]+"-"+t[20].id},{type:"checkbox"},1&n&&{name:t[0]},2&n&&{__value:t[20].id},4096&n&&t[12]])),32&n&&(e.checked=~t[5].indexOf(e.__value))},d(n){n&&m(e),t[18][0].splice(t[18][0].indexOf(e),1),i(r)}}}function ge(t){let e,n,r,o=t[20].title+"";return{c(){e=y("label"),n=g(o),O(e,"for",r=t[20].id)},m(t,r){v(t,e,r),h(e,n)},p(t,i){2&i&&o!==(o=t[20].title+"")&&j(n,o),2&i&&r!==(r=t[20].id)&&O(e,"for",r)},d(t){t&&m(e)}}}function be(t){let e,n;function r(t,e){return t[2]?ye:_e}let o=r(t),i=o(t),u=t[20].title&&ge(t);return{c(){i.c(),e=b(),u&&u.c(),n=g("")},m(t,r){i.m(t,r),v(t,e,r),u&&u.m(t,r),v(t,n,r)},p(t,l){o===(o=r(t))&&i?i.p(t,l):(i.d(1),i=o(t),i&&(i.c(),i.m(e.parentNode,e))),t[20].title?u?u.p(t,l):(u=ge(t),u.c(),u.m(n.parentNode,n)):u&&(u.d(1),u=null)},d(t){i.d(t),t&&m(e),u&&u.d(t),t&&m(n)}}}function $e(t){let e,n,r=Xt(t[4],t[0])+"";return{c(){e=y("div"),n=g(r),O(e,"class","message")},m(t,r){v(t,e,r),h(e,n)},p(t,e){17&e&&r!==(r=Xt(t[4],t[0])+"")&&j(n,r)},d(t){t&&m(e)}}}function Oe(t){let n,r,o=Xt(t[3],t[0])&&Xt(t[4],t[0]),i=t[1],u=[];for(let e=0;e<i.length;e+=1)u[e]=be(me(t,i,e));let l=o&&$e(t);return{c(){n=y("div");for(let t=0;t<u.length;t+=1)u[t].c();r=b(),l&&l.c(),O(n,"class","field"),w(n,"error",Xt(t[3],t[0])&&Xt(t[4],t[0]))},m(t,e){v(t,n,e);for(let t=0;t<u.length;t+=1)u[t].m(n,null);h(n,r),l&&l.m(n,null)},p(t,[e]){if(7207&e){let o;for(i=t[1],o=0;o<i.length;o+=1){const l=me(t,i,o);u[o]?u[o].p(l,e):(u[o]=be(l),u[o].c(),u[o].m(n,r))}for(;o<u.length;o+=1)u[o].d(1);u.length=i.length}25&e&&(o=Xt(t[3],t[0])&&Xt(t[4],t[0])),o?l?l.p(t,e):(l=$e(t),l.c(),l.m(n,null)):l&&(l.d(1),l=null),25&e&&w(n,"error",Xt(t[3],t[0])&&Xt(t[4],t[0]))},i:e,o:e,d(t){t&&m(n),_(u,t),l&&l.d()}}}function xe(t,e,r){const o=["name","options","multiple","value"];let i,u,l,c,s=d(e,o),{name:p}=e,{options:h}=e,{multiple:v=!1}=e,{value:m=""}=e;const{touchField:_,values:y,errors:g,touched:b,validateOnChange:$}=C(ee);a(t,y,t=>r(14,i=t)),a(t,g,t=>r(4,l=t)),a(t,b,t=>r(3,u=t));const O=ve(y,t=>Xt(t,p,v?[]:""),t=>Wt(i,p,t));a(t,O,t=>r(5,c=t)),m&&setTimeout(()=>{O.set(m)},0);const x=[[]];return t.$set=t=>{e=n(n({},e),f(t)),r(12,s=d(e,o)),"name"in t&&r(0,p=t.name),"options"in t&&r(1,h=t.options),"multiple"in t&&r(2,v=t.multiple),"value"in t&&r(13,m=t.value)},[p,h,v,u,l,c,y,g,b,O,function(){_(p,$)},function(){_(p)},s,m,i,_,$,function(){c=function(t){const e=[];for(let n=0;n<t.length;n+=1)t[n].checked&&e.push(t[n].__value);return e}(x[0]),O.set(c)},x,function(){c=this.__value,O.set(c)}]}t.Choice=class extends H{constructor(t){super(),G(this,t,xe,Oe,l,{name:0,options:1,multiple:2,value:13})}},t.Form=class extends H{constructor(t){super(),G(this,t,ne,te,l,{initialValues:16,schema:17,validateOnChange:18,validateOnBlur:19})}},t.Input=class extends H{constructor(t){super(),G(this,t,ce,le,l,{name:0,label:1,type:2,multiline:3})}},t.Select=class extends H{constructor(t){super(),G(this,t,he,pe,l,{name:0,label:1,options:2})}},Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=index.min.js.map