lew-ui 1.8.15 → 1.8.16

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.es.js CHANGED
@@ -3403,7 +3403,7 @@ const _hoisted_7$4 = {
3403
3403
  "stroke-linejoin": "miter"
3404
3404
  };
3405
3405
  const _hoisted_8$4 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ createElementVNode("path", { d: "m16 39.513 15.556-15.557L16 8.4" }, null, -1));
3406
- const _hoisted_9$3 = [
3406
+ const _hoisted_9$4 = [
3407
3407
  _hoisted_8$4
3408
3408
  ];
3409
3409
  const _sfc_main$A = defineComponent({
@@ -3424,7 +3424,7 @@ const _sfc_main$A = defineComponent({
3424
3424
  }, toDisplayString(item.label), 11, _hoisted_2$o),
3425
3425
  index2 != _ctx.options.length - 1 ? (openBlock(), createElementBlock("div", _hoisted_3$f, [
3426
3426
  _ctx.iconType === "sprit" ? (openBlock(), createElementBlock("svg", _hoisted_4$d, _hoisted_6$5)) : createCommentVNode("v-if", true),
3427
- _ctx.iconType === "shoulder" ? (openBlock(), createElementBlock("svg", _hoisted_7$4, _hoisted_9$3)) : createCommentVNode("v-if", true)
3427
+ _ctx.iconType === "shoulder" ? (openBlock(), createElementBlock("svg", _hoisted_7$4, _hoisted_9$4)) : createCommentVNode("v-if", true)
3428
3428
  ])) : createCommentVNode("v-if", true)
3429
3429
  ], 2);
3430
3430
  }), 128))
@@ -3675,7 +3675,7 @@ const _hoisted_8$3 = {
3675
3675
  key: 1,
3676
3676
  class: "lew-input-suffix-icon"
3677
3677
  };
3678
- const _hoisted_9$2 = {
3678
+ const _hoisted_9$3 = {
3679
3679
  key: 2,
3680
3680
  class: "lew-input-suffix-select"
3681
3681
  };
@@ -3938,7 +3938,7 @@ const _sfc_main$y = defineComponent({
3938
3938
  type: unref(suffixValue)
3939
3939
  }, null, 8, ["size", "type"])
3940
3940
  ])) : createCommentVNode("v-if", true),
