bkui-vue 0.0.1-beta.126 → 0.0.1-beta.129

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/index.esm.js CHANGED
@@ -12335,6 +12335,56 @@ function autoUpdate(reference2, floating, update, options) {
12335
12335
  const computePosition = (reference2, floating, options) => computePosition$1(reference2, floating, __spreadValues({
12336
12336
  platform
12337
12337
  }, options));
12338
+ var usePlatform = () => {
12339
+ const getElementRects = ({
12340
+ reference: reference2,
12341
+ floating
12342
+ }) => {
12343
+ const refRect = reference2.getBoundingClientRect();
12344
+ const floatRect = floating.getBoundingClientRect();
12345
+ return {
12346
+ reference: {
12347
+ width: refRect.width,
12348
+ height: refRect.height,
12349
+ x: refRect.x,
12350
+ y: refRect.y
12351
+ },
12352
+ floating: {
12353
+ width: floatRect.width,
12354
+ height: floatRect.height,
12355
+ x: floatRect.x,
12356
+ y: floatRect.y
12357
+ }
12358
+ };
12359
+ };
12360
+ const getDimensions2 = (element) => {
12361
+ const {
12362
+ width,
12363
+ height
12364
+ } = element.getBoundingClientRect();
12365
+ return {
12366
+ width,
12367
+ height
12368
+ };
12369
+ };
12370
+ const getClippingRect2 = ({}) => {
12371
+ const {
12372
+ width,
12373
+ height
12374
+ } = document.fullscreenElement.getBoundingClientRect();
12375
+ return {
12376
+ width,
12377
+ height,
12378
+ x: 0,
12379
+ y: 0
12380
+ };
12381
+ };
12382
+ return {
12383
+ getElementRects,
12384
+ getDimensions: getDimensions2,
12385
+ getClippingRect: getClippingRect2
12386
+ };
12387
+ };
12338
12388
  var useFloating = (props, ctx, refReference, refContent, refArrow, refRoot) => {
12339
12389
  const localIsShow = ref(false);
12340
12390
  const isElementFullScreen = () => {
@@ -12390,6 +12440,20 @@ var useFloating = (props, ctx, refReference, refContent, refArrow, refRoot) => {
12390
12440
  if (isHideMiddlewareAvailable()) {
12391
12441
  options.middleware.push(hide());
12392
12442
  }
12443
+ if (isElementFullScreen()) {
12444
+ const {
12445
+ getElementRects,
12446
+ getDimensions: getDimensions2,
12447
+ getClippingRect: getClippingRect2
12448
+ } = usePlatform();
12449
+ Object.assign(options, {
12450
+ platform: {
12451
+ getElementRects,
12452
+ getDimensions: getDimensions2,
12453
+ getClippingRect: getClippingRect2
12454
+ }
12455
+ });
12456
+ }
12393
12457
  return options;
12394
12458
  };
12395
12459
  const resolveTargetElement = (target) => {
@@ -13172,7 +13236,7 @@ const radioButtonProps = {
13172
13236
  modelValue: PropTypes.oneOfType([String, Number, Boolean]).def(""),
13173
13237
  checked: PropTypes.bool.def(false),
13174
13238
  disabled: PropTypes.bool.def(false),
13175
- size: PropTypes.size
13239
+ size: PropTypes.size()
13176
13240
  };
13177
13241
  var RadioButton = defineComponent({
13178
13242
  name: "RadioButton",
@@ -15235,6 +15299,11 @@ const TABLE_ROW_ATTRIBUTE = {
15235
15299
  ROW_EXPAND: "__row_expand"
15236
15300
  };
15237
15301
  const SCROLLY_WIDTH = 4;
15302
+ const SETTING_SIZE = {
15303
+ large: 56,
15304
+ default: 40,
15305
+ small: 32
15306
+ };
15238
15307
  const resolvePaginationOption = (propPagination, defVal) => {
15239
15308
  if (!!propPagination) {
15240
15309
  if (typeof propPagination === "object") {
@@ -15402,7 +15471,20 @@ const tableProps = {
15402
15471
  pagination: PropTypes.oneOfType([PropTypes.bool.def(false), PropTypes.object.def({})]).def(false),
15403
15472
  remotePagination: PropTypes.bool.def(false),
15404
15473
  emptyText: PropTypes.string.def("\u6682\u65E0\u6570\u636E"),
15405
- settings: PropTypes.oneOfType([PropTypes.any, PropTypes.bool]).def(false),
15474
+ settings: PropTypes.oneOfType([
15475
+ PropTypes.shape({
15476
+ fields: PropTypes.arrayOf(PropTypes.shape({
15477
+ label: PropTypes.string,
15478
+ field: PropTypes.string,
15479
+ disabled: PropTypes.bool
15480
+ })),
15481
+ checked: PropTypes.arrayOf(PropTypes.string),
15482
+ limit: PropTypes.number.def(0),
15483
+ size: PropTypes.size(["small", "default", "large"]).def("default"),
15484
+ sizeList: PropTypes.shape([])
15485
+ }),
15486
+ PropTypes.bool
15487
+ ]).def(false),
15406
15488
  rowClass: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]).def({}),
15407
15489
  rowStyle: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]).def({}),
15408
15490
  cellStyle: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]).def({}),
@@ -15883,13 +15965,18 @@ var BodyEmpty = defineComponent({
15883
15965
  }
15884
15966
  });
15885
15967
  const resolvePropVal = (prop, key2, args) => {
15886
- if (Object.prototype.hasOwnProperty.call(prop, key2)) {
15887
- if (typeof prop[key2] === "function") {
15888
- return prop[key2].call(globalThis, ...args);
15968
+ if (typeof key2 === "string") {
15969
+ if (Object.prototype.hasOwnProperty.call(prop, key2)) {
15970
+ if (typeof prop[key2] === "function") {
15971
+ return prop[key2].call(globalThis, ...args);
15972
+ }
15973
+ return prop[key2];
15889
15974
  }
15890
- return prop[key2];
15975
+ return void 0;
15976
+ }
15977
+ if (Array.isArray(key2)) {
15978
+ return key2.map((_key) => resolvePropVal(prop, _key, args)).filter((val) => val !== void 0).at(0);
15891
15979
  }
15892
- return void 0;
15893
15980
  };
15894
15981
  const resolveNumberToNumArray = (prop) => {
15895
15982
  if (/^\d+$/.test(`${prop}`)) {
@@ -16249,7 +16336,17 @@ function _isSlot$1(s2) {
16249
16336
  var Settings = defineComponent({
16250
16337
  name: "Settings",
16251
16338
  props: {
16252
- settings: PropTypes.oneOfType([PropTypes.any, PropTypes.bool]).def(false),
16339
+ settings: PropTypes.oneOfType([PropTypes.shape({
16340
+ fields: PropTypes.arrayOf(PropTypes.shape({
16341
+ label: PropTypes.string,
16342
+ field: PropTypes.string,
16343
+ disabled: PropTypes.bool
16344
+ })),
16345
+ checked: PropTypes.arrayOf(PropTypes.string),
16346
+ limit: PropTypes.number.def(0),
16347
+ size: PropTypes.size(["small", "default", "large"]).def("default"),
16348
+ sizeList: PropTypes.shape([])
16349
+ }), PropTypes.bool]).def(false),
16253
16350
  columns: PropTypes.array.def([]),
16254
16351
  rowHeight: PropTypes.number.def(40)
16255
16352
  },
@@ -16257,11 +16354,11 @@ var Settings = defineComponent({
16257
16354
  setup(props, {
16258
16355
  emit
16259
16356
  }) {
16260
- var _a, _b, _c;
16357
+ var _a;
16261
16358
  const defaultSizeList = [{
16262
16359
  value: "small",
16263
16360
  label: "\u5C0F",
16264
- height: 32
16361
+ height: SETTING_SIZE.small
16265
16362
  }, {
16266
16363
  value: "default",
16267
16364
  label: "\u4E2D",
@@ -16269,16 +16366,29 @@ var Settings = defineComponent({
16269
16366
  }, {
16270
16367
  value: "large",
16271
16368
  label: "\u5927",
16272
- height: 56
16369
+ height: SETTING_SIZE.large
16273
16370
  }];
16274
16371
  const checkAll = ref(false);
16275
16372
  const isShow = ref(false);
16276
- const settings = props.settings;
16277
- const activeSize = ref((_a = settings.size) != null ? _a : "default");
16373
+ const localSettings = typeof props.settings === "boolean" ? ref({
16374
+ fields: props.columns.map((col) => __spreadProps(__spreadValues({}, col), {
16375
+ field: col.field || col.type
16376
+ })),
16377
+ checked: [],
16378
+ limit: 0,
16379
+ size: "default",
16380
+ sizeList: defaultSizeList
16381
+ }) : ref(props.settings);
16382
+ const activeSize = ref(localSettings.value.size || "default");
16278
16383
  const activeHeight = ref(props.rowHeight);
16279
- const checkedFields = ref((_b = settings.checked) != null ? _b : []);
16384
+ const checkedFields = ref(localSettings.value.checked);
16280
16385
  const className = resolveClassName("table-settings");
16281
16386
  const theme = `light ${className}`;
16387
+ const cachedValue = {
16388
+ checkAll: checkAll.value,
16389
+ activeSize: activeSize.value,
16390
+ activeHeight: activeHeight.value
16391
+ };
16282
16392
  const handleSaveClick = () => {
16283
16393
  emit("change", {
16284
16394
  checked: checkedFields.value,
@@ -16288,13 +16398,18 @@ var Settings = defineComponent({
16288
16398
  isShow.value = false;
16289
16399
  };
16290
16400
  const handleCancelClick = () => {
16291
- var _a2;
16292
- activeSize.value = "default";
16293
- activeHeight.value = props.rowHeight;
16294
- checkedFields.value = (_a2 = settings.checked) != null ? _a2 : [];
16401
+ checkAll.value = cachedValue.checkAll;
16402
+ activeSize.value = cachedValue.activeSize;
16403
+ activeHeight.value = cachedValue.activeHeight;
16404
+ checkedFields.value = localSettings.value.checked || [];
16295
16405
  isShow.value = false;
16296
16406
  };
16297
16407
  const handleSettingClick = () => {
16408
+ Object.assign(cachedValue, {
16409
+ checkAll: checkAll.value,
16410
+ activeSize: activeSize.value,
16411
+ activeHeight: activeHeight.value
16412
+ });
16298
16413
  isShow.value = true;
16299
16414
  };
16300
16415
  const handleCheckAllClick = (e) => {
@@ -16302,21 +16417,20 @@ var Settings = defineComponent({
16302
16417
  e.stopPropagation();
16303
16418
  e.preventDefault();
16304
16419
  checkAll.value = !checkAll.value;
16420
+ const fields = localSettings.value.fields || props.columns || [];
16305
16421
  if (checkAll.value) {
16306
- checkedFields.value = (settings.fields || props.columns || []).map((item, index) => resolvePropVal(item, "field", [item, index]));
16422
+ checkedFields.value = fields.map((item, index) => resolvePropVal(item, "field", [item, index]));
16307
16423
  } else {
16308
- checkedFields.value.splice(0, checkedFields.value.length);
16424
+ const readonlyFields = fields.filter((item) => item.disabled).map((item, index) => resolvePropVal(item, "field", [item, index]));
16425
+ checkedFields.value.splice(0, checkedFields.value.length, ...readonlyFields);
16309
16426
  }
16310
16427
  };
16311
16428
  const isLimit = computed(() => {
16312
16429
  var _a2;
16313
- return ((_a2 = settings.limit) != null ? _a2 : 0) > 0;
16314
- });
16315
- const sizeList = (_c = settings.sizeList) != null ? _c : defaultSizeList;
16316
- const isFiledDisabled = computed(() => {
16317
- var _a2;
16318
- return isLimit.value && ((_a2 = settings.limit) != null ? _a2 : 0) <= checkedFields.value.length;
16430
+ return ((_a2 = localSettings.value.limit) != null ? _a2 : 0) > 0;
16319
16431
  });
16432
+ const sizeList = (_a = localSettings.value.sizeList) != null ? _a : defaultSizeList;
16433
+ const isFiledDisabled = computed(() => isLimit.value && (localSettings.value.limit ? localSettings.value.limit : 0) <= checkedFields.value.length);
16320
16434
  const isItemReadonly = (item, index) => item.disabled || isFiledDisabled.value && !checkedFields.value.includes(resolvePropVal(item, "field", [item, index]));
16321
16435
  const handleSizeItemClick = (item) => {
16322
16436
  activeSize.value = item.value;
@@ -16334,8 +16448,26 @@ var Settings = defineComponent({
16334
16448
  "class": getItemClass(item),
16335
16449
  "onClick": () => handleSizeItemClick(item)
16336
16450
  }, [item.label]));
16337
- const renderFields = computed(() => settings.fields || props.columns || []);
16338
- return () => createVNode(BkPopover2, mergeProps({
16451
+ const renderFields = computed(() => localSettings.value.fields || props.columns || []);
16452
+ const indeterminate = computed(() => checkedFields.value.length > 0 && !renderFields.value.every((field, index) => checkedFields.value.includes(resolvePropVal(field, "field", [field, index]))));
16453
+ watch(() => [checkedFields.value], () => {
16454
+ if (!checkedFields.value.length) {
16455
+ checkAll.value = false;
16456
+ }
16457
+ if (checkedFields.value.length && renderFields.value.every((field, index) => checkedFields.value.includes(resolvePropVal(field, "field", [field, index])))) {
16458
+ checkAll.value = true;
16459
+ }
16460
+ }, {
16461
+ immediate: true,
16462
+ deep: true
16463
+ });
16464
+ watch(() => [props.settings.checked], () => {
16465
+ checkedFields.value.splice(0, checkedFields.value.length, ...localSettings.value.checked);
16466
+ }, {
16467
+ immediate: true,
16468
+ deep: true
16469
+ });
16470
+ return () => props.settings ? createVNode(BkPopover2, mergeProps({
16339
16471
  "trigger": "manual",
16340
16472
  "isShow": isShow.value,
16341
16473
  "placement": "bottom-end",
@@ -16368,12 +16500,13 @@ var Settings = defineComponent({
16368
16500
  "class": "field-setting-label"
16369
16501
  }, [createTextVNode("\u5B57\u6BB5\u663E\u793A\u8BBE\u7F6E")]), isLimit.value ? createVNode("span", {
16370
16502
  "class": "limit"
16371
- }, [createTextVNode("\uFF08\u6700\u591A"), settings.limit, createTextVNode("\u9879\uFF09")]) : ""]), isLimit.value ? "" : createVNode("span", {
16503
+ }, [createTextVNode("\uFF08\u6700\u591A"), localSettings.value.limit, createTextVNode("\u9879\uFF09")]) : ""]), isLimit.value ? "" : createVNode("span", {
16372
16504
  "class": "check-all",
16373
16505
  "onClick": handleCheckAllClick
16374
16506
  }, [createVNode(BkCheckbox, {
16375
16507
  "label": "\u5168\u9009",
16376
- "modelValue": checkAll.value
16508
+ "indeterminate": Boolean(indeterminate.value),
16509
+ "modelValue": checkedFields.value.length > 0
16377
16510
  }, {
16378
16511
  default: () => [createTextVNode("\u5168\u9009")]
16379
16512
  })])]), createVNode(BkCheckboxGroup, {
@@ -16386,6 +16519,7 @@ var Settings = defineComponent({
16386
16519
  "class": "field-item"
16387
16520
  }, [createVNode(BkCheckbox, {
16388
16521
  "label": resolvePropVal(item, "field", [item, index]),
16522
+ "checked": checkedFields.value.includes(resolvePropVal(item, "field", [item, index])),
16389
16523
  "disabled": isItemReadonly(item, index)
16390
16524
  }, _isSlot$1(_slot = resolvePropVal(item, "label", [item, index])) ? _slot : {
16391
16525
  default: () => [_slot]
@@ -16409,7 +16543,7 @@ var Settings = defineComponent({
16409
16543
  default: () => [createTextVNode("\u53D6\u6D88")]
16410
16544
  })])]);
16411
16545
  }
16412
- });
16546
+ }) : "";
16413
16547
  }
16414
16548
  });
16415
16549
  var useFixedColumn = (props, colgroups, hasScrollY) => {
@@ -16529,14 +16663,14 @@ class TableRender {
16529
16663
  this.reactiveProp.setting.height = height;
16530
16664
  if (checked.length) {
16531
16665
  this.colgroups.forEach((col) => {
16532
- col.isHidden = !(checked != null ? checked : []).includes(resolvePropVal(col, "field", [col]));
16666
+ col.isHidden = !(checked != null ? checked : []).includes(resolvePropVal(col, ["field", "type"], [col]));
16533
16667
  });
16534
16668
  }
16535
16669
  this.emitEvent(EVENTS$1.ON_SETTING_CHANGE, [arg]);
16536
16670
  };
16537
16671
  return [this.props.settings ? createVNode(Settings, {
16538
16672
  "class": "table-head-settings",
16539
- "settings": this.props.settings,
16673
+ "settings": this.reactiveProp.settings,
16540
16674
  "columns": this.props.columns,
16541
16675
  "rowHeight": this.props.rowHeight,
16542
16676
  "onChange": handleSettingsChanged
@@ -17015,7 +17149,8 @@ const useClass = (props, root, reactiveProp, pageData) => {
17015
17149
  "has-scroll-y": hasScrollY.value || props.virtualEnabled
17016
17150
  }, resolvePropBorderToClassStr(props.border)));
17017
17151
  const headClass = classes({
17018
- [resolveClassName("table-head")]: true
17152
+ [resolveClassName("table-head")]: true,
17153
+ "has-settings": !!props.settings
17019
17154
  });
17020
17155
  const config = resolveHeadConfig(props);
17021
17156
  const headStyle = computed(() => ({
@@ -17113,10 +17248,11 @@ const useClass = (props, root, reactiveProp, pageData) => {
17113
17248
  };
17114
17249
  };
17115
17250
  const useInit = (props) => {
17251
+ var _a, _b;
17116
17252
  const colgroups = reactive([]);
17117
17253
  const updateColGroups = () => {
17118
- var _a;
17119
- colgroups.splice(0, colgroups.length, ...((_a = props.columns) != null ? _a : []).map((col) => __spreadProps(__spreadValues({}, col), {
17254
+ var _a2;
17255
+ colgroups.splice(0, colgroups.length, ...((_a2 = props.columns) != null ? _a2 : []).map((col) => __spreadProps(__spreadValues({}, col), {
17120
17256
  calcWidth: null,
17121
17257
  resizeWidth: null,
17122
17258
  listeners: /* @__PURE__ */ new Map()
@@ -17135,23 +17271,24 @@ const useInit = (props) => {
17135
17271
  bottom: 1
17136
17272
  },
17137
17273
  activeColumns,
17274
+ settings: props.settings,
17138
17275
  setting: {
17139
- size: null,
17140
- height: null
17276
+ size: (_a = props.settings) == null ? void 0 : _a.size,
17277
+ height: SETTING_SIZE[(_b = props.settings) == null ? void 0 : _b.size]
17141
17278
  }
17142
17279
  });
17143
17280
  const isRowExpand = (rowId) => {
17144
- var _a;
17281
+ var _a2;
17145
17282
  if (reactiveSchema.rowActions.has(rowId)) {
17146
- return (_a = reactiveSchema.rowActions.get(rowId)) == null ? void 0 : _a.isExpand;
17283
+ return (_a2 = reactiveSchema.rowActions.get(rowId)) == null ? void 0 : _a2.isExpand;
17147
17284
  }
17148
17285
  return false;
17149
17286
  };
17150
17287
  const setRowExpand = (row, expand = void 0) => {
17151
- var _a;
17288
+ var _a2;
17152
17289
  const rowId = row[TABLE_ROW_ATTRIBUTE.ROW_UID];
17153
17290
  const isExpand = typeof expand === "boolean" ? expand : !isRowExpand(rowId);
17154
- reactiveSchema.rowActions.set(rowId, Object.assign({}, (_a = reactiveSchema.rowActions.get(rowId)) != null ? _a : {}, { isExpand }));
17291
+ reactiveSchema.rowActions.set(rowId, Object.assign({}, (_a2 = reactiveSchema.rowActions.get(rowId)) != null ? _a2 : {}, { isExpand }));
17155
17292
  updateIndexData();
17156
17293
  };
17157
17294
  const indexData = reactive([]);
@@ -24290,8 +24427,14 @@ var useNodeAction = (props, ctx, flatData, _renderData, schemaValues, initOption
24290
24427
  updateParentChecked(item, value);
24291
24428
  ctx.emit(EVENTS.NODE_CHECKED, schemaValues.value.filter((t2) => isNodeChecked(t2)).map((n2) => n2[NODE_ATTRIBUTES.UUID]));
24292
24429
  };
24293
- const isIndeterminate = (item) => isNodeChecked(item) && !schemaValues.value.filter((node) => String.prototype.startsWith.call(getNodePath(node), getNodePath(item))).every((filterNode) => isNodeChecked(filterNode));
24294
- const isNodeItemChecked = (item) => isNodeChecked(item) || schemaValues.value.filter((node) => String.prototype.startsWith.call(getNodePath(node), getNodePath(item))).some((filterNode) => isNodeChecked(filterNode));
24430
+ const isIndeterminate = (item) => isNodeChecked(item) && !schemaValues.value.filter((node) => {
24431
+ var _a;
24432
+ return (_a = getNodePath(node)) == null ? void 0 : _a.startsWith(getNodePath(item));
24433
+ }).every((filterNode) => isNodeChecked(filterNode));
24434
+ const isNodeItemChecked = (item) => isNodeChecked(item) || schemaValues.value.filter((node) => {
24435
+ var _a;
24436
+ return (_a = getNodePath(node)) == null ? void 0 : _a.startsWith(getNodePath(item));
24437
+ }).some((filterNode) => isNodeChecked(filterNode));
24295
24438
  const getCheckboxRender = (item) => {
24296
24439
  if (!props.showCheckbox) {
24297
24440
  return null;
@@ -24762,7 +24905,10 @@ var useTreeInit = (props) => {
24762
24905
  flatten(treeData ? treeData : data2);
24763
24906
  if (props2.showCheckbox) {
24764
24907
  checkedList == null ? void 0 : checkedList.forEach((value) => {
24765
- Array.from(schema.values()).filter((t2) => t2[NODE_ATTRIBUTES.PATH].startsWith(schema.get(value)[NODE_ATTRIBUTES.PATH])).forEach((n2) => Object.assign(n2, {
24908
+ Array.from(schema.values()).filter((t2) => {
24909
+ var _a2;
24910
+ return (_a2 = t2[NODE_ATTRIBUTES.PATH]) == null ? void 0 : _a2.startsWith(schema.get(value)[NODE_ATTRIBUTES.PATH]);
24911
+ }).forEach((n2) => Object.assign(n2, {
24766
24912
  [NODE_ATTRIBUTES.IS_CHECKED]: true
24767
24913
  }));
24768
24914
  loopUpdateNodeAttr(value, NODE_ATTRIBUTES.IS_CHECKED, true, () => true);
@@ -24922,7 +25068,10 @@ var Component$5 = defineComponent({
24922
25068
  }
24923
25069
  const filterFn = (item) => {
24924
25070
  if (isSearchActive.value) {
24925
- const treeUiFilter = () => isTreeUI ? schemaValues.value.some((schema) => schema[NODE_ATTRIBUTES.PATH].startsWith(getNodePath(item)) && schema[NODE_ATTRIBUTES.IS_MATCH]) : false;
25071
+ const treeUiFilter = () => isTreeUI ? schemaValues.value.some((schema) => {
25072
+ var _a;
25073
+ return ((_a = schema[NODE_ATTRIBUTES.PATH]) == null ? void 0 : _a.startsWith(getNodePath(item))) && schema[NODE_ATTRIBUTES.IS_MATCH];
25074
+ }) : false;
24926
25075
  return getNodeAttr2(item, NODE_ATTRIBUTES.IS_MATCH) || treeUiFilter();
24927
25076
  }
24928
25077
  return true;