assui 2.0.121 → 2.0.124

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/es/condition-input/index.d.ts +2 -1
  2. package/es/condition-input/index.js +11 -18
  3. package/es/index.d.ts +4 -0
  4. package/es/index.js +2 -0
  5. package/es/keep-tab/index.js +1 -1
  6. package/es/label-auto-complete/style/index.less +1 -1
  7. package/es/label-condition-input/index.d.ts +17 -0
  8. package/es/label-condition-input/index.js +118 -0
  9. package/es/label-condition-input/style/index.css +43 -0
  10. package/es/label-condition-input/style/index.d.ts +1 -0
  11. package/es/label-condition-input/style/index.js +1 -0
  12. package/es/label-condition-input/style/index.less +59 -0
  13. package/es/label-number-input/index.d.ts +15 -0
  14. package/es/label-number-input/index.js +117 -0
  15. package/es/label-number-input/style/index.css +43 -0
  16. package/es/label-number-input/style/index.d.ts +1 -0
  17. package/es/label-number-input/style/index.js +1 -0
  18. package/es/label-number-input/style/index.less +59 -0
  19. package/es/label-select/index.js +1 -1
  20. package/es/label-text-area/index.js +1 -1
  21. package/es/number-input/index.d.ts +4 -3
  22. package/es/number-input/index.js +28 -41
  23. package/lib/condition-input/index.d.ts +2 -1
  24. package/lib/condition-input/index.js +13 -18
  25. package/lib/index.d.ts +4 -0
  26. package/lib/index.js +18 -0
  27. package/lib/keep-tab/index.js +1 -1
  28. package/lib/label-auto-complete/style/index.less +1 -1
  29. package/lib/label-condition-input/index.d.ts +17 -0
  30. package/lib/label-condition-input/index.js +135 -0
  31. package/lib/label-condition-input/style/index.css +43 -0
  32. package/lib/label-condition-input/style/index.d.ts +1 -0
  33. package/lib/label-condition-input/style/index.js +7 -0
  34. package/lib/label-condition-input/style/index.less +59 -0
  35. package/lib/label-number-input/index.d.ts +15 -0
  36. package/lib/label-number-input/index.js +135 -0
  37. package/lib/label-number-input/style/index.css +43 -0
  38. package/lib/label-number-input/style/index.d.ts +1 -0
  39. package/lib/label-number-input/style/index.js +7 -0
  40. package/lib/label-number-input/style/index.less +59 -0
  41. package/lib/label-select/index.js +2 -2
  42. package/lib/label-text-area/index.js +2 -2
  43. package/lib/number-input/index.d.ts +4 -3
  44. package/lib/number-input/index.js +29 -41
  45. package/package.json +2 -2
