Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复一些 ts 报错 #6674

Merged
merged 3 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 🚀
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 14 additions & 4 deletions packages/amis-core/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -179,7 +182,14 @@ export {
RendererConfig,
styleMap,
RENDERER_TRANSMISSION_OMIT_PROPS,
ScopedComponentType
ScopedComponentType,
IItem,
IColumn,
IRow,
IColumn2,
IRow2,
OnEventProps,
FormSchemaBase
};

export function render(
Expand Down
2 changes: 1 addition & 1 deletion packages/amis-editor-core/src/component/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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?: (
Expand Down
4 changes: 2 additions & 2 deletions packages/amis-editor-core/src/component/factory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 并构建成树
Expand Down
2 changes: 1 addition & 1 deletion packages/amis-editor-core/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
4 changes: 2 additions & 2 deletions packages/amis-editor-core/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/amis-editor-core/src/store/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
6 changes: 3 additions & 3 deletions packages/amis-ui/src/components/TabsTransfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface TabsTransferProps
onTabChange: (key: number) => void;
activeKey: number;
onlyChildren?: boolean;
data?: any;
ctx?: Record<string, any>;
}

export interface TabsTransferState {
Expand Down Expand Up @@ -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);

Expand All @@ -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"
>
Expand Down
6 changes: 2 additions & 4 deletions packages/amis-ui/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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};
2 changes: 1 addition & 1 deletion packages/amis/src/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
5 changes: 2 additions & 3 deletions packages/amis/src/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';

Expand Down
3 changes: 3 additions & 0 deletions packages/amis/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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};
1 change: 0 additions & 1 deletion packages/amis/src/renderers/Action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/amis/src/renderers/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 & {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/amis/src/renderers/Cards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 卡片集合渲染器。
Expand Down
4 changes: 3 additions & 1 deletion packages/amis/src/renderers/Form/TabsTransfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ export class TabsTransferRenderer extends BaseTabsTransferRenderer<TabsTransferP
itemHeight,
virtualThreshold,
onlyChildren,
loadingConfig
loadingConfig,
data
} = this.props;

return (
Expand Down Expand Up @@ -327,6 +328,7 @@ export class TabsTransferRenderer extends BaseTabsTransferRenderer<TabsTransferP
toNumber(itemHeight) > 0 ? toNumber(itemHeight) : undefined
}
virtualThreshold={virtualThreshold}
ctx={data}
/>

<Spinner
Expand Down
4 changes: 2 additions & 2 deletions packages/amis/src/renderers/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import {
} from '../Schema';
import {ActionSchema} from './Action';
import {SchemaRemark} from './Remark';
import type {IItem} from 'amis-core/lib/store/list';
import type {OnEventProps} from 'amis-core/lib/utils/renderer-event';
import type {IItem} from 'amis-core';
import type {OnEventProps} from 'amis-core';

/**
* 不指定类型默认就是文本
Expand Down
2 changes: 0 additions & 2 deletions packages/amis/src/renderers/Remark.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';
import {Renderer, RendererProps} from 'amis-core';
import {Api, SchemaNode, Schema, ActionObject} from 'amis-core';
import cx from 'classnames';
import {TooltipWrapper} from 'amis-ui';
import {filter, generateIcon} from 'amis-core';
import {ClassNamesFn, themeable} from 'amis-core';
Expand Down
4 changes: 2 additions & 2 deletions packages/amis/src/renderers/Table/ColumnToggler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {getIcon} from 'amis-ui';
import {generateIcon} from 'amis-core';
import {RootClose} from 'amis-core';
import type {TooltipObject} from 'amis-ui/lib/components/TooltipWrapper';
import {IColumn} from 'amis-core/lib/store/table';
import type {IColumn2} from 'amis-core/lib/store/table2';
import {IColumn} from 'amis-core';
import type {IColumn2} from 'amis-core';

export interface ColumnTogglerProps extends RendererProps {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/amis/src/renderers/Table/TableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {trace, reaction} from 'mobx';
import {createObject, flattenTree} from 'amis-core';
import {LocaleProps} from 'amis-core';
import {ActionSchema} from '../Action';
import type {IColumn, IRow} from 'amis-core/lib/store/table';
import type {IColumn, IRow} from 'amis-core';

export interface TableBodyProps extends LocaleProps {
className?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/amis/src/renderers/Table/TableContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ItemActionsWrapper from './ItemActionsWrapper';
import {SchemaTpl} from '../../Schema';
import {Icon} from 'amis-ui';

import type {IColumn, IRow} from 'amis-core/lib/store/table';
import type {IColumn, IRow} from 'amis-core';

export interface TableContentProps extends LocaleProps {
className?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/amis/src/renderers/Table/TableRow.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {observer} from 'mobx-react';
import React from 'react';
import type {IColumn, IRow} from 'amis-core/lib/store/table';
import type {IColumn, IRow} from 'amis-core';
import {RendererProps} from 'amis-core';
import {Action} from '../Action';
import {isClickOnInput, createObject} from 'amis-core';
Expand Down
2 changes: 1 addition & 1 deletion packages/amis/src/renderers/Table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import ColumnToggler from './ColumnToggler';
import {offset} from 'amis-core';
import {getStyleNumber} from 'amis-core';
import {exportExcel} from './exportExcel';
import type {IColumn, IRow} from 'amis-core/lib/store/table';
import type {IColumn, IRow} from 'amis-core';
import intersection from 'lodash/intersection';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/ooxml-viewer/src/Word.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ export default class Word {
/**
* 打印功能
*/
async print() {
async print(): Promise<any> {
const iframe = document.createElement('iframe') as HTMLIFrameElement;
iframe.style.position = 'absolute';
iframe.style.top = '-10000px';
Expand Down
4 changes: 2 additions & 2 deletions packages/ooxml-viewer/src/util/print.ts
Original file line number Diff line number Diff line change
@@ -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);
}
});

Expand Down