@hi-ui/table 4.10.0 → 4.11.0

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.
@@ -1,83 +0,0 @@
1
- /** @LICENSE
2
- * @hi-ui/table
3
- * https://github.com/XiaoMi/hiui/tree/master/packages/ui/table#readme
4
- *
5
- * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */
10
- import { __rest } from 'tslib';
11
- import { useCallback, useMemo } from 'react';
12
- import { useUncontrolledState } from '@hi-ui/use-uncontrolled-state';
13
- import { hiddenStyle, setAttrStatus } from '@hi-ui/dom-utils';
14
-
15
- /** @LICENSE
16
- * @hi-ui/radio
17
- * https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
18
- *
19
- * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
20
- *
21
- * This source code is licensed under the MIT license found in the
22
- * LICENSE file in the root directory of this source tree.
23
- */
24
- var useRadio = function useRadio(_a) {
25
- var nameProp = _a.name,
26
- valueProp = _a.value,
27
- _a$autoFocus = _a.autoFocus,
28
- autoFocus = _a$autoFocus === void 0 ? false : _a$autoFocus,
29
- _a$defaultChecked = _a.defaultChecked,
30
- defaultChecked = _a$defaultChecked === void 0 ? false : _a$defaultChecked,
31
- onChange = _a.onChange,
32
- checkedProp = _a.checked,
33
- _a$readOnly = _a.readOnly,
34
- readOnly = _a$readOnly === void 0 ? false : _a$readOnly,
35
- _a$disabled = _a.disabled,
36
- disabled = _a$disabled === void 0 ? false : _a$disabled,
37
- rest = __rest(_a, ["name", "value", "autoFocus", "defaultChecked", "onChange", "checked", "readOnly", "disabled"]);
38
- var _useUncontrolledState = useUncontrolledState(defaultChecked, checkedProp, function (_, evt) {
39
- onChange === null || onChange === void 0 ? void 0 : onChange(evt);
40
- }),
41
- checked = _useUncontrolledState[0],
42
- tryChangeChecked = _useUncontrolledState[1];
43
- var nonInteractive = disabled || readOnly;
44
- var handleChange = useCallback(function (evt) {
45
- if (nonInteractive) {
46
- // 不可交互,不触发事件的任何默认行为
47
- evt.preventDefault();
48
- return;
49
- }
50
- tryChangeChecked(evt.target.checked, evt);
51
- }, [nonInteractive, tryChangeChecked]);
52
- var getInputProps = useCallback(function () {
53
- return {
54
- style: hiddenStyle,
55
- type: 'radio',
56
- checked: checked,
57
- disabled: disabled,
58
- readOnly: readOnly,
59
- onChange: handleChange,
60
- autoFocus: autoFocus,
61
- name: nameProp,
62
- value: valueProp
63
- };
64
- }, [nameProp, handleChange, checked, disabled, readOnly, autoFocus, valueProp]);
65
- var state = useMemo(function () {
66
- return {
67
- disabled: disabled,
68
- checked: checked,
69
- readOnly: readOnly
70
- };
71
- }, [disabled, checked, readOnly]);
72
- var rootProps = Object.assign(Object.assign({}, rest), {
73
- 'data-disabled': setAttrStatus(disabled),
74
- 'data-checked': setAttrStatus(checked),
75
- 'data-readonly': setAttrStatus(readOnly)
76
- });
77
- return {
78
- state: state,
79
- rootProps: rootProps,
80
- getInputProps: getInputProps
81
- };
82
- };
83
- export { useRadio };