diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 0a8963eab..6cc07e434 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -28,6 +28,9 @@ jobs: - name: build gh-pages run: | npm i --legacy-peer-deps + cd packages/ooxml-viewer + npm i --legacy-peer-deps + cd ../../ npm run build --workspaces sh deploy-gh-pages.sh - name: Deploy 🚀 diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index 1cd0e13ad..064072aec 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -25,6 +25,9 @@ jobs: - name: test run: | npm i --legacy-peer-deps + cd packages/ooxml-viewer + npm i --legacy-peer-deps + cd ../../ npm run build --workspaces npm test --workspaces sh deploy-gh-pages.sh diff --git a/packages/amis-core/src/index.tsx b/packages/amis-core/src/index.tsx index dce25f8d8..991835e93 100644 --- a/packages/amis-core/src/index.tsx +++ b/packages/amis-core/src/index.tsx @@ -31,6 +31,7 @@ import * as utils from './utils/helper'; import {getEnv} from 'mobx-state-tree'; import {RegisterStore, RendererStore} from './store'; +import type {IColumn, IColumn2, IRow, IRow2} from './store'; import { setDefaultLocale, getDefaultLocale, @@ -42,8 +43,8 @@ import { } from './locale'; import type {LocaleProps, TranslateFn} from './locale'; -import Scoped, {ScopedComponentType, ScopedContext} from './Scoped'; -import type {IScopedContext} from './Scoped'; +import Scoped, {ScopedContext} from './Scoped'; +import type {ScopedComponentType, IScopedContext} from './Scoped'; import { classnames, @@ -95,10 +96,12 @@ import LazyComponent from './components/LazyComponent'; import Overlay from './components/Overlay'; import PopOver from './components/PopOver'; import {FormRenderer} from './renderers/Form'; -import type {FormHorizontal} from './renderers/Form'; +import type {FormHorizontal, FormSchemaBase} from './renderers/Form'; import {enableDebug, promisify, replaceText, wrapFetcher} from './utils/index'; +import type {OnEventProps} from './utils/index'; import {valueMap as styleMap} from './utils/style-helper'; import {RENDERER_TRANSMISSION_OMIT_PROPS} from './SchemaRenderer'; +import type {IItem} from './store/list'; // @ts-ignore export const version = '__buildVersion'; @@ -179,7 +182,14 @@ export { RendererConfig, styleMap, RENDERER_TRANSMISSION_OMIT_PROPS, - ScopedComponentType + ScopedComponentType, + IItem, + IColumn, + IRow, + IColumn2, + IRow2, + OnEventProps, + FormSchemaBase }; export function render( diff --git a/packages/amis-editor-core/src/component/Preview.tsx b/packages/amis-editor-core/src/component/Preview.tsx index 147730acc..ced753425 100644 --- a/packages/amis-editor-core/src/component/Preview.tsx +++ b/packages/amis-editor-core/src/component/Preview.tsx @@ -15,7 +15,7 @@ import IFrameBridge from './IFrameBridge'; import {isAlive} from 'mobx-state-tree'; import {findTree} from 'amis-core'; import BackTop from './base/BackTop'; -import {RendererConfig} from 'amis-core/lib/factory'; +import {RendererConfig} from 'amis-core'; export interface PreviewProps { // isEditorEnabled?: ( diff --git a/packages/amis-editor-core/src/component/factory.tsx b/packages/amis-editor-core/src/component/factory.tsx index 9f69bf15f..07d77afb7 100644 --- a/packages/amis-editor-core/src/component/factory.tsx +++ b/packages/amis-editor-core/src/component/factory.tsx @@ -18,8 +18,8 @@ import {createObject} from 'amis-core'; import {CommonConfigWrapper} from './CommonConfigWrapper'; import type {Schema} from 'amis'; import type {DataScope} from 'amis-core'; -import type {RendererConfig} from 'amis-core/lib/factory'; -import type {SchemaCollection} from 'amis/lib/Schema'; +import type {RendererConfig} from 'amis-core'; +import type {SchemaCollection} from 'amis'; import {omit} from 'lodash'; // 创建 Node Store 并构建成树 diff --git a/packages/amis-editor-core/src/manager.ts b/packages/amis-editor-core/src/manager.ts index 737d4dad7..20c7365f1 100644 --- a/packages/amis-editor-core/src/manager.ts +++ b/packages/amis-editor-core/src/manager.ts @@ -67,7 +67,7 @@ import {EditorDNDManager} from './dnd'; import {VariableManager} from './variable'; import {IScopedContext} from 'amis'; import type {SchemaObject, SchemaCollection} from 'amis/lib/Schema'; -import type {RendererConfig} from 'amis-core/lib/factory'; +import type {RendererConfig} from 'amis-core'; import isPlainObject from 'lodash/isPlainObject'; import {omit} from 'lodash'; diff --git a/packages/amis-editor-core/src/plugin.ts b/packages/amis-editor-core/src/plugin.ts index 16404f595..38e8d1526 100644 --- a/packages/amis-editor-core/src/plugin.ts +++ b/packages/amis-editor-core/src/plugin.ts @@ -10,9 +10,9 @@ import {EditorDNDManager} from './dnd'; import React from 'react'; import {DiffChange} from './util'; import find from 'lodash/find'; -import type {RendererConfig} from 'amis-core/lib/factory'; +import type {RendererConfig} from 'amis-core'; import type {MenuDivider, MenuItem} from 'amis-ui/lib/components/ContextMenu'; -import type {BaseSchema, SchemaCollection} from 'amis/lib/Schema'; +import type {BaseSchema, SchemaCollection} from 'amis'; import {DSFieldGroup} from './builder/DSBuilder'; /** diff --git a/packages/amis-editor-core/src/store/node.ts b/packages/amis-editor-core/src/store/node.ts index af6e8d907..4cc43fc14 100644 --- a/packages/amis-editor-core/src/store/node.ts +++ b/packages/amis-editor-core/src/store/node.ts @@ -17,7 +17,7 @@ import {filterSchema} from 'amis'; import React from 'react'; import {EditorStoreType} from './editor'; import findIndex from 'lodash/findIndex'; -import type {RendererConfig} from 'amis-core/lib/factory'; +import type {RendererConfig} from 'amis-core'; export const EditorNode = types .model('EditorNode', { diff --git a/packages/amis-ui/src/components/TabsTransfer.tsx b/packages/amis-ui/src/components/TabsTransfer.tsx index 572ada1d7..554c7c772 100644 --- a/packages/amis-ui/src/components/TabsTransfer.tsx +++ b/packages/amis-ui/src/components/TabsTransfer.tsx @@ -50,7 +50,7 @@ export interface TabsTransferProps onTabChange: (key: number) => void; activeKey: number; onlyChildren?: boolean; - data?: any; + ctx?: Record; } export interface TabsTransferState { @@ -258,7 +258,7 @@ export class TabsTransfer extends React.Component< activeKey, classnames: cx, translate: __, - data + ctx } = this.props; const showOptions = options.filter(item => item.visible !== false); @@ -283,7 +283,7 @@ export class TabsTransfer extends React.Component< key={index} title={filter( option.label || option.title, - createObject(data, option) + createObject(ctx, option) )} className="TabsTransfer-tab" > diff --git a/packages/amis-ui/src/index.tsx b/packages/amis-ui/src/index.tsx index d46fa9528..e460066be 100644 --- a/packages/amis-ui/src/index.tsx +++ b/packages/amis-ui/src/index.tsx @@ -9,9 +9,7 @@ import './themes/ang'; import './themes/antd'; import './themes/dark'; import './themes/default'; -import { - SchemaEditorItemPlaceholder, - schemaEditorItemPlaceholder -} from './components/schema-editor/Common'; +import type {SchemaEditorItemPlaceholder} from './components/schema-editor/Common'; +import {schemaEditorItemPlaceholder} from './components/schema-editor/Common'; export {schemaEditorItemPlaceholder, SchemaEditorItemPlaceholder}; diff --git a/packages/amis/src/Schema.ts b/packages/amis/src/Schema.ts index 2600dc37c..466e8a0a6 100644 --- a/packages/amis/src/Schema.ts +++ b/packages/amis/src/Schema.ts @@ -127,7 +127,7 @@ import { SchemaClassName, SchemaExpression } from 'amis-core'; -import type {FormSchemaBase} from 'amis-core/lib/renderers/Form'; +import type {FormSchemaBase} from 'amis-core'; import {MultilineTextSchema} from './renderers/MultilineText'; import {DateRangeSchema} from './renderers/DateRange'; import {PasswordSchema} from './renderers/Password'; diff --git a/packages/amis/src/compat.ts b/packages/amis/src/compat.ts index a5b860699..997842b87 100644 --- a/packages/amis/src/compat.ts +++ b/packages/amis/src/compat.ts @@ -2,8 +2,8 @@ * @file 兼容配置,对于一些老的 api 设计的得不合理的地方做一些适配。 * @author fex */ -import {SchemaNode, Schema} from 'amis-core/lib/types'; -import {RendererProps, addSchemaFilter} from 'amis-core'; +import {Schema} from 'amis-core'; +import {addSchemaFilter} from 'amis-core'; import {CheckboxControlRenderer} from './renderers/Form/Checkbox'; import {FormRenderer} from 'amis-core'; import {FieldSetRenderer} from './renderers/Form/FieldSet'; @@ -14,7 +14,6 @@ import {getLevelFromClassName} from 'amis-core'; import {FileControlRenderer} from './renderers/Form/InputFile'; import {ImageControlRenderer} from './renderers/Form/InputImage'; import {RichTextControlRenderer} from './renderers/Form/InputRichText'; -import isPlainObject from 'lodash/isPlainObject'; import {GridRenderer} from './renderers/Grid'; import {HBoxRenderer} from './renderers/HBox'; diff --git a/packages/amis/src/index.tsx b/packages/amis/src/index.tsx index 422a6c210..2817afbba 100644 --- a/packages/amis/src/index.tsx +++ b/packages/amis/src/index.tsx @@ -154,5 +154,8 @@ import './renderers/OfficeViewer'; import './compat'; import './schemaExtend'; +import type {BaseSchema, SchemaCollection} from './Schema'; export * from './renderers/Form/IconPickerIcons'; export * from './renderers/Form/IconSelectStore'; + +export {BaseSchema, SchemaCollection}; diff --git a/packages/amis/src/renderers/Action.tsx b/packages/amis/src/renderers/Action.tsx index 5cc13a925..d21ebb759 100644 --- a/packages/amis/src/renderers/Action.tsx +++ b/packages/amis/src/renderers/Action.tsx @@ -448,7 +448,6 @@ import {generateIcon} from 'amis-core'; import {withBadge} from 'amis-ui'; import {normalizeApi, str2AsyncFunction} from 'amis-core'; import {TooltipWrapper} from 'amis-ui'; -import {ICmptAction} from 'amis-core/lib/actions/CmptAction'; // 构造一个假的 React 事件避免可能的报错,主要用于快捷键功能 // 来自 https://stackoverflow.com/questions/27062455/reactjs-can-i-create-my-own-syntheticevent diff --git a/packages/amis/src/renderers/Card.tsx b/packages/amis/src/renderers/Card.tsx index 6d6b76100..c9e7a4491 100644 --- a/packages/amis/src/renderers/Card.tsx +++ b/packages/amis/src/renderers/Card.tsx @@ -23,7 +23,7 @@ import {ActionSchema} from './Action'; import {Card} from 'amis-ui'; import {findDOMNode} from 'react-dom'; import {Icon} from 'amis-ui'; -import type {IItem} from 'amis-core/lib/store/list'; +import type {IItem} from 'amis-core'; export type CardBodyField = SchemaObject & { /** diff --git a/packages/amis/src/renderers/Cards.tsx b/packages/amis/src/renderers/Cards.tsx index 37b563220..fb213ab3c 100644 --- a/packages/amis/src/renderers/Cards.tsx +++ b/packages/amis/src/renderers/Cards.tsx @@ -27,7 +27,7 @@ import { } from '../Schema'; import {CardProps, CardSchema} from './Card'; import {Card2Props, Card2Schema} from './Card2'; -import type {IItem} from 'amis-core/lib/store/list'; +import type {IItem} from 'amis-core'; /** * Cards 卡片集合渲染器。 diff --git a/packages/amis/src/renderers/Form/TabsTransfer.tsx b/packages/amis/src/renderers/Form/TabsTransfer.tsx index c7c006ded..16276203e 100644 --- a/packages/amis/src/renderers/Form/TabsTransfer.tsx +++ b/packages/amis/src/renderers/Form/TabsTransfer.tsx @@ -299,7 +299,8 @@ export class TabsTransferRenderer extends BaseTabsTransferRenderer 0 ? toNumber(itemHeight) : undefined } virtualThreshold={virtualThreshold} + ctx={data} /> { const iframe = document.createElement('iframe') as HTMLIFrameElement; iframe.style.position = 'absolute'; iframe.style.top = '-10000px'; diff --git a/packages/ooxml-viewer/src/util/print.ts b/packages/ooxml-viewer/src/util/print.ts index 9255bf925..5f058851d 100644 --- a/packages/ooxml-viewer/src/util/print.ts +++ b/packages/ooxml-viewer/src/util/print.ts @@ -1,7 +1,7 @@ function loadIframeImages(images: HTMLImageElement[]) { - const promises = images.map(image => { + const promises = images.map(async image => { if (image.src && image.src !== window.location.href) { - return loadIframeImage(image); + await loadIframeImage(image); } });