@rc-component/select 1.3.5 → 1.4.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/es/BaseSelect/index.js +1 -1
- package/es/SelectInput/Content/SingleContent.js +4 -10
- package/es/hooks/useOpen.d.ts +1 -1
- package/es/hooks/useOpen.js +2 -2
- package/lib/BaseSelect/index.js +1 -1
- package/lib/SelectInput/Content/SingleContent.js +4 -10
- package/lib/hooks/useOpen.d.ts +1 -1
- package/lib/hooks/useOpen.js +2 -2
- package/package.json +1 -1
package/es/BaseSelect/index.js
CHANGED
|
@@ -135,7 +135,7 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
135
135
|
// ============================== Open ==============================
|
|
136
136
|
// Not trigger `open` when `notFoundContent` is empty
|
|
137
137
|
const emptyListContent = !notFoundContent && emptyOptions;
|
|
138
|
-
const [mergedOpen, triggerOpen] = useOpen(open, onPopupVisibleChange, nextOpen => disabled || emptyListContent ? false : nextOpen);
|
|
138
|
+
const [mergedOpen, triggerOpen] = useOpen(defaultOpen || false, open, onPopupVisibleChange, nextOpen => disabled || emptyListContent ? false : nextOpen);
|
|
139
139
|
|
|
140
140
|
// ============================= Search =============================
|
|
141
141
|
const tokenWithEnter = React.useMemo(() => (tokenSeparators || []).some(tokenSeparator => ['\n', '\r\n'].includes(tokenSeparator)), [tokenSeparators]);
|
|
@@ -40,7 +40,7 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
|
|
|
40
40
|
|
|
41
41
|
// Extract option props, excluding label and value, and handle className/style merging
|
|
42
42
|
const optionProps = React.useMemo(() => {
|
|
43
|
-
|
|
43
|
+
const restProps = {
|
|
44
44
|
className: `${prefixCls}-content-value`,
|
|
45
45
|
style: {
|
|
46
46
|
visibility: mergedSearchValue ? 'hidden' : 'visible'
|
|
@@ -50,23 +50,17 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
|
|
|
50
50
|
const option = selectContext.flattenOptions.find(opt => opt.value === displayValue.value);
|
|
51
51
|
if (option?.data) {
|
|
52
52
|
const {
|
|
53
|
-
label,
|
|
54
|
-
value,
|
|
55
53
|
className,
|
|
56
|
-
style
|
|
57
|
-
key,
|
|
58
|
-
...rest
|
|
54
|
+
style
|
|
59
55
|
} = option.data;
|
|
60
|
-
restProps
|
|
61
|
-
...restProps,
|
|
62
|
-
...rest,
|
|
56
|
+
Object.assign(restProps, {
|
|
63
57
|
title: getTitle(option.data),
|
|
64
58
|
className: clsx(restProps.className, className),
|
|
65
59
|
style: {
|
|
66
60
|
...restProps.style,
|
|
67
61
|
...style
|
|
68
62
|
}
|
|
69
|
-
};
|
|
63
|
+
});
|
|
70
64
|
}
|
|
71
65
|
}
|
|
72
66
|
if (displayValue && !restProps.title) {
|
package/es/hooks/useOpen.d.ts
CHANGED
|
@@ -15,4 +15,4 @@ export type TriggerOpenType = (nextOpen?: boolean, config?: {
|
|
|
15
15
|
* SSR handling: During SSR, `open` is always false to avoid Portal issues.
|
|
16
16
|
* On client-side hydration, it syncs with the actual open state.
|
|
17
17
|
*/
|
|
18
|
-
export default function useOpen(propOpen: boolean, onOpen: (nextOpen: boolean) => void, postOpen: (nextOpen: boolean) => boolean): [boolean, TriggerOpenType];
|
|
18
|
+
export default function useOpen(defaultOpen: boolean, propOpen: boolean, onOpen: (nextOpen: boolean) => void, postOpen: (nextOpen: boolean) => boolean): [boolean, TriggerOpenType];
|
package/es/hooks/useOpen.js
CHANGED
|
@@ -29,13 +29,13 @@ export const macroTask = (fn, times = 1) => {
|
|
|
29
29
|
* SSR handling: During SSR, `open` is always false to avoid Portal issues.
|
|
30
30
|
* On client-side hydration, it syncs with the actual open state.
|
|
31
31
|
*/
|
|
32
|
-
export default function useOpen(propOpen, onOpen, postOpen) {
|
|
32
|
+
export default function useOpen(defaultOpen, propOpen, onOpen, postOpen) {
|
|
33
33
|
// SSR not support Portal which means we need delay `open` for the first time render
|
|
34
34
|
const [rendered, setRendered] = useState(false);
|
|
35
35
|
useEffect(() => {
|
|
36
36
|
setRendered(true);
|
|
37
37
|
}, []);
|
|
38
|
-
const [stateOpen, internalSetOpen] = useControlledState(
|
|
38
|
+
const [stateOpen, internalSetOpen] = useControlledState(defaultOpen, propOpen);
|
|
39
39
|
|
|
40
40
|
// During SSR, always return false for open state
|
|
41
41
|
const ssrSafeOpen = rendered ? stateOpen : false;
|
package/lib/BaseSelect/index.js
CHANGED
|
@@ -144,7 +144,7 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
144
144
|
// ============================== Open ==============================
|
|
145
145
|
// Not trigger `open` when `notFoundContent` is empty
|
|
146
146
|
const emptyListContent = !notFoundContent && emptyOptions;
|
|
147
|
-
const [mergedOpen, triggerOpen] = (0, _useOpen.default)(open, onPopupVisibleChange, nextOpen => disabled || emptyListContent ? false : nextOpen);
|
|
147
|
+
const [mergedOpen, triggerOpen] = (0, _useOpen.default)(defaultOpen || false, open, onPopupVisibleChange, nextOpen => disabled || emptyListContent ? false : nextOpen);
|
|
148
148
|
|
|
149
149
|
// ============================= Search =============================
|
|
150
150
|
const tokenWithEnter = React.useMemo(() => (tokenSeparators || []).some(tokenSeparator => ['\n', '\r\n'].includes(tokenSeparator)), [tokenSeparators]);
|
|
@@ -49,7 +49,7 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
|
|
|
49
49
|
|
|
50
50
|
// Extract option props, excluding label and value, and handle className/style merging
|
|
51
51
|
const optionProps = React.useMemo(() => {
|
|
52
|
-
|
|
52
|
+
const restProps = {
|
|
53
53
|
className: `${prefixCls}-content-value`,
|
|
54
54
|
style: {
|
|
55
55
|
visibility: mergedSearchValue ? 'hidden' : 'visible'
|
|
@@ -59,23 +59,17 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
|
|
|
59
59
|
const option = selectContext.flattenOptions.find(opt => opt.value === displayValue.value);
|
|
60
60
|
if (option?.data) {
|
|
61
61
|
const {
|
|
62
|
-
label,
|
|
63
|
-
value,
|
|
64
62
|
className,
|
|
65
|
-
style
|
|
66
|
-
key,
|
|
67
|
-
...rest
|
|
63
|
+
style
|
|
68
64
|
} = option.data;
|
|
69
|
-
restProps
|
|
70
|
-
...restProps,
|
|
71
|
-
...rest,
|
|
65
|
+
Object.assign(restProps, {
|
|
72
66
|
title: (0, _commonUtil.getTitle)(option.data),
|
|
73
67
|
className: (0, _clsx.clsx)(restProps.className, className),
|
|
74
68
|
style: {
|
|
75
69
|
...restProps.style,
|
|
76
70
|
...style
|
|
77
71
|
}
|
|
78
|
-
};
|
|
72
|
+
});
|
|
79
73
|
}
|
|
80
74
|
}
|
|
81
75
|
if (displayValue && !restProps.title) {
|
package/lib/hooks/useOpen.d.ts
CHANGED
|
@@ -15,4 +15,4 @@ export type TriggerOpenType = (nextOpen?: boolean, config?: {
|
|
|
15
15
|
* SSR handling: During SSR, `open` is always false to avoid Portal issues.
|
|
16
16
|
* On client-side hydration, it syncs with the actual open state.
|
|
17
17
|
*/
|
|
18
|
-
export default function useOpen(propOpen: boolean, onOpen: (nextOpen: boolean) => void, postOpen: (nextOpen: boolean) => boolean): [boolean, TriggerOpenType];
|
|
18
|
+
export default function useOpen(defaultOpen: boolean, propOpen: boolean, onOpen: (nextOpen: boolean) => void, postOpen: (nextOpen: boolean) => boolean): [boolean, TriggerOpenType];
|
package/lib/hooks/useOpen.js
CHANGED
|
@@ -36,13 +36,13 @@ exports.macroTask = macroTask;
|
|
|
36
36
|
* SSR handling: During SSR, `open` is always false to avoid Portal issues.
|
|
37
37
|
* On client-side hydration, it syncs with the actual open state.
|
|
38
38
|
*/
|
|
39
|
-
function useOpen(propOpen, onOpen, postOpen) {
|
|
39
|
+
function useOpen(defaultOpen, propOpen, onOpen, postOpen) {
|
|
40
40
|
// SSR not support Portal which means we need delay `open` for the first time render
|
|
41
41
|
const [rendered, setRendered] = (0, _react.useState)(false);
|
|
42
42
|
(0, _react.useEffect)(() => {
|
|
43
43
|
setRendered(true);
|
|
44
44
|
}, []);
|
|
45
|
-
const [stateOpen, internalSetOpen] = (0, _util.useControlledState)(
|
|
45
|
+
const [stateOpen, internalSetOpen] = (0, _util.useControlledState)(defaultOpen, propOpen);
|
|
46
46
|
|
|
47
47
|
// During SSR, always return false for open state
|
|
48
48
|
const ssrSafeOpen = rendered ? stateOpen : false;
|