3941
- _ctx.suffix === "select" ? (openBlock(), createElementBlock("div", _hoisted_9$2, [
3941
+ _ctx.suffix === "select" ? (openBlock(), createElementBlock("div", _hoisted_9$3, [
3942
3942
  createVNode(unref(LewDropdown), {
3943
3943
  placement: "bottom",
3944
3944
  trigger: "click",
@@ -13825,7 +13825,7 @@ const _hoisted_5$4 = { class: "lew-date-box" };
13825
13825
  const _hoisted_6$3 = { class: "lew-date-num" };
13826
13826
  const _hoisted_7$2 = ["onClick"];
13827
13827
  const _hoisted_8$2 = { class: "lew-date-label" };
13828
- const _hoisted_9$1 = {
13828
+ const _hoisted_9$2 = {
13829
13829
  key: 0,
13830
13830
  class: "lew-date-item-today"
13831
13831
  };
@@ -13963,7 +13963,7 @@ const _sfc_main$n = defineComponent({
13963
13963
  onClick: ($event) => selectDateFn(item)
13964
13964
  }, [
13965
13965
  createElementVNode("div", _hoisted_8$2, [
13966
- unref(checkToday)(item) ? (openBlock(), createElementBlock("i", _hoisted_9$1)) : createCommentVNode("v-if", true),
13966
+ unref(checkToday)(item) ? (openBlock(), createElementBlock("i", _hoisted_9$2)) : createCommentVNode("v-if", true),
13967
13967
  createElementVNode("div", _hoisted_10$1, toDisplayString(item.showDate), 1)
13968
13968
  ])
13969
13969
  ], 10, _hoisted_7$2);
@@ -13983,7 +13983,7 @@ const _hoisted_5$3 = { class: "lew-date-control-right" };
13983
13983
  const _hoisted_6$2 = { class: "lew-date-box" };
13984
13984
  const _hoisted_7$1 = { class: "lew-date-num" };
13985
13985
  const _hoisted_8$1 = ["onClick", "onMouseenter"];
13986
- const _hoisted_9 = {
13986
+ const _hoisted_9$1 = {
13987
13987
  key: 0,
13988
13988
  class: "lew-date-item-today"
13989
13989
  };
@@ -14307,7 +14307,7 @@ const _sfc_main$m = defineComponent({
14307
14307
  createElementVNode("div", {
14308
14308
  class: normalizeClass(["lew-date-label", unref(object2class2)("rangeSelected", item)])
14309
14309
  }, [
14310
- unref(object2class2)("today", item) ? (openBlock(), createElementBlock("div", _hoisted_9)) : createCommentVNode("v-if", true),
14310
+ unref(object2class2)("today", item) ? (openBlock(), createElementBlock("div", _hoisted_9$1)) : createCommentVNode("v-if", true),
14311
14311
  createElementVNode("div", {
14312
14312
  class: normalizeClass(["lew-date-value", unref(object2class2)("selected", item)])
14313
14313
  }, toDisplayString(item.showDate), 3)
@@ -14655,11 +14655,6 @@ const _sfc_main$k = defineComponent({
14655
14655
  });
14656
14656
  var LewDateRangePicker = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__scopeId", "data-v-8717ea06"], ["__file", "C:/Users/div/Documents/GitHub/lew-ui/lib/components/date-picker/src/LewDateRangePicker.vue"]]);
14657
14657
  const tableProps = {
14658
- selectedKey: {
14659
- type: Array,
14660
- default: [],
14661
- description: "\u9009\u4E2D\u7684key"
14662
- },
14663
14658
  rowKey: {
14664
14659
  type: String,
14665
14660
  default: "id",
@@ -14688,25 +14683,29 @@ const tableProps = {
14688
14683
  checkable: {
14689
14684
  type: Boolean,
14690
14685
  default: false,
14691
- description: "\u662F\u5426\u663E\u793A\u9009\u62E9\u6846"
14686
+ description: "\u662F\u5426\u663E\u793A\u590D\u9009\u6846"
14687
+ },
14688
+ singleSelect: {
14689
+ type: Boolean,
14690
+ default: false,
14691
+ description: "\u662F\u5426\u5355\u9009"
14692
14692
  }
14693
14693
  };
14694
14694
  var LewTable_vue_vue_type_style_index_0_lang = "";
14695
14695
  const _hoisted_1$g = { class: "lew-table-tr" };
14696
- const _hoisted_2$b = { class: "lew-table-main" };
14697
- const _hoisted_3$6 = { class: "lew-table-tr" };
14696
+ const _hoisted_2$b = { key: 1 };
14697
+ const _hoisted_3$6 = { class: "lew-table-main" };
14698
14698
  const _hoisted_4$4 = { class: "lew-table-tr" };
14699
- const _hoisted_5$1 = ["onMouseenter"];
14700
- const _hoisted_6 = { class: "lew-table-main" };
14701
- const _hoisted_7 = ["onMouseenter"];
14702
- const _hoisted_8 = ["onMouseenter"];
14699
+ const _hoisted_5$1 = { class: "lew-table-tr" };
14700
+ const _hoisted_6 = ["onClick", "onMouseenter"];
14701
+ const _hoisted_7 = { class: "lew-table-main" };
14702
+ const _hoisted_8 = ["onClick", "onMouseenter"];
14703
+ const _hoisted_9 = ["onMouseenter"];
14703
14704
  const _sfc_main$j = defineComponent({
14704
14705
  __name: "LewTable",
14705
14706
  props: tableProps,
14706
- emits: ["update:selectedKey"],
14707
- setup(__props, { emit }) {
14707
+ setup(__props, { expose: __expose }) {
14708
14708
  const props = __props;
14709
- const selectedKey = useVModel(props, "selectedKey", emit);
14710
14709
  const tableRef = ref();
14711
14710
  let obs;
14712
14711
  const state = reactive({
@@ -14715,8 +14714,8 @@ const _sfc_main$j = defineComponent({
14715
14714
  scrollbarVisible: false,
14716
14715
  scrollClientWidth: 0,
14717
14716
  hidScrollLine: "all",
14718
- checkList: [],
14719
- checkAll: false
14717
+ checkAll: false,
14718
+ selectedKeysMap: {}
14720
14719
  });
14721
14720
  onActivated(() => {
14722
14721
  checkScroll();
@@ -14755,7 +14754,7 @@ const _sfc_main$j = defineComponent({
14755
14754
  if (!table)
14756
14755
  return;
14757
14756
  let clientWidth = 0;
14758
- props.columns.map((e) => e.width).forEach((w) => {
14757
+ props.columns.map((e2) => e2.width).forEach((w) => {
14759
14758
  clientWidth += w;
14760
14759
  });
14761
14760
  if (props.checkable) {
@@ -14767,7 +14766,7 @@ const _sfc_main$j = defineComponent({
14767
14766
  }, 200);
14768
14767
  const getTdNotWidth = computed(() => {
14769
14768
  let totalWidth = 0;
14770
- const countWidth = props.columns.filter((e) => !!e.width).length;
14769
+ const countWidth = props.columns.filter((e2) => !!e2.width).length;
14771
14770
  props.columns.forEach((item) => {
14772
14771
  if (item.width !== void 0) {
14773
14772
  totalWidth += item.width;
@@ -14800,52 +14799,54 @@ const _sfc_main$j = defineComponent({
14800
14799
  return width;
14801
14800
  });
14802
14801
  const newColumns = computed(() => {
14803
- return props.columns.filter((e) => !e.fixed);
14802
+ return props.columns.filter((e2) => !e2.fixed);
14804
14803
  });
14805
14804
  const fixedColumns = computed(() => (direction) => {
14806
- return props.columns.filter((e) => e.fixed === direction);
14805
+ return props.columns.filter((e2) => e2.fixed === direction);
14807
14806
  });
14808
14807
  const setAllChecked = (checked) => {
14809
14808
  if (checked) {
14810
- selectedKey.value = props.dataSource.map(
14811
- (e) => props.rowKey && e[props.rowKey]
14809
+ state.selectedKeysMap = _.mapValues(
14810
+ _.keyBy(props.dataSource, props.rowKey),
14811
+ () => true
14812
14812
  );
14813
14813
  } else {
14814
- selectedKey.value = [];
14814
+ state.selectedKeysMap = _.mapValues(
14815
+ _.keyBy(props.dataSource, props.rowKey),
14816
+ () => false
14817
+ );
14815
14818
  }
14816
14819
  };
14817
- const setChecked = (key, checked) => {
14818
- if (checked) {
14819
- selectedKey.value.push(key);
14820
- } else {
14821
- const index2 = props.selectedKey.findIndex((e) => e === key);
14822
- if (index2 >= 0) {
14823
- selectedKey.value.splice(index2, 1);
14824
- }
14825
- }
14826
- initCheckAll();
14820
+ const setSelectedKeys = (keys) => {
14821
+ state.selectedKeysMap = {};
14822
+ keys.forEach((key) => {
14823
+ state.selectedKeysMap[key] = true;
14824
+ });
14825
+ checkIsAll();
14827
14826
  };
14828
- const initCheckAll = () => {
14829
- const isAll = selectedKey.value.length > 0 && selectedKey.value.length === props.dataSource.length;
14830
- if (isAll) {
14831
- state.checkAll = true;
14827
+ const checkIsAll = () => {
14828
+ const filteredKeys = _.keys(
14829
+ _.pickBy(state.selectedKeysMap, (value) => value === true)
14830
+ );
14831
+ const dataKey = props.dataSource.map((e2) => String(e2[props.rowKey]));
14832
+ const diffArr = _.difference(dataKey, filteredKeys);
14833
+ state.checkAll = _.isEmpty(diffArr);
14834
+ };
14835
+ const getSelectedKeys = () => {
14836
+ return _.keys(_.pickBy(state.selectedKeysMap, (value) => value === true));
14837
+ };
14838
+ const selectTr = (row) => {
14839
+ if (props.singleSelect) {
14840
+ state.selectedKeysMap = {};
14841
+ }
14842
+ if (state.selectedKeysMap[row[props.rowKey]]) {
14843
+ state.selectedKeysMap[row[props.rowKey]] = false;
14832
14844
  } else {
14833
- state.checkAll = false;
14845
+ state.selectedKeysMap[row[props.rowKey]] = true;
14834
14846
  }
14847
+ checkIsAll();
14835
14848
  };
14836
- const initCheckbox = () => {
14837
- state.checkList = props.dataSource.map((item) => {
14838
- if (props.rowKey && selectedKey.value.includes(item[props.rowKey])) {
14839
- return true;
14840
- }
14841
- return false;
14842
- });
14843
- };
14844
- initCheckbox();
14845
- watchArray(selectedKey, () => {
14846
- initCheckbox();
14847
- initCheckAll();
14848
- });
14849
+ __expose({ setSelectedKeys, getSelectedKeys });
14849
14850
  onMounted(() => {
14850
14851
  tableObserve();
14851
14852
  checkScroll();
@@ -14861,8 +14862,9 @@ const _sfc_main$j = defineComponent({
14861
14862
  const _component_lew_empty = resolveComponent("lew-empty");
14862
14863
  return openBlock(), createElementBlock("div", {
14863
14864
  class: normalizeClass(["lew-table-wrapper", {
14864
- "hide-line-left": !unref(state).scrollbarVisible || ["all", "left"].includes(unref(state).hidScrollLine) || _ctx.columns.filter((e) => e.fixed === "left").length > 0,
14865
- "hide-line-right": !unref(state).scrollbarVisible || ["all", "right"].includes(unref(state).hidScrollLine) || _ctx.columns.filter((e) => e.fixed === "right").length > 0
14865
+ "lew-table-checkable": props.checkable,
14866
+ "hide-line-left": !unref(state).scrollbarVisible || ["all", "left"].includes(unref(state).hidScrollLine) || _ctx.columns.filter((e2) => e2.fixed === "left").length > 0,
14867
+ "hide-line-right": !unref(state).scrollbarVisible || ["all", "right"].includes(unref(state).hidScrollLine) || _ctx.columns.filter((e2) => e2.fixed === "right").length > 0
14866
14868
  }])
14867
14869
  }, [
14868
14870
  createElementVNode("div", {
@@ -14890,15 +14892,17 @@ const _sfc_main$j = defineComponent({
14890
14892
  _ctx.checkable && unref(fixedColumns)("left").length > 0 ? (openBlock(), createBlock(unref(LewFlex), {
14891
14893
  key: 0,
14892
14894
  style: { "width": "50px" },
14895
+ class: "lew-table-td",
14893
14896
  x: "center"
14894
14897
  }, {
14895
14898
  default: withCtx(() => [
14896
- createVNode(unref(LewCheckbox), {
14899
+ !_ctx.singleSelect ? (openBlock(), createBlock(unref(LewCheckbox), {
14900
+ key: 0,
14897
14901
  disabled: _ctx.dataSource.length === 0,
14898
14902
  modelValue: unref(state).checkAll,
14899
14903
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(state).checkAll = $event),
14900
14904
  onChange: _cache[1] || (_cache[1] = ($event) => setAllChecked($event))
14901
- }, null, 8, ["disabled", "modelValue"])
14905
+ }, null, 8, ["disabled", "modelValue"])) : (openBlock(), createElementBlock("span", _hoisted_2$b, "\u5355\u9009"))
14902
14906
  ]),
14903
14907
  _: 1
14904
14908
  })) : createCommentVNode("v-if", true),
@@ -14918,19 +14922,21 @@ const _sfc_main$j = defineComponent({
14918
14922
  }), 128))
14919
14923
  ])
14920
14924
  ], 2)) : createCommentVNode("v-if", true),
14921
- createElementVNode("div", _hoisted_2$b, [
14922
- createElementVNode("div", _hoisted_3$6, [
14925
+ createElementVNode("div", _hoisted_3$6, [
14926
+ createElementVNode("div", _hoisted_4$4, [
14923
14927
  _ctx.checkable && unref(fixedColumns)("left").length === 0 ? (openBlock(), createBlock(unref(LewFlex), {
14924
14928
  key: 0,
14925
14929
  style: { "width": "50px" },
14926
14930
  x: "center"
14927
14931
  }, {
14928
14932
  default: withCtx(() => [
14929
- createVNode(unref(LewCheckbox), {
14933
+ !_ctx.singleSelect ? (openBlock(), createBlock(unref(LewCheckbox), {
14934
+ key: 0,
14935
+ disabled: _ctx.dataSource.length === 0,
14930
14936
  modelValue: unref(state).checkAll,
14931
14937
  "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => unref(state).checkAll = $event),
14932
14938
  onChange: _cache[3] || (_cache[3] = ($event) => setAllChecked($event))
14933
- }, null, 8, ["modelValue"])
14939
+ }, null, 8, ["disabled", "modelValue"])) : createCommentVNode("v-if", true)
14934
14940
  ]),
14935
14941
  _: 1
14936
14942
  })) : createCommentVNode("v-if", true),
@@ -14958,7 +14964,7 @@ const _sfc_main$j = defineComponent({
14958
14964
  )
14959
14965
  }])
14960
14966
  }, [
14961
- createElementVNode("div", _hoisted_4$4, [
14967
+ createElementVNode("div", _hoisted_5$1, [
14962
14968
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(fixedColumns)("right"), (column, index2) => {
14963
14969
  return openBlock(), createBlock(unref(LewFlex), {
14964
14970
  key: `columns${index2}`,
@@ -14993,21 +14999,23 @@ const _sfc_main$j = defineComponent({
14993
14999
  return openBlock(), createElementBlock("div", {
14994
15000
  key: `data${i}`,
14995
15001
  class: normalizeClass(["lew-table-tr", {
14996
- "lew-table-tr-hover": unref(state).hoverIndex === i
15002
+ "lew-table-tr-hover": unref(state).hoverIndex === i,
15003
+ "lew-table-tr-selected": unref(state).selectedKeysMap[row[_ctx.rowKey]]
14997
15004
  }]),
15005
+ onClick: ($event) => selectTr(row),
14998
15006
  onMouseenter: ($event) => unref(state).hoverIndex = i
14999
15007
  }, [
15000
15008
  _ctx.checkable && unref(fixedColumns)("left").length > 0 ? (openBlock(), createBlock(unref(LewFlex), {
15001
15009
  key: 0,
15002
15010
  style: { "width": "50px" },
15003
- x: "center"
15011
+ x: "center",
15012
+ class: "lew-table-checkbox-wrapper"
15004
15013
  }, {
15005
15014
  default: withCtx(() => [
15006
15015
  createVNode(unref(LewCheckbox), {
15007
- modelValue: unref(state).checkList[i],
15008
- "onUpdate:modelValue": ($event) => unref(state).checkList[i] = $event,
15009
- onChange: ($event) => _ctx.rowKey && setChecked(row[_ctx.rowKey], $event)
15010
- }, null, 8, ["modelValue", "onUpdate:modelValue", "onChange"])
15016
+ class: "lew-table-checkbox",
15017
+ checked: unref(state).selectedKeysMap[row[_ctx.rowKey]]
15018
+ }, null, 8, ["checked"])
15011
15019
  ]),
15012
15020
  _: 2
15013
15021
  }, 1024)) : createCommentVNode("v-if", true),
@@ -15032,29 +15040,31 @@ const _sfc_main$j = defineComponent({
15032
15040
  _: 2
15033
15041
  }, 1032, ["x", "y", "style"]);
15034
15042
  }), 128))
15035
- ], 42, _hoisted_5$1);
15043
+ ], 42, _hoisted_6);
15036
15044
  }), 128))
15037
15045
  ], 2)) : createCommentVNode("v-if", true),
15038
- createElementVNode("div", _hoisted_6, [
15046
+ createElementVNode("div", _hoisted_7, [
15039
15047
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.dataSource, (row, i) => {
15040
15048
  return openBlock(), createElementBlock("div", {
15041
15049
  key: `data${i}`,
15042
15050
  class: normalizeClass(["lew-table-tr", {
15043
- "lew-table-tr-hover": unref(state).hoverIndex === i
15051
+ "lew-table-tr-hover": unref(state).hoverIndex === i,
15052
+ "lew-table-tr-selected": unref(state).selectedKeysMap[row[_ctx.rowKey]]
15044
15053
  }]),
15054
+ onClick: ($event) => selectTr(row),
15045
15055
  onMouseenter: ($event) => unref(state).hoverIndex = i
15046
15056
  }, [
15047
15057
  _ctx.checkable && unref(fixedColumns)("left").length === 0 ? (openBlock(), createBlock(unref(LewFlex), {
15048
15058
  key: 0,
15049
15059
  style: { "width": "50px" },
15050
- x: "center"
15060
+ x: "center",
15061
+ class: "lew-table-checkbox-wrapper"
15051
15062
  }, {
15052
15063
  default: withCtx(() => [
15053
15064
  createVNode(unref(LewCheckbox), {
15054
- modelValue: unref(state).checkList[i],
15055
- "onUpdate:modelValue": ($event) => unref(state).checkList[i] = $event,
15056
- onChange: ($event) => _ctx.rowKey && setChecked(row[_ctx.rowKey], $event)
15057
- }, null, 8, ["modelValue", "onUpdate:modelValue", "onChange"])
15065
+ class: "lew-table-checkbox",
15066
+ checked: unref(state).selectedKeysMap[row[_ctx.rowKey]]
15067
+ }, null, 8, ["checked"])
15058
15068
  ]),
15059
15069
  _: 2
15060
15070
  }, 1024)) : createCommentVNode("v-if", true),
@@ -15082,7 +15092,7 @@ const _sfc_main$j = defineComponent({
15082
15092
  _: 2
15083
15093
  }, 1032, ["x", "y", "style"]);
15084
15094
  }), 128))
15085
- ], 42, _hoisted_7);
15095
+ ], 42, _hoisted_8);
15086
15096
  }), 128))
15087
15097
  ]),
15088
15098
  unref(fixedColumns)("right").length > 0 ? (openBlock(), createElementBlock("div", {
@@ -15097,7 +15107,8 @@ const _sfc_main$j = defineComponent({
15097
15107
  return openBlock(), createElementBlock("div", {
15098
15108
  key: `data${i}`,
15099
15109
  class: normalizeClass(["lew-table-tr", {
15100
- "lew-table-tr-hover": unref(state).hoverIndex === i
15110
+ "lew-table-tr-hover": unref(state).hoverIndex === i,
15111
+ "lew-table-tr-selected": unref(state).selectedKeysMap[row[_ctx.rowKey]]
15101
15112
  }]),
15102
15113
  onMouseenter: ($event) => unref(state).hoverIndex = i
15103
15114
  }, [
@@ -15122,7 +15133,7 @@ const _sfc_main$j = defineComponent({
15122
15133
  _: 2
15123
15134
  }, 1032, ["x", "y", "style"]);
15124
15135
  }), 128))
15125
- ], 42, _hoisted_8);
15136
+ ], 42, _hoisted_9);
15126
15137
  }), 128))
15127
15138
  ], 2)) : createCommentVNode("v-if", true)
15128
15139
  ], 4)) : createCommentVNode("v-if", true)