UNPKG

@opentiny/vue-common

Version:

An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.

1,194 lines (1,193 loc) 38.5 kB
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function(n) { for (var e = 1; e < arguments.length; e++) { var t2 = arguments[e]; for (var r in t2) ({}).hasOwnProperty.call(t2, r) && (n[r] = t2[r]); } return n; }, _extends.apply(null, arguments); } import * as hooks from "vue"; import { capitalize, camelize, hyphenate, debounce, isServer } from "@opentiny/utils"; import { t } from "@opentiny/vue-locale"; import "@opentiny/vue-theme/base/index.css"; import { useInstanceSlots as useInstanceSlots$1, useRelation as useRelation$1 } from "@opentiny/vue-hooks"; var emitter = function emitter2() { var listeners = {}; var on = function on2(event, callback, once) { if (once === void 0) { once = false; } if (event && typeof event === "string" && typeof callback === "function") { var callbacks = listeners[event] || []; listeners[event] = callbacks; callbacks.push(callback); callback.once = once; } }; var emitter22 = { emit: function emit(eventName) { var _arguments = arguments; var callbacks = listeners[eventName]; if (callbacks) { callbacks.forEach(function(callback) { return callback.apply(null, [].slice.call(_arguments, 1)); }); listeners[eventName] = callbacks.filter(function(callback) { return !callback.once; }); } }, on, once: function once(event, callback) { on(event, callback, true); }, off: function off(event, callback) { if (event && typeof event === "string") { var callbacks = listeners[event]; if (typeof callback === "function") { listeners[event] = callbacks.filter(function(cb) { return cb !== callback; }); } else { delete listeners[event]; } } else { listeners = {}; } } }; return emitter22; }; var bindFilter = function bindFilter2(props2, attrs) { if (attrs === void 0) { attrs = {}; } var properties = {}; for (var name in props2) { if (name.indexOf("_") !== 0) { properties[name] = props2[name]; } } for (var _name in attrs) { properties[_name] = attrs[_name]; } return properties; }; var getElementStatusClass = function getElementStatusClass2(className, status) { if (!className || !status) return; var classNames = []; if (typeof className === "string") { classNames.push(className); } else if (Array.isArray(className)) { classNames = className; } var statusList = []; if (typeof status === "string") { statusList.push(status); } else if (Array.isArray(status)) { statusList = status; } var res = []; statusList.forEach(function(status2) { return classNames.forEach(function(name) { return res.push(status2 + ":" + name + "-" + status2); }); }); return classNames.concat(res).join(" "); }; var getElementCssClass = function getElementCssClass2(classes, key) { if (classes === void 0) { classes = {}; } if (typeof key === "object") { var keys = Array.isArray(key) ? key : Object.keys(key).filter(function(k) { return key[k]; }); var cls = ""; keys.forEach(function(k) { if (classes[k]) cls += classes[k] + " "; }); return cls; } else { return classes[key] || ""; } }; var __TINY__ = typeof window === "undefined" ? null : window.__Longque__; var Teleport = hooks.Teleport; var defineAsyncComponent = hooks.defineAsyncComponent; var markRaw = hooks.markRaw; var renderComponent = function renderComponent2(_ref) { var _ref$view = _ref.view, view = _ref$view === void 0 ? void 0 : _ref$view, _ref$component = _ref.component, component = _ref$component === void 0 ? void 0 : _ref$component, props2 = _ref.props, customDesignProps = _ref.customDesignProps, _ref$context = _ref.context, attrs = _ref$context.attrs, slots = _ref$context.slots, _ref$extend = _ref.extend, extend = _ref$extend === void 0 ? {} : _ref$extend; return function() { return hooks.h(view && view.value || component, _extends({ ref: "modeTemplate" }, props2, attrs, customDesignProps, extend), slots); }; }; var rootConfig = function rootConfig2(context) { var instance = hooks.getCurrentInstance(); context && setInstanceEmitter(instance); return instance == null ? void 0 : instance.appContext.config.globalProperties; }; var getCustomProps = function getCustomProps2() { var _instance$vnode; var instance = hooks.getCurrentInstance(); return (instance == null ? void 0 : (_instance$vnode = instance.vnode) == null ? void 0 : _instance$vnode.props) || {}; }; var getComponentName = function getComponentName2() { var _instance$type; var instance = hooks.getCurrentInstance(); var componentName = instance == null ? void 0 : (_instance$type = instance.type) == null ? void 0 : _instance$type.name; if (!componentName) { var _instance$parent, _instance$parent$type; componentName = instance == null ? void 0 : (_instance$parent = instance.parent) == null ? void 0 : (_instance$parent$type = _instance$parent.type) == null ? void 0 : _instance$parent$type.name; } return componentName || ""; }; var appContext = function appContext2() { var _hooks$getCurrentInst; return ((_hooks$getCurrentInst = hooks.getCurrentInstance()) == null ? void 0 : _hooks$getCurrentInst.appContext) || { component: function component() { } }; }; var appProperties = function appProperties2() { var instance = hooks.getCurrentInstance(); return (instance == null ? void 0 : instance.appContext.config.globalProperties) || {}; }; var useRouter = function useRouter2(instance) { var _instance; if (instance === void 0) { instance = hooks.getCurrentInstance(); } var router = (_instance = instance) == null ? void 0 : _instance.appContext.config.globalProperties.$router; var route = router && router.currentRoute.value; return { route, router }; }; var setInstanceEmitter = function setInstanceEmitter2(instance) { var $emitter = emitter(); if (typeof instance.$emitter === "undefined") Object.defineProperty(instance, "$emitter", { get: function get() { return $emitter; } }); }; var emitEvent = function emitEvent2(vm) { var _broadcast = function broadcast(vm2, componentName, eventName, params) { var children22 = vm2.subTree && vm2.subTree.children || vm2.children; Array.isArray(children22) && children22.forEach(function(child) { var name = child.type && child.type.componentName; var component = child.component; if (name === componentName) { component.emit(eventName, params); component.$emitter && component.$emitter.emit(eventName, params); } else { _broadcast(child, componentName, eventName, params); } }); }; return { dispatch: function dispatch(componentName, eventName, params) { var parent22 = vm.parent || vm.root; var name = parent22.type && parent22.type.componentName; while (parent22 && (!name || name !== componentName)) { parent22 = parent22.parent; if (parent22) name = parent22.type && parent22.type.componentName; } if (parent22) { var _parent, _parent2$$emitter; (_parent = parent22).emit.apply(_parent, [eventName].concat(params)); parent22.$emitter && (_parent2$$emitter = parent22.$emitter).emit.apply(_parent2$$emitter, [eventName].concat(params)); } }, broadcast: function broadcast(componentName, eventName, params) { _broadcast(vm, componentName, eventName, params); } }; }; var getRealParent = function getRealParent2(vm) { if (vm && vm.parent) return vm.parent.type.name === "AsyncComponentWrapper" && vm.parent.parent ? vm.parent.parent : vm.parent; }; var parent = function parent2(vm) { return function(handler) { var parent22 = getRealParent(vm); var level = 0; var parentObject = function parentObject2(parent3) { return { level, vm: _createVm({}, parent3), el: parent3.vnode.el, options: parent3.type }; }; if (typeof handler !== "function") return parent22 ? parentObject(parent22) : {}; level++; while (parent22) { if (handler(parentObject(parent22))) break; parent22 = getRealParent(parent22); level++; } }; }; var children = function children2(vm) { return function(handler) { if (typeof handler !== "function") return generateChildren(vm.subTree); var layer = 1; var _broadcast2 = function broadcast(subTree) { if (subTree) { var children22 = subTree.children || subTree.dynamicChildren; var level = layer++; if (Array.isArray(children22)) { if (children22.some(function(child) { return child.component && handler({ level, vm: _createVm({}, child.component), el: child.el, options: child.type, isLevel1: true }); })) return; children22.forEach(function(child) { return _broadcast2(child); }); } } }; _broadcast2(vm.subTree); }; }; var regEventPrefix = /^on[A-Z]/; var generateListeners = function generateListeners2(attrs) { var $attrs = {}; var $listeners = {}; for (var name in attrs) { var event = attrs[name]; if (regEventPrefix.test(name) && typeof event === "function") { $listeners[hyphenate(name.substr(2))] = event; continue; } $attrs[name] = event; } return { $attrs, $listeners }; }; var generateChildren = function generateChildren2(subTree) { var children22 = []; children22.refs = {}; if (subTree) { var arr = subTree.dynamicChildren || subTree.children; if (Array.isArray(arr)) { arr.forEach(function(child) { if (child.component) { var vm = _createVm({}, child.component); children22.push(vm); child.props.ref && (children22.refs[child.props.ref] = vm); } }); } else if (subTree.component) { children22.push(_createVm({}, subTree.component)); } } return children22; }; var originalDefineProperties = function originalDefineProperties2(vm, instance, property, filter22) { var _loop = function _loop2(name2) { if (typeof filter22 === "function" && filter22(name2)) return 1; Object.defineProperty(vm, name2, { configurable: true, enumerable: true, get: function get() { return instance[property][name2]; }, set: function set(value) { return instance[property][name2] = value; } }); }; for (var name in instance[property]) { if (_loop(name)) continue; } return vm; }; var harmonyDefineProperties = function harmonyDefineProperties2(vm, instance, property) { var propertyFilterFlags = __TINY__.SKIP_PREFIX_UNDERSCORE; __TINY__.createDelegate(instance[property], vm, propertyFilterFlags); }; var defineProperties = __TINY__ ? harmonyDefineProperties : originalDefineProperties; var filter = function filter2(name) { return name.indexOf("_") === 0; }; var defineInstanceVm = function defineInstanceVm2(vm, instance) { originalDefineProperties(vm, instance, "setupState", null); originalDefineProperties(vm, instance, "props", filter); defineProperties(vm, instance, "ctx", filter); return vm; }; var _createVm = function createVm(vm, instance, context) { if (context === void 0) { context = null; } var _generateListeners = generateListeners(instance.attrs), $attrs = _generateListeners.$attrs, $listeners = _generateListeners.$listeners; var $emitter = instance.$emitter; if (!$emitter) { setInstanceEmitter(instance); $emitter = instance.$emitter; } var emit = function emit2() { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } instance.emit.apply(instance, args); $emitter.emit.apply(vm, args); }; var $set = function $set2(target, propertyName, value) { return target[propertyName] = value; }; context || defineInstanceVm(vm, instance); Object.defineProperties(vm, { $attrs: { get: function get() { return $attrs; } }, $children: { get: function get() { return generateChildren(instance.subTree); } }, $constants: { get: function get() { return instance.props._constants; } }, $emit: { get: function get() { return emit; } }, $el: { get: function get() { return instance.vnode.el; } }, $listeners: { get: function get() { return $listeners; } }, $mode: { get: function get() { return instance._tiny_mode; } }, $nextTick: { get: function get() { return hooks.nextTick; } }, $off: { get: function get() { return $emitter.off; } }, $on: { get: function get() { return $emitter.on; } }, $once: { get: function get() { return $emitter.once; } }, $options: { get: function get() { return { componentName: instance.type.componentName }; } }, $parent: { get: function get() { return instance.parent && _createVm({}, getRealParent(instance)); } }, $refs: { get: function get() { return instance.refs; } }, $renderless: { get: function get() { return instance.props.tiny_renderless; } }, $scopedSlots: { get: function get() { return instance.slots; } }, $set: { get: function get() { return $set; } }, $slots: { get: function get() { return instance.slots; } }, $template: { get: function get() { return instance.props.tiny_template; } } }); return vm; }; var onBeforeMount = function onBeforeMount2(instance, refs) { for (var name in instance.refs) { if (Object.prototype.hasOwnProperty.call(instance.refs, name)) { refs[name] = instance.refs[name]; } } }; var tools = function tools2(context, mode) { var _instance$proxy, _instance$proxy$$root; var instance = hooks.getCurrentInstance(); var root = instance == null ? void 0 : instance.appContext.config.globalProperties; var _useRouter = useRouter(instance), route = _useRouter.route, router = _useRouter.router; var i18n = instance == null ? void 0 : (_instance$proxy = instance.proxy) == null ? void 0 : (_instance$proxy$$root = _instance$proxy.$root) == null ? void 0 : _instance$proxy$$root.$i18n; var _emitEvent = emitEvent(instance), dispatch = _emitEvent.dispatch, broadcast = _emitEvent.broadcast; var parentHandler = parent(instance); var childrenHandler = children(instance); var vm = _createVm({}, instance, context); var emit = context.emit; var refs = {}; var grandParent = typeof instance.props.tiny_template === "undefined" && getRealParent(instance); var parentVm = grandParent ? _createVm({}, grandParent) : instance.parent ? _createVm({}, instance.parent) : null; var setParentAttribute = function setParentAttribute2(_ref2) { var _instance$parent2; var name = _ref2.name, value = _ref2.value; var ctx = grandParent ? grandParent.ctx : instance == null ? void 0 : (_instance$parent2 = instance.parent) == null ? void 0 : _instance$parent2.ctx; ctx[name] = value; parentVm[name] = value; }; var defineInstanceProperties = function defineInstanceProperties2(props2) { Object.defineProperties(vm, props2); Object.defineProperties(instance == null ? void 0 : instance.ctx, props2); }; var defineParentInstanceProperties = function defineParentInstanceProperties2(props2) { parentVm && Object.defineProperties(parentVm, props2); }; hooks.onBeforeMount(function() { return defineInstanceVm(vm, instance); }); hooks.onMounted(function() { return onBeforeMount(instance, refs); }); return { framework: "vue3", vm, emit, emitter, route, router, dispatch, broadcast, parentHandler, childrenHandler, i18n, refs, slots: instance == null ? void 0 : instance.slots, scopedSlots: instance == null ? void 0 : instance.slots, attrs: context.attrs, parent: parentVm, nextTick: hooks.nextTick, constants: instance == null ? void 0 : instance.props._constants, mode, isPCMode: mode === "pc", isMobileMode: mode === "mobile", service: root == null ? void 0 : root.$service, getService: function getService() { return root == null ? void 0 : root.$getService(vm); }, setParentAttribute, defineInstanceProperties, defineParentInstanceProperties }; }; var mapping = function mapping2(content, before, after) { if (typeof content[before] !== "undefined") { var fn = content[before]; content[after] = function(el, binding, vnode) { vnode.context = binding.instance; fn(el, binding, vnode); }; delete content[before]; } }; var directive = function directive2(directives) { for (var name in directives) { var content = directives[name]; mapping(content, "inserted", "mounted"); mapping(content, "bind", "beforeMount"); mapping(content, "update", "updated"); mapping(content, "unbind", "unmounted"); } return directives; }; var parseVnode = function parseVnode2(vnode) { return vnode; }; var Text = hooks.Text, Comment = hooks.Comment; var isEmptyVnode = function isEmptyVnode2(vnode) { return !vnode || !vnode.type || [Text, Comment].includes(vnode.type); }; var parseProps = function parseProps2(propsData) { var props2 = {}; for (var name in propsData) { if (name === "class" || name === "style") { props2[name] = propsData[name]; } else if (name === "on" || name === "nativeOn") { var events = propsData[name]; for (var eventName in events) props2["on" + capitalize(camelize(eventName))] = events[eventName]; } else if (name === "attrs" || name === "props" || name === "domProps") { var attrs = propsData[name]; for (var key in attrs) props2[key] = attrs[key]; } else { props2[name] = propsData[name]; } } return props2; }; var customResolveComponent = function customResolveComponent2(component) { var type = component; var customElement = false; if (typeof component === "string" && typeof document !== "undefined") { var el = document.createElement(component); var svgTagNames = ["SVG", "CIRCLE", "PATH"]; if (el instanceof HTMLUnknownElement && !svgTagNames.includes(el.nodeName) || component.includes("-")) { component = component.toLowerCase(); customElement = true; if (component === "transition") type = hooks.Transition; else if (component === "transition-group") type = hooks.TransitionGroup; else type = hooks.resolveComponent(component); } else { type = component; } } return { type, component, customElement }; }; var h = function h2(component, propsData, childData) { var props2 = {}; var children22 = childData; var ret = customResolveComponent(component); var customElement = ret.customElement; var type = ret.type; component = ret.component; if (propsData && typeof propsData === "object" && !Array.isArray(propsData)) { props2 = parseProps(propsData); propsData.scopedSlots && (children22 = propsData.scopedSlots); } else if (typeof propsData === "string" || Array.isArray(propsData)) { childData = propsData; } if (typeof childData === "string" || Array.isArray(childData)) children22 = typeof component !== "string" || customElement ? function() { return childData; } : childData; return hooks.h(type, props2, children22); }; var createComponentFn = function createComponentFn2(design2) { return function(_ref3) { var _provide; var component = _ref3.component, propsData = _ref3.propsData, el = _ref3.el; var comp = Object.assign(component, { provide: (_provide = {}, _provide[design2.configKey] = design2.configInstance, _provide) }); var vnode = hooks.createVNode(comp, propsData); hooks.render(vnode, el); return _createVm({}, vnode.component); }; }; var defineComponent = hooks.defineComponent; var isVue2 = false; var isVue3 = true; var isVnode = hooks.isVNode; var KeepAlive = hooks.KeepAlive; var stringifyCssClassObject = function stringifyCssClassObject2(cssClassObject) { var allCssClass = []; Object.keys(cssClassObject).forEach(function(cssClass) { return cssClassObject[cssClass] && allCssClass.push(cssClass); }); return allCssClass.join(" "); }; var stringifyCssClassArray = function stringifyCssClassArray2(cssClassArray) { var allCssClass = []; cssClassArray.forEach(function(cssClass) { if (typeof cssClass === "string") { allCssClass.push(cssClass); } else if (typeof cssClass === "object") { allCssClass.push(stringifyCssClassObject(cssClass)); } }); return allCssClass.join(" "); }; var stringifyCssClass = function stringifyCssClass2(cssClasses) { if (!cssClasses) { return ""; } if (typeof cssClasses === "string") { return cssClasses; } if (Array.isArray(cssClasses) && cssClasses.length > 0) { var allCssClass = []; cssClasses.forEach(function(cssClass) { if (cssClass) { if (typeof cssClass === "string") { allCssClass.push(cssClass); } else if (Array.isArray(cssClass)) { allCssClass.push(stringifyCssClassArray(cssClass)); } else if (typeof cssClass === "object") { allCssClass.push(stringifyCssClassObject(cssClass)); } } }); return allCssClass.join(" "); } if (typeof cssClasses === "object") { return stringifyCssClassObject(cssClasses); } return ""; }; var deduplicateCssClass = function deduplicateCssClass2(cssClasses) { var classNames = stringifyCssClass(cssClasses); var classArray = Array.from(new Set(classNames.split(" "))).filter(function(i) { return i; }); return stringifyCssClass(classArray); }; var useBreakpoint = function useBreakpoint2() { var activeBreakpoint = hooks.ref(""); var prefixes = ["2xl", "xl", "lg", "md", "sm"]; var createMatchMedia = function createMatchMedia2(mediaQueryString) { if (isServer || typeof matchMedia !== "function") { return { matches: false, media: mediaQueryString, addEventListener: function addEventListener() { }, removeEventListener: function removeEventListener() { } }; } else { return window.matchMedia(mediaQueryString); } }; var mediaQuerys = { "2xl": createMatchMedia("(min-width:1536px)"), "xl": createMatchMedia("(min-width:1280px)"), "lg": createMatchMedia("(min-width:1024px)"), "md": createMatchMedia("(min-width:768px)"), "sm": createMatchMedia("(min-width:640px)") }; var setActiveBreakpoint = function setActiveBreakpoint2() { for (var i = 0; i < prefixes.length; i++) { var key = prefixes[i]; if (mediaQuerys[key].matches) { activeBreakpoint.value = key; return; } } activeBreakpoint.value = "default"; }; var mediaQueryListener = debounce(0, function() { return setActiveBreakpoint(); }); setActiveBreakpoint(); prefixes.forEach(function(key) { return mediaQuerys[key].addEventListener("change", mediaQueryListener); }); hooks.onBeforeUnmount(function() { prefixes.forEach(function(key) { return mediaQuerys[key].removeEventListener("change", mediaQueryListener); }); }); return { current: activeBreakpoint }; }; function useDefer(maxCount) { if (maxCount === void 0) { maxCount = 100; } var frameCount = hooks.ref(0); var rafId; function updateFrameCount() { rafId = requestAnimationFrame(function() { frameCount.value++; if (frameCount.value >= maxCount) { return; } updateFrameCount(); }); } function cancel() { if (rafId) { cancelAnimationFrame(rafId); rafId = 0; } } updateFrameCount(); hooks.onBeforeUnmount(function() { return cancel(); }); return { defer: function defer(n) { return frameCount.value >= n; }, reset: function reset() { cancel(); frameCount.value = 0; updateFrameCount(); }, cancel }; } var GRADIENT_ICONS_LIST = ["IconLoadingShadow", "IconNoData"]; var uniqueId = 0; var _generateId = function generateId(vnode, idMaps) { { var _vnode$props; if ((_vnode$props = vnode.props) != null && _vnode$props.id) { var newId = "" + vnode.props.id + uniqueId; idMaps[vnode.props.id] = newId; vnode.props.id = newId; } } if (Array.isArray(vnode == null ? void 0 : vnode.children)) { vnode.children.forEach(function(item) { _generateId(item, idMaps); }); } }; var _generateUrl = function generateUrl(vnode, idMaps) { var checkList = ["fill", "mask", "filter"]; checkList.forEach(function(item) { { var _vnode$props2, _vnode$props2$item; if ((_vnode$props2 = vnode.props) != null && (_vnode$props2$item = _vnode$props2[item]) != null && _vnode$props2$item.includes("url(#")) { var oldId = vnode.props[item].replace("url(#", "").replace(")", ""); var newId = idMaps[oldId]; if (newId) { vnode.props[item] = "url(#" + newId + ")"; } } } }); if (Array.isArray(vnode == null ? void 0 : vnode.children)) { vnode.children.forEach(function(item) { _generateUrl(item, idMaps); }); } }; var generateIcon = function generateIcon2(vnode) { if (!vnode) { return; } var idMaps = {}; _generateId(vnode, idMaps); _generateUrl(vnode, idMaps); uniqueId++; }; var version = "3.undefined"; var useInstanceSlots = useInstanceSlots$1(_extends({}, hooks, { isVue2 })); var useRelation = useRelation$1(_extends({}, hooks, { isVue2 })); var $prefix = "Tiny"; var $props = { "tiny_mode": String, "tiny_mode_root": Boolean, "tiny_template": [Function, Object], "tiny_renderless": Function, "tiny_theme": String, "tiny_mcp_config": Object, "tiny_chart_theme": Object }; var props = ["tiny_mode", "tiny_mode_root", "tiny_template", "tiny_renderless", "_constants", "tiny_theme", "tiny_chart_theme", "tiny_mcp_config"]; var resolveMode = function resolveMode2(props2, context) { var isRightMode = function isRightMode2(mode) { return ~["pc", "mobile", "mobile-first"].indexOf(mode); }; var config = rootConfig(context); var tinyModeProp = typeof props2.tiny_mode === "string" ? props2.tiny_mode : null; var tinyModeInject = hooks.inject("TinyMode", null); var tinyModeGlobal; if (typeof config.tiny_mode === "string") { tinyModeGlobal = config.tiny_mode; } else if (config.tiny_mode) { tinyModeGlobal = config.tiny_mode.value; } if (!isRightMode(tinyModeProp)) tinyModeProp = null; if (!isRightMode(tinyModeInject)) tinyModeInject = null; if (!isRightMode(tinyModeGlobal)) tinyModeGlobal = null; var tinyMode = tinyModeProp || tinyModeInject || tinyModeGlobal || "pc"; if (props2.tiny_mode_root) { hooks.provide("TinyMode", tinyMode); } var instance = hooks.getCurrentInstance(); Object.defineProperty(instance, "_tiny_mode", { value: tinyMode }); return tinyMode; }; var resolveTheme = function resolveTheme2(props2, context) { var isRightTheme = function isRightTheme2(theme) { return ~["tiny", "saas"].indexOf(theme); }; var config = rootConfig(context); var tinyThemeProp = typeof props2.tiny_theme === "string" ? props2.tiny_theme : null; var tinyThemeInject = hooks.inject("TinyTheme", null); var tinyThemeGlobal = config.tiny_theme && config.tiny_theme.value; if (!isRightTheme(tinyThemeProp)) tinyThemeProp = null; if (!isRightTheme(tinyThemeInject)) tinyThemeInject = null; if (!isRightTheme(tinyThemeGlobal)) tinyThemeGlobal = null; var tinyTheme = tinyThemeProp || tinyThemeInject || tinyThemeGlobal || "tiny"; return tinyTheme; }; var resolveChartTheme = function resolveChartTheme2(props2, context) { var config = rootConfig(context); var tinyChartProp = typeof props2.tiny_chart_theme === "object" ? props2.tiny_chart_theme : null; var tinyChartInject = hooks.inject("TinyChartTheme", null); var tinyChartGlobal = config.tiny_chart_theme && config.tiny_chart_theme.value; var tinyChartTheme = tinyChartProp || tinyChartInject || tinyChartGlobal || null; return tinyChartTheme; }; var design = { configKey: Symbol("designConfigKey"), configInstance: null }; var provideDesignConfig = function provideDesignConfig2(designConfig) { if (Object.keys(designConfig).length) { hooks.provide(design.configKey, designConfig); design.configInstance = designConfig; } }; var createComponent = createComponentFn(design); var customDesignConfig = { designConfig: null, twMerge: function twMerge() { return ""; } }; var getDesignConfig = function getDesignConfig2() { var _globalDesignConfig, _globalDesignConfig2, _globalDesignConfig2$; var globalDesignConfig = customDesignConfig.designConfig || hooks.inject(design.configKey, {}); globalDesignConfig = ((_globalDesignConfig = globalDesignConfig) == null ? void 0 : _globalDesignConfig.value) || globalDesignConfig || {}; var designConfig = (_globalDesignConfig2 = globalDesignConfig) == null ? void 0 : (_globalDesignConfig2$ = _globalDesignConfig2.components) == null ? void 0 : _globalDesignConfig2$[getComponentName().replace($prefix, "")]; return { designConfig, globalDesignConfig }; }; var getComponentMcpConfig = function getComponentMcpConfig2() { var _mcpConfig$components; var mcpConfig = globalMcpConfig.mcpConfig; var componentName = getComponentName().replace($prefix, ""); return mcpConfig == null ? void 0 : (_mcpConfig$components = mcpConfig.components) == null ? void 0 : _mcpConfig$components[componentName]; }; var globalMcpConfig = { mcpConfig: null, createMcpTools: null }; var registerMcpConfig = function registerMcpConfig2(mcpConfig, defineTool) { globalMcpConfig.mcpConfig = mcpConfig; globalMcpConfig.createMcpTools = defineTool; }; var $setup = function $setup2(_ref4) { var propData = _ref4.props, context = _ref4.context, template = _ref4.template, _ref4$extend = _ref4.extend, extend = _ref4$extend === void 0 ? {} : _ref4$extend; var mode = resolveMode(propData, context); var view = hooks.computed(function() { if (typeof propData.tiny_template !== "undefined") return propData.tiny_template; var component = template(mode, propData); return typeof component === "function" ? defineAsyncComponent(component) : component; }); var _getDesignConfig = getDesignConfig(), designConfig = _getDesignConfig.designConfig; var customDesignProps = {}; var designProps = designConfig == null ? void 0 : designConfig.props; if (designProps) { var customProps = getCustomProps(); Object.keys(designProps).forEach(function(key) { var camelKey = key.replace(/-(\w)/g, function(_, c) { return c.toUpperCase(); }); var kebabKey = key.replace(/([A-Z])/g, "-$1").toLowerCase(); if (!Object.prototype.hasOwnProperty.call(customProps, camelKey) && !Object.prototype.hasOwnProperty.call(customProps, kebabKey)) { customDesignProps[key] = designProps[key]; } }); } return renderComponent({ view, props: propData, customDesignProps, context, extend }); }; var mergeClass = function mergeClass2() { for (var _len2 = arguments.length, cssClasses = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { cssClasses[_key2] = arguments[_key2]; } return customDesignConfig.twMerge(stringifyCssClass(cssClasses)); }; var setup = function setup2(_ref5) { var props2 = _ref5.props, context = _ref5.context, renderless = _ref5.renderless, api = _ref5.api, _ref5$extendOptions = _ref5.extendOptions, extendOptions = _ref5$extendOptions === void 0 ? {} : _ref5$extendOptions, _ref5$mono = _ref5.mono, mono = _ref5$mono === void 0 ? false : _ref5$mono, _ref5$classes = _ref5.classes, classes = _ref5$classes === void 0 ? {} : _ref5$classes; var render = typeof props2.tiny_renderless === "function" ? props2.tiny_renderless : renderless; var _getDesignConfig2 = getDesignConfig(), designConfig = _getDesignConfig2.designConfig, globalDesignConfig = _getDesignConfig2.globalDesignConfig; var utils = _extends({ $prefix, t }, tools(context, resolveMode(props2, context)), { designConfig, globalDesignConfig, useBreakpoint, mergeClass }); utils.vm.theme = resolveTheme(props2, context); utils.vm.chartTheme = resolveChartTheme(props2, context); var sdk = render(props2, hooks, utils, extendOptions); if (typeof (designConfig == null ? void 0 : designConfig.renderless) === "function") { Object.assign(sdk, designConfig.renderless(props2, hooks, utils, sdk)); } var attrs = { t, vm: utils.vm, f: bindFilter, a: filterAttrs, d: utils.defineInstanceProperties, dp: utils.defineParentInstanceProperties, gcls: function gcls(key) { return getElementCssClass(classes, key); }, m: mergeClass }; attrs.d({ slots: { get: function get() { return utils.vm.$slots; }, configurable: true }, scopedSlots: { get: function get() { return utils.vm.$scopedSlots; }, configurable: true } }); attrs.dp({ slots: { get: function get() { return utils.parent.$slots; }, configurable: true }, scopedSlots: { get: function get() { return utils.parent.$scopedSlots; }, configurable: true } }); initComponent(); if (Array.isArray(api)) { if (Array.isArray(designConfig == null ? void 0 : designConfig.api)) { api = api.concat(designConfig.api); } api.forEach(function(name) { var value = sdk[name]; if (typeof value !== "undefined") { attrs[name] = value; if (!mono) { utils.setParentAttribute({ name, value }); } } }); } var componentMcpConfig = getComponentMcpConfig(); if (componentMcpConfig && props2.tiny_mcp_config && globalMcpConfig.createMcpTools) { globalMcpConfig.createMcpTools(attrs.vm, props2.tiny_mcp_config, componentMcpConfig); } return attrs; }; function svg(_ref6) { var _ref6$name = _ref6.name, name = _ref6$name === void 0 ? "Icon" : _ref6$name, component = _ref6.component; return function(propData) { return markRaw(defineComponent({ name: $prefix + name, setup: function setup3(props2, context) { var _ref7 = context.attrs || {}, fill = _ref7.fill, width = _ref7.width, height = _ref7.height, customClass = _ref7["custom-class"], firstColor = _ref7["first-color"], secondColor = _ref7["second-color"]; var mergeProps = Object.assign({}, props2, propData || null); var mode = resolveMode(mergeProps, context); var isMobileFirst = mode === "mobile-first"; var tinyTag = { "data-tag": isMobileFirst ? "tiny-svg" : null }; var attrs = tinyTag; var className = "tiny-svg"; if (isMobileFirst) { className = mergeClass("h-4 w-4 inline-block", customClass || "", mergeProps.class || ""); } var extend = Object.assign({ style: { fill, width, height, "--tiny-first-color": firstColor || "", "--tiny-second-color": secondColor || "" }, class: className, isSvg: true }, attrs); { extend.nativeOn = context.listeners; } if (GRADIENT_ICONS_LIST.includes(name)) { if (!component.__raw_render) { component.__raw_render = component.render; } component.render = function() { var newRender = component.__raw_render.bind(this); var vnode = newRender.apply(void 0, arguments); generateIcon(vnode); return vnode; }; } return renderComponent({ component, props: mergeProps, context, extend }); } })); }; } var filterAttrs = function filterAttrs2(attrs, filters, include) { var props2 = {}; var _loop2 = function _loop22(name2) { var find = filters.some(function(r) { return new RegExp(r).test(name2); }); if (include && find || !include && !find) { props2[name2] = attrs[name2]; } }; for (var name in attrs) { _loop2(name); } return props2; }; var setupComponent = {}; var initComponent = function initComponent2() { for (var name in setupComponent) { var component = setupComponent[name]; if (typeof component.install === "function") { component.install(appContext()); } if (typeof component.init === "function") { component.init(appProperties()); } } setupComponent = {}; }; var $install = function $install2(component) { component.install = function(Vue) { Vue.component(component.name, component); }; }; var index = { h, directive, parseVnode, isEmptyVnode, useRouter, emitter, createComponent, defineAsyncComponent, filterAttrs, initComponent, setupComponent, svg, $prefix, $props, props, $setup, setup, hooks, getElementStatusClass, $install, isVnode }; export { $install, $prefix, $props, $setup, KeepAlive, Teleport, appProperties, createComponent, customDesignConfig, deduplicateCssClass, index as default, defineAsyncComponent, defineComponent, design, directive, emitter, filterAttrs, getElementStatusClass, h, hooks, initComponent, isEmptyVnode, isVnode, isVue2, isVue3, mergeClass, parseVnode, props, provideDesignConfig, registerMcpConfig, resolveMode, resolveTheme, setup, setupComponent, stringifyCssClass, stringifyCssClassArray, stringifyCssClassObject, svg, useBreakpoint, useDefer, useInstanceSlots, useRelation, useRouter, version };