@next-bricks/form 0.1.0
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.
- package/dist/bricks.json +48 -0
- package/dist/chunks/1646.1d16cabe.js +2 -0
- package/dist/chunks/1646.1d16cabe.js.map +1 -0
- package/dist/chunks/1970.62810c92.js +3 -0
- package/dist/chunks/1970.62810c92.js.LICENSE.txt +46 -0
- package/dist/chunks/1970.62810c92.js.map +1 -0
- package/dist/chunks/2024.709c5b23.js +2 -0
- package/dist/chunks/2024.709c5b23.js.map +1 -0
- package/dist/chunks/2108.60158822.js +2 -0
- package/dist/chunks/2108.60158822.js.map +1 -0
- package/dist/chunks/2241.fd1d3265.js +3 -0
- package/dist/chunks/2241.fd1d3265.js.LICENSE.txt +19 -0
- package/dist/chunks/2241.fd1d3265.js.map +1 -0
- package/dist/chunks/2323.89167d40.js +2 -0
- package/dist/chunks/2323.89167d40.js.map +1 -0
- package/dist/chunks/2754.e812a197.js +2 -0
- package/dist/chunks/2754.e812a197.js.map +1 -0
- package/dist/chunks/2993.e2812bdf.js +2 -0
- package/dist/chunks/2993.e2812bdf.js.map +1 -0
- package/dist/chunks/31.2b21ef1e.js +2 -0
- package/dist/chunks/31.2b21ef1e.js.map +1 -0
- package/dist/chunks/3494.fd1b6a17.js +2 -0
- package/dist/chunks/3494.fd1b6a17.js.map +1 -0
- package/dist/chunks/3525.08bc8edc.js +2 -0
- package/dist/chunks/3525.08bc8edc.js.map +1 -0
- package/dist/chunks/353.94523d86.js +2 -0
- package/dist/chunks/353.94523d86.js.map +1 -0
- package/dist/chunks/3914.2e2d5e08.js +2 -0
- package/dist/chunks/3914.2e2d5e08.js.map +1 -0
- package/dist/chunks/4049.a1078a82.js +2 -0
- package/dist/chunks/4049.a1078a82.js.map +1 -0
- package/dist/chunks/4454.238ebb5b.js +2 -0
- package/dist/chunks/4454.238ebb5b.js.map +1 -0
- package/dist/chunks/4512.02f5e4dd.js +2 -0
- package/dist/chunks/4512.02f5e4dd.js.map +1 -0
- package/dist/chunks/4717.e16b316a.js +2 -0
- package/dist/chunks/4717.e16b316a.js.map +1 -0
- package/dist/chunks/4728.caffe075.js +2 -0
- package/dist/chunks/4728.caffe075.js.map +1 -0
- package/dist/chunks/4795.90b6991e.js +2 -0
- package/dist/chunks/4795.90b6991e.js.map +1 -0
- package/dist/chunks/5151.d72c681c.js +2 -0
- package/dist/chunks/5151.d72c681c.js.map +1 -0
- package/dist/chunks/5202.e887583f.js +2 -0
- package/dist/chunks/5202.e887583f.js.map +1 -0
- package/dist/chunks/5628.d77bdb77.js +2 -0
- package/dist/chunks/5628.d77bdb77.js.map +1 -0
- package/dist/chunks/5637.2b1b90a3.js +2 -0
- package/dist/chunks/5637.2b1b90a3.js.map +1 -0
- package/dist/chunks/6205.bc110b6d.js +2 -0
- package/dist/chunks/6205.bc110b6d.js.map +1 -0
- package/dist/chunks/6473.70b8b648.js +2 -0
- package/dist/chunks/6473.70b8b648.js.map +1 -0
- package/dist/chunks/6635.cf6a5657.js +3 -0
- package/dist/chunks/6635.cf6a5657.js.LICENSE.txt +8 -0
- package/dist/chunks/6635.cf6a5657.js.map +1 -0
- package/dist/chunks/7164.3bd246c1.js +2 -0
- package/dist/chunks/7164.3bd246c1.js.map +1 -0
- package/dist/chunks/7244.686e225b.js +2 -0
- package/dist/chunks/7244.686e225b.js.map +1 -0
- package/dist/chunks/7746.0d8051b2.js +2 -0
- package/dist/chunks/7746.0d8051b2.js.map +1 -0
- package/dist/chunks/7822.98ffb1b1.js +2 -0
- package/dist/chunks/7822.98ffb1b1.js.map +1 -0
- package/dist/chunks/7915.e235a57b.js +2 -0
- package/dist/chunks/7915.e235a57b.js.map +1 -0
- package/dist/chunks/8008.f2563beb.js +3 -0
- package/dist/chunks/8008.f2563beb.js.LICENSE.txt +3 -0
- package/dist/chunks/8008.f2563beb.js.map +1 -0
- package/dist/chunks/873.d8778899.js +2 -0
- package/dist/chunks/873.d8778899.js.map +1 -0
- package/dist/chunks/9431.4eea30bd.js +2 -0
- package/dist/chunks/9431.4eea30bd.js.map +1 -0
- package/dist/chunks/9549.530da202.js +2 -0
- package/dist/chunks/9549.530da202.js.map +1 -0
- package/dist/chunks/code-editor.c7854829.js +2 -0
- package/dist/chunks/code-editor.c7854829.js.map +1 -0
- package/dist/chunks/dynamic-form-item.48770a46.js +2 -0
- package/dist/chunks/dynamic-form-item.48770a46.js.map +1 -0
- package/dist/chunks/general-checkbox.d95faa71.js +3 -0
- package/dist/chunks/general-checkbox.d95faa71.js.LICENSE.txt +5 -0
- package/dist/chunks/general-checkbox.d95faa71.js.map +1 -0
- package/dist/chunks/general-form-item.b05c0bb9.js +3 -0
- package/dist/chunks/general-form-item.b05c0bb9.js.LICENSE.txt +5 -0
- package/dist/chunks/general-form-item.b05c0bb9.js.map +1 -0
- package/dist/chunks/general-form.432c96e8.js +2 -0
- package/dist/chunks/general-form.432c96e8.js.map +1 -0
- package/dist/chunks/general-input.178d80f2.js +3 -0
- package/dist/chunks/general-input.178d80f2.js.LICENSE.txt +5 -0
- package/dist/chunks/general-input.178d80f2.js.map +1 -0
- package/dist/chunks/general-radio.b77395e8.js +3 -0
- package/dist/chunks/general-radio.b77395e8.js.LICENSE.txt +5 -0
- package/dist/chunks/general-radio.b77395e8.js.map +1 -0
- package/dist/chunks/general-select.a226b1b7.js +3 -0
- package/dist/chunks/general-select.a226b1b7.js.LICENSE.txt +5 -0
- package/dist/chunks/general-select.a226b1b7.js.map +1 -0
- package/dist/chunks/general-textarea.4f0d38a1.js +2 -0
- package/dist/chunks/general-textarea.4f0d38a1.js.map +1 -0
- package/dist/chunks/main.c0e537b3.js +2 -0
- package/dist/chunks/main.c0e537b3.js.map +1 -0
- package/dist/chunks/react.300d737e.js +2 -0
- package/dist/chunks/react.300d737e.js.LICENSE.txt +29 -0
- package/dist/chunks/submit-buttons.1115d5d5.js +2 -0
- package/dist/chunks/submit-buttons.1115d5d5.js.map +1 -0
- package/dist/index.c21224c7.js +2 -0
- package/dist/index.c21224c7.js.map +1 -0
- package/dist-types/bootstrap.d.ts +10 -0
- package/dist-types/checkbox/index.d.ts +84 -0
- package/dist-types/code-editor/aceBuilds/index.d.ts +16 -0
- package/dist-types/code-editor/codeEditor.d.ts +5 -0
- package/dist-types/code-editor/custom-mode/BrickNextMode.d.ts +7 -0
- package/dist-types/code-editor/custom-mode/BrickNextRules.d.ts +170 -0
- package/dist-types/code-editor/custom-mode/BrickNextYamlMode.d.ts +7 -0
- package/dist-types/code-editor/custom-mode/CommonExpressionLanguageMode.d.ts +7 -0
- package/dist-types/code-editor/custom-mode/CommonExpressionLanguageRules.d.ts +19 -0
- package/dist-types/code-editor/custom-mode/CommonExpressionLanguageRules.spec.d.ts +1 -0
- package/dist-types/code-editor/custom-mode/CommonExpressionLanguageYamlMode.d.ts +7 -0
- package/dist-types/code-editor/custom-mode/TerraformMode.d.ts +7 -0
- package/dist-types/code-editor/custom-mode/brickNextUtil.d.ts +15 -0
- package/dist-types/code-editor/getClickableMarker.d.ts +2 -0
- package/dist-types/code-editor/getHighlightMarkers.d.ts +11 -0
- package/dist-types/code-editor/index.d.ts +166 -0
- package/dist-types/code-editor/index.spec.d.ts +1 -0
- package/dist-types/code-editor/interfaces.d.ts +76 -0
- package/dist-types/dynamic-form-item/index.d.ts +34 -0
- package/dist-types/dynamic-form-item/index.spec.d.ts +1 -0
- package/dist-types/form/formStore.d.ts +52 -0
- package/dist-types/form/index.d.ts +71 -0
- package/dist-types/form-item/FormItemElement.d.ts +22 -0
- package/dist-types/form-item/index.d.ts +165 -0
- package/dist-types/index.d.ts +1 -0
- package/dist-types/input/index.d.ts +27 -0
- package/dist-types/interface.d.ts +15 -0
- package/dist-types/radio/index.d.ts +145 -0
- package/dist-types/radio/index.spec.d.ts +1 -0
- package/dist-types/select/index.d.ts +135 -0
- package/dist-types/select/index.spec.d.ts +1 -0
- package/dist-types/submit-buttons/index.d.ts +88 -0
- package/dist-types/submit-buttons/index.spec.d.ts +1 -0
- package/dist-types/textarea/calculateAutoSizeStyle.d.ts +2 -0
- package/dist-types/textarea/index.d.ts +19 -0
- package/dist-types/utils/PubSub.d.ts +6 -0
- package/dist-types/utils/formatOptions.d.ts +5 -0
- package/package.json +60 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IEditorProps } from "react-ace";
|
|
2
|
+
export declare const brickNextSnippet: {
|
|
3
|
+
label: string;
|
|
4
|
+
caption: string;
|
|
5
|
+
snippet: string;
|
|
6
|
+
meta: string;
|
|
7
|
+
}[];
|
|
8
|
+
export declare const brickNextKeywords: string[];
|
|
9
|
+
export declare const brickNextCompleters: ({
|
|
10
|
+
identifierRegexps: RegExp[];
|
|
11
|
+
getCompletions(editor: IEditorProps, session: any, pos: any, prefix: string, callback: any): void;
|
|
12
|
+
} | {
|
|
13
|
+
getCompletions(editor: IEditorProps, session: any, pos: any, prefix: string, callback: any): void;
|
|
14
|
+
identifierRegexps?: undefined;
|
|
15
|
+
})[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IEditorProps } from "react-ace";
|
|
2
|
+
import { ExtendedMarker, HighlightTokenSettings } from "./interfaces.js";
|
|
3
|
+
export declare function getHighlightMarkers({ editor, markerClassMap, highlightTokens, }: {
|
|
4
|
+
editor: IEditorProps;
|
|
5
|
+
markerClassMap: {
|
|
6
|
+
default: string;
|
|
7
|
+
warn: string;
|
|
8
|
+
error: string;
|
|
9
|
+
};
|
|
10
|
+
highlightTokens?: HighlightTokenSettings[];
|
|
11
|
+
}): ExtendedMarker[];
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
+
import { CodeEditorProps, HighlightTokenSettings, Annotation } from "./interfaces.js";
|
|
3
|
+
import { FormItemElement } from "../form-item/FormItemElement.js";
|
|
4
|
+
export interface Error {
|
|
5
|
+
err: Annotation[];
|
|
6
|
+
hasError: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* @id form.code-editor
|
|
10
|
+
* @name form.code-editor
|
|
11
|
+
* @docKind brick
|
|
12
|
+
* @description 通用输入框构件
|
|
13
|
+
* @author sailor
|
|
14
|
+
* @noInheritDoc
|
|
15
|
+
*/
|
|
16
|
+
declare class CodeEditor extends FormItemElement {
|
|
17
|
+
#private;
|
|
18
|
+
/**
|
|
19
|
+
* @description
|
|
20
|
+
* @required -
|
|
21
|
+
* @group basic
|
|
22
|
+
*/
|
|
23
|
+
accessor name: string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* @description
|
|
26
|
+
* @required -
|
|
27
|
+
* @group basic
|
|
28
|
+
*/
|
|
29
|
+
accessor label: string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* @description 代码内容
|
|
32
|
+
* @group basic
|
|
33
|
+
*/
|
|
34
|
+
accessor value: string;
|
|
35
|
+
/**
|
|
36
|
+
* @required false
|
|
37
|
+
* @description 选择框占位说明
|
|
38
|
+
* @group basic
|
|
39
|
+
*/
|
|
40
|
+
accessor placeholder: string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* @default "monokai"
|
|
43
|
+
* @description 主题,支持 tomorrow、monokai、github
|
|
44
|
+
* @group basic
|
|
45
|
+
*/
|
|
46
|
+
accessor theme: string | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* @default "text"
|
|
49
|
+
* @description 语言模式,支持语言如下
|
|
50
|
+
* @group basic
|
|
51
|
+
*/
|
|
52
|
+
accessor mode: string;
|
|
53
|
+
/**
|
|
54
|
+
* @default false
|
|
55
|
+
* @description 是否必填
|
|
56
|
+
* @group basic
|
|
57
|
+
*/
|
|
58
|
+
accessor required: boolean | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* @default false
|
|
61
|
+
* @description 是否只能读,不能编辑。如果一个页面同时需要编辑和查看,可以使用该属性,以保证代码构件的一致性。而如果一个页面只有查看的功能,建议直接使用轻量级[代码展示构件 code-bricks.code-display](developers/brick-book/brick/code-bricks.code-display),避免代码内容过多的时候页面卡顿。
|
|
62
|
+
* @group basic
|
|
63
|
+
*/
|
|
64
|
+
accessor readOnly: boolean | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* @description 是否显示行号
|
|
67
|
+
* @group ui
|
|
68
|
+
*/
|
|
69
|
+
accessor showLineNumbers: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* @description 最大行号,超出就显示滚动条,注意应该为正数或者无穷大
|
|
72
|
+
* @group ui
|
|
73
|
+
*/
|
|
74
|
+
accessor maxLines: number | "Infinity" | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* @description 最小行号,即最小高度为多少行
|
|
77
|
+
* @group ui
|
|
78
|
+
*/
|
|
79
|
+
accessor minLines: number;
|
|
80
|
+
/**
|
|
81
|
+
* @description 一个 tab 代表多少个空格
|
|
82
|
+
* @group other
|
|
83
|
+
*/
|
|
84
|
+
accessor tabSize: number;
|
|
85
|
+
/**
|
|
86
|
+
* @required false
|
|
87
|
+
* @description 显示打印边距
|
|
88
|
+
* @group ui
|
|
89
|
+
*/
|
|
90
|
+
accessor printMargin: boolean | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* @description 高亮激活的行
|
|
93
|
+
* @group other
|
|
94
|
+
*/
|
|
95
|
+
accessor highlightActiveLine: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* @default false
|
|
98
|
+
* @description 是否显示导出按钮
|
|
99
|
+
* @group ui
|
|
100
|
+
*/
|
|
101
|
+
accessor showExportButton: boolean | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* @description 是否显示复制按钮
|
|
104
|
+
* @group ui
|
|
105
|
+
*/
|
|
106
|
+
accessor showCopyButton: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* @description 是否显示展开按钮
|
|
109
|
+
* @group ui
|
|
110
|
+
*/
|
|
111
|
+
accessor showExpandButton: boolean | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* @default "download.txt"
|
|
114
|
+
* @description 当 `showExportButton = true` 时, 配置导出的文件名称, 默认为 download.txt
|
|
115
|
+
* @group other
|
|
116
|
+
*/
|
|
117
|
+
accessor exportFileName: string | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* @description json schema,当 mode 为 json,yaml,brick_next,brick_next_yaml 时会根据该 json schema 进行校验
|
|
120
|
+
* @group other
|
|
121
|
+
*/
|
|
122
|
+
accessor jsonSchema: Record<string, any> | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* @description 校验 Json Schema 的模式,warning 为告警模式,仅作告警提示,不影响表单提交;error 为错误模式,将会阻止表单提交错误内容。
|
|
125
|
+
* @group other
|
|
126
|
+
*/
|
|
127
|
+
accessor validateJsonSchemaMode: "warning" | "error";
|
|
128
|
+
/**
|
|
129
|
+
* @description json schema $ref,设置该属性后会验证 json schema 中对应 $ref 指向的部分片段,以 # 开头代表根节点,例如可以设置成 `#/definitions/BrickConf`
|
|
130
|
+
* @group other
|
|
131
|
+
*/
|
|
132
|
+
accessor schemaRef: string | undefined;
|
|
133
|
+
/**
|
|
134
|
+
* @default false
|
|
135
|
+
* @description 是否开启自动补全
|
|
136
|
+
* @group other
|
|
137
|
+
*/
|
|
138
|
+
accessor enableLiveAutocompletion: boolean | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* @description 自定义自动补全,注意当`enableLiveAutocompletion:true`时才能生效
|
|
141
|
+
* @group other
|
|
142
|
+
*/
|
|
143
|
+
accessor customCompleters: string[] | {
|
|
144
|
+
caption?: string;
|
|
145
|
+
value: string;
|
|
146
|
+
meta?: string;
|
|
147
|
+
score?: number;
|
|
148
|
+
}[] | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* @description 是否与JSON解析行为一致,如果设为`true`,有重复key时取最后一个的value,如果设为`false`,有重复key时会抛出错误
|
|
151
|
+
* @group other
|
|
152
|
+
*/
|
|
153
|
+
accessor loadYamlInJsonMode: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* @description 高亮标记设置。
|
|
156
|
+
* @group other
|
|
157
|
+
*/
|
|
158
|
+
accessor highlightTokens: HighlightTokenSettings[] | undefined;
|
|
159
|
+
private _handleChange;
|
|
160
|
+
private _handleBlur;
|
|
161
|
+
private _handleErrorChange;
|
|
162
|
+
private _handleHighlightTokenClick;
|
|
163
|
+
render(): JSX.Element;
|
|
164
|
+
}
|
|
165
|
+
export declare function CodeEditorComponent(props: CodeEditorProps): JSX.Element;
|
|
166
|
+
export { CodeEditor };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./index.js";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { IMarker } from "react-ace";
|
|
2
|
+
import type { FormItemProps } from "../form-item/index.js";
|
|
3
|
+
export interface Error {
|
|
4
|
+
err: Annotation[];
|
|
5
|
+
hasError: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface ExtendedMarker extends IMarker {
|
|
8
|
+
highlightType: HighlightTokenType;
|
|
9
|
+
identifier: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CodeEditorProps extends FormItemProps {
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
value: string;
|
|
16
|
+
onChange?: (value: string) => void;
|
|
17
|
+
onBlur?: () => void;
|
|
18
|
+
onErrorChange?: (error: Error) => void;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
theme?: string;
|
|
21
|
+
mode: string;
|
|
22
|
+
readOnly?: boolean;
|
|
23
|
+
showLineNumbers?: boolean;
|
|
24
|
+
maxLines?: number | "Infinity";
|
|
25
|
+
minLines: number;
|
|
26
|
+
tabSize?: number;
|
|
27
|
+
showGutter?: boolean;
|
|
28
|
+
printMargin?: boolean;
|
|
29
|
+
highlightActiveLine?: boolean;
|
|
30
|
+
onValidate?: (error: Annotation[]) => void;
|
|
31
|
+
showExportButton?: boolean;
|
|
32
|
+
showCopyButton?: boolean;
|
|
33
|
+
showExpandButton?: boolean;
|
|
34
|
+
exportFileName?: string;
|
|
35
|
+
jsonSchema?: Record<string, any>;
|
|
36
|
+
validateJsonSchemaMode?: "warning" | "error";
|
|
37
|
+
schemaRef?: string;
|
|
38
|
+
enableLiveAutocompletion?: boolean;
|
|
39
|
+
customCompleters?: string[] | {
|
|
40
|
+
caption?: string;
|
|
41
|
+
value: string;
|
|
42
|
+
meta?: string;
|
|
43
|
+
score?: number;
|
|
44
|
+
}[];
|
|
45
|
+
loadYamlInJsonMode?: boolean;
|
|
46
|
+
showPrintMargin?: boolean;
|
|
47
|
+
highlightTokens?: HighlightTokenSettings[];
|
|
48
|
+
onClickHighlightToken?: (token: {
|
|
49
|
+
type: HighlightTokenType;
|
|
50
|
+
value: string;
|
|
51
|
+
}) => void;
|
|
52
|
+
}
|
|
53
|
+
export interface HighlightTokenSettings {
|
|
54
|
+
type: HighlightTokenType;
|
|
55
|
+
clickable?: boolean;
|
|
56
|
+
level?: "default" | "warn" | "error";
|
|
57
|
+
}
|
|
58
|
+
export type HighlightTokenType = "storyboard-function" | "storyboard-context" | "storyboard-context-action" | "storyboard-state" | "storyboard-state-action" | "storyboard-tpl-var" | "storyboard-tag-name-as-target" | "storyboard-route-var" | "dashboard-DS";
|
|
59
|
+
export interface AceLanguageRules {
|
|
60
|
+
[className: string]: AceLanguageRule[];
|
|
61
|
+
}
|
|
62
|
+
export interface AceLanguageRule {
|
|
63
|
+
token?: string | string[] | AceTokenFunction;
|
|
64
|
+
regex?: string | RegExp;
|
|
65
|
+
next?: string;
|
|
66
|
+
defaultToken?: string;
|
|
67
|
+
consumeLineEnd?: boolean;
|
|
68
|
+
onMatch?: (val?: string, state?: unknown, stack?: [string, number], line?: string) => string;
|
|
69
|
+
}
|
|
70
|
+
export type AceTokenFunction = (value: string) => string;
|
|
71
|
+
export interface Annotation {
|
|
72
|
+
row: number;
|
|
73
|
+
column: number;
|
|
74
|
+
text: string;
|
|
75
|
+
type: string;
|
|
76
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
+
import { FormItemElement } from "../form-item/FormItemElement.js";
|
|
3
|
+
import { UseBrickConf } from "@next-core/types";
|
|
4
|
+
import "@next-core/theme";
|
|
5
|
+
type DynamicFormValuesItem = Record<string, any>;
|
|
6
|
+
/**
|
|
7
|
+
* @id form.dynamic-form-item
|
|
8
|
+
* @name form.dynamic-form-item
|
|
9
|
+
* @docKind brick
|
|
10
|
+
* @description 动态表单
|
|
11
|
+
* @author sailor
|
|
12
|
+
* @noInheritDoc
|
|
13
|
+
*/
|
|
14
|
+
declare class DynamicFormItem extends FormItemElement {
|
|
15
|
+
#private;
|
|
16
|
+
accessor name: string | undefined;
|
|
17
|
+
accessor label: string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* @default
|
|
20
|
+
* @required
|
|
21
|
+
* @description
|
|
22
|
+
*/
|
|
23
|
+
accessor required: boolean | undefined;
|
|
24
|
+
accessor value: DynamicFormValuesItem[] | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* @default
|
|
27
|
+
* @required
|
|
28
|
+
* @description
|
|
29
|
+
*/
|
|
30
|
+
accessor useBrick: UseBrickConf | undefined;
|
|
31
|
+
handleDynamicFormChange: (values: DynamicFormValuesItem[]) => void;
|
|
32
|
+
render(): JSX.Element;
|
|
33
|
+
}
|
|
34
|
+
export { DynamicFormItem };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
+
import { PubSub } from "../utils/PubSub.js";
|
|
3
|
+
interface FormStoreOptions {
|
|
4
|
+
onValuesChanged?: (data: any) => void;
|
|
5
|
+
}
|
|
6
|
+
interface FieldDetail {
|
|
7
|
+
name: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
originProps?: Record<string, any>;
|
|
10
|
+
validate: Validate;
|
|
11
|
+
[k: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export interface MessageBody {
|
|
14
|
+
message: string;
|
|
15
|
+
type: string;
|
|
16
|
+
}
|
|
17
|
+
export interface WatchOptions {
|
|
18
|
+
needValidate?: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface Validate {
|
|
21
|
+
required?: boolean;
|
|
22
|
+
pattern?: string;
|
|
23
|
+
min?: number;
|
|
24
|
+
max?: number;
|
|
25
|
+
message?: {
|
|
26
|
+
required?: string;
|
|
27
|
+
pattern?: string;
|
|
28
|
+
min?: string;
|
|
29
|
+
max?: string;
|
|
30
|
+
};
|
|
31
|
+
validator?: (value: any) => MessageBody | string;
|
|
32
|
+
}
|
|
33
|
+
export declare class FormStore extends PubSub {
|
|
34
|
+
#private;
|
|
35
|
+
static uid: number;
|
|
36
|
+
static instance: Map<number, FormStore>;
|
|
37
|
+
static getInstance(options?: FormStoreOptions): FormStore;
|
|
38
|
+
constructor(options?: FormStoreOptions);
|
|
39
|
+
setField(name: string, detail: FieldDetail): void;
|
|
40
|
+
getAllValues(): Record<string, unknown>;
|
|
41
|
+
setInitValue(values: Record<string, unknown>, isEmitValuseChange?: boolean): void;
|
|
42
|
+
setFieldsValueByInitData(name: string): void;
|
|
43
|
+
setFieldsValue(values: Record<string, unknown>, isEmitValuseChange?: boolean): void;
|
|
44
|
+
resetFields(name?: string): void;
|
|
45
|
+
getFieldsValue(name: string): unknown;
|
|
46
|
+
validateFields(callback: (err: boolean, value: any) => void): boolean | Record<string, unknown>;
|
|
47
|
+
validateField(field: string | FieldDetail): MessageBody | undefined;
|
|
48
|
+
getValueFromEvent(e: React.ChangeEvent): any;
|
|
49
|
+
resetValidateState(): void;
|
|
50
|
+
onWatch(name: string, event: React.ChangeEvent, callback?: (v: string) => void, options?: WatchOptions): void;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
+
import { ReactNextElement } from "@next-core/react-element";
|
|
3
|
+
import { FormStore } from "./formStore.js";
|
|
4
|
+
import { ComponentSize, Layout } from "../interface.js";
|
|
5
|
+
interface FormProps {
|
|
6
|
+
values?: Record<string, any>;
|
|
7
|
+
layout?: Layout;
|
|
8
|
+
size?: ComponentSize;
|
|
9
|
+
}
|
|
10
|
+
export interface FormEvents {
|
|
11
|
+
valuesChange?: Event;
|
|
12
|
+
validateSuccess?: Event;
|
|
13
|
+
validateError?: Event;
|
|
14
|
+
}
|
|
15
|
+
export interface FormMapEvents {
|
|
16
|
+
onValuesChange: "values.change";
|
|
17
|
+
onValidateSuccess: "validate.success";
|
|
18
|
+
onValidateError: "validate.error";
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @id form.general-form
|
|
22
|
+
* @name form.general-form
|
|
23
|
+
* @docKind brick
|
|
24
|
+
* @description 通用输入框构件
|
|
25
|
+
* @author sailor
|
|
26
|
+
* @noInheritDoc
|
|
27
|
+
*/
|
|
28
|
+
declare class Form extends ReactNextElement implements FormProps {
|
|
29
|
+
#private;
|
|
30
|
+
readonly isFormElement = true;
|
|
31
|
+
formStore: FormStore;
|
|
32
|
+
defaultEmitValuesChange: boolean;
|
|
33
|
+
constructor();
|
|
34
|
+
set values(value: Record<string, unknown>);
|
|
35
|
+
get values(): Record<string, unknown>;
|
|
36
|
+
accessor layout: Layout | undefined;
|
|
37
|
+
accessor size: ComponentSize | undefined;
|
|
38
|
+
handleValuesChange: (values: Record<string, unknown>) => void;
|
|
39
|
+
/**
|
|
40
|
+
* @description
|
|
41
|
+
*/
|
|
42
|
+
validate(): boolean | Record<string, unknown>;
|
|
43
|
+
/**
|
|
44
|
+
* @description
|
|
45
|
+
*/
|
|
46
|
+
setInitValue(values: Record<string, unknown>): void;
|
|
47
|
+
/**
|
|
48
|
+
* @description
|
|
49
|
+
*/
|
|
50
|
+
resetFields(name?: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* @description
|
|
53
|
+
*/
|
|
54
|
+
getFieldsValue(name: string): unknown;
|
|
55
|
+
/**
|
|
56
|
+
* @description
|
|
57
|
+
*/
|
|
58
|
+
validateField(name: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* @description
|
|
61
|
+
*/
|
|
62
|
+
resetValidateState(): void;
|
|
63
|
+
render(): JSX.Element;
|
|
64
|
+
}
|
|
65
|
+
interface FormComponentProps extends FormProps {
|
|
66
|
+
onValuesChange?: (value: Record<string, any>) => void;
|
|
67
|
+
onValidateSuccess?: () => void;
|
|
68
|
+
onValidateError?: () => void;
|
|
69
|
+
}
|
|
70
|
+
export declare function FormComponent({ layout }: FormComponentProps): JSX.Element;
|
|
71
|
+
export { Form, FormProps };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactNextElement } from "@next-core/react-element";
|
|
2
|
+
import type { Form } from "../form/index.jsx";
|
|
3
|
+
export declare abstract class FormItemElement extends ReactNextElement {
|
|
4
|
+
#private;
|
|
5
|
+
accessor isFormItemElement: boolean;
|
|
6
|
+
set validateState(value: string);
|
|
7
|
+
get validateState(): string;
|
|
8
|
+
/**
|
|
9
|
+
* @required false
|
|
10
|
+
* @default false
|
|
11
|
+
* @description 控制该表单项是否隐藏
|
|
12
|
+
* @group ui
|
|
13
|
+
*/
|
|
14
|
+
set notRender(value: boolean);
|
|
15
|
+
get notRender(): boolean;
|
|
16
|
+
get $bindFormItem(): boolean;
|
|
17
|
+
set $bindFormItem(value: boolean);
|
|
18
|
+
/**
|
|
19
|
+
* @description
|
|
20
|
+
*/
|
|
21
|
+
getFormElement(): Form;
|
|
22
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
+
import { FormItemElement } from "./FormItemElement.js";
|
|
3
|
+
import type { Form } from "../form/index.jsx";
|
|
4
|
+
import type { ComponentSize, Layout } from "../interface.js";
|
|
5
|
+
import type { MessageBody } from "../form/formStore.js";
|
|
6
|
+
import "@next-core/theme";
|
|
7
|
+
type CurrentElement = HTMLElement & {
|
|
8
|
+
size?: ComponentSize;
|
|
9
|
+
validateState?: MessageBody | string;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
12
|
+
export interface FormItemProps {
|
|
13
|
+
formElement?: Form;
|
|
14
|
+
curElement: CurrentElement;
|
|
15
|
+
name?: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
current?: HTMLElement;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
pattern?: string;
|
|
20
|
+
min?: number;
|
|
21
|
+
max?: number;
|
|
22
|
+
labelCol?: string;
|
|
23
|
+
wrapperCol?: string;
|
|
24
|
+
message?: Record<string, string>;
|
|
25
|
+
layout?: Layout;
|
|
26
|
+
size?: ComponentSize;
|
|
27
|
+
trigger?: string;
|
|
28
|
+
valuePropsName?: string;
|
|
29
|
+
needValidate?: boolean;
|
|
30
|
+
validator?: (value: any) => MessageBody | string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @id form.general-form
|
|
34
|
+
* @name form.general-form
|
|
35
|
+
* @docKind brick
|
|
36
|
+
* @description 通用输入框构件
|
|
37
|
+
* @author sailor
|
|
38
|
+
* @noInheritDoc
|
|
39
|
+
*/
|
|
40
|
+
declare class FormItem extends FormItemElement implements FormItemProps {
|
|
41
|
+
/**
|
|
42
|
+
* @default
|
|
43
|
+
* @required
|
|
44
|
+
* @description
|
|
45
|
+
*/
|
|
46
|
+
accessor formElement: Form | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* @default
|
|
49
|
+
* @required
|
|
50
|
+
* @description
|
|
51
|
+
*/
|
|
52
|
+
accessor curElement: HTMLElement;
|
|
53
|
+
/**
|
|
54
|
+
* @kind string
|
|
55
|
+
* @required false
|
|
56
|
+
* @default default
|
|
57
|
+
* @description 字段名称
|
|
58
|
+
* @enums
|
|
59
|
+
* @group basic
|
|
60
|
+
*/
|
|
61
|
+
accessor name: string | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* @default
|
|
64
|
+
* @required
|
|
65
|
+
* @description
|
|
66
|
+
*/
|
|
67
|
+
accessor label: string | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* @default
|
|
70
|
+
* @required
|
|
71
|
+
* @description
|
|
72
|
+
*/
|
|
73
|
+
accessor pattern: string | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* @default
|
|
76
|
+
* @required
|
|
77
|
+
* @description
|
|
78
|
+
*/
|
|
79
|
+
accessor message: Record<string, string> | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* @default
|
|
82
|
+
* @required
|
|
83
|
+
* @description
|
|
84
|
+
*/
|
|
85
|
+
accessor max: number | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* @default
|
|
88
|
+
* @required
|
|
89
|
+
* @description
|
|
90
|
+
*/
|
|
91
|
+
accessor min: number | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* @kind boolean
|
|
94
|
+
* @required false
|
|
95
|
+
* @default -
|
|
96
|
+
* @description 表单项是否必填
|
|
97
|
+
* @group basicFormItem
|
|
98
|
+
*/
|
|
99
|
+
accessor required: boolean | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* @kind string
|
|
102
|
+
* @required false
|
|
103
|
+
* @default default
|
|
104
|
+
* @description 初始值
|
|
105
|
+
* @enums
|
|
106
|
+
* @group basic
|
|
107
|
+
*/
|
|
108
|
+
accessor value: string | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* @required false
|
|
111
|
+
* @description 表单项 label 标签布局
|
|
112
|
+
* @group ui
|
|
113
|
+
*/
|
|
114
|
+
accessor labelCol: string | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* @required false
|
|
117
|
+
* @description 表单项控件布局
|
|
118
|
+
* @group ui
|
|
119
|
+
*/
|
|
120
|
+
accessor wrapperCol: string | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* @kind string
|
|
123
|
+
* @required false
|
|
124
|
+
* @default default
|
|
125
|
+
* @description 初始值
|
|
126
|
+
* @enums
|
|
127
|
+
* @group basic
|
|
128
|
+
*/
|
|
129
|
+
accessor valuePropsName: string | undefined;
|
|
130
|
+
accessor layout: Layout;
|
|
131
|
+
/**
|
|
132
|
+
* @kind string
|
|
133
|
+
* @required false
|
|
134
|
+
* @default default
|
|
135
|
+
* @description 初始值
|
|
136
|
+
* @enums
|
|
137
|
+
* @group basic
|
|
138
|
+
*/
|
|
139
|
+
accessor size: ComponentSize | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* @default true
|
|
142
|
+
* @description 是否自动去除前后的空白字符
|
|
143
|
+
* @group advancedFormItem
|
|
144
|
+
*/
|
|
145
|
+
accessor trim: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* @default false
|
|
148
|
+
* @description 事件触发方法名
|
|
149
|
+
*/
|
|
150
|
+
accessor trigger: string;
|
|
151
|
+
/**
|
|
152
|
+
* @default false
|
|
153
|
+
* @description 表单项校验方法
|
|
154
|
+
*/
|
|
155
|
+
accessor validator: ((value: any) => MessageBody) | undefined;
|
|
156
|
+
/**
|
|
157
|
+
* @default
|
|
158
|
+
* @required
|
|
159
|
+
* @description 值变化时是否主动出发校验
|
|
160
|
+
*/
|
|
161
|
+
accessor needValidate: boolean | undefined;
|
|
162
|
+
render(): JSX.Element;
|
|
163
|
+
}
|
|
164
|
+
export { FormItem };
|
|
165
|
+
export declare function FormItemComponent(props: FormItemProps): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ComponentSize, InputType } from "../interface.js";
|
|
3
|
+
import "@next-core/theme";
|
|
4
|
+
import { Form } from "../form/index.js";
|
|
5
|
+
interface InputProps {
|
|
6
|
+
formElement?: Form;
|
|
7
|
+
curElement: HTMLElement;
|
|
8
|
+
name?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
value?: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
type?: InputType;
|
|
14
|
+
size?: ComponentSize;
|
|
15
|
+
inputStyle?: React.CSSProperties;
|
|
16
|
+
minLength?: number;
|
|
17
|
+
maxLength?: number;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
pattern?: string;
|
|
20
|
+
min?: number;
|
|
21
|
+
max?: number;
|
|
22
|
+
validateState?: string;
|
|
23
|
+
trigger?: string;
|
|
24
|
+
onInputChange: (value: string) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare function InputComponent(props: InputProps): JSX.Element;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type Target = "_self" | "_blank" | "_parent" | "_top";
|
|
2
|
+
export type UIType = "default" | "dashboard";
|
|
3
|
+
export type Shape = "round" | "circle";
|
|
4
|
+
export type ButtonType = "primary" | "default" | "dashed" | "ghost" | "link" | "text";
|
|
5
|
+
export type ComponentSize = "large" | "middle" | "small" | "xs";
|
|
6
|
+
export type InputType = "button" | "checkbox" | "color" | "date" | "datetime-local" | "email" | "file" | "hidden" | "image" | "month" | "number" | "password" | "radio" | "range" | "reset" | "search" | "submit" | "tel" | "text" | "time" | "url" | "week";
|
|
7
|
+
export type Layout = "horizontal" | "vertical" | "inline";
|
|
8
|
+
export type RadioType = "button" | "default" | "icon" | "icon-circle" | "icon-square" | "custom";
|
|
9
|
+
export interface GeneralComplexOption<T = string | number | boolean> {
|
|
10
|
+
label: string;
|
|
11
|
+
value: T;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}
|
|
14
|
+
export declare type GeneralOption = string | number | boolean | GeneralComplexOption | Record<string, any>;
|
|
15
|
+
export declare type RadioGroupButtonStyle = "outline" | "solid";
|