@@ -56,30 +56,30 @@ var __read = this && this.__read || function (o, n) {
56
56
 
57
57
  import * as React from 'react';
58
58
  import Input from 'antd/es/input';
59
- import isUndefined from 'lodash/isUndefined';
59
+ import useControllableValue from 'ahooks/lib/useControllableValue';
60
+ import omit from 'lodash/omit';
60
61
  import * as dataTypeEnum from './const/dataTypeEnum';
61
62
  import * as numberTypeEnum from './const/numberType';
62
63
  import { filterInt, filterFloat } from './utils';
63
64
  var NumberInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
64
- var value = props.value,
65
- onChange = props.onChange,
66
- _a = props.numberType,
67
- numberType = _a === void 0 ? numberTypeEnum.INT : _a,
68
- _b = props.dataType,
69
- dataType = _b === void 0 ? dataTypeEnum.NUMBER : _b,
65
+ var _a = __read(useControllableValue(props, {
66
+ defaultValue: ''
67
+ }), 2),
68
+ value = _a[0],
69
+ setValue = _a[1];
70
+
71
+ var onChange = props.onChange,
72
+ _b = props.numberType,
73
+ numberType = _b === void 0 ? numberTypeEnum.INT : _b,
74
+ _c = props.dataType,
75
+ dataType = _c === void 0 ? dataTypeEnum.NUMBER : _c,
70
76
  precision = props.precision,
71
77
  formatter = props.formatter,
72
78
  parser = props.parser,
73
79
  enableMinus = props.enableMinus,
74
80
  onBlur = props.onBlur,
75
81
  maxLength = props.maxLength,
76
- restProps = __rest(props, ["value", "onChange", "numberType", "dataType", "precision", "formatter", "parser", "enableMinus", "onBlur", "maxLength"]);
77
-
78
- var _c = __read(React.useState(''), 2),
79
- inputValue = _c[0],
80
- setInputValue = _c[1];
81
-
82
- var resultValue = isUndefined(value) ? inputValue : value;
82
+ restProps = __rest(props, ["onChange", "numberType", "dataType", "precision", "formatter", "parser", "enableMinus", "onBlur", "maxLength"]);
83
83
 
84
84
  var onNumberChange = function onNumberChange(e) {
85
85
  var newNumber;
@@ -88,13 +88,13 @@ var NumberInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
88
88
  if (numberType === numberTypeEnum.INT) {
89
89
  newNumber = filterInt({
90
90
  value: newValue,
91
- preValue: "" + resultValue,
91
+ preValue: "" + value,
92
92
  enableMinus: enableMinus
93
93
  });
94
94
  } else {
95
95
  newNumber = filterFloat({
96
96
  value: newValue,
97
- preValue: "" + resultValue,
97
+ preValue: "" + value,
98
98
  precision: precision !== null && precision !== void 0 ? precision : 2,
99
99
  enableMinus: enableMinus
100
100
  });
@@ -104,42 +104,29 @@ var NumberInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
104
104
  newNumber = parser(newNumber);
105
105
  }
106
106
 
107
- if (resultValue !== newNumber) {
108
- if (value === undefined) {
109
- setInputValue(newNumber);
110
- }
111
-
112
- if (onChange) {
113
- onChange(newNumber);
114
- }
107
+ if (value !== newNumber) {
108
+ setValue(newNumber);
115
109
  }
116
110
  };
117
111
 
118
112
  var onNumberBlur = function onNumberBlur() {
119
- if (resultValue === '-' || resultValue === '.') {
120
- if (value === undefined) {
121
- setInputValue('');
122
- }
113
+ var resultValue = value;
123
114
 
124
- if (onChange) {
125
- onChange('');
126
- }
127
- }
128
-
129
- if (dataType === dataTypeEnum.NUMBER && resultValue) {
115
+ if (value === '-' || value === '.') {
116
+ resultValue = '';
117
+ } else if (value && dataType === dataTypeEnum.NUMBER) {
130
118
  if (numberType === numberTypeEnum.FLOAT) {
131
- onChange && onChange(+resultValue);
119
+ resultValue = +value;
132
120
  } else {
133
- onChange && onChange(parseInt("" + resultValue, 10));
121
+ resultValue = parseInt("" + value, 10);
134
122
  }
135
123
  }
136
124
 
137
- if (onBlur) {
138
- onBlur("" + resultValue);
139
- }
125
+ setValue(resultValue);
126
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(resultValue);
140
127
  };
141
128
 
142
- var finallyValue = formatter ? formatter("" + resultValue) : resultValue;
129
+ var finallyValue = formatter ? formatter("" + value) : value;
143
130
  return /*#__PURE__*/React.createElement(Input, __assign({
144
131
  type: "text",
145
132
  ref: ref,
@@ -147,7 +134,7 @@ var NumberInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
147
134
  onBlur: onNumberBlur,
148
135
  onChange: onNumberChange,
149
136
  maxLength: maxLength
150
- }, restProps));
137
+ }, omit(restProps, ['value'])));
151
138
  });
