@blueking/bkui-form 0.0.43 → 0.0.45

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.
@@ -1826,6 +1826,7 @@
1826
1826
  crtInstance = _ref.instance; // 当前组件实例,用来条件表达式判断
1827
1827
  var _ref2 = widgetTree.widgetMap[targetPath] || {},
1828
1828
  operateInstance = _ref2.instance; // 需要执行操作的组件实例,可能为其他组件也可能为当前组件
1829
+ if (!crtInstance || !operateInstance) return;
1829
1830
  var fullfill = true;
1830
1831
  var deps = [];
1831
1832
  if (reaction.source) {
@@ -9975,6 +9976,11 @@
9975
9976
  setState: function setState(key, value) {
9976
9977
  if (Reflect.has(this.state, key)) {
9977
9978
  this.state[key] = value;
9979
+ // state变化
9980
+ this.$emit('state-change', {
9981
+ path: this.path,
9982
+ state: this.state
9983
+ });
9978
9984
  } else if (key === 'value') {
9979
9985
  // 特殊处理value设置
9980
9986
  this.$emit('input', {
@@ -10256,7 +10262,9 @@
10256
10262
  'ui:component': {
10257
10263
  props: {
10258
10264
  type: 'number',
10259
- min: ((_ctx$props$schema = ctx.props.schema) === null || _ctx$props$schema === void 0 ? void 0 : _ctx$props$schema.type) === 'integer' ? 0 : -Infinity
10265
+ min: ((_ctx$props$schema = ctx.props.schema) === null || _ctx$props$schema === void 0 ? void 0 : _ctx$props$schema.type) === 'integer' ? 0 : -Infinity,
10266
+ allowNumberPaste: true,
10267
+ allowNumberCopy: true
10260
10268
  }
10261
10269
  }
10262
10270
  }, ctx.props.schema)
@@ -11135,14 +11143,98 @@
11135
11143
 
11136
11144
  function _extends(){return _extends=Object.assign?Object.assign.bind():function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}var normalMerge=["attrs","props","domProps"],toArrayMerge=["class","style","directives"],functionalMerge=["on","nativeOn"],mergeJsxProps=function(a){return a.reduce(function(c,a){for(var b in a)if(!c[b])c[b]=a[b];else if(-1!==normalMerge.indexOf(b))c[b]=_extends({},c[b],a[b]);else if(-1!==toArrayMerge.indexOf(b)){var d=c[b]instanceof Array?c[b]:[c[b]],e=a[b]instanceof Array?a[b]:[a[b]];c[b]=[].concat(d,e);}else if(-1!==functionalMerge.indexOf(b)){for(var f in a[b])if(c[b][f]){var g=c[b][f]instanceof Array?c[b][f]:[c[b][f]],h=a[b][f]instanceof Array?a[b][f]:[a[b][f]];c[b][f]=[].concat(g,h);}else c[b][f]=a[b][f];}else if("hook"===b)for(var i in a[b])c[b][i]=c[b][i]?mergeFn(c[b][i],a[b][i]):a[b][i];else c[b]=a[b];return c},{})},mergeFn=function(a,b){return function(){a&&a.apply(this,arguments),b&&b.apply(this,arguments);}};var helper=mergeJsxProps;
11137
11145
 
11146
+ var CommonGroupWrap = Vue__default["default"].extend({
11147
+ name: 'CommonFieldGroupWrap',
11148
+ inject: ['widgetTree'],
11149
+ props: _objectSpread2(_objectSpread2({}, props), {}, {
11150
+ // 组类型
11151
+ type: {
11152
+ type: String,
11153
+ default: 'default',
11154
+ validator: function validator(value) {
11155
+ return ['default', 'normal', 'card'].includes(value);
11156
+ }
11157
+ },
11158
+ // 是否显示组title
11159
+ showTitle: {
11160
+ type: Boolean,
11161
+ default: false
11162
+ },
11163
+ // 是否显示border
11164
+ border: {
11165
+ type: Boolean,
11166
+ default: false
11167
+ },
11168
+ verifiable: {
11169
+ type: Boolean,
11170
+ default: false
11171
+ },
11172
+ hideEmptyRow: {
11173
+ type: Boolean,
11174
+ default: false
11175
+ },
11176
+ description: {
11177
+ type: String,
11178
+ default: ''
11179
+ },
11180
+ tag: {
11181
+ type: String,
11182
+ default: 'div'
11183
+ }
11184
+ }),
11185
+ data: function data() {
11186
+ return {
11187
+ state: {
11188
+ // 组类型目前只支持visible
11189
+ visible: true
11190
+ }
11191
+ };
11192
+ },
11193
+ created: function created() {
11194
+ // 注册widget TreeNode
11195
+ this.widgetTree.addWidgetNode(this.path, this, 'group');
11196
+ },
11197
+ mounted: function mounted() {
11198
+ // 更新样式
11199
+ this.$forceUpdate();
11200
+ },
11201
+ beforeDestroy: function beforeDestroy() {
11202
+ this.widgetTree.removeWidgetNode(this.path, this);
11203
+ },
11204
+ methods: {
11205
+ setState: function setState(key, value) {
11206
+ if (Reflect.has(this.state, key)) {
11207
+ this.state[key] = value;
11208
+ } else {
11209
+ console.warn("Group unsupported ".concat(key, " state, please check"));
11210
+ }
11211
+ }
11212
+ },
11213
+ render: function render(h) {
11214
+ var _this$layout;
11215
+ var groupContentStyle = _objectSpread2({}, (_this$layout = this.layout) === null || _this$layout === void 0 ? void 0 : _this$layout.container);
11216
+ return h(this.tag, {
11217
+ style: groupContentStyle
11218
+ }, [this.$slots.default]);
11219
+ }
11220
+ });
11221
+
11138
11222
  // 伪数组类型
11139
11223
  var KeyValueArrayWidget = Vue__default["default"].extend({
11140
11224
  name: 'KeyValueArrayWidget',
11141
11225
  props: _objectSpread2({}, props),
11226
+ data: function data() {
11227
+ return {
11228
+ columns: {},
11229
+ showTableHead: false
11230
+ };
11231
+ },
11142
11232
  mounted: function mounted() {
11143
11233
  var _this$value;
11144
11234
  var _this$schema$minItems = this.schema.minItems,
11145
11235
  minItems = _this$schema$minItems === void 0 ? 0 : _this$schema$minItems;
11236
+ var uiOptions = Schema.getUiOptions(this.schema);
11237
+ this.showTableHead = !!uiOptions.showTableHead;
11146
11238
  // 补全minItems项
11147
11239
  if (((_this$value = this.value) === null || _this$value === void 0 ? void 0 : _this$value.length) < minItems) {
11148
11240
  var data = Schema.getSchemaDefaultValue(this.schema.items);
@@ -11184,16 +11276,23 @@
11184
11276
  cursor: this.disabled ? 'not-allowed' : 'pointer',
11185
11277
  display: 'inline-block'
11186
11278
  };
11279
+ var theadStyle = {
11280
+ display: this.showTableHead ? '' : 'none'
11281
+ };
11282
+ var thStyle = {
11283
+ fontSize: '14px',
11284
+ textAlign: 'left',
11285
+ fontWeight: 'normal',
11286
+ color: '#63656E',
11287
+ paddingLeft: '10px',
11288
+ paddingRight: '10px'
11289
+ };
11290
+ var tdStyle = {
11291
+ paddingLeft: '10px',
11292
+ paddingRight: '10px'
11293
+ };
11187
11294
  var properties = (_this$schema = this.schema) === null || _this$schema === void 0 ? void 0 : (_this$schema$items = _this$schema.items) === null || _this$schema$items === void 0 ? void 0 : _this$schema$items.properties;
11188
11295
  var props = orderProperties(Object.keys(properties || {}), (_this$schema2 = this.schema) === null || _this$schema2 === void 0 ? void 0 : (_this$schema2$items = _this$schema2.items) === null || _this$schema2$items === void 0 ? void 0 : _this$schema2$items['ui:order']);
11189
- // props为空时,表示只有一个项
11190
- var keysLen = Object.keys(properties || {}).length;
11191
- var defaultCols = properties ? new Array(keysLen).fill('1fr').concat('20px').join(' ') : '1fr 20px';
11192
- var defaultContainerLayout = _objectSpread2({}, this.layout.container || {
11193
- display: 'grid',
11194
- gridGap: '20px',
11195
- 'grid-template-columns': defaultCols // 默认配置
11196
- });
11197
11296
  var self = this;
11198
11297
  var dealSchema = function dealSchema(schema) {
11199
11298
  return (
@@ -11229,6 +11328,11 @@
11229
11328
  on: {
11230
11329
  input: function input(data) {
11231
11330
  self.handleInput(data);
11331
+ },
11332
+ 'state-change': function stateChange(_ref2) {
11333
+ var path = _ref2.path,
11334
+ state = _ref2.state;
11335
+ _this.$set(_this.columns, path, state);
11232
11336
  }
11233
11337
  },
11234
11338
  style: {
@@ -11236,37 +11340,53 @@
11236
11340
  }
11237
11341
  });
11238
11342
  };
11239
- return h("div", [(_this$value2 = this.value) === null || _this$value2 === void 0 ? void 0 : _this$value2.map(function (_, index) {
11240
- var _this$schema4;
11343
+ return h("table", [h("thead", {
11344
+ "style": theadStyle
11345
+ }, [h("tr", [props === null || props === void 0 ? void 0 : props.map(function (prop) {
11346
+ var _this$schema3, _this$schema3$items, _this$columns$path;
11347
+ var schemaItem = (_this$schema3 = _this.schema) === null || _this$schema3 === void 0 ? void 0 : (_this$schema3$items = _this$schema3.items) === null || _this$schema3$items === void 0 ? void 0 : _this$schema3$items.properties[prop];
11348
+ var path = Path.getCurPath(_this.path, "0.".concat(prop));
11349
+ return h("th", {
11350
+ "style": _objectSpread2(_objectSpread2({}, thStyle), {}, {
11351
+ display: ((_this$columns$path = _this.columns[path]) === null || _this$columns$path === void 0 ? void 0 : _this$columns$path.visible) === false ? 'none' : ''
11352
+ })
11353
+ }, [schemaItem === null || schemaItem === void 0 ? void 0 : schemaItem.title]);
11354
+ }), h("th")])]), h("tbody", [(_this$value2 = this.value) === null || _this$value2 === void 0 ? void 0 : _this$value2.map(function (_, index) {
11355
+ var _this$schema5;
11241
11356
  var groupPath = Path.getCurPath(_this.path, "".concat(index));
11242
- return h(FieldGroupWrap, helper([{}, {
11357
+ return h(CommonGroupWrap, helper([{}, {
11243
11358
  "props": _objectSpread2(_objectSpread2({}, _this.$props), {}, {
11244
11359
  path: groupPath,
11245
11360
  value: Path.getPathVal(_this.rootData, groupPath),
11246
11361
  schema: _this.schema.items,
11247
- layout: _objectSpread2(_objectSpread2({}, _this.layout), {}, {
11248
- container: _objectSpread2({}, defaultContainerLayout)
11249
- })
11362
+ tag: 'tr',
11363
+ layout: _objectSpread2({}, _this.layout)
11250
11364
  })
11251
11365
  }]), [props !== null && props !== void 0 && props.length ? props.map(function (prop) {
11252
- var _this$schema3, _this$schema3$items;
11253
- var schemaItem = (_this$schema3 = _this.schema) === null || _this$schema3 === void 0 ? void 0 : (_this$schema3$items = _this$schema3.items) === null || _this$schema3$items === void 0 ? void 0 : _this$schema3$items.properties[prop];
11366
+ var _this$schema4, _this$schema4$items, _this$columns$curPath;
11367
+ var schemaItem = (_this$schema4 = _this.schema) === null || _this$schema4 === void 0 ? void 0 : (_this$schema4$items = _this$schema4.items) === null || _this$schema4$items === void 0 ? void 0 : _this$schema4$items.properties[prop];
11254
11368
  var curPath = Path.getCurPath(_this.path, "".concat(index, ".").concat(prop));
11255
11369
  var lastProp = curPath.split('.').pop();
11256
11370
  var layoutConfig = Layout.findLayoutByProp(lastProp, _this.layout.group || []) || {};
11257
- return renderSchemaField({
11371
+ return h("td", {
11372
+ "style": _objectSpread2(_objectSpread2({}, tdStyle), {}, {
11373
+ display: ((_this$columns$curPath = _this.columns[curPath]) === null || _this$columns$curPath === void 0 ? void 0 : _this$columns$curPath.visible) === false ? 'none' : ''
11374
+ })
11375
+ }, [renderSchemaField({
11258
11376
  path: curPath,
11259
11377
  schema: dealSchema(schemaItem),
11260
11378
  layout: layoutConfig,
11261
11379
  required: Schema.isRequired(schemaItem, prop)
11262
- });
11263
- }) : renderSchemaField({
11380
+ })]);
11381
+ }) : h("td", [renderSchemaField({
11264
11382
  path: Path.getCurPath(_this.path, index),
11265
- schema: dealSchema(((_this$schema4 = _this.schema) === null || _this$schema4 === void 0 ? void 0 : _this$schema4.items) || {}),
11383
+ schema: dealSchema(((_this$schema5 = _this.schema) === null || _this$schema5 === void 0 ? void 0 : _this$schema5.items) || {}),
11266
11384
  layout: {},
11267
11385
  required: false
11268
- }), h("span", {
11269
- "style": labelBtnStyle,
11386
+ })]), h("td", [h("span", {
11387
+ "style": _objectSpread2(_objectSpread2({}, labelBtnStyle), {}, {
11388
+ marginBottom: '10px'
11389
+ }),
11270
11390
  "on": {
11271
11391
  "click": function click() {
11272
11392
  return _this.handleRemoveItem(index);
@@ -11274,7 +11394,7 @@
11274
11394
  }
11275
11395
  }, [h("i", {
11276
11396
  "class": "bk-icon icon-minus-line"
11277
- })])]);
11397
+ })])])]);
11278
11398
  }), h("span", {
11279
11399
  "on": {
11280
11400
  "click": this.handleAddItem
@@ -11282,7 +11402,7 @@
11282
11402
  "style": labelBtnStyle
11283
11403
  }, [h("i", {
11284
11404
  "class": "bk-icon icon-plus-line"
11285
- })])]);
11405
+ })])])]);
11286
11406
  }
11287
11407
  });
11288
11408