bkui-vue 0.0.1-beta.20 → 0.0.1-beta.21

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 (46) hide show
  1. package/README.md +7 -3
  2. package/README_EN.md +7 -3
  3. package/dist/bkui-vue.cjs.js +230 -208
  4. package/dist/bkui-vue.esm.js +230 -208
  5. package/dist/bkui-vue.umd.js +230 -208
  6. package/dist/style.css +127 -85
  7. package/lib/button/button.css +9 -0
  8. package/lib/button/button.d.ts +25 -1
  9. package/lib/button/button.less +18 -10
  10. package/lib/button/button.variable.css +9 -0
  11. package/lib/button/index.d.ts +42 -4
  12. package/lib/button/index.js +1 -1
  13. package/lib/code-diff/code-diff.css +114 -0
  14. package/lib/code-diff/code-diff.d.ts +71 -0
  15. package/lib/code-diff/code-diff.less +144 -0
  16. package/lib/code-diff/code-diff.variable.css +207 -0
  17. package/lib/code-diff/index.d.ts +6 -0
  18. package/lib/date-picker/date-picker.d.ts +20 -130
  19. package/lib/date-picker/index.js +1 -1
  20. package/lib/date-picker/interface.d.ts +1 -1
  21. package/lib/date-picker/props.d.ts +111 -0
  22. package/lib/directives/clickoutside.d.ts +3 -23
  23. package/lib/directives/index.js +2 -2
  24. package/lib/input/index.d.ts +58 -4
  25. package/lib/input/index.js +2 -2
  26. package/lib/input/input.css +19 -2
  27. package/lib/input/input.d.ts +31 -1
  28. package/lib/input/input.less +25 -3
  29. package/lib/input/input.variable.css +19 -2
  30. package/lib/loading/index.d.ts +31 -9
  31. package/lib/loading/index.js +1 -1
  32. package/lib/loading/loading.css +98 -71
  33. package/lib/loading/loading.d.ts +23 -8
  34. package/lib/loading/loading.less +62 -49
  35. package/lib/loading/loading.variable.css +98 -71
  36. package/lib/shared/index.js +1 -1
  37. package/lib/shared/vue-types.d.ts +4 -0
  38. package/lib/tree/index.d.ts +17 -24
  39. package/lib/tree/index.js +1 -1
  40. package/lib/tree/props.d.ts +9 -8
  41. package/lib/tree/tree.css +1 -12
  42. package/lib/tree/tree.d.ts +8 -11
  43. package/lib/tree/tree.less +10 -24
  44. package/lib/tree/tree.variable.css +1 -12
  45. package/lib/tree/util.d.ts +9 -1
  46. package/package.json +1 -1
@@ -183,7 +183,7 @@ function getWindow(node) {
183
183
  }
184
184
  return node;
185
185
  }