152
139
  NumberInput.defaultProps = {
153
140
  enableMinus: false
@@ -1,3 +1,4 @@
1
+ import * as React from 'react';
1
2
  import type { InputProps } from 'antd/es/input';
2
3
  export interface ConditionInputProps extends Omit<InputProps, 'onChange'> {
3
4
  /** 过滤的正则条件 */
@@ -12,5 +13,5 @@ export interface ConditionInputProps extends Omit<InputProps, 'onChange'> {
12
13
  /** 输入框内容 */
13
14
  value?: string;
14
15
  }
15
- declare const ConditionInput: (props: ConditionInputProps) => JSX.Element;
16
+ declare const ConditionInput: React.ForwardRefExoticComponent<ConditionInputProps & React.RefAttributes<unknown>>;
16
17
  export default ConditionInput;
@@ -108,20 +108,19 @@ var input_1 = __importDefault(require("antd/es/input"));
108
108
 
109
109
  var isFunction_1 = __importDefault(require("lodash/isFunction"));
110
110
 
111
+ var useControllableValue_1 = __importDefault(require("ahooks/lib/useControllableValue"));
112
+
111
113
  var parse2RegexOption_1 = __importDefault(require("./parse2RegexOption"));
112
114
 
113
- var ConditionInput = function ConditionInput(props) {
115
+ var ConditionInput = React.forwardRef(function (props, ref) {
116
+ var _a = __read(useControllableValue_1["default"](props), 2),
117
+ value = _a[0],
118
+ setValue = _a[1];
119
+
114
120
  var regexp = props.regexp,
115
121
  formatter = props.formatter,
116
- value = props.value,
117
122
  onChange = props.onChange,
118
- rest = __rest(props, ["regexp", "formatter", "value", "onChange"]);
119
-
120
- var _a = __read(React.useState(''), 2),
121
- stateValue = _a[0],
122
- setStateValue = _a[1];
123
-
124
- var resultValue = value === undefined ? stateValue : value;
123
+ rest = __rest(props, ["regexp", "formatter", "onChange"]);
125
124
 
126
125
  var handleChange = function handleChange(e) {
127
126
  var originalValue = e.target.value;
@@ -144,19 +143,15 @@ var ConditionInput = function ConditionInput(props) {
144
143
  nextValue = formatter(nextValue);
145
144
  }
146
145
 
147
- if (resultValue !== nextValue) {
148
- setStateValue(nextValue);
149
-
150
- if (onChange) {
151
- onChange(nextValue);
152
- }
146
+ if (value !== nextValue) {
147
+ setValue(nextValue);
153
148
  }
154
149
  };
155
150
 
156
151
  return React.createElement(input_1["default"], __assign({
157
- value: resultValue,
152
+ ref: ref,
153
+ value: value,
158
154
  onChange: handleChange
159
155
  }, rest));
160
- };
161
-
156
+ });
162
157
  exports["default"] = ConditionInput;
package/lib/index.d.ts CHANGED
@@ -46,6 +46,10 @@ export type { LabelDatePickerProps } from './label-date-picker';
46
46
  export { default as LabelDatePicker } from './label-date-picker';
47
47
  export type { LabelAutoCompleteProps } from './label-auto-complete';
48
48
  export { default as LabelAutoComplete } from './label-auto-complete';
49
+ export type { LabelNumberInputProps } from './label-number-input';
50
+ export { default as LabelNumberInput } from './label-number-input';
51
+ export type { LabelConditionInputProps } from './label-condition-input';
52
+ export { default as LabelConditionInput } from './label-condition-input';
49
53
  export type { LabelTreeSelectProps } from './label-tree-select';
50
54
  export { default as LabelTreeSelect } from './label-tree-select';
51
55
  export type { LabelCustomizeRangePickerProps } from './label-customize-range-picker';
package/lib/index.js CHANGED
@@ -229,6 +229,24 @@ Object.defineProperty(exports, "LabelAutoComplete", {
229
229
  }
230
230
  });
231
231
 
232
+ var label_number_input_1 = require("./label-number-input");
233
+
234
+ Object.defineProperty(exports, "LabelNumberInput", {
235
+ enumerable: true,
236
+ get: function get() {
237
+ return label_number_input_1["default"];
238
+ }
239
+ });
240
+
241
+ var label_condition_input_1 = require("./label-condition-input");
242
+
243
+ Object.defineProperty(exports, "LabelConditionInput", {
244
+ enumerable: true,
245
+ get: function get() {
246
+ return label_condition_input_1["default"];
247
+ }
248
+ });
249
+
232
250
  var label_tree_select_1 = require("./label-tree-select");
233
251
 
234
252
  Object.defineProperty(exports, "LabelTreeSelect", {
@@ -112,7 +112,7 @@ var tabs_1 = __importDefault(require("antd/es/tabs"));
112
112
 
113
113
  var use_url_state_1 = __importDefault(require("@ahooksjs/use-url-state"));
114
114
 
115
- var useControllableValue_1 = __importDefault(require("ahooks/es/useControllableValue"));
115
+ var useControllableValue_1 = __importDefault(require("ahooks/lib/useControllableValue"));
116
116
 
117
117
  var toArray_1 = __importDefault(require("rc-util/lib/Children/toArray"));
118
118
 
@@ -34,7 +34,7 @@
34
34
  padding-top: 17px;
35
35
  padding-left: 4px;
36
36
 
37
- .ant-select-selection-search-input {
37
+ .@{ant-prefix}-select-selection-search-input {
38
38
  height: auto !important;
39
39
  font-size: @font-size-base;
40
40
  }
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import type { ConditionInputProps } from '../condition-input';
3
+ export interface LabelConditionInputProps extends ConditionInputProps {
4
+ /** label 标签的文本 */
5
+ label?: React.ReactNode;
6
+ /** 输入框内容变化时的回调 */
7
+ onChange?: (value: string) => void;
8
+ /** 输入框除去label之后的最小末尾宽度 */
9
+ baseMinWidth?: number;
10
+ /** 组件dom id */
11
+ id?: string;
12
+ }
13
+ declare const LabelConditionInput: {
14
+ (props: LabelConditionInputProps): JSX.Element;
15
+ Option: new (text?: string | undefined, value?: string | undefined, defaultSelected?: boolean | undefined, selected?: boolean | undefined) => HTMLOptionElement;
16
+ };
17
+ export default LabelConditionInput;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+
8
+ for (var p in s) {
9
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
10
+ }
11
+ }
12
+
13
+ return t;
14
+ };
15
+
16
+ return __assign.apply(this, arguments);
17
+ };
18
+
19
+ var __read = this && this.__read || function (o, n) {
20
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
21
+ if (!m) return o;
22
+ var i = m.call(o),
23
+ r,
24
+ ar = [],
25
+ e;
26
+
27
+ try {
28
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
29
+ ar.push(r.value);
30
+ }
31
+ } catch (error) {
32
+ e = {
33
+ error: error
34
+ };
35
+ } finally {
36
+ try {
37
+ if (r && !r.done && (m = i["return"])) m.call(i);
38
+ } finally {
39
+ if (e) throw e.error;
40
+ }
41
+ }
42
+
43
+ return ar;
44
+ };
45
+
46
+ var __importDefault = this && this.__importDefault || function (mod) {
47
+ return mod && mod.__esModule ? mod : {
48
+ "default": mod
49
+ };
50
+ };
51
+
52
+ Object.defineProperty(exports, "__esModule", {
53
+ value: true
54
+ });
55
+
56
+ var react_1 = __importDefault(require("react"));
57
+
58
+ var classnames_1 = __importDefault(require("classnames"));
59
+
60
+ var omit_1 = __importDefault(require("lodash/omit"));
61
+
62
+ var useControllableValue_1 = __importDefault(require("ahooks/lib/useControllableValue"));
63
+
64
+ var useSize_1 = __importDefault(require("ahooks/lib/useSize"));
65
+
66
+ var condition_input_1 = __importDefault(require("../condition-input"));
67
+
68
+ var LabelConditionInput = function LabelConditionInput(props) {
69
+ var className = props.className,
70
+ label = props.label,
71
+ onBlur = props.onBlur,
72
+ id = props.id,
73
+ onFocus = props.onFocus,
74
+ _a = props.baseMinWidth,
75
+ baseMinWidth = _a === void 0 ? 50 : _a;
76
+
77
+ var _b = __read(useControllableValue_1["default"](props), 2),
78
+ value = _b[0],
79
+ setValue = _b[1];
80
+
81
+ var labelDomRef = react_1["default"].useRef(null);
82
+ var labelSize = useSize_1["default"](labelDomRef);
83
+ var InputDomRef = react_1["default"].useRef(null);
84
+
85
+ var _c = __read(react_1["default"].useState(false), 2),
86
+ focused = _c[0],
87
+ setFocused = _c[1];
88
+
89
+ var handleLabelClick = function handleLabelClick() {
90
+ var _a;
91
+
92
+ setFocused(true);
93
+ (_a = InputDomRef.current) === null || _a === void 0 ? void 0 : _a.focus();
94
+ };
95
+
96
+ var handleFocus = function handleFocus() {
97
+ setFocused(true);
98
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(value);
99
+ };
100
+
101
+ var handleBlur = function handleBlur(e) {
102
+ setFocused(false);
103
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
104
+ };
105
+
106
+ var controlMinWidth = (labelSize === null || labelSize === void 0 ? void 0 : labelSize.width) ? labelSize.width + baseMinWidth : undefined;
107
+ return react_1["default"].createElement("div", {
108
+ className: classnames_1["default"]('label-condition-input-warper', className),
109
+ id: id,
110
+ style: {
111
+ minWidth: controlMinWidth
112
+ }
113
+ }, react_1["default"].createElement("div", {
114
+ className: classnames_1["default"]('label-condition-input-field', {
115
+ 'label-condition-input-focused': focused || value
116
+ })
117
+ }, react_1["default"].createElement(condition_input_1["default"], __assign({}, omit_1["default"](props, ['onChange', 'onBlur', 'onFocus', 'className', 'label', 'placeholder']), {
118
+ ref: InputDomRef,
119
+ "data-value": value ? value.length : 0,
120
+ value: value,
121
+ onBlur: handleBlur,
122
+ onFocus: handleFocus,
123
+ className: "label-condition-input",
124
+ onChange: function onChange(inputValue) {
125
+ return setValue(inputValue);
126
+ }
127
+ })), react_1["default"].createElement("label", {
128
+ ref: labelDomRef,
129
+ className: "label-condition-input-text",
130
+ onClick: handleLabelClick
131
+ }, label)));
132
+ };
133
+
134
+ exports["default"] = LabelConditionInput;
135
+ LabelConditionInput.Option = Option;
@@ -0,0 +1,43 @@
1
+ .label-condition-input {
2
+ z-index: 1;
3
+ width: 100%;
4
+ height: 100%;
5
+ padding: 19px 15px 2px 15px;
6
+ color: #263241;
7
+ font-size: 14px;
8
+ line-height: 16px;
9
+ border: 0;
10
+ outline: 0;
11
+ }
12
+ .label-condition-input:focus + label,
13
+ .label-condition-input:not([data-value='0']) + label {
14
+ transform: translateY(-8px) scale(0.8);
15
+ }
16
+ .label-condition-input-field {
17
+ height: 45px;
18
+ overflow: hidden;
19
+ border: 1px solid #e5e5e5;
20
+ border-radius: 8px;
21
+ transition: border 0.3s;
22
+ }
23
+ .label-condition-input-focused {
24
+ border-color: #000;
25
+ }
26
+ .label-condition-input-warper {
27
+ position: relative;
28
+ width: 100%;
29
+ height: 100%;
30
+ }
31
+ .label-condition-input-text {
32
+ position: absolute;
33
+ top: 12px;
34
+ left: 15px;
35
+ z-index: 2;
36
+ height: 20px;
37
+ color: #9aa5b5;
38
+ font-size: 14px;
39
+ line-height: 20px;
40
+ transform-origin: top left;
41
+ cursor: text;
42
+ transition: all 0.2s ease-out;
43
+ }
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ require("./index.less");
@@ -0,0 +1,59 @@
1
+ @import '../../style/themes/default.less';
2
+
3
+ @color_263241: #263241;
4
+ @color_9aa5b5: #9aa5b5;
5
+ @color_e5e5e5: #e5e5e5;
6
+
7
+ @font-size-base: 14px;
8
+ @font-size-lg: @font-size-base + 2px;
9
+
10
+ @font-weight-500: 500;
11
+
12
+ .label-condition-input {
13
+ z-index: 1;
14
+ width: 100%;
15
+ height: 100%;
16
+ padding: 19px 15px 2px 15px;
17
+ color: @color_263241;
18
+ font-size: @font-size-base;
19
+ line-height: 16px;
20
+ border: 0;
21
+ outline: 0;
22
+
23
+ &:focus + label,
24
+ &:not([data-value='0']) + label {
25
+ transform: translateY(@labelTextLabeltranslateY) scale(@labelTextLabelScale);
26
+ }
27
+
28
+ &-field {
29
+ height: 45px;
30
+ overflow: hidden;
31
+ border: 1px solid @color_e5e5e5;
32
+ border-radius: 8px;
33
+ transition: border 0.3s;
34
+ }
35
+
36
+ &-focused {
37
+ border-color: @labelFocusBorderColor;
38
+ }
39
+
40
+ &-warper {
41
+ position: relative;
42
+ width: 100%;
43
+ height: 100%;
44
+ }
45
+
46
+ &-text {
47
+ position: absolute;
48
+ top: 12px;
49
+ left: 15px;
50
+ z-index: 2;
51
+ height: 20px;
52
+ color: @color_9aa5b5;
53
+ font-size: @font-size-base;
54
+ line-height: 20px;
55
+ transform-origin: top left;
56
+ cursor: text;
57
+ transition: all 0.2s ease-out;
58
+ }
59
+ }
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import type { NumberInputProps } from '../number-input';
3
+ export interface LabelNumberInputProps extends NumberInputProps {
4
+ /** label 标签的文本 */
5
+ label?: React.ReactNode;
6
+ /** 输入框除去label之后的最小末尾宽度 */
7
+ baseMinWidth?: number;
8
+ /** 组件dom id */
9
+ id?: string;
10
+ }
11
+ declare const LabelNumberInput: {
12
+ (props: LabelNumberInputProps): JSX.Element;
13
+ Option: new (text?: string | undefined, value?: string | undefined, defaultSelected?: boolean | undefined, selected?: boolean | undefined) => HTMLOptionElement;
14
+ };
15
+ export default LabelNumberInput;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+
8
+ for (var p in s) {
9
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
10
+ }
11
+ }
12
+
13
+ return t;
14
+ };
15
+
16
+ return __assign.apply(this, arguments);
17
+ };
18
+
19
+ var __read = this && this.__read || function (o, n) {
20
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
21
+ if (!m) return o;
22
+ var i = m.call(o),
23
+ r,
24
+ ar = [],
25
+ e;
26
+
27
+ try {
28
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
29
+ ar.push(r.value);
30
+ }
31
+ } catch (error) {
32
+ e = {
33
+ error: error
34
+ };
35
+ } finally {
36
+ try {
37
+ if (r && !r.done && (m = i["return"])) m.call(i);
38
+ } finally {
39
+ if (e) throw e.error;
40
+ }
41
+ }
42
+
43
+ return ar;
44
+ };
45
+
46
+ var __importDefault = this && this.__importDefault || function (mod) {
47
+ return mod && mod.__esModule ? mod : {
48
+ "default": mod
49
+ };
50
+ };
51
+
52
+ Object.defineProperty(exports, "__esModule", {
53
+ value: true
54
+ });
55
+
56
+ var react_1 = __importDefault(require("react"));
57
+
58
+ var useControllableValue_1 = __importDefault(require("ahooks/lib/useControllableValue"));
59
+
60
+ var useSize_1 = __importDefault(require("ahooks/lib/useSize"));
61
+
62
+ var isUndefined_1 = __importDefault(require("lodash/isUndefined"));
63
+
64
+ var classnames_1 = __importDefault(require("classnames"));
65
+
66
+ var omit_1 = __importDefault(require("lodash/omit"));
67
+
68
+ var number_input_1 = __importDefault(require("../number-input"));
69
+
70
+ var LabelNumberInput = function LabelNumberInput(props) {
71
+ var className = props.className,
72
+ label = props.label,
73
+ onBlur = props.onBlur,
74
+ onFocus = props.onFocus,
75
+ id = props.id,
76
+ _a = props.baseMinWidth,
77
+ baseMinWidth = _a === void 0 ? 50 : _a;
78
+ var numberInputRef = react_1["default"].useRef(null);
79
+ var labelDomRef = react_1["default"].useRef(null);
80
+ var labelSize = useSize_1["default"](labelDomRef);
81
+
82
+ var _b = __read(useControllableValue_1["default"](props), 2),
83
+ value = _b[0],
84
+ setValue = _b[1];
85
+
86
+ var _c = __read(react_1["default"].useState(false), 2),
87
+ focused = _c[0],
88
+ setFocused = _c[1];
89
+
90
+ var handleLabelClick = function handleLabelClick() {
91
+ var _a;
92
+
93
+ setFocused(true);
94
+ (_a = numberInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
95
+ };
96
+
97
+ var handleFocus = function handleFocus() {
98
+ setFocused(true);
99
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(value);
100
+ };
101
+
102
+ var handleBlur = function handleBlur(e) {
103
+ setFocused(false);
104
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
105
+ };
106
+
107
+ var controlMinWidth = (labelSize === null || labelSize === void 0 ? void 0 : labelSize.width) ? labelSize.width + baseMinWidth : undefined;
108
+ return react_1["default"].createElement("div", {
109
+ className: classnames_1["default"]('label-number-input-warper', className),
110
+ id: id,
111
+ style: {
112
+ minWidth: controlMinWidth
113
+ }
114
+ }, react_1["default"].createElement("div", {
115
+ className: classnames_1["default"]('label-number-input-field', {
116
+ 'label-number-input-focused': focused || !isUndefined_1["default"](value)
117
+ })
118
+ }, react_1["default"].createElement(number_input_1["default"], __assign({}, omit_1["default"](props, ['onChange', 'onBlur', 'onFocus', 'className', 'label', 'placeholder']), {
119
+ ref: numberInputRef,
120
+ "data-value": !isUndefined_1["default"](value) ? ("" + value).length : 0,
121
+ value: value,
122
+ onBlur: handleBlur,
123
+ onFocus: handleFocus,
124
+ className: "label-number-input",
125
+ onChange: function onChange(inputValue) {
126
+ return setValue(inputValue);
127
+ }
128
+ })), react_1["default"].createElement("label", {
129
+ className: "label-number-input-text",
130
+ onClick: handleLabelClick
131
+ }, label)));
132
+ };
133
+
134
+ exports["default"] = LabelNumberInput;
135
+ LabelNumberInput.Option = Option;