amis-editor 4.0.1-beta.16 → 4.0.1-beta.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,163 @@
1
+ /**
2
+ * @file 组件选项组件的可视化编辑控件
3
+ */
4
+ import React from 'react';
5
+ import Sortable from 'sortablejs';
6
+ import type { Option } from 'amis';
7
+ import type { FormControlProps } from 'amis/lib/renderers/Form/Item';
8
+ import type { OptionValue } from 'amis/lib/components/Select';
9
+ export declare type valueType = 'text' | 'boolean' | 'number';
10
+ export interface PopoverForm {
11
+ optionLabel: string;
12
+ optionValue: any;
13
+ optionValueType: valueType;
14
+ }
15
+ export declare type OptionControlItem = Option & {
16
+ checked: boolean;
17
+ };
18
+ export interface OptionControlProps extends FormControlProps {
19
+ className?: string;
20
+ }
21
+ export interface OptionControlState {
22
+ options: Array<OptionControlItem>;
23
+ popOverData: any;
24
+ popOverCtx?: {
25
+ mode: 'add' | 'edit';
26
+ index?: number;
27
+ };
28
+ source: 'custom' | 'api' | 'form';
29
+ sourceOptions: Array<Option>;
30
+ }
31
+ export declare class OptionControl extends React.Component<OptionControlProps, OptionControlState> {
32
+ sortable?: Sortable;
33
+ drag?: HTMLElement | null;
34
+ target: HTMLElement | null;
35
+ internalProps: string[];
36
+ constructor(props: OptionControlProps);
37
+ componentDidUpdate(prevProps: OptionControlProps): void;
38
+ /**
39
+ * 获取当前选项值的类型
40
+ */
41
+ getOptionValueType(value: any): valueType;
42
+ /**
43
+ * 将当前选项值转换为选择的类型
44
+ */
45
+ normalizeOptionValue(value: any, valueType: valueType): string | number | boolean;
46
+ /**
47
+ * 处理填入输入框的值
48
+ */
49
+ transformOptionValue(value: any): string;
50
+ transformOptions(props: OptionControlProps): {
51
+ checked: boolean;
52
+ label?: string | undefined;
53
+ scopeLabel?: string | undefined;
54
+ value?: any;
55
+ disabled?: boolean | undefined;
56
+ children?: import("amis").Options | undefined;
57
+ visible?: boolean | undefined;
58
+ hidden?: boolean | undefined;
59
+ description?: string | undefined;
60
+ defer?: boolean | undefined;
61
+ deferApi?: import("amis").SchemaApi | undefined;
62
+ loading?: boolean | undefined;
63
+ loaded?: boolean | undefined;
64
+ }[];
65
+ /**
66
+ * 处理当前组件的默认值
67
+ */
68
+ normalizeValue(): OptionValue | OptionValue[];
69
+ /**
70
+ * 更新options字段的统一出口
71
+ */
72
+ onChangeOptions(): void;
73
+ targetRef(ref: any): void;
74
+ dragRef(ref: any): void;
75
+ initDragging(): void;
76
+ destroyDragging(): void;
77
+ scroll2Bottom(): void;
78
+ /**
79
+ * 切换选项类型
80
+ */
81
+ handleSourceChange(option: {
82
+ label: string;
83
+ value: 'custom' | 'api' | 'form';
84
+ }): void;
85
+ /**
86
+ * 删除选项
87
+ */
88
+ handleDelete(index: number, e: React.UIEvent<any>): void;
89
+ /**
90
+ * 设置默认选项
91
+ */
92
+ handleToggleDefaultValue(index: number, checked: any, shift?: boolean): void;
93
+ /**
94
+ * 编辑选项
95
+ */
96
+ handleEdit(index: number, e: React.UIEvent<any>): void;
97
+ handleEditLabel(index: number, e: React.FocusEvent<HTMLInputElement>): void;
98
+ handleAdd(): void;
99
+ handlePopoverSubmit(values: PopoverForm, action: any): void;
100
+ closePopoverEdit(): boolean;
101
+ handleBatchAdd(values: {
102
+ batchOption: string;
103
+ }, action: any): void;
104
+ renderHeader(): JSX.Element;
105
+ renderOption(props: any): JSX.Element;
106
+ renderPopover(): JSX.Element;
107
+ buildBatchAddSchema(): {
108
+ type: string;
109
+ actionType: string;
110
+ level: string;
111
+ size: string;
112
+ label: string;
113
+ dialog: {
114
+ title: string;
115
+ headerClassName: string;
116
+ closeOnEsc: boolean;
117
+ closeOnOutside: boolean;
118
+ showCloseButton: boolean;
119
+ body: ({
120
+ type: string;
121
+ level: string;
122
+ body: string;
123
+ showIcon: boolean;
124
+ className: string;
125
+ wrapWithPanel?: undefined;
126
+ mode?: undefined;
127
+ wrapperComponent?: undefined;
128
+ resetAfterSubmit?: undefined;
129
+ autoFocus?: undefined;
130
+ preventEnterSubmit?: undefined;
131
+ horizontal?: undefined;
132
+ } | {
133
+ type: string;
134
+ wrapWithPanel: boolean;
135
+ mode: string;
136
+ wrapperComponent: string;
137
+ resetAfterSubmit: boolean;
138
+ autoFocus: boolean;
139
+ preventEnterSubmit: boolean;
140
+ horizontal: {
141
+ left: number;
142
+ right: number;
143
+ };
144
+ body: {
145
+ name: string;
146
+ type: string;
147
+ label: string;
148
+ placeholder: string;
149
+ trimContents: boolean;
150
+ minRows: number;
151
+ maxRows: number;
152
+ required: boolean;
153
+ }[];
154
+ level?: undefined;
155
+ showIcon?: undefined;
156
+ className?: undefined;
157
+ })[];
158
+ };
159
+ };
160
+ render(): JSX.Element;
161
+ }
162
+ export declare class OptionControlRenderer extends OptionControl {
163
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @file 浮窗编辑
3
+ */
4
+ import React from 'react';
5
+ import type { Action } from 'amis/lib/types';
6
+ import type { IScopedContext } from 'amis/lib/Scoped';
7
+ import type { FormSchema } from 'amis/lib/renderers/Form';
8
+ import type { FormControlProps } from 'amis/lib/renderers/Form/Item';
9
+ import type { Offset } from 'amis/lib/components/PopOver';
10
+ export interface PopoverEditProps extends FormControlProps {
11
+ className?: string;
12
+ popOverclassName?: string;
13
+ btnLabel?: string;
14
+ btnIcon?: string;
15
+ iconPosition?: 'right' | 'left';
16
+ mode: 'popover' | 'dialog';
17
+ form: Omit<FormSchema, 'type'>;
18
+ rootClose?: boolean;
19
+ placement?: string;
20
+ offset?: ((clip: object, offset: object) => Offset) | Offset;
21
+ style?: object;
22
+ overlay?: boolean;
23
+ container?: React.ReactNode | Function;
24
+ target?: React.ReactNode | Function;
25
+ trueValue?: any;
26
+ falseValue?: any;
27
+ enableEdit?: boolean;
28
+ removable?: boolean;
29
+ onClose: (e: React.UIEvent<any> | void) => void;
30
+ }
31
+ interface PopoverEditState {
32
+ /**
33
+ * 是否展示编辑窗口
34
+ */
35
+ show: boolean;
36
+ /**
37
+ * 是否开启编辑
38
+ */
39
+ checked: boolean;
40
+ }
41
+ export declare class PopoverEdit extends React.Component<PopoverEditProps, PopoverEditState> {
42
+ static defaultProps: Pick<PopoverEditProps, 'btnIcon' | 'iconPosition' | 'container' | 'placement' | 'overlay' | 'rootClose' | 'mode' | 'trueValue' | 'falseValue' | 'enableEdit'>;
43
+ overlay: HTMLElement | null;
44
+ constructor(props: PopoverEditProps);
45
+ overlayRef(ref: any): void;
46
+ openPopover(): void;
47
+ closePopover(): void;
48
+ handleDelete(e: React.UIEvent<any> | void): void;
49
+ handleSwitchChange(checked: boolean): void;
50
+ handleSubmit(values: any, action: any): void;
51
+ handleAction(e: React.UIEvent<any> | void, action: Action, data: object, throwErrors?: boolean, delegate?: IScopedContext): void;
52
+ renderPopover(): JSX.Element;
53
+ render(): JSX.Element;
54
+ }
55
+ export declare class PopoverEditRenderer extends PopoverEdit {
56
+ }
57
+ export {};
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @file 表单项校验配置
3
+ */
4
+ /// <reference types="lodash" />
5
+ import React from 'react';
6
+ import type { FormControlProps } from 'amis/lib/renderers/Form/Item';
7
+ export interface ValidationControlProps extends FormControlProps {
8
+ }
9
+ interface Rule {
10
+ label: string;
11
+ key: string;
12
+ value: boolean | string | number;
13
+ checked: boolean;
14
+ message?: string;
15
+ }
16
+ interface ValidationControlState {
17
+ rules: Array<Rule>;
18
+ }
19
+ export declare class ValidationControl extends React.Component<ValidationControlProps, ValidationControlState> {
20
+ validationRules: Record<string, string>;
21
+ constructor(props: ValidationControlProps);
22
+ transformRules(): Rule[];
23
+ normalizeRules(): import("lodash").Dictionary<boolean | Record<string, any>>;
24
+ handleAddRule(): void;
25
+ handleSubmit(values: any, action: any): void;
26
+ render(): JSX.Element;
27
+ }
28
+ export declare class ValidationControlRenderer extends ValidationControl {
29
+ }
30
+ export {};
@@ -7,7 +7,6 @@ interface LeftPanelsProps {
7
7
  theme?: string;
8
8
  }
9
9
  interface LeftPanelsStates {
10
- isOpenStatus: boolean;
11
10
  isFixedStatus: boolean;
12
11
  }
13
12
  export declare class LeftPanels extends React.Component<LeftPanelsProps, LeftPanelsStates> {
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import { EditorStoreType } from '../../store/editor';
3
+ import { SubRendererInfo } from '../../plugin';
4
+ interface SearchRendererProps {
5
+ store: EditorStoreType;
6
+ }
7
+ interface SearchRendererStates {
8
+ subRenderersByOrder: Array<SubRendererInfo>;
9
+ groupedSubRenderers: {
10
+ [propName: string]: Array<SubRendererInfo>;
11
+ };
12
+ searchSubRenderers: {
13
+ [propName: string]: Array<SubRendererInfo>;
14
+ };
15
+ visible: boolean;
16
+ curKeyword: string;
17
+ curKeywordSearchHistory: string[];
18
+ toggleTagFolderStatus: boolean;
19
+ }
20
+ export default class SearchRendererPanel extends React.Component<SearchRendererProps, SearchRendererStates> {
21
+ ref: React.RefObject<HTMLDivElement>;
22
+ curInputBox: any;
23
+ localStorageKey: string;
24
+ curTagFolded: {
25
+ [propName: string]: boolean;
26
+ };
27
+ lastSubRenderersTag: string;
28
+ constructor(props: any);
29
+ componentDidMount(): void;
30
+ componentWillReceiveProps(nextProps: any): void;
31
+ componentWillUnmount(): void;
32
+ bindFocusEvent(): void;
33
+ bindBlurEvent(): void;
34
+ searchSubRenderersByKeyword(keywords: string): void;
35
+ changeTagFoldStatus(tagKey: string, event: any): void;
36
+ bindEnterEvent(event: any): void;
37
+ bindClearActionEvent(): void;
38
+ bindTagClickEvent(tag: string): void;
39
+ getSearchHistory(): any[];
40
+ addSearchHistory(newKeywords: string): void;
41
+ clickKeywordEvent(keywords: string): void;
42
+ deleteSearchHistory(event: any, newKeywords: string): void;
43
+ clearSearchHistory(event: any): void;
44
+ updateSearchHistory(): void;
45
+ renderNameByKeyword(rendererName: string, curKeyword: string): string | JSX.Element;
46
+ resultIsHasScroll(searchSubRenderers: {
47
+ [propName: string]: Array<SubRendererInfo>;
48
+ }, maxShowLine: number): boolean;
49
+ render(): JSX.Element;
50
+ }
51
+ export {};
@@ -0,0 +1,150 @@
1
+ /**
2
+ * @description 信息提示组件模版
3
+ * @file src/component/remarkTpl.tsx
4
+ * @author hanxiao11@baidu.com
5
+ */
6
+ export default function remarkTpl(config: {
7
+ name: 'remark' | 'labelRemark';
8
+ label: string;
9
+ }): {
10
+ type: string;
11
+ label: string;
12
+ mode: string;
13
+ className: string;
14
+ labelRemark: {
15
+ icon: string;
16
+ trigger: string[];
17
+ setting: boolean;
18
+ title: string;
19
+ content: string;
20
+ placement: string;
21
+ };
22
+ body: {
23
+ type: string;
24
+ className: string;
25
+ body: ({
26
+ type: string;
27
+ name: "remark" | "labelRemark";
28
+ label: string;
29
+ btnLabel: string;
30
+ visibleOn: string;
31
+ className: string;
32
+ itemClassName: string;
33
+ icon: string;
34
+ form: {
35
+ title: string;
36
+ mode: string;
37
+ size: string;
38
+ body: {
39
+ type: string;
40
+ columns: ({
41
+ md: string;
42
+ body: ({
43
+ name: string;
44
+ type: string;
45
+ label: string;
46
+ placeholder: string;
47
+ } | {
48
+ name: string;
49
+ type: string;
50
+ label: string;
51
+ placeholder?: undefined;
52
+ })[];
53
+ } | {
54
+ md: string;
55
+ body: ({
56
+ name: string;
57
+ type: string;
58
+ size: string;
59
+ label: string;
60
+ options: {
61
+ label: string;
62
+ value: string;
63
+ }[];
64
+ labelRemark?: undefined;
65
+ multiple?: undefined;
66
+ pipeIn?: undefined;
67
+ pipeOut?: undefined;
68
+ visibleOn?: undefined;
69
+ } | {
70
+ name: string;
71
+ label: string;
72
+ type: string;
73
+ size?: undefined;
74
+ options?: undefined;
75
+ labelRemark?: undefined;
76
+ multiple?: undefined;
77
+ pipeIn?: undefined;
78
+ pipeOut?: undefined;
79
+ visibleOn?: undefined;
80
+ } | {
81
+ name: string;
82
+ label: string;
83
+ type: string;
84
+ labelRemark: {
85
+ trigger: string;
86
+ className: string;
87
+ rootClose: boolean;
88
+ content: string;
89
+ placement: string;
90
+ };
91
+ size?: undefined;
92
+ options?: undefined;
93
+ multiple?: undefined;
94
+ pipeIn?: undefined;
95
+ pipeOut?: undefined;
96
+ visibleOn?: undefined;
97
+ } | {
98
+ name: string;
99
+ type: string;
100
+ label: string;
101
+ multiple: boolean;
102
+ pipeIn: (value: any) => string | never[];
103
+ pipeOut: (value: any) => any;
104
+ options: {
105
+ label: string;
106
+ value: string;
107
+ }[];
108
+ size?: undefined;
109
+ labelRemark?: undefined;
110
+ visibleOn?: undefined;
111
+ } | {
112
+ name: string;
113
+ visibleOn: string;
114
+ label: string;
115
+ type: string;
116
+ size?: undefined;
117
+ options?: undefined;
118
+ labelRemark?: undefined;
119
+ multiple?: undefined;
120
+ pipeIn?: undefined;
121
+ pipeOut?: undefined;
122
+ })[];
123
+ })[];
124
+ };
125
+ };
126
+ mode?: undefined;
127
+ pipeIn?: undefined;
128
+ pipeOut?: undefined;
129
+ } | {
130
+ type: string;
131
+ name: "remark" | "labelRemark";
132
+ mode: string;
133
+ pipeIn: (value: any) => boolean;
134
+ pipeOut: (value: any) => {
135
+ icon: string;
136
+ trigger: string[];
137
+ className: string;
138
+ setting: boolean;
139
+ placement: string;
140
+ } | null;
141
+ label?: undefined;
142
+ btnLabel?: undefined;
143
+ visibleOn?: undefined;
144
+ className?: undefined;
145
+ itemClassName?: undefined;
146
+ icon?: undefined;
147
+ form?: undefined;
148
+ })[];
149
+ }[];
150
+ };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,10 @@
3
3
  */
4
4
  import Editor from './component/Editor';
5
5
  import './component/ClassNameControl';
6
+ import './component/Control/OptionControl';
7
+ import './component/Control/APIControl';
8
+ import './component/Control/ValidationControl';
9
+ import './component/Control/PopoverEdit';
6
10
  import './plugin/Panel/AvailableRenderers';
7
11
  import './plugin/Panel/Code';
8
12
  import './plugin/Panel/Name';