186
- function isElement$1(node) {
186
+ function isElement$2(node) {
187
187
  var OwnElement = getWindow(node).Element;
188
188
  return node instanceof OwnElement || node instanceof Element;
189
189
  }
@@ -337,7 +337,7 @@ function isTableElement(element) {
337
337
  return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
338
338
  }
339
339
  function getDocumentElement(element) {
340
- return ((isElement$1(element) ? element.ownerDocument : element.document) || window.document).documentElement;
340
+ return ((isElement$2(element) ? element.ownerDocument : element.document) || window.document).documentElement;
341
341
  }
342
342
  function getParentNode(element) {
343
343
  if (getNodeName(element) === "html") {
@@ -745,17 +745,17 @@ function getInnerBoundingClientRect(element) {
745
745
  return rect;
746
746
  }
747
747
  function getClientRectFromMixedType(element, clippingParent) {
748
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement$1(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
748
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement$2(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
749
749
  }
750
750
  function getClippingParents(element) {
751
751
  var clippingParents2 = listScrollParents(getParentNode(element));
752
752
  var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle(element).position) >= 0;
753
753
  var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
754
- if (!isElement$1(clipperElement)) {
754
+ if (!isElement$2(clipperElement)) {
755
755
  return [];
756
756
  }
757
757
  return clippingParents2.filter(function(clippingParent) {
758
- return isElement$1(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
758
+ return isElement$2(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
759
759
  });
760
760
  }
761
761
  function getClippingRect(element, boundary, rootBoundary) {
@@ -837,7 +837,7 @@ function detectOverflow(state, options) {
837
837
  var altContext = elementContext === popper$1 ? reference : popper$1;
838
838
  var popperRect = state.rects.popper;
839
839
  var element = state.elements[altBoundary ? altContext : elementContext];
840
- var clippingClientRect = getClippingRect(isElement$1(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
840
+ var clippingClientRect = getClippingRect(isElement$2(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
841
841
  var referenceClientRect = getBoundingClientRect(state.elements.reference);
842
842
  var popperOffsets2 = computeOffsets({
843
843
  reference: referenceClientRect,
@@ -1354,7 +1354,7 @@ function popperGenerator(generatorOptions) {
1354
1354
  cleanupModifierEffects();
1355
1355
  state.options = Object.assign({}, defaultOptions, state.options, options2);
1356
1356
  state.scrollParents = {
1357
- reference: isElement$1(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
1357
+ reference: isElement$2(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
1358
1358
  popper: listScrollParents(popper2)
1359
1359
  };
1360
1360
  var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state.options.modifiers)));
@@ -1404,7 +1404,7 @@ function popperGenerator(generatorOptions) {
1404
1404
  resolve(state);
1405
1405
  });
1406
1406
  }),
1407
- destroy: function destroy2() {
1407
+ destroy: function destroy() {
1408
1408
  cleanupModifierEffects();
1409
1409
  isDestroyed = true;
1410
1410
  }
@@ -1553,7 +1553,7 @@ function throttle(func, wait, options) {
1553
1553
  return result;
1554
1554
  };
1555
1555
  }
1556
- function isElement(obj) {
1556
+ function isElement$1(obj) {
1557
1557
  try {
1558
1558
  return obj instanceof HTMLElement;
1559
1559
  } catch (e) {
@@ -1655,13 +1655,13 @@ class BKPopover {
1655
1655
  }
1656
1656
  restorePopContent() {
1657
1657
  const target = this.getAppendToTarget();
1658
- if (isElement(target) && target.contains(this.popperRefer) && this.container && !this.container.contains(this.popperRefer)) {
1658
+ if (isElement$1(target) && target.contains(this.popperRefer) && this.container && !this.container.contains(this.popperRefer)) {
1659
1659
  this.container.append(this.popperRefer);
1660
1660
  }
1661
1661
  }
1662
1662
  appendToTarget() {
1663
1663
  const target = this.getAppendToTarget();
1664
- if (isElement(target) && target.contains(this.popperRefer)) {
1664
+ if (isElement$1(target) && target.contains(this.popperRefer)) {
1665
1665
  target.append(this.popperRefer);
1666
1666
  }
1667
1667
  }
@@ -1742,7 +1742,7 @@ class BKPopover {
1742
1742
  return null;
1743
1743
  }
1744
1744
  isElement(obj) {
1745
- return isElement(obj);
1745
+ return isElement$1(obj);
1746
1746
  }
1747
1747
  registerEvents() {
1748
1748
  if (this.isElement(this.referenceTarget)) {
@@ -2270,6 +2270,12 @@ function R(e = { func: () => {
2270
2270
  class z extends R() {
2271
2271
  }
2272
2272
  const propTypesNS = R({});
2273
+ function stringEnum(o2) {
2274
+ return o2.reduce((res, key) => {
2275
+ res[key] = key;
2276
+ return res;
2277
+ }, /* @__PURE__ */ Object.create(null));
2278
+ }
2273
2279
  class PropTypes extends propTypesNS {
2274
2280
  static size(sizes = ["small", "default", "large"]) {
2275
2281
  return j("Size", {
@@ -2293,8 +2299,7 @@ class PropTypes extends propTypesNS {
2293
2299
  }
2294
2300
  console.error(`invalid theme, ${val}, the theme must be one of \u3010${themes.join(" | ")}\u3011`);
2295
2301
  return false;
2296
- },
2297
- default: "primary"
2302
+ }
2298
2303
  });
2299
2304
  }
2300
2305
  static placement(placements2 = ["top", "left", "right", "bottom"]) {
@@ -2866,12 +2871,12 @@ var Component$s = defineComponent({
2866
2871
  }) {
2867
2872
  const container = ref(null);
2868
2873
  const el = ref(null);
2869
- const visiable = ref(false);
2874
+ const visible = ref(false);
2870
2875
  const zIndex = ref(bkZIndexManager.getModalNextIndex());
2871
2876
  const styleBottom = `${props.bottom}px`;
2872
2877
  const styleRight = `${props.right}px`;
2873
2878
  const scrollHandler = throttle(() => {
2874
- visiable.value = el.value.scrollTop >= props.visibilityHeight;
2879
+ visible.value = el.value.scrollTop >= props.visibilityHeight;
2875
2880
  }, 30);
2876
2881
  const scrollTop = () => {
2877
2882
  el.value.scrollTo({
@@ -2879,7 +2884,7 @@ var Component$s = defineComponent({
2879
2884
  behavior: "smooth"
2880
2885
  });
2881
2886
  };
2882
- watch(() => visiable, () => {
2887
+ watch(() => visible, () => {
2883
2888
  zIndex.value = bkZIndexManager.getModalNextIndex();
2884
2889
  });
2885
2890
  onMounted(() => {
@@ -2902,7 +2907,7 @@ var Component$s = defineComponent({
2902
2907
  }, {
2903
2908
  default: () => {
2904
2909
  var _a, _b;
2905
- return [visiable.value ? createVNode("div", {
2910
+ return [visible.value ? createVNode("div", {
2906
2911
  "class": `bk-backtop ${props.extCls}`,
2907
2912
  "style": {
2908
2913
  right: styleRight,
@@ -3057,11 +3062,12 @@ var BreadcrumbItem = defineComponent({
3057
3062
  const BkBreadcrumb = withInstallProps(Component$q, { Item: BreadcrumbItem });
3058
3063
  let BkLoadingMode;
3059
3064
  (function(BkLoadingMode2) {
3060
- BkLoadingMode2["Spin"] = "spin";
3061
3065
  BkLoadingMode2["Default"] = "default";
3066
+ BkLoadingMode2["Spin"] = "spin";
3062
3067
  })(BkLoadingMode || (BkLoadingMode = {}));
3063
3068
  let BkLoadingSize;
3064
3069
  (function(BkLoadingSize2) {
3070
+ BkLoadingSize2["Mini"] = "mini";
3065
3071
  BkLoadingSize2["Small"] = "small";
3066
3072
  BkLoadingSize2["Large"] = "large";
3067
3073
  })(BkLoadingSize || (BkLoadingSize = {}));
@@ -3076,8 +3082,8 @@ const loadingTypes = {
3076
3082
  loading: PropTypes.bool,
3077
3083
  theme: PropTypes.theme(["white", "primary", "warning", "success", "danger"]),
3078
3084
  title: PropTypes.string.def(""),
3079
- size: PropTypes.size(),
3080
- mode: PropTypes.oneOf(Object.values(BkLoadingMode))
3085
+ size: PropTypes.commonType(Object.values(BkLoadingSize)).def("small"),
3086
+ mode: PropTypes.commonType(Object.values(BkLoadingMode)).def("default")
3081
3087
  };
3082
3088
  var Component$p = defineComponent({
3083
3089
  name: "Loading",
@@ -3094,13 +3100,14 @@ var Component$p = defineComponent({
3094
3100
  const loadingWrapperCls = computed(() => classes({
3095
3101
  "bk-nested-loading": !!ctx.slots.default
3096
3102
  }, "bk-loading-wrapper"));
3103
+ console.log(props.theme);
3097
3104
  const containerCls = computed(() => classes({
3098
- [`bk-loading-size-${props.size}`]: !props.size,
3099
- [`bk-loading-${props.theme}`]: !props.theme
3105
+ [`bk-loading-size-${props.size}`]: !!props.size,
3106
+ [`bk-loading-${props.theme}`]: !!props.theme
3100
3107
  }, "bk-loading-indicator"));
3101
3108
  const hasTitle = computed(() => !!props.title);
3102
3109
  const indicator = computed(() => {
3103
- const isSpinMode = props.mode === "spin";
3110
+ const isSpinMode = props.mode === BkLoadingMode.Spin;
3104
3111
  if (typeof props.indicator === "function") {
3105
3112
  return createVNode(props.indicator, null, null);
3106
3113
  }
@@ -3129,8 +3136,11 @@ const buttonProps = {
3129
3136
  hoverTheme: PropTypes.theme(["primary", "warning", "success", "danger"]).def(""),
3130
3137
  size: PropTypes.size(),
3131
3138
  title: PropTypes.string,
3139
+ icon: PropTypes.string,
3140
+ iconRight: PropTypes.string,
3132
3141
  disabled: PropTypes.bool,
3133
3142
  loading: PropTypes.bool,
3143
+ laodingMode: PropTypes.commonType(Object.values(BkLoadingMode)),
3134
3144
  outline: PropTypes.bool,
3135
3145
  text: PropTypes.bool,
3136
3146
  nativeType: {
@@ -3139,14 +3149,15 @@ const buttonProps = {
3139
3149
  };
3140
3150
  var Component$o = defineComponent({
3141
3151
  name: "Button",
3142
- emits: ["click"],
3143
3152
  props: buttonProps,
3153
+ emits: ["click", "mouseover"],
3144
3154
  setup(props, {
3145
3155
  slots,
3146
3156
  attrs,
3147
3157
  emit
3148
3158
  }) {
3149
3159
  var _a;
3160
+ const isHover = ref(false);
3150
3161
  const showSlot = (_a = slots.default) != null ? _a : false;
3151
3162
  const btnClsPrefix = "bk-button";
3152
3163
  const btnCls = computed(() => {
@@ -3161,28 +3172,44 @@ var Component$o = defineComponent({
3161
3172
  "no-slot": !showSlot
3162
3173
  }, `${themeCls} ${btnClsPrefix} ${hoverTheme}`);
3163
3174
  });
3164
- const bkLoadingCls = `${btnClsPrefix}-loading`;
3165
- const loadingTheme = ["", "default"].includes(props.theme) ? "default" : "white";
3175
+ const loadingTheme = computed(() => {
3176
+ if (props.text || props.outline || props.hoverTheme) {
3177
+ if (isHover.value && !props.text)
3178
+ return "white";
3179
+ return props.hoverTheme || props.theme;
3180
+ }
3181
+ return ["", "default"].includes(props.theme) ? "" : "white";
3182
+ });
3183
+ const loadingSize = computed(() => props.size === BkLoadingSize.Small ? BkLoadingSize.Mini : BkLoadingSize.Small);
3166
3184
  const handleClick = () => {
3167
3185
  emit("click");
3168
3186
  };
3187
+ const handleMouseOver = () => {
3188
+ isHover.value = true;
3189
+ emit("mouseover");
3190
+ };
3191
+ const handleMouseout = () => {
3192
+ isHover.value = false;
3193
+ };
3169
3194
  return () => {
3170
- var _a2, _b;
3195
+ var _a2;
3171
3196
  return createVNode("button", mergeProps({
3172
3197
  "title": props.title,
3173
3198
  "disabled": props.disabled,
3174
3199
  "class": btnCls.value,
3175
3200
  "type": props.nativeType
3176
3201
  }, attrs, {
3177
- "onClick": handleClick
3178
- }), [props.loading ? createVNode("div", {
3179
- "class": bkLoadingCls
3180
- }, [createVNode(BkLoading, {
3181
- "theme": loadingTheme,
3182
- "size": BkLoadingSize.Small
3183
- }, null)]) : createVNode("div", {
3184
- "class": "bk-button-content-wrapper"
3185
- }, [createVNode("span", null, [(_b = (_a2 = slots.default) == null ? void 0 : _a2.call(slots)) != null ? _b : "default"])])]);
3202
+ "onClick": handleClick,
3203
+ "onMouseover": handleMouseOver,
3204
+ "onMouseleave": handleMouseout
3205
+ }), [props.loading && createVNode(BkLoading, {
3206
+ "class": `${btnClsPrefix}-loading`,
3207
+ "mode": props.laodingMode,
3208
+ "theme": loadingTheme.value,
3209
+ "size": loadingSize.value
3210
+ }, null), slots.default && createVNode("span", {
3211
+ "class": `${btnClsPrefix}-text`
3212
+ }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])]);
3186
3213
  };
3187
3214
  }
3188
3215
  });
@@ -3847,19 +3874,24 @@ const inputType = {
3847
3874
  max: PropTypes.integer,
3848
3875
  min: PropTypes.integer,
3849
3876
  maxlength: PropTypes.integer,
3877
+ behavior: PropTypes.commonType(["simplicity", "normal"]).def("normal"),
3850
3878
  showWordLimit: PropTypes.bool,
3851
3879
  showControl: PropTypes.bool.def(true),
3880
+ showClearOnlyHover: PropTypes.bool.def(false),
3852
3881
  precision: PropTypes.number.def(0).validate((val) => val >= 0 && val < 20),
3853
3882
  modelValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
3854
3883
  size: PropTypes.size()
3855
3884
  };
3885
+ const inputEvents = ["update:modelValue", "focus", "blur", "change", "clear", "input", "keypress", "keydown", "keyup", "enter", "paste"];
3886
+ const EventEnum = stringEnum([...inputEvents]);
3856
3887
  var Component$g = defineComponent({
3857
3888
  name: "Input",
3858
3889
  inheritAttrs: false,
3859
3890
  props: inputType,
3860
- emits: ["update:modelValue", "focus", "blur", "change", "clear", "input", "keydown"],
3891
+ emits: [...inputEvents],
3861
3892
  setup(props, ctx) {
3862
3893
  const isFocused = ref(false);
3894
+ const isCNInput = ref(false);
3863
3895
  const inputClsPrefix = "bk-input";
3864
3896
  const _a = ctx.attrs, {
3865
3897
  class: cls,
@@ -3873,6 +3905,7 @@ var Component$g = defineComponent({
3873
3905
  "is-focused": isFocused.value,
3874
3906
  "is-readonly": props.readonly,
3875
3907
  "is-disabled": props.disabled,
3908
+ "is-simplicity": props.behavior === "simplicity",
3876
3909
  [`${cls}`]: !!cls
3877
3910
  }, inputClsPrefix));
3878
3911
  const suffixIconMap = {
@@ -3897,33 +3930,51 @@ var Component$g = defineComponent({
3897
3930
  const isNumberInput = computed(() => props.type === "number");
3898
3931
  const ceilMaxLength = computed(() => Math.floor(props.maxlength));
3899
3932
  const pwdVisible = ref(false);
3933
+ const clearCls = computed(() => classes({
3934
+ "show-clear-only-hover": props.showClearOnlyHover
3935
+ }, suffixCls));
3900
3936
  function clear() {
3901
- ctx.emit("update:modelValue", "");
3902
- ctx.emit("change", "");
3903
- ctx.emit("clear");
3937
+ ctx.emit(EventEnum["update:modelValue"], "");
3938
+ ctx.emit(EventEnum.change, "");
3939
+ ctx.emit(EventEnum.clear);
3904
3940
  }
3905
3941
  function handleFocus(e) {
3906
3942
  isFocused.value = true;
3907
- ctx.emit("focus", e);
3943
+ ctx.emit(EventEnum.focus, e);
3908
3944
  }
3909
3945
  function handleBlur(e) {
3910
3946
  isFocused.value = false;
3911
- ctx.emit("blur", e);
3912
- }
3913
- function handleInput(e) {
3914
- ctx.emit("update:modelValue", isNumberInput.value ? +e.target.value : e.target.value);
3915
- ctx.emit("input", e.target.value);
3947
+ ctx.emit(EventEnum.blur, e);
3948
+ }
3949
+ function eventHandler(eventName) {
3950
+ return (e) => {
3951
+ let originEventName = eventName;
3952
+ if (e.code === "Enter" || e.key === "Enter" || e.keyCode === 13) {
3953
+ originEventName = EventEnum.enter;
3954
+ if (e.type !== EventEnum.keyup)
3955
+ return;
3956
+ }
3957
+ if (isCNInput.value && [EventEnum.input, EventEnum.change].some((e2) => eventName === e2))
3958
+ return;
3959
+ if (eventName === EventEnum.input) {
3960
+ ctx.emit(EventEnum["update:modelValue"], isNumberInput.value ? +e.target.value : e.target.value);
3961
+ }
3962
+ ctx.emit(originEventName, e.target.value, e);
3963
+ };
3916
3964
  }
3917
- function handleKeydown(e) {
3918
- ctx.emit("keydown", e.target.value, e);
3965
+ const [handleKeyup, handleKeydown, handleKeyPress, handlePaste, handleChange, handleInput] = [EventEnum.keyup, EventEnum.keydown, EventEnum.keypress, EventEnum.paste, EventEnum.change, EventEnum.input].map(eventHandler);
3966
+ function handleCompositionStart() {
3967
+ isCNInput.value = true;
3919
3968
  }
3920
- function handleChange(e) {
3921
- ctx.emit("change", e.target.value, e);
3969
+ function handleCompositionEnd(e) {
3970
+ isCNInput.value = false;
3971
+ handleInput(e);
3922
3972
  }
3923
3973
  function handleNumber(step, INC = true) {
3974
+ const numStep = parseInt(String(step), 10);
3924
3975
  const precision = Number.isInteger(props.precision) ? props.precision : 0;
3925
3976
  const val = parseFloat(props.modelValue.toString());
3926
- const factor = Number.isInteger(step) ? step : 1;
3977
+ const factor = Number.isInteger(numStep) ? numStep : 1;
3927
3978
  let newVal = val + (INC ? factor : -1 * factor);
3928
3979
  if (Number.isInteger(props.max)) {
3929
3980
  newVal = Math.min(newVal, props.max);
@@ -3934,12 +3985,12 @@ var Component$g = defineComponent({
3934
3985
  return +newVal.toFixed(precision);
3935
3986
  }
3936
3987
  function handleInc() {
3937
- const newVal = handleNumber(parseInt(String(props.step), 10));
3938
- ctx.emit("update:modelValue", newVal);
3988
+ const newVal = handleNumber(props.step);
3989
+ ctx.emit(EventEnum["update:modelValue"], newVal);
3939
3990
  }
3940
3991
  function handleDec() {
3941
- const newVal = handleNumber(parseInt(String(props.step), 10), false);
3942
- ctx.emit("update:modelValue", newVal);
3992
+ const newVal = handleNumber(props.step, false);
3993
+ ctx.emit(EventEnum["update:modelValue"], newVal);
3943
3994
  }
3944
3995
  function getCls(name) {
3945
3996
  return `${inputClsPrefix}--${name}`;
@@ -3970,11 +4021,16 @@ var Component$g = defineComponent({
3970
4021
  "onInput": handleInput,
3971
4022
  "onFocus": handleFocus,
3972
4023
  "onBlur": handleBlur,
4024
+ "onPaste": handlePaste,
3973
4025
  "onChange": handleChange,
3974
- "onKeydown": handleKeydown
4026
+ "onKeypress": handleKeyPress,
4027
+ "onKeydown": handleKeydown,
4028
+ "onKeyup": handleKeyup,
4029
+ "onCompositionstart": handleCompositionStart,
4030
+ "onCompositionend": handleCompositionEnd
3975
4031
  }), null), props.clearable && !!props.modelValue && createVNode(close$1, {
3976
4032
  "onClick": clear,
3977
- "class": suffixCls
4033
+ "class": clearCls.value
3978
4034
  }, null), suffixIcon.value, typeof props.maxlength === "number" && props.showWordLimit && createVNode("p", {
3979
4035
  "class": getCls("max-length")
3980
4036
  }, [props.modelValue.toString().length, createTextVNode("/"), createVNode("span", null, [ceilMaxLength.value])]), isNumberInput.value && props.showControl && createVNode("div", {
@@ -5001,92 +5057,72 @@ const mousewheel = {
5001
5057
  mousewheelHandler(el, binding.value);
5002
5058
  }
5003
5059
  };
5004
- const nodeMap = /* @__PURE__ */ new Map();
5005
- function parseBindingValue(value) {
5006
- const isTouch = "ontouchstart" in window || (navigator == null ? void 0 : navigator.maxTouchPoints) > 0;
5007
- const defaultOption = {
5008
- handler() {
5009
- },
5010
- capture: true,
5011
- disabled: false,
5012
- detectIframe: true,
5013
- exclude: [],
5014
- events: isTouch ? ["ontouchstart"] : ["click"]
5015
- };
5016
- if (typeof value === "function") {
5017
- defaultOption.handler = value;
5018
- return defaultOption;
5019
- }
5020
- return Object.assign({}, defaultOption);
5021
- }
5022
- function onEvent(config) {
5023
- var _a;
5024
- const { el, event, handler, disabled } = config;
5025
- const path = (_a = event.composedPath) == null ? void 0 : _a.call(event);
5026
- const isClickOutside = path ? path.indexOf(el) < 0 : !el.contains(event.target);
5027
- if (!isClickOutside || !!disabled)
5028
- return;
5029
- handler(event);
5030
- }
5031
- function onIframeClick(config) {
5032
- const { activeElement } = document;
5033
- const { el, handler, disabled, event } = config;
5034
- if (activeElement && activeElement.tagName === "IFRAME" && !el.contains(activeElement) && !disabled) {
5035
- handler(event);
5036
- }
5037
- }
5038
- function getEventConfigList(el, options) {
5039
- const configList = options.events.map((name) => ({
5040
- event: name,
5041
- target: document.documentElement,
5042
- capture: options.capture,
5043
- handler: (event) => onEvent({ el, event, handler: options.handler, disabled: options.disabled })
5044
- }));
5045
- if (options.detectIframe) {
5046
- configList.push({
5047
- event: "blur",
5048
- target: window,
5049
- capture: options.capture,
5050
- handler: (event) => onIframeClick({ el, event, handler: options.handler, disabled: options.disabled })
5051
- });
5052
- }
5053
- return configList;
5054
- }
5055
- function init(el, options) {
5056
- if (nodeMap.has(el)) {
5057
- destroy(el);
5060
+ const isElement = (e) => {
5061
+ if (typeof Element === "undefined")
5062
+ return false;
5063
+ return e instanceof Element;
5064
+ };
5065
+ const nodeList = /* @__PURE__ */ new Map();
5066
+ let startClick;
5067
+ document.addEventListener("mousedown", (e) => startClick = e);
5068
+ document.addEventListener("mouseup", (e) => {
5069
+ for (const handlers of nodeList.values()) {
5070
+ for (const { documentHandler } of handlers) {
5071
+ documentHandler(e, startClick);
5072
+ }
5058
5073
  }
5059
- const configList = getEventConfigList(el, options);
5060
- nodeMap.set(el, configList);
5061
- configList.forEach((config) => {
5062
- const { target, event, handler, capture } = config;
5063
- target.addEventListener(event, handler, capture);
5064
- });
5065
- }
5066
- function destroy(el) {
5067
- var _a;
5068
- const configList = (_a = nodeMap.get(el)) != null ? _a : [];
5069
- configList.forEach((config) => {
5070
- const { target, event, handler, capture } = config;
5071
- target.removeEventListener(event, handler, capture);
5072
- });
5073
- nodeMap.delete(el);
5074
+ });
5075
+ function createDocumentHandler(el, binding) {
5076
+ let excludes = [];
5077
+ if (Array.isArray(binding.arg)) {
5078
+ excludes = binding.arg;
5079
+ } else if (isElement(binding.arg)) {
5080
+ excludes.push(binding.arg);
5081
+ }
5082
+ return function(mouseup, mousedown) {
5083
+ const { popperRef } = binding.instance;
5084
+ const mouseUpTarget = mouseup.target;
5085
+ const mouseDownTarget = mousedown == null ? void 0 : mousedown.target;
5086
+ const isBound = !binding || !binding.instance;
5087
+ const isTargetExists = !mouseUpTarget || !mouseDownTarget;
5088
+ const isContainedByEl = el.contains(mouseUpTarget) || el.contains(mouseDownTarget);
5089
+ const isSelf = el === mouseUpTarget;
5090
+ const isTargetExcluded = excludes.length && excludes.some((item) => item == null ? void 0 : item.contains(mouseUpTarget)) || excludes.length && excludes.includes(mouseDownTarget);
5091
+ const isContainedByPopper = popperRef && (popperRef.contains(mouseUpTarget) || popperRef.contains(mouseDownTarget));
5092
+ if (isBound || isTargetExists || isContainedByEl || isSelf || isTargetExcluded || isContainedByPopper) {
5093
+ return;
5094
+ }
5095
+ binding.value(mouseup, mousedown);
5096
+ };
5074
5097
  }
5075
- const clickoutside = {
5098
+ const ClickOutside = {
5076
5099
  beforeMount(el, binding) {
5077
- const options = parseBindingValue(binding.value);
5078
- if (options.disabled)
5079
- return;
5080
- nodeMap.set(el, getEventConfigList(el, options));
5100
+ if (!nodeList.has(el)) {
5101
+ nodeList.set(el, []);
5102
+ }
5103
+ nodeList.get(el).push({
5104
+ documentHandler: createDocumentHandler(el, binding),
5105
+ bindingFn: binding.value
5106
+ });
5081
5107
  },
5082
5108
  updated(el, binding) {
5083
- const newOptions = parseBindingValue(binding.value);
5084
- if (newOptions.disabled && !nodeMap.has(el))
5085
- return;
5086
- init(el, newOptions);
5109
+ if (!nodeList.has(el)) {
5110
+ nodeList.set(el, []);
5111
+ }
5112
+ const handlers = nodeList.get(el);
5113
+ const oldHandlerIndex = handlers.findIndex((item) => item.bindingFn === binding.oldValue);
5114
+ const newHandler = {
5115
+ documentHandler: createDocumentHandler(el, binding),
5116
+ bindingFn: binding.value
5117
+ };
5118
+ if (oldHandlerIndex >= 0) {
5119
+ handlers.splice(oldHandlerIndex, 1, newHandler);
5120
+ } else {
5121
+ handlers.push(newHandler);
5122
+ }
5087
5123
  },
5088
5124
  unmounted(el) {
5089
- destroy(el);
5125
+ nodeList.delete(el);
5090
5126
  }
5091
5127
  };
5092
5128
  var popper = "";
@@ -5200,7 +5236,7 @@ function createPopperInstance(el, popper2, options) {
5200
5236
  var Component$a = defineComponent({
5201
5237
  name: "Select",
5202
5238
  directives: {
5203
- clickoutside
5239
+ clickoutside: ClickOutside
5204
5240
  },
5205
5241
  props: {
5206
5242
  modelValue: PropTypes.any,
@@ -5736,7 +5772,7 @@ var Component$8 = defineComponent({
5736
5772
  });
5737
5773
  defaultSteps.value.splice(0, defaultSteps.value.length, ...defaults);
5738
5774
  };
5739
- const init2 = () => {
5775
+ const init = () => {
5740
5776
  var _a;
5741
5777
  defaultSteps.value.splice(0, defaultSteps.value.length, ...[{
5742
5778
  title: "\u6B65\u9AA41",
@@ -5768,7 +5804,7 @@ var Component$8 = defineComponent({
5768
5804
  console.warn(e);
5769
5805
  }
5770
5806
  };
5771
- onMounted(init2);
5807
+ onMounted(init);
5772
5808
  return {
5773
5809
  defaultSteps,
5774
5810
  jumpTo
@@ -11531,7 +11567,20 @@ const datePickerProps = {
11531
11567
  type: String,
11532
11568
  default: "bottom-start",
11533
11569
  validator: (value) => {
11534
- const validList = ["top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "left", "left-start", "left-end", "right", "right-start", "right-end"];
11570
+ const validList = [
11571
+ "top",
11572
+ "top-start",
11573
+ "top-end",
11574
+ "bottom",
11575
+ "bottom-start",
11576
+ "bottom-end",
11577
+ "left",
11578
+ "left-start",
11579
+ "left-end",
11580
+ "right",
11581
+ "right-start",
11582
+ "right-end"
11583
+ ];
11535
11584
  if (validList.indexOf(value) < 0) {
11536
11585
  console.error(`placement property is not valid: '${value}'`);
11537
11586
  return false;
@@ -11598,7 +11647,7 @@ const datePickerProps = {
11598
11647
  var Component$1 = defineComponent({
11599
11648
  name: "DatePicker",
11600
11649
  directives: {
11601
- clickoutside
11650
+ clickoutside: ClickOutside
11602
11651
  },
11603
11652
  props: datePickerProps,
11604
11653
  emits: ["open-change", "input", "change", "update:modelValue", "clear", "shortcut-change", "pick-success"],
@@ -11717,6 +11766,7 @@ var Component$1 = defineComponent({
11717
11766
  };
11718
11767
  watch(() => state.visible, (visible) => {
11719
11768
  var _a, _b;
11769
+ console.error(123);
11720
11770
  if (visible === false) {
11721
11771
  (_a = pickerDropdownRef.value) == null ? void 0 : _a.destoryDropdown();
11722
11772
  }
@@ -12244,7 +12294,7 @@ var Transfer = defineComponent({
12244
12294
  if (!typeFlag.value) {
12245
12295
  generalInit();
12246
12296
  } else {
12247
- init2();
12297
+ init();
12248
12298
  }
12249
12299
  }
12250
12300
  };
@@ -12281,7 +12331,7 @@ var Transfer = defineComponent({
12281
12331
  emit("change", dataList.value, [...handleListFormat(hasSelectedList.value, false)], []);
12282
12332
  }
12283
12333
  };
12284
- const init2 = () => {
12334
+ const init = () => {
12285
12335
  if (!props.targetList.length || props.targetList.length > props.sourceList.length) {
12286
12336
  dataList.value.splice(0, dataList.value.length, ...props.sourceList);
12287
12337
  hasSelectedList.value = [];
@@ -12414,7 +12464,7 @@ var Transfer = defineComponent({
12414
12464
  if (!typeFlag.value) {
12415
12465
  generalInit();
12416
12466
  } else {
12417
- init2();
12467
+ init();
12418
12468
  }
12419
12469
  initSort();
12420
12470
  }
@@ -12747,7 +12797,10 @@ const getStringOrFuncStr = (item, props, key, args = []) => {
12747
12797
  };
12748
12798
  const getLabel = (item, props) => getStringOrFuncStr(item, props, "label");
12749
12799
  const getSchemaVal = (schema, uuid2) => schema.get(uuid2) || {};
12750
- const getNodeAttr = (schema, uuid2, key) => (getSchemaVal(schema, uuid2) || {})[key];
12800
+ const getNodeAttr = (schema, uuid2, key) => {
12801
+ var _a;
12802
+ return (_a = getSchemaVal(schema, uuid2)) == null ? void 0 : _a[key];
12803
+ };
12751
12804
  const getTreeStyle = (item, props) => {
12752
12805
  const levelLine = getPropsOneOfBoolValueWithDefault(props, "levelLine", item, DEFAULT_LEVLE_LINE, null, ["tree"]);
12753
12806
  return {
@@ -12758,14 +12811,11 @@ const getTreeStyle = (item, props) => {
12758
12811
  };
12759
12812
  };
12760
12813
  const getNodeItemStyle = (item, props, flatData = {}) => {
12761
- const { levelLineSchema, schema } = flatData;
12762
- const { childNodeCount = 0, isLeaf = false, lastNode = null } = levelLineSchema[item.__uuid] || {};
12763
- const lastNodeCount = isLeaf ? 0 : (levelLineSchema[lastNode] || { childNodeCount: 0 }).childNodeCount;
12814
+ const { schema } = flatData;
12764
12815
  const depth = getNodeAttr(schema, item.__uuid, "__depth");
12765
12816
  return __spreadValues({
12766
12817
  "--depth": depth,
12767
- paddingLeft: 0,
12768
- "--lines": childNodeCount - lastNodeCount
12818
+ paddingLeft: 0
12769
12819
  }, typeof props.levelLine === "function" ? {
12770
12820
  "--level-line": getPropsOneOfBoolValueWithDefault(props, "levelLine", item, DEFAULT_LEVLE_LINE, null, [
12771
12821
  "node"
@@ -12778,16 +12828,20 @@ const getNodeItemClass = (item, schema, props) => {
12778
12828
  "is-root": __isRoot,
12779
12829
  "bk-tree-node": true,
12780
12830
  "is-open": __isOpen,
12781
- "is-virtual-render": props.virtualRender
12831
+ "is-virtual-render": props.virtualRender,
12832
+ "level-line": props.levelLine
12782
12833
  };
12783
12834
  };
12784
12835
  const updateTreeNode = (path, treeData, childKey, nodekey, nodeValue) => {
12836
+ assignTreeNode(path, treeData, childKey, { [nodekey]: nodeValue });
12837
+ };
12838
+ const assignTreeNode = (path, treeData, childKey, assignVal) => {
12785
12839
  const paths = path.split("-");
12786
12840
  const targetNode = paths.reduce((pre, nodeIndex) => {
12787
12841
  const index = Number(nodeIndex);
12788
12842
  return Array.isArray(pre) ? pre[index] : pre[childKey][index];
12789
12843
  }, treeData);
12790
- Object.assign(targetNode, { [nodekey]: nodeValue });
12844
+ Object.assign(targetNode, assignVal || {});
12791
12845
  };
12792
12846
  const treeProps = {
12793
12847
  data: PropTypes.arrayOf(PropTypes.any).def([]),
@@ -12806,7 +12860,10 @@ const treeProps = {
12806
12860
  }),
12807
12861
  PropTypes.bool.def(false)
12808
12862
  ]).def(true),
12809
- asyncLoad: PropTypes.func.def(null)
12863
+ async: PropTypes.shape({
12864
+ callback: PropTypes.func.def(null),
12865
+ cache: PropTypes.bool.def(true)
12866
+ })
12810
12867
  };
12811
12868
  var Component = defineComponent({
12812
12869
  name: "Tree",
@@ -12823,13 +12880,9 @@ var Component = defineComponent({
12823
12880
  const formatData2 = getFlatdata(props, newData, schemaValues.value);
12824
12881
  flatData.data = formatData2[0];
12825
12882
  flatData.schema = formatData2[1];
12826
- computeLevelHeight();
12827
12883
  }, {
12828
12884
  deep: true
12829
12885
  });
12830
- watch(() => [props.levelLine], () => {
12831
- computeLevelHeight();
12832
- });
12833
12886
  const schemaValues = computed(() => Array.from(flatData.schema.values()));
12834
12887
  const getSchemaVal2 = (key) => flatData.schema.get(key);
12835
12888
  const getNodeAttr2 = (node, attr) => {
@@ -12844,7 +12897,6 @@ var Component = defineComponent({
12844
12897
  const isNodeOpened = (node) => getNodeAttr2(node, "__isOpen");
12845
12898
  const hasChildNode = (node) => getNodeAttr2(node, "__hasChild");
12846
12899
  const renderData = computed(() => flatData.data.filter((item) => checkNodeIsOpen(item)));
12847
- const renderNodePathColl = computed(() => renderData.value.map((node) => getNodePath(node)));
12848
12900
  const isItemOpen = (item) => {
12849
12901
  var _a;
12850
12902
  if (typeof item === "object") {
@@ -12912,7 +12964,10 @@ var Component = defineComponent({
12912
12964
  const setNodeOpened = (item) => {
12913
12965
  const newVal = !isItemOpen(item);
12914
12966
  setNodeAttr(item, "__isOpen", newVal);
12915
- computeLevelHeight();
12967
+ if (newVal) {
12968
+ return;
12969
+ }
12970
+ renderData.value.filter((node) => String.prototype.startsWith.call(getNodePath(node), getNodePath(item))).forEach((filterNode) => setNodeAttr(filterNode, "__isOpen", newVal));
12916
12971
  };
12917
12972
  const setNodeRemoteLoad = (resp, item) => {
12918
12973
  if (typeof resp === "object" && resp !== null) {
@@ -12923,12 +12978,20 @@ var Component = defineComponent({
12923
12978
  };
12924
12979
  const hanldeTreeNodeClick = (item) => {
12925
12980
  if (item.async) {
12926
- if (typeof props.asyncLoad === "function") {
12981
+ const {
12982
+ callback = null,
12983
+ cache = true
12984
+ } = props.async || {};
12985
+ if (typeof callback === "function" && !item.cached) {
12927
12986
  Object.assign(item, {
12928
12987
  loading: true
12929
12988
  });
12930
- props.asyncLoad(item, (resp) => setNodeRemoteLoad(resp, item)).then((resp) => setNodeRemoteLoad(resp, item)).catch((err) => console.error("load remote data error:", err)).finally(() => {
12931
- updateTreeNode(getNodePath(item), props.data, props.children, "loading", false);
12989
+ callback(item, (resp) => setNodeRemoteLoad(resp, item)).then((resp) => setNodeRemoteLoad(resp, item)).catch((err) => console.error("load remote data error:", err)).finally(() => {
12990
+ assignTreeNode(getNodePath(item), props.data, props.children, __spreadValues({
12991
+ loading: false
12992
+ }, cache ? {
12993
+ cached: true
12994
+ } : {}));
12932
12995
  });
12933
12996
  } else {
12934
12997
  console.error("async need to set prop: asyncLoad with function wich will return promise object");
@@ -12938,47 +13001,6 @@ var Component = defineComponent({
12938
13001
  setNodeOpened(item);
12939
13002
  }
12940
13003
  };
12941
- const computeLevelHeight = () => {
12942
- if (!!props.levelLine) {
12943
- setTimeout(() => {
12944
- let showNodeCount = renderData.value.length;
12945
- const nodeSchema = {};
12946
- const setDefaultNodeSchema = (uuid2, lastNode = null, isLeaf = false) => {
12947
- if (!Object.prototype.hasOwnProperty.call(nodeSchema, uuid2)) {
12948
- Object.assign(nodeSchema, {
12949
- [uuid2]: __spreadValues(__spreadValues({
12950
- childNodeCount: 0,
12951
- isLastNode: false
12952
- }, lastNode !== null ? {
12953
- lastNode
12954
- } : {}), isLeaf !== null ? {
12955
- isLeaf
12956
- } : {})
12957
- });
12958
- }
12959
- };
12960
- for (; showNodeCount > 0; showNodeCount--) {
12961
- const node = renderData.value[showNodeCount - 1];
12962
- const parentId = getNodeAttr2(node, "__parentId");
12963
- const nodepath = getNodePath(node);
12964
- const isLeaf = !renderNodePathColl.value.includes(`${nodepath}-0`);
12965
- setDefaultNodeSchema(node.__uuid, null, isLeaf);
12966
- setDefaultNodeSchema(parentId, node.__uuid);
12967
- const parentSchema = nodeSchema[parentId];
12968
- const currentNodeSchema = nodeSchema[node.__uuid];
12969
- const {
12970
- childNodeCount = 0
12971
- } = currentNodeSchema;
12972
- currentNodeSchema.childNodeCount = childNodeCount + 1;
12973
- currentNodeSchema.isLastNode = parentSchema.lastNode === node.__uuid;
12974
- parentSchema.childNodeCount += currentNodeSchema.childNodeCount;
12975
- }
12976
- flatData.levelLineSchema = nodeSchema;
12977
- });
12978
- } else {
12979
- flatData.levelLineSchema = {};
12980
- }
12981
- };
12982
13004
  const checkNodeIsOpen = (node) => isRootNode(node) || isItemOpen(node) || isItemOpen(getNodeAttr2(node, "__parentId"));
12983
13005
  const filterNextNode = (depth, node) => {
12984
13006
  if (isRootNode(node)) {
@@ -12997,7 +13019,7 @@ var Component = defineComponent({
12997
13019
  return schemaValues.value.some((val) => val.__path === nextNodePath);
12998
13020
  };
12999
13021
  const getVirtualLines = (node) => {
13000
- if (!props.virtualRender) {
13022
+ if (!props.levelLine) {
13001
13023
  return null;
13002
13024
  }
13003
13025
  const getNodeLineStyle = (dpth) => ({
@@ -13009,7 +13031,6 @@ var Component = defineComponent({
13009
13031
  "style": getNodeLineStyle(maxDeep - index)
13010
13032
  }, null));
13011
13033
  };
13012
- computeLevelHeight();
13013
13034
  return {
13014
13035
  renderData,
13015
13036
  flatData,
@@ -13033,7 +13054,8 @@ var Component = defineComponent({
13033
13054
  "style": getTreeStyle(null, props),
13034
13055
  "list": this.renderData,
13035
13056
  "lineHeight": props.lineHeight,
13036
- "enabled": props.virtualRender
13057
+ "enabled": props.virtualRender,
13058
+ "throttleDelay": 0
13037
13059
  }, {
13038
13060
  default: (scoped) => (scoped.data || []).map(renderTreeNode)
13039
13061
  });
@@ -13395,4 +13417,4 @@ var preset = {
13395
13417
  install: createInstall(),
13396
13418
  version: "0.0.1"
13397
13419
  };
13398
- export { BkAlert as Alert, BkAnimateNumber as AnimateNumber, BkBacktop as Backtop, BkBadge as Badge, BkOption, OptionGroup as BkOptionGroup, BkBreadcrumb as Breadcrumb, BreadcrumbItem, BkButton as Button, ButtonGroup, BkCard as Card, BkCheckbox as Checkbox, CheckboxGroup, BkCollaspe as Collapse, BkDatePicker as DatePicker, BkDialog as Dialog, BkDivider as Divider, BkException as Exception, BkFixedNavbar as FixedNavbar, BkForm as Form, FormItem, BkInput as Input, BkLink as Link, BkLoading as Loading, BkMenu as Menu, Message, BkModal as Modal, Navigation, Notify, BkPopover as Popover, BkProgress as Progress, BkRadio as Radio, RadioButton, RadioGroup, BkRate as Rate, BkSelect as Select, BkSideslider as Sideslider, BkSteps as Steps, BkSwitcher as Switcher, BKTab as Tab, BKTabPanel as TabPanel, BkTable as Table, BkTag as Tag, Transfer, BkTree as Tree, BkVirtualRender as VirtualRender, tooltips as bkTooltips, clickoutside, preset as default, mousewheel };
13420
+ export { BkAlert as Alert, BkAnimateNumber as AnimateNumber, BkBacktop as Backtop, BkBadge as Badge, BkOption, OptionGroup as BkOptionGroup, BkBreadcrumb as Breadcrumb, BreadcrumbItem, BkButton as Button, ButtonGroup, BkCard as Card, BkCheckbox as Checkbox, CheckboxGroup, BkCollaspe as Collapse, BkDatePicker as DatePicker, BkDialog as Dialog, BkDivider as Divider, BkException as Exception, BkFixedNavbar as FixedNavbar, BkForm as Form, FormItem, BkInput as Input, BkLink as Link, BkLoading as Loading, BkMenu as Menu, Message, BkModal as Modal, Navigation, Notify, BkPopover as Popover, BkProgress as Progress, BkRadio as Radio, RadioButton, RadioGroup, BkRate as Rate, BkSelect as Select, BkSideslider as Sideslider, BkSteps as Steps, BkSwitcher as Switcher, BKTab as Tab, BKTabPanel as TabPanel, BkTable as Table, BkTag as Tag, Transfer, BkTree as Tree, BkVirtualRender as VirtualRender, tooltips as bkTooltips, ClickOutside as clickoutside, preset as default, mousewheel };