@felte/common
Advanced tools
Comparing version 0.3.7 to 0.4.0
# @felte/common | ||
## 0.4.0 | ||
### Minor Changes | ||
- 230e76d: Handle inputs generated with an array | ||
## 0.3.7 | ||
@@ -4,0 +10,0 @@ |
@@ -1,2 +0,2 @@ | ||
export{_some}from"./utils/some.js";export{_mapValues}from"./utils/mapValues.js";export{isFieldValue}from"./utils/isFieldValue.js";export{_cloneDeep}from"./utils/cloneDeep.js";export{_isPlainObject}from"./utils/isPlainObject.js";export{_mergeWith}from"./utils/mergeWith.js";export{_defaultsDeep}from"./utils/defaultsDeep.js";export{_merge}from"./utils/merge.js";export{_get}from"./utils/get.js";export{_set}from"./utils/set.js";export{_unset}from"./utils/unset.js";export{_update}from"./utils/update.js";export{deepSet}from"./utils/deepSet.js";export{deepSome}from"./utils/deepSome.js";export{isElement,isFieldSetElement,isFormControl,isInputElement,isSelectElement,isTextAreaElement}from"./utils/typeGuards.js";export{getPath}from"./utils/getPath.js";export{addAttrsFromFieldset,executeValidation,getFormControls,getFormDefaultValues,getInputTextOrNumber,setControlValue,setForm}from"./utils/domUtils.js"; | ||
export{_some}from"./utils/some.js";export{_mapValues}from"./utils/mapValues.js";export{isFieldValue}from"./utils/isFieldValue.js";export{_cloneDeep}from"./utils/cloneDeep.js";export{_isPlainObject}from"./utils/isPlainObject.js";export{_mergeWith}from"./utils/mergeWith.js";export{_defaultsDeep}from"./utils/defaultsDeep.js";export{_merge}from"./utils/merge.js";export{_get}from"./utils/get.js";export{_set}from"./utils/set.js";export{_unset}from"./utils/unset.js";export{_update}from"./utils/update.js";export{deepSet}from"./utils/deepSet.js";export{deepSome}from"./utils/deepSome.js";export{getIndex}from"./utils/getIndex.js";export{isElement,isFieldSetElement,isFormControl,isInputElement,isSelectElement,isTextAreaElement}from"./utils/typeGuards.js";export{getPath}from"./utils/getPath.js";export{addAttrsFromFieldset,executeValidation,getFormControls,getFormDefaultValues,getInputTextOrNumber,setControlValue,setForm}from"./utils/domUtils.js"; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import{_mapValues as r}from"./mapValues.js";import{_isPlainObject as o}from"./isPlainObject.js";function t(i,m){return r(i,(r=>o(r)?t(r,m):m))}export{t as deepSet}; | ||
import{_mapValues as r}from"./mapValues.js";import{_isPlainObject as n}from"./isPlainObject.js";function t(i,o){return r(i,(r=>n(r)?t(r,o):Array.isArray(r)?r.map(function(r){return function(i){return n(i)?t(i,r):r}}(o)):o))}export{t as deepSet}; | ||
//# sourceMappingURL=deepSet.js.map |
@@ -1,2 +0,2 @@ | ||
import{isFormControl as e,isFieldSetElement as t,isInputElement as n}from"./typeGuards.js";import{_mergeWith as r}from"./mergeWith.js";import{_isPlainObject as o}from"./isPlainObject.js";import{_get as i}from"./get.js";import{_set as a}from"./set.js";import{_update as f}from"./update.js";import{getPath as c}from"./getPath.js";function u(n){if(e(n))return[n];if(0===n.childElementCount)return[];const r=new Set;for(const o of n.children){if(e(o)&&r.add(o),t(o))for(const t of o.elements)e(t)&&r.add(t);o.childElementCount>0&&u(o).forEach((e=>r.add(e)))}return Array.from(r)}function l(n){for(const r of n.elements)(e(r)||t(r))&&(n.name&&r.name&&(r.dataset.felteFieldset=n.dataset.felteFieldset?`${n.dataset.felteFieldset}.${n.name}`:n.name),"true"!==n.dataset.felteUnsetOnRemove||r.hasAttribute("data-felte-unset-on-remove")||(r.dataset.felteUnsetOnRemove="true"))}function s(e){return e.type.match(/^(number|range)$/)?e.value?+e.value:void 0:e.value}function d(r){var o;const u={};for(const d of r.elements){if(t(d)&&l(d),!e(d)||!d.name)continue;const m=c(d);if(n(d)&&"checkbox"===d.type){if(void 0===i(u,m)){if(1===r.querySelectorAll(`[name="${d.name}"]`).length){a(u,m,d.checked);continue}a(u,m,d.checked?[d.value]:[]);continue}Array.isArray(i(u,m))&&d.checked&&f(u,m,(e=>[...e,d.value]));continue}if(n(d)&&"radio"===d.type){if(i(u,m))continue;a(u,m,d.checked?d.value:void 0);continue}if(n(d)&&"file"===d.type){a(u,m,d.multiple?Array.from(d.files||[]):null===(o=d.files)||void 0===o?void 0:o[0]);continue}const v=s(d);a(u,m,v)}return{defaultData:u}}function m(e,t){if(n(e)&&"checkbox"===e.type){const n=t;return void 0===n||"boolean"==typeof n?void(e.checked=!!n):void(Array.isArray(n)&&(n.includes(e.value)?e.checked=!0:e.checked=!1))}if(n(e)&&"radio"===e.type){const n=t;e.value===n?e.checked=!0:e.checked=!1}else{if(n(e)&&"file"===e.type)return e.files=null,void(e.value="");e.value=String(t||"")}}function v(n,r){for(const o of n.elements){if(t(o)&&l(o),!e(o)||!o.name)continue;const n=c(o);m(o,i(r,n))}}function y(e,t){if(!o(e)&&!o(t)){if(null===e)return t;if(null===t)return e;if(e&&t)return Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]),[...e,...t]}}async function h(e,t){if(!t)return;if(!Array.isArray(t))return t(e);const n=await Promise.all(t.map((t=>t(e))));return r(...n,y)}export{l as addAttrsFromFieldset,h as executeValidation,u as getFormControls,d as getFormDefaultValues,s as getInputTextOrNumber,m as setControlValue,v as setForm}; | ||
import{isFormControl as e,isFieldSetElement as t,isInputElement as r}from"./typeGuards.js";import{_mergeWith as n}from"./mergeWith.js";import{_isPlainObject as i}from"./isPlainObject.js";import{_get as o}from"./get.js";import{_set as a}from"./set.js";import{_update as f}from"./update.js";import{getPath as c}from"./getPath.js";import{getIndex as u}from"./getIndex.js";function l(r){if(e(r))return[r];if(0===r.childElementCount)return[];const n=new Set;for(const i of r.children){if(e(i)&&n.add(i),t(i))for(const t of i.elements)e(t)&&n.add(t);i.childElementCount>0&&l(i).forEach((e=>n.add(e)))}return Array.from(n)}function s(r){for(const n of r.elements)if(e(n)||t(n)){if(r.name&&n.name){const e=u(r),t=void 0===e?r.name:`${r.name}[${e}]`;n.dataset.felteFieldset=r.dataset.felteFieldset?`${r.dataset.felteFieldset}.${t}`:t}"true"!==r.dataset.felteUnsetOnRemove||n.hasAttribute("data-felte-unset-on-remove")||(n.dataset.felteUnsetOnRemove="true")}}function d(e){return e.type.match(/^(number|range)$/)?e.value?+e.value:void 0:e.value}function m(n){var i;const l={};for(const m of n.elements){if(t(m)&&s(m),!r(m)||!e(m)||!m.name)continue;const v=c(m),y=u(m);if("checkbox"===m.type){if(void 0===o(l,v)){if(1===Array.from(n.querySelectorAll(`[name="${m.name}"]`)).filter((t=>{if(!e(t))return!1;if(void 0!==y){return Number(t.dataset.felteIndex)===y}return v===c(t)})).length){a(l,v,m.checked);continue}a(l,v,m.checked?[m.value]:[]);continue}Array.isArray(o(l,v))&&m.checked&&f(l,v,(e=>(void 0===y||Array.isArray(e)||(e=[]),[...e,m.value])));continue}if("radio"===m.type){if(o(l,v))continue;a(l,v,m.checked?m.value:void 0);continue}if("file"===m.type){a(l,v,m.multiple?Array.from(m.files||[]):null===(i=m.files)||void 0===i?void 0:i[0]);continue}const p=d(m);a(l,v,p)}return{defaultData:l}}function v(e,t){if(!r(e))return;const n=t;if("checkbox"===e.type){const t=n;return void 0===t||"boolean"==typeof t?void(e.checked=!!t):void(Array.isArray(t)&&(t.includes(e.value)?e.checked=!0:e.checked=!1))}if("radio"!==e.type){if("file"===e.type)return e.files=null,void(e.value="");e.value=String(n||"")}else{const t=n;e.value===t?e.checked=!0:e.checked=!1}}function y(r,n){for(const i of r.elements){if(t(i)&&s(i),!e(i)||!i.name)continue;const r=c(i);v(i,o(n,r))}}function p(e,t){if(!i(e)&&!i(t)){if(null===e)return t;if(null===t)return e;if(e&&t)return Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]),[...e,...t]}}async function h(e,t){if(!t)return;if(!Array.isArray(t))return t(e);const r=await Promise.all(t.map((t=>t(e))));return n(...r,p)}export{s as addAttrsFromFieldset,h as executeValidation,l as getFormControls,m as getFormDefaultValues,d as getInputTextOrNumber,v as setControlValue,y as setForm}; | ||
//# sourceMappingURL=domUtils.js.map |
@@ -1,2 +0,2 @@ | ||
function t(t,o,r){const n=o.split(".");let c=t;try{for(const t of n)c=c[t]}catch(t){return r}return void 0===c?r:c}export{t as _get}; | ||
function t(t,o,e){const l=e=>String.prototype.split.call(o,e).filter(Boolean).reduce(((t,o)=>null!=t?t[o]:t),t),n=l(/[,[\]]+?/)||l(/[,[\].]+?/);return void 0===n||n===t?e:n}export{t as _get}; | ||
//# sourceMappingURL=get.js.map |
@@ -1,2 +0,2 @@ | ||
function e(e){const t=e.dataset.felteFieldset;return t?`${t}.${e.name}`:e.name}export{e as getPath}; | ||
function e(e){const t=e.dataset.felteFieldset,n=function(e){return e.hasAttribute("data-felte-index")?Number(e.dataset.felteIndex):void 0}(e),a=void 0===n?e.name:`${e.name}[${n}]`;return t?`${t}.${a}`:a}export{e as getPath}; | ||
//# sourceMappingURL=getPath.js.map |
@@ -1,2 +0,2 @@ | ||
import{_cloneDeep as o}from"./cloneDeep.js";import{_isPlainObject as e}from"./isPlainObject.js";import{deepSet as t}from"./deepSet.js";function i(...n){const s=n.pop(),f=o(n.shift());if(0===n.length)return f;for(const r of n){if(!r)continue;const n=Object.keys(r);for(const c of n){const n=s(f[c],r[c]);if(void 0!==n)f[c]=n;else if(e(r[c])&&e(f[c]))f[c]=i(f[c],r[c],s);else if(e(r[c])){const e=t(o(r[c]),void 0);f[c]=i(e,r[c],s)}else void 0!==r[c]&&(f[c]=r[c])}}return f}export{i as _mergeWith}; | ||
import{_cloneDeep as o}from"./cloneDeep.js";import{_isPlainObject as e}from"./isPlainObject.js";import{deepSet as r}from"./deepSet.js";function i(...t){const s=t.pop(),f=o(t.shift());if(0===t.length)return f;for(const n of t){if(!n)continue;const t=Object.keys(n);for(const c of t){const t=s(f[c],n[c]);if(void 0!==t)f[c]=t;else if(e(n[c])&&e(f[c]))f[c]=i(f[c],n[c],s);else if(Array.isArray(n[c])&&Array.isArray(f[c]))f[c]=n[c].map(((o,e)=>i(f[c][e],o,s)));else if(e(n[c])){const e=r(o(n[c]),void 0);f[c]=i(e,n[c],s)}else void 0!==n[c]&&(f[c]=n[c])}}return f}export{i as _mergeWith}; | ||
//# sourceMappingURL=mergeWith.js.map |
@@ -1,2 +0,2 @@ | ||
function t(t,n,l){null!=t||(t={});const o=n.split(".");let e=t;for(;o.length-1;){const t=o.shift();t&&(t in e||(e[t]={}),e=e[t])}return e[o[0]]=l,t}export{t as _set}; | ||
function t(t,e,r){Object(t)!==t&&(t={});let c=Array.isArray(e)?e:e.toString().match(/[^.[\]]+/g)||[];return c.slice(0,-1).reduce(((t,e,r)=>Object(t[e])===t[e]?t[e]:t[e]=Math.abs(Number(c[r+1]))>>0==+c[r+1]?[]:{}),t)[c[c.length-1]]=r,t}export{t as _set}; | ||
//# sourceMappingURL=set.js.map |
@@ -1,2 +0,2 @@ | ||
function t(t,e){const n=e.split(".");let o=t;for(;n.length-1;){const t=n.shift();t&&(t in o||(o[t]={}),o=o[t])}return delete o[n[0]],t}export{t as _unset}; | ||
function e(e,r){var t;if(Object(e)!==e)return;let i=Array.isArray(r)?r:r.toString().match(/[^.[\]]+/g)||[];return null===(t=i.slice(0,-1).reduce(((e,r)=>Object(e[r])===e[r]?e[r]:void 0),e))||void 0===t||delete t[i[i.length-1]],e}export{e as _unset}; | ||
//# sourceMappingURL=unset.js.map |
@@ -1,2 +0,2 @@ | ||
function t(t,n,o){const e=n.split(".");let i=t;for(;e.length-1;){const t=e.shift();t&&(t in i||(i[t]={}),i=i[t])}return i[e[0]]=o(i[e[0]]),t}export{t as _update}; | ||
import{_get as t}from"./get.js";function e(e,r,c){Object(e)!==e&&(e={});let n=r.toString().match(/[^.[\]]+/g)||[];return n.slice(0,-1).reduce(((t,e,r)=>Object(t[e])===t[e]?t[e]:t[e]=Math.abs(Number(n[r+1]))>>0==+n[r+1]?[]:{}),e)[n[n.length-1]]=c(t(e,r)),e}export{e as _update}; | ||
//# sourceMappingURL=update.js.map |
@@ -15,6 +15,7 @@ export { _some } from "./utils/some"; | ||
export { deepSome } from "./utils/deepSome"; | ||
export { getIndex } from "./utils/getIndex"; | ||
export * from "./utils/typeGuards"; | ||
export { getPath } from "./utils/getPath"; | ||
export * from "./utils/domUtils"; | ||
export * from "./types-9bd61299"; | ||
export * from "./types-50c3e825"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Common={})}(this,(function(e){"use strict";function t(e,t){return Object.keys(e).some((n=>t(e[n])))}function n(e,t){return Object.keys(e).reduce(((n,o)=>Object.assign(Object.assign({},n),{[o]:t(e[o])})),{})}function o(e){return"[object Object]"===Object.prototype.toString.call(e)}function i(e){return Object.keys(e||{}).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:o(e[n])?i(e[n]):e[n]})),{})}function r(e,t){return n(e,(e=>o(e)?r(e,t):t))}function u(...e){const t=e.pop(),n=i(e.shift());if(0===e.length)return n;for(const c of e){if(!c)continue;const e=Object.keys(c);for(const f of e){const e=t(n[f],c[f]);if(void 0!==e)n[f]=e;else if(o(c[f])&&o(n[f]))n[f]=u(n[f],c[f],t);else if(o(c[f])){const e=r(i(c[f]),void 0);n[f]=u(e,c[f],t)}else void 0!==c[f]&&(n[f]=c[f])}}return n}function c(e,t){if(!o(e)||!o(t))return void 0!==e?e:void 0}function f(e,t,n){const o=t.split(".");let i=e;try{for(const e of o)i=i[e]}catch(e){return n}return void 0===i?n:i}function l(e,t,n){null!=e||(e={});const o=t.split(".");let i=e;for(;o.length-1;){const e=o.shift();e&&(e in i||(i[e]={}),i=i[e])}return i[o[0]]=n,e}function s(e,t,n){const o=t.split(".");let i=e;for(;o.length-1;){const e=o.shift();e&&(e in i||(i[e]={}),i=i[e])}return i[o[0]]=n(i[o[0]]),e}function a(e){var t;return"INPUT"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function d(e){var t;return"TEXTAREA"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function m(e){var t;return"SELECT"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function v(e){var t;return"FIELDSET"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function y(e){return a(e)||d(e)||m(e)}function p(e){const t=e.dataset.felteFieldset;return t?`${t}.${e.name}`:e.name}function h(e){for(const t of e.elements)(y(t)||v(t))&&(e.name&&t.name&&(t.dataset.felteFieldset=e.dataset.felteFieldset?`${e.dataset.felteFieldset}.${e.name}`:e.name),"true"!==e.dataset.felteUnsetOnRemove||t.hasAttribute("data-felte-unset-on-remove")||(t.dataset.felteUnsetOnRemove="true"))}function b(e){return e.type.match(/^(number|range)$/)?e.value?+e.value:void 0:e.value}function g(e,t){if(a(e)&&"checkbox"===e.type){const n=t;return void 0===n||"boolean"==typeof n?void(e.checked=!!n):void(Array.isArray(n)&&(n.includes(e.value)?e.checked=!0:e.checked=!1))}if(a(e)&&"radio"===e.type){const n=t;e.value===n?e.checked=!0:e.checked=!1}else{if(a(e)&&"file"===e.type)return e.files=null,void(e.value="");e.value=String(t||"")}}function A(e,t){if(!o(e)&&!o(t)){if(null===e)return t;if(null===t)return e;if(e&&t)return Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]),[...e,...t]}}e._cloneDeep=i,e._defaultsDeep=function(...e){return u(...e,c)},e._get=f,e._isPlainObject=o,e._mapValues=n,e._merge=function(...e){return u(...e,(()=>{}))},e._mergeWith=u,e._set=l,e._some=t,e._unset=function(e,t){const n=t.split(".");let o=e;for(;n.length-1;){const e=n.shift();e&&(e in o||(o[e]={}),o=o[e])}return delete o[n[0]],e},e._update=s,e.addAttrsFromFieldset=h,e.deepSet=r,e.deepSome=function e(n,i){return t(n,(t=>o(t)?e(t,i):i(t)))},e.executeValidation=async function(e,t){if(!t)return;return Array.isArray(t)?u(...await Promise.all(t.map((t=>t(e)))),A):t(e)},e.getFormControls=function e(t){if(y(t))return[t];if(0===t.childElementCount)return[];const n=new Set;for(const o of t.children){if(y(o)&&n.add(o),v(o))for(const e of o.elements)y(e)&&n.add(e);o.childElementCount>0&&e(o).forEach((e=>n.add(e)))}return Array.from(n)},e.getFormDefaultValues=function(e){var t;const n={};for(const o of e.elements){if(v(o)&&h(o),!y(o)||!o.name)continue;const i=p(o);if(a(o)&&"checkbox"===o.type){if(void 0===f(n,i)){if(1===e.querySelectorAll(`[name="${o.name}"]`).length){l(n,i,o.checked);continue}l(n,i,o.checked?[o.value]:[]);continue}Array.isArray(f(n,i))&&o.checked&&s(n,i,(e=>[...e,o.value]));continue}if(a(o)&&"radio"===o.type){if(f(n,i))continue;l(n,i,o.checked?o.value:void 0);continue}if(a(o)&&"file"===o.type){l(n,i,o.multiple?Array.from(o.files||[]):null===(t=o.files)||void 0===t?void 0:t[0]);continue}l(n,i,b(o))}return{defaultData:n}},e.getInputTextOrNumber=b,e.getPath=p,e.isElement=function(e){return e.nodeType===Node.ELEMENT_NODE},e.isFieldSetElement=v,e.isFieldValue=function(e){return Array.isArray(e)?0===e.length||e.some((e=>e instanceof File||"string"==typeof e)):"string"==typeof e||"number"==typeof e||"boolean"==typeof e||e instanceof File},e.isFormControl=y,e.isInputElement=a,e.isSelectElement=m,e.isTextAreaElement=d,e.setControlValue=g,e.setForm=function(e,t){for(const n of e.elements){if(v(n)&&h(n),!y(n)||!n.name)continue;g(n,f(t,p(n)))}},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Common={})}(this,(function(e){"use strict";function t(e,t){return Object.keys(e).some((n=>t(e[n])))}function n(e,t){return Object.keys(e).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:t(e[r])})),{})}function r(e){return"[object Object]"===Object.prototype.toString.call(e)}function i(e){return Object.keys(e||{}).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:r(e[n])?i(e[n]):e[n]})),{})}function o(e,t){return n(e,(e=>r(e)?o(e,t):Array.isArray(e)?e.map(function(e){return function(t){return r(t)?o(t,e):e}}(t)):t))}function u(...e){const t=e.pop(),n=i(e.shift());if(0===e.length)return n;for(const a of e){if(!a)continue;const e=Object.keys(a);for(const c of e){const e=t(n[c],a[c]);if(void 0!==e)n[c]=e;else if(r(a[c])&&r(n[c]))n[c]=u(n[c],a[c],t);else if(Array.isArray(a[c])&&Array.isArray(n[c]))n[c]=a[c].map(((e,r)=>u(n[c][r],e,t)));else if(r(a[c])){const e=o(i(a[c]),void 0);n[c]=u(e,a[c],t)}else void 0!==a[c]&&(n[c]=a[c])}}return n}function a(e,t){if(!r(e)||!r(t))return void 0!==e?e:void 0}function c(e,t,n){const r=n=>String.prototype.split.call(t,n).filter(Boolean).reduce(((e,t)=>null!=e?e[t]:e),e),i=r(/[,[\]]+?/)||r(/[,[\].]+?/);return void 0===i||i===e?n:i}function f(e,t,n){Object(e)!==e&&(e={});let r=Array.isArray(t)?t:t.toString().match(/[^.[\]]+/g)||[];return r.slice(0,-1).reduce(((e,t,n)=>Object(e[t])===e[t]?e[t]:e[t]=Math.abs(Number(r[n+1]))>>0==+r[n+1]?[]:{}),e)[r[r.length-1]]=n,e}function l(e,t,n){Object(e)!==e&&(e={});let r=t.toString().match(/[^.[\]]+/g)||[];return r.slice(0,-1).reduce(((e,t,n)=>Object(e[t])===e[t]?e[t]:e[t]=Math.abs(Number(r[n+1]))>>0==+r[n+1]?[]:{}),e)[r[r.length-1]]=n(c(e,t)),e}function s(e){return e.hasAttribute("data-felte-index")?Number(e.dataset.felteIndex):void 0}function d(e){var t;return"INPUT"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function m(e){var t;return"TEXTAREA"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function y(e){var t;return"SELECT"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function v(e){var t;return"FIELDSET"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function p(e){return d(e)||m(e)||y(e)}function b(e){const t=e.dataset.felteFieldset,n=function(e){return e.hasAttribute("data-felte-index")?Number(e.dataset.felteIndex):void 0}(e),r=void 0===n?e.name:`${e.name}[${n}]`;return t?`${t}.${r}`:r}function h(e){for(const t of e.elements)if(p(t)||v(t)){if(e.name&&t.name){const n=s(e),r=void 0===n?e.name:`${e.name}[${n}]`;t.dataset.felteFieldset=e.dataset.felteFieldset?`${e.dataset.felteFieldset}.${r}`:r}"true"!==e.dataset.felteUnsetOnRemove||t.hasAttribute("data-felte-unset-on-remove")||(t.dataset.felteUnsetOnRemove="true")}}function A(e){return e.type.match(/^(number|range)$/)?e.value?+e.value:void 0:e.value}function g(e,t){if(!d(e))return;const n=t;if("checkbox"===e.type){const t=n;return void 0===t||"boolean"==typeof t?void(e.checked=!!t):void(Array.isArray(t)&&(t.includes(e.value)?e.checked=!0:e.checked=!1))}if("radio"!==e.type){if("file"===e.type)return e.files=null,void(e.value="");e.value=String(n||"")}else{const t=n;e.value===t?e.checked=!0:e.checked=!1}}function O(e,t){if(!r(e)&&!r(t)){if(null===e)return t;if(null===t)return e;if(e&&t)return Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]),[...e,...t]}}e._cloneDeep=i,e._defaultsDeep=function(...e){return u(...e,a)},e._get=c,e._isPlainObject=r,e._mapValues=n,e._merge=function(...e){return u(...e,(()=>{}))},e._mergeWith=u,e._set=f,e._some=t,e._unset=function(e,t){var n;if(Object(e)!==e)return;let r=Array.isArray(t)?t:t.toString().match(/[^.[\]]+/g)||[];return null===(n=r.slice(0,-1).reduce(((e,t)=>Object(e[t])===e[t]?e[t]:void 0),e))||void 0===n||delete n[r[r.length-1]],e},e._update=l,e.addAttrsFromFieldset=h,e.deepSet=o,e.deepSome=function e(n,i){return t(n,(t=>r(t)?e(t,i):i(t)))},e.executeValidation=async function(e,t){if(!t)return;return Array.isArray(t)?u(...await Promise.all(t.map((t=>t(e)))),O):t(e)},e.getFormControls=function e(t){if(p(t))return[t];if(0===t.childElementCount)return[];const n=new Set;for(const r of t.children){if(p(r)&&n.add(r),v(r))for(const e of r.elements)p(e)&&n.add(e);r.childElementCount>0&&e(r).forEach((e=>n.add(e)))}return Array.from(n)},e.getFormDefaultValues=function(e){var t;const n={};for(const r of e.elements){if(v(r)&&h(r),!d(r)||!p(r)||!r.name)continue;const i=b(r),o=s(r);if("checkbox"===r.type){if(void 0===c(n,i)){if(1===Array.from(e.querySelectorAll(`[name="${r.name}"]`)).filter((e=>{if(!p(e))return!1;if(void 0!==o){return Number(e.dataset.felteIndex)===o}return i===b(e)})).length){f(n,i,r.checked);continue}f(n,i,r.checked?[r.value]:[]);continue}Array.isArray(c(n,i))&&r.checked&&l(n,i,(e=>(void 0===o||Array.isArray(e)||(e=[]),[...e,r.value])));continue}if("radio"===r.type){if(c(n,i))continue;f(n,i,r.checked?r.value:void 0);continue}if("file"===r.type){f(n,i,r.multiple?Array.from(r.files||[]):null===(t=r.files)||void 0===t?void 0:t[0]);continue}const u=A(r);f(n,i,u)}return{defaultData:n}},e.getIndex=s,e.getInputTextOrNumber=A,e.getPath=b,e.isElement=function(e){return e.nodeType===Node.ELEMENT_NODE},e.isFieldSetElement=v,e.isFieldValue=function(e){return Array.isArray(e)?0===e.length||e.some((e=>e instanceof File||"string"==typeof e)):"string"==typeof e||"number"==typeof e||"boolean"==typeof e||e instanceof File},e.isFormControl=p,e.isInputElement=d,e.isSelectElement=y,e.isTextAreaElement=m,e.setControlValue=g,e.setForm=function(e,t){for(const n of e.elements){if(v(n)&&h(n),!p(n)||!n.name)continue;g(n,c(t,b(n)))}},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { Obj } from "../types-9bd61299"; | ||
import { Obj } from "../types-50c3e825"; | ||
/** @ignore */ | ||
@@ -3,0 +3,0 @@ declare function _cloneDeep<T extends Obj>(obj: T): T; |
@@ -1,2 +0,2 @@ | ||
import { Obj, DeepSetResult } from "../types-9bd61299"; | ||
import { Obj, DeepSetResult } from "../types-50c3e825"; | ||
/** | ||
@@ -3,0 +3,0 @@ * @category Helper |
@@ -1,2 +0,2 @@ | ||
import { Obj } from "../types-9bd61299"; | ||
import { Obj } from "../types-50c3e825"; | ||
/** | ||
@@ -3,0 +3,0 @@ * @category Helper |
@@ -1,2 +0,2 @@ | ||
import { Obj } from "../types-9bd61299"; | ||
import { Obj } from "../types-50c3e825"; | ||
/** @ignore */ | ||
@@ -3,0 +3,0 @@ declare function _defaultsDeep<T extends Obj>(...args: any[]): T; |
@@ -1,2 +0,2 @@ | ||
import { FormControl, Obj, FieldValue, ValidationFunction } from "../types-9bd61299"; | ||
import { FormControl, Obj, FieldValue, ValidationFunction } from "../types-50c3e825"; | ||
/** | ||
@@ -18,3 +18,3 @@ * @ignore | ||
}; | ||
declare function setControlValue(el: FormControl, value: FieldValue): void; | ||
declare function setControlValue(el: FormControl, value: FieldValue | FieldValue[]): void; | ||
/** Sets the form inputs value to match the data object provided. */ | ||
@@ -21,0 +21,0 @@ declare function setForm<Data extends Obj>(node: HTMLFormElement, data: Data): void; |
@@ -1,5 +0,5 @@ | ||
import { Obj, FieldValue } from "../types-9bd61299"; | ||
import { Obj, FieldValue } from "../types-50c3e825"; | ||
/** @ignore */ | ||
declare function _get<Data extends Obj, Default = undefined>(obj: Data, path: string, defaultValue?: Default): FieldValue | Default | undefined; | ||
declare function _get<Data extends Obj, Default = undefined>(obj: Data, path: string, defaultValue?: Default): Default | FieldValue | FieldValue[] | undefined; | ||
export { _get }; | ||
//# sourceMappingURL=utils/get.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { FormControl } from "../types-9bd61299"; | ||
import { FormControl } from "../types-50c3e825"; | ||
/** | ||
@@ -3,0 +3,0 @@ * @category Helper |
@@ -1,2 +0,2 @@ | ||
import { FieldValue } from "../types-9bd61299"; | ||
import { FieldValue } from "../types-50c3e825"; | ||
/** @category Helper */ | ||
@@ -3,0 +3,0 @@ declare function isFieldValue(value: unknown): value is FieldValue; |
@@ -1,2 +0,2 @@ | ||
import { Obj } from "../types-9bd61299"; | ||
import { Obj } from "../types-50c3e825"; | ||
/** @ignore */ | ||
@@ -3,0 +3,0 @@ declare function _mapValues(obj: Obj, updater: (value: unknown) => unknown): Obj; |
@@ -1,2 +0,2 @@ | ||
import { Obj } from "../types-9bd61299"; | ||
import { Obj } from "../types-50c3e825"; | ||
/** @ignore */ | ||
@@ -3,0 +3,0 @@ declare function _merge<T extends Obj>(...args: any[]): T; |
@@ -1,2 +0,2 @@ | ||
import { Obj } from "../types-9bd61299"; | ||
import { Obj } from "../types-50c3e825"; | ||
/** @ignore */ | ||
@@ -3,0 +3,0 @@ declare function _mergeWith<T extends Obj>(...args: any[]): T; |
@@ -1,5 +0,5 @@ | ||
import { Obj, FieldValue } from "../types-9bd61299"; | ||
import { Obj, FieldValue } from "../types-50c3e825"; | ||
/** @ignore */ | ||
declare function _set<Data extends Obj>(obj: Data | undefined, path: string, value: FieldValue): Data; | ||
declare function _set<Data extends Obj>(obj: Data | undefined, path: string | string[], value: FieldValue | FieldValue[]): Data; | ||
export { _set }; | ||
//# sourceMappingURL=utils/set.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { Obj } from "../types-9bd61299"; | ||
import { Obj } from "../types-50c3e825"; | ||
/** @ignore */ | ||
@@ -3,0 +3,0 @@ declare function _some(obj: Obj, pred: (value: unknown) => boolean): boolean; |
@@ -1,2 +0,2 @@ | ||
import { FormControl } from "../types-9bd61299"; | ||
import { FormControl } from "../types-50c3e825"; | ||
/** | ||
@@ -3,0 +3,0 @@ * @category Helper |
@@ -1,5 +0,6 @@ | ||
import { Obj } from "../types-9bd61299"; | ||
import { Obj } from "../types-50c3e825"; | ||
/** @ignore */ | ||
declare function _unset<Data extends Obj>(obj: Data, path: string): Data; | ||
declare function _unset(obj: undefined, path: string | string[]): undefined; | ||
declare function _unset<Data extends Obj>(obj: Data, path: string | string[]): Data; | ||
export { _unset }; | ||
//# sourceMappingURL=utils/unset.d.ts.map |
@@ -1,5 +0,5 @@ | ||
import { Obj, FieldValue } from "../types-9bd61299"; | ||
import { Obj, FieldValue } from "../types-50c3e825"; | ||
/** @ignore */ | ||
declare function _update<Data extends Obj, Value = FieldValue>(obj: Data, path: string, updater: (value: Value) => Value): Data; | ||
declare function _update<Data extends Obj, Value = FieldValue>(obj: Data | undefined, path: string, updater: (value: Value) => Value): Data; | ||
export { _update }; | ||
//# sourceMappingURL=utils/update.d.ts.map |
{ | ||
"name": "@felte/common", | ||
"version": "0.3.7", | ||
"description": "Common utilities for Felte packages", | ||
"author": "Pablo Berganza <pablo@berganza.dev>", | ||
"homepage": "https://github.com/pablo-abc/felte/tree/main/packages/common", | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"browser": "dist/index.js", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/index.d.ts", | ||
"sideEffects": false, | ||
"keywords": [ | ||
"svelte", | ||
"forms", | ||
"utility" | ||
], | ||
"files": [ | ||
"dist" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://git@github.com/pablo-abc/felte.git" | ||
}, | ||
"scripts": { | ||
"prebuild": "rimraf ./dist", | ||
"build": "cross-env NODE_ENV=production rollup -c", | ||
"dev": "rollup -cw", | ||
"prepublishOnly": "yarn build", | ||
"test": "jest", | ||
"test:ci": "jest --ci --coverage" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/pablo-abc/felte/issues" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": {}, | ||
"exports": { | ||
".": { | ||
"import": "./dist/esm/index.js", | ||
"require": "./dist/index.js" | ||
}, | ||
"./dist/utils/*": "./dist/esm/utils/*.js", | ||
"./package.json": "./package.json" | ||
} | ||
"name": "@felte/common", | ||
"version": "0.4.0", | ||
"description": "Common utilities for Felte packages", | ||
"author": "Pablo Berganza <pablo@berganza.dev>", | ||
"homepage": "https://github.com/pablo-abc/felte/tree/main/packages/common", | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"browser": "dist/index.js", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/index.d.ts", | ||
"sideEffects": false, | ||
"keywords": [ | ||
"svelte", | ||
"forms", | ||
"utility" | ||
], | ||
"files": [ | ||
"dist" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://git@github.com/pablo-abc/felte.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/pablo-abc/felte/issues" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": {}, | ||
"exports": { | ||
".": { | ||
"import": "./dist/esm/index.js", | ||
"require": "./dist/index.js" | ||
}, | ||
"./dist/utils/*": "./dist/esm/utils/*.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"scripts": { | ||
"prebuild": "rimraf ./dist", | ||
"build": "cross-env NODE_ENV=production rollup -c", | ||
"dev": "rollup -cw", | ||
"test": "jest", | ||
"test:ci": "jest --ci --coverage" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94766
84
338
1