@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.
Files changed (168) hide show
  1. package/esm/adapter/common/FieldGroupWrap.tsx.js +199 -0
  2. package/esm/adapter/field/ArrayField.tsx.js +55 -0
  3. package/esm/adapter/field/BooleanField.tsx.js +41 -0
  4. package/esm/adapter/field/CompositionField.tsx.js +113 -0
  5. package/esm/adapter/field/FieldProps.ts.js +85 -0
  6. package/esm/adapter/field/NumberField.tsx.js +19 -0
  7. package/esm/adapter/field/ObjectField.tsx.js +58 -0
  8. package/esm/adapter/field/SchemaField.tsx.js +28 -0
  9. package/esm/adapter/field/StringField.tsx.js +4 -0
  10. package/esm/adapter/widget/ArrayWidget.ts.js +196 -0
  11. package/esm/adapter/widget/ButtonWidget.ts.js +76 -0
  12. package/esm/adapter/widget/CheckboxWidget.ts.js +101 -0
  13. package/esm/adapter/widget/CollapseGroupWidget.ts.js +140 -0
  14. package/esm/adapter/widget/ColorPickerWidget.ts.js +71 -0
  15. package/esm/adapter/widget/InputWidget.ts.js +79 -0
  16. package/esm/adapter/widget/KeyValueArrayWidget.tsx.js +156 -0
  17. package/esm/adapter/widget/RadioWidget.ts.js +98 -0
  18. package/esm/adapter/widget/SelectWidget.ts.js +98 -0
  19. package/esm/adapter/widget/SwitchWidget.ts.js +73 -0
  20. package/esm/adapter/widget/TabGroupWidget.ts.js +145 -0
  21. package/esm/adapter/widget/TableWidget.ts.js +205 -0
  22. package/esm/adapter/widget/Widget.ts.js +497 -0
  23. package/esm/assets/fonts/iconcool.eot +0 -0
  24. package/esm/assets/fonts/iconcool.ttf +0 -0
  25. package/esm/assets/fonts/iconcool.woff +0 -0
  26. package/esm/assets/style.css +43 -0
  27. package/esm/controller/form.css +164 -0
  28. package/esm/controller/form.tsx.js +159 -0
  29. package/esm/controller/props.ts.js +75 -0
  30. package/esm/core/events.ts.js +74 -0
  31. package/esm/core/expression.ts.js +67 -0
  32. package/esm/core/lang.ts.js +25 -0
  33. package/esm/core/layout.ts.js +149 -0
  34. package/esm/core/path.ts.js +60 -0
  35. package/esm/core/proxy.ts.js +10 -0
  36. package/esm/core/reaction.ts.js +116 -0
  37. package/esm/core/register.ts.js +74 -0
  38. package/esm/core/schema.ts.js +302 -0
  39. package/esm/core/validator.ts.js +248 -0
  40. package/esm/core/widgetTree.ts.js +163 -0
  41. package/esm/index.ts.js +6 -0
  42. package/esm/node_modules/@blueking/cli-service/dist/lib/path.js +35 -0
  43. package/esm/node_modules/@blueking/cli-service/dist/lib/util.js +233 -0
  44. package/esm/node_modules/@blueking/cli-service/dist/tools/rust/helper/path.js +172 -0
  45. package/esm/node_modules/ajv/dist/ajv.js +50 -0
  46. package/esm/node_modules/ajv/dist/compile/codegen/code.js +156 -0
  47. package/esm/node_modules/ajv/dist/compile/codegen/index.js +697 -0
  48. package/esm/node_modules/ajv/dist/compile/codegen/scope.js +143 -0
  49. package/esm/node_modules/ajv/dist/compile/errors.js +123 -0
  50. package/esm/node_modules/ajv/dist/compile/index.js +242 -0
  51. package/esm/node_modules/ajv/dist/compile/names.js +28 -0
  52. package/esm/node_modules/ajv/dist/compile/ref_error.js +12 -0
  53. package/esm/node_modules/ajv/dist/compile/resolve.js +155 -0
  54. package/esm/node_modules/ajv/dist/compile/rules.js +26 -0
  55. package/esm/node_modules/ajv/dist/compile/util.js +178 -0
  56. package/esm/node_modules/ajv/dist/compile/validate/applicability.js +19 -0
  57. package/esm/node_modules/ajv/dist/compile/validate/boolSchema.js +50 -0
  58. package/esm/node_modules/ajv/dist/compile/validate/dataType.js +203 -0
  59. package/esm/node_modules/ajv/dist/compile/validate/defaults.js +35 -0
  60. package/esm/node_modules/ajv/dist/compile/validate/index.js +520 -0
  61. package/esm/node_modules/ajv/dist/compile/validate/keyword.js +124 -0
  62. package/esm/node_modules/ajv/dist/compile/validate/subschema.js +81 -0
  63. package/esm/node_modules/ajv/dist/core.js +618 -0
  64. package/esm/node_modules/ajv/dist/refs/data.json +13 -0
  65. package/esm/node_modules/ajv/dist/refs/json-schema-draft-07.json +151 -0
  66. package/esm/node_modules/ajv/dist/runtime/equal.js +7 -0
  67. package/esm/node_modules/ajv/dist/runtime/ucs2length.js +24 -0
  68. package/esm/node_modules/ajv/dist/runtime/uri.js +6 -0
  69. package/esm/node_modules/ajv/dist/runtime/validation_error.js +11 -0
  70. package/esm/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +49 -0
  71. package/esm/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +106 -0
  72. package/esm/node_modules/ajv/dist/vocabularies/applicator/allOf.js +23 -0
  73. package/esm/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +12 -0
  74. package/esm/node_modules/ajv/dist/vocabularies/applicator/contains.js +95 -0
  75. package/esm/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +85 -0
  76. package/esm/node_modules/ajv/dist/vocabularies/applicator/if.js +66 -0
  77. package/esm/node_modules/ajv/dist/vocabularies/applicator/index.js +44 -0
  78. package/esm/node_modules/ajv/dist/vocabularies/applicator/items.js +52 -0
  79. package/esm/node_modules/ajv/dist/vocabularies/applicator/items2020.js +30 -0
  80. package/esm/node_modules/ajv/dist/vocabularies/applicator/not.js +26 -0
  81. package/esm/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +60 -0
  82. package/esm/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +75 -0
  83. package/esm/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +12 -0
  84. package/esm/node_modules/ajv/dist/vocabularies/applicator/properties.js +54 -0
  85. package/esm/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +38 -0
  86. package/esm/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +13 -0
  87. package/esm/node_modules/ajv/dist/vocabularies/code.js +131 -0
  88. package/esm/node_modules/ajv/dist/vocabularies/core/id.js +10 -0
  89. package/esm/node_modules/ajv/dist/vocabularies/core/index.js +16 -0
  90. package/esm/node_modules/ajv/dist/vocabularies/core/ref.js +122 -0
  91. package/esm/node_modules/ajv/dist/vocabularies/discriminator/index.js +104 -0
  92. package/esm/node_modules/ajv/dist/vocabularies/discriminator/types.js +9 -0
  93. package/esm/node_modules/ajv/dist/vocabularies/draft7.js +17 -0
  94. package/esm/node_modules/ajv/dist/vocabularies/format/format.js +92 -0
  95. package/esm/node_modules/ajv/dist/vocabularies/format/index.js +6 -0
  96. package/esm/node_modules/ajv/dist/vocabularies/metadata.js +18 -0
  97. package/esm/node_modules/ajv/dist/vocabularies/validation/const.js +25 -0
  98. package/esm/node_modules/ajv/dist/vocabularies/validation/enum.js +48 -0
  99. package/esm/node_modules/ajv/dist/vocabularies/validation/index.js +33 -0
  100. package/esm/node_modules/ajv/dist/vocabularies/validation/limitItems.js +24 -0
  101. package/esm/node_modules/ajv/dist/vocabularies/validation/limitLength.js +27 -0
  102. package/esm/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +27 -0
  103. package/esm/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +24 -0
  104. package/esm/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +26 -0
  105. package/esm/node_modules/ajv/dist/vocabularies/validation/pattern.js +24 -0
  106. package/esm/node_modules/ajv/dist/vocabularies/validation/required.js +79 -0
  107. package/esm/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +64 -0
  108. package/esm/node_modules/ajv-formats/dist/formats.js +173 -0
  109. package/esm/node_modules/ajv-formats/dist/index.js +37 -0
  110. package/esm/node_modules/ajv-formats/dist/limit.js +69 -0
  111. package/esm/node_modules/ajv-i18n/localize/zh/index.js +154 -0
  112. package/esm/node_modules/fast-deep-equal/index.js +46 -0
  113. package/esm/node_modules/fast-uri/index.js +303 -0
  114. package/esm/node_modules/fast-uri/lib/schemes.js +188 -0
  115. package/esm/node_modules/fast-uri/lib/scopedChars.js +30 -0
  116. package/esm/node_modules/fast-uri/lib/utils.js +244 -0
  117. package/esm/node_modules/json-schema-traverse/index.js +89 -0
  118. package/esm/node_modules/semver/classes/comparator.js +143 -0
  119. package/esm/node_modules/semver/classes/range.js +557 -0
  120. package/esm/node_modules/semver/classes/semver.js +333 -0
  121. package/esm/node_modules/semver/functions/clean.js +8 -0
  122. package/esm/node_modules/semver/functions/cmp.js +54 -0
  123. package/esm/node_modules/semver/functions/coerce.js +62 -0
  124. package/esm/node_modules/semver/functions/compare-build.js +9 -0
  125. package/esm/node_modules/semver/functions/compare-loose.js +5 -0
  126. package/esm/node_modules/semver/functions/compare.js +7 -0
  127. package/esm/node_modules/semver/functions/diff.js +60 -0
  128. package/esm/node_modules/semver/functions/eq.js +5 -0
  129. package/esm/node_modules/semver/functions/gt.js +5 -0
  130. package/esm/node_modules/semver/functions/gte.js +5 -0
  131. package/esm/node_modules/semver/functions/inc.js +21 -0
  132. package/esm/node_modules/semver/functions/lt.js +5 -0
  133. package/esm/node_modules/semver/functions/lte.js +5 -0
  134. package/esm/node_modules/semver/functions/major.js +5 -0
  135. package/esm/node_modules/semver/functions/minor.js +5 -0
  136. package/esm/node_modules/semver/functions/neq.js +5 -0
  137. package/esm/node_modules/semver/functions/parse.js +18 -0
  138. package/esm/node_modules/semver/functions/patch.js +5 -0
  139. package/esm/node_modules/semver/functions/prerelease.js +8 -0
  140. package/esm/node_modules/semver/functions/rcompare.js +5 -0
  141. package/esm/node_modules/semver/functions/rsort.js +5 -0
  142. package/esm/node_modules/semver/functions/satisfies.js +12 -0
  143. package/esm/node_modules/semver/functions/sort.js +5 -0
  144. package/esm/node_modules/semver/functions/valid.js +8 -0
  145. package/esm/node_modules/semver/index.js +91 -0
  146. package/esm/node_modules/semver/internal/constants.js +37 -0
  147. package/esm/node_modules/semver/internal/debug.js +11 -0
  148. package/esm/node_modules/semver/internal/identifiers.js +29 -0
  149. package/esm/node_modules/semver/internal/lrucache.js +42 -0
  150. package/esm/node_modules/semver/internal/parse-options.js +17 -0
  151. package/esm/node_modules/semver/internal/re.js +223 -0
  152. package/esm/node_modules/semver/ranges/gtr.js +6 -0
  153. package/esm/node_modules/semver/ranges/intersects.js +9 -0
  154. package/esm/node_modules/semver/ranges/ltr.js +6 -0
  155. package/esm/node_modules/semver/ranges/max-satisfying.js +27 -0
  156. package/esm/node_modules/semver/ranges/min-satisfying.js +26 -0
  157. package/esm/node_modules/semver/ranges/min-version.js +63 -0
  158. package/esm/node_modules/semver/ranges/outside.js +82 -0
  159. package/esm/node_modules/semver/ranges/simplify.js +49 -0
  160. package/esm/node_modules/semver/ranges/subset.js +249 -0
  161. package/esm/node_modules/semver/ranges/to-comparators.js +10 -0
  162. package/esm/node_modules/semver/ranges/valid.js +13 -0
  163. package/esm/util/fetch.ts.js +190 -0
  164. package/esm/util/index.ts.js +276 -0
  165. package/package.json +3 -4
  166. package/dist/main.css +0 -208
  167. package/dist/main.js +0 -17353
  168. /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
+ });