bkui-vue 0.0.1-beta.331 → 0.0.1-beta.333

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 (45) hide show
  1. package/dist/index.cjs.js +36 -36
  2. package/dist/index.esm.js +119 -51
  3. package/dist/index.umd.js +36 -36
  4. package/dist/style.css +1 -1
  5. package/dist/style.variable.css +1 -1
  6. package/lib/alert/alert.css +4 -0
  7. package/lib/alert/alert.less +24 -19
  8. package/lib/alert/alert.variable.css +4 -0
  9. package/lib/checkbox/checkbox.css +10 -6
  10. package/lib/checkbox/checkbox.less +38 -32
  11. package/lib/checkbox/checkbox.variable.css +10 -6
  12. package/lib/checkbox/index.js +1 -1
  13. package/lib/date-picker/date-picker.css +6 -1
  14. package/lib/date-picker/date-picker.d.ts +2 -0
  15. package/lib/date-picker/date-picker.less +7 -1
  16. package/lib/date-picker/date-picker.variable.css +6 -1
  17. package/lib/date-picker/index.d.ts +6 -0
  18. package/lib/date-picker/index.js +1 -1
  19. package/lib/date-picker/panel/date-range.d.ts +1 -0
  20. package/lib/date-picker/utils.d.ts +0 -1
  21. package/lib/form/form-item.d.ts +14 -3
  22. package/lib/form/form.css +13 -7
  23. package/lib/form/form.less +61 -52
  24. package/lib/form/form.variable.css +13 -7
  25. package/lib/form/index.d.ts +11 -2
  26. package/lib/form/index.js +1 -1
  27. package/lib/form/type.d.ts +1 -2
  28. package/lib/form/utils.d.ts +2 -0
  29. package/lib/message/message.css +1 -1
  30. package/lib/message/message.less +1 -1
  31. package/lib/message/message.variable.css +1 -1
  32. package/lib/pagination/pagination.less +9 -7
  33. package/lib/radio/index.js +1 -1
  34. package/lib/radio/radio.css +61 -66
  35. package/lib/radio/radio.less +75 -81
  36. package/lib/radio/radio.variable.css +61 -66
  37. package/lib/select/index.js +1 -1
  38. package/lib/shared/index.js +1 -1
  39. package/lib/table/index.js +1 -1
  40. package/lib/table/table.css +13 -6
  41. package/lib/table/table.less +6 -0
  42. package/lib/table/table.variable.css +13 -6
  43. package/lib/tree/tree.css +10 -6
  44. package/lib/tree/tree.variable.css +10 -6
  45. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -7941,7 +7941,7 @@ class PropTypes extends propTypesNS {
7941
7941
  const formKey = Symbol("form");
7942
7942
  const formItemKey = Symbol("formItem");
7943
7943
  const useForm = () => inject(formKey);
7944
- const useFormItem = () => inject(formItemKey, EMPTY_OBJ);
7944
+ const useFormItem = () => inject(formItemKey, void 0);
7945
7945
  const on$2 = (() => {
7946
7946
  if (document.addEventListener) {
7947
7947
  return (element, event, handler) => {
@@ -9797,6 +9797,14 @@ var Component$w = defineComponent({
9797
9797
  "is-disabled": this.isDisabled,
9798
9798
  "is-indeterminated": this.indeterminate
9799
9799
  });
9800
+ const renderLabel = () => {
9801
+ if (!this.label && !this.$slots.default) {
9802
+ return null;
9803
+ }
9804
+ return createVNode("span", {
9805
+ "class": "bk-checkbox-label"
9806
+ }, [this.$slots.default ? this.$slots.default() : this.label]);
9807
+ };
9800
9808
  return createVNode("label", {
9801
9809
  "class": checkboxClass
9802
9810
  }, [createVNode("span", {
@@ -9808,9 +9816,7 @@ var Component$w = defineComponent({
9808
9816
  "disabled": this.isDisabled,
9809
9817
  "checked": this.isChecked,
9810
9818
  "onChange": this.handleChange
9811
- }, null)]), this.$slots.default ? this.$slots.default() : createVNode("span", {
9812
- "class": "bk-checkbox-label"
9813
- }, [this.label])]);
9819
+ }, null)]), renderLabel()]);
9814
9820
  }
