@hi-ui/input 5.0.0-canary.6 → 5.0.0-canary.7

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @hi-ui/input
2
2
 
3
+ ## 5.0.0-canary.7
4
+
5
+ ### Patch Changes
6
+
7
+ - chore: rebase master (5.0)
8
+ - Updated dependencies
9
+ - @hi-ui/core@5.0.0-canary.2
10
+ - @hi-ui/use-latest@5.0.0-canary.2
11
+ - @hi-ui/use-merge-refs@5.0.0-canary.2
12
+ - @hi-ui/use-uncontrolled-state@5.0.0-canary.2
13
+ - @hi-ui/icons@5.0.0-canary.2
14
+ - @hi-ui/classname@5.0.0-canary.2
15
+ - @hi-ui/dom-utils@5.0.0-canary.2
16
+ - @hi-ui/env@5.0.0-canary.2
17
+ - @hi-ui/func-utils@5.0.0-canary.2
18
+ - @hi-ui/type-assertion@5.0.0-canary.2
19
+
3
20
  ## 5.0.0-canary.6
4
21
 
5
22
  ### Patch Changes
@@ -74,6 +91,12 @@
74
91
  - @hi-ui/func-utils@5.0.0-canary.0
75
92
  - @hi-ui/type-assertion@5.0.0-canary.0
76
93
 
