tdesign-vue-next
Version:
TDesign Component for vue-next
86 lines (82 loc) • 2.8 kB
JavaScript
/**
* tdesign v1.20.3
* (c) 2026 tdesign
* @license MIT
*/
import { isEqual, isObject, mapKeys } from 'lodash-es';
import { LoadingPlugin } from './plugin.js';
import '@babel/runtime/helpers/defineProperty';
import 'vue';
import '../_chunks/dep-45fc4be9.js';
import '@babel/runtime/helpers/slicedToArray';
import './icon/gradient.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/typeof';
import '../_chunks/dep-9a792278.js';
import '../_chunks/dep-0ad1fea4.js';
import '../_chunks/dep-5222f6e9.js';
import '../config-provider/hooks/useConfig.js';
import '../config-provider/utils/context.js';
import '../_chunks/dep-5db45404.js';
import 'dayjs';
import '../_chunks/dep-f7f14b1f.js';
import '@babel/runtime/helpers/createClass';
import '@babel/runtime/helpers/classCallCheck';
import '../_chunks/dep-df8ee692.js';
import '../_chunks/dep-c368cb39.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '../_chunks/dep-5cf1c7d3.js';
import '../_chunks/dep-9adf4ccf.js';
import '../_chunks/dep-1b677277.js';
import '../_chunks/dep-18ea1a72.js';
import './props.js';
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(binding.value)) {
mapKeys(binding.value, function (value, key) {
options[key] = value;
});
}
el[INSTANCE_KEY] = {
options: options,
instance: 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(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();
}
};
export { vLoading as default, vLoading };
//# sourceMappingURL=directive.js.map