@rc-component/select 1.3.4 → 1.3.6

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.
@@ -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]);
package/es/Select.d.ts CHANGED
@@ -125,7 +125,7 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
125
125
  classNames?: Partial<Record<SemanticName, string>>;
126
126
  styles?: Partial<Record<SemanticName, React.CSSProperties>>;
127
127
  }
128
- declare const TypedSelect: (<ValueType = any, OptionType extends DefaultOptionType | BaseOptionType = DefaultOptionType>(props: React.PropsWithChildren<SelectProps<ValueType, OptionType>> & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
128
+ declare const TypedSelect: (<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props: React.PropsWithChildren<SelectProps<ValueType, OptionType>> & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
129
129
  Option: typeof Option;
130
130
  OptGroup: typeof OptGroup;
131
131
  };
@@ -174,9 +174,9 @@ const Input = /*#__PURE__*/React.forwardRef((props, ref) => {
174
174
  role: role || 'combobox',
175
175
  'aria-expanded': open || false,
176
176
  'aria-haspopup': 'listbox',
177
- 'aria-owns': `${id}_list`,
177
+ 'aria-owns': open ? `${id}_list` : undefined,
178
178
  'aria-autocomplete': 'list',
179
- 'aria-controls': `${id}_list`,
179
+ 'aria-controls': open ? `${id}_list` : undefined,
180
180
  'aria-activedescendant': open ? activeDescendantId : undefined
181
181
  };
182
182
 
@@ -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];
@@ -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(false, propOpen);
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;
@@ -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]);
package/lib/Select.d.ts CHANGED
@@ -125,7 +125,7 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
125
125
  classNames?: Partial<Record<SemanticName, string>>;
126
126
  styles?: Partial<Record<SemanticName, React.CSSProperties>>;
127
127
  }
128
- declare const TypedSelect: (<ValueType = any, OptionType extends DefaultOptionType | BaseOptionType = DefaultOptionType>(props: React.PropsWithChildren<SelectProps<ValueType, OptionType>> & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
128
+ declare const TypedSelect: (<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props: React.PropsWithChildren<SelectProps<ValueType, OptionType>> & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
129
129
  Option: typeof Option;
130
130
  OptGroup: typeof OptGroup;
131
131
  };
@@ -183,9 +183,9 @@ const Input = /*#__PURE__*/React.forwardRef((props, ref) => {
183
183
  role: role || 'combobox',
184
184
  'aria-expanded': open || false,
185
185
  'aria-haspopup': 'listbox',
186
- 'aria-owns': `${id}_list`,
186
+ 'aria-owns': open ? `${id}_list` : undefined,
187
187
  'aria-autocomplete': 'list',
188
- 'aria-controls': `${id}_list`,
188
+ 'aria-controls': open ? `${id}_list` : undefined,
189
189
  'aria-activedescendant': open ? activeDescendantId : undefined
190
190
  };
191
191
 
@@ -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];
@@ -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)(false, propOpen);
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/select",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "description": "React Select",
5
5
  "engines": {
6
6
  "node": ">=8.x"