@rainbow-oh/yee-c 0.14.7 → 0.15.1
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/dist/cjs/Form/index.d.ts +1 -1
- package/dist/cjs/Input/style/index.less +1 -0
- package/dist/cjs/InputNumber/demo/basic.js +1 -1
- package/dist/cjs/InputNumber/input-number.js +17 -4
- package/dist/cjs/InputNumber/interface.d.ts +3 -3
- package/dist/cjs/InputNumber/style/index.less +1 -0
- package/dist/cjs/Select/hooks/useSelectKeyboard.js +5 -2
- package/dist/cjs/Selector/selector.js +6 -3
- package/dist/cjs/TableSelect/hooks/useTableSelectKeyboard.d.ts +27 -0
- package/dist/cjs/TableSelect/hooks/useTableSelectKeyboard.js +128 -0
- package/dist/cjs/TableSelect/interface.d.ts +9 -4
- package/dist/cjs/TableSelect/internal-table.js +27 -14
- package/dist/cjs/TableSelect/style/index.less +3 -11
- package/dist/cjs/TableSelect/table-select.js +40 -3
- package/dist/cjs/style/size.css +1 -1
- package/dist/cjs/style/themes.css +1 -1
- package/dist/cjs/style/variables.css +2 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Form/index.d.ts +1 -1
- package/dist/esm/Input/style/index.less +1 -0
- package/dist/esm/InputNumber/demo/basic.js +1 -1
- package/dist/esm/InputNumber/input-number.js +20 -4
- package/dist/esm/InputNumber/interface.d.ts +3 -3
- package/dist/esm/InputNumber/style/index.less +1 -0
- package/dist/esm/Select/hooks/useSelectKeyboard.js +7 -2
- package/dist/esm/Selector/selector.js +10 -5
- package/dist/esm/TableSelect/hooks/useTableSelectKeyboard.d.ts +27 -0
- package/dist/esm/TableSelect/hooks/useTableSelectKeyboard.js +132 -0
- package/dist/esm/TableSelect/interface.d.ts +9 -4
- package/dist/esm/TableSelect/internal-table.js +6 -2
- package/dist/esm/TableSelect/style/index.less +3 -11
- package/dist/esm/TableSelect/table-select.js +36 -3
- package/dist/esm/style/size.css +1 -1
- package/dist/esm/style/themes.css +1 -1
- package/dist/esm/style/variables.css +2 -2
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/yee-c.min.css +2 -2
- package/dist/umd/yee-c.min.js +1 -1
- package/package.json +1 -1
- package/src/Form/index.ts +4 -0
- package/src/Input/style/index.less +1 -0
- package/src/InputNumber/demo/basic.tsx +1 -1
- package/src/InputNumber/index.en-US.md +2 -2
- package/src/InputNumber/index.zh-CN.md +2 -2
- package/src/InputNumber/input-number.tsx +27 -6
- package/src/InputNumber/interface.ts +3 -3
- package/src/InputNumber/style/index.less +1 -0
- package/src/Select/hooks/useSelectKeyboard.ts +7 -2
- package/src/Selector/selector.tsx +10 -5
- package/src/TableSelect/hooks/useTableSelectKeyboard.ts +141 -0
- package/src/TableSelect/index.en-US.md +47 -44
- package/src/TableSelect/index.zh-CN.md +47 -44
- package/src/TableSelect/interface.ts +9 -4
- package/src/TableSelect/internal-table.tsx +14 -6
- package/src/TableSelect/style/index.less +3 -11
- package/src/TableSelect/table-select.tsx +45 -3
- package/src/style/size.css +1 -1
- package/src/version.ts +1 -1
package/dist/cjs/Form/index.d.ts
CHANGED
|
@@ -16,5 +16,5 @@ type FormInterface = typeof InternalForm & {
|
|
|
16
16
|
List: typeof List;
|
|
17
17
|
};
|
|
18
18
|
declare const Form: FormInterface;
|
|
19
|
-
export type { FieldGroupProps, FieldStatus, FieldStatusData, FormInstance, FormListProps, FormProps, Rule as FormRule, ValidateMessage, } from './interface';
|
|
19
|
+
export type { FieldGroupProps, FieldProps, FieldStatus, FieldStatusData, FieldTooltip, FormInstance, FormListField, FormListOperation, FormListProps, FormProps, Rule as FormRule, ValidateMessage, } from './interface';
|
|
20
20
|
export default Form;
|
|
@@ -133,8 +133,14 @@ var InputNumber = (0, import_react.forwardRef)(
|
|
|
133
133
|
});
|
|
134
134
|
const [focused, setFocused] = (0, import_react.useState)(false);
|
|
135
135
|
const inputRef = (0, import_react.useRef)(null);
|
|
136
|
+
function toNumber(val) {
|
|
137
|
+
if (val === null || val === void 0 || val === "")
|
|
138
|
+
return null;
|
|
139
|
+
const n = Number(val);
|
|
140
|
+
return Number.isNaN(n) ? null : n;
|
|
141
|
+
}
|
|
136
142
|
function formatValue(val) {
|
|
137
|
-
if (val === null || val === void 0 || isNaN(val))
|
|
143
|
+
if (val === null || val === void 0 || val === "" || isNaN(val))
|
|
138
144
|
return "";
|
|
139
145
|
let formattedVal = precision !== void 0 ? Number(val).toFixed(precision) : val;
|
|
140
146
|
if (formatter) {
|
|
@@ -199,10 +205,11 @@ var InputNumber = (0, import_react.forwardRef)(
|
|
|
199
205
|
onFocus == null ? void 0 : onFocus(event);
|
|
200
206
|
};
|
|
201
207
|
const handleStep = (type) => {
|
|
208
|
+
var _a2;
|
|
202
209
|
if (disabled || readOnly)
|
|
203
210
|
return;
|
|
204
211
|
const offset = type === "up" ? step : -step;
|
|
205
|
-
const currentValue = mergedValue != null ?
|
|
212
|
+
const currentValue = (_a2 = toNumber(mergedValue)) != null ? _a2 : 0;
|
|
206
213
|
const newValue = currentValue + offset;
|
|
207
214
|
updateValue(newValue);
|
|
208
215
|
onStep == null ? void 0 : onStep(newValue, { offset, type });
|
|
@@ -303,7 +310,10 @@ var InputNumber = (0, import_react.forwardRef)(
|
|
|
303
310
|
`${prefixCls}-handler`,
|
|
304
311
|
`${prefixCls}-handler-up`,
|
|
305
312
|
{
|
|
306
|
-
[`${prefixCls}-handler-disabled`]: disabled ||
|
|
313
|
+
[`${prefixCls}-handler-disabled`]: disabled || (() => {
|
|
314
|
+
const n = toNumber(mergedValue);
|
|
315
|
+
return n !== null && n >= max;
|
|
316
|
+
})()
|
|
307
317
|
}
|
|
308
318
|
),
|
|
309
319
|
onClick: () => handleStep("up")
|
|
@@ -317,7 +327,10 @@ var InputNumber = (0, import_react.forwardRef)(
|
|
|
317
327
|
`${prefixCls}-handler`,
|
|
318
328
|
`${prefixCls}-handler-down`,
|
|
319
329
|
{
|
|
320
|
-
[`${prefixCls}-handler-disabled`]: disabled ||
|
|
330
|
+
[`${prefixCls}-handler-disabled`]: disabled || (() => {
|
|
331
|
+
const n = toNumber(mergedValue);
|
|
332
|
+
return n !== null && n <= min;
|
|
333
|
+
})()
|
|
321
334
|
}
|
|
322
335
|
),
|
|
323
336
|
onClick: () => handleStep("down")
|
|
@@ -26,13 +26,13 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
26
26
|
*/
|
|
27
27
|
size?: 'small' | 'default' | 'large';
|
|
28
28
|
/**
|
|
29
|
-
* Controlled value
|
|
29
|
+
* Controlled value('' 视为空值,配合 formatter 不会渲染成 0)
|
|
30
30
|
*/
|
|
31
|
-
value?: number | null;
|
|
31
|
+
value?: number | string | null;
|
|
32
32
|
/**
|
|
33
33
|
* Default value
|
|
34
34
|
*/
|
|
35
|
-
defaultValue?: number | null;
|
|
35
|
+
defaultValue?: number | string | null;
|
|
36
36
|
/**
|
|
37
37
|
* Minimum value
|
|
38
38
|
*/
|
|
@@ -218,8 +218,11 @@ function useSelectKeyboard({
|
|
|
218
218
|
handleEnter();
|
|
219
219
|
break;
|
|
220
220
|
case "Escape":
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
if (open) {
|
|
222
|
+
event.preventDefault();
|
|
223
|
+
event.stopPropagation();
|
|
224
|
+
handleEscape();
|
|
225
|
+
}
|
|
223
226
|
break;
|
|
224
227
|
default:
|
|
225
228
|
}
|
|
@@ -313,10 +313,13 @@ var Selector = import_react.default.forwardRef(
|
|
|
313
313
|
onKeyDown: (event) => {
|
|
314
314
|
if (disabled)
|
|
315
315
|
return;
|
|
316
|
-
if (
|
|
317
|
-
|
|
316
|
+
if (event.key === "Enter" && !open && onOpenChange) {
|
|
317
|
+
event.preventDefault();
|
|
318
|
+
onOpenChange(true);
|
|
319
|
+
}
|
|
320
|
+
if (event.target !== inputRef.current) {
|
|
321
|
+
externalOnKeyDown == null ? void 0 : externalOnKeyDown(event);
|
|
318
322
|
}
|
|
319
|
-
externalOnKeyDown == null ? void 0 : externalOnKeyDown(event);
|
|
320
323
|
},
|
|
321
324
|
ref
|
|
322
325
|
}),
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { TableSelectDataType } from '../interface';
|
|
3
|
+
type KeyType = string | number;
|
|
4
|
+
interface UseTableSelectKeyboardParams {
|
|
5
|
+
open: boolean;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
dataSource: Array<TableSelectDataType>;
|
|
8
|
+
rowKey: string | ((record: any) => string);
|
|
9
|
+
selectionType: 'radio' | 'checkbox';
|
|
10
|
+
selectedRowKeys: Array<KeyType>;
|
|
11
|
+
searchValue: string;
|
|
12
|
+
onSelect: (keys: Array<KeyType>, rows: Array<TableSelectDataType>) => void;
|
|
13
|
+
onClose: () => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Keyboard navigation for the popup table. The highlight is positional (like a
|
|
17
|
+
* hover cursor): `activeRow` is a rendered row index, and Space selects the
|
|
18
|
+
* record displayed there. The rendered order is the filter→sort→paginate
|
|
19
|
+
* result inside Table and is not derivable from `dataSource`, so the row count
|
|
20
|
+
* and the highlighted row's key are both read from the popup DOM.
|
|
21
|
+
*/
|
|
22
|
+
export default function useTableSelectKeyboard({ open, disabled, dataSource, rowKey, selectionType, selectedRowKeys, searchValue, onSelect, onClose, }: UseTableSelectKeyboardParams): {
|
|
23
|
+
popupRef: import("react").RefObject<HTMLDivElement | null>;
|
|
24
|
+
activeRow: number;
|
|
25
|
+
handleKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/TableSelect/hooks/useTableSelectKeyboard.ts
|
|
20
|
+
var useTableSelectKeyboard_exports = {};
|
|
21
|
+
__export(useTableSelectKeyboard_exports, {
|
|
22
|
+
default: () => useTableSelectKeyboard
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useTableSelectKeyboard_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
function useTableSelectKeyboard({
|
|
27
|
+
open,
|
|
28
|
+
disabled,
|
|
29
|
+
dataSource,
|
|
30
|
+
rowKey,
|
|
31
|
+
selectionType,
|
|
32
|
+
selectedRowKeys,
|
|
33
|
+
searchValue,
|
|
34
|
+
onSelect,
|
|
35
|
+
onClose
|
|
36
|
+
}) {
|
|
37
|
+
const popupRef = (0, import_react.useRef)(null);
|
|
38
|
+
const [activeRow, setActiveRow] = (0, import_react.useState)(0);
|
|
39
|
+
(0, import_react.useEffect)(() => {
|
|
40
|
+
setActiveRow(0);
|
|
41
|
+
}, [open, searchValue]);
|
|
42
|
+
const getRecordKey = (item) => typeof rowKey === "function" ? rowKey(item) : item[rowKey];
|
|
43
|
+
const getRowCount = () => {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
return (_b = (_a = popupRef.current) == null ? void 0 : _a.querySelectorAll("tr[data-row-index]").length) != null ? _b : 0;
|
|
46
|
+
};
|
|
47
|
+
(0, import_react.useEffect)(() => {
|
|
48
|
+
var _a;
|
|
49
|
+
if (!open || activeRow < 1)
|
|
50
|
+
return;
|
|
51
|
+
const rowEl = (_a = popupRef.current) == null ? void 0 : _a.querySelector(
|
|
52
|
+
`tr[data-row-index="${activeRow}"]`
|
|
53
|
+
);
|
|
54
|
+
if (!rowEl)
|
|
55
|
+
return;
|
|
56
|
+
let parent = rowEl.parentElement;
|
|
57
|
+
while (parent && parent !== popupRef.current) {
|
|
58
|
+
const { overflowY } = window.getComputedStyle(parent);
|
|
59
|
+
if (/(auto|scroll)/.test(overflowY) && parent.scrollHeight > parent.clientHeight) {
|
|
60
|
+
const parentRect = parent.getBoundingClientRect();
|
|
61
|
+
const rowRect = rowEl.getBoundingClientRect();
|
|
62
|
+
if (rowRect.bottom > parentRect.bottom) {
|
|
63
|
+
parent.scrollTop += rowRect.bottom - parentRect.bottom;
|
|
64
|
+
} else if (rowRect.top < parentRect.top) {
|
|
65
|
+
parent.scrollTop -= parentRect.top - rowRect.top;
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
parent = parent.parentElement;
|
|
70
|
+
}
|
|
71
|
+
}, [activeRow, open]);
|
|
72
|
+
const selectActiveRow = () => {
|
|
73
|
+
var _a;
|
|
74
|
+
const rowEl = (_a = popupRef.current) == null ? void 0 : _a.querySelector(
|
|
75
|
+
`tr[data-row-index="${activeRow}"]`
|
|
76
|
+
);
|
|
77
|
+
const inputEl = rowEl == null ? void 0 : rowEl.querySelector(
|
|
78
|
+
'input[type="radio"],input[type="checkbox"]'
|
|
79
|
+
);
|
|
80
|
+
if (!inputEl || inputEl.disabled)
|
|
81
|
+
return;
|
|
82
|
+
const record = dataSource.find(
|
|
83
|
+
(item) => String(getRecordKey(item)) === inputEl.value
|
|
84
|
+
);
|
|
85
|
+
if (!record)
|
|
86
|
+
return;
|
|
87
|
+
const key = getRecordKey(record);
|
|
88
|
+
if (selectionType === "radio") {
|
|
89
|
+
onSelect([key], [record]);
|
|
90
|
+
onClose();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const checked = selectedRowKeys.some((k) => String(k) === String(key));
|
|
94
|
+
const nextKeys = checked ? selectedRowKeys.filter((k) => String(k) !== String(key)) : [...selectedRowKeys, key];
|
|
95
|
+
const rows = dataSource.filter(
|
|
96
|
+
(item) => nextKeys.some((k) => String(getRecordKey(item)) === String(k))
|
|
97
|
+
);
|
|
98
|
+
onSelect(nextKeys, rows);
|
|
99
|
+
};
|
|
100
|
+
const handleKeyDown = (event) => {
|
|
101
|
+
if (!open || disabled)
|
|
102
|
+
return;
|
|
103
|
+
switch (event.key) {
|
|
104
|
+
case "ArrowDown":
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
setActiveRow(Math.min(activeRow + 1, getRowCount()));
|
|
107
|
+
break;
|
|
108
|
+
case "ArrowUp":
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
setActiveRow(activeRow <= 1 ? getRowCount() : activeRow - 1);
|
|
111
|
+
break;
|
|
112
|
+
case " ":
|
|
113
|
+
if (activeRow > 0) {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
selectActiveRow();
|
|
116
|
+
}
|
|
117
|
+
break;
|
|
118
|
+
case "Escape":
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
event.stopPropagation();
|
|
121
|
+
onClose();
|
|
122
|
+
break;
|
|
123
|
+
default:
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
return { popupRef, activeRow, handleKeyDown };
|
|
128
|
+
}
|
|
@@ -9,7 +9,7 @@ type SelectedKeyType = string | number;
|
|
|
9
9
|
/**
|
|
10
10
|
* Data item type
|
|
11
11
|
*/
|
|
12
|
-
type
|
|
12
|
+
export type TableSelectDataType = {
|
|
13
13
|
[propName: string]: any;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
@@ -40,7 +40,7 @@ export interface InternalTableProps {
|
|
|
40
40
|
/**
|
|
41
41
|
* Data source
|
|
42
42
|
*/
|
|
43
|
-
dataSource: Array<
|
|
43
|
+
dataSource: Array<TableSelectDataType>;
|
|
44
44
|
/**
|
|
45
45
|
* Custom class name
|
|
46
46
|
*/
|
|
@@ -65,6 +65,11 @@ export interface InternalTableProps {
|
|
|
65
65
|
* Whether popup is visible (for focus trap)
|
|
66
66
|
*/
|
|
67
67
|
visible?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Ref to the popup root element, used by TableSelect for keyboard navigation
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
popupRef?: React.RefObject<HTMLDivElement | null>;
|
|
68
73
|
}
|
|
69
74
|
/**
|
|
70
75
|
* TableSelect component Props interface
|
|
@@ -77,7 +82,7 @@ export interface TableSelectProps extends Omit<InternalTableProps, 'value' | 'on
|
|
|
77
82
|
/**
|
|
78
83
|
* Data source
|
|
79
84
|
*/
|
|
80
|
-
dataSource: Array<
|
|
85
|
+
dataSource: Array<TableSelectDataType>;
|
|
81
86
|
/**
|
|
82
87
|
* Single or multiple selection
|
|
83
88
|
* @default: 'radio'
|
|
@@ -161,7 +166,7 @@ export interface TableSelectProps extends Omit<InternalTableProps, 'value' | 'on
|
|
|
161
166
|
* Option label property (text field for displaying labels)
|
|
162
167
|
* @default 'name'
|
|
163
168
|
*/
|
|
164
|
-
optionLabelProp?: string | ((option:
|
|
169
|
+
optionLabelProp?: string | ((option: TableSelectDataType) => string);
|
|
165
170
|
/**
|
|
166
171
|
* Selection change callback
|
|
167
172
|
* @param keys Selected keys
|
|
@@ -75,7 +75,8 @@ var InternalTable = (props) => {
|
|
|
75
75
|
rowKey = "key",
|
|
76
76
|
isShowFilter = true,
|
|
77
77
|
rowSelection = {},
|
|
78
|
-
visible
|
|
78
|
+
visible,
|
|
79
|
+
popupRef: externalPopupRef
|
|
79
80
|
} = _a, rest = __objRest(_a, [
|
|
80
81
|
"prefixCls",
|
|
81
82
|
"type",
|
|
@@ -85,11 +86,10 @@ var InternalTable = (props) => {
|
|
|
85
86
|
"rowKey",
|
|
86
87
|
"isShowFilter",
|
|
87
88
|
"rowSelection",
|
|
88
|
-
"visible"
|
|
89
|
+
"visible",
|
|
90
|
+
"popupRef"
|
|
89
91
|
]);
|
|
90
|
-
const [internalDataSource, setInternalDataSource] = (0, import_react.useState)(
|
|
91
|
-
[]
|
|
92
|
-
);
|
|
92
|
+
const [internalDataSource, setInternalDataSource] = (0, import_react.useState)([]);
|
|
93
93
|
const renderRowSelection = __spreadValues({ type, selectedRowKeys: value }, rowSelection);
|
|
94
94
|
(0, import_react.useEffect)(() => {
|
|
95
95
|
setInternalDataSource(dataSource || []);
|
|
@@ -134,14 +134,27 @@ var InternalTable = (props) => {
|
|
|
134
134
|
}
|
|
135
135
|
return null;
|
|
136
136
|
};
|
|
137
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
137
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
138
|
+
"div",
|
|
139
|
+
{
|
|
140
|
+
className: `${prefixCls}-popup`,
|
|
141
|
+
tabIndex: 0,
|
|
142
|
+
ref: (node) => {
|
|
143
|
+
popupRef.current = node;
|
|
144
|
+
if (externalPopupRef)
|
|
145
|
+
externalPopupRef.current = node;
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
renderRadio(),
|
|
149
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
150
|
+
import_Table.default,
|
|
151
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
152
|
+
rowKey,
|
|
153
|
+
dataSource: internalDataSource,
|
|
154
|
+
columns,
|
|
155
|
+
rowSelection: renderRowSelection
|
|
156
|
+
})
|
|
157
|
+
)
|
|
158
|
+
);
|
|
146
159
|
};
|
|
147
160
|
var internal_table_default = InternalTable;
|
|
@@ -6,16 +6,8 @@
|
|
|
6
6
|
margin: 0;
|
|
7
7
|
padding: 12px 0;
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.rb-table-select {
|
|
16
|
-
margin-bottom: 0;
|
|
17
|
-
|
|
18
|
-
.rb-table-footer-operate {
|
|
19
|
-
padding: 0 12px;
|
|
9
|
+
// Keyboard-navigated row (TableSelect arrow keys)
|
|
10
|
+
.yee-table-highlight-row {
|
|
11
|
+
background-color: var(--yee-table-tbody-tr-hover-bg-color);
|
|
20
12
|
}
|
|
21
13
|
}
|
|
@@ -70,10 +70,13 @@ var import_Trigger = __toESM(require("../Trigger"));
|
|
|
70
70
|
var import_mergeContextToProps = __toESM(require("../utils/mergeContextToProps"));
|
|
71
71
|
var import_omit = __toESM(require("../utils/omit"));
|
|
72
72
|
var import_pick = __toESM(require("../utils/pick"));
|
|
73
|
+
var import_useTableSelectKeyboard = __toESM(require("./hooks/useTableSelectKeyboard"));
|
|
73
74
|
var import_internal_table = __toESM(require("./internal-table"));
|
|
74
75
|
var import_style = require("./style/index.less");
|
|
75
76
|
var handleState = (value) => {
|
|
76
|
-
if (
|
|
77
|
+
if (value === "") {
|
|
78
|
+
return [];
|
|
79
|
+
} else if (typeof value === "string" || typeof value === "number") {
|
|
77
80
|
return [value];
|
|
78
81
|
} else if (Array.isArray(value)) {
|
|
79
82
|
return value;
|
|
@@ -182,9 +185,28 @@ var TableSelect = (baseprops) => {
|
|
|
182
185
|
const renderKeys = keys.length === 0 ? selectionType === "checkbox" ? [] : "" : keys;
|
|
183
186
|
onChange == null ? void 0 : onChange(renderKeys, void 0);
|
|
184
187
|
};
|
|
188
|
+
const {
|
|
189
|
+
popupRef,
|
|
190
|
+
activeRow,
|
|
191
|
+
handleKeyDown: handleSelectorKeyDown
|
|
192
|
+
} = (0, import_useTableSelectKeyboard.default)({
|
|
193
|
+
open,
|
|
194
|
+
disabled,
|
|
195
|
+
dataSource,
|
|
196
|
+
rowKey,
|
|
197
|
+
selectionType,
|
|
198
|
+
selectedRowKeys: mergedValue,
|
|
199
|
+
searchValue,
|
|
200
|
+
onSelect: onSelectChange,
|
|
201
|
+
onClose: () => onVisibleChange(false)
|
|
202
|
+
});
|
|
203
|
+
const userHighlight = rest.highlight;
|
|
185
204
|
const tableProps = (0, import_omit.default)(
|
|
186
205
|
__spreadProps(__spreadValues({}, rest), {
|
|
187
206
|
prefixCls,
|
|
207
|
+
// Keyboard navigation reuses the row highlight; it takes precedence over
|
|
208
|
+
// a user-supplied index list while active.
|
|
209
|
+
highlight: activeRow > 0 ? [activeRow, ...Array.isArray(userHighlight) ? userHighlight : []] : userHighlight,
|
|
188
210
|
rowSelection: __spreadProps(__spreadValues({}, props.rowSelection), {
|
|
189
211
|
onChange: onSelectChange,
|
|
190
212
|
selectedRowKeys: mergedValue
|
|
@@ -212,8 +234,15 @@ var TableSelect = (baseprops) => {
|
|
|
212
234
|
selectedKeys: mergedValue,
|
|
213
235
|
onSearch: handleSearch,
|
|
214
236
|
onRemove: onTagRemove,
|
|
237
|
+
onClear: () => {
|
|
238
|
+
setMergedValue([]);
|
|
239
|
+
onChange == null ? void 0 : onChange(selectionType === "radio" ? "" : [], void 0);
|
|
240
|
+
},
|
|
241
|
+
onKeyDown: handleSelectorKeyDown,
|
|
215
242
|
onOpenChange: (open2) => {
|
|
216
|
-
if (
|
|
243
|
+
if (open2) {
|
|
244
|
+
onVisibleChange(true);
|
|
245
|
+
} else {
|
|
217
246
|
clearSearchValue();
|
|
218
247
|
}
|
|
219
248
|
},
|
|
@@ -222,11 +251,19 @@ var TableSelect = (baseprops) => {
|
|
|
222
251
|
closable,
|
|
223
252
|
placeholder
|
|
224
253
|
});
|
|
225
|
-
const renderPopup = () => /* @__PURE__ */ import_react.default.createElement(
|
|
254
|
+
const renderPopup = () => /* @__PURE__ */ import_react.default.createElement(
|
|
255
|
+
import_internal_table.default,
|
|
256
|
+
__spreadProps(__spreadValues({}, tableProps), {
|
|
257
|
+
value,
|
|
258
|
+
rowKey,
|
|
259
|
+
popupRef
|
|
260
|
+
})
|
|
261
|
+
);
|
|
226
262
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
227
263
|
import_Trigger.default,
|
|
228
264
|
__spreadProps(__spreadValues({}, rest), {
|
|
229
265
|
trigger: "click",
|
|
266
|
+
open,
|
|
230
267
|
popupClassName: `${prefixCls}-popup`,
|
|
231
268
|
popup: renderPopup(),
|
|
232
269
|
placement,
|
package/dist/cjs/style/size.css
CHANGED
|
@@ -587,7 +587,7 @@
|
|
|
587
587
|
--yee-select-popup-max-height: 200px;
|
|
588
588
|
|
|
589
589
|
/* --Selector-- */
|
|
590
|
-
--yee-selector-padding:
|
|
590
|
+
--yee-selector-padding: 3px 6px;
|
|
591
591
|
--yee-selector-border-width: 1px;
|
|
592
592
|
--yee-selector-border-radius: 4px;
|
|
593
593
|
--yee-selector-height: var(--yee-input-height);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @rainbow-oh/yee-c CSS Variables
|
|
3
3
|
* Auto-generated, do not edit manually
|
|
4
|
-
* Generated on 2026-10-
|
|
4
|
+
* Generated on 2026-10-16T07:04:02.333Z
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/* ========== color.css ========== */
|
|
@@ -1940,7 +1940,7 @@
|
|
|
1940
1940
|
--yee-select-popup-max-height: 200px;
|
|
1941
1941
|
|
|
1942
1942
|
/* --Selector-- */
|
|
1943
|
-
--yee-selector-padding:
|
|
1943
|
+
--yee-selector-padding: 3px 6px;
|
|
1944
1944
|
--yee-selector-border-width: 1px;
|
|
1945
1945
|
--yee-selector-border-radius: 4px;
|
|
1946
1946
|
--yee-selector-height: var(--yee-input-height);
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
package/dist/esm/Form/index.d.ts
CHANGED
|
@@ -16,5 +16,5 @@ type FormInterface = typeof InternalForm & {
|
|
|
16
16
|
List: typeof List;
|
|
17
17
|
};
|
|
18
18
|
declare const Form: FormInterface;
|
|
19
|
-
export type { FieldGroupProps, FieldStatus, FieldStatusData, FormInstance, FormListProps, FormProps, Rule as FormRule, ValidateMessage, } from './interface';
|
|
19
|
+
export type { FieldGroupProps, FieldProps, FieldStatus, FieldStatusData, FieldTooltip, FormInstance, FormListField, FormListOperation, FormListProps, FormProps, Rule as FormRule, ValidateMessage, } from './interface';
|
|
20
20
|
export default Form;
|
|
@@ -6,7 +6,7 @@ import { InputNumber } from "../..";
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
export default (function () {
|
|
8
8
|
return /*#__PURE__*/React.createElement(InputNumber, {
|
|
9
|
-
defaultValue:
|
|
9
|
+
defaultValue: 123,
|
|
10
10
|
placeholder: "Enter a number",
|
|
11
11
|
onChange: function onChange(value) {
|
|
12
12
|
return console.log('value:', value);
|
|
@@ -71,9 +71,18 @@ var InputNumber = /*#__PURE__*/forwardRef(function (baseprops, _ref) {
|
|
|
71
71
|
setFocused = _useState2[1];
|
|
72
72
|
var inputRef = useRef(null);
|
|
73
73
|
|
|
74
|
+
/** 字符串值(表单 store 常见)参与算术/比较前转数字;不可解析返回 null */
|
|
75
|
+
function toNumber(val) {
|
|
76
|
+
if (val === null || val === undefined || val === '') return null;
|
|
77
|
+
var n = Number(val);
|
|
78
|
+
return Number.isNaN(n) ? null : n;
|
|
79
|
+
}
|
|
80
|
+
|
|
74
81
|
// Format value
|
|
75
82
|
function formatValue(val) {
|
|
76
|
-
|
|
83
|
+
// '' 与 null/undefined 同为空值:Number('') === 0,若不拦截会被
|
|
84
|
+
// formatter/precision 格式化成 '0'(如全局千分位 formatter 场景)
|
|
85
|
+
if (val === null || val === undefined || val === '' || isNaN(val)) return '';
|
|
77
86
|
var formattedVal = precision !== undefined ? Number(val).toFixed(precision) : val;
|
|
78
87
|
if (formatter) {
|
|
79
88
|
return formatter(Number(formattedVal));
|
|
@@ -148,9 +157,10 @@ var InputNumber = /*#__PURE__*/forwardRef(function (baseprops, _ref) {
|
|
|
148
157
|
onFocus === null || onFocus === void 0 || onFocus(event);
|
|
149
158
|
};
|
|
150
159
|
var handleStep = function handleStep(type) {
|
|
160
|
+
var _toNumber;
|
|
151
161
|
if (disabled || readOnly) return;
|
|
152
162
|
var offset = type === 'up' ? step : -step;
|
|
153
|
-
var currentValue = mergedValue !== null &&
|
|
163
|
+
var currentValue = (_toNumber = toNumber(mergedValue)) !== null && _toNumber !== void 0 ? _toNumber : 0;
|
|
154
164
|
var newValue = currentValue + offset;
|
|
155
165
|
updateValue(newValue);
|
|
156
166
|
onStep === null || onStep === void 0 || onStep(newValue, {
|
|
@@ -221,7 +231,10 @@ var InputNumber = /*#__PURE__*/forwardRef(function (baseprops, _ref) {
|
|
|
221
231
|
className: clsx("".concat(prefixCls, "-handler-wrap"), classNames === null || classNames === void 0 ? void 0 : classNames.handler),
|
|
222
232
|
style: styles === null || styles === void 0 ? void 0 : styles.handler
|
|
223
233
|
}, /*#__PURE__*/React.createElement("span", {
|
|
224
|
-
className: clsx("".concat(prefixCls, "-handler"), "".concat(prefixCls, "-handler-up"), _defineProperty({}, "".concat(prefixCls, "-handler-disabled"), disabled ||
|
|
234
|
+
className: clsx("".concat(prefixCls, "-handler"), "".concat(prefixCls, "-handler-up"), _defineProperty({}, "".concat(prefixCls, "-handler-disabled"), disabled || function () {
|
|
235
|
+
var n = toNumber(mergedValue);
|
|
236
|
+
return n !== null && n >= max;
|
|
237
|
+
}())),
|
|
225
238
|
onClick: function onClick() {
|
|
226
239
|
return handleStep('up');
|
|
227
240
|
}
|
|
@@ -229,7 +242,10 @@ var InputNumber = /*#__PURE__*/forwardRef(function (baseprops, _ref) {
|
|
|
229
242
|
size: 12,
|
|
230
243
|
strokeWidth: 2
|
|
231
244
|
})), /*#__PURE__*/React.createElement("span", {
|
|
232
|
-
className: clsx("".concat(prefixCls, "-handler"), "".concat(prefixCls, "-handler-down"), _defineProperty({}, "".concat(prefixCls, "-handler-disabled"), disabled ||
|
|
245
|
+
className: clsx("".concat(prefixCls, "-handler"), "".concat(prefixCls, "-handler-down"), _defineProperty({}, "".concat(prefixCls, "-handler-disabled"), disabled || function () {
|
|
246
|
+
var n = toNumber(mergedValue);
|
|
247
|
+
return n !== null && n <= min;
|
|
248
|
+
}())),
|
|
233
249
|
onClick: function onClick() {
|
|
234
250
|
return handleStep('down');
|
|
235
251
|
}
|
|
@@ -26,13 +26,13 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
26
26
|
*/
|
|
27
27
|
size?: 'small' | 'default' | 'large';
|
|
28
28
|
/**
|
|
29
|
-
* Controlled value
|
|
29
|
+
* Controlled value('' 视为空值,配合 formatter 不会渲染成 0)
|
|
30
30
|
*/
|
|
31
|
-
value?: number | null;
|
|
31
|
+
value?: number | string | null;
|
|
32
32
|
/**
|
|
33
33
|
* Default value
|
|
34
34
|
*/
|
|
35
|
-
defaultValue?: number | null;
|
|
35
|
+
defaultValue?: number | string | null;
|
|
36
36
|
/**
|
|
37
37
|
* Minimum value
|
|
38
38
|
*/
|