@blueking/bkui-form 1.0.1-beta.1 → 1.0.1-beta.3
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/esm/adapter/common/FieldGroupWrap.tsx.js +199 -0
- package/esm/adapter/field/ArrayField.tsx.js +55 -0
- package/esm/adapter/field/BooleanField.tsx.js +41 -0
- package/esm/adapter/field/CompositionField.tsx.js +113 -0
- package/esm/adapter/field/FieldProps.ts.js +85 -0
- package/esm/adapter/field/NumberField.tsx.js +19 -0
- package/esm/adapter/field/ObjectField.tsx.js +58 -0
- package/esm/adapter/field/SchemaField.tsx.js +28 -0
- package/esm/adapter/field/StringField.tsx.js +4 -0
- package/esm/adapter/widget/ArrayWidget.ts.js +196 -0
- package/esm/adapter/widget/ButtonWidget.ts.js +76 -0
- package/esm/adapter/widget/CheckboxWidget.ts.js +101 -0
- package/esm/adapter/widget/CollapseGroupWidget.ts.js +140 -0
- package/esm/adapter/widget/ColorPickerWidget.ts.js +71 -0
- package/esm/adapter/widget/InputWidget.ts.js +79 -0
- package/esm/adapter/widget/KeyValueArrayWidget.tsx.js +156 -0
- package/esm/adapter/widget/RadioWidget.ts.js +98 -0
- package/esm/adapter/widget/SelectWidget.ts.js +98 -0
- package/esm/adapter/widget/SwitchWidget.ts.js +73 -0
- package/esm/adapter/widget/TabGroupWidget.ts.js +145 -0
- package/esm/adapter/widget/TableWidget.ts.js +205 -0
- package/esm/adapter/widget/Widget.ts.js +497 -0
- package/esm/assets/fonts/iconcool.eot +0 -0
- package/esm/assets/fonts/iconcool.ttf +0 -0
- package/esm/assets/fonts/iconcool.woff +0 -0
- package/esm/assets/style.css +43 -0
- package/esm/controller/form.css +164 -0
- package/esm/controller/form.tsx.js +159 -0
- package/esm/controller/props.ts.js +75 -0
- package/esm/core/events.ts.js +74 -0
- package/esm/core/expression.ts.js +67 -0
- package/esm/core/lang.ts.js +25 -0
- package/esm/core/layout.ts.js +149 -0
- package/esm/core/path.ts.js +60 -0
- package/esm/core/proxy.ts.js +10 -0
- package/esm/core/reaction.ts.js +116 -0
- package/esm/core/register.ts.js +74 -0
- package/esm/core/schema.ts.js +302 -0
- package/esm/core/validator.ts.js +248 -0
- package/esm/core/widgetTree.ts.js +163 -0
- package/esm/index.ts.js +6 -0
- package/esm/node_modules/@blueking/cli-service/dist/lib/path.js +35 -0
- package/esm/node_modules/@blueking/cli-service/dist/lib/util.js +233 -0
- package/esm/node_modules/@blueking/cli-service/dist/tools/rust/helper/path.js +172 -0
- package/esm/node_modules/ajv/dist/ajv.js +50 -0
- package/esm/node_modules/ajv/dist/compile/codegen/code.js +156 -0
- package/esm/node_modules/ajv/dist/compile/codegen/index.js +697 -0
- package/esm/node_modules/ajv/dist/compile/codegen/scope.js +143 -0
- package/esm/node_modules/ajv/dist/compile/errors.js +123 -0
- package/esm/node_modules/ajv/dist/compile/index.js +242 -0
- package/esm/node_modules/ajv/dist/compile/names.js +28 -0
- package/esm/node_modules/ajv/dist/compile/ref_error.js +12 -0
- package/esm/node_modules/ajv/dist/compile/resolve.js +155 -0
- package/esm/node_modules/ajv/dist/compile/rules.js +26 -0
- package/esm/node_modules/ajv/dist/compile/util.js +178 -0
- package/esm/node_modules/ajv/dist/compile/validate/applicability.js +19 -0
- package/esm/node_modules/ajv/dist/compile/validate/boolSchema.js +50 -0
- package/esm/node_modules/ajv/dist/compile/validate/dataType.js +203 -0
- package/esm/node_modules/ajv/dist/compile/validate/defaults.js +35 -0
- package/esm/node_modules/ajv/dist/compile/validate/index.js +520 -0
- package/esm/node_modules/ajv/dist/compile/validate/keyword.js +124 -0
- package/esm/node_modules/ajv/dist/compile/validate/subschema.js +81 -0
- package/esm/node_modules/ajv/dist/core.js +618 -0
- package/esm/node_modules/ajv/dist/refs/data.json +13 -0
- package/esm/node_modules/ajv/dist/refs/json-schema-draft-07.json +151 -0
- package/esm/node_modules/ajv/dist/runtime/equal.js +7 -0
- package/esm/node_modules/ajv/dist/runtime/ucs2length.js +24 -0
- package/esm/node_modules/ajv/dist/runtime/uri.js +6 -0
- package/esm/node_modules/ajv/dist/runtime/validation_error.js +11 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +49 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +106 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/allOf.js +23 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +12 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/contains.js +95 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +85 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/if.js +66 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/index.js +44 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/items.js +52 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/items2020.js +30 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/not.js +26 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +60 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +75 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +12 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/properties.js +54 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +38 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +13 -0
- package/esm/node_modules/ajv/dist/vocabularies/code.js +131 -0
- package/esm/node_modules/ajv/dist/vocabularies/core/id.js +10 -0
- package/esm/node_modules/ajv/dist/vocabularies/core/index.js +16 -0
- package/esm/node_modules/ajv/dist/vocabularies/core/ref.js +122 -0
- package/esm/node_modules/ajv/dist/vocabularies/discriminator/index.js +104 -0
- package/esm/node_modules/ajv/dist/vocabularies/discriminator/types.js +9 -0
- package/esm/node_modules/ajv/dist/vocabularies/draft7.js +17 -0
- package/esm/node_modules/ajv/dist/vocabularies/format/format.js +92 -0
- package/esm/node_modules/ajv/dist/vocabularies/format/index.js +6 -0
- package/esm/node_modules/ajv/dist/vocabularies/metadata.js +18 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/const.js +25 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/enum.js +48 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/index.js +33 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/limitItems.js +24 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/limitLength.js +27 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +27 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +24 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +26 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/pattern.js +24 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/required.js +79 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +64 -0
- package/esm/node_modules/ajv-formats/dist/formats.js +173 -0
- package/esm/node_modules/ajv-formats/dist/index.js +37 -0
- package/esm/node_modules/ajv-formats/dist/limit.js +69 -0
- package/esm/node_modules/ajv-i18n/localize/zh/index.js +154 -0
- package/esm/node_modules/fast-deep-equal/index.js +46 -0
- package/esm/node_modules/fast-uri/index.js +303 -0
- package/esm/node_modules/fast-uri/lib/schemes.js +188 -0
- package/esm/node_modules/fast-uri/lib/scopedChars.js +30 -0
- package/esm/node_modules/fast-uri/lib/utils.js +244 -0
- package/esm/node_modules/json-schema-traverse/index.js +89 -0
- package/esm/node_modules/semver/classes/comparator.js +143 -0
- package/esm/node_modules/semver/classes/range.js +557 -0
- package/esm/node_modules/semver/classes/semver.js +333 -0
- package/esm/node_modules/semver/functions/clean.js +8 -0
- package/esm/node_modules/semver/functions/cmp.js +54 -0
- package/esm/node_modules/semver/functions/coerce.js +62 -0
- package/esm/node_modules/semver/functions/compare-build.js +9 -0
- package/esm/node_modules/semver/functions/compare-loose.js +5 -0
- package/esm/node_modules/semver/functions/compare.js +7 -0
- package/esm/node_modules/semver/functions/diff.js +60 -0
- package/esm/node_modules/semver/functions/eq.js +5 -0
- package/esm/node_modules/semver/functions/gt.js +5 -0
- package/esm/node_modules/semver/functions/gte.js +5 -0
- package/esm/node_modules/semver/functions/inc.js +21 -0
- package/esm/node_modules/semver/functions/lt.js +5 -0
- package/esm/node_modules/semver/functions/lte.js +5 -0
- package/esm/node_modules/semver/functions/major.js +5 -0
- package/esm/node_modules/semver/functions/minor.js +5 -0
- package/esm/node_modules/semver/functions/neq.js +5 -0
- package/esm/node_modules/semver/functions/parse.js +18 -0
- package/esm/node_modules/semver/functions/patch.js +5 -0
- package/esm/node_modules/semver/functions/prerelease.js +8 -0
- package/esm/node_modules/semver/functions/rcompare.js +5 -0
- package/esm/node_modules/semver/functions/rsort.js +5 -0
- package/esm/node_modules/semver/functions/satisfies.js +12 -0
- package/esm/node_modules/semver/functions/sort.js +5 -0
- package/esm/node_modules/semver/functions/valid.js +8 -0
- package/esm/node_modules/semver/index.js +91 -0
- package/esm/node_modules/semver/internal/constants.js +37 -0
- package/esm/node_modules/semver/internal/debug.js +11 -0
- package/esm/node_modules/semver/internal/identifiers.js +29 -0
- package/esm/node_modules/semver/internal/lrucache.js +42 -0
- package/esm/node_modules/semver/internal/parse-options.js +17 -0
- package/esm/node_modules/semver/internal/re.js +223 -0
- package/esm/node_modules/semver/ranges/gtr.js +6 -0
- package/esm/node_modules/semver/ranges/intersects.js +9 -0
- package/esm/node_modules/semver/ranges/ltr.js +6 -0
- package/esm/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/esm/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/esm/node_modules/semver/ranges/min-version.js +63 -0
- package/esm/node_modules/semver/ranges/outside.js +82 -0
- package/esm/node_modules/semver/ranges/simplify.js +49 -0
- package/esm/node_modules/semver/ranges/subset.js +249 -0
- package/esm/node_modules/semver/ranges/to-comparators.js +10 -0
- package/esm/node_modules/semver/ranges/valid.js +13 -0
- package/esm/util/fetch.ts.js +190 -0
- package/esm/util/index.ts.js +276 -0
- package/package.json +3 -4
- package/dist/main.css +0 -208
- package/dist/main.js +0 -17353
- /package/{dist/svg/iconcool.eb237688.svg → esm/assets/fonts/iconcool.svg} +0 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _object_spread(target) {
|
|
15
|
+
for(var i = 1; i < arguments.length; i++){
|
|
16
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
+
var ownKeys = Object.keys(source);
|
|
18
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
ownKeys.forEach(function(key) {
|
|
24
|
+
_define_property(target, key, source[key]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
function ownKeys(object, enumerableOnly) {
|
|
30
|
+
var keys = Object.keys(object);
|
|
31
|
+
if (Object.getOwnPropertySymbols) {
|
|
32
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
+
if (enumerableOnly) {
|
|
34
|
+
symbols = symbols.filter(function(sym) {
|
|
35
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
keys.push.apply(keys, symbols);
|
|
39
|
+
}
|
|
40
|
+
return keys;
|
|
41
|
+
}
|
|
42
|
+
function _object_spread_props(target, source) {
|
|
43
|
+
source = source != null ? source : {};
|
|
44
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
45
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
46
|
+
} else {
|
|
47
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
48
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
import { defineComponent, h } from 'vue';
|
|
54
|
+
import register from '../../core/register.ts.js';
|
|
55
|
+
import { mergeDeep } from '../../util/index.ts.js';
|
|
56
|
+
import Schema from '../../core/schema.ts.js';
|
|
57
|
+
import Path from '../../core/path.ts.js';
|
|
58
|
+
import props from '../field/FieldProps.ts.js';
|
|
59
|
+
import SchemaField from '../field/SchemaField.tsx.js';
|
|
60
|
+
import widgetTree from '../../core/widgetTree.ts.js';
|
|
61
|
+
// @todo widgetTree添加单行node,内置导入、导出功能
|
|
62
|
+
// 获取表格单行默认值
|
|
63
|
+
const getRowDefaultData = (properties = {})=>{
|
|
64
|
+
const keys = Object.keys(properties);
|
|
65
|
+
const data = {};
|
|
66
|
+
keys.forEach((key)=>{
|
|
67
|
+
data[key] = Schema.getSchemaDefaultValue(properties[key]);
|
|
68
|
+
});
|
|
69
|
+
return [
|
|
70
|
+
data
|
|
71
|
+
];
|
|
72
|
+
};
|
|
73
|
+
export default defineComponent({
|
|
74
|
+
name: 'TableWidget',
|
|
75
|
+
props: _object_spread_props(_object_spread({}, props), {
|
|
76
|
+
// 当前值
|
|
77
|
+
modelValue: {
|
|
78
|
+
type: Array
|
|
79
|
+
}
|
|
80
|
+
}),
|
|
81
|
+
watch: {
|
|
82
|
+
modelValue: {
|
|
83
|
+
immediate: true,
|
|
84
|
+
handler () {
|
|
85
|
+
var _this_modelValue;
|
|
86
|
+
(_this_modelValue = this.modelValue) === null || _this_modelValue === void 0 ? void 0 : _this_modelValue.forEach((_, index)=>{
|
|
87
|
+
const path = `${this.path}.${index}`;
|
|
88
|
+
// 销毁上一次的缓存
|
|
89
|
+
widgetTree.removeWidgetNode(path, null);
|
|
90
|
+
// 重新当前行的父节点
|
|
91
|
+
widgetTree.addWidgetNode(path, null, 'group');
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
methods: {
|
|
97
|
+
// 单元格表单编辑
|
|
98
|
+
handleCellValChange ({ path, value }) {
|
|
99
|
+
const subPath = Path.getSubPath(this.path, path);
|
|
100
|
+
const newValue = Path.setPathValue(this.modelValue, subPath, value);
|
|
101
|
+
this.$emit('update:modelValue', newValue);
|
|
102
|
+
},
|
|
103
|
+
// 新增
|
|
104
|
+
handleAddRow (index) {
|
|
105
|
+
var _this_schema_uiprops, _this_modelValue, _this_$props_schema_items;
|
|
106
|
+
if ((_this_schema_uiprops = this.schema['ui:props']) === null || _this_schema_uiprops === void 0 ? void 0 : _this_schema_uiprops.disabled) return;
|
|
107
|
+
const newValue = ((_this_modelValue = this.modelValue) === null || _this_modelValue === void 0 ? void 0 : _this_modelValue.slice(0)) || [];
|
|
108
|
+
newValue.splice(index + 1, 0, ...getRowDefaultData((_this_$props_schema_items = this.$props.schema.items) === null || _this_$props_schema_items === void 0 ? void 0 : _this_$props_schema_items.properties));
|
|
109
|
+
this.$emit('update:modelValue', newValue);
|
|
110
|
+
},
|
|
111
|
+
// 删除
|
|
112
|
+
handleDelRow (index) {
|
|
113
|
+
var _this_schema_uiprops, _this_modelValue;
|
|
114
|
+
if ((_this_schema_uiprops = this.schema['ui:props']) === null || _this_schema_uiprops === void 0 ? void 0 : _this_schema_uiprops.disabled) return;
|
|
115
|
+
const newValue = ((_this_modelValue = this.modelValue) === null || _this_modelValue === void 0 ? void 0 : _this_modelValue.slice(0)) || [];
|
|
116
|
+
newValue.splice(index, 1);
|
|
117
|
+
this.$emit('update:modelValue', newValue);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
render () {
|
|
121
|
+
const self = this;
|
|
122
|
+
const { schema, path, modelValue } = this;
|
|
123
|
+
const schemaItems = schema.items;
|
|
124
|
+
let properties = {};
|
|
125
|
+
if (schemaItems === null || schemaItems === void 0 ? void 0 : schemaItems.properties) {
|
|
126
|
+
properties = schemaItems === null || schemaItems === void 0 ? void 0 : schemaItems.properties;
|
|
127
|
+
} else {
|
|
128
|
+
// table类型目前只支持items的类型为对象的schema
|
|
129
|
+
console.warn('The current schema type is not supported table component', schemaItems);
|
|
130
|
+
}
|
|
131
|
+
const uiOptions = Schema.getUiOptions(schema);
|
|
132
|
+
const getTableColumns = ()=>{
|
|
133
|
+
const columnList = Object.keys(properties).map((field)=>{
|
|
134
|
+
const colField = properties[field];
|
|
135
|
+
// 仅支持基础数据类型的属性配置,render-header、sort-method、formatter等Function类型的属性不属于json支持的数据类型,配置将不会生效
|
|
136
|
+
const colProps = colField['ui:props'] || {};
|
|
137
|
+
return _object_spread_props(_object_spread({}, colProps), {
|
|
138
|
+
label: colField === null || colField === void 0 ? void 0 : colField.title,
|
|
139
|
+
field,
|
|
140
|
+
render: ({ row, index })=>h(SchemaField, _object_spread_props(_object_spread({}, this.$props), {
|
|
141
|
+
schema: mergeDeep(colField, {
|
|
142
|
+
'ui:props': {
|
|
143
|
+
// 默认不展示标题
|
|
144
|
+
showTitle: false,
|
|
145
|
+
// 0.1 兼容formItem设置 labelWidth 0 不生效问题
|
|
146
|
+
labelWidth: 0.1
|
|
147
|
+
}
|
|
148
|
+
}),
|
|
149
|
+
path: Path.getCurPath(path, `${index}.${field}`),
|
|
150
|
+
modelValue: row[field],
|
|
151
|
+
'onUpdate:modelValue' (data) {
|
|
152
|
+
self.handleCellValChange(data);
|
|
153
|
+
}
|
|
154
|
+
}))
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
if (!this.readonly && uiOptions.modifyRows !== false) {
|
|
158
|
+
columnList.push({
|
|
159
|
+
label: '操作',
|
|
160
|
+
width: 100,
|
|
161
|
+
fixed: 'right',
|
|
162
|
+
render: ({ index })=>{
|
|
163
|
+
var _schema_uiprops;
|
|
164
|
+
return h('div', {
|
|
165
|
+
class: {
|
|
166
|
+
'table-widget-actions': true,
|
|
167
|
+
'is-disabled': (_schema_uiprops = schema['ui:props']) === null || _schema_uiprops === void 0 ? void 0 : _schema_uiprops.disabled
|
|
168
|
+
}
|
|
169
|
+
}, {
|
|
170
|
+
default: ()=>[
|
|
171
|
+
h('i', {
|
|
172
|
+
class: 'bk-form-icon icon-plus-line action-btn',
|
|
173
|
+
onClick () {
|
|
174
|
+
self.handleAddRow(index);
|
|
175
|
+
}
|
|
176
|
+
}),
|
|
177
|
+
h('i', {
|
|
178
|
+
class: 'bk-form-icon icon-minus-line action-btn',
|
|
179
|
+
onClick () {
|
|
180
|
+
self.handleDelRow(index);
|
|
181
|
+
}
|
|
182
|
+
})
|
|
183
|
+
]
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return columnList;
|
|
189
|
+
};
|
|
190
|
+
return h(register.getBaseWidget('table'), _object_spread_props(_object_spread({}, schema['ui:component'] || {}), {
|
|
191
|
+
data: modelValue,
|
|
192
|
+
columns: getTableColumns()
|
|
193
|
+
}), {
|
|
194
|
+
empty: ()=>this.readonly || uiOptions.modifyRows === false ? null : h('div', {
|
|
195
|
+
style: {
|
|
196
|
+
color: '#3a84ff',
|
|
197
|
+
cursor: 'pointer'
|
|
198
|
+
},
|
|
199
|
+
onClick: ()=>{
|
|
200
|
+
self.handleAddRow(0);
|
|
201
|
+
}
|
|
202
|
+
}, '点击添加数据')
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
});
|