Removed lodash
parent
8ea3e561b2
commit
06ae612f3b
|
@ -46,8 +46,6 @@
|
|||
<script>
|
||||
import { UniqueComponentId } from '@primevue/core/utils';
|
||||
import { $dt } from '@primevue/themes';
|
||||
import set from 'lodash.set';
|
||||
import unset from 'lodash.unset';
|
||||
|
||||
export default {
|
||||
emits: ['update:modelValue'],
|
||||
|
@ -122,13 +120,13 @@ export default {
|
|||
if (this.path.startsWith(colorSchemePrefix)) {
|
||||
let tokenPath = this.getPathFromColorScheme(this.path.slice(colorSchemePrefix.length));
|
||||
|
||||
set(tokens, tokenPath, this.modelValue);
|
||||
unset(tokens, 'colorScheme.light.' + tokenPath);
|
||||
unset(tokens, 'colorScheme.dark.' + tokenPath);
|
||||
this.set(tokens, tokenPath, this.modelValue);
|
||||
this.unset(tokens, 'colorScheme.light.' + tokenPath);
|
||||
this.unset(tokens, 'colorScheme.dark.' + tokenPath);
|
||||
} else {
|
||||
set(tokens, 'colorScheme.light.' + this.path, this.modelValue);
|
||||
set(tokens, 'colorScheme.dark.' + this.path, this.modelValue);
|
||||
unset(tokens, this.path);
|
||||
this.set(tokens, 'colorScheme.light.' + this.path, this.modelValue);
|
||||
this.set(tokens, 'colorScheme.dark.' + this.path, this.modelValue);
|
||||
this.unset(tokens, this.path);
|
||||
}
|
||||
|
||||
this.removeEmptyProps(tokens);
|
||||
|
@ -155,6 +153,62 @@ export default {
|
|||
}
|
||||
|
||||
return obj;
|
||||
},
|
||||
set(obj, path, value) {
|
||||
if (Object(obj) !== obj) return obj;
|
||||
const pathArray = Array.isArray(path) ? path : path.toString().match(/[^.[\]]+/g) || [];
|
||||
|
||||
pathArray.reduce((acc, key, i) => {
|
||||
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
||||
return acc;
|
||||
}
|
||||
|
||||
if (i === pathArray.length - 1) {
|
||||
acc[key] = value;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
acc[key] = Object(acc[key]) === acc[key] ? acc[key] : {};
|
||||
|
||||
return acc[key];
|
||||
}, obj);
|
||||
|
||||
return obj;
|
||||
},
|
||||
unset(obj, path) {
|
||||
if (Object(obj) !== obj) return false;
|
||||
|
||||
const pathArray = Array.isArray(path) ? path : path.toString().match(/[^.[\]]+/g) || [];
|
||||
|
||||
if (pathArray.length === 0) return false;
|
||||
|
||||
if (pathArray.includes('__proto__') || pathArray.includes('constructor') || pathArray.includes('prototype')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let current = obj;
|
||||
const length = pathArray.length;
|
||||
|
||||
for (let i = 0; i < length - 1; i++) {
|
||||
const key = pathArray[i];
|
||||
|
||||
if (current[key] == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
current = current[key];
|
||||
}
|
||||
|
||||
const lastKey = pathArray[length - 1];
|
||||
|
||||
if (!(lastKey in current)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
delete current[lastKey];
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
|
@ -63,9 +63,7 @@
|
|||
"superstruct": "^2.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@docsearch/js": "^3.3.3",
|
||||
"lodash.set": "^4.3.2",
|
||||
"lodash.unset": "^4.3.2"
|
||||
"@docsearch/js": "^3.3.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.11.0"
|
||||
|
|
|
@ -74,12 +74,6 @@ importers:
|
|||
'@docsearch/js':
|
||||
specifier: ^3.3.3
|
||||
version: 3.8.2(@algolia/client-search@5.19.0)(search-insights@2.17.3)
|
||||
lodash.set:
|
||||
specifier: ^4.3.2
|
||||
version: 4.3.2
|
||||
lodash.unset:
|
||||
specifier: ^4.3.2
|
||||
version: 4.5.2
|
||||
devDependencies:
|
||||
'@primevue/core':
|
||||
specifier: workspace:*
|
||||
|
@ -4307,9 +4301,6 @@ packages:
|
|||
lodash.pick@4.4.0:
|
||||
resolution: {integrity: sha512-hXt6Ul/5yWjfklSGvLQl8vM//l3FtyHZeuelpzK6mm99pNvN9yTDruNZPEJZD1oWrqo+izBmB7oUfWgcCX7s4Q==}
|
||||
|
||||
lodash.set@4.3.2:
|
||||
resolution: {integrity: sha512-4hNPN5jlm/N/HLMCO43v8BXKq9Z7QdAGc/VGrRD61w8gN9g/6jF9A4L1pbUgBLCffi0w9VsXfTOij5x8iTyFvg==}
|
||||
|
||||
lodash.sortby@4.7.0:
|
||||
resolution: {integrity: sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==}
|
||||
|
||||
|
@ -4325,9 +4316,6 @@ packages:
|
|||
lodash.uniq@4.5.0:
|
||||
resolution: {integrity: sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==}
|
||||
|
||||
lodash.unset@4.5.2:
|
||||
resolution: {integrity: sha512-bwKX88k2JhCV9D1vtE8+naDKlLiGrSmf8zi/Y9ivFHwbmRfA8RxS/aVJ+sIht2XOwqoNr4xUPUkGZpc1sHFEKg==}
|
||||
|
||||
lodash@4.17.21:
|
||||
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
|
||||
|
||||
|
@ -11495,8 +11483,6 @@ snapshots:
|
|||
|
||||
lodash.pick@4.4.0: {}
|
||||
|
||||
lodash.set@4.3.2: {}
|
||||
|
||||
lodash.sortby@4.7.0: {}
|
||||
|
||||
lodash.template@4.5.0:
|
||||
|
@ -11512,8 +11498,6 @@ snapshots:
|
|||
|
||||
lodash.uniq@4.5.0: {}
|
||||
|
||||
lodash.unset@4.5.2: {}
|
||||
|
||||
lodash@4.17.21: {}
|
||||
|
||||
loupe@2.3.7:
|
||||
|
|
Loading…
Reference in New Issue