assui 2.0.120 → 2.0.123

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/keep-tab/index.js +1 -1
  4. package/es/label-auto-complete/style/index.less +1 -1
  5. package/es/label-condition-input/index.d.ts +17 -0
  6. package/es/label-condition-input/index.js +118 -0
  7. package/es/label-condition-input/style/index.css +43 -0
  8. package/es/label-condition-input/style/index.d.ts +1 -0
  9. package/es/label-condition-input/style/index.js +1 -0
  10. package/es/label-condition-input/style/index.less +59 -0
  11. package/es/label-number-input/index.d.ts +15 -0
  12. package/es/label-number-input/index.js +117 -0
  13. package/es/label-number-input/style/index.css +43 -0
  14. package/es/label-number-input/style/index.d.ts +1 -0
  15. package/es/label-number-input/style/index.js +1 -0
  16. package/es/label-number-input/style/index.less +59 -0
  17. package/es/label-select/index.js +1 -1
  18. package/es/label-text-area/index.js +1 -1
  19. package/es/label-text-area/style/index.css +1 -0
  20. package/es/label-text-area/style/index.less +1 -0
  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/keep-tab/index.js +1 -1
  26. package/lib/label-auto-complete/style/index.less +1 -1
  27. package/lib/label-condition-input/index.d.ts +17 -0
  28. package/lib/label-condition-input/index.js +135 -0
  29. package/lib/label-condition-input/style/index.css +43 -0
  30. package/lib/label-condition-input/style/index.d.ts +1 -0
  31. package/lib/label-condition-input/style/index.js +7 -0
  32. package/lib/label-condition-input/style/index.less +59 -0
  33. package/lib/label-number-input/index.d.ts +15 -0
  34. package/lib/label-number-input/index.js +135 -0
  35. package/lib/label-number-input/style/index.css +43 -0
  36. package/lib/label-number-input/style/index.d.ts +1 -0
  37. package/lib/label-number-input/style/index.js +7 -0
  38. package/lib/label-number-input/style/index.less +59 -0
  39. package/lib/label-select/index.js +2 -2
  40. package/lib/label-text-area/index.js +2 -2
  41. package/lib/label-text-area/style/index.css +1 -0
  42. package/lib/label-text-area/style/index.less +1 -0
  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
@@ -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-number-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
+ }
@@ -60,7 +60,7 @@ var useControllableValue_1 = __importDefault(require("ahooks/lib/useControllable
60
60
 
61
61
  var select_1 = __importDefault(require("antd/es/select"));
62
62
 
63
- var lodash_1 = require("lodash");
63
+ var isUndefined_1 = __importDefault(require("lodash/isUndefined"));
64
64
 
65
65
  var classnames_1 = __importDefault(require("classnames"));
66
66
 
@@ -108,7 +108,7 @@ var LabelSelect = function LabelSelect(props) {
108
108
  return react_1["default"].createElement("div", {
109
109
  className: classnames_1["default"]({
110
110
  'label-select': true,
111
- 'label-select-label-scale': open || !lodash_1.isUndefined(value)
111
+ 'label-select-label-scale': open || !isUndefined_1["default"](value)
112
112
  }, className)
113
113
  }, react_1["default"].createElement(select_1["default"], __assign({}, omit_1["default"](props, ['open', 'onChange', 'className', 'label']), {
114
114
  open: open,
@@ -70,7 +70,7 @@ var react_1 = __importDefault(require("react"));
70
70
 
71
71
  var classnames_1 = __importDefault(require("classnames"));
72
72
 
73
- var ahooks_1 = require("ahooks");
73
+ var useControllableValue_1 = __importDefault(require("ahooks/lib/useControllableValue"));
74
74
 
75
75
  var trimStart_1 = __importDefault(require("lodash/trimStart"));
76
76
 
@@ -87,7 +87,7 @@ var LabelTextArea = function LabelTextArea(props) {
87
87
  focused = _a[0],
88
88
  setFocused = _a[1];
89
89
 
90
- var _b = __read(ahooks_1.useControllableValue(props), 2),
90
+ var _b = __read(useControllableValue_1["default"](props), 2),
91
91
  value = _b[0],
92
92
  setValue = _b[1];
93
93
 
@@ -21,6 +21,7 @@
21
21
  width: 100%;
22
22
  height: 100%;
23
23
  padding-top: 24px;
24
+ overflow: hidden;
24
25
  border: 1px solid #e5e5e5;
25
26
  border-radius: 12px;
26
27
  outline: 0;
@@ -33,6 +33,7 @@
33
33
  width: 100%;
34
34
  height: 100%;
35
35
  padding-top: 24px;
36
+ overflow: hidden;
36
37
  border: 1px solid @color_e5e5e5;
37
38
  border-radius: 12px;
38
39
  outline: 0;
@@ -2,9 +2,10 @@ import * as React from 'react';
2
2
  import type { InputProps } from 'antd/es/input';
3
3
  import * as dataTypeEnum from './const/dataTypeEnum';
4
4
  import * as numberTypeEnum from './const/numberType';
5
+ export declare type NumberInputValueType = string | number;
5
6
  export interface NumberInputProps extends Omit<InputProps, 'onChange' | 'onBlur'> {
6
7
  /** 输入框的内容 */
7
- value?: string | number;
8
+ value?: NumberInputValueType;
8
9
  /** 输入数据的类型 */
9
10
  numberType?: 'int' | 'float';
10
11
  /** value的数据类型 */
@@ -20,9 +21,9 @@ export interface NumberInputProps extends Omit<InputProps, 'onChange' | 'onBlur'
20
21
  /** 是否允许输入负数 */
21
22
  enableMinus?: boolean;
22
23
  /** 变化回调 */
23
- onChange?: (value: string | number) => void;
24
+ onChange?: (value: NumberInputValueType) => void;
24
25
  /** 失去焦点回调 */
25
- onBlur?: (value: string) => void;
26
+ onBlur?: (value: NumberInputValueType) => void;
26
27
  /** 按下回车的回调 */
27
28
  onPressEnter?: React.KeyboardEventHandler<HTMLInputElement>;
28
29
  /** 带标签的 input,设置前置标签 */
@@ -105,7 +105,9 @@ var React = __importStar(require("react"));
105
105
 
106
106
  var input_1 = __importDefault(require("antd/es/input"));
107
107
 
108
- var isUndefined_1 = __importDefault(require("lodash/isUndefined"));
108
+ var useControllableValue_1 = __importDefault(require("ahooks/lib/useControllableValue"));
109
+
110
+ var omit_1 = __importDefault(require("lodash/omit"));
109
111
 
110
112
  var dataTypeEnum = __importStar(require("./const/dataTypeEnum"));
111
113
 
@@ -118,25 +120,24 @@ exports.numberTypeEnum = numberTypeEnum;
118
120
  var utils_1 = require("./utils");
119
121
 
120
122
  var NumberInput = React.forwardRef(function (props, ref) {
121
- var value = props.value,
122
- onChange = props.onChange,
123
- _a = props.numberType,
124
- numberType = _a === void 0 ? numberTypeEnum.INT : _a,
125
- _b = props.dataType,
126
- dataType = _b === void 0 ? dataTypeEnum.NUMBER : _b,
123
+ var _a = __read(useControllableValue_1["default"](props, {
124
+ defaultValue: ''
125
+ }), 2),
126
+ value = _a[0],
127
+ setValue = _a[1];
128
+
129
+ var onChange = props.onChange,
130
+ _b = props.numberType,
131
+ numberType = _b === void 0 ? numberTypeEnum.INT : _b,
132
+ _c = props.dataType,
133
+ dataType = _c === void 0 ? dataTypeEnum.NUMBER : _c,
127
134
  precision = props.precision,
128
135
  formatter = props.formatter,
129
136
  parser = props.parser,
130
137
  enableMinus = props.enableMinus,
131
138
  onBlur = props.onBlur,
132
139
  maxLength = props.maxLength,
133
- restProps = __rest(props, ["value", "onChange", "numberType", "dataType", "precision", "formatter", "parser", "enableMinus", "onBlur", "maxLength"]);
134
-
135
- var _c = __read(React.useState(''), 2),
136
- inputValue = _c[0],
137
- setInputValue = _c[1];
138
-
139
- var resultValue = isUndefined_1["default"](value) ? inputValue : value;
140
+ restProps = __rest(props, ["onChange", "numberType", "dataType", "precision", "formatter", "parser", "enableMinus", "onBlur", "maxLength"]);
140
141
 
141
142
  var onNumberChange = function onNumberChange(e) {
142
143
  var newNumber;
@@ -145,13 +146,13 @@ var NumberInput = React.forwardRef(function (props, ref) {
145
146
  if (numberType === numberTypeEnum.INT) {
146
147
  newNumber = utils_1.filterInt({
147
148
  value: newValue,
148
- preValue: "" + resultValue,
149
+ preValue: "" + value,
149
150
  enableMinus: enableMinus
150
151
  });
151
152
  } else {
152
153
  newNumber = utils_1.filterFloat({
153
154
  value: newValue,
154
- preValue: "" + resultValue,
155
+ preValue: "" + value,
155
156
  precision: precision !== null && precision !== void 0 ? precision : 2,
156
157
  enableMinus: enableMinus
157
158
  });
@@ -161,42 +162,29 @@ var NumberInput = React.forwardRef(function (props, ref) {
161
162
  newNumber = parser(newNumber);
162
163
  }
163
164
 
164
- if (resultValue !== newNumber) {
165
- if (value === undefined) {
166
- setInputValue(newNumber);
167
- }
168
-
169
- if (onChange) {
170
- onChange(newNumber);
171
- }
165
+ if (value !== newNumber) {
166
+ setValue(newNumber);
172
167
  }
173
168
  };
174
169
 
175
170
  var onNumberBlur = function onNumberBlur() {
176
- if (resultValue === '-' || resultValue === '.') {
177
- if (value === undefined) {
178
- setInputValue('');
179
- }
171
+ var resultValue = value;
180
172
 
181
- if (onChange) {
182
- onChange('');
183
- }
184
- }
185
-
186
- if (dataType === dataTypeEnum.NUMBER && resultValue) {
173
+ if (value === '-' || value === '.') {
174
+ resultValue = '';
175
+ } else if (value && dataType === dataTypeEnum.NUMBER) {
187
176
  if (numberType === numberTypeEnum.FLOAT) {
188
- onChange && onChange(+resultValue);
177
+ resultValue = +value;
189
178
  } else {
190
- onChange && onChange(parseInt("" + resultValue, 10));
179
+ resultValue = parseInt("" + value, 10);
191
180
  }
192
181
  }
193
182
 
194
- if (onBlur) {
195
- onBlur("" + resultValue);
196
- }
183
+ setValue(resultValue);
184
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(resultValue);
197
185
  };
198
186
 
199
- var finallyValue = formatter ? formatter("" + resultValue) : resultValue;
187
+ var finallyValue = formatter ? formatter("" + value) : value;
200
188
  return React.createElement(input_1["default"], __assign({
201
189
  type: "text",
202
190
  ref: ref,
@@ -204,7 +192,7 @@ var NumberInput = React.forwardRef(function (props, ref) {
204
192
  onBlur: onNumberBlur,
205
193
  onChange: onNumberChange,
206
194
  maxLength: maxLength
207
- }, restProps));
195
+ }, omit_1["default"](restProps, ['value'])));
208
196
  });
209
197
  NumberInput.defaultProps = {
210
198
  enableMinus: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assui",
3
- "version": "2.0.120",
3
+ "version": "2.0.123",
4
4
  "description": "react ui library",
5
5
  "author": "jason <usochen@gmail.com>",
6
6
  "main": "./lib/index.js",
@@ -69,5 +69,5 @@
69
69
  "node": ">=10.0.0"
70
70
  },
71
71
  "license": "MIT",
72
- "gitHead": "06e30bd22efb48f7333e7beefabc3756aa0399be"
72
+ "gitHead": "90952a6585aab0568fc109904ce28bd322e9052d"
73
73
  }