bkui-vue 2.1.0-dev-beta.10 → 2.1.0-dev-beta.12

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.
@@ -8,6 +8,8 @@ import * as __WEBPACK_EXTERNAL_MODULE__popperjs_core_a5c7319c__ from "@popperjs/
8
8
  import * as __WEBPACK_EXTERNAL_MODULE__loading_4d683b23__ from "../loading";
9
9
  import * as __WEBPACK_EXTERNAL_MODULE__overflow_title_f9bafa47__ from "../overflow-title";
10
10
  import * as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_icon_a97c79c3__ from "../icon";
11
+ import * as __WEBPACK_EXTERNAL_MODULE_lodash_trim_5cdad98c__ from "lodash/trim";
12
+ import * as __WEBPACK_EXTERNAL_MODULE_lodash_isNumber_64d4ca37__ from "lodash/isNumber";
11
13
  /******/ var __webpack_modules__ = ({
12
14
 
13
15
  /***/ 2439:
@@ -1564,6 +1566,14 @@ function calcTextareaHeight(targetElement) {
1564
1566
  hiddenTextarea = undefined;
1565
1567
  return result;
1566
1568
  }
1569
+ ;// CONCATENATED MODULE: external "lodash/trim"
1570
+ var trim_x = y => { var x = {}; __webpack_require__.d(x, y); return x; }
1571
+ var trim_y = x => () => x
1572
+ const trim_namespaceObject = trim_x({ ["default"]: () => __WEBPACK_EXTERNAL_MODULE_lodash_trim_5cdad98c__["default"] });
1573
+ ;// CONCATENATED MODULE: external "lodash/isNumber"
1574
+ var isNumber_x = y => { var x = {}; __webpack_require__.d(x, y); return x; }
1575
+ var isNumber_y = x => () => x
1576
+ const isNumber_namespaceObject = isNumber_x({ ["default"]: () => __WEBPACK_EXTERNAL_MODULE_lodash_isNumber_64d4ca37__["default"] });
1567
1577
  ;// CONCATENATED MODULE: ../../packages/input/src/input.tsx
1568
1578
 
1569
1579
 
@@ -1605,6 +1615,8 @@ function input_objectSpread(e) { for (var r = 1; r < arguments.length; r++) { va
1605
1615
 
1606
1616
 
1607
1617
 
1618
+
1619
+
1608
1620
  var inputType = {
1609
1621
  type: shared_namespaceObject.PropTypes.string.def('text'),
1610
1622
  clearable: shared_namespaceObject.PropTypes.bool,
@@ -1615,9 +1627,9 @@ var inputType = {
1615
1627
  suffixIcon: shared_namespaceObject.PropTypes.string,
1616
1628
  suffix: shared_namespaceObject.PropTypes.string,
1617
1629
  prefix: shared_namespaceObject.PropTypes.string,
1618
- step: shared_namespaceObject.PropTypes.number,
1619
- max: shared_namespaceObject.PropTypes.number,
1620
- min: shared_namespaceObject.PropTypes.number,
1630
+ step: shared_namespaceObject.PropTypes.number.def(1),
1631
+ max: shared_namespaceObject.PropTypes.number.def(Infinity),
1632
+ min: shared_namespaceObject.PropTypes.number.def(-Infinity),
1621
1633
  maxlength: shared_namespaceObject.PropTypes.number,
1622
1634
  maxcharacter: shared_namespaceObject.PropTypes.number,
1623
1635
  behavior: (0,shared_namespaceObject.InputBehaviorType)(),
@@ -1642,7 +1654,8 @@ var inputType = {
1642
1654
  },
1643
1655
  resize: shared_namespaceObject.PropTypes.bool.def(true),
1644
1656
  autosize: shared_namespaceObject.PropTypes.oneOfType([Boolean, Object]).def(false),
1645
- stopPropagation: shared_namespaceObject.PropTypes.bool.def(true)
1657
+ stopPropagation: shared_namespaceObject.PropTypes.bool.def(true),
1658
+ allowEmptyValue: shared_namespaceObject.PropTypes.bool.def(false)
1646
1659
  };
1647
1660
  var EVENTS;
1648
1661
  (function (EVENTS) {
@@ -1670,16 +1683,13 @@ function EventFunction(_value, _evt) {
1670
1683
  function PastEventFunction(_value, _e) {
1671
1684
  return true;
1672
1685
  }
1673
- function CompositionEventFunction(evt) {
1674
- return evt;
1675
- }
1676
1686
  var inputEmitEventsType = (_inputEmitEventsType = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_inputEmitEventsType, EVENTS.UPDATE, EventFunction), EVENTS.FOCUS, function (evt) {
1677
1687
  return evt;
1678
1688
  }), EVENTS.BLUR, function (evt) {
1679
1689
  return evt;
1680
1690
  }), EVENTS.CHANGE, EventFunction), EVENTS.CLEAR, function () {
1681
1691
  return true;
1682
- }), EVENTS.INPUT, EventFunction), EVENTS.KEYPRESS, EventFunction), EVENTS.KEYDOWN, EventFunction), EVENTS.KEYUP, EventFunction), EVENTS.ENTER, EventFunction), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_inputEmitEventsType, EVENTS.PASTE, PastEventFunction), EVENTS.COMPOSITIONSTART, CompositionEventFunction), EVENTS.COMPOSITIONUPDATE, CompositionEventFunction), EVENTS.COMPOSITIONEND, CompositionEventFunction), EVENTS.SEARCH, function (evt) {
1692
+ }), EVENTS.INPUT, EventFunction), EVENTS.KEYPRESS, EventFunction), EVENTS.KEYDOWN, EventFunction), EVENTS.KEYUP, EventFunction), EVENTS.ENTER, EventFunction), _defineProperty(_defineProperty(_inputEmitEventsType, EVENTS.PASTE, PastEventFunction), EVENTS.SEARCH, function (evt) {
1683
1693
  return evt;
1684
1694
  }));