9815
9821
  });
9816
9822
  const checkboxGroupProps = {
@@ -13964,6 +13970,14 @@ var Component$o = defineComponent({
13964
13970
  "is-disabled": this.isDisabled,
13965
13971
  "is-checked": this.isChecked
13966
13972
  });
13973
+ const renderLabel = () => {
13974
+ if (!this.label && !this.$slots.default) {
13975
+ return null;
13976
+ }
13977
+ return createVNode("span", {
13978
+ "class": "bk-radio-label"
13979
+ }, [this.$slots.default ? this.$slots.default() : this.label]);
13980
+ };
13967
13981
  return createVNode("label", {
13968
13982
  "class": radioClass,
13969
13983
  "tabindex": "0"
@@ -13977,9 +13991,7 @@ var Component$o = defineComponent({
13977
13991
  "onFocus": this.handleFocus,
13978
13992
  "onBlur": this.handleBlur,
13979
13993
  "onChange": this.handleChange
13980
- }, null), createVNode("span", {
13981
- "class": "bk-radio-text"
13982
- }, [this.$slots.default ? this.$slots.default() : this.label])]);
13994
+ }, null), renderLabel()]);
13983
13995
  }
13984
13996
  });
13985
13997
  const radioButtonProps = {
@@ -14022,6 +14034,14 @@ var RadioButton = defineComponent({
14022
14034
  "is-disabled": this.isDisabled,
14023
14035
  "is-checked": this.isChecked
14024
14036
  });
14037
+ const renderLabel = () => {
14038
+ if (!this.label && !this.$slots.default) {
14039
+ return null;
14040
+ }
14041
+ return createVNode("span", {
14042
+ "class": "bk-radio-button-label"
14043
+ }, [this.$slots.default ? this.$slots.default() : this.label]);
14044
+ };
14025
14045
  return createVNode("label", {
14026
14046
  "class": radioClass,
14027
14047
  "tabindex": "0"
@@ -14035,9 +14055,7 @@ var RadioButton = defineComponent({
14035
14055
  "onFocus": this.handleFocus,
14036
14056
  "onBlur": this.handleBlur,
14037
14057
  "onChange": this.handleChange
14038
- }, null), createVNode("div", {
14039
- "class": "bk-radio-button-text"
14040
- }, [this.$slots.default ? this.$slots.default() : this.label])]);
14058
+ }, null), renderLabel()]);
14041
14059
  }
14042
14060
  });
14043
14061
  const radioGroupProps = {
@@ -15258,7 +15276,7 @@ var Component$j = defineComponent({
15258
15276
  var _a;
15259
15277
  handleSetSelectedData();
15260
15278
  if (props2.withValidate) {
15261
- (_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change");
15279
+ (_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "blur");
15262
15280
  }
15263
15281
  }, {
15264
15282
  deep: true
@@ -16457,7 +16475,8 @@ var usePagination = (props2, indexData) => {
16457
16475
  count: 0,
16458
16476
  limit: 10,
16459
16477
  current: 1,
16460
- align: "left"
16478
+ align: "right",
16479
+ layout: ["total", "limit", "list"]
16461
16480
  });
16462
16481
  pagination2 = resolvePaginationOption(props2.pagination, pagination2);
16463
16482
  const localPagination = ref(null);
@@ -21929,6 +21948,7 @@ var Confirm = defineComponent({
21929
21948
  };
21930
21949
  },
21931
21950
  render() {
21951
+ var _a, _b, _c;
21932
21952
  return createVNode("div", {
21933
21953
  "class": "bk-picker-confirm",
21934
21954
  "ref": "elRef",
@@ -21940,7 +21960,9 @@ var Confirm = defineComponent({
21940
21960
  "onClick": this.handleToggleTime
21941
21961
  }, {
21942
21962
  default: () => [this.labels.time]
21943
- }) : "", this.clearable ? createVNode("a", {
21963
+ }) : "", (_c = (_b = (_a = this.$slots).confirm) == null ? void 0 : _b.call(_a)) != null ? _c : createVNode("div", {
21964
+ "class": "bk-picker-confirm-action"
21965
+ }, [this.clearable ? createVNode("a", {
21944
21966
  "href": "javascript: void(0);",
21945
21967
  "onClick": this.handleClear,
21946
21968
  "onKeydown": this.handleClear
@@ -21949,7 +21971,7 @@ var Confirm = defineComponent({
21949
21971
  "class": "confirm",
21950
21972
  "onClick": this.handleSuccess,
21951
21973
  "onKeydown_enter": this.handleSuccess
21952
- }, [this.labels.ok])]);
21974
+ }, [this.labels.ok])])]);
21953
21975
  }
21954
21976
  });
