UNPKG

tdesign-vue-next

Version:
86 lines (82 loc) 2.8 kB
/** * tdesign v1.19.2 * (c) 2026 tdesign * @license MIT */ import { isEqual, isObject, mapKeys } from 'lodash-es'; import { LoadingPlugin } from './plugin.js'; import 'vue'; import '../_chunks/dep-2a7145b5.js'; import '@babel/runtime/helpers/slicedToArray'; import '@babel/runtime/helpers/defineProperty'; import './icon/gradient.js'; import '@babel/runtime/helpers/toConsumableArray'; import '@babel/runtime/helpers/typeof'; import '../_chunks/dep-c68ea098.js'; import '../_chunks/dep-f0f392fb.js'; import '../_chunks/dep-e8dd47a9.js'; import '../config-provider/hooks/useConfig.js'; import '../config-provider/utils/context.js'; import '../_chunks/dep-509ddbe3.js'; import 'dayjs'; import '../_chunks/dep-91fc762d.js'; import '@babel/runtime/helpers/createClass'; import '@babel/runtime/helpers/classCallCheck'; import '../_chunks/dep-ef7a41ce.js'; import '../_chunks/dep-fbf70ecb.js'; import '@babel/runtime/helpers/objectWithoutProperties'; import '../_chunks/dep-d518fdfb.js'; import '../_chunks/dep-7bdccf65.js'; import '../_chunks/dep-8d4d971b.js'; import '../_chunks/dep-98d89c71.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