1685
1695
  /* harmony default export */ const input = ((0,external_vue_namespaceObject.defineComponent)({
@@ -1696,7 +1706,6 @@ var inputEmitEventsType = (_inputEmitEventsType = {}, _defineProperty(_definePro
1696
1706
  var formItem = (0,shared_namespaceObject.useFormItem)();
1697
1707
  var t = (0,config_provider_namespaceObject.useLocale)('input');
1698
1708
  var isFocused = (0,external_vue_namespaceObject.ref)(false);
1699
- var isCNInput = (0,external_vue_namespaceObject.ref)(false);
1700
1709
  var isTextArea = (0,external_vue_namespaceObject.computed)(function () {
1701
1710
  return props.type === 'textarea';
1702
1711
  });
@@ -1783,12 +1792,12 @@ var inputEmitEventsType = (_inputEmitEventsType = {}, _defineProperty(_definePro
1783
1792
  });
1784
1793
  var incControlCls = (0,external_vue_namespaceObject.computed)(function () {
1785
1794
  return (0,shared_namespaceObject.classes)({
1786
- 'is-disabled': props.disabled || props.modelValue >= props.max
1795
+ 'is-disabled': props.disabled || Number(props.modelValue) >= props.max
1787
1796
  });
1788
1797
  });
1789
1798
  var decControlCls = (0,external_vue_namespaceObject.computed)(function () {
1790
1799
  return (0,shared_namespaceObject.classes)({
1791
- 'is-disabled': props.disabled || props.modelValue <= props.min
1800
+ 'is-disabled': props.disabled || Number(props.modelValue) <= props.min
1792
1801
  });
1793
1802
  });
1794
1803
  var tooltips = (0,external_vue_namespaceObject.computed)(function () {
@@ -1878,10 +1887,15 @@ var inputEmitEventsType = (_inputEmitEventsType = {}, _defineProperty(_definePro
1878
1887
  });
1879
1888
  }
1880
1889
  function clear() {
1881
- if (props.disabled) return;
1882
- var resetVal = isNumberInput.value ? props.min : '';
1883
- ctx.emit(EVENTS.UPDATE, resetVal, null);
1884
- ctx.emit(EVENTS.CHANGE, resetVal, null);
1890
+ if (props.disabled) {
1891
+ return;
1892
+ }
1893
+ var value = '';
1894
+ if (props.type === 'number' && !props.allowEmptyValue) {
1895
+ value = props.min !== -Infinity ? props.min : 0;
1896
+ }
1897
+ ctx.emit(EVENTS.UPDATE, value, null);
1898
+ ctx.emit(EVENTS.CHANGE, value, null);
1885
1899
  ctx.emit(EVENTS.CLEAR);
1886
1900
  }
1887
1901
  function handleFocus(e) {
@@ -1904,10 +1918,16 @@ var inputEmitEventsType = (_inputEmitEventsType = {}, _defineProperty(_definePro
1904
1918
  function eventHandler(eventName) {
1905
1919
  return function (e) {
1906
1920
  props.stopPropagation && e.stopPropagation();
1921
+ if (e.isComposing) {
1922
+ // 跳过输入法复合事件
1923
+ return;
1924
+ }
1925
+ var inputValue = (0,trim_namespaceObject["default"])(e.target.value) || '';
1926
+ // 字符类型输入框才会有这种场景
1907
1927
  if (showMaxLimit.value && !props.overMaxLengthLimit) {
1908
- var limit = getValueLimits(e.target.value);
1909
- if (limit.len >= ceilMaxLength.value && (eventName === EVENTS.KEYDOWN || eventName === EVENTS.INPUT) && !isCNInput.value) {
1910
- var val = limit.pos > 0 ? e.target.value.slice(0, limit.pos) : e.target.value;
1928
+ var limit = getValueLimits(inputValue);
1929
+ if (limit.len >= ceilMaxLength.value && (eventName === EVENTS.KEYDOWN || eventName === EVENTS.INPUT)) {
1930
+ var val = limit.pos > 0 ? "".concat(inputValue).slice(0, limit.pos) : inputValue;
1911
1931
  innerInputValue.value = {
1912
1932
  value: val
1913
1933
  };
@@ -1916,44 +1936,37 @@ var inputEmitEventsType = (_inputEmitEventsType = {}, _defineProperty(_definePro
1916
1936
  return;
1917
1937
  }
1918
1938
  }
1919
- if (eventName === EVENTS.KEYDOWN && (e.code === 'Enter' || e.key === 'Enter' || e.keyCode === 13)) {
1920
- ctx.emit(EVENTS.ENTER, isNumberInput.value ? handleNumber(e.target.value, 0) : e.target.value, e);
1921
- }
1922
- if (isCNInput.value && [EVENTS.INPUT, EVENTS.CHANGE, EVENTS.KEYDOWN].some(function (e) {
1923
- return eventName === e;
1924
- })) return;
1925
- if (eventName === EVENTS.INPUT) {
1926
- // ctx.emit(EVENTS.UPDATE, isNumberInput.value ? handleNumber(e.target.value, 0) : e.target.value, e);
1927
- ctx.emit(EVENTS.UPDATE, isNumberInput.value ?
1928
- // 这里不直接使用 handleNumber,是因为 handleNumber 里有 min 和 max 的判断
1929
- // https://github.com/TencentBlueKing/bkui-vue3/issues/2426
1930
- function () {
1931
- var precision = Number.isInteger(props.precision) ? props.precision : 0;
1932
- var val = e.target.value;
1933
- if (Number.isNaN(val)) {
1934
- return isNum(props.min) ? props.min : 0;
1935
- }
1936
- if (val === '' || val === null || val === undefined) {
1937
- return '';
1939
+ // 数字输入框需要处理空值和类型转换
1940
+ if (props.type === 'number') {
1941
+ if (inputValue === '') {
1942
+ // 处理空值(默认为0,可通过allowEmptyValue控制)
1943
+ if (!props.allowEmptyValue) {
1944
+ inputValue = props.min !== -Infinity ? props.min : 0;
1938
1945
  }
1939
- // 输入过程中只截断超出 precision 的多余小数位,不用 toFixed 补零
1940
- // 完整的精度格式化在 CHANGE(失焦)时由 handleNumber 处理
1941
- var dotIndex = val.indexOf('.');
1942
- if (precision === 0) {
1943
- return dotIndex > -1 ? val.slice(0, dotIndex) : val;
1944
- }
1945
- if (dotIndex > -1 && val.length - dotIndex - 1 > precision) {
1946
- return val.slice(0, dotIndex + precision + 1);
1947
- }
1948
- return val;
1949
- }() : e.target.value, e);
1950
- } else if (eventName === EVENTS.CHANGE && isNumberInput.value) {
1951
- var _val = handleNumber(e.target.value, 0);
1952
- ctx.emit(EVENTS.UPDATE, _val, e);
1953
- ctx.emit(eventName, _val, e);
1954
- return;
1946
+ } else {
1947
+ inputValue = Number(Number(inputValue).toFixed(props.precision));
1948
+ }
1949
+ }
1950
+ if (eventName === EVENTS.KEYDOWN && e.code === 'Enter') {
1951
+ // 输入框值改变时,数字输入框需要限制最大最小值
1952
+ if ((0,isNumber_namespaceObject["default"])(inputValue)) {
1953
+ inputValue = Math.min(Math.max(Number(inputValue), props.min), props.max);
1954
+ }
1955
+ ctx.emit(EVENTS.ENTER, inputValue, e);
1956
+ ctx.emit(EVENTS.UPDATE, inputValue, e);
1957
+ } else if (eventName === EVENTS.INPUT) {
1958
+ ctx.emit(EVENTS.INPUT, inputValue, e);
1959
+ ctx.emit(EVENTS.UPDATE, inputValue, e);
1960
+ } else if (eventName === EVENTS.CHANGE) {
1961
+ // 输入框值改变时,数字输入框需要限制最大最小值
1962
+ if ((0,isNumber_namespaceObject["default"])(inputValue)) {
1963
+ inputValue = Math.min(Math.max(Number(inputValue), props.min), props.max);
1964
+ }
1965
+ ctx.emit(EVENTS.CHANGE, inputValue, e);
1966
+ ctx.emit(EVENTS.UPDATE, inputValue, e);
1967
+ } else {
1968
+ ctx.emit(eventName, inputValue, e);
1955
1969
  }
1956
- ctx.emit(eventName, isNumberInput.value ? handleNumber(e.target.value, 0) : e.target.value, e);
1957
1970
  };
1958
1971
  }
1959
1972
  var _map = [EVENTS.KEYUP, EVENTS.KEYDOWN, EVENTS.KEYPRESS, EVENTS.PASTE, EVENTS.CHANGE, EVENTS.INPUT].map(eventHandler),
@@ -1964,47 +1977,21 @@ var inputEmitEventsType = (_inputEmitEventsType = {}, _defineProperty(_definePro
1964
1977
  handlePaste = _map2[3],
1965
1978
  handleChange = _map2[4],
1966
1979
  handleInput = _map2[5];
1967
- // 输入法启用时
1968
- function handleCompositionStart() {
1969
- isCNInput.value = true;
1970
- }
1971
- // 输入法输入结束时
1972
- function handleCompositionEnd(e) {
1973
- isCNInput.value = false;
1974
- handleInput(e);
1975
- }
1976
- function isNum(num) {
1977
- return typeof num === 'number' && !Number.isNaN(num);
1978
- }
1979
- function handleNumber(modelValue, step) {
1980
- var INC = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
1981
- var numStep = Number(step);
1982
- var factor = isNum(numStep) ? numStep : 1;
1983
- var precision = Number.isInteger(props.precision) ? props.precision : 0;
1984
- var val = Number(modelValue);
1985
- if (Number.isNaN(val)) {
1986
- return isNum(props.min) ? props.min : 0;
1987
- }
1988
- var newVal = val + (INC ? factor : -1 * factor);
1989
- if (isNum(props.max)) {
1990
- newVal = Math.min(newVal, props.max);
1991
- }
1992
- if (isNum(props.min)) {
1993
- newVal = Math.max(newVal, props.min);
1994
- }
1995
- return +newVal.toFixed(precision);
1996
- }
1997
1980
  function handleInc(e) {
1998
- if (props.disabled) return;
1999
- var newVal = handleNumber(props.modelValue, props.step);
2000
- ctx.emit(EVENTS.UPDATE, newVal, e);
2001
- ctx.emit(EVENTS.CHANGE, newVal, e);
1981
+ if (props.disabled) {
1982
+ return;
1983
+ }
1984
+ var newValue = Number(Math.min(Number(props.modelValue) + props.step, props.max).toFixed(props.precision));
1985
+ ctx.emit(EVENTS.UPDATE, newValue, e);
1986
+ ctx.emit(EVENTS.CHANGE, newValue, e);
2002
1987
  }
2003
1988
  function handleDec(e) {
2004
- if (props.disabled) return;
2005
- var newVal = handleNumber(props.modelValue, props.step, false);
2006
- ctx.emit(EVENTS.UPDATE, newVal, e);
2007
- ctx.emit(EVENTS.CHANGE, newVal, e);
1989
+ if (props.disabled) {
1990
+ return;
1991
+ }
1992
+ var newValue = Number(Math.max(Number(props.modelValue) - props.step, props.min).toFixed(props.precision));
1993
+ ctx.emit(EVENTS.UPDATE, newValue, e);
1994
+ ctx.emit(EVENTS.CHANGE, newValue, e);
2008
1995
  }
2009
1996
  function getCls(name) {
2010
1997
  return "".concat(inputClsPrefix.value, "--").concat(name);
@@ -2028,9 +2015,7 @@ var inputEmitEventsType = (_inputEmitEventsType = {}, _defineProperty(_definePro
2028
2015
  onChange: handleChange,
2029
2016
  onKeypress: handleKeyPress,
2030
2017
  onKeydown: handleKeydown,
2031
- onKeyup: handleKeyup,
2032
- onCompositionstart: handleCompositionStart,
2033
- onCompositionend: handleCompositionEnd
2018
+ onKeyup: handleKeyup
2034
2019
  };
2035
2020
  return function () {
2036
2021
  var _ctx$slots$prefix, _ctx$slots, _ctx$slots$prefix2, _ctx$slots$suffix, _ctx$slots2, _ctx$slots2$suffix;
@@ -38,12 +38,18 @@ export declare const inputType: {
38
38
  };
39
39
  step: import("vue-types").VueTypeValidableDef<number> & {
40
40
  default: number;
41
+ } & {
42
+ default: number;
41
43
  };
42
44
  max: import("vue-types").VueTypeValidableDef<number> & {
43
45
  default: number;
46
+ } & {
47
+ default: number;
44
48
  };
45
49
  min: import("vue-types").VueTypeValidableDef<number> & {
46
50
  default: number;
51
+ } & {
52
+ default: number;
47
53
  };
48
54
  maxlength: import("vue-types").VueTypeValidableDef<number> & {
49
55
  default: number;
@@ -116,6 +122,11 @@ export declare const inputType: {
116
122
  } & {
117
123
  default: boolean;
118
124
  };
125
+ allowEmptyValue: import("vue-types").VueTypeValidableDef<boolean> & {
126
+ default: boolean;
127
+ } & {
128
+ default: boolean;
129
+ };
119
130
  };
120
131
  export declare const enum EVENTS {
121
132
  BLUR = "blur",
@@ -136,7 +147,6 @@ export declare const enum EVENTS {
136
147
  }
137
148
  declare function EventFunction(_value: any, _evt: KeyboardEvent): any;
138
149
  declare function PastEventFunction(_value: any, _e: ClipboardEvent): boolean;
139
- declare function CompositionEventFunction(evt: CompositionEvent): CompositionEvent;
140
150
  export declare const inputEmitEventsType: {
141
151
  "update:modelValue": typeof EventFunction;
142
152
  focus: (evt: FocusEvent) => FocusEvent;
@@ -149,9 +159,6 @@ export declare const inputEmitEventsType: {
149
159
  keyup: typeof EventFunction;
150
160
  enter: typeof EventFunction;
151
161
  paste: typeof PastEventFunction;
152
- compositionstart: typeof CompositionEventFunction;
153
- compositionupdate: typeof CompositionEventFunction;
154
- compositionend: typeof CompositionEventFunction;
155
162
  search: (evt: Event) => Event;
156
163
  };
157
164
  export type InputType = ExtractPropTypes<typeof inputType>;
@@ -189,12 +196,18 @@ declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
189
196
  };
190
197
  step: import("vue-types").VueTypeValidableDef<number> & {
191
198
  default: number;
199
+ } & {
200
+ default: number;
192
201
  };
193
202
  max: import("vue-types").VueTypeValidableDef<number> & {
194
203
  default: number;
204
+ } & {
205
+ default: number;
195
206
  };
196
207
  min: import("vue-types").VueTypeValidableDef<number> & {
197
208
  default: number;
209
+ } & {
210
+ default: number;
198
211
  };
199
212
  maxlength: import("vue-types").VueTypeValidableDef<number> & {
200
213
  default: number;
@@ -267,6 +280,11 @@ declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
267
280
  } & {
268
281
  default: boolean;
269
282
  };
283
+ allowEmptyValue: import("vue-types").VueTypeValidableDef<boolean> & {
284
+ default: boolean;
285
+ } & {
286
+ default: boolean;
287
+ };
270
288
  }>, () => JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
271
289
  "update:modelValue": typeof EventFunction;
272
290
  focus: (evt: FocusEvent) => FocusEvent;
@@ -279,9 +297,6 @@ declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
279
297
  keyup: typeof EventFunction;
280
298
  enter: typeof EventFunction;
281
299
  paste: typeof PastEventFunction;
282
- compositionstart: typeof CompositionEventFunction;
283
- compositionupdate: typeof CompositionEventFunction;
284
- compositionend: typeof CompositionEventFunction;
285
300
  search: (evt: Event) => Event;
286
301
  }, string, import("vue").PublicProps, Readonly<ExtractPropTypes<{
287
302
  type: import("vue-types").VueTypeValidableDef<string> & {
@@ -317,12 +332,18 @@ declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
317
332
  };
318
333
  step: import("vue-types").VueTypeValidableDef<number> & {
319
334
  default: number;
335
+ } & {
336
+ default: number;
320
337
  };
321
338
  max: import("vue-types").VueTypeValidableDef<number> & {
322
339
  default: number;
340
+ } & {
341
+ default: number;
323
342
  };
324
343
  min: import("vue-types").VueTypeValidableDef<number> & {
325
344
  default: number;
345
+ } & {
346
+ default: number;
326
347
  };
327
348
  maxlength: import("vue-types").VueTypeValidableDef<number> & {
328
349
  default: number;
@@ -395,13 +416,15 @@ declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
395
416
  } & {
396
417
  default: boolean;
397
418
  };
419
+ allowEmptyValue: import("vue-types").VueTypeValidableDef<boolean> & {
420
+ default: boolean;
421
+ } & {
422
+ default: boolean;
423
+ };
398
424
  }>> & Readonly<{
399
425
  onBlur?: (evt: FocusEvent) => any;
400
426
  onChange?: (_value: any, _evt: KeyboardEvent) => any;
401
427
  onClear?: () => any;
402
- onCompositionend?: (evt: CompositionEvent) => any;
403
- onCompositionstart?: (evt: CompositionEvent) => any;
404
- onCompositionupdate?: (evt: CompositionEvent) => any;
405
428
  onEnter?: (_value: any, _evt: KeyboardEvent) => any;
406
429
  onFocus?: (evt: FocusEvent) => any;
407
430
  onInput?: (_value: any, _evt: KeyboardEvent) => any;
@@ -440,6 +463,7 @@ declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
440
463
  showOverflowTooltips: boolean;
441
464
  tooltipsOptions: Partial<IOptions>;
442
465
  autosize: boolean | InputAutoSize;
466
+ allowEmptyValue: boolean;
443
467
  }, {}, {}, {
444
468
  bkTooltips: import("vue").ObjectDirective<any, any, string, any>;
445
469
  }, string, import("vue").ComponentProvideOptions, true, {}, any>;