| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("solid-js"),s=r.createContext(),d=()=>r.useContext(s),l=s.Provider;function c(e,t){const[o,n]=r.createSignal(e(),{equals:!1}),a=t(i=>{n(i)});return r.onCleanup(()=>a()),o}function u(e){e.solid={},e.solid.createStore=c,e.solid.valid=c(()=>e.valid,o=>e.eeSync.on("valid",o));const t=e.createField;e.createField=function(...o){const n=t.call(e,...o);return S(n),n}}function S(e){e.solid={};for(const t in e.data)e.solid[t]=c(()=>e.data[t],o=>e.eeSync.on(t,o));e.solid.errorTouched=c(()=>e.errorTouched,t=>e.eeSync.on("errorTouched",t))}const F=()=>e=>{u(e)};exports.FfwContextProvider=l;exports.addSolidPlugin=F;exports.getFfwContext=d; |
| import { createContext as i, useContext as d, createSignal as l, onCleanup as u } from "solid-js"; | ||
| const c = i(), C = () => d(c), v = c.Provider; | ||
| function r(e, t) { | ||
| const [o, n] = l(e(), { equals: !1 }), a = t((s) => { | ||
| n(s); | ||
| }); | ||
| return u(() => a()), o; | ||
| } | ||
| function S(e) { | ||
| e.solid = {}, e.solid.createStore = r, e.solid.valid = r( | ||
| () => e.valid, | ||
| (o) => e.eeSync.on("valid", o) | ||
| ); | ||
| const t = e.createField; | ||
| e.createField = function(...o) { | ||
| const n = t.call(e, ...o); | ||
| return F(n), n; | ||
| }; | ||
| } | ||
| function F(e) { | ||
| e.solid = {}; | ||
| for (const t in e.data) | ||
| e.solid[t] = r( | ||
| () => e.data[t], | ||
| (o) => e.eeSync.on(t, o) | ||
| ); | ||
| e.solid.errorTouched = r( | ||
| () => e.errorTouched, | ||
| (t) => e.eeSync.on("errorTouched", t) | ||
| ); | ||
| } | ||
| const g = () => (e) => { | ||
| S(e); | ||
| }; | ||
| export { | ||
| v as FfwContextProvider, | ||
| g as addSolidPlugin, | ||
| C as getFfwContext | ||
| }; |
+7
-26
| { | ||
| "name": "ffw-solid", | ||
| "version": "1.1.1", | ||
| "description": "", | ||
| "version": "1.1.2", | ||
| "type": "module", | ||
| "main": "./dist/cjs/index.js", | ||
| "exports": { | ||
| ".": { | ||
| "development": { | ||
| "import": "./dist/esm/dev.js", | ||
| "require": "./dist/cjs/dev.js" | ||
| }, | ||
| "production": { | ||
| "import": "./dist/esm/prod.js", | ||
| "require": "./dist/cjs/prod.js" | ||
| }, | ||
| "import": "./dist/esm/prod.js", | ||
| "require": "./dist/cjs/prod.js" | ||
| }, | ||
| "./*": "./*" | ||
| "import": "./dist/ffw-solid.js", | ||
| "require": "./dist/ffw-solid.cjs" | ||
| }, | ||
@@ -25,16 +12,10 @@ "files": [ | ||
| ], | ||
| "keywords": [], | ||
| "author": "", | ||
| "license": "ISC", | ||
| "author": "utftu", | ||
| "license": "MIT", | ||
| "dependencies": { | ||
| "ffw": "1.1.1" | ||
| "ffw": "1.1.4" | ||
| }, | ||
| "devDependencies": { | ||
| "@testing-library/svelte": "^3.2.2", | ||
| "solid-js": "^1.6.2", | ||
| "svelte": "^3.53.1" | ||
| }, | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| "build": "node ./build.js" | ||
| } | ||
| } |
-415
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
| isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
| mod | ||
| )); | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| // packages/ffw-solid/src/index.js | ||
| var src_exports = {}; | ||
| __export(src_exports, { | ||
| FfwContextProvider: () => FfwContextProvider, | ||
| FieldSolid: () => field_solid_default, | ||
| FormSolid: () => form_solid_default, | ||
| getFfwContext: () => getFfwContext, | ||
| initForm: () => init_form_default, | ||
| prepareYup: () => X | ||
| }); | ||
| module.exports = __toCommonJS(src_exports); | ||
| // packages/ffw/dist/esm/prod.js | ||
| var x = __toESM(require("yup"), 1); | ||
| function P(s) { | ||
| let t = s || /* @__PURE__ */ new Map(); | ||
| return { on(e, r) { | ||
| t.has(e) || t.set(e, []), t.get(e).push(r); | ||
| }, off(e, r) { | ||
| t.has(e) && t.set(e, t.get(e).filter((i) => i !== r)); | ||
| }, emit(e, r) { | ||
| t.has(e) && t.get(e).forEach((i) => i(r)), t.has("*") && t.get("*").forEach((i) => i(e, r)); | ||
| } }; | ||
| } | ||
| var V = P; | ||
| var d = V; | ||
| var T = () => ""; | ||
| var p = class { | ||
| form = null; | ||
| ee = d(); | ||
| data = { value: "", error: "", touched: false }; | ||
| constructor({ value: t = "", touched: e = false, error: r = "", test: i = T, form: o = null } = {}) { | ||
| this.form = o, this.test = T, this.initParams = { value: t, touched: e, error: r, test: i }, this.test = i, this.data.value = t, this.data.error = r, this.data.touched = e, o.addField(this); | ||
| } | ||
| get value() { | ||
| return this.data.value; | ||
| } | ||
| set value(t) { | ||
| this.set(t); | ||
| } | ||
| get error() { | ||
| return this.data.error; | ||
| } | ||
| set error(t) { | ||
| this.setError(t); | ||
| } | ||
| get touched() { | ||
| return this.data.touched; | ||
| } | ||
| set touched(t) { | ||
| this.setTouched(t); | ||
| } | ||
| get errorTouched() { | ||
| return this.data.touched === false ? "" : this.data.error; | ||
| } | ||
| setData(t, e) { | ||
| let r = this.data[t]; | ||
| if (r === e) | ||
| return; | ||
| let i = this.errorTouched; | ||
| if (this.data[t] = e, this.form.calls.add(this, t, () => this.ee.emit(t, e)), this.form.calls.add(this.form, "*", () => this.form.ee.emit("global")), t === "error") { | ||
| let o = r, l = e; | ||
| l !== "" && o === "" ? (this.form._errors++, this.form._errors === 1 && this.form.calls.add(this.form, "valid", () => this.form.ee.emit("valid", false))) : l === "" && o !== "" && (this.form._errors--, this.form._errors === 0 && this.form.calls.add(this.form, "valid", () => this.form.ee.emit("valid", true))); | ||
| } | ||
| if (t === "error" || t === "touched") { | ||
| if (i === this.errorTouched) | ||
| return; | ||
| this.form.calls.add(this, "errorTouched", () => this.ee.emit("errorTouched", this.errorTouched)); | ||
| } | ||
| } | ||
| update() { | ||
| this.form.calls.add(this, "*", () => this.ee.emit("*")), this.form.calls.add(this.form, "*", () => this.form.ee.emit("*")); | ||
| } | ||
| setError(t) { | ||
| this.setData("error", t); | ||
| } | ||
| setTouched(t) { | ||
| this.setData("touched", t); | ||
| } | ||
| set(t, e) { | ||
| if (this.setData("value", t), e === true) { | ||
| this.validate(); | ||
| return; | ||
| } | ||
| e !== false && e === void 0 && this.form.options.validateOnChange && this.validate(); | ||
| } | ||
| async validate() { | ||
| let t = await this.test(this.data.value); | ||
| return this.setError(t), t; | ||
| } | ||
| on(t, e) { | ||
| return this.ee.on(t, e), () => this.ee.off(t, e); | ||
| } | ||
| off(t, e) { | ||
| return () => this.ee.off(t, e); | ||
| } | ||
| onInput = (t) => { | ||
| this.set(t.target.value); | ||
| }; | ||
| onBlur = () => { | ||
| this.setTouched(true), this.form.options.validateOnBlur && this.validate(); | ||
| }; | ||
| reset() { | ||
| this.setData("value", this.initParams.value), this.setData("touched", this.initParams.touched), this.setData("error", this.initParams.error); | ||
| } | ||
| }; | ||
| var n = p; | ||
| function O(s) { | ||
| let t, e; | ||
| return [new Promise((r, i) => { | ||
| t = r, e = i, s && s(t, e); | ||
| }), { resolve: t, reject: e }]; | ||
| } | ||
| var A = O; | ||
| var F = A; | ||
| var v = class { | ||
| _calls = /* @__PURE__ */ new Map(); | ||
| constructor(t) { | ||
| this.batch = t || ((e) => e()); | ||
| } | ||
| promise = null; | ||
| add(t, e, r) { | ||
| if (this._calls.has(t) || this._calls.set(t, /* @__PURE__ */ new Map()), this._calls.get(t).set(e, r), !this.promise) { | ||
| let [o, l] = F(); | ||
| this.promise = o, this.promiseConrtols = l, queueMicrotask(async () => { | ||
| await this._call(), this._calls.clear(), this.promiseConrtols.resolve(), this.promise = null; | ||
| }); | ||
| } | ||
| return this.promise; | ||
| } | ||
| _call() { | ||
| return this.batch(() => { | ||
| for (let t of this._calls.values()) | ||
| for (let e of t.values()) | ||
| e(); | ||
| }); | ||
| } | ||
| }; | ||
| var y = v; | ||
| function C(s) { | ||
| return s ? Array.isArray(s) ? "array" : s.__proto__ === Object.prototype ? "object" : "unknown" : "unknown"; | ||
| } | ||
| var c = C; | ||
| u.EXIT = Symbol("exit"); | ||
| function u(s, t, e) { | ||
| if (t === "array") | ||
| for (let r = 0; r < s.length; r++) { | ||
| let i = s[r]; | ||
| if (e(i, r) === u.EXIT) | ||
| return u.EXIT; | ||
| } | ||
| else if (t === "object") { | ||
| for (let r in s) | ||
| if (e(s[r], r) === u.EXIT) | ||
| return u.EXIT; | ||
| } | ||
| } | ||
| var h = u; | ||
| function b(s, t) { | ||
| let e = c(s); | ||
| return t(s) === true ? true : e === "unknown" ? false : h(s, e, (i) => { | ||
| if (b(i, t)) | ||
| return h.EXIT; | ||
| }) === h.EXIT; | ||
| } | ||
| var g = b; | ||
| var D = { array: () => [], object: () => ({}) }; | ||
| var w = D; | ||
| m.PASS = Symbol("pass"); | ||
| function m(s, t, e) { | ||
| let r = c(s); | ||
| if (e(s, r)) | ||
| return t(s); | ||
| if (r === "unknown") | ||
| return s; | ||
| let i = w[r](); | ||
| return h(s, r, (o, l) => { | ||
| let _ = m(o, t, e); | ||
| _ !== m.PASS && (i[l] = _); | ||
| }), i; | ||
| } | ||
| var f = m; | ||
| a.PASS = f.PASS; | ||
| function a(s, t) { | ||
| return f(s, (e) => { | ||
| let r = t(e); | ||
| return r === a.PASS ? f.PASS : a(r, t); | ||
| }, (e) => e instanceof n); | ||
| } | ||
| var S = class { | ||
| options = { validateOnChange: true, validateOnBlur: true, validateOnMount: false, checkPrevData: true }; | ||
| fields = {}; | ||
| f = null; | ||
| validateSchema = {}; | ||
| onSubmit = () => { | ||
| }; | ||
| initValues = {}; | ||
| calls = new y(); | ||
| ee = d(); | ||
| batch(t) { | ||
| t(); | ||
| } | ||
| createField(t = {}) { | ||
| return new n(t); | ||
| } | ||
| _getFlatFieldOrCreate(t, e) { | ||
| return this.fields[t] || (this.fields[t] = this.createField({ name: t, form: this, ...e })), this.fields[t]; | ||
| } | ||
| constructor(t = {}) { | ||
| this.f = this.fields, this.options = { ...this.options, ...t.options }, this.onSubmit = t.onSubmit ?? (() => { | ||
| }), this.initValues = t.initValues ?? {}; | ||
| for (let r in this.initValues) { | ||
| let i = this.initValues[r]; | ||
| this._getFlatFieldOrCreate(r, { value: i }); | ||
| } | ||
| t.batch && (this.batch = t.batch); | ||
| let e = typeof t.validateSchema == "function" ? t.validateSchema(this) : t.validateSchema; | ||
| for (let r in e) { | ||
| let i = e[r], o = this._getFlatFieldOrCreate(r); | ||
| o.test = i; | ||
| } | ||
| this.options.validateOnMount && this.validate(); | ||
| } | ||
| async validate() { | ||
| return (await Promise.all([...this._flatFields].map((e) => e.validate()))).every((e) => e === ""); | ||
| } | ||
| getValid() { | ||
| return this._errors === 0; | ||
| } | ||
| get valid() { | ||
| return this.getValid(); | ||
| } | ||
| submit = async () => { | ||
| if (await this.validate()) | ||
| return this.onSubmit(this); | ||
| }; | ||
| reset() { | ||
| for (let t of this._flatFields) | ||
| t.reset(); | ||
| } | ||
| getData() { | ||
| function t(e) { | ||
| return a(e, (r) => ({ error: r.error, touched: r.touched, value: t(r.value) })); | ||
| } | ||
| return t(this.fields); | ||
| } | ||
| getValues() { | ||
| return a(this.fields, (t) => t.value); | ||
| } | ||
| getErrors() { | ||
| return a(this.fields, (t) => g(t.value, (e) => e instanceof n) ? t.value : t.error !== "" ? t.error : a.PASS); | ||
| } | ||
| getTouches() { | ||
| return a(this.fields, (t) => g(t.value, (e) => e instanceof n) ? t.value : t.touched === true ? t.touched : a.PASS); | ||
| } | ||
| get values() { | ||
| return this.getValues(); | ||
| } | ||
| get errors() { | ||
| return this.getErrors(); | ||
| } | ||
| get touches() { | ||
| return this.getTouches(); | ||
| } | ||
| on(t, e) { | ||
| return this.ee.on(t, e), () => this.ee.off(t, e); | ||
| } | ||
| off(t, e) { | ||
| return () => this.ee.off(t, e); | ||
| } | ||
| _errors = 0; | ||
| _flatFields = /* @__PURE__ */ new Set(); | ||
| addField(t) { | ||
| t.error !== "" && this._errors++, this._flatFields.add(t); | ||
| } | ||
| removeField(t) { | ||
| t.error !== "" && this._errors--, this._flatFields.delete(t); | ||
| } | ||
| }; | ||
| var E = S; | ||
| function I(s) { | ||
| return async (t) => { | ||
| try { | ||
| return await s.validate(t), ""; | ||
| } catch (e) { | ||
| return e.message; | ||
| } | ||
| }; | ||
| } | ||
| function R(s) { | ||
| return f(s, (t) => I(t), (t) => t instanceof x.BaseSchema); | ||
| } | ||
| var X = R; | ||
| // packages/ffw-solid/src/create-store/create-store.js | ||
| var import_solid_js = require("solid-js"); | ||
| function createStore(get, subscribe) { | ||
| const [state, setState] = (0, import_solid_js.createSignal)(get()); | ||
| const unsubscribe = subscribe((value) => { | ||
| setState(value); | ||
| }); | ||
| (0, import_solid_js.onCleanup)(() => unsubscribe()); | ||
| return state; | ||
| } | ||
| var create_store_default = createStore; | ||
| // packages/ffw-solid/src/field-solid/field-solid.js | ||
| function makeFieldStore(name, field) { | ||
| return create_store_default( | ||
| () => field.data[name], | ||
| (cb) => field.on(name, cb) | ||
| ); | ||
| } | ||
| var FieldSolid = class extends n { | ||
| constructor(config) { | ||
| super(config); | ||
| const field = this; | ||
| this.solid = { | ||
| createStore: (name) => makeFieldStore(name, field), | ||
| field: create_store_default( | ||
| () => field, | ||
| (cb) => field.on("*", cb) | ||
| ), | ||
| value: makeFieldStore("value", field), | ||
| touched: makeFieldStore("touched", field), | ||
| error: makeFieldStore("error", field), | ||
| errorTouched: makeFieldStore("errorTouched", field) | ||
| }; | ||
| this.s = this.solid; | ||
| } | ||
| getInput = () => { | ||
| return { | ||
| value: this.solid.value(), | ||
| onInput: this.onInput, | ||
| onBlur: this.onBlur | ||
| }; | ||
| }; | ||
| getSelect = () => { | ||
| return { | ||
| value: this.solid.value(), | ||
| onChange: (value) => this.set(value), | ||
| onBlur: this.onBlur | ||
| }; | ||
| }; | ||
| }; | ||
| var field_solid_default = FieldSolid; | ||
| // packages/ffw-solid/src/form-solid/form-solid.js | ||
| var import_solid_js2 = require("solid-js"); | ||
| var FormSolid = class extends E { | ||
| createField(config) { | ||
| return new field_solid_default(config); | ||
| } | ||
| batch = import_solid_js2.batch; | ||
| constructor(config) { | ||
| super(config); | ||
| const form = this; | ||
| this.solid = this.s = { | ||
| form: create_store_default( | ||
| () => form, | ||
| (cb) => form.on("*", cb) | ||
| ), | ||
| valid: create_store_default( | ||
| () => form.valid, | ||
| (cb) => form.on("valid", cb) | ||
| ) | ||
| }; | ||
| } | ||
| }; | ||
| var form_solid_default = FormSolid; | ||
| // packages/ffw-solid/src/init-form/init-form.js | ||
| function initForm(config) { | ||
| return new form_solid_default(config); | ||
| } | ||
| var init_form_default = initForm; | ||
| // packages/ffw-solid/src/context/context.js | ||
| var import_solid_js3 = require("solid-js"); | ||
| var context = (0, import_solid_js3.createContext)(); | ||
| var getFfwContext = () => (0, import_solid_js3.useContext)(context); | ||
| var FfwContextProvider = context.Provider; | ||
| // Annotate the CommonJS export names for ESM import in node: | ||
| 0 && (module.exports = { | ||
| FfwContextProvider, | ||
| FieldSolid, | ||
| FormSolid, | ||
| getFfwContext, | ||
| initForm, | ||
| prepareYup | ||
| }); |
| 'use strict'; | ||
| if (process.env.NODE_ENV === 'development') { | ||
| module.exports = require('./dev.js'); | ||
| } else { | ||
| module.exports = require('./prod.js'); | ||
| } |
| { | ||
| "type": "commonjs" | ||
| } |
| var M=Object.create;var d=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var z=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},b=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Y(e))!R.call(t,s)&&s!==r&&d(t,s,{get:()=>e[s],enumerable:!(i=j(e,s))||i.enumerable});return t};var G=(t,e,r)=>(r=t!=null?M(q(t)):{},b(e||!t||!t.__esModule?d(r,"default",{value:t,enumerable:!0}):r,t)),H=t=>b(d({},"__esModule",{value:!0}),t);var lt={};z(lt,{FfwContextProvider:()=>X,FieldSolid:()=>p,FormSolid:()=>S,getFfwContext:()=>B,initForm:()=>D,prepareYup:()=>A});module.exports=H(lt);var I=G(require("yup"),1);function J(t){let e=t||new Map;return{on(r,i){e.has(r)||e.set(r,[]),e.get(r).push(i)},off(r,i){e.has(r)&&e.set(r,e.get(r).filter(s=>s!==i))},emit(r,i){e.has(r)&&e.get(r).forEach(s=>s(i)),e.has("*")&&e.get("*").forEach(s=>s(r,i))}}}var K=J,P=K,T=()=>"",L=class{form=null;ee=P();data={value:"",error:"",touched:!1};constructor({value:t="",touched:e=!1,error:r="",test:i=T,form:s=null}={}){this.form=s,this.test=T,this.initParams={value:t,touched:e,error:r,test:i},this.test=i,this.data.value=t,this.data.error=r,this.data.touched=e,s.addField(this)}get value(){return this.data.value}set value(t){this.set(t)}get error(){return this.data.error}set error(t){this.setError(t)}get touched(){return this.data.touched}set touched(t){this.setTouched(t)}get errorTouched(){return this.data.touched===!1?"":this.data.error}setData(t,e){let r=this.data[t];if(r===e)return;let i=this.errorTouched;if(this.data[t]=e,this.form.calls.add(this,t,()=>this.ee.emit(t,e)),this.form.calls.add(this.form,"*",()=>this.form.ee.emit("global")),t==="error"){let s=r,a=e;a!==""&&s===""?(this.form._errors++,this.form._errors===1&&this.form.calls.add(this.form,"valid",()=>this.form.ee.emit("valid",!1))):a===""&&s!==""&&(this.form._errors--,this.form._errors===0&&this.form.calls.add(this.form,"valid",()=>this.form.ee.emit("valid",!0)))}if(t==="error"||t==="touched"){if(i===this.errorTouched)return;this.form.calls.add(this,"errorTouched",()=>this.ee.emit("errorTouched",this.errorTouched))}}update(){this.form.calls.add(this,"*",()=>this.ee.emit("*")),this.form.calls.add(this.form,"*",()=>this.form.ee.emit("*"))}setError(t){this.setData("error",t)}setTouched(t){this.setData("touched",t)}set(t,e){if(this.setData("value",t),e===!0){this.validate();return}e!==!1&&e===void 0&&this.form.options.validateOnChange&&this.validate()}async validate(){let t=await this.test(this.data.value);return this.setError(t),t}on(t,e){return this.ee.on(t,e),()=>this.ee.off(t,e)}off(t,e){return()=>this.ee.off(t,e)}onInput=t=>{this.set(t.target.value)};onBlur=()=>{this.setTouched(!0),this.form.options.validateOnBlur&&this.validate()};reset(){this.setData("value",this.initParams.value),this.setData("touched",this.initParams.touched),this.setData("error",this.initParams.error)}},n=L;function N(t){let e,r;return[new Promise((i,s)=>{e=i,r=s,t&&t(e,r)}),{resolve:e,reject:r}]}var Q=N,U=Q,W=class{_calls=new Map;constructor(t){this.batch=t||(e=>e())}promise=null;add(t,e,r){if(this._calls.has(t)||this._calls.set(t,new Map),this._calls.get(t).set(e,r),!this.promise){let[i,s]=U();this.promise=i,this.promiseConrtols=s,queueMicrotask(async()=>{await this._call(),this._calls.clear(),this.promiseConrtols.resolve(),this.promise=null})}return this.promise}_call(){return this.batch(()=>{for(let t of this._calls.values())for(let e of t.values())e()})}},Z=W;function $(t){return t?Array.isArray(t)?"array":t.__proto__===Object.prototype?"object":"unknown":"unknown"}var y=$;l.EXIT=Symbol("exit");function l(t,e,r){if(e==="array")for(let i=0;i<t.length;i++){let s=t[i];if(r(s,i)===l.EXIT)return l.EXIT}else if(e==="object"){for(let i in t)if(r(t[i],i)===l.EXIT)return l.EXIT}}var c=l;function C(t,e){let r=y(t);return e(t)===!0?!0:r==="unknown"?!1:c(t,r,i=>{if(C(i,e))return c.EXIT})===c.EXIT}var x=C,tt={array:()=>[],object:()=>({})},et=tt;f.PASS=Symbol("pass");function f(t,e,r){let i=y(t);if(r(t,i))return e(t);if(i==="unknown")return t;let s=et[i]();return c(t,i,(a,k)=>{let w=f(a,e,r);w!==f.PASS&&(s[k]=w)}),s}var m=f;o.PASS=m.PASS;function o(t,e){return m(t,r=>{let i=e(r);return i===o.PASS?m.PASS:o(i,e)},r=>r instanceof n)}var rt=class{options={validateOnChange:!0,validateOnBlur:!0,validateOnMount:!1,checkPrevData:!0};fields={};f=null;validateSchema={};onSubmit=()=>{};initValues={};calls=new Z;ee=P();batch(t){t()}createField(t={}){return new n(t)}_getFlatFieldOrCreate(t,e){return this.fields[t]||(this.fields[t]=this.createField({name:t,form:this,...e})),this.fields[t]}constructor(t={}){this.f=this.fields,this.options={...this.options,...t.options},this.onSubmit=t.onSubmit??(()=>{}),this.initValues=t.initValues??{};for(let r in this.initValues){let i=this.initValues[r];this._getFlatFieldOrCreate(r,{value:i})}t.batch&&(this.batch=t.batch);let e=typeof t.validateSchema=="function"?t.validateSchema(this):t.validateSchema;for(let r in e){let i=e[r],s=this._getFlatFieldOrCreate(r);s.test=i}this.options.validateOnMount&&this.validate()}async validate(){return(await Promise.all([...this._flatFields].map(t=>t.validate()))).every(t=>t==="")}getValid(){return this._errors===0}get valid(){return this.getValid()}submit=async()=>{if(await this.validate())return this.onSubmit(this)};reset(){for(let t of this._flatFields)t.reset()}getData(){function t(e){return o(e,r=>({error:r.error,touched:r.touched,value:t(r.value)}))}return t(this.fields)}getValues(){return o(this.fields,t=>t.value)}getErrors(){return o(this.fields,t=>x(t.value,e=>e instanceof n)?t.value:t.error!==""?t.error:o.PASS)}getTouches(){return o(this.fields,t=>x(t.value,e=>e instanceof n)?t.value:t.touched===!0?t.touched:o.PASS)}get values(){return this.getValues()}get errors(){return this.getErrors()}get touches(){return this.getTouches()}on(t,e){return this.ee.on(t,e),()=>this.ee.off(t,e)}off(t,e){return()=>this.ee.off(t,e)}_errors=0;_flatFields=new Set;addField(t){t.error!==""&&this._errors++,this._flatFields.add(t)}removeField(t){t.error!==""&&this._errors--,this._flatFields.delete(t)}},E=rt;function it(t){return async e=>{try{return await t.validate(e),""}catch(r){return r.message}}}function st(t){return m(t,e=>it(e),e=>e instanceof I.BaseSchema)}var A=st;var v=require("solid-js");function ot(t,e){let[r,i]=(0,v.createSignal)(t()),s=e(a=>{i(a)});return(0,v.onCleanup)(()=>s()),r}var h=ot;function u(t,e){return h(()=>e.data[t],r=>e.on(t,r))}var F=class extends n{constructor(e){super(e);let r=this;this.solid={createStore:i=>u(i,r),field:h(()=>r,i=>r.on("*",i)),value:u("value",r),touched:u("touched",r),error:u("error",r),errorTouched:u("errorTouched",r)},this.s=this.solid}getInput=()=>({value:this.solid.value(),onInput:this.onInput,onBlur:this.onBlur});getSelect=()=>({value:this.solid.value(),onChange:e=>this.set(e),onBlur:this.onBlur})},p=F;var O=require("solid-js");var _=class extends E{createField(e){return new p(e)}batch=O.batch;constructor(e){super(e);let r=this;this.solid=this.s={form:h(()=>r,i=>r.on("*",i)),valid:h(()=>r.valid,i=>r.on("valid",i))}}},S=_;function at(t){return new S(t)}var D=at;var g=require("solid-js"),V=(0,g.createContext)(),B=()=>(0,g.useContext)(V),X=V.Provider;0&&(module.exports={FfwContextProvider,FieldSolid,FormSolid,getFfwContext,initForm,prepareYup}); |
-378
| // packages/ffw/dist/esm/prod.js | ||
| import * as x from "yup"; | ||
| function P(s) { | ||
| let t = s || /* @__PURE__ */ new Map(); | ||
| return { on(e, r) { | ||
| t.has(e) || t.set(e, []), t.get(e).push(r); | ||
| }, off(e, r) { | ||
| t.has(e) && t.set(e, t.get(e).filter((i) => i !== r)); | ||
| }, emit(e, r) { | ||
| t.has(e) && t.get(e).forEach((i) => i(r)), t.has("*") && t.get("*").forEach((i) => i(e, r)); | ||
| } }; | ||
| } | ||
| var V = P; | ||
| var d = V; | ||
| var T = () => ""; | ||
| var p = class { | ||
| form = null; | ||
| ee = d(); | ||
| data = { value: "", error: "", touched: false }; | ||
| constructor({ value: t = "", touched: e = false, error: r = "", test: i = T, form: o = null } = {}) { | ||
| this.form = o, this.test = T, this.initParams = { value: t, touched: e, error: r, test: i }, this.test = i, this.data.value = t, this.data.error = r, this.data.touched = e, o.addField(this); | ||
| } | ||
| get value() { | ||
| return this.data.value; | ||
| } | ||
| set value(t) { | ||
| this.set(t); | ||
| } | ||
| get error() { | ||
| return this.data.error; | ||
| } | ||
| set error(t) { | ||
| this.setError(t); | ||
| } | ||
| get touched() { | ||
| return this.data.touched; | ||
| } | ||
| set touched(t) { | ||
| this.setTouched(t); | ||
| } | ||
| get errorTouched() { | ||
| return this.data.touched === false ? "" : this.data.error; | ||
| } | ||
| setData(t, e) { | ||
| let r = this.data[t]; | ||
| if (r === e) | ||
| return; | ||
| let i = this.errorTouched; | ||
| if (this.data[t] = e, this.form.calls.add(this, t, () => this.ee.emit(t, e)), this.form.calls.add(this.form, "*", () => this.form.ee.emit("global")), t === "error") { | ||
| let o = r, l = e; | ||
| l !== "" && o === "" ? (this.form._errors++, this.form._errors === 1 && this.form.calls.add(this.form, "valid", () => this.form.ee.emit("valid", false))) : l === "" && o !== "" && (this.form._errors--, this.form._errors === 0 && this.form.calls.add(this.form, "valid", () => this.form.ee.emit("valid", true))); | ||
| } | ||
| if (t === "error" || t === "touched") { | ||
| if (i === this.errorTouched) | ||
| return; | ||
| this.form.calls.add(this, "errorTouched", () => this.ee.emit("errorTouched", this.errorTouched)); | ||
| } | ||
| } | ||
| update() { | ||
| this.form.calls.add(this, "*", () => this.ee.emit("*")), this.form.calls.add(this.form, "*", () => this.form.ee.emit("*")); | ||
| } | ||
| setError(t) { | ||
| this.setData("error", t); | ||
| } | ||
| setTouched(t) { | ||
| this.setData("touched", t); | ||
| } | ||
| set(t, e) { | ||
| if (this.setData("value", t), e === true) { | ||
| this.validate(); | ||
| return; | ||
| } | ||
| e !== false && e === void 0 && this.form.options.validateOnChange && this.validate(); | ||
| } | ||
| async validate() { | ||
| let t = await this.test(this.data.value); | ||
| return this.setError(t), t; | ||
| } | ||
| on(t, e) { | ||
| return this.ee.on(t, e), () => this.ee.off(t, e); | ||
| } | ||
| off(t, e) { | ||
| return () => this.ee.off(t, e); | ||
| } | ||
| onInput = (t) => { | ||
| this.set(t.target.value); | ||
| }; | ||
| onBlur = () => { | ||
| this.setTouched(true), this.form.options.validateOnBlur && this.validate(); | ||
| }; | ||
| reset() { | ||
| this.setData("value", this.initParams.value), this.setData("touched", this.initParams.touched), this.setData("error", this.initParams.error); | ||
| } | ||
| }; | ||
| var n = p; | ||
| function O(s) { | ||
| let t, e; | ||
| return [new Promise((r, i) => { | ||
| t = r, e = i, s && s(t, e); | ||
| }), { resolve: t, reject: e }]; | ||
| } | ||
| var A = O; | ||
| var F = A; | ||
| var v = class { | ||
| _calls = /* @__PURE__ */ new Map(); | ||
| constructor(t) { | ||
| this.batch = t || ((e) => e()); | ||
| } | ||
| promise = null; | ||
| add(t, e, r) { | ||
| if (this._calls.has(t) || this._calls.set(t, /* @__PURE__ */ new Map()), this._calls.get(t).set(e, r), !this.promise) { | ||
| let [o, l] = F(); | ||
| this.promise = o, this.promiseConrtols = l, queueMicrotask(async () => { | ||
| await this._call(), this._calls.clear(), this.promiseConrtols.resolve(), this.promise = null; | ||
| }); | ||
| } | ||
| return this.promise; | ||
| } | ||
| _call() { | ||
| return this.batch(() => { | ||
| for (let t of this._calls.values()) | ||
| for (let e of t.values()) | ||
| e(); | ||
| }); | ||
| } | ||
| }; | ||
| var y = v; | ||
| function C(s) { | ||
| return s ? Array.isArray(s) ? "array" : s.__proto__ === Object.prototype ? "object" : "unknown" : "unknown"; | ||
| } | ||
| var c = C; | ||
| u.EXIT = Symbol("exit"); | ||
| function u(s, t, e) { | ||
| if (t === "array") | ||
| for (let r = 0; r < s.length; r++) { | ||
| let i = s[r]; | ||
| if (e(i, r) === u.EXIT) | ||
| return u.EXIT; | ||
| } | ||
| else if (t === "object") { | ||
| for (let r in s) | ||
| if (e(s[r], r) === u.EXIT) | ||
| return u.EXIT; | ||
| } | ||
| } | ||
| var h = u; | ||
| function b(s, t) { | ||
| let e = c(s); | ||
| return t(s) === true ? true : e === "unknown" ? false : h(s, e, (i) => { | ||
| if (b(i, t)) | ||
| return h.EXIT; | ||
| }) === h.EXIT; | ||
| } | ||
| var g = b; | ||
| var D = { array: () => [], object: () => ({}) }; | ||
| var w = D; | ||
| m.PASS = Symbol("pass"); | ||
| function m(s, t, e) { | ||
| let r = c(s); | ||
| if (e(s, r)) | ||
| return t(s); | ||
| if (r === "unknown") | ||
| return s; | ||
| let i = w[r](); | ||
| return h(s, r, (o, l) => { | ||
| let _ = m(o, t, e); | ||
| _ !== m.PASS && (i[l] = _); | ||
| }), i; | ||
| } | ||
| var f = m; | ||
| a.PASS = f.PASS; | ||
| function a(s, t) { | ||
| return f(s, (e) => { | ||
| let r = t(e); | ||
| return r === a.PASS ? f.PASS : a(r, t); | ||
| }, (e) => e instanceof n); | ||
| } | ||
| var S = class { | ||
| options = { validateOnChange: true, validateOnBlur: true, validateOnMount: false, checkPrevData: true }; | ||
| fields = {}; | ||
| f = null; | ||
| validateSchema = {}; | ||
| onSubmit = () => { | ||
| }; | ||
| initValues = {}; | ||
| calls = new y(); | ||
| ee = d(); | ||
| batch(t) { | ||
| t(); | ||
| } | ||
| createField(t = {}) { | ||
| return new n(t); | ||
| } | ||
| _getFlatFieldOrCreate(t, e) { | ||
| return this.fields[t] || (this.fields[t] = this.createField({ name: t, form: this, ...e })), this.fields[t]; | ||
| } | ||
| constructor(t = {}) { | ||
| this.f = this.fields, this.options = { ...this.options, ...t.options }, this.onSubmit = t.onSubmit ?? (() => { | ||
| }), this.initValues = t.initValues ?? {}; | ||
| for (let r in this.initValues) { | ||
| let i = this.initValues[r]; | ||
| this._getFlatFieldOrCreate(r, { value: i }); | ||
| } | ||
| t.batch && (this.batch = t.batch); | ||
| let e = typeof t.validateSchema == "function" ? t.validateSchema(this) : t.validateSchema; | ||
| for (let r in e) { | ||
| let i = e[r], o = this._getFlatFieldOrCreate(r); | ||
| o.test = i; | ||
| } | ||
| this.options.validateOnMount && this.validate(); | ||
| } | ||
| async validate() { | ||
| return (await Promise.all([...this._flatFields].map((e) => e.validate()))).every((e) => e === ""); | ||
| } | ||
| getValid() { | ||
| return this._errors === 0; | ||
| } | ||
| get valid() { | ||
| return this.getValid(); | ||
| } | ||
| submit = async () => { | ||
| if (await this.validate()) | ||
| return this.onSubmit(this); | ||
| }; | ||
| reset() { | ||
| for (let t of this._flatFields) | ||
| t.reset(); | ||
| } | ||
| getData() { | ||
| function t(e) { | ||
| return a(e, (r) => ({ error: r.error, touched: r.touched, value: t(r.value) })); | ||
| } | ||
| return t(this.fields); | ||
| } | ||
| getValues() { | ||
| return a(this.fields, (t) => t.value); | ||
| } | ||
| getErrors() { | ||
| return a(this.fields, (t) => g(t.value, (e) => e instanceof n) ? t.value : t.error !== "" ? t.error : a.PASS); | ||
| } | ||
| getTouches() { | ||
| return a(this.fields, (t) => g(t.value, (e) => e instanceof n) ? t.value : t.touched === true ? t.touched : a.PASS); | ||
| } | ||
| get values() { | ||
| return this.getValues(); | ||
| } | ||
| get errors() { | ||
| return this.getErrors(); | ||
| } | ||
| get touches() { | ||
| return this.getTouches(); | ||
| } | ||
| on(t, e) { | ||
| return this.ee.on(t, e), () => this.ee.off(t, e); | ||
| } | ||
| off(t, e) { | ||
| return () => this.ee.off(t, e); | ||
| } | ||
| _errors = 0; | ||
| _flatFields = /* @__PURE__ */ new Set(); | ||
| addField(t) { | ||
| t.error !== "" && this._errors++, this._flatFields.add(t); | ||
| } | ||
| removeField(t) { | ||
| t.error !== "" && this._errors--, this._flatFields.delete(t); | ||
| } | ||
| }; | ||
| var E = S; | ||
| function I(s) { | ||
| return async (t) => { | ||
| try { | ||
| return await s.validate(t), ""; | ||
| } catch (e) { | ||
| return e.message; | ||
| } | ||
| }; | ||
| } | ||
| function R(s) { | ||
| return f(s, (t) => I(t), (t) => t instanceof x.BaseSchema); | ||
| } | ||
| var X = R; | ||
| // packages/ffw-solid/src/create-store/create-store.js | ||
| import { createSignal, onCleanup } from "solid-js"; | ||
| function createStore(get, subscribe) { | ||
| const [state, setState] = createSignal(get()); | ||
| const unsubscribe = subscribe((value) => { | ||
| setState(value); | ||
| }); | ||
| onCleanup(() => unsubscribe()); | ||
| return state; | ||
| } | ||
| var create_store_default = createStore; | ||
| // packages/ffw-solid/src/field-solid/field-solid.js | ||
| function makeFieldStore(name, field) { | ||
| return create_store_default( | ||
| () => field.data[name], | ||
| (cb) => field.on(name, cb) | ||
| ); | ||
| } | ||
| var FieldSolid = class extends n { | ||
| constructor(config) { | ||
| super(config); | ||
| const field = this; | ||
| this.solid = { | ||
| createStore: (name) => makeFieldStore(name, field), | ||
| field: create_store_default( | ||
| () => field, | ||
| (cb) => field.on("*", cb) | ||
| ), | ||
| value: makeFieldStore("value", field), | ||
| touched: makeFieldStore("touched", field), | ||
| error: makeFieldStore("error", field), | ||
| errorTouched: makeFieldStore("errorTouched", field) | ||
| }; | ||
| this.s = this.solid; | ||
| } | ||
| getInput = () => { | ||
| return { | ||
| value: this.solid.value(), | ||
| onInput: this.onInput, | ||
| onBlur: this.onBlur | ||
| }; | ||
| }; | ||
| getSelect = () => { | ||
| return { | ||
| value: this.solid.value(), | ||
| onChange: (value) => this.set(value), | ||
| onBlur: this.onBlur | ||
| }; | ||
| }; | ||
| }; | ||
| var field_solid_default = FieldSolid; | ||
| // packages/ffw-solid/src/form-solid/form-solid.js | ||
| import { batch } from "solid-js"; | ||
| var FormSolid = class extends E { | ||
| createField(config) { | ||
| return new field_solid_default(config); | ||
| } | ||
| batch = batch; | ||
| constructor(config) { | ||
| super(config); | ||
| const form = this; | ||
| this.solid = this.s = { | ||
| form: create_store_default( | ||
| () => form, | ||
| (cb) => form.on("*", cb) | ||
| ), | ||
| valid: create_store_default( | ||
| () => form.valid, | ||
| (cb) => form.on("valid", cb) | ||
| ) | ||
| }; | ||
| } | ||
| }; | ||
| var form_solid_default = FormSolid; | ||
| // packages/ffw-solid/src/init-form/init-form.js | ||
| function initForm(config) { | ||
| return new form_solid_default(config); | ||
| } | ||
| var init_form_default = initForm; | ||
| // packages/ffw-solid/src/context/context.js | ||
| import { createContext, useContext } from "solid-js"; | ||
| var context = createContext(); | ||
| var getFfwContext = () => useContext(context); | ||
| var FfwContextProvider = context.Provider; | ||
| export { | ||
| FfwContextProvider, | ||
| field_solid_default as FieldSolid, | ||
| form_solid_default as FormSolid, | ||
| getFfwContext, | ||
| init_form_default as initForm, | ||
| X as prepareYup | ||
| }; |
| import*as P from"yup";function E(t){let e=t||new Map;return{on(r,i){e.has(r)||e.set(r,[]),e.get(r).push(i)},off(r,i){e.has(r)&&e.set(r,e.get(r).filter(s=>s!==i))},emit(r,i){e.has(r)&&e.get(r).forEach(s=>s(i)),e.has("*")&&e.get("*").forEach(s=>s(r,i))}}}var I=E,w=I,F=()=>"",A=class{form=null;ee=w();data={value:"",error:"",touched:!1};constructor({value:t="",touched:e=!1,error:r="",test:i=F,form:s=null}={}){this.form=s,this.test=F,this.initParams={value:t,touched:e,error:r,test:i},this.test=i,this.data.value=t,this.data.error=r,this.data.touched=e,s.addField(this)}get value(){return this.data.value}set value(t){this.set(t)}get error(){return this.data.error}set error(t){this.setError(t)}get touched(){return this.data.touched}set touched(t){this.setTouched(t)}get errorTouched(){return this.data.touched===!1?"":this.data.error}setData(t,e){let r=this.data[t];if(r===e)return;let i=this.errorTouched;if(this.data[t]=e,this.form.calls.add(this,t,()=>this.ee.emit(t,e)),this.form.calls.add(this.form,"*",()=>this.form.ee.emit("global")),t==="error"){let s=r,a=e;a!==""&&s===""?(this.form._errors++,this.form._errors===1&&this.form.calls.add(this.form,"valid",()=>this.form.ee.emit("valid",!1))):a===""&&s!==""&&(this.form._errors--,this.form._errors===0&&this.form.calls.add(this.form,"valid",()=>this.form.ee.emit("valid",!0)))}if(t==="error"||t==="touched"){if(i===this.errorTouched)return;this.form.calls.add(this,"errorTouched",()=>this.ee.emit("errorTouched",this.errorTouched))}}update(){this.form.calls.add(this,"*",()=>this.ee.emit("*")),this.form.calls.add(this.form,"*",()=>this.form.ee.emit("*"))}setError(t){this.setData("error",t)}setTouched(t){this.setData("touched",t)}set(t,e){if(this.setData("value",t),e===!0){this.validate();return}e!==!1&&e===void 0&&this.form.options.validateOnChange&&this.validate()}async validate(){let t=await this.test(this.data.value);return this.setError(t),t}on(t,e){return this.ee.on(t,e),()=>this.ee.off(t,e)}off(t,e){return()=>this.ee.off(t,e)}onInput=t=>{this.set(t.target.value)};onBlur=()=>{this.setTouched(!0),this.form.options.validateOnBlur&&this.validate()};reset(){this.setData("value",this.initParams.value),this.setData("touched",this.initParams.touched),this.setData("error",this.initParams.error)}},n=A;function O(t){let e,r;return[new Promise((i,s)=>{e=i,r=s,t&&t(e,r)}),{resolve:e,reject:r}]}var D=O,V=D,B=class{_calls=new Map;constructor(t){this.batch=t||(e=>e())}promise=null;add(t,e,r){if(this._calls.has(t)||this._calls.set(t,new Map),this._calls.get(t).set(e,r),!this.promise){let[i,s]=V();this.promise=i,this.promiseConrtols=s,queueMicrotask(async()=>{await this._call(),this._calls.clear(),this.promiseConrtols.resolve(),this.promise=null})}return this.promise}_call(){return this.batch(()=>{for(let t of this._calls.values())for(let e of t.values())e()})}},X=B;function k(t){return t?Array.isArray(t)?"array":t.__proto__===Object.prototype?"object":"unknown":"unknown"}var b=k;l.EXIT=Symbol("exit");function l(t,e,r){if(e==="array")for(let i=0;i<t.length;i++){let s=t[i];if(r(s,i)===l.EXIT)return l.EXIT}else if(e==="object"){for(let i in t)if(r(t[i],i)===l.EXIT)return l.EXIT}}var d=l;function T(t,e){let r=b(t);return e(t)===!0?!0:r==="unknown"?!1:d(t,r,i=>{if(T(i,e))return d.EXIT})===d.EXIT}var _=T,M={array:()=>[],object:()=>({})},j=M;c.PASS=Symbol("pass");function c(t,e,r){let i=b(t);if(r(t,i))return e(t);if(i==="unknown")return t;let s=j[i]();return d(t,i,(a,C)=>{let g=c(a,e,r);g!==c.PASS&&(s[C]=g)}),s}var f=c;o.PASS=f.PASS;function o(t,e){return f(t,r=>{let i=e(r);return i===o.PASS?f.PASS:o(i,e)},r=>r instanceof n)}var Y=class{options={validateOnChange:!0,validateOnBlur:!0,validateOnMount:!1,checkPrevData:!0};fields={};f=null;validateSchema={};onSubmit=()=>{};initValues={};calls=new X;ee=w();batch(t){t()}createField(t={}){return new n(t)}_getFlatFieldOrCreate(t,e){return this.fields[t]||(this.fields[t]=this.createField({name:t,form:this,...e})),this.fields[t]}constructor(t={}){this.f=this.fields,this.options={...this.options,...t.options},this.onSubmit=t.onSubmit??(()=>{}),this.initValues=t.initValues??{};for(let r in this.initValues){let i=this.initValues[r];this._getFlatFieldOrCreate(r,{value:i})}t.batch&&(this.batch=t.batch);let e=typeof t.validateSchema=="function"?t.validateSchema(this):t.validateSchema;for(let r in e){let i=e[r],s=this._getFlatFieldOrCreate(r);s.test=i}this.options.validateOnMount&&this.validate()}async validate(){return(await Promise.all([...this._flatFields].map(t=>t.validate()))).every(t=>t==="")}getValid(){return this._errors===0}get valid(){return this.getValid()}submit=async()=>{if(await this.validate())return this.onSubmit(this)};reset(){for(let t of this._flatFields)t.reset()}getData(){function t(e){return o(e,r=>({error:r.error,touched:r.touched,value:t(r.value)}))}return t(this.fields)}getValues(){return o(this.fields,t=>t.value)}getErrors(){return o(this.fields,t=>_(t.value,e=>e instanceof n)?t.value:t.error!==""?t.error:o.PASS)}getTouches(){return o(this.fields,t=>_(t.value,e=>e instanceof n)?t.value:t.touched===!0?t.touched:o.PASS)}get values(){return this.getValues()}get errors(){return this.getErrors()}get touches(){return this.getTouches()}on(t,e){return this.ee.on(t,e),()=>this.ee.off(t,e)}off(t,e){return()=>this.ee.off(t,e)}_errors=0;_flatFields=new Set;addField(t){t.error!==""&&this._errors++,this._flatFields.add(t)}removeField(t){t.error!==""&&this._errors--,this._flatFields.delete(t)}},x=Y;function q(t){return async e=>{try{return await t.validate(e),""}catch(r){return r.message}}}function R(t){return f(t,e=>q(e),e=>e instanceof P.BaseSchema)}var z=R;import{createSignal as G,onCleanup as H}from"solid-js";function J(t,e){let[r,i]=G(t()),s=e(a=>{i(a)});return H(()=>s()),r}var h=J;function u(t,e){return h(()=>e.data[t],r=>e.on(t,r))}var m=class extends n{constructor(e){super(e);let r=this;this.solid={createStore:i=>u(i,r),field:h(()=>r,i=>r.on("*",i)),value:u("value",r),touched:u("touched",r),error:u("error",r),errorTouched:u("errorTouched",r)},this.s=this.solid}getInput=()=>({value:this.solid.value(),onInput:this.onInput,onBlur:this.onBlur});getSelect=()=>({value:this.solid.value(),onChange:e=>this.set(e),onBlur:this.onBlur})},v=m;import{batch as K}from"solid-js";var p=class extends x{createField(e){return new v(e)}batch=K;constructor(e){super(e);let r=this;this.solid=this.s={form:h(()=>r,i=>r.on("*",i)),valid:h(()=>r.valid,i=>r.on("valid",i))}}},S=p;function L(t){return new S(t)}var N=L;import{createContext as Q,useContext as U}from"solid-js";var y=Q(),W=()=>U(y),Z=y.Provider;export{Z as FfwContextProvider,v as FieldSolid,S as FormSolid,W as getFfwContext,N as initForm,z as prepareYup}; |
-21
| MIT License | ||
| Copyright (c) 2021 utftufutukgyftryidytftuv | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Mixed license
LicensePackage contains multiple licenses.
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
0
-100%0
-100%1
-50%3
-25%1
-50%1943
-94.89%3
-62.5%42
-95.02%2
Infinity%+ Added
- Removed
- Removed
Updated