Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@felte/common

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@felte/common - npm Package Compare versions

Comparing version 0.4.5 to 0.4.6

6

CHANGELOG.md
# @felte/common
## 0.4.6
### Patch Changes
- fc42f8d: Fix getPath
## 0.4.5

@@ -4,0 +10,0 @@

2

dist/esm/utils/getPath.js

@@ -1,2 +0,2 @@

import{isFormControl as e,isFieldSetElement as t}from"./typeGuards.js";function n(e){return e.hasAttribute("data-felte-index")?Number(e.dataset.felteIndex):void 0}function r(r,a){const o=n(r);let d;a?d=a:e(r)&&r.name&&(d=r.name),d=void 0===o?d:`${d}[${o}]`;let i=r.parentNode;if(!i)return d;for(;i&&"FORM"!==i.nodeName;){if(t(i)&&i.name){const e=n(i);d=`${void 0===e?i.name:`${i.name}[${e}]`}.${d}`}i=i.parentNode}return d}export{r as getPath};
import{isFormControl as e,isFieldSetElement as t}from"./typeGuards.js";function n(e){return e.hasAttribute("data-felte-index")?Number(e.dataset.felteIndex):void 0}function r(r,o){const a=n(r);let d="";o?d=o:e(r)&&(d=r.name),d=void 0===a?d:`${d}[${a}]`;let i=r.parentNode;if(!i)return d;for(;i&&"FORM"!==i.nodeName;){if(t(i)&&i.name){const e=n(i);d=`${void 0===e?i.name:`${i.name}[${e}]`}.${d}`}i=i.parentNode}return d}export{r as getPath};
//# sourceMappingURL=getPath.js.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,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]):Array.isArray(e[n])?[...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)){if(Array.isArray(t)){if(t.some(r))return;const n=Array.isArray(e)?e:[];return t.map(((e,t)=>{var r;return null!==(r=n[t])&&void 0!==r?r:e}))}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={}:void 0!==e&&(e=i(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 A(e){return e.hasAttribute("data-felte-index")?Number(e.dataset.felteIndex):void 0}function b(e,t){const n=A(e);let r;t?r=t:p(e)&&e.name&&(r=e.name),r=void 0===n?r:`${r}[${n}]`;let i=e.parentNode;if(!i)return r;for(;i&&"FORM"!==i.nodeName;){if(v(i)&&i.name){const e=A(i);r=`${void 0===e?i.name:`${i.name}[${e}]`}.${r}`}i=i.parentNode}return 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 g(e){return e.type.match(/^(number|range)$/)?e.value?+e.value:void 0:e.value}function O(e,t){if(!p(e))return;const n=t;if(d(e)){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){const t=n;return void(e.value===t?e.checked=!0:e.checked=!1)}if("file"===e.type)return e.files=null,void(e.value="")}e.value=String(n||"")}function j(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;void 0!==e&&(e=i(e));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)))),j):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;let n={};for(const r of e.elements){if(v(r)&&h(r),!p(r)||!r.name)continue;const i=b(r),o=s(r);if(d(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){n=f(n,i,r.checked);continue}n=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;n=f(n,i,r.checked?r.value:void 0);continue}if("file"===r.type){n=f(n,i,r.multiple?Array.from(r.files||[]):null===(t=r.files)||void 0===t?void 0:t[0]);continue}}const u=g(r);n=f(n,i,u)}return{defaultData:n}},e.getIndex=s,e.getInputTextOrNumber=g,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=O,e.setForm=function(e,t){for(const n of e.elements){if(v(n)&&h(n),!p(n)||!n.name)continue;O(n,c(t,b(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]):Array.isArray(e[n])?[...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)){if(Array.isArray(t)){if(t.some(r))return;const n=Array.isArray(e)?e:[];return t.map(((e,t)=>{var r;return null!==(r=n[t])&&void 0!==r?r:e}))}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={}:void 0!==e&&(e=i(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 A(e){return e.hasAttribute("data-felte-index")?Number(e.dataset.felteIndex):void 0}function b(e,t){const n=A(e);let r="";t?r=t:p(e)&&(r=e.name),r=void 0===n?r:`${r}[${n}]`;let i=e.parentNode;if(!i)return r;for(;i&&"FORM"!==i.nodeName;){if(v(i)&&i.name){const e=A(i);r=`${void 0===e?i.name:`${i.name}[${e}]`}.${r}`}i=i.parentNode}return 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 g(e){return e.type.match(/^(number|range)$/)?e.value?+e.value:void 0:e.value}function O(e,t){if(!p(e))return;const n=t;if(d(e)){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){const t=n;return void(e.value===t?e.checked=!0:e.checked=!1)}if("file"===e.type)return e.files=null,void(e.value="")}e.value=String(n||"")}function j(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;void 0!==e&&(e=i(e));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)))),j):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;let n={};for(const r of e.elements){if(v(r)&&h(r),!p(r)||!r.name)continue;const i=b(r),o=s(r);if(d(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){n=f(n,i,r.checked);continue}n=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;n=f(n,i,r.checked?r.value:void 0);continue}if("file"===r.type){n=f(n,i,r.multiple?Array.from(r.files||[]):null===(t=r.files)||void 0===t?void 0:t[0]);continue}}const u=g(r);n=f(n,i,u)}return{defaultData:n}},e.getIndex=s,e.getInputTextOrNumber=g,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=O,e.setForm=function(e,t){for(const n of e.elements){if(v(n)&&h(n),!p(n)||!n.name)continue;O(n,c(t,b(n)))}},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.js.map

@@ -5,6 +5,4 @@ import { FormControl } from "../types-50c3e825";

*/
declare function getPath(el: FormControl, name?: string | undefined): string;
declare function getPath(el: HTMLElement, name?: string | undefined): string | undefined;
declare function getPath(el: HTMLElement | FormControl, name: string): string;
declare function getPath(el: HTMLElement | FormControl, name?: string | undefined): string;
export { getPath };
//# sourceMappingURL=utils/getPath.d.ts.map
{
"name": "@felte/common",
"version": "0.4.5",
"version": "0.4.6",
"description": "Common utilities for Felte packages",

@@ -5,0 +5,0 @@ "author": "Pablo Berganza <pablo@berganza.dev>",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc