diff --git a/packages/core/package.json b/packages/core/package.json index 763392a8..9b37420f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -11,9 +11,9 @@ "import": "./dist/tmagic-core.js", "require": "./dist/tmagic-core.umd.cjs" }, - "./dist/style.css": { - "import": "./dist/style.css", - "require": "./dist/style.css" + "./resetcss.css": { + "import": "./resetcss.css", + "require": "./resetcss.css" }, "./*": "./*" }, @@ -37,6 +37,10 @@ "vue" ], "dependencies": { + "@tmagic/data-source": "workspace:*", + "@tmagic/dep": "workspace:*", + "@tmagic/schema": "workspace:*", + "@tmagic/utils": "workspace:*", "events": "^3.3.0", "lodash-es": "^4.17.21" }, @@ -48,9 +52,6 @@ "vite": "^5.3.5" }, "peerDependencies": { - "@tmagic/data-source": "workspace:*", - "@tmagic/schema": "workspace:*", - "@tmagic/utils": "workspace:*", "typescript": "*" }, "peerDependenciesMeta": { diff --git a/packages/utils/src/resetcss.css b/packages/core/resetcss.css similarity index 100% rename from packages/utils/src/resetcss.css rename to packages/core/resetcss.css diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index c6d9da90..aab4cb19 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -18,6 +18,11 @@ import App from './App'; +export * from '@tmagic/data-source'; +export * from '@tmagic/dep'; +export * from '@tmagic/schema'; +export * from '@tmagic/utils'; + export { default as EventHelper } from './EventHelper'; export * from './utils'; diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts index f350a8fd..b3210410 100644 --- a/packages/core/src/utils.ts +++ b/packages/core/src/utils.ts @@ -16,6 +16,7 @@ * limitations under the License. */ import { JsEngine } from '@tmagic/schema'; +import { isNumber } from '@tmagic/utils'; import type { default as TMagicNode } from './Node'; @@ -57,8 +58,6 @@ export const fillBackgroundImage = (value: string) => { return value; }; -export const isNumber = (value: string) => /^(-?\d+)(\.\d+)?$/.test(value); - export const getTransform = (value: Record, jsEngine: JsEngine) => { if (!value) return []; diff --git a/packages/data-source/package.json b/packages/data-source/package.json index e5412d01..bf2117d6 100644 --- a/packages/data-source/package.json +++ b/packages/data-source/package.json @@ -33,15 +33,12 @@ "data-source" ], "dependencies": { - "@tmagic/dep": "workspace:*", "deep-state-observer": "^5.5.13", "events": "^3.3.0", "lodash-es": "^4.17.21" }, "peerDependencies": { "@tmagic/core": "workspace:*", - "@tmagic/schema": "workspace:*", - "@tmagic/utils": "workspace:*", "typescript": "*" }, "peerDependenciesMeta": { diff --git a/packages/data-source/src/DataSourceManager.ts b/packages/data-source/src/DataSourceManager.ts index 136f7bb4..1f4457c8 100644 --- a/packages/data-source/src/DataSourceManager.ts +++ b/packages/data-source/src/DataSourceManager.ts @@ -20,9 +20,8 @@ import EventEmitter from 'events'; import { cloneDeep } from 'lodash-es'; -import type { default as TMagicApp } from '@tmagic/core'; -import type { DataSourceSchema, DisplayCond, Id, MNode, NODE_CONDS_KEY } from '@tmagic/schema'; -import { compiledNode } from '@tmagic/utils'; +import type { DataSourceSchema, default as TMagicApp, DisplayCond, Id, MNode, NODE_CONDS_KEY } from '@tmagic/core'; +import { compiledNode } from '@tmagic/core'; import { SimpleObservedData } from './observed-data/SimpleObservedData'; import { DataSource, HttpDataSource } from './data-sources'; diff --git a/packages/data-source/src/createDataSourceManager.ts b/packages/data-source/src/createDataSourceManager.ts index 62cb9229..ec4285a9 100644 --- a/packages/data-source/src/createDataSourceManager.ts +++ b/packages/data-source/src/createDataSourceManager.ts @@ -18,7 +18,7 @@ import { union } from 'lodash-es'; import type { default as TMagicApp } from '@tmagic/core'; -import { getDepNodeIds, getNodes, isPage } from '@tmagic/utils'; +import { getDepNodeIds, getNodes, isPage } from '@tmagic/core'; import DataSourceManager from './DataSourceManager'; import type { ChangeEvent, DataSourceManagerData } from './types'; diff --git a/packages/data-source/src/data-sources/Base.ts b/packages/data-source/src/data-sources/Base.ts index 246a905d..a5515775 100644 --- a/packages/data-source/src/data-sources/Base.ts +++ b/packages/data-source/src/data-sources/Base.ts @@ -19,9 +19,8 @@ import EventEmitter from 'events'; import { cloneDeep } from 'lodash-es'; -import type { default as TMagicApp } from '@tmagic/core'; -import type { CodeBlockContent, DataSchema, DataSourceSchema } from '@tmagic/schema'; -import { getDefaultValueFromFields } from '@tmagic/utils'; +import type { CodeBlockContent, DataSchema, DataSourceSchema, default as TMagicApp } from '@tmagic/core'; +import { getDefaultValueFromFields } from '@tmagic/core'; import { ObservedData } from '@data-source/observed-data/ObservedData'; import { SimpleObservedData } from '@data-source/observed-data/SimpleObservedData'; diff --git a/packages/data-source/src/data-sources/Http.ts b/packages/data-source/src/data-sources/Http.ts index c6b2a48b..3b8c02a3 100644 --- a/packages/data-source/src/data-sources/Http.ts +++ b/packages/data-source/src/data-sources/Http.ts @@ -15,8 +15,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { HttpOptions, RequestFunction } from '@tmagic/schema'; -import { getValueByKeyPath } from '@tmagic/utils'; +import type { HttpOptions, RequestFunction } from '@tmagic/core'; +import { getValueByKeyPath } from '@tmagic/core'; import { DataSourceOptions, HttpDataSourceSchema } from '@data-source/types'; diff --git a/packages/data-source/src/depsCache.ts b/packages/data-source/src/depsCache.ts index 45c69618..dda86ac6 100644 --- a/packages/data-source/src/depsCache.ts +++ b/packages/data-source/src/depsCache.ts @@ -1,6 +1,5 @@ -import { isDataSourceCondTarget, isDataSourceTarget, Target, Watcher } from '@tmagic/dep'; -import type { DataSourceSchema, MNode } from '@tmagic/schema'; -import { DSL_NODE_KEY_COPY_PREFIX } from '@tmagic/utils'; +import type { DataSourceSchema, MNode } from '@tmagic/core'; +import { DSL_NODE_KEY_COPY_PREFIX, isDataSourceCondTarget, isDataSourceTarget, Target, Watcher } from '@tmagic/core'; const cache = new Map(); diff --git a/packages/data-source/src/index.ts b/packages/data-source/src/index.ts index 84fd066e..a8d0a512 100644 --- a/packages/data-source/src/index.ts +++ b/packages/data-source/src/index.ts @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - export { default as DataSourceManager } from './DataSourceManager'; export * from './data-sources'; export * from './createDataSourceManager'; diff --git a/packages/data-source/src/observed-data/SimpleObservedData.ts b/packages/data-source/src/observed-data/SimpleObservedData.ts index ba8cb82c..0bd002fc 100644 --- a/packages/data-source/src/observed-data/SimpleObservedData.ts +++ b/packages/data-source/src/observed-data/SimpleObservedData.ts @@ -1,6 +1,6 @@ import { EventEmitter } from 'events'; -import { getValueByKeyPath, setValueByKeyPath } from '@tmagic/utils'; +import { getValueByKeyPath, setValueByKeyPath } from '@tmagic/core'; import { ObservedData } from './ObservedData'; diff --git a/packages/data-source/src/types.ts b/packages/data-source/src/types.ts index 47ada219..cdf84410 100644 --- a/packages/data-source/src/types.ts +++ b/packages/data-source/src/types.ts @@ -1,5 +1,4 @@ -import type { default as TMagicApp } from '@tmagic/core'; -import type { DataSourceSchema, HttpOptions, RequestFunction } from '@tmagic/schema'; +import type { DataSourceSchema, default as TMagicApp, HttpOptions, RequestFunction } from '@tmagic/core'; import type DataSource from './data-sources/Base'; import type HttpDataSource from './data-sources/Http'; diff --git a/packages/data-source/src/utils.ts b/packages/data-source/src/utils.ts index 75706cdb..61f1c95e 100644 --- a/packages/data-source/src/utils.ts +++ b/packages/data-source/src/utils.ts @@ -1,7 +1,6 @@ import { cloneDeep } from 'lodash-es'; -import type { DepData, DisplayCond, DisplayCondItem, MApp, MNode, MPage, MPageFragment } from '@tmagic/schema'; -import { NODE_CONDS_KEY } from '@tmagic/schema'; +import type { DepData, DisplayCond, DisplayCondItem, MApp, MNode, MPage, MPageFragment } from '@tmagic/core'; import { compiledCond, compiledNode, @@ -10,8 +9,9 @@ import { getValueByKeyPath, isPage, isPageFragment, + NODE_CONDS_KEY, replaceChildNode, -} from '@tmagic/utils'; +} from '@tmagic/core'; import type { AsyncDataSourceResolveResult, DataSourceManagerData } from './types'; diff --git a/packages/data-source/tests/DataSourceMenager.spec.ts b/packages/data-source/tests/DataSourceMenager.spec.ts index db57f63a..0088f25b 100644 --- a/packages/data-source/tests/DataSourceMenager.spec.ts +++ b/packages/data-source/tests/DataSourceMenager.spec.ts @@ -1,11 +1,10 @@ import { describe, expect, test } from 'vitest'; -import App from '@tmagic/core'; -import { NodeType } from '@tmagic/schema'; +import TMagicApp, { NodeType } from '@tmagic/core'; import { DataSource, DataSourceManager } from '@data-source/index'; -const app = new App({ +const app = new TMagicApp({ config: { type: NodeType.ROOT, id: '1', diff --git a/packages/data-source/tests/createDataSourceManager.spec.ts b/packages/data-source/tests/createDataSourceManager.spec.ts index a3b96c73..fa953017 100644 --- a/packages/data-source/tests/createDataSourceManager.spec.ts +++ b/packages/data-source/tests/createDataSourceManager.spec.ts @@ -1,17 +1,9 @@ import { describe, expect, test } from 'vitest'; -import { MApp, NodeType } from '@tmagic/schema'; +import TMagicApp, { type MApp, NodeType } from '@tmagic/core'; import { createDataSourceManager, DataSourceManager } from '@data-source/index'; -class Core { - public dsl?: MApp; - - constructor(options: any) { - this.dsl = options.config; - } -} - const dsl: MApp = { type: NodeType.ROOT, id: 'app_1', @@ -46,13 +38,14 @@ const dsl: MApp = { }, ], methods: [], + events: [], }, ], }; describe('createDataSourceManager', () => { test('instance', () => { - const manager = createDataSourceManager(new Core({ config: dsl })); + const manager = createDataSourceManager(new TMagicApp({ config: dsl })); expect(manager).toBeInstanceOf(DataSourceManager); }); }); diff --git a/packages/design/src/Autocomplete.vue b/packages/design/src/Autocomplete.vue index e45109c6..0f6f6a6b 100644 --- a/packages/design/src/Autocomplete.vue +++ b/packages/design/src/Autocomplete.vue @@ -29,7 +29,7 @@ diff --git a/packages/design/src/Form.vue b/packages/design/src/Form.vue index acbc11aa..df823ee6 100644 --- a/packages/design/src/Form.vue +++ b/packages/design/src/Form.vue @@ -13,7 +13,7 @@ diff --git a/packages/design/src/Input.vue b/packages/design/src/Input.vue index 3144cff3..1bbf0e4a 100644 --- a/packages/design/src/Input.vue +++ b/packages/design/src/Input.vue @@ -26,7 +26,7 @@ - - diff --git a/packages/design/src/Radio.vue b/packages/design/src/Radio.vue index 527d7ec8..042e0f75 100644 --- a/packages/design/src/Radio.vue +++ b/packages/design/src/Radio.vue @@ -7,7 +7,7 @@ diff --git a/packages/design/src/Scrollbar.vue b/packages/design/src/Scrollbar.vue index 2f6da23f..1a37afd6 100644 --- a/packages/design/src/Scrollbar.vue +++ b/packages/design/src/Scrollbar.vue @@ -5,13 +5,13 @@ diff --git a/packages/design/src/Select.vue b/packages/design/src/Select.vue index f3094a93..27372c3d 100644 --- a/packages/design/src/Select.vue +++ b/packages/design/src/Select.vue @@ -16,7 +16,7 @@ - - diff --git a/packages/table/src/index.ts b/packages/table/src/index.ts index 36db3fbc..a7d99527 100644 --- a/packages/table/src/index.ts +++ b/packages/table/src/index.ts @@ -20,6 +20,8 @@ import { App } from 'vue'; import Table from './Table.vue'; +import './theme/index.scss'; + export { default as MagicTable } from './Table.vue'; export * from './schema'; export * from './utils'; diff --git a/packages/table/src/theme/index.scss b/packages/table/src/theme/index.scss new file mode 100644 index 00000000..f6b3fabf --- /dev/null +++ b/packages/table/src/theme/index.scss @@ -0,0 +1,15 @@ +.m-table { + .el-button.action-btn + .el-button.action-btn { + margin-left: 0; + } + .keep-all { + word-break: keep-all; + } + .el-table .cell > div { + display: inline-block; + vertical-align: middle; + } + .el-table__row.el-table__row--level-1 { + color: #999; + } +} diff --git a/packages/table/src/utils.ts b/packages/table/src/utils.ts index ecc89bd1..7990f9a0 100644 --- a/packages/table/src/utils.ts +++ b/packages/table/src/utils.ts @@ -16,7 +16,7 @@ * limitations under the License. */ -import { datetimeFormatter } from '@tmagic/utils'; +import { datetimeFormatter } from '@tmagic/form'; import { ColumnConfig } from './schema'; diff --git a/packages/utils/package.json b/packages/utils/package.json index 9ea99d19..e751dba9 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -10,10 +10,6 @@ "types": "./types/index.d.ts", "import": "./dist/tmagic-utils.js", "require": "./dist/tmagic-utils.umd.cjs" - }, - "./resetcss.css": { - "import": "./src/resetcss.css", - "require": "./src/resetcss.css" } }, "files": [ @@ -33,7 +29,6 @@ "url": "https://github.com/Tencent/tmagic-editor.git" }, "dependencies": { - "dayjs": "^1.11.11", "lodash-es": "^4.17.21" }, "devDependencies": { diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 89134869..09f942e1 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -16,8 +16,6 @@ * limitations under the License. */ -import dayjs from 'dayjs'; -import utc from 'dayjs/plugin/utc'; import { cloneDeep, set as objectSet } from 'lodash-es'; import type { DataSchema, DataSourceDeps, Id, MComponent, MNode, MNodeInstance } from '@tmagic/schema'; @@ -33,31 +31,6 @@ export const sleep = (ms: number): Promise => }, ms); }); -export const datetimeFormatter = ( - v: string | Date, - defaultValue = '-', - format = 'YYYY-MM-DD HH:mm:ss', -): string | number => { - if (v) { - let time: string | number; - if (['x', 'timestamp'].includes(format)) { - time = dayjs(v).valueOf(); - } else if ((typeof v === 'string' && v.includes('Z')) || v.constructor === Date) { - dayjs.extend(utc); - // UTC字符串时间或Date对象格式化为北京时间 - time = dayjs(v).utcOffset(8).format(format); - } else { - time = dayjs(v).format(format); - } - - if (time !== 'Invalid Date') { - return time; - } - return defaultValue; - } - return defaultValue; -}; - // 驼峰转换横线 export const toLine = (name = '') => name.replace(/\B([A-Z])/g, '-$1').toLowerCase(); diff --git a/packages/utils/tests/unit/index.spec.ts b/packages/utils/tests/unit/index.spec.ts index 3c95c2db..b7781a6c 100644 --- a/packages/utils/tests/unit/index.spec.ts +++ b/packages/utils/tests/unit/index.spec.ts @@ -22,37 +22,6 @@ import type { DataSchema } from '@tmagic/schema'; import * as util from '../../src'; -describe('datetimeFormatter', () => { - // Date会将时间转为UTC - const date = new Date('2021-07-17T15:37:00'); - const dateValue = '2021-07-17 15:37:00'; - const defaultValue = '默认值'; - - test('v为空且未设置默认时间', () => { - expect(util.datetimeFormatter('')).toBe('-'); - }); - - test('v是字符串且未设置了默认时间', () => { - expect(util.datetimeFormatter('abc', defaultValue)).toMatch(defaultValue); - }); - - test('v是日期字符串', () => { - expect(util.datetimeFormatter(date.toISOString(), defaultValue)).toMatch(dateValue); - }); - - test('v是Date对象', () => { - expect(util.datetimeFormatter(date)).toMatch(dateValue); - }); - - test('v是UTC字符串', () => { - expect(util.datetimeFormatter(date.toUTCString())).toMatch(dateValue); - }); - - test('format是x', () => { - expect(util.datetimeFormatter(date.toISOString(), defaultValue, 'timestamp')).toBe(date.getTime()); - }); -}); - describe('asyncLoadJs', () => { const url = 'https://m.film.qq.com/magic-ui/production/1/1625056093304/magic/magic-ui.umd.min.js'; diff --git a/playground/package.json b/playground/package.json index 978217a8..2e9d4e68 100644 --- a/playground/package.json +++ b/playground/package.json @@ -14,14 +14,9 @@ "dependencies": { "@element-plus/icons-vue": "^2.3.1", "@tmagic/core": "1.5.0-beta.4", - "@tmagic/design": "1.5.0-beta.4", "@tmagic/editor": "1.5.0-beta.4", "@tmagic/element-plus-adapter": "1.5.0-beta.4", - "@tmagic/form": "1.5.0-beta.4", "@tmagic/tmagic-form-runtime": "1.1.1", - "@tmagic/schema": "1.5.0-beta.4", - "@tmagic/stage": "1.5.0-beta.4", - "@tmagic/utils": "1.5.0-beta.4", "element-plus": "^2.8.0", "lodash-es": "^4.17.21", "monaco-editor": "^0.48.0", diff --git a/playground/src/components/DeviceGroup.vue b/playground/src/components/DeviceGroup.vue index ebd1b317..b8d1320a 100644 --- a/playground/src/components/DeviceGroup.vue +++ b/playground/src/components/DeviceGroup.vue @@ -9,10 +9,9 @@ diff --git a/runtime/vue3/playground/main.ts b/runtime/vue3/playground/main.ts index 2b44ea90..909e80a5 100644 --- a/runtime/vue3/playground/main.ts +++ b/runtime/vue3/playground/main.ts @@ -18,12 +18,11 @@ import { createApp } from 'vue'; -import Core from '@tmagic/core'; -import { DataSourceManager, DeepObservedData } from '@tmagic/data-source'; +import TMagicApp, { DataSourceManager, DeepObservedData } from '@tmagic/core'; import App from './App.vue'; -import '@tmagic/utils/resetcss.css'; +import '@tmagic/core/resetcss.css'; DataSourceManager.registerObservedData(DeepObservedData); @@ -34,7 +33,7 @@ Promise.all([ ]).then(([components, plugins, dataSources]) => { const vueApp = createApp(App); - const app = new Core({ + const app = new TMagicApp({ ua: window.navigator.userAgent, platform: 'editor', });