chore: update ant-design dependencies and add new icon types
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
export default function get(entity: any, path: (string | number | symbol)[] | readonly (string | number | symbol)[]): any;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
export default function get(entity, path) {
|
||||
var current = entity;
|
||||
for (var i = 0; i < path.length; i += 1) {
|
||||
if (current === null || current === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
current = current[path[i]];
|
||||
}
|
||||
return current;
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
export type Path = (string | number | symbol)[];
|
||||
export default function set<Entity = any, Output = Entity, Value = any>(entity: Entity, paths: Path, value: Value, removeIfUndefined?: boolean): Output;
|
||||
/**
|
||||
* Merge objects which will create
|
||||
*/
|
||||
export declare function merge<T extends object>(...sources: T[]): T;
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import _toArray from "@babel/runtime/helpers/esm/toArray";
|
||||
import get from "./get";
|
||||
function internalSet(entity, paths, value, removeIfUndefined) {
|
||||
if (!paths.length) {
|
||||
return value;
|
||||
}
|
||||
var _paths = _toArray(paths),
|
||||
path = _paths[0],
|
||||
restPath = _paths.slice(1);
|
||||
var clone;
|
||||
if (!entity && typeof path === 'number') {
|
||||
clone = [];
|
||||
} else if (Array.isArray(entity)) {
|
||||
clone = _toConsumableArray(entity);
|
||||
} else {
|
||||
clone = _objectSpread({}, entity);
|
||||
}
|
||||
|
||||
// Delete prop if `removeIfUndefined` and value is undefined
|
||||
if (removeIfUndefined && value === undefined && restPath.length === 1) {
|
||||
delete clone[path][restPath[0]];
|
||||
} else {
|
||||
clone[path] = internalSet(clone[path], restPath, value, removeIfUndefined);
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
export default function set(entity, paths, value) {
|
||||
var removeIfUndefined = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
||||
// Do nothing if `removeIfUndefined` and parent object not exist
|
||||
if (paths.length && removeIfUndefined && value === undefined && !get(entity, paths.slice(0, -1))) {
|
||||
return entity;
|
||||
}
|
||||
return internalSet(entity, paths, value, removeIfUndefined);
|
||||
}
|
||||
function isObject(obj) {
|
||||
return _typeof(obj) === 'object' && obj !== null && Object.getPrototypeOf(obj) === Object.prototype;
|
||||
}
|
||||
function createEmpty(source) {
|
||||
return Array.isArray(source) ? [] : {};
|
||||
}
|
||||
var keys = typeof Reflect === 'undefined' ? Object.keys : Reflect.ownKeys;
|
||||
|
||||
/**
|
||||
* Merge objects which will create
|
||||
*/
|
||||
export function merge() {
|
||||
for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
sources[_key] = arguments[_key];
|
||||
}
|
||||
var clone = createEmpty(sources[0]);
|
||||
sources.forEach(function (src) {
|
||||
function internalMerge(path, parentLoopSet) {
|
||||
var loopSet = new Set(parentLoopSet);
|
||||
var value = get(src, path);
|
||||
var isArr = Array.isArray(value);
|
||||
if (isArr || isObject(value)) {
|
||||
// Only add not loop obj
|
||||
if (!loopSet.has(value)) {
|
||||
loopSet.add(value);
|
||||
var originValue = get(clone, path);
|
||||
if (isArr) {
|
||||
// Array will always be override
|
||||
clone = set(clone, path, []);
|
||||
} else if (!originValue || _typeof(originValue) !== 'object') {
|
||||
// Init container if not exist
|
||||
clone = set(clone, path, createEmpty(value));
|
||||
}
|
||||
keys(value).forEach(function (key) {
|
||||
internalMerge([].concat(_toConsumableArray(path), [key]), loopSet);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
clone = set(clone, path, value);
|
||||
}
|
||||
}
|
||||
internalMerge([]);
|
||||
});
|
||||
return clone;
|
||||
}
|
||||
Reference in New Issue
Block a user