@hi-ui/table 4.5.5 → 4.6.0-alpha.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.
- package/lib/cjs/Table.js +17 -4
- package/lib/cjs/hooks/use-check.js +9 -1
- package/lib/cjs/hooks/use-col-width.js +10 -8
- package/lib/cjs/packages/ui/radio/lib/esm/Radio.js +100 -0
- package/lib/cjs/packages/ui/radio/lib/esm/RadioGroup.js +104 -0
- package/lib/cjs/packages/ui/radio/lib/esm/context.js +37 -0
- package/lib/cjs/packages/ui/radio/lib/esm/index.js +33 -0
- package/lib/cjs/packages/ui/radio/lib/esm/styles/index.scss.js +35 -0
- package/lib/cjs/packages/ui/radio/lib/esm/types.js +34 -0
- package/lib/cjs/packages/ui/radio/lib/esm/use-radio-group.js +61 -0
- package/lib/cjs/packages/ui/radio/lib/esm/use-radio.js +88 -0
- package/lib/esm/Table.js +17 -4
- package/lib/esm/hooks/use-check.js +9 -1
- package/lib/esm/hooks/use-col-width.js +10 -8
- package/lib/esm/packages/ui/radio/lib/esm/Radio.js +88 -0
- package/lib/esm/packages/ui/radio/lib/esm/RadioGroup.js +92 -0
- package/lib/esm/packages/ui/radio/lib/esm/context.js +31 -0
- package/lib/esm/packages/ui/radio/lib/esm/index.js +26 -0
- package/lib/esm/packages/ui/radio/lib/esm/styles/index.scss.js +23 -0
- package/lib/esm/packages/ui/radio/lib/esm/types.js +27 -0
- package/lib/esm/packages/ui/radio/lib/esm/use-radio-group.js +56 -0
- package/lib/esm/packages/ui/radio/lib/esm/use-radio.js +83 -0
- package/lib/types/hooks/use-check.d.ts +1 -0
- package/lib/types/types.d.ts +1 -0
- package/package.json +1 -1
package/lib/cjs/Table.js
CHANGED
|
@@ -25,6 +25,7 @@ var reactUtils = require('@hi-ui/react-utils');
|
|
|
25
25
|
var TableSettingMenu = require('./TableSettingMenu.js');
|
|
26
26
|
var Loading = require('@hi-ui/loading');
|
|
27
27
|
var Checkbox = require('@hi-ui/checkbox');
|
|
28
|
+
var index$1 = require('./packages/ui/radio/lib/esm/index.js');
|
|
28
29
|
var useCheck = require('./hooks/use-check.js');
|
|
29
30
|
var typeAssertion = require('@hi-ui/type-assertion');
|
|
30
31
|
var treeUtils = require('@hi-ui/tree-utils');
|
|
@@ -194,16 +195,19 @@ var Table = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
194
195
|
tryCheckAllRow = _useTableCheck.tryCheckAllRow,
|
|
195
196
|
isCheckedRowKey = _useTableCheck.isCheckedRowKey,
|
|
196
197
|
onCheckedRowKeysChange = _useTableCheck.onCheckedRowKeysChange,
|
|
198
|
+
onRadioCheckedRowKeysChange = _useTableCheck.onRadioCheckedRowKeysChange,
|
|
197
199
|
checkRowIsDisabledCheckbox = _useTableCheck.checkRowIsDisabledCheckbox;
|
|
198
200
|
// 表格列多选操作区
|
|
199
201
|
var getSelectionColumn = React__default["default"].useCallback(function (rowSelection) {
|
|
202
|
+
var _rowSelection$type = rowSelection.type,
|
|
203
|
+
type = _rowSelection$type === void 0 ? 'checkbox' : _rowSelection$type;
|
|
200
204
|
var renderCell = function renderCell(_, rowItem, rowIndex) {
|
|
201
205
|
var rowKey = getRowKeyField(rowItem);
|
|
202
206
|
var checked = isCheckedRowKey(rowKey);
|
|
203
207
|
var disabledCheckbox = checkRowIsDisabledCheckbox(rowItem);
|
|
204
208
|
return {
|
|
205
|
-
node: ( /*#__PURE__*/React__default["default"].createElement(Checkbox__default["default"], {
|
|
206
|
-
checked:
|
|
209
|
+
node: type === 'checkbox' ? ( /*#__PURE__*/React__default["default"].createElement(Checkbox__default["default"], {
|
|
210
|
+
checked: checked,
|
|
207
211
|
disabled: disabledCheckbox,
|
|
208
212
|
onChange: function onChange(evt) {
|
|
209
213
|
onCheckedRowKeysChange(rowItem, evt.target.checked);
|
|
@@ -211,6 +215,15 @@ var Table = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
211
215
|
onClick: function onClick(evt) {
|
|
212
216
|
evt.stopPropagation();
|
|
213
217
|
}
|
|
218
|
+
})) : ( /*#__PURE__*/React__default["default"].createElement(index$1["default"], {
|
|
219
|
+
checked: checked,
|
|
220
|
+
disabled: disabledCheckbox,
|
|
221
|
+
onChange: function onChange(evt) {
|
|
222
|
+
onRadioCheckedRowKeysChange(rowItem, evt.target.checked);
|
|
223
|
+
},
|
|
224
|
+
onClick: function onClick(evt) {
|
|
225
|
+
evt.stopPropagation();
|
|
226
|
+
}
|
|
214
227
|
})),
|
|
215
228
|
checked: checked
|
|
216
229
|
};
|
|
@@ -261,12 +274,12 @@ var Table = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
261
274
|
// selectionColumn 宽度固定,防止自动被拉伸
|
|
262
275
|
fixed: true,
|
|
263
276
|
className: prefixCls + "__selection-col",
|
|
264
|
-
title: renderSelectionTitleCell,
|
|
277
|
+
title: type === 'checkbox' ? renderSelectionTitleCell : undefined,
|
|
265
278
|
// @ts-ignore
|
|
266
279
|
render: renderSelectionCell
|
|
267
280
|
};
|
|
268
281
|
return selectionColumn;
|
|
269
|
-
}, [
|
|
282
|
+
}, [checkboxColWidth, prefixCls, getRowKeyField, isCheckedRowKey, checkRowIsDisabledCheckbox, onCheckedRowKeysChange, onRadioCheckedRowKeysChange, checkedAll, semiChecked, tryCheckAllRow]);
|
|
270
283
|
var mergedColumns = React__default["default"].useMemo(function () {
|
|
271
284
|
if (rowSelection) {
|
|
272
285
|
var selectionColumn = getSelectionColumn(rowSelection);
|
|
@@ -71,6 +71,13 @@ var useTableCheck = function useTableCheck(_ref) {
|
|
|
71
71
|
}
|
|
72
72
|
handleCheckedRowKeysChange(rowItem, checked);
|
|
73
73
|
}, [checkedRowDataItems, checkedRowKeys, fieldKey, handleCheckedRowKeysChange]);
|
|
74
|
+
var onRadioCheckedRowKeysChange = React__default["default"].useCallback(function (rowItem, checked) {
|
|
75
|
+
var _a;
|
|
76
|
+
checkedRowDataItemsRef.current = [rowItem];
|
|
77
|
+
trySetCheckedRowKeys((_a = checkedRowDataItemsRef.current) === null || _a === void 0 ? void 0 : _a.map(function (item) {
|
|
78
|
+
return item[fieldKey];
|
|
79
|
+
}), rowItem, checked, checkedRowDataItemsRef.current);
|
|
80
|
+
}, [fieldKey, trySetCheckedRowKeys]);
|
|
74
81
|
// 判断是否全选
|
|
75
82
|
var _React$useMemo = React__default["default"].useMemo(function () {
|
|
76
83
|
if (rowSelection) {
|
|
@@ -130,12 +137,13 @@ var useTableCheck = function useTableCheck(_ref) {
|
|
|
130
137
|
});
|
|
131
138
|
return Array.from(checkedRowKeysSet);
|
|
132
139
|
}, targetRowItems, true, checkedRowDataItemsRef.current);
|
|
133
|
-
}, [
|
|
140
|
+
}, [flattedData, checkedAll, trySetCheckedRowKeys, checkRowIsDisabledCheckbox, fieldKey]);
|
|
134
141
|
return {
|
|
135
142
|
tryCheckAllRow: tryCheckAllRow,
|
|
136
143
|
checkedAll: checkedAll,
|
|
137
144
|
semiChecked: semiChecked,
|
|
138
145
|
onCheckedRowKeysChange: onCheckedRowKeysChange,
|
|
146
|
+
onRadioCheckedRowKeysChange: onRadioCheckedRowKeysChange,
|
|
139
147
|
isCheckedRowKey: isCheckedRowKey,
|
|
140
148
|
checkedRowKeys: checkedRowKeys,
|
|
141
149
|
trySetCheckedRowKeys: trySetCheckedRowKeys,
|
|
@@ -104,14 +104,16 @@ var useColWidth = function useColWidth(_ref) {
|
|
|
104
104
|
}
|
|
105
105
|
}, [getVirtualWidths, virtual]);
|
|
106
106
|
useUpdateEffect.useUpdateEffect(function () {
|
|
107
|
-
setColWidths(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
107
|
+
setColWidths(index.getGroupItemWidth(columns));
|
|
108
|
+
// setColWidths((prev) => {
|
|
109
|
+
// // resizable 模式下通过 measureRowElementRef.current 去更新列宽,防止拖拽后宽度被重置
|
|
110
|
+
// // 例如同时设置了 resizable 和 rowSelection,当拖拽某列宽度后再选中某行时,该列宽度会被重置
|
|
111
|
+
// return resizable && measureRowElementRef.current?.childNodes.length === prev.length
|
|
112
|
+
// ? // 走更新逻辑
|
|
113
|
+
// getWidths(measureRowElementRef.current)
|
|
114
|
+
// : // 当列数变化时重新走初始化逻辑
|
|
115
|
+
// getGroupItemWidth(columns)
|
|
116
|
+
// })
|
|
115
117
|
}, [columns]);
|
|
116
118
|
/**
|
|
117
119
|
* 根据实际内容区(table 的第一行)渲染,再次精确收集并设置每列宽度
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
13
|
+
Object.defineProperty(exports, '__esModule', {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
var tslib = require('tslib');
|
|
17
|
+
var React = require('react');
|
|
18
|
+
var classname = require('@hi-ui/classname');
|
|
19
|
+
var env = require('@hi-ui/env');
|
|
20
|
+
var useRadio = require('./use-radio.js');
|
|
21
|
+
var context = require('./context.js');
|
|
22
|
+
var typeAssertion = require('@hi-ui/type-assertion');
|
|
23
|
+
var funcUtils = require('@hi-ui/func-utils');
|
|
24
|
+
function _interopDefaultCompat(e) {
|
|
25
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
26
|
+
'default': e
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
30
|
+
|
|
31
|
+
/** @LICENSE
|
|
32
|
+
* @hi-ui/radio
|
|
33
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
|
|
34
|
+
*
|
|
35
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
36
|
+
*
|
|
37
|
+
* This source code is licensed under the MIT license found in the
|
|
38
|
+
* LICENSE file in the root directory of this source tree.
|
|
39
|
+
*/
|
|
40
|
+
var RADIO_PREFIX = classname.getPrefixCls('radio');
|
|
41
|
+
/**
|
|
42
|
+
* 单选
|
|
43
|
+
*/
|
|
44
|
+
var Radio = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
45
|
+
var _a$prefixCls = _a.prefixCls,
|
|
46
|
+
prefixCls = _a$prefixCls === void 0 ? RADIO_PREFIX : _a$prefixCls,
|
|
47
|
+
_a$role = _a.role,
|
|
48
|
+
role = _a$role === void 0 ? 'radio' : _a$role,
|
|
49
|
+
className = _a.className,
|
|
50
|
+
children = _a.children,
|
|
51
|
+
rest = tslib.__rest(_a, ["prefixCls", "role", "className", "children"]);
|
|
52
|
+
var groupContext = context.useRadioGroupContext();
|
|
53
|
+
var _ref = groupContext || {},
|
|
54
|
+
disabledContext = _ref.disabled,
|
|
55
|
+
isCheckedContext = _ref.isChecked,
|
|
56
|
+
nameContext = _ref.name,
|
|
57
|
+
onChangeContext = _ref.onChange,
|
|
58
|
+
_ref$type = _ref.type,
|
|
59
|
+
type = _ref$type === void 0 ? 'default' : _ref$type;
|
|
60
|
+
var checkedProp = rest.checked,
|
|
61
|
+
valueProp = rest.value,
|
|
62
|
+
_rest$disabled = rest.disabled,
|
|
63
|
+
disabled = _rest$disabled === void 0 ? disabledContext : _rest$disabled,
|
|
64
|
+
_rest$name = rest.name,
|
|
65
|
+
name = _rest$name === void 0 ? nameContext : _rest$name,
|
|
66
|
+
onChangeProp = rest.onChange;
|
|
67
|
+
// Group's priority is higher than its own.
|
|
68
|
+
var checked = isCheckedContext && !typeAssertion.isNullish(valueProp) ? isCheckedContext(valueProp) : checkedProp;
|
|
69
|
+
var onChange = onChangeContext && !typeAssertion.isNullish(valueProp) ? funcUtils.callAllFuncs(function (evt) {
|
|
70
|
+
if (evt.target.checked) {
|
|
71
|
+
onChangeContext(valueProp);
|
|
72
|
+
}
|
|
73
|
+
}, onChangeProp) : onChangeProp;
|
|
74
|
+
var _useRadio = useRadio.useRadio(Object.assign(Object.assign({}, rest), {
|
|
75
|
+
disabled: disabled,
|
|
76
|
+
name: name,
|
|
77
|
+
checked: checked,
|
|
78
|
+
onChange: onChange
|
|
79
|
+
})),
|
|
80
|
+
rootProps = _useRadio.rootProps,
|
|
81
|
+
getInputProps = _useRadio.getInputProps;
|
|
82
|
+
var inputProps = getInputProps();
|
|
83
|
+
var cls = classname.cx(prefixCls, className, prefixCls + "--type-" + type);
|
|
84
|
+
return /*#__PURE__*/React__default["default"].createElement("label", Object.assign({
|
|
85
|
+
ref: ref,
|
|
86
|
+
role: role,
|
|
87
|
+
className: cls
|
|
88
|
+
}, rootProps), /*#__PURE__*/React__default["default"].createElement("input", Object.assign({}, inputProps, {
|
|
89
|
+
tabIndex: 0,
|
|
90
|
+
className: prefixCls + "__input"
|
|
91
|
+
})), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
92
|
+
className: prefixCls + "__controller"
|
|
93
|
+
}), children ? /*#__PURE__*/React__default["default"].createElement("span", {
|
|
94
|
+
className: prefixCls + "__label"
|
|
95
|
+
}, children) : null);
|
|
96
|
+
});
|
|
97
|
+
if (env.__DEV__) {
|
|
98
|
+
Radio.displayName = 'Radio';
|
|
99
|
+
}
|
|
100
|
+
exports.Radio = Radio;
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
13
|
+
Object.defineProperty(exports, '__esModule', {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
var tslib = require('tslib');
|
|
17
|
+
var React = require('react');
|
|
18
|
+
var classname = require('@hi-ui/classname');
|
|
19
|
+
var env = require('@hi-ui/env');
|
|
20
|
+
var useRadioGroup = require('./use-radio-group.js');
|
|
21
|
+
var context = require('./context.js');
|
|
22
|
+
var types = require('./types.js');
|
|
23
|
+
var typeAssertion = require('@hi-ui/type-assertion');
|
|
24
|
+
var Radio = require('./Radio.js');
|
|
25
|
+
function _interopDefaultCompat(e) {
|
|
26
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
27
|
+
'default': e
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
31
|
+
|
|
32
|
+
/** @LICENSE
|
|
33
|
+
* @hi-ui/radio
|
|
34
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
|
|
35
|
+
*
|
|
36
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
37
|
+
*
|
|
38
|
+
* This source code is licensed under the MIT license found in the
|
|
39
|
+
* LICENSE file in the root directory of this source tree.
|
|
40
|
+
*/
|
|
41
|
+
var RADIO_GROUP_PREFIX = classname.getPrefixCls('radio-group');
|
|
42
|
+
/**
|
|
43
|
+
* 单选组合器
|
|
44
|
+
*/
|
|
45
|
+
var RadioGroup = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
46
|
+
var _a$prefixCls = _a.prefixCls,
|
|
47
|
+
prefixCls = _a$prefixCls === void 0 ? RADIO_GROUP_PREFIX : _a$prefixCls,
|
|
48
|
+
className = _a.className,
|
|
49
|
+
children = _a.children,
|
|
50
|
+
data = _a.data,
|
|
51
|
+
_a$type = _a.type,
|
|
52
|
+
type = _a$type === void 0 ? types.RadioGroupTypeEnum.DEFAULT : _a$type,
|
|
53
|
+
_a$placement = _a.placement,
|
|
54
|
+
placement = _a$placement === void 0 ? types.RadioGroupPlacementEnum.HORIZONTAL : _a$placement,
|
|
55
|
+
_a$autoWidth = _a.autoWidth,
|
|
56
|
+
autoWidth = _a$autoWidth === void 0 ? false : _a$autoWidth,
|
|
57
|
+
rest = tslib.__rest(_a, ["prefixCls", "className", "children", "data", "type", "placement", "autoWidth"]);
|
|
58
|
+
var _useRadioGroup = useRadioGroup.useRadioGroup(rest),
|
|
59
|
+
rootProps = _useRadioGroup.rootProps,
|
|
60
|
+
name = _useRadioGroup.name,
|
|
61
|
+
value = _useRadioGroup.value,
|
|
62
|
+
onChange = _useRadioGroup.onChange,
|
|
63
|
+
isChecked = _useRadioGroup.isChecked,
|
|
64
|
+
disabled = _useRadioGroup.disabled;
|
|
65
|
+
var providedValue = React.useMemo(function () {
|
|
66
|
+
return {
|
|
67
|
+
name: name,
|
|
68
|
+
onChange: onChange,
|
|
69
|
+
value: value,
|
|
70
|
+
isChecked: isChecked,
|
|
71
|
+
disabled: disabled,
|
|
72
|
+
type: type,
|
|
73
|
+
placement: placement
|
|
74
|
+
};
|
|
75
|
+
}, [name, onChange, value, isChecked, disabled, type, placement]);
|
|
76
|
+
var hasData = typeAssertion.isArrayNonEmpty(data);
|
|
77
|
+
// data 优先级大于内嵌式组合
|
|
78
|
+
if (hasData) {
|
|
79
|
+
children = data.map(function (_ref) {
|
|
80
|
+
var id = _ref.id,
|
|
81
|
+
disabled = _ref.disabled,
|
|
82
|
+
title = _ref.title;
|
|
83
|
+
return /*#__PURE__*/React__default["default"].createElement(Radio.Radio, {
|
|
84
|
+
key: id,
|
|
85
|
+
value: id,
|
|
86
|
+
name: name,
|
|
87
|
+
disabled: disabled,
|
|
88
|
+
checked: isChecked(id),
|
|
89
|
+
className: prefixCls + "__item"
|
|
90
|
+
}, title);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
var cls = classname.cx(prefixCls, className, prefixCls + "--placement-" + placement, autoWidth && type === types.RadioGroupTypeEnum.BUTTON && prefixCls + "--auto-width", prefixCls + "--type-" + type, hasData && prefixCls + "--data-wrap");
|
|
94
|
+
return /*#__PURE__*/React__default["default"].createElement(context.RadioGroupProvider, {
|
|
95
|
+
value: providedValue
|
|
96
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", Object.assign({
|
|
97
|
+
ref: ref,
|
|
98
|
+
className: cls
|
|
99
|
+
}, rootProps), children));
|
|
100
|
+
});
|
|
101
|
+
if (env.__DEV__) {
|
|
102
|
+
RadioGroup.displayName = 'RadioGroup';
|
|
103
|
+
}
|
|
104
|
+
exports.RadioGroup = RadioGroup;
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
|
13
|
+
value: true
|
|
14
|
+
});
|
|
15
|
+
var React = require('react');
|
|
16
|
+
|
|
17
|
+
/** @LICENSE
|
|
18
|
+
* @hi-ui/radio
|
|
19
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/
|
|
26
|
+
var RadioGroupContext = /*#__PURE__*/React.createContext(null);
|
|
27
|
+
var RadioGroupProvider = RadioGroupContext.Provider;
|
|
28
|
+
var useRadioGroupContext = function useRadioGroupContext() {
|
|
29
|
+
var context = React.useContext(RadioGroupContext);
|
|
30
|
+
// 允许 Radio 单独存在,不做检查
|
|
31
|
+
// if (!context) {
|
|
32
|
+
// throw new Error('The RadioGroupContext context should using in Radio.')
|
|
33
|
+
// }
|
|
34
|
+
return context;
|
|
35
|
+
};
|
|
36
|
+
exports.RadioGroupProvider = RadioGroupProvider;
|
|
37
|
+
exports.useRadioGroupContext = useRadioGroupContext;
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
|
13
|
+
value: true
|
|
14
|
+
});
|
|
15
|
+
require('./styles/index.scss.js');
|
|
16
|
+
var Radio$1 = require('./Radio.js');
|
|
17
|
+
var RadioGroup = require('./RadioGroup.js');
|
|
18
|
+
|
|
19
|
+
/** @LICENSE
|
|
20
|
+
* @hi-ui/radio
|
|
21
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
|
|
22
|
+
*
|
|
23
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the MIT license found in the
|
|
26
|
+
* LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/
|
|
28
|
+
var Radio = Object.assign(Radio$1.Radio, {
|
|
29
|
+
Group: RadioGroup.RadioGroup
|
|
30
|
+
});
|
|
31
|
+
exports.Radio = Radio$1.Radio;
|
|
32
|
+
exports.RadioGroup = RadioGroup.RadioGroup;
|
|
33
|
+
exports["default"] = Radio;
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
13
|
+
Object.defineProperty(exports, '__esModule', {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
var __styleInject__ = require('@hi-ui/style-inject');
|
|
17
|
+
function _interopDefaultCompat(e) {
|
|
18
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
19
|
+
'default': e
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
var __styleInject____default = /*#__PURE__*/_interopDefaultCompat(__styleInject__);
|
|
23
|
+
|
|
24
|
+
/** @LICENSE
|
|
25
|
+
* @hi-ui/radio
|
|
26
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
|
|
27
|
+
*
|
|
28
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the MIT license found in the
|
|
31
|
+
* LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/
|
|
33
|
+
var css_248z = ".hi-v4-radio {overflow-wrap: break-word;font-size: var(--hi-v4-text-size-md, 0.875rem);line-height: var(--hi-v4-text-lineheight-md, 1.375rem);position: relative;-webkit-box-sizing: border-box;box-sizing: border-box;cursor: pointer;display: -webkit-inline-box;display: -ms-inline-flexbox;display: inline-flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;vertical-align: middle;}.hi-v4-radio--type-button {height: 32px;padding: 0 12px;color: var(--hi-v4-color-gray-600, #5f6a7a);background: var(--hi-v4-color-gray-100, #f2f4f7);cursor: pointer;-webkit-transition: all var(--hi-v4-motion-duration-normal, 200ms);transition: all var(--hi-v4-motion-duration-normal, 200ms);}.hi-v4-radio--type-button .hi-v4-radio__input {display: none;}.hi-v4-radio--type-button .hi-v4-radio__input:focus + .hi-v4-radio__label {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-radio--type-button .hi-v4-radio__controller {display: none;}.hi-v4-radio--type-button:hover, .hi-v4-radio--type-button[data-checked] {background: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe));color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-radio--type-button[data-disabled] {cursor: not-allowed;background: var(--hi-v4-color-gray-200, #ebedf0);color: var(--hi-v4-color-gray-400, #b5bcc7);}.hi-v4-radio--type-button[data-checked].hi-v4-radio--type-button[data-disabled] {background: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe));color: var(--hi-v4-color-primary-300, var(--hi-v4-color-brandblue-300, #70b8ff));}.hi-v4-radio--type-default .hi-v4-radio__input:focus + .hi-v4-radio__controller {border-color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));-webkit-box-shadow: 0 0 0 2px var(--hi-v4-color-primary-100, var(--hi-v4-color-brandblue-100, #bde2ff));box-shadow: 0 0 0 2px var(--hi-v4-color-primary-100, var(--hi-v4-color-brandblue-100, #bde2ff));}.hi-v4-radio--type-default .hi-v4-radio__controller {display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-pack: center;-ms-flex-pack: center;justify-content: center;-webkit-box-align: center;-ms-flex-align: center;align-items: center;-webkit-box-orient: horizontal;-webkit-box-direction: normal;-ms-flex-direction: row;flex-direction: row;position: relative;-webkit-box-sizing: border-box;box-sizing: border-box;width: 16px;height: 16px;border: 1px solid var(--hi-v4-color-gray-300, #dfe2e8);border-radius: var(--hi-v4-border-radius-full, 9999px);-webkit-transition: all var(--hi-v4-motion-duration-normal, 200ms);transition: all var(--hi-v4-motion-duration-normal, 200ms);-webkit-box-flex: 0;-ms-flex: none;flex: none;}.hi-v4-radio--type-default .hi-v4-radio__controller::after {position: absolute;top: 0;left: 0;-webkit-box-sizing: border-box;box-sizing: border-box;display: inline-block;width: 14px;height: 14px;content: \"\";background: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));border-radius: var(--hi-v4-border-radius-full, 9999px);opacity: 0;-webkit-transition: all var(--hi-v4-motion-duration-normal, 200ms);transition: all var(--hi-v4-motion-duration-normal, 200ms);-webkit-transform: scale(0);transform: scale(0);}.hi-v4-radio--type-default .hi-v4-radio__label {-webkit-box-sizing: border-box;box-sizing: border-box;-webkit-margin-start: var(--hi-v4-spacing-4, 8px);margin-inline-start: var(--hi-v4-spacing-4, 8px);color: var(--hi-v4-color-gray-700, #1f2733);}.hi-v4-radio--type-default:hover .hi-v4-radio__controller {border-color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-radio--type-default[data-checked] .hi-v4-radio__controller {border-color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));background: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-radio--type-default[data-checked] .hi-v4-radio__controller::after {opacity: 1;-webkit-transform: scale(0.3);transform: scale(0.3);background-color: var(--hi-v4-color-static-white, #fff);}.hi-v4-radio--type-default[data-checked].hi-v4-radio--type-default[data-disabled] .hi-v4-radio__controller {border-color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));background: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));opacity: 0.4;}.hi-v4-radio--type-default[data-checked].hi-v4-radio--type-default[data-disabled] .hi-v4-radio__controller::after {opacity: 1;-webkit-transform: scale(0.3);transform: scale(0.3);background-color: var(--hi-v4-color-static-white, #fff);}.hi-v4-radio--type-default[data-disabled] {cursor: not-allowed;}.hi-v4-radio--type-default[data-disabled] .hi-v4-radio__controller {border-color: var(--hi-v4-color-gray-300, #dfe2e8);background: var(--hi-v4-color-gray-100, #f2f4f7);}.hi-v4-radio--type-default[data-disabled] .hi-v4-radio__controller::after {background: var(--hi-v4-color-gray-300, #dfe2e8);}.hi-v4-radio--type-default[data-disabled] .hi-v4-radio__label {color: var(--hi-v4-color-gray-500, #929aa6);}.hi-v4-radio-group {position: relative;}.hi-v4-radio-group--data-wrap {display: -webkit-inline-box;display: -ms-inline-flexbox;display: inline-flex;z-index: var(--hi-v4-zindex-normal, 0);}.hi-v4-radio-group--type-button {border-radius: var(--hi-v4-border-radius-md, 4px);overflow: hidden;}.hi-v4-radio-group--type-default.hi-v4-radio-group--data-wrap {gap: var(--hi-v4-spacing-8, 16px);}.hi-v4-radio-group--placement-horizontal.hi-v4-radio-group--data-wrap {-webkit-box-align: center;-ms-flex-align: center;align-items: center;}.hi-v4-radio-group--placement-horizontal.hi-v4-radio-group--auto-width {display: -webkit-box;display: -ms-flexbox;display: flex;}.hi-v4-radio-group--placement-horizontal.hi-v4-radio-group--auto-width .hi-v4-radio--type-button {-webkit-box-flex: 1;-ms-flex: 1 1;flex: 1 1;-webkit-box-pack: center;-ms-flex-pack: center;justify-content: center;}.hi-v4-radio-group--placement-horizontal .hi-v4-radio--type-button::after {content: \"\";background: var(--hi-v4-color-gray-300, #dfe2e8);width: 1px;left: 100%;top: 8px;bottom: 8px;position: absolute;z-index: var(--hi-v4-zindex-absolute, 1);}.hi-v4-radio-group--placement-vertical {-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;}.hi-v4-radio-group--placement-vertical .hi-v4-radio--type-button::after {content: \"\";background: var(--hi-v4-color-gray-300, #dfe2e8);height: 1px;left: 8px;right: 8px;top: 100%;position: absolute;z-index: var(--hi-v4-zindex-absolute, 1);}";
|
|
34
|
+
__styleInject____default["default"](css_248z);
|
|
35
|
+
exports["default"] = css_248z;
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
|
13
|
+
value: true
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
/** @LICENSE
|
|
17
|
+
* @hi-ui/radio
|
|
18
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
|
|
19
|
+
*
|
|
20
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
21
|
+
*
|
|
22
|
+
* This source code is licensed under the MIT license found in the
|
|
23
|
+
* LICENSE file in the root directory of this source tree.
|
|
24
|
+
*/
|
|
25
|
+
var RadioGroupPlacementEnum = {
|
|
26
|
+
VERTICAL: 'vertical',
|
|
27
|
+
HORIZONTAL: 'horizontal'
|
|
28
|
+
};
|
|
29
|
+
var RadioGroupTypeEnum = {
|
|
30
|
+
DEFAULT: 'default',
|
|
31
|
+
BUTTON: 'button'
|
|
32
|
+
};
|
|
33
|
+
exports.RadioGroupPlacementEnum = RadioGroupPlacementEnum;
|
|
34
|
+
exports.RadioGroupTypeEnum = RadioGroupTypeEnum;
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
|
13
|
+
value: true
|
|
14
|
+
});
|
|
15
|
+
var tslib = require('tslib');
|
|
16
|
+
var React = require('react');
|
|
17
|
+
var useUncontrolledState = require('@hi-ui/use-uncontrolled-state');
|
|
18
|
+
|
|
19
|
+
/** @LICENSE
|
|
20
|
+
* @hi-ui/radio
|
|
21
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
|
|
22
|
+
*
|
|
23
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the MIT license found in the
|
|
26
|
+
* LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/
|
|
28
|
+
var useRadioGroup = function useRadioGroup(_a) {
|
|
29
|
+
var name = _a.name,
|
|
30
|
+
valueProp = _a.value,
|
|
31
|
+
onChange = _a.onChange,
|
|
32
|
+
_a$defaultValue = _a.defaultValue,
|
|
33
|
+
defaultValue = _a$defaultValue === void 0 ? '' : _a$defaultValue,
|
|
34
|
+
_a$disabled = _a.disabled,
|
|
35
|
+
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
|
36
|
+
rest = tslib.__rest(_a, ["name", "value", "onChange", "defaultValue", "disabled"]);
|
|
37
|
+
var _useUncontrolledState = useUncontrolledState.useUncontrolledState(defaultValue, valueProp, onChange),
|
|
38
|
+
value = _useUncontrolledState[0],
|
|
39
|
+
tryChangeValue = _useUncontrolledState[1];
|
|
40
|
+
var handleChange = React.useCallback(function (value) {
|
|
41
|
+
if (disabled) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
tryChangeValue(value);
|
|
45
|
+
}, [disabled, tryChangeValue]);
|
|
46
|
+
var isChecked = React.useCallback(function (valueArg) {
|
|
47
|
+
return valueArg === value;
|
|
48
|
+
}, [value]);
|
|
49
|
+
var rootProps = Object.assign(Object.assign({}, rest), {
|
|
50
|
+
role: 'radiogroup'
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
rootProps: rootProps,
|
|
54
|
+
value: value,
|
|
55
|
+
onChange: handleChange,
|
|
56
|
+
name: name,
|
|
57
|
+
isChecked: isChecked,
|
|
58
|
+
disabled: disabled
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
exports.useRadioGroup = useRadioGroup;
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
|
13
|
+
value: true
|
|
14
|
+
});
|
|
15
|
+
var tslib = require('tslib');
|
|
16
|
+
var React = require('react');
|
|
17
|
+
var useUncontrolledState = require('@hi-ui/use-uncontrolled-state');
|
|
18
|
+
var domUtils = require('@hi-ui/dom-utils');
|
|
19
|
+
|
|
20
|
+
/** @LICENSE
|
|
21
|
+
* @hi-ui/radio
|
|
22
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
|
|
23
|
+
*
|
|
24
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
25
|
+
*
|
|
26
|
+
* This source code is licensed under the MIT license found in the
|
|
27
|
+
* LICENSE file in the root directory of this source tree.
|
|
28
|
+
*/
|
|
29
|
+
var useRadio = function useRadio(_a) {
|
|
30
|
+
var nameProp = _a.name,
|
|
31
|
+
valueProp = _a.value,
|
|
32
|
+
_a$autoFocus = _a.autoFocus,
|
|
33
|
+
autoFocus = _a$autoFocus === void 0 ? false : _a$autoFocus,
|
|
34
|
+
_a$defaultChecked = _a.defaultChecked,
|
|
35
|
+
defaultChecked = _a$defaultChecked === void 0 ? false : _a$defaultChecked,
|
|
36
|
+
onChange = _a.onChange,
|
|
37
|
+
checkedProp = _a.checked,
|
|
38
|
+
_a$readOnly = _a.readOnly,
|
|
39
|
+
readOnly = _a$readOnly === void 0 ? false : _a$readOnly,
|
|
40
|
+
_a$disabled = _a.disabled,
|
|
41
|
+
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
|
42
|
+
rest = tslib.__rest(_a, ["name", "value", "autoFocus", "defaultChecked", "onChange", "checked", "readOnly", "disabled"]);
|
|
43
|
+
var _useUncontrolledState = useUncontrolledState.useUncontrolledState(defaultChecked, checkedProp, function (_, evt) {
|
|
44
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(evt);
|
|
45
|
+
}),
|
|
46
|
+
checked = _useUncontrolledState[0],
|
|
47
|
+
tryChangeChecked = _useUncontrolledState[1];
|
|
48
|
+
var nonInteractive = disabled || readOnly;
|
|
49
|
+
var handleChange = React.useCallback(function (evt) {
|
|
50
|
+
if (nonInteractive) {
|
|
51
|
+
// 不可交互,不触发事件的任何默认行为
|
|
52
|
+
evt.preventDefault();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
tryChangeChecked(evt.target.checked, evt);
|
|
56
|
+
}, [nonInteractive, tryChangeChecked]);
|
|
57
|
+
var getInputProps = React.useCallback(function () {
|
|
58
|
+
return {
|
|
59
|
+
style: domUtils.hiddenStyle,
|
|
60
|
+
type: 'radio',
|
|
61
|
+
checked: checked,
|
|
62
|
+
disabled: disabled,
|
|
63
|
+
readOnly: readOnly,
|
|
64
|
+
onChange: handleChange,
|
|
65
|
+
autoFocus: autoFocus,
|
|
66
|
+
name: nameProp,
|
|
67
|
+
value: valueProp
|
|
68
|
+
};
|
|
69
|
+
}, [nameProp, handleChange, checked, disabled, readOnly, autoFocus, valueProp]);
|
|
70
|
+
var state = React.useMemo(function () {
|
|
71
|
+
return {
|
|
72
|
+
disabled: disabled,
|
|
73
|
+
checked: checked,
|
|
74
|
+
readOnly: readOnly
|
|
75
|
+
};
|
|
76
|
+
}, [disabled, checked, readOnly]);
|
|
77
|
+
var rootProps = Object.assign(Object.assign({}, rest), {
|
|
78
|
+
'data-disabled': domUtils.setAttrStatus(disabled),
|
|
79
|
+
'data-checked': domUtils.setAttrStatus(checked),
|
|
80
|
+
'data-readonly': domUtils.setAttrStatus(readOnly)
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
state: state,
|
|
84
|
+
rootProps: rootProps,
|
|
85
|
+
getInputProps: getInputProps
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
exports.useRadio = useRadio;
|
package/lib/esm/Table.js
CHANGED
|
@@ -20,6 +20,7 @@ import { withDefaultProps } from '@hi-ui/react-utils';
|
|
|
20
20
|
import { TableSettingMenu } from './TableSettingMenu.js';
|
|
21
21
|
import Loading from '@hi-ui/loading';
|
|
22
22
|
import Checkbox from '@hi-ui/checkbox';
|
|
23
|
+
import Radio from './packages/ui/radio/lib/esm/index.js';
|
|
23
24
|
import { useTableCheck } from './hooks/use-check.js';
|
|
24
25
|
import { isNullish } from '@hi-ui/type-assertion';
|
|
25
26
|
import { cloneTree, flattenTree } from '@hi-ui/tree-utils';
|
|
@@ -180,16 +181,19 @@ var Table = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
180
181
|
tryCheckAllRow = _useTableCheck.tryCheckAllRow,
|
|
181
182
|
isCheckedRowKey = _useTableCheck.isCheckedRowKey,
|
|
182
183
|
onCheckedRowKeysChange = _useTableCheck.onCheckedRowKeysChange,
|
|
184
|
+
onRadioCheckedRowKeysChange = _useTableCheck.onRadioCheckedRowKeysChange,
|
|
183
185
|
checkRowIsDisabledCheckbox = _useTableCheck.checkRowIsDisabledCheckbox;
|
|
184
186
|
// 表格列多选操作区
|
|
185
187
|
var getSelectionColumn = React__default.useCallback(function (rowSelection) {
|
|
188
|
+
var _rowSelection$type = rowSelection.type,
|
|
189
|
+
type = _rowSelection$type === void 0 ? 'checkbox' : _rowSelection$type;
|
|
186
190
|
var renderCell = function renderCell(_, rowItem, rowIndex) {
|
|
187
191
|
var rowKey = getRowKeyField(rowItem);
|
|
188
192
|
var checked = isCheckedRowKey(rowKey);
|
|
189
193
|
var disabledCheckbox = checkRowIsDisabledCheckbox(rowItem);
|
|
190
194
|
return {
|
|
191
|
-
node: ( /*#__PURE__*/React__default.createElement(Checkbox, {
|
|
192
|
-
checked:
|
|
195
|
+
node: type === 'checkbox' ? ( /*#__PURE__*/React__default.createElement(Checkbox, {
|
|
196
|
+
checked: checked,
|
|
193
197
|
disabled: disabledCheckbox,
|
|
194
198
|
onChange: function onChange(evt) {
|
|
195
199
|
onCheckedRowKeysChange(rowItem, evt.target.checked);
|
|
@@ -197,6 +201,15 @@ var Table = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
197
201
|
onClick: function onClick(evt) {
|
|
198
202
|
evt.stopPropagation();
|
|
199
203
|
}
|
|
204
|
+
})) : ( /*#__PURE__*/React__default.createElement(Radio, {
|
|
205
|
+
checked: checked,
|
|
206
|
+
disabled: disabledCheckbox,
|
|
207
|
+
onChange: function onChange(evt) {
|
|
208
|
+
onRadioCheckedRowKeysChange(rowItem, evt.target.checked);
|
|
209
|
+
},
|
|
210
|
+
onClick: function onClick(evt) {
|
|
211
|
+
evt.stopPropagation();
|
|
212
|
+
}
|
|
200
213
|
})),
|
|
201
214
|
checked: checked
|
|
202
215
|
};
|
|
@@ -247,12 +260,12 @@ var Table = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
247
260
|
// selectionColumn 宽度固定,防止自动被拉伸
|
|
248
261
|
fixed: true,
|
|
249
262
|
className: prefixCls + "__selection-col",
|
|
250
|
-
title: renderSelectionTitleCell,
|
|
263
|
+
title: type === 'checkbox' ? renderSelectionTitleCell : undefined,
|
|
251
264
|
// @ts-ignore
|
|
252
265
|
render: renderSelectionCell
|
|
253
266
|
};
|
|
254
267
|
return selectionColumn;
|
|
255
|
-
}, [
|
|
268
|
+
}, [checkboxColWidth, prefixCls, getRowKeyField, isCheckedRowKey, checkRowIsDisabledCheckbox, onCheckedRowKeysChange, onRadioCheckedRowKeysChange, checkedAll, semiChecked, tryCheckAllRow]);
|
|
256
269
|
var mergedColumns = React__default.useMemo(function () {
|
|
257
270
|
if (rowSelection) {
|
|
258
271
|
var selectionColumn = getSelectionColumn(rowSelection);
|
|
@@ -59,6 +59,13 @@ var useTableCheck = function useTableCheck(_ref) {
|
|
|
59
59
|
}
|
|
60
60
|
handleCheckedRowKeysChange(rowItem, checked);
|
|
61
61
|
}, [checkedRowDataItems, checkedRowKeys, fieldKey, handleCheckedRowKeysChange]);
|
|
62
|
+
var onRadioCheckedRowKeysChange = React__default.useCallback(function (rowItem, checked) {
|
|
63
|
+
var _a;
|
|
64
|
+
checkedRowDataItemsRef.current = [rowItem];
|
|
65
|
+
trySetCheckedRowKeys((_a = checkedRowDataItemsRef.current) === null || _a === void 0 ? void 0 : _a.map(function (item) {
|
|
66
|
+
return item[fieldKey];
|
|
67
|
+
}), rowItem, checked, checkedRowDataItemsRef.current);
|
|
68
|
+
}, [fieldKey, trySetCheckedRowKeys]);
|
|
62
69
|
// 判断是否全选
|
|
63
70
|
var _React$useMemo = React__default.useMemo(function () {
|
|
64
71
|
if (rowSelection) {
|
|
@@ -118,12 +125,13 @@ var useTableCheck = function useTableCheck(_ref) {
|
|
|
118
125
|
});
|
|
119
126
|
return Array.from(checkedRowKeysSet);
|
|
120
127
|
}, targetRowItems, true, checkedRowDataItemsRef.current);
|
|
121
|
-
}, [
|
|
128
|
+
}, [flattedData, checkedAll, trySetCheckedRowKeys, checkRowIsDisabledCheckbox, fieldKey]);
|
|
122
129
|
return {
|
|
123
130
|
tryCheckAllRow: tryCheckAllRow,
|
|
124
131
|
checkedAll: checkedAll,
|
|
125
132
|
semiChecked: semiChecked,
|
|
126
133
|
onCheckedRowKeysChange: onCheckedRowKeysChange,
|
|
134
|
+
onRadioCheckedRowKeysChange: onRadioCheckedRowKeysChange,
|
|
127
135
|
isCheckedRowKey: isCheckedRowKey,
|
|
128
136
|
checkedRowKeys: checkedRowKeys,
|
|
129
137
|
trySetCheckedRowKeys: trySetCheckedRowKeys,
|
|
@@ -92,14 +92,16 @@ var useColWidth = function useColWidth(_ref) {
|
|
|
92
92
|
}
|
|
93
93
|
}, [getVirtualWidths, virtual]);
|
|
94
94
|
useUpdateEffect(function () {
|
|
95
|
-
setColWidths(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
setColWidths(getGroupItemWidth(columns));
|
|
96
|
+
// setColWidths((prev) => {
|
|
97
|
+
// // resizable 模式下通过 measureRowElementRef.current 去更新列宽,防止拖拽后宽度被重置
|
|
98
|
+
// // 例如同时设置了 resizable 和 rowSelection,当拖拽某列宽度后再选中某行时,该列宽度会被重置
|
|
99
|
+
// return resizable && measureRowElementRef.current?.childNodes.length === prev.length
|
|
100
|
+
// ? // 走更新逻辑
|
|
101
|
+
// getWidths(measureRowElementRef.current)
|
|
102
|
+
// : // 当列数变化时重新走初始化逻辑
|
|
103
|
+
// getGroupItemWidth(columns)
|
|
104
|
+
// })
|
|
103
105
|
}, [columns]);
|
|
104
106
|
/**
|
|
105
107
|
* 根据实际内容区(table 的第一行)渲染,再次精确收集并设置每列宽度
|
|
@@ -0,0 +1,88 @@
|
|
|
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 React__default, { forwardRef } from 'react';
|
|
12
|
+
import { getPrefixCls, cx } from '@hi-ui/classname';
|
|
13
|
+
import { __DEV__ } from '@hi-ui/env';
|
|
14
|
+
import { useRadio } from './use-radio.js';
|
|
15
|
+
import { useRadioGroupContext } from './context.js';
|
|
16
|
+
import { isNullish } from '@hi-ui/type-assertion';
|
|
17
|
+
import { callAllFuncs } from '@hi-ui/func-utils';
|
|
18
|
+
|
|
19
|
+
/** @LICENSE
|
|
20
|
+
* @hi-ui/radio
|
|
21
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
|
|
22
|
+
*
|
|
23
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the MIT license found in the
|
|
26
|
+
* LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/
|
|
28
|
+
var RADIO_PREFIX = getPrefixCls('radio');
|
|
29
|
+
/**
|
|
30
|
+
* 单选
|
|
31
|
+
*/
|
|
32
|
+
var Radio = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
33
|
+
var _a$prefixCls = _a.prefixCls,
|
|
34
|
+
prefixCls = _a$prefixCls === void 0 ? RADIO_PREFIX : _a$prefixCls,
|
|
35
|
+
_a$role = _a.role,
|
|
36
|
+
role = _a$role === void 0 ? 'radio' : _a$role,
|
|
37
|
+
className = _a.className,
|
|
38
|
+
children = _a.children,
|
|
39
|
+
rest = __rest(_a, ["prefixCls", "role", "className", "children"]);
|
|
40
|
+
var groupContext = useRadioGroupContext();
|
|
41
|
+
var _ref = groupContext || {},
|
|
42
|
+
disabledContext = _ref.disabled,
|
|
43
|
+
isCheckedContext = _ref.isChecked,
|
|
44
|
+
nameContext = _ref.name,
|
|
45
|
+
onChangeContext = _ref.onChange,
|
|
46
|
+
_ref$type = _ref.type,
|
|
47
|
+
type = _ref$type === void 0 ? 'default' : _ref$type;
|
|
48
|
+
var checkedProp = rest.checked,
|
|
49
|
+
valueProp = rest.value,
|
|
50
|
+
_rest$disabled = rest.disabled,
|
|
51
|
+
disabled = _rest$disabled === void 0 ? disabledContext : _rest$disabled,
|
|
52
|
+
_rest$name = rest.name,
|
|
53
|
+
name = _rest$name === void 0 ? nameContext : _rest$name,
|
|
54
|
+
onChangeProp = rest.onChange;
|
|
55
|
+
// Group's priority is higher than its own.
|
|
56
|
+
var checked = isCheckedContext && !isNullish(valueProp) ? isCheckedContext(valueProp) : checkedProp;
|
|
57
|
+
var onChange = onChangeContext && !isNullish(valueProp) ? callAllFuncs(function (evt) {
|
|
58
|
+
if (evt.target.checked) {
|
|
59
|
+
onChangeContext(valueProp);
|
|
60
|
+
}
|
|
61
|
+
}, onChangeProp) : onChangeProp;
|
|
62
|
+
var _useRadio = useRadio(Object.assign(Object.assign({}, rest), {
|
|
63
|
+
disabled: disabled,
|
|
64
|
+
name: name,
|
|
65
|
+
checked: checked,
|
|
66
|
+
onChange: onChange
|
|
67
|
+
})),
|
|
68
|
+
rootProps = _useRadio.rootProps,
|
|
69
|
+
getInputProps = _useRadio.getInputProps;
|
|
70
|
+
var inputProps = getInputProps();
|
|
71
|
+
var cls = cx(prefixCls, className, prefixCls + "--type-" + type);
|
|
72
|
+
return /*#__PURE__*/React__default.createElement("label", Object.assign({
|
|
73
|
+
ref: ref,
|
|
74
|
+
role: role,
|
|
75
|
+
className: cls
|
|
76
|
+
}, rootProps), /*#__PURE__*/React__default.createElement("input", Object.assign({}, inputProps, {
|
|
77
|
+
tabIndex: 0,
|
|
78
|
+
className: prefixCls + "__input"
|
|
79
|
+
})), /*#__PURE__*/React__default.createElement("span", {
|
|
80
|
+
className: prefixCls + "__controller"
|
|
81
|
+
}), children ? /*#__PURE__*/React__default.createElement("span", {
|
|
82
|
+
className: prefixCls + "__label"
|
|
83
|
+
}, children) : null);
|
|
84
|
+
});
|
|
85
|
+
if (__DEV__) {
|
|
86
|
+
Radio.displayName = 'Radio';
|
|
87
|
+
}
|
|
88
|
+
export { Radio };
|
|
@@ -0,0 +1,92 @@
|
|
|
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 React__default, { forwardRef, useMemo } from 'react';
|
|
12
|
+
import { getPrefixCls, cx } from '@hi-ui/classname';
|
|
13
|
+
import { __DEV__ } from '@hi-ui/env';
|
|
14
|
+
import { useRadioGroup } from './use-radio-group.js';
|
|
15
|
+
import { RadioGroupProvider } from './context.js';
|
|
16
|
+
import { RadioGroupTypeEnum, RadioGroupPlacementEnum } from './types.js';
|
|
17
|
+
import { isArrayNonEmpty } from '@hi-ui/type-assertion';
|
|
18
|
+
import { Radio } from './Radio.js';
|
|
19
|
+
|
|
20
|
+
/** @LICENSE
|
|
21
|
+
* @hi-ui/radio
|
|
22
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
|
|
23
|
+
*
|
|
24
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
25
|
+
*
|
|
26
|
+
* This source code is licensed under the MIT license found in the
|
|
27
|
+
* LICENSE file in the root directory of this source tree.
|
|
28
|
+
*/
|
|
29
|
+
var RADIO_GROUP_PREFIX = getPrefixCls('radio-group');
|
|
30
|
+
/**
|
|
31
|
+
* 单选组合器
|
|
32
|
+
*/
|
|
33
|
+
var RadioGroup = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
34
|
+
var _a$prefixCls = _a.prefixCls,
|
|
35
|
+
prefixCls = _a$prefixCls === void 0 ? RADIO_GROUP_PREFIX : _a$prefixCls,
|
|
36
|
+
className = _a.className,
|
|
37
|
+
children = _a.children,
|
|
38
|
+
data = _a.data,
|
|
39
|
+
_a$type = _a.type,
|
|
40
|
+
type = _a$type === void 0 ? RadioGroupTypeEnum.DEFAULT : _a$type,
|
|
41
|
+
_a$placement = _a.placement,
|
|
42
|
+
placement = _a$placement === void 0 ? RadioGroupPlacementEnum.HORIZONTAL : _a$placement,
|
|
43
|
+
_a$autoWidth = _a.autoWidth,
|
|
44
|
+
autoWidth = _a$autoWidth === void 0 ? false : _a$autoWidth,
|
|
45
|
+
rest = __rest(_a, ["prefixCls", "className", "children", "data", "type", "placement", "autoWidth"]);
|
|
46
|
+
var _useRadioGroup = useRadioGroup(rest),
|
|
47
|
+
rootProps = _useRadioGroup.rootProps,
|
|
48
|
+
name = _useRadioGroup.name,
|
|
49
|
+
value = _useRadioGroup.value,
|
|
50
|
+
onChange = _useRadioGroup.onChange,
|
|
51
|
+
isChecked = _useRadioGroup.isChecked,
|
|
52
|
+
disabled = _useRadioGroup.disabled;
|
|
53
|
+
var providedValue = useMemo(function () {
|
|
54
|
+
return {
|
|
55
|
+
name: name,
|
|
56
|
+
onChange: onChange,
|
|
57
|
+
value: value,
|
|
58
|
+
isChecked: isChecked,
|
|
59
|
+
disabled: disabled,
|
|
60
|
+
type: type,
|
|
61
|
+
placement: placement
|
|
62
|
+
};
|
|
63
|
+
}, [name, onChange, value, isChecked, disabled, type, placement]);
|
|
64
|
+
var hasData = isArrayNonEmpty(data);
|
|
65
|
+
// data 优先级大于内嵌式组合
|
|
66
|
+
if (hasData) {
|
|
67
|
+
children = data.map(function (_ref) {
|
|
68
|
+
var id = _ref.id,
|
|
69
|
+
disabled = _ref.disabled,
|
|
70
|
+
title = _ref.title;
|
|
71
|
+
return /*#__PURE__*/React__default.createElement(Radio, {
|
|
72
|
+
key: id,
|
|
73
|
+
value: id,
|
|
74
|
+
name: name,
|
|
75
|
+
disabled: disabled,
|
|
76
|
+
checked: isChecked(id),
|
|
77
|
+
className: prefixCls + "__item"
|
|
78
|
+
}, title);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
var cls = cx(prefixCls, className, prefixCls + "--placement-" + placement, autoWidth && type === RadioGroupTypeEnum.BUTTON && prefixCls + "--auto-width", prefixCls + "--type-" + type, hasData && prefixCls + "--data-wrap");
|
|
82
|
+
return /*#__PURE__*/React__default.createElement(RadioGroupProvider, {
|
|
83
|
+
value: providedValue
|
|
84
|
+
}, /*#__PURE__*/React__default.createElement("div", Object.assign({
|
|
85
|
+
ref: ref,
|
|
86
|
+
className: cls
|
|
87
|
+
}, rootProps), children));
|
|
88
|
+
});
|
|
89
|
+
if (__DEV__) {
|
|
90
|
+
RadioGroup.displayName = 'RadioGroup';
|
|
91
|
+
}
|
|
92
|
+
export { RadioGroup };
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { useContext, createContext } from 'react';
|
|
11
|
+
|
|
12
|
+
/** @LICENSE
|
|
13
|
+
* @hi-ui/radio
|
|
14
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
17
|
+
*
|
|
18
|
+
* This source code is licensed under the MIT license found in the
|
|
19
|
+
* LICENSE file in the root directory of this source tree.
|
|
20
|
+
*/
|
|
21
|
+
var RadioGroupContext = /*#__PURE__*/createContext(null);
|
|
22
|
+
var RadioGroupProvider = RadioGroupContext.Provider;
|
|
23
|
+
var useRadioGroupContext = function useRadioGroupContext() {
|
|
24
|
+
var context = useContext(RadioGroupContext);
|
|
25
|
+
// 允许 Radio 单独存在,不做检查
|
|
26
|
+
// if (!context) {
|
|
27
|
+
// throw new Error('The RadioGroupContext context should using in Radio.')
|
|
28
|
+
// }
|
|
29
|
+
return context;
|
|
30
|
+
};
|
|
31
|
+
export { RadioGroupProvider, useRadioGroupContext };
|
|
@@ -0,0 +1,26 @@
|
|
|
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 './styles/index.scss.js';
|
|
11
|
+
import { Radio as Radio$1 } from './Radio.js';
|
|
12
|
+
import { RadioGroup } from './RadioGroup.js';
|
|
13
|
+
|
|
14
|
+
/** @LICENSE
|
|
15
|
+
* @hi-ui/radio
|
|
16
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
|
|
17
|
+
*
|
|
18
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the MIT license found in the
|
|
21
|
+
* LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/
|
|
23
|
+
var Radio = Object.assign(Radio$1, {
|
|
24
|
+
Group: RadioGroup
|
|
25
|
+
});
|
|
26
|
+
export { Radio$1 as Radio, RadioGroup, Radio as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
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 __styleInject__ from '@hi-ui/style-inject';
|
|
11
|
+
|
|
12
|
+
/** @LICENSE
|
|
13
|
+
* @hi-ui/radio
|
|
14
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
17
|
+
*
|
|
18
|
+
* This source code is licensed under the MIT license found in the
|
|
19
|
+
* LICENSE file in the root directory of this source tree.
|
|
20
|
+
*/
|
|
21
|
+
var css_248z = ".hi-v4-radio {overflow-wrap: break-word;font-size: var(--hi-v4-text-size-md, 0.875rem);line-height: var(--hi-v4-text-lineheight-md, 1.375rem);position: relative;-webkit-box-sizing: border-box;box-sizing: border-box;cursor: pointer;display: -webkit-inline-box;display: -ms-inline-flexbox;display: inline-flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;vertical-align: middle;}.hi-v4-radio--type-button {height: 32px;padding: 0 12px;color: var(--hi-v4-color-gray-600, #5f6a7a);background: var(--hi-v4-color-gray-100, #f2f4f7);cursor: pointer;-webkit-transition: all var(--hi-v4-motion-duration-normal, 200ms);transition: all var(--hi-v4-motion-duration-normal, 200ms);}.hi-v4-radio--type-button .hi-v4-radio__input {display: none;}.hi-v4-radio--type-button .hi-v4-radio__input:focus + .hi-v4-radio__label {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-radio--type-button .hi-v4-radio__controller {display: none;}.hi-v4-radio--type-button:hover, .hi-v4-radio--type-button[data-checked] {background: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe));color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-radio--type-button[data-disabled] {cursor: not-allowed;background: var(--hi-v4-color-gray-200, #ebedf0);color: var(--hi-v4-color-gray-400, #b5bcc7);}.hi-v4-radio--type-button[data-checked].hi-v4-radio--type-button[data-disabled] {background: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe));color: var(--hi-v4-color-primary-300, var(--hi-v4-color-brandblue-300, #70b8ff));}.hi-v4-radio--type-default .hi-v4-radio__input:focus + .hi-v4-radio__controller {border-color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));-webkit-box-shadow: 0 0 0 2px var(--hi-v4-color-primary-100, var(--hi-v4-color-brandblue-100, #bde2ff));box-shadow: 0 0 0 2px var(--hi-v4-color-primary-100, var(--hi-v4-color-brandblue-100, #bde2ff));}.hi-v4-radio--type-default .hi-v4-radio__controller {display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-pack: center;-ms-flex-pack: center;justify-content: center;-webkit-box-align: center;-ms-flex-align: center;align-items: center;-webkit-box-orient: horizontal;-webkit-box-direction: normal;-ms-flex-direction: row;flex-direction: row;position: relative;-webkit-box-sizing: border-box;box-sizing: border-box;width: 16px;height: 16px;border: 1px solid var(--hi-v4-color-gray-300, #dfe2e8);border-radius: var(--hi-v4-border-radius-full, 9999px);-webkit-transition: all var(--hi-v4-motion-duration-normal, 200ms);transition: all var(--hi-v4-motion-duration-normal, 200ms);-webkit-box-flex: 0;-ms-flex: none;flex: none;}.hi-v4-radio--type-default .hi-v4-radio__controller::after {position: absolute;top: 0;left: 0;-webkit-box-sizing: border-box;box-sizing: border-box;display: inline-block;width: 14px;height: 14px;content: \"\";background: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));border-radius: var(--hi-v4-border-radius-full, 9999px);opacity: 0;-webkit-transition: all var(--hi-v4-motion-duration-normal, 200ms);transition: all var(--hi-v4-motion-duration-normal, 200ms);-webkit-transform: scale(0);transform: scale(0);}.hi-v4-radio--type-default .hi-v4-radio__label {-webkit-box-sizing: border-box;box-sizing: border-box;-webkit-margin-start: var(--hi-v4-spacing-4, 8px);margin-inline-start: var(--hi-v4-spacing-4, 8px);color: var(--hi-v4-color-gray-700, #1f2733);}.hi-v4-radio--type-default:hover .hi-v4-radio__controller {border-color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-radio--type-default[data-checked] .hi-v4-radio__controller {border-color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));background: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-radio--type-default[data-checked] .hi-v4-radio__controller::after {opacity: 1;-webkit-transform: scale(0.3);transform: scale(0.3);background-color: var(--hi-v4-color-static-white, #fff);}.hi-v4-radio--type-default[data-checked].hi-v4-radio--type-default[data-disabled] .hi-v4-radio__controller {border-color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));background: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));opacity: 0.4;}.hi-v4-radio--type-default[data-checked].hi-v4-radio--type-default[data-disabled] .hi-v4-radio__controller::after {opacity: 1;-webkit-transform: scale(0.3);transform: scale(0.3);background-color: var(--hi-v4-color-static-white, #fff);}.hi-v4-radio--type-default[data-disabled] {cursor: not-allowed;}.hi-v4-radio--type-default[data-disabled] .hi-v4-radio__controller {border-color: var(--hi-v4-color-gray-300, #dfe2e8);background: var(--hi-v4-color-gray-100, #f2f4f7);}.hi-v4-radio--type-default[data-disabled] .hi-v4-radio__controller::after {background: var(--hi-v4-color-gray-300, #dfe2e8);}.hi-v4-radio--type-default[data-disabled] .hi-v4-radio__label {color: var(--hi-v4-color-gray-500, #929aa6);}.hi-v4-radio-group {position: relative;}.hi-v4-radio-group--data-wrap {display: -webkit-inline-box;display: -ms-inline-flexbox;display: inline-flex;z-index: var(--hi-v4-zindex-normal, 0);}.hi-v4-radio-group--type-button {border-radius: var(--hi-v4-border-radius-md, 4px);overflow: hidden;}.hi-v4-radio-group--type-default.hi-v4-radio-group--data-wrap {gap: var(--hi-v4-spacing-8, 16px);}.hi-v4-radio-group--placement-horizontal.hi-v4-radio-group--data-wrap {-webkit-box-align: center;-ms-flex-align: center;align-items: center;}.hi-v4-radio-group--placement-horizontal.hi-v4-radio-group--auto-width {display: -webkit-box;display: -ms-flexbox;display: flex;}.hi-v4-radio-group--placement-horizontal.hi-v4-radio-group--auto-width .hi-v4-radio--type-button {-webkit-box-flex: 1;-ms-flex: 1 1;flex: 1 1;-webkit-box-pack: center;-ms-flex-pack: center;justify-content: center;}.hi-v4-radio-group--placement-horizontal .hi-v4-radio--type-button::after {content: \"\";background: var(--hi-v4-color-gray-300, #dfe2e8);width: 1px;left: 100%;top: 8px;bottom: 8px;position: absolute;z-index: var(--hi-v4-zindex-absolute, 1);}.hi-v4-radio-group--placement-vertical {-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;}.hi-v4-radio-group--placement-vertical .hi-v4-radio--type-button::after {content: \"\";background: var(--hi-v4-color-gray-300, #dfe2e8);height: 1px;left: 8px;right: 8px;top: 100%;position: absolute;z-index: var(--hi-v4-zindex-absolute, 1);}";
|
|
22
|
+
__styleInject__(css_248z);
|
|
23
|
+
export { css_248z as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
/** @LICENSE
|
|
11
|
+
* @hi-ui/radio
|
|
12
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
15
|
+
*
|
|
16
|
+
* This source code is licensed under the MIT license found in the
|
|
17
|
+
* LICENSE file in the root directory of this source tree.
|
|
18
|
+
*/
|
|
19
|
+
var RadioGroupPlacementEnum = {
|
|
20
|
+
VERTICAL: 'vertical',
|
|
21
|
+
HORIZONTAL: 'horizontal'
|
|
22
|
+
};
|
|
23
|
+
var RadioGroupTypeEnum = {
|
|
24
|
+
DEFAULT: 'default',
|
|
25
|
+
BUTTON: 'button'
|
|
26
|
+
};
|
|
27
|
+
export { RadioGroupPlacementEnum, RadioGroupTypeEnum };
|
|
@@ -0,0 +1,56 @@
|
|
|
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 } from 'react';
|
|
12
|
+
import { useUncontrolledState } from '@hi-ui/use-uncontrolled-state';
|
|
13
|
+
|
|
14
|
+
/** @LICENSE
|
|
15
|
+
* @hi-ui/radio
|
|
16
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/radio#readme
|
|
17
|
+
*
|
|
18
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the MIT license found in the
|
|
21
|
+
* LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/
|
|
23
|
+
var useRadioGroup = function useRadioGroup(_a) {
|
|
24
|
+
var name = _a.name,
|
|
25
|
+
valueProp = _a.value,
|
|
26
|
+
onChange = _a.onChange,
|
|
27
|
+
_a$defaultValue = _a.defaultValue,
|
|
28
|
+
defaultValue = _a$defaultValue === void 0 ? '' : _a$defaultValue,
|
|
29
|
+
_a$disabled = _a.disabled,
|
|
30
|
+
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
|
31
|
+
rest = __rest(_a, ["name", "value", "onChange", "defaultValue", "disabled"]);
|
|
32
|
+
var _useUncontrolledState = useUncontrolledState(defaultValue, valueProp, onChange),
|
|
33
|
+
value = _useUncontrolledState[0],
|
|
34
|
+
tryChangeValue = _useUncontrolledState[1];
|
|
35
|
+
var handleChange = useCallback(function (value) {
|
|
36
|
+
if (disabled) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
tryChangeValue(value);
|
|
40
|
+
}, [disabled, tryChangeValue]);
|
|
41
|
+
var isChecked = useCallback(function (valueArg) {
|
|
42
|
+
return valueArg === value;
|
|
43
|
+
}, [value]);
|
|
44
|
+
var rootProps = Object.assign(Object.assign({}, rest), {
|
|
45
|
+
role: 'radiogroup'
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
rootProps: rootProps,
|
|
49
|
+
value: value,
|
|
50
|
+
onChange: handleChange,
|
|
51
|
+
name: name,
|
|
52
|
+
isChecked: isChecked,
|
|
53
|
+
disabled: disabled
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export { useRadioGroup };
|
|
@@ -0,0 +1,83 @@
|
|
|
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 };
|
|
@@ -9,6 +9,7 @@ export declare const useTableCheck: ({ rowSelection, flattedData, fieldKey, }: {
|
|
|
9
9
|
checkedAll: boolean;
|
|
10
10
|
semiChecked: boolean;
|
|
11
11
|
onCheckedRowKeysChange: (rowItem: Record<string, any>, checked: boolean) => void;
|
|
12
|
+
onRadioCheckedRowKeysChange: (rowItem: Record<string, any>, checked: boolean) => void;
|
|
12
13
|
isCheckedRowKey: (id: React.ReactText) => boolean;
|
|
13
14
|
checkedRowKeys: React.ReactText[];
|
|
14
15
|
trySetCheckedRowKeys: (stateOrFunction: React.SetStateAction<React.ReactText[]>, ...args: any[]) => void;
|
package/lib/types/types.d.ts
CHANGED