21955
21977
  var oneDay = 1e3 * 60 * 60 * 24;
@@ -24119,15 +24141,6 @@ const formatDate = (val, type, multiple, format2) => {
24119
24141
  };
24120
24142
  const datePickerKey = Symbol("date-picker");
24121
24143
  const timePickerKey = Symbol("time-picker");
24122
- function findChildComponents(context, componentName) {
24123
- return (context.$children || []).reduce((components2, child) => {
24124
- if (child.$options.name === componentName) {
24125
- components2.push(child);
24126
- }
24127
- const foundChilds = findChildComponents(child, componentName);
24128
- return components2.concat(foundChilds);
24129
- }, []);
24130
- }
24131
24144
  function iconBtnCls(direction, type = "") {
24132
24145
  return [
24133
24146
  "bk-picker-panel-icon-btn",
@@ -25713,6 +25726,25 @@ var DateRangePanel = defineComponent({
25713
25726
  };
25714
25727
  setPanelDates(props2.startDate || state.dates[0] || new Date());
25715
25728
  });
25729
+ watch(() => state.currentView, (v2) => {
25730
+ const leftMonth = state.leftPanelDate.getMonth();
25731
+ const rightMonth = state.rightPanelDate.getMonth();
25732
+ const isSameYear = state.leftPanelDate.getFullYear() === state.rightPanelDate.getFullYear();
25733
+ if (v2 === "date" && isSameYear && leftMonth === rightMonth) {
25734
+ changePanelDate("right", "Month", 1);
25735
+ }
25736
+ if (v2 === "month" && isSameYear) {
25737
+ changePanelDate("right", "FullYear", 1);
25738
+ }
25739
+ if (v2 === "year" && isSameYear) {
25740
+ changePanelDate("right", "FullYear", 10);
25741
+ }
25742
+ if (state.currentView === "time") {
25743
+ nextTick(() => {
25744
+ timePickerRef.value.updateScroll();
25745
+ });
25746
+ }
25747
+ });
25716
25748
  const isTime = computed(() => state.currentView === "time");
25717
25749
  const leftDatePanelLabel = computed(() => panelLabelConfig("left"));
25718
25750
  const rightDatePanelLabel = computed(() => panelLabelConfig("right"));
@@ -25757,6 +25789,7 @@ var DateRangePanel = defineComponent({
25757
25789
  emit("pick-click");
25758
25790
  }
25759
25791
  const timeDisabled = computed(() => !(state.dates[0] && state.dates[1]));
25792
+ const timePickerRef = ref(null);
25760
25793
  return __spreadProps(__spreadValues({}, toRefs(state)), {
25761
25794
  isTime,
25762
25795
  hasShortcuts,
@@ -25783,7 +25816,8 @@ var DateRangePanel = defineComponent({
25783
25816
  handleToggleTime,
25784
25817
  handlePickSuccess,
25785
25818
  handlePickClear,
25786
- handlePickClick
25819
+ handlePickClick,
25820
+ timePickerRef
25787
25821
  });
25788
25822
  },
25789
25823
  render() {
@@ -25960,7 +25994,7 @@ var DateRangePanel = defineComponent({
25960
25994
  "onPick-toggle-time": this.handleToggleTime,
25961
25995
  "onPick-clear": this.handlePickClear,
25962
25996
  "onPick-success": this.handlePickSuccess
25963
- }, null) : ""]), shortcuts]);
25997
+ }, this.$slots) : ""]), shortcuts]);
25964
25998
  }
25965
25999
  });
25966
26000
  var Component$a = defineComponent({
@@ -26053,6 +26087,7 @@ var Component$a = defineComponent({
26053
26087
  const hasHeader = computed(() => !!slots.header);
26054
26088
  const hasFooter = computed(() => !!slots.footer);
26055
26089
  const hasShortcuts = computed(() => !!slots.shortcuts);
26090
+ const hasConfirm = computed(() => !!slots.confirm);
26056
26091
  const fontSizeCls = computed(() => {
26057
26092
  let cls = "";
26058
26093
  if (props2.fontSize === "medium") {
@@ -26322,6 +26357,10 @@ var Component$a = defineComponent({
26322
26357
  emit("shortcut-change", state.shortcut, shortcutIndex);
26323
26358
  };
26324
26359
  const triggerRef = ref(null);
26360
+ const handleToggleTime = () => {
26361
+ var _a, _b;
26362
+ (_b = (_a = pickerPanelRef.value).handleToggleTime) == null ? void 0 : _b.call(_a);
26363
+ };
26325
26364
  return __spreadProps(__spreadValues({}, toRefs(state)), {
26326
26365
  panel,
26327
26366
  publicStringValue,
@@ -26332,6 +26371,7 @@ var Component$a = defineComponent({
26332
26371
  hasHeader,
26333
26372
  hasFooter,
26334
26373
  hasShortcuts,
26374
+ hasConfirm,
26335
26375
  fontSizeCls,
26336
26376
  longWidthCls,
26337
26377
  localReadonly,
@@ -26351,7 +26391,8 @@ var Component$a = defineComponent({
26351
26391
  handleInputChange,
26352
26392
  handleClear,
26353
26393
  onPick,
26354
- onPickSuccess
26394
+ onPickSuccess,
26395
+ handleToggleTime
26355
26396
  });
26356
26397
  },
26357
26398
  render() {
@@ -26429,6 +26470,10 @@ var Component$a = defineComponent({
26429
26470
  })) || null;
26430
26471
  }
26431
26472
  } : {};
26473
+ const confirmSlot = this.hasConfirm ? {
26474
+ confirm: this.$slots.confirm
26475
+ } : {};
26476
+ const slots = __spreadValues(__spreadValues({}, shortcutsSlot), confirmSlot);
26432
26477
  return withDirectives(createVNode("div", {
26433
26478
  "class": ["bk-date-picker", this.type === "datetimerange" ? "long" : "", this.longWidthCls]
26434
26479
  }, [createVNode("div", {
@@ -26472,7 +26517,7 @@ var Component$a = defineComponent({
26472
26517
  "onPick-clear": this.handleClear,
26473
26518
  "onPick-success": this.onPickSuccess,
26474
26519
  "onSelection-mode-change": this.onSelectionModeChange
26475
- }, shortcutsSlot) : createVNode(DatePanel, {
26520
+ }, slots) : createVNode(DatePanel, {
26476
26521
  "ref": "pickerPanelRef",
26477
26522
  "clearable": this.clearable,
26478
26523
  "showTime": this.type === "datetime" || this.type === "datetimerange",
@@ -26490,7 +26535,7 @@ var Component$a = defineComponent({
26490
26535
  "onPick-clear": this.handleClear,
26491
26536
  "onPick-success": this.onPickSuccess,
26492
26537
  "onSelection-mode-change": this.onSelectionModeChange
26493
- }, shortcutsSlot), this.hasFooter ? createVNode("div", {
26538
+ }, slots), this.hasFooter ? createVNode("div", {
26494
26539
  "class": ["bk-date-picker-footer-wrapper", this.footerSlotCls]
26495
26540
  }, [(_f = (_e = (_d = this.$slots).footer) == null ? void 0 : _e.call(_d)) != null ? _f : null]) : null];
26496
26541
  }
@@ -26631,8 +26676,8 @@ var TimePicker = defineComponent({
26631
26676
  watch(() => state.visible, (visible) => {
26632
26677
  if (visible) {
26633
26678
  nextTick(() => {
26634
- const spinners = findChildComponents(proxy, "TimeSpinner");
26635
- spinners.forEach((instance) => instance.updateScroll());
26679
+ var _a, _b;
26680
+ (_b = (_a = proxy.pickerPanelRef) == null ? void 0 : _a.timeSpinnerRef) == null ? void 0 : _b.updateScroll();
26636
26681
  });
26637
26682
  }
26638
26683
  });
@@ -28758,8 +28803,14 @@ var Form = defineComponent({
28758
28803
  }, [(_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)]);
28759
28804
  }
28760
28805
  });
28806
+ const getRuleMessage = (rule) => {
28807
+ if (typeof rule.message === "function") {
28808
+ return rule.message();
28809
+ }
28810
+ return rule.message;
28811
+ };
28761
28812
  var defaultValidator = {
28762
- required: (value) => value !== "" && value !== void 0 && value !== null,
28813
+ required: (value) => !_$1.isEmpty(value),
28763
28814
  min: (value, min2) => value >= min2,
28764
28815
  max: (value, max2) => max2 >= value,
28765
28816
  email: (value) => /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/.test(value),
@@ -28768,7 +28819,7 @@ var defaultValidator = {
28768
28819
  };
28769
28820
  const formItemProps = {
28770
28821
  label: PropTypes.string,
28771
- labelWidth: PropTypes.oneOfType([Number, String]),
28822
+ labelWidth: PropTypes.oneOfType([Number, String]).def(150),
28772
28823
  labelPosition: PropTypes.oneOf(["left", "center", "right"]),
28773
28824
  property: PropTypes.string.def(""),
28774
28825
  required: PropTypes.bool.def(false),
@@ -28801,21 +28852,21 @@ const getRulesFromProps = (props2) => {
28801
28852
  if (Number(props2.max) > -1) {
28802
28853
  rules.push({
28803
28854
  validator: (value) => defaultValidator.max(value, props2.max),
28804
- message: `${props2.label}\u6700\u5927\u503C${props2.max}`,
28855
+ message: `${props2.label}\u6700\u5927\u503C ${props2.max}`,
28805
28856
  trigger: "blur"
28806
28857
  });
28807
28858
  }
28808
28859
  if (Number(props2.min) > -1) {
28809
28860
  rules.push({
28810
28861
  validator: (value) => defaultValidator.min(value, props2.min),
28811
- message: `${props2.label}\u6700\u5C0F\u503C${props2.min}`,
28862
+ message: `${props2.label}\u6700\u5C0F\u503C ${props2.min}`,
28812
28863
  trigger: "blur"
28813
28864
  });
28814
28865
  }
28815
28866
  if (Number(props2.maxlength) > -1) {
28816
28867
  rules.push({
28817
28868
  validator: (value) => defaultValidator.maxlength(value, props2.maxlength),
28818
- message: `${props2.label}\u6700\u5927\u957F\u5EA6${props2.maxlength}`,
28869
+ message: `${props2.label}\u6700\u5927\u957F\u5EA6 ${props2.maxlength}`,
28819
28870
  trigger: "blur"
28820
28871
  });
28821
28872
  }
@@ -28843,8 +28894,8 @@ const mergeRules = (configRules, propsRules) => {
28843
28894
  }
28844
28895
  result.push({
28845
28896
  validator: rulevalidator,
28846
- message: rule.message,
28847
- trigger: rule.trigger
28897
+ message: rule.message || "\u9A8C\u8BC1\u9519\u8BEF",
28898
+ trigger: rule.trigger || "blur"
28848
28899
  });
28849
28900
  return result;
28850
28901
  }, []);
@@ -28868,37 +28919,51 @@ var FormItem = defineComponent({
28868
28919
  bkTooltips: tooltips
28869
28920
  },
28870
28921
  props: formItemProps,
28871
- setup(props2) {
28922
+ setup(props2, context) {
28923
+ const form2 = useForm();
28924
+ const isForm = Boolean(form2);
28925
+ const parentFormItem = useFormItem();
28926
+ const isNested = Boolean(parentFormItem);
28872
28927
  const currentInstance = getCurrentInstance();
28873
28928
  const state = reactive({
28874
28929
  isError: false,
28875
28930
  errorMessage: ""
28876
28931
  });
28877
- const form2 = useForm();
28878
- const isForm = Boolean(form2);
28879
28932
  const isFormTypeVertical = computed(() => {
28880
28933
  if (!isForm) {
28881
28934
  return false;
28882
28935
  }
28883
28936
  return form2.props.formType === "vertical";
28884
28937
  });
28938
+ const isShowLabel = computed(() => {
28939
+ if (props2.label || context.slots.label) {
28940
+ return true;
28941
+ }
28942
+ return false;
28943
+ });
28885
28944
  const labelStyles = computed(() => {
28886
28945
  const styles = {
28887
28946
  width: "",
28888
28947
  paddingRight: "",
28889
28948
  textAlign: ""
28890
28949
  };
28950
+ const labelPosition = props2.labelPosition || isForm && form2.props.labelPosition;
28951
+ if (labelPosition) {
28952
+ styles["text-align"] = labelPosition;
28953
+ }
28954
+ if (form2.props.formType === "vertical" || !props2.label && isNested) {
28955
+ return styles;
28956
+ }
28891
28957
  const labelWidth = isValid(props2.labelWidth) ? props2.labelWidth : isForm && form2.props.labelWidth;
28892
28958
  if (isValid(labelWidth)) {
28893
28959
  styles.width = `${labelWidth}px`;
28894
28960
  styles.paddingRight = labelWidth ? "" : "0px";
28895
28961
  }
28896
- const labelPosition = props2.labelPosition || isForm && form2.props.labelPosition;
28897
- if (labelPosition) {
28898
- styles["text-align"] = labelPosition;
28899
- }
28900
28962
  return styles;
28901
28963
  });
28964
+ const contentStyles = computed(() => ({
28965
+ ["margin-left"]: labelStyles.value.width
28966
+ }));
28902
28967
  const validate = (trigger) => {
28903
28968
  if (!props2.property || isForm && !form2.props.model) {
28904
28969
  return Promise.resolve(true);
@@ -28929,18 +28994,18 @@ var FormItem = defineComponent({
28929
28994
  if (typeof result !== "boolean" && typeof result.then === "function") {
28930
28995
  return result.then((data2) => {
28931
28996
  if (data2 === false) {
28932
- return Promise.reject(rule.message);
28997
+ return Promise.reject(getRuleMessage(rule));
28933
28998
  }
28934
28999
  }).then(() => doValidate(), () => {
28935
29000
  state.isError = true;
28936
- state.errorMessage = rule.message;
28937
- return Promise.reject(rule.message);
29001
+ state.errorMessage = getRuleMessage(rule);
29002
+ return Promise.reject(state.errorMessage);
28938
29003
  });
28939
29004
  }
28940
29005
  if (!result) {
28941
29006
  state.isError = true;
28942
- state.errorMessage = rule.message;
28943
- return Promise.reject(rule.message);
29007
+ state.errorMessage = getRuleMessage(rule);
29008
+ return Promise.reject(state.errorMessage);
28944
29009
  }
28945
29010
  return doValidate();
28946
29011
  });
@@ -28967,7 +29032,9 @@ var FormItem = defineComponent({
28967
29032
  }
28968
29033
  });
28969
29034
  return __spreadProps(__spreadValues({}, toRefs(state)), {
29035
+ isShowLabel,
28970
29036
  labelStyles,
29037
+ contentStyles,
28971
29038
  isFormTypeVertical,
28972
29039
  validate,
28973
29040
  clearValidate
@@ -29008,11 +29075,12 @@ var FormItem = defineComponent({
29008
29075
  };
29009
29076
  return createVNode("div", {
29010
29077
  "class": itemClassees
29011
- }, [createVNode("div", {
29078
+ }, [this.isShowLabel && createVNode("div", {
29012
29079
  "class": "bk-form-label",
29013
29080
  "style": this.labelStyles
29014
29081
  }, [renderLabel(), this.isFormTypeVertical && ((_b = (_a = this.$slots).labelAppend) == null ? void 0 : _b.call(_a))]), createVNode("div", {
29015
- "class": "bk-form-content"
29082
+ "class": "bk-form-content",
29083
+ "style": this.contentStyles
29016
29084
  }, [(_d = (_c = this.$slots).default) == null ? void 0 : _d.call(_c), renderError()])]);
29017
29085
  }
29018
29086
  });