@blueking/bkui-form 0.0.4
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/bkui-form-umd-min.js +9 -0
- package/dist/bkui-form-umd.js +10802 -0
- package/dist/bkui-form-umd.js.map +1 -0
- package/dist/bkui-form.css +96 -0
- package/dist/types/bkui-form.d.ts +148 -0
- package/package.json +75 -0
- package/readme.md +410 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
.bk-schema-form .mr24 {
|
|
2
|
+
margin-right: 24px;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.bk-schema-form .bk-form-item {
|
|
6
|
+
margin-top: unset !important;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.bk-schema-form .bk-form-item .bk-form-content .group-text {
|
|
10
|
+
background-color: #f2f4f8;
|
|
11
|
+
height: 100%;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.bk-schema-form .bk-form-item .bk-select {
|
|
15
|
+
background-color: #fff;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.bk-schema-form .bk-form-item .bk-select.is-disabled {
|
|
19
|
+
background-color: #fafbfd;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.bk-schema-form .bk-schema-form-group.normal {
|
|
23
|
+
padding: 24px;
|
|
24
|
+
position: relative;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.bk-schema-form .bk-schema-form-group.card{
|
|
28
|
+
background: #fff;
|
|
29
|
+
padding: 0 24px 24px 24px;
|
|
30
|
+
border-radius: 2px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.bk-schema-form .bk-schema-form-group .bk-schema-form-group-title {
|
|
34
|
+
font-size: 14px;
|
|
35
|
+
font-weight: 600;
|
|
36
|
+
color: #63656E;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.bk-schema-form .bk-schema-form-group .bk-schema-form-group-title.normal {
|
|
40
|
+
position: absolute;
|
|
41
|
+
top: -1em;
|
|
42
|
+
left: 10px;
|
|
43
|
+
line-height: 2em;
|
|
44
|
+
padding: 0 0.5em;
|
|
45
|
+
background: #fff;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.bk-schema-form .bk-schema-form-group .bk-schema-form-group-title.card{
|
|
49
|
+
display: flex;
|
|
50
|
+
height: 50px;
|
|
51
|
+
align-items: center;
|
|
52
|
+
padding: 0 24px;
|
|
53
|
+
margin: 0 -24px 16px -24px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.bk-schema-form .bk-collapse-item .bk-collapse-item-header {
|
|
57
|
+
height: 54px;
|
|
58
|
+
padding: 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.bk-schema-form .bk-collapse-item .bk-collapse-item-content {
|
|
62
|
+
background: #f5f7fa;
|
|
63
|
+
padding: 0 34px 16px 34px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.bk-schema-form .bk-schema-form-group-add {
|
|
67
|
+
font-size: 14px;
|
|
68
|
+
color: #3a84ff;
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
display: flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.bk-schema-form .bk-schema-form-group-delete {
|
|
75
|
+
position: absolute;
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
color: #979bA5;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.bk-schema-form .bk-schema-form-group-delete:hover {
|
|
81
|
+
color: #3a84ff;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.bk-schema-form-item__error-tips {
|
|
85
|
+
color: #f5222d;
|
|
86
|
+
font-size: 12px;
|
|
87
|
+
margin-top: 5px;
|
|
88
|
+
margin: 0;
|
|
89
|
+
line-height: 1.5em;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.bk-schema-form-item--error input,
|
|
93
|
+
.bk-schema-form-item--error .bk-textarea-wrapper,
|
|
94
|
+
.bk-schema-form-item--error .bk-select {
|
|
95
|
+
border: 1px solid #f5222d;
|
|
96
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import * as vue_types_vue from 'vue/types/vue';
|
|
2
|
+
import * as json_schema from 'json-schema';
|
|
3
|
+
import { JSONSchema6TypeName, JSONSchema7 } from 'json-schema';
|
|
4
|
+
import Vue, { VNodeData } from 'vue';
|
|
5
|
+
import styleInject from '../node_modules/style-inject/dist/style-inject.es.js';
|
|
6
|
+
|
|
7
|
+
type ILayout = ILayoutConfig | string | number;
|
|
8
|
+
interface ILayoutConfig {
|
|
9
|
+
prop: string | number;
|
|
10
|
+
container?: any;
|
|
11
|
+
item?: any;
|
|
12
|
+
group?: ILayoutConfig[][];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type GlobalComponents = any;
|
|
16
|
+
interface IFormOption<T> {
|
|
17
|
+
// 组件命名空间,默认bk
|
|
18
|
+
namespace: string;
|
|
19
|
+
// Schema表单依赖的基础组件
|
|
20
|
+
baseWidgets?: {},
|
|
21
|
+
// 内置的自定义表单组件(包装特定逻辑后的别名)
|
|
22
|
+
components: {
|
|
23
|
+
[k in GlobalComponents]: T
|
|
24
|
+
},
|
|
25
|
+
// schema type对应的field类型
|
|
26
|
+
fields: {
|
|
27
|
+
[k in JSONSchema6TypeName]: T
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface IUIComponent extends VNodeData {
|
|
32
|
+
name: any;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var css_248z = ".bk-schema-form .mr24 {\n margin-right: 24px;\n}\n\n.bk-schema-form .bk-form-item {\n margin-top: unset !important;\n}\n\n.bk-schema-form .bk-form-item .bk-form-content .group-text {\n background-color: #f2f4f8;\n height: 100%;\n}\n\n.bk-schema-form .bk-form-item .bk-select {\n background-color: #fff;\n}\n\n.bk-schema-form .bk-form-item .bk-select.is-disabled {\n background-color: #fafbfd;\n}\n\n.bk-schema-form .bk-schema-form-group.normal {\n padding: 24px;\n position: relative;\n}\n\n.bk-schema-form .bk-schema-form-group.card{\n background: #fff;\n padding: 0 24px 24px 24px;\n border-radius: 2px;\n}\n\n.bk-schema-form .bk-schema-form-group .bk-schema-form-group-title {\n font-size: 14px;\n font-weight: 600;\n color: #63656E;\n}\n\n.bk-schema-form .bk-schema-form-group .bk-schema-form-group-title.normal {\n position: absolute;\n top: -1em;\n left: 10px;\n line-height: 2em;\n padding: 0 0.5em;\n background: #fff;\n}\n\n.bk-schema-form .bk-schema-form-group .bk-schema-form-group-title.card{\n display: flex;\n height: 50px;\n align-items: center;\n padding: 0 24px;\n margin: 0 -24px 16px -24px;\n}\n\n.bk-schema-form .bk-collapse-item .bk-collapse-item-header {\n height: 54px;\n padding: 0;\n}\n\n.bk-schema-form .bk-collapse-item .bk-collapse-item-content {\n background: #f5f7fa;\n padding: 0 34px 16px 34px;\n}\n\n.bk-schema-form .bk-schema-form-group-add {\n font-size: 14px;\n color: #3a84ff;\n cursor: pointer;\n display: flex;\n align-items: center;\n}\n\n.bk-schema-form .bk-schema-form-group-delete {\n position: absolute;\n cursor: pointer;\n color: #979bA5;\n}\n\n.bk-schema-form .bk-schema-form-group-delete:hover {\n color: #3a84ff;\n}\n\n.bk-schema-form-item__error-tips {\n color: #f5222d;\n font-size: 12px;\n margin-top: 5px;\n margin: 0;\n line-height: 1.5em;\n}\n\n.bk-schema-form-item--error input,\n.bk-schema-form-item--error .bk-textarea-wrapper,\n.bk-schema-form-item--error .bk-select {\n border: 1px solid #f5222d;\n}";
|
|
36
|
+
styleInject(css_248z);
|
|
37
|
+
|
|
38
|
+
declare function createForm<T>(opts?: Partial<IFormOption<T>>): vue_types_vue.ExtendedVue<Vue, {
|
|
39
|
+
rootData: {};
|
|
40
|
+
}, {
|
|
41
|
+
initFormData(): void;
|
|
42
|
+
emitFormValueChange(newValue: any, oldValue: any): void;
|
|
43
|
+
validateForm: () => boolean;
|
|
44
|
+
validateFormItem: (path: string) => boolean;
|
|
45
|
+
}, unknown, {
|
|
46
|
+
value: any;
|
|
47
|
+
rules: any;
|
|
48
|
+
schema: any;
|
|
49
|
+
width: string | number;
|
|
50
|
+
layout: ILayout[][];
|
|
51
|
+
formType: string;
|
|
52
|
+
context: any;
|
|
53
|
+
httpAdapter: any;
|
|
54
|
+
}>;
|
|
55
|
+
|
|
56
|
+
declare class FormEvent {
|
|
57
|
+
callbacks: Record<string, Record<string, Array<Function>>>;
|
|
58
|
+
constructor();
|
|
59
|
+
on(path: string, type: string, cb: Function): this;
|
|
60
|
+
off(path: string, type: string, cb: Function): this;
|
|
61
|
+
once(path: string, type: string, cb: Function): this;
|
|
62
|
+
emit(path: string, type: string, ...arg: any[]): void;
|
|
63
|
+
}
|
|
64
|
+
declare const _default: FormEvent;
|
|
65
|
+
|
|
66
|
+
declare class Schema {
|
|
67
|
+
static rootSchema: JSONSchema7;
|
|
68
|
+
static resolveAllOf(schema: JSONSchema7): {
|
|
69
|
+
$id?: string | undefined;
|
|
70
|
+
$ref?: string | undefined;
|
|
71
|
+
$schema?: string | undefined;
|
|
72
|
+
$comment?: string | undefined;
|
|
73
|
+
$defs?: {
|
|
74
|
+
[key: string]: json_schema.JSONSchema7Definition;
|
|
75
|
+
} | undefined;
|
|
76
|
+
type?: json_schema.JSONSchema7TypeName | json_schema.JSONSchema7TypeName[] | undefined;
|
|
77
|
+
enum?: json_schema.JSONSchema7Type[] | undefined;
|
|
78
|
+
const?: json_schema.JSONSchema7Type | undefined;
|
|
79
|
+
multipleOf?: number | undefined;
|
|
80
|
+
maximum?: number | undefined;
|
|
81
|
+
exclusiveMaximum?: number | undefined;
|
|
82
|
+
minimum?: number | undefined;
|
|
83
|
+
exclusiveMinimum?: number | undefined;
|
|
84
|
+
maxLength?: number | undefined;
|
|
85
|
+
minLength?: number | undefined;
|
|
86
|
+
pattern?: string | undefined;
|
|
87
|
+
items?: json_schema.JSONSchema7Definition | json_schema.JSONSchema7Definition[] | undefined;
|
|
88
|
+
additionalItems?: json_schema.JSONSchema7Definition | undefined;
|
|
89
|
+
maxItems?: number | undefined;
|
|
90
|
+
minItems?: number | undefined;
|
|
91
|
+
uniqueItems?: boolean | undefined;
|
|
92
|
+
contains?: JSONSchema7 | undefined;
|
|
93
|
+
maxProperties?: number | undefined;
|
|
94
|
+
minProperties?: number | undefined;
|
|
95
|
+
required?: string[] | undefined;
|
|
96
|
+
properties?: {
|
|
97
|
+
[key: string]: json_schema.JSONSchema7Definition;
|
|
98
|
+
} | undefined;
|
|
99
|
+
patternProperties?: {
|
|
100
|
+
[key: string]: json_schema.JSONSchema7Definition;
|
|
101
|
+
} | undefined;
|
|
102
|
+
additionalProperties?: json_schema.JSONSchema7Definition | undefined;
|
|
103
|
+
dependencies?: {
|
|
104
|
+
[key: string]: string[] | json_schema.JSONSchema7Definition;
|
|
105
|
+
} | undefined;
|
|
106
|
+
propertyNames?: json_schema.JSONSchema7Definition | undefined;
|
|
107
|
+
if?: json_schema.JSONSchema7Definition | undefined;
|
|
108
|
+
then?: json_schema.JSONSchema7Definition | undefined;
|
|
109
|
+
else?: json_schema.JSONSchema7Definition | undefined;
|
|
110
|
+
anyOf?: json_schema.JSONSchema7Definition[] | undefined;
|
|
111
|
+
oneOf?: json_schema.JSONSchema7Definition[] | undefined;
|
|
112
|
+
not?: json_schema.JSONSchema7Definition | undefined;
|
|
113
|
+
format?: string | undefined;
|
|
114
|
+
contentMediaType?: string | undefined;
|
|
115
|
+
contentEncoding?: string | undefined;
|
|
116
|
+
definitions?: {
|
|
117
|
+
[key: string]: json_schema.JSONSchema7Definition;
|
|
118
|
+
} | undefined;
|
|
119
|
+
title?: string | undefined;
|
|
120
|
+
description?: string | undefined;
|
|
121
|
+
default?: json_schema.JSONSchema7Type | undefined;
|
|
122
|
+
readOnly?: boolean | undefined;
|
|
123
|
+
writeOnly?: boolean | undefined;
|
|
124
|
+
examples?: json_schema.JSONSchema7Type | undefined;
|
|
125
|
+
};
|
|
126
|
+
static mergeSchemaAllOf(...args: any[]): JSONSchema7;
|
|
127
|
+
static resolveRef(): void;
|
|
128
|
+
static resolveDependencies(): void;
|
|
129
|
+
static resolveAdditionalProperties(): void;
|
|
130
|
+
static resolveSchema(schema: JSONSchema7): JSONSchema7;
|
|
131
|
+
static getSchemaDefaultValue(_schema: JSONSchema7): any;
|
|
132
|
+
static getSchemaType(schema: JSONSchema7): string;
|
|
133
|
+
static getSchemaField(schema: JSONSchema7): Partial<IUIComponent>;
|
|
134
|
+
static isMultiSelect(schema: JSONSchema7): boolean;
|
|
135
|
+
static isTupleArray(schema: JSONSchema7): boolean;
|
|
136
|
+
static isCustomArrayWidget(schema: JSONSchema7): any;
|
|
137
|
+
static getGroupWrap(schema: JSONSchema7): Partial<IUIComponent>;
|
|
138
|
+
static getUiComponent(schema: JSONSchema7): Partial<IUIComponent>;
|
|
139
|
+
static getDefaultWidget(schema: JSONSchema7): string | object | null;
|
|
140
|
+
static isRequired(schema: JSONSchema7, name: string): boolean;
|
|
141
|
+
static getUiOptions(schema: JSONSchema7): any;
|
|
142
|
+
static getDependencies(schema: JSONSchema7, name: string): [string, string[] | json_schema.JSONSchema7Definition] | undefined;
|
|
143
|
+
static orderProps(): void;
|
|
144
|
+
static resolveDefaultDatasource(schema: JSONSchema7): any;
|
|
145
|
+
constructor(rootSchema: any);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export { Schema, createForm as default, _default as events };
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.0.4",
|
|
3
|
+
"main": "dist/bkui-form-umd-min.js",
|
|
4
|
+
"name": "@blueking/bkui-form",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "gulp build",
|
|
7
|
+
"dev": "gulp dev",
|
|
8
|
+
"playground": "node ./playground/server.js",
|
|
9
|
+
"test": "jest",
|
|
10
|
+
"coverage": "jest --coverage"
|
|
11
|
+
},
|
|
12
|
+
"files":[
|
|
13
|
+
"dist/"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [],
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"description": "",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@babel/core": "^7.15.5",
|
|
21
|
+
"@babel/plugin-proposal-decorators": "^7.15.4",
|
|
22
|
+
"@babel/plugin-transform-runtime": "^7.15.0",
|
|
23
|
+
"@babel/preset-env": "^7.15.6",
|
|
24
|
+
"@babel/preset-typescript": "^7.15.0",
|
|
25
|
+
"@babel/runtime": "^7.15.4",
|
|
26
|
+
"@blueking/eslint-config-bk": "2.1.0-beta.6",
|
|
27
|
+
"@rollup/plugin-alias": "^3.1.5",
|
|
28
|
+
"@rollup/plugin-babel": "^5.3.0",
|
|
29
|
+
"@rollup/plugin-commonjs": "^20.0.0",
|
|
30
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
31
|
+
"@rollup/plugin-node-resolve": "^13.0.4",
|
|
32
|
+
"@rollup/plugin-replace": "^3.0.0",
|
|
33
|
+
"@rollup/plugin-typescript": "^8.2.5",
|
|
34
|
+
"@rollup/plugin-url": "^6.1.0",
|
|
35
|
+
"@types/jest": "^27.0.3",
|
|
36
|
+
"@types/json-schema": "^7.0.9",
|
|
37
|
+
"@types/node": "^16.9.1",
|
|
38
|
+
"@vue/babel-preset-jsx": "^1.2.4",
|
|
39
|
+
"@vue/compiler-sfc": "^3.2.11",
|
|
40
|
+
"fs-extra": "^10.0.0",
|
|
41
|
+
"generate-source-map": "0.0.5",
|
|
42
|
+
"gulp": "^4.0.2",
|
|
43
|
+
"jest": "^27.4.4",
|
|
44
|
+
"postcss": "^8.4.12",
|
|
45
|
+
"resize-detector": "^0.3.0",
|
|
46
|
+
"rollup": "^2.56.3",
|
|
47
|
+
"rollup-merge-config": "0.0.3",
|
|
48
|
+
"rollup-plugin-copy": "^3.4.0",
|
|
49
|
+
"rollup-plugin-css-only": "^3.1.0",
|
|
50
|
+
"rollup-plugin-dts": "^4.2.1",
|
|
51
|
+
"rollup-plugin-external-globals": "^0.6.1",
|
|
52
|
+
"rollup-plugin-import-css": "^3.0.3",
|
|
53
|
+
"rollup-plugin-livereload": "^2.0.5",
|
|
54
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
55
|
+
"rollup-plugin-serve": "^1.1.0",
|
|
56
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
57
|
+
"rollup-plugin-vue": "^5.1.9",
|
|
58
|
+
"ts-jest": "^27.1.1",
|
|
59
|
+
"ts-node": "^10.4.0",
|
|
60
|
+
"tslib": "^2.3.1",
|
|
61
|
+
"typescript": "^4.4.3",
|
|
62
|
+
"vue": "2.6.12",
|
|
63
|
+
"vue-template-compiler": "2.6.12"
|
|
64
|
+
},
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"bk-magic-vue": "2.4.8",
|
|
67
|
+
"ajv": "^8.10.0",
|
|
68
|
+
"koa": "^2.7.0",
|
|
69
|
+
"koa-static": "^5.0.0"
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": ">= 12.16.3",
|
|
73
|
+
"npm": ">= 6.4.1 <7"
|
|
74
|
+
}
|
|
75
|
+
}
|