94
+ ## 4.4.0
95
+
96
+ ### Minor Changes
97
+
98
+ - [#3172](https://github.com/XiaoMi/hiui/pull/3172) [`a883d8e19`](https://github.com/XiaoMi/hiui/commit/a883d8e197446ef0e7cefcc5cc44d21ed1d0807f) Thanks [@zyprepare](https://github.com/zyprepare)! - feat(mock-input): 增加 onClear 参数 (#3171)
99
+
77
100
  ## 4.3.0
78
101
 
79
102
  ### Minor Changes
@@ -20,6 +20,7 @@ var env = require('@hi-ui/env');
20
20
  var useUncontrolledState = require('@hi-ui/use-uncontrolled-state');
21
21
  var icons = require('@hi-ui/icons');
22
22
  var typeAssertion = require('@hi-ui/type-assertion');
23
+ var useLatest = require('@hi-ui/use-latest');
23
24
  function _interopDefaultCompat(e) {
24
25
  return e && _typeof(e) === 'object' && 'default' in e ? e : {
25
26
  'default': e
@@ -67,8 +68,9 @@ var MockInput = /*#__PURE__*/React.forwardRef(function (_a, ref) {
67
68
  suffixProp = _a.suffix,
68
69
  _onMouseOver = _a.onMouseOver,
69
70
  _onMouseLeave = _a.onMouseLeave,
71
+ onClear = _a.onClear,
70
72
  label = _a.label,
71
- rest = tslib.__rest(_a, ["prefixCls", "role", "className", "data", "defaultValue", "value", "onChange", "placeholder", "disabled", "clearable", "focused", "invalid", "readOnly", "size", "appearance", "clearableTrigger", "displayRender", "prefix", "suffix", "onMouseOver", "onMouseLeave", "label"]);
73
+ rest = tslib.__rest(_a, ["prefixCls", "role", "className", "data", "defaultValue", "value", "onChange", "placeholder", "disabled", "clearable", "focused", "invalid", "readOnly", "size", "appearance", "clearableTrigger", "displayRender", "prefix", "suffix", "onMouseOver", "onMouseLeave", "onClear", "label"]);
72
74
  var _useUncontrolledState = useUncontrolledState.useUncontrolledState(defaultValue, valueProp, onChange),
73
75
  value = _useUncontrolledState[0],
74
76
  tryChangeValue = _useUncontrolledState[1];
@@ -89,11 +91,13 @@ var MockInput = /*#__PURE__*/React.forwardRef(function (_a, ref) {
89
91
  }
90
92
  return displayItem.title;
91
93
  }, [displayItem, displayRender]);
94
+ var onClearLatest = useLatest.useLatestCallback(onClear);
92
95
  var handleClear = React.useCallback(function (evt) {
93
96
  if (disabled) return;
94
97
  evt.stopPropagation();
95
98
  tryChangeValue(NOOP_VALUE, displayItem);
96
- }, [tryChangeValue, disabled, displayItem]);
99
+ onClearLatest === null || onClearLatest === void 0 ? void 0 : onClearLatest();
100
+ }, [tryChangeValue, disabled, displayItem, onClearLatest]);
97
101
  var _useState = React.useState(false),
98
102
  hover = _useState[0],
99
103
  setHover = _useState[1];
@@ -14,6 +14,7 @@ import { __DEV__ } from '@hi-ui/env';
14
14
  import { useUncontrolledState } from '@hi-ui/use-uncontrolled-state';
15
15
  import { CloseCircleFilled } from '@hi-ui/icons';
16
16
  import { isArray } from '@hi-ui/type-assertion';
17
+ import { useLatestCallback } from '@hi-ui/use-latest';
17
18
  var _role = 'mock-input';
18
19
  var _prefix = getPrefixCls(_role);
19
20
  var NOOP_VALUE = '';
@@ -55,8 +56,9 @@ var MockInput = /*#__PURE__*/forwardRef(function (_a, ref) {
55
56
  suffixProp = _a.suffix,
56
57
  _onMouseOver = _a.onMouseOver,
57
58
  _onMouseLeave = _a.onMouseLeave,
59
+ onClear = _a.onClear,
58
60
  label = _a.label,
59
- rest = __rest(_a, ["prefixCls", "role", "className", "data", "defaultValue", "value", "onChange", "placeholder", "disabled", "clearable", "focused", "invalid", "readOnly", "size", "appearance", "clearableTrigger", "displayRender", "prefix", "suffix", "onMouseOver", "onMouseLeave", "label"]);
61
+ rest = __rest(_a, ["prefixCls", "role", "className", "data", "defaultValue", "value", "onChange", "placeholder", "disabled", "clearable", "focused", "invalid", "readOnly", "size", "appearance", "clearableTrigger", "displayRender", "prefix", "suffix", "onMouseOver", "onMouseLeave", "onClear", "label"]);
60
62
  var _useUncontrolledState = useUncontrolledState(defaultValue, valueProp, onChange),
61
63
  value = _useUncontrolledState[0],
62
64
  tryChangeValue = _useUncontrolledState[1];
@@ -77,11 +79,13 @@ var MockInput = /*#__PURE__*/forwardRef(function (_a, ref) {
77
79
  }
78
80
  return displayItem.title;
79
81
  }, [displayItem, displayRender]);
82
+ var onClearLatest = useLatestCallback(onClear);
80
83
  var handleClear = useCallback(function (evt) {
81
84
  if (disabled) return;
82
85
  evt.stopPropagation();
83
86
  tryChangeValue(NOOP_VALUE, displayItem);
84
- }, [tryChangeValue, disabled, displayItem]);
87
+ onClearLatest === null || onClearLatest === void 0 ? void 0 : onClearLatest();
88
+ }, [tryChangeValue, disabled, displayItem, onClearLatest]);
85
89
  var _useState = useState(false),
86
90
  hover = _useState[0],
87
91
  setHover = _useState[1];
@@ -3,7 +3,7 @@ import type { HiBaseAppearanceEnum, HiBaseDataItem, HiBaseHTMLFieldProps } from
3
3
  /**
4
4
  * 支持自定义渲染输入框内容,暂时仅供内部 Picker 类组件使用,不对外提供
5
5
  */
6
- export declare const MockInput: React.ForwardRefExoticComponent<Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>>, "value" | "disabled" | "readOnly" | "placeholder" | "defaultValue" | "onChange" | "type" | "focused" | "onSelect" | "title" | "size" | "prefix" | "data" | "label" | "onClick" | "appearance" | "suffix" | "clearableTrigger" | "clearable" | "displayRender"> & {
6
+ export declare const MockInput: React.ForwardRefExoticComponent<Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>>, "value" | "disabled" | "readOnly" | "placeholder" | "defaultValue" | "onChange" | "type" | "focused" | "onSelect" | "title" | "size" | "prefix" | "data" | "label" | "onClick" | "appearance" | "suffix" | "clearableTrigger" | "clearable" | "onClear" | "displayRender"> & {
7
7
  prefixCls?: string | undefined;
8
8
  role?: string | undefined;
9
9
  } & {
@@ -27,6 +27,10 @@ export declare const MockInput: React.ForwardRefExoticComponent<Omit<Pick<React.
27
27
  * 清除按钮展示的触发形态
28
28
  */
29
29
  clearableTrigger?: "always" | "hover" | undefined;
30
+ /**
31
+ * 点击关闭按钮时触发
32
+ */
33
+ onClear?: (() => void) | undefined;
30
34
  /**
31
35
  * 是否禁止使用
32
36
  */
@@ -109,6 +113,10 @@ export declare type MockInputProps = HiBaseHTMLFieldProps<'div', {
109
113
  * 清除按钮展示的触发形态
110
114
  */
111
115
  clearableTrigger?: 'always' | 'hover';
116
+ /**
117
+ * 点击关闭按钮时触发
118
+ */
119
+ onClear?: () => void;
112
120
  /**
113
121
  * 是否禁止使用
114
122
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/input",
3
- "version": "5.0.0-canary.6",
3
+ "version": "5.0.0-canary.7",
4
4
  "description": "A sub-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HiUI <mi-hiui@xiaomi.com>",
@@ -44,24 +44,24 @@
44
44
  "url": "https://github.com/XiaoMi/hiui/issues"
45
45
  },
46
46
  "dependencies": {
47
- "@hi-ui/classname": "^5.0.0-canary.1",
48
- "@hi-ui/dom-utils": "^5.0.0-canary.1",
49
- "@hi-ui/env": "^5.0.0-canary.1",
50
- "@hi-ui/func-utils": "^5.0.0-canary.1",
51
- "@hi-ui/icons": "^5.0.0-canary.1",
52
- "@hi-ui/type-assertion": "^5.0.0-canary.1",
53
- "@hi-ui/use-latest": "^5.0.0-canary.1",
54
- "@hi-ui/use-merge-refs": "^5.0.0-canary.1",
55
- "@hi-ui/use-uncontrolled-state": "^5.0.0-canary.1"
47
+ "@hi-ui/classname": "^5.0.0-canary.2",
48
+ "@hi-ui/dom-utils": "^5.0.0-canary.2",
49
+ "@hi-ui/env": "^5.0.0-canary.2",
50
+ "@hi-ui/func-utils": "^5.0.0-canary.2",
51
+ "@hi-ui/icons": "^5.0.0-canary.2",
52
+ "@hi-ui/type-assertion": "^5.0.0-canary.2",
53
+ "@hi-ui/use-latest": "^5.0.0-canary.2",
54
+ "@hi-ui/use-merge-refs": "^5.0.0-canary.2",
55
+ "@hi-ui/use-uncontrolled-state": "^5.0.0-canary.2"
56
56
  },
57
57
  "peerDependencies": {
58
- "@hi-ui/core": ">=5.0.0-canary.1",
58
+ "@hi-ui/core": ">=5.0.0-canary.2",
59
59
  "react": ">=16.8.6",
60
60
  "react-dom": ">=16.8.6"
61
61
  },
62
62
  "devDependencies": {
63
- "@hi-ui/core": "^5.0.0-canary.1",
64
- "@hi-ui/core-css": "^5.0.0-canary.5",
63
+ "@hi-ui/core": "^5.0.0-canary.2",
64
+ "@hi-ui/core-css": "^5.0.0-canary.6",
65
65
  "react": "^17.0.1",
66
66
  "react-dom": "^17.0.1"
67
67
  }