UNPKG

tdesign-vue-next

Version:
321 lines (301 loc) 9.96 kB
/** * tdesign v1.11.5 * (c) 2025 tdesign * @license MIT */ 'use strict'; var loading_plugin = require('../loading/plugin.js'); var isEqual = require('./dep-d4796921.js'); var isObject = require('./dep-0a510359.js'); var _assignValue = require('./dep-ba2090c8.js'); var configProvider_utils_context = require('./dep-b4c4a54b.js'); var cloneDeep = require('./dep-61a7e281.js'); var _typeof = require('@babel/runtime/helpers/typeof'); var _initCloneObject = require('./dep-b6c192db.js'); var get = require('./dep-56c837c8.js'); var hasIn = require('./dep-fd1ddb6b.js'); var _baseGet = require('./dep-55d8c3ed.js'); var identity = require('./dep-abf21389.js'); var isArray = require('./dep-5ad8a2ab.js'); var _baseProperty = require('./dep-d83ac33f.js'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG$1 = 1, COMPARE_UNORDERED_FLAG$1 = 2; /** * The base implementation of `_.isMatch` without support for iteratee shorthands. * * @private * @param {Object} object The object to inspect. * @param {Object} source The object of property values to match. * @param {Array} matchData The property names, values, and compare flags to match. * @param {Function} [customizer] The function to customize comparisons. * @returns {boolean} Returns `true` if `object` is a match, else `false`. */ function baseIsMatch(object, source, matchData, customizer) { var index = matchData.length, length = index, noCustomizer = !customizer; if (object == null) { return !length; } object = Object(object); while (index--) { var data = matchData[index]; if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) { return false; } } while (++index < length) { data = matchData[index]; var key = data[0], objValue = object[key], srcValue = data[1]; if (noCustomizer && data[2]) { if (objValue === undefined && !(key in object)) { return false; } } else { var stack = new _initCloneObject.Stack(); if (customizer) { var result = customizer(objValue, srcValue, key, object, source, stack); } if (!(result === undefined ? isEqual.baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack) : result)) { return false; } } } return true; } /** * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` if suitable for strict * equality comparisons, else `false`. */ function isStrictComparable(value) { return value === value && !isObject.isObject(value); } /** * Gets the property names, values, and compare flags of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the match data of `object`. */ function getMatchData(object) { var result = cloneDeep.keys(object), length = result.length; while (length--) { var key = result[length], value = object[key]; result[length] = [key, value, isStrictComparable(value)]; } return result; } /** * A specialized version of `matchesProperty` for source values suitable * for strict equality comparisons, i.e. `===`. * * @private * @param {string} key The key of the property to get. * @param {*} srcValue The value to match. * @returns {Function} Returns the new spec function. */ function matchesStrictComparable(key, srcValue) { return function (object) { if (object == null) { return false; } return object[key] === srcValue && (srcValue !== undefined || key in Object(object)); }; } /** * The base implementation of `_.matches` which doesn't clone `source`. * * @private * @param {Object} source The object of property values to match. * @returns {Function} Returns the new spec function. */ function baseMatches(source) { var matchData = getMatchData(source); if (matchData.length == 1 && matchData[0][2]) { return matchesStrictComparable(matchData[0][0], matchData[0][1]); } return function (object) { return object === source || baseIsMatch(object, source, matchData); }; } /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; /** * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. * * @private * @param {string} path The path of the property to get. * @param {*} srcValue The value to match. * @returns {Function} Returns the new spec function. */ function baseMatchesProperty(path, srcValue) { if (_baseGet.isKey(path) && isStrictComparable(srcValue)) { return matchesStrictComparable(_baseGet.toKey(path), srcValue); } return function (object) { var objValue = get.get(object, path); return objValue === undefined && objValue === srcValue ? hasIn.hasIn(object, path) : isEqual.baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); }; } /** * A specialized version of `baseProperty` which supports deep paths. * * @private * @param {Array|string} path The path of the property to get. * @returns {Function} Returns the new accessor function. */ function basePropertyDeep(path) { return function (object) { return _baseGet.baseGet(object, path); }; } /** * Creates a function that returns the value at `path` of a given object. * * @static * @memberOf _ * @since 2.4.0 * @category Util * @param {Array|string} path The path of the property to get. * @returns {Function} Returns the new accessor function. * @example * * var objects = [ * { 'a': { 'b': 2 } }, * { 'a': { 'b': 1 } } * ]; * * _.map(objects, _.property('a.b')); * // => [2, 1] * * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); * // => [1, 2] */ function property(path) { return _baseGet.isKey(path) ? _baseProperty.baseProperty(_baseGet.toKey(path)) : basePropertyDeep(path); } /** * The base implementation of `_.iteratee`. * * @private * @param {*} [value=_.identity] The value to convert to an iteratee. * @returns {Function} Returns the iteratee. */ function baseIteratee(value) { // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. if (typeof value == 'function') { return value; } if (value == null) { return identity.identity; } if (_typeof__default["default"](value) == 'object') { return isArray.isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value); } return property(value); } /** * The base implementation of `_.forOwn` without support for iteratee shorthands. * * @private * @param {Object} object The object to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Object} Returns `object`. */ function baseForOwn(object, iteratee) { return object && configProvider_utils_context.baseFor(object, iteratee, cloneDeep.keys); } /** * The opposite of `_.mapValues`; this method creates an object with the * same values as `object` and keys generated by running each own enumerable * string keyed property of `object` thru `iteratee`. The iteratee is invoked * with three arguments: (value, key, object). * * @static * @memberOf _ * @since 3.8.0 * @category Object * @param {Object} object The object to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. * @returns {Object} Returns the new mapped object. * @see _.mapValues * @example * * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { * return key + value; * }); * // => { 'a1': 1, 'b2': 2 } */ function mapKeys(object, iteratee) { var result = {}; iteratee = baseIteratee(iteratee); baseForOwn(object, function (value, key, object) { _assignValue.baseAssignValue(result, iteratee(value, key, object), value); }); return result; } var INSTANCE_KEY = Symbol("TdLoading"); var createInstance = function createInstance(el, binding) { var _binding$modifiers = binding.modifiers, fullscreen = _binding$modifiers.fullscreen, inheritColor = _binding$modifiers.inheritColor; var options = { attach: function attach() { return el; }, fullscreen: fullscreen !== null && fullscreen !== void 0 ? fullscreen : false, inheritColor: inheritColor !== null && inheritColor !== void 0 ? inheritColor : false, loading: binding.value }; if (isObject.isObject(binding.value)) { mapKeys(binding.value, function (value, key) { options[key] = value; }); } el[INSTANCE_KEY] = { options: options, instance: loading_plugin.LoadingPlugin(options) }; }; var vLoading = { mounted: function mounted(el, binding) { if (binding.value) { createInstance(el, binding); } }, updated: function updated(el, binding) { var instance = el[INSTANCE_KEY]; var value = binding.value, oldValue = binding.oldValue; if (!isEqual.isEqual(value, oldValue)) { var _value$loading; var loading = (_value$loading = value === null || value === void 0 ? void 0 : value.loading) !== null && _value$loading !== void 0 ? _value$loading : value; if (loading) { createInstance(el, binding); } else { instance === null || instance === void 0 || instance.instance.hide(); } } }, unmounted: function unmounted(el) { var _el$INSTANCE_KEY; (_el$INSTANCE_KEY = el[INSTANCE_KEY]) === null || _el$INSTANCE_KEY === void 0 || _el$INSTANCE_KEY.instance.hide(); } }; exports.baseForOwn = baseForOwn; exports.baseIteratee = baseIteratee; exports.vLoading = vLoading; //# sourceMappingURL=dep-0d31a2f0.js.map