@felte/core
Advanced tools
Comparing version 1.0.0-next.26 to 1.0.0-next.27
@@ -52,3 +52,3 @@ import { __rest } from './external/.pnpm/tslib@2.3.1/external/tslib/tslib.es6.js'; | ||
} | ||
const response = await fetch(action.toString(), fetchOptions); | ||
const response = await window.fetch(action.toString(), fetchOptions); | ||
if (response.ok) | ||
@@ -55,0 +55,0 @@ return response; |
@@ -83,3 +83,6 @@ import { isFormControl, isFieldSetElement, isInputElement } from './typeGuards.js'; | ||
if (Array.isArray(_get(defaultData, elName)) && el.checked) { | ||
defaultData = _update(defaultData, elName, (value) => [...value, el.value]); | ||
defaultData = _update(defaultData, elName, (value) => [ | ||
...value, | ||
el.value, | ||
]); | ||
} | ||
@@ -86,0 +89,0 @@ continue; |
@@ -1,26 +0,6 @@ | ||
import { _cloneDeep } from './cloneDeep.js'; | ||
import { _update } from './update.js'; | ||
/* From: https://stackoverflow.com/a/54733755 */ | ||
/** @ignore */ | ||
function _set(obj, path, value) { | ||
if (Object(obj) !== obj) | ||
obj = {}; | ||
// When obj is not an object | ||
else if (typeof obj !== 'undefined') | ||
obj = _cloneDeep(obj); | ||
// If not yet an array, get the keys from the string-path | ||
const newPath = !Array.isArray(path) | ||
? path.toString().match(/[^.[\]]+/g) || [] | ||
: path; | ||
newPath.slice(0, -1).reduce((a, c, i // Iterate all of them except the last one | ||
) => Object(a[c]) === a[c] // Does the key exist and is its value an object? | ||
? // Yes: then follow that path | ||
a[c] | ||
: // No: create the key. Is the next key a potential array-index? | ||
(a[c] = | ||
Math.abs(Number(newPath[i + 1])) >> 0 === +newPath[i + 1] | ||
? [] // Yes: assign a new array object | ||
: {}), // No: assign a new plain object | ||
obj)[newPath[newPath.length - 1]] = value; // Finally assign the value to the last key | ||
return obj; // Return the top-level object to allow chaining | ||
return _update(obj, path, () => value); | ||
} | ||
@@ -27,0 +7,0 @@ |
@@ -1,24 +0,31 @@ | ||
import { _get } from './get.js'; | ||
import { _cloneDeep } from './cloneDeep.js'; | ||
import { _isPlainObject } from './isPlainObject.js'; | ||
/** @ignore */ | ||
function _update(obj, path, updater) { | ||
if (Object(obj) !== obj) | ||
if (obj) | ||
obj = _cloneDeep(obj); | ||
if (!_isPlainObject(obj)) | ||
obj = {}; | ||
// When obj is not an object | ||
else if (typeof obj !== 'undefined') | ||
obj = _cloneDeep(obj); | ||
// If not yet an array, get the keys from the string-path | ||
const newPath = path.toString().match(/[^.[\]]+/g) || []; | ||
newPath.slice(0, -1).reduce((a, c, i // Iterate all of them except the last one | ||
) => Object(a[c]) === a[c] // Does the key exist and is its value an object? | ||
? // Yes: then follow that path | ||
a[c] | ||
: // No: create the key. Is the next key a potential array-index? | ||
(a[c] = | ||
Math.abs(Number(newPath[i + 1])) >> 0 === +newPath[i + 1] | ||
? [] // Yes: assign a new array object | ||
: {}), // No: assign a new plain object | ||
obj)[newPath[newPath.length - 1]] = updater(_get(obj, path)); // Finally assign the value to the last key | ||
return obj; // Return the top-level object to allow chaining | ||
const splitPath = !Array.isArray(path) ? path.match(/[^.[\]]+/g) || [] : path; | ||
const lastSection = splitPath[splitPath.length - 1]; | ||
if (!lastSection) | ||
return obj; | ||
let property = obj; | ||
for (let i = 0; i < splitPath.length - 1; i++) { | ||
const section = splitPath[i]; | ||
if (!property[section] || | ||
(!_isPlainObject(property[section]) && !Array.isArray(property[section]))) { | ||
const nextSection = splitPath[i + 1]; | ||
if (isNaN(Number(nextSection))) { | ||
property[section] = {}; | ||
} | ||
else { | ||
property[section] = []; | ||
} | ||
} | ||
property = property[section]; | ||
} | ||
property[lastSection] = updater(property[lastSection]); | ||
return obj; | ||
} | ||
@@ -25,0 +32,0 @@ |
@@ -307,3 +307,3 @@ import { deepSetTouched } from './deep-set-touched.js'; | ||
export { createDerivedFactory, createStores }; | ||
export { createDerivedFactory, createStores, errorFilterer, warningFilterer }; | ||
//# sourceMappingURL=stores.js.map |
import { StoreFactory, Obj, Keyed, FormConfig, Errors, Touched, ValidationFunction, PartialWritableErrors } from '@felte/common'; | ||
import { Writable, Readable } from 'svelte/store'; | ||
declare function errorFilterer(touchValue?: unknown, errValue?: unknown): any[] | import("@felte/common/dist/types/types-f8d7390f").DeepSetResult<Record<string, unknown>, null> | null | undefined; | ||
declare function warningFilterer(touchValue?: unknown, errValue?: unknown): any[] | import("@felte/common/dist/types/types-f8d7390f").DeepSetResult<Record<string, unknown>, null> | null | undefined; | ||
type Readables = Readable<any> | [Readable<any>, ...Array<Readable<any>>] | Array<Readable<any>>; | ||
@@ -36,2 +38,2 @@ type ReadableValues<T> = T extends Readable<infer U> ? [U] : { | ||
}; | ||
export { createDerivedFactory, createStores }; | ||
export { errorFilterer, warningFilterer, createDerivedFactory, createStores }; |
{ | ||
"name": "@felte/core", | ||
"version": "1.0.0-next.26", | ||
"version": "1.0.0-next.27", | ||
"description": "Core utility for Felte's integration with front-end frameworks", | ||
@@ -27,3 +27,3 @@ "main": "dist/cjs/index.cjs", | ||
"dependencies": { | ||
"@felte/common": "1.0.0-next.22" | ||
"@felte/common": "1.0.0-next.23" | ||
}, | ||
@@ -33,5 +33,2 @@ "publishConfig": { | ||
}, | ||
"devDependencies": { | ||
"ts-jest": "^26.5.0" | ||
}, | ||
"exports": { | ||
@@ -50,6 +47,6 @@ ".": { | ||
"dev": "rollup -cw", | ||
"test": "jest", | ||
"test:ci": "jest --coverage" | ||
"test": "uvu -r tsm -r global-jsdom/register tests -i common", | ||
"test:ci": "nyc -n src pnpm test" | ||
}, | ||
"readme": "# @felte/core\n\n[![Bundle size](https://img.shields.io/bundlephobia/min/@felte/core)](https://bundlephobia.com/result?p=@felte/core)\n[![NPM Version](https://img.shields.io/npm/v/@felte/core)](https://www.npmjs.com/package/@felte/core)\n\nThe core package containing the main functionality of Felte. This allows to make Felte compatible with multiple frameworks or vanilla javascript. More documenttion on this pending.\n\nSince this package is _bundled_ with other packages, breaking changes might occur in between minor versions, specially if they're required to _prevent_ breaking changes on the other packages.\n\nIf you're looking to use Felte for any of your apps, you're most likely looking for:\n\n- [felte](../felte/README.md) if you're working with Svelte.\n\n- [@felte/solid](../solid/README.md) if you're working with Solid.\n\n- [@felte/react](../react/README.md) if your're working with React.\n" | ||
} |
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
0
0
419854
3716
+ Added@felte/common@1.0.0-next.23(transitive)
- Removed@felte/common@1.0.0-next.22(transitive)
Updated@felte/common@1.0.0-next.23