1 line
14 KiB
Plaintext

{"version":3,"file":"components.js","sources":["../../../../packages/ui/src/useApp.ts","../../../../packages/ui/src/page/src/index.vue","../../../../packages/ui/src/useCommonMethod.ts","../../../../packages/ui/src/Component.vue","../../../../packages/ui/src/container/src/Container.vue","../../../../packages/ui/src/button/src/index.vue","../../../../packages/ui/src/text/src/index.vue","../../src/comp-entry.ts"],"sourcesContent":["/*\n * Tencent is pleased to support the open source community by making TMagicEditor available.\n *\n * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getCurrentInstance, inject, onMounted, onUnmounted } from 'vue';\n\nimport Core from '@tmagic/core';\n\nexport default (props: any) => {\n const app: Core | undefined = inject('app');\n const node = app?.page?.getNode(props.config.id);\n\n const vm = getCurrentInstance()?.proxy;\n\n node?.emit('created', vm);\n\n onMounted(() => {\n node?.emit('mounted', vm);\n });\n\n onUnmounted(() => {\n node?.emit('destroy', vm);\n });\n\n return app;\n};\n","<template>\n <magic-ui-container class=\"magic-ui-page\" :config=\"config\">\n <slot></slot>\n </magic-ui-container>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, PropType } from 'vue';\n\nimport { MPage } from '@tmagic/schema';\n\nimport useApp from '../../useApp';\n\nexport default defineComponent({\n name: 'magic-ui-page',\n props: {\n config: {\n type: Object as PropType<MPage>,\n defautl: () => ({}),\n },\n },\n\n setup(props) {\n if (props.config) {\n useApp(props);\n }\n },\n});\n</script>\n","/*\n * Tencent is pleased to support the open source community by making TMagicEditor available.\n *\n * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport default (props: any) => ({\n show: () => {\n props.config.style.display = 'initial';\n },\n hide: () => {\n props.config.style.display = 'none';\n },\n});\n","<template>\n <component\n v-if=\"display()\"\n :is=\"tagName\"\n :id=\"config.id\"\n :class=\"`magic-ui-component${config.className ? ` ${config.className}` : ''}`\"\n :style=\"style\"\n :config=\"config\"\n ></component>\n</template>\n\n<script lang=\"ts\">\nimport { computed, defineComponent, getCurrentInstance, provide } from 'vue';\n\nimport { toLine } from '@tmagic/utils';\n\nimport useApp from './useApp';\nimport useCommonMethod from './useCommonMethod';\n\nexport default defineComponent({\n name: 'magic-ui-component',\n\n props: {\n config: {\n type: Object,\n default: () => ({}),\n },\n },\n\n setup(props) {\n const vm = getCurrentInstance()?.proxy;\n const app = useApp(props);\n\n provide('hoc', vm);\n\n return {\n tagName: computed(() => `magic-ui-${toLine(props.config.type)}`),\n style: computed(() => app?.transformStyle(props.config.style)),\n\n display: () => {\n const displayCfg = props.config?.display;\n\n if (typeof displayCfg === 'function') {\n return displayCfg(app);\n }\n return displayCfg !== false;\n },\n ...useCommonMethod(props),\n };\n },\n});\n</script>\n","<template>\n <div\n v-if=\"display()\"\n :id=\"config.id\"\n :class=\"`magic-ui-container${config.className ? ` ${config.className}` : ''}`\"\n :style=\"style\"\n >\n <slot></slot>\n <magic-ui-component v-for=\"item in config.items\" :key=\"item.id\" :config=\"item\"></magic-ui-component>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { computed, defineComponent, PropType } from 'vue';\n\nimport { MContainer } from '@tmagic/schema';\n\nimport Component from '../../Component.vue';\nimport useApp from '../../useApp';\nimport useCommonMethod from '../../useCommonMethod';\n\nexport default defineComponent({\n name: 'magic-ui-container',\n\n components: {\n 'magic-ui-component': Component,\n },\n\n props: {\n config: {\n type: Object as PropType<MContainer>,\n default: () => ({}),\n },\n },\n\n setup(props) {\n const app = useApp(props);\n\n return {\n style: computed(() => app?.transformStyle(props.config.style || {})),\n\n display: () => {\n const displayCfg = props.config?.display;\n\n if (typeof displayCfg === 'function') {\n return displayCfg(app);\n }\n return displayCfg !== false;\n },\n ...useCommonMethod(props),\n };\n },\n});\n</script>\n","<template>\n <button class=\"magic-ui-button\" @click=\"clickHandler\">\n <slot>\n <magic-ui-text :config=\"textConfig\"></magic-ui-text>\n </slot>\n </button>\n</template>\n<script lang=\"ts\">\nimport { computed, defineComponent, getCurrentInstance, PropType, reactive } from 'vue';\n\nimport { MButton, MButtonInstance, MText } from '../../../src/types';\n\nexport default defineComponent({\n name: 'magic-ui-button',\n props: {\n config: {\n type: Object as PropType<MButton>,\n default: () => ({}),\n },\n\n model: {\n type: Object,\n default: () => ({}),\n },\n },\n setup(props) {\n const vm: MButtonInstance = getCurrentInstance()?.proxy as MButtonInstance;\n const actions = reactive<Function[]>([]);\n const actualActions = computed(() => [\n typeof props.config.preAction === 'function' ? props.config.preAction : () => true,\n ...actions,\n typeof props.config.postAction === 'function' ? props.config.postAction : () => true,\n ]);\n function pushAction(action: Function): void {\n actions.push(action);\n }\n async function clickHandler(): Promise<void> {\n for (const fn of actualActions.value) {\n if (typeof fn === 'function') {\n const ret = await fn(vm, { model: props.model });\n if (ret === false) {\n break;\n }\n }\n }\n }\n\n const textConfig = computed<MText>(() => ({\n type: 'text',\n text: props.config?.text || '',\n disabledText: props.config?.disabledText || '',\n html: props.config?.html || '',\n }));\n\n return {\n pushAction,\n clickHandler,\n textConfig,\n };\n },\n});\n</script>\n","<script lang=\"ts\">\nimport { computed, defineComponent, getCurrentInstance, h, inject, PropType } from 'vue';\n\nimport { MComponentInstance, MText, MTextInstance } from '../../../src/types';\n\nexport default defineComponent({\n name: 'magic-ui-text',\n props: {\n config: {\n type: Object as PropType<MText>,\n default: () => ({}),\n },\n\n model: {\n type: Object,\n default: () => ({}),\n },\n\n vars: {\n type: Object,\n default: () => ({}),\n },\n },\n setup(props) {\n const vm: MTextInstance = getCurrentInstance()?.proxy as MTextInstance;\n const hoc: MComponentInstance = inject('hoc');\n const displayText = computed(() => {\n let text = props.config?.text || '';\n const { vars } = props;\n if (hoc?.disabled && props.config?.disabledText) {\n text = props.config.disabledText;\n }\n if (typeof text === 'function') {\n return text.bind(vm)(vm, { model: props.model });\n }\n if (Object.prototype.toString.call(vars) === '[object Object]') {\n let tmp: string = text;\n Object.entries(vars).forEach(([key, value]) => {\n tmp = tmp.replace(new RegExp(`{{${key}}}`, 'g'), value);\n });\n return tmp;\n }\n return text || '';\n });\n\n return {\n displayText,\n };\n },\n\n render() {\n const className = this.config?.multiple ? 'magic-ui-text' : 'magic-ui-text magic-ui-text--single-line';\n if (typeof this.$slots?.default === 'function') {\n return h('span', { class: className }, [this.$slots?.default?.() || '']);\n }\n return h('span', {\n class: className,\n ...(this.displayText ? { innerHTML: this.displayText } : {}),\n });\n },\n});\n</script>\n","import page from '/parisma/github/tmagic-editor/packages/ui/src/page/src/index.vue';\nimport container from '/parisma/github/tmagic-editor/packages/ui/src/container/src/Container.vue';\nimport button from '/parisma/github/tmagic-editor/packages/ui/src/button/src/index.vue';\nimport text from '/parisma/github/tmagic-editor/packages/ui/src/text/src/index.vue';\n\nconst components: Record<string, any> = {\n 'page': page,\n 'container': container,\n 'button': button,\n 'text': text,\n};\n\nconst plugins = {};\n\nconst entry = {\n components,\n plugins,\n};\n\nwindow.magicPresetComponents = entry;\nexport default entry;"],"names":["_sfc_main","text"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,IAAA,SAAA,CAAA,UAAA;;AACE,QAAA,MAA8B;AAC9B,QAAA,OAAA,iCAAA,SAAA,mBAAA,QAAA,MAAA,OAAA;AAEA,QAAA,K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