@rescui/select 0.18.1-RUI-297-Add-react-compiler-to-the-packages-build-f15074a13.11 → 0.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,15 @@
1
1
  var styles = {
2
- "icon": "_icon_ydxoyp_4",
3
- "sizeXS": "_sizeXS_ydxoyp_14",
4
- "sizeS": "_sizeS_ydxoyp_18",
5
- "sizeM": "_sizeM_ydxoyp_22",
6
- "sizeL": "_sizeL_ydxoyp_26",
7
- "light": "_light_ydxoyp_30",
8
- "dark": "_dark_ydxoyp_34",
9
- "allVariants": "_allVariants_ydxoyp_48",
10
- "variant16": "_variant16_ydxoyp_53",
11
- "variant20": "_variant20_ydxoyp_54",
12
- "variant24": "_variant24_ydxoyp_55",
13
- "variant28": "_variant28_ydxoyp_58"
2
+ "icon": "_icon_1npbgia_4",
3
+ "sizeXS": "_sizeXS_1npbgia_14",
4
+ "sizeS": "_sizeS_1npbgia_18",
5
+ "sizeM": "_sizeM_1npbgia_22",
6
+ "sizeL": "_sizeL_1npbgia_26",
7
+ "light": "_light_1npbgia_30",
8
+ "dark": "_dark_1npbgia_34",
9
+ "allVariants": "_allVariants_1npbgia_48",
10
+ "variant16": "_variant16_1npbgia_53",
11
+ "variant20": "_variant20_1npbgia_54",
12
+ "variant24": "_variant24_1npbgia_55",
13
+ "variant28": "_variant28_1npbgia_58"
14
14
  };
15
15
  export { styles as default };
@@ -1,5 +1,6 @@
1
- import { useRef, useMemo, useCallback } from 'react';
1
+ import { useRef, useMemo, useCallback, useEffect, useLayoutEffect } from 'react';
2
2
  import { getOptionValue } from '../utils/get-option-value.js';
3
+ const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
3
4
 
4
5
  const useMultiHandlers = _ref => {
5
6
  let {
@@ -7,7 +8,9 @@ const useMultiHandlers = _ref => {
7
8
  onChange
8
9
  } = _ref;
9
10
  const onChangeRef = useRef(null);
10
- onChangeRef.current = onChange;
11
+ useIsomorphicLayoutEffect(() => {
12
+ onChangeRef.current = onChange;
13
+ }, [onChange]);
11
14
  const selectedMap = useMemo(() => new Map(selectedItems.map(item => [getOptionValue(item), item])), [selectedItems]);
12
15
  const addItem = useCallback(item => {
13
16
  if (selectedMap.has(getOptionValue(item))) {
@@ -1,4 +1,5 @@
1
- import { useRef } from 'react';
1
+ import { useState, useEffect, useLayoutEffect } from 'react';
2
+ const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
2
3
  /**
3
4
  * Transfer primary contrast css var to the dropdown, but only when the dropdown opens
4
5
  */
@@ -8,21 +9,17 @@ const usePrimaryContrastCssVarTransfer = _ref => {
8
9
  triggerRef,
9
10
  isOpen
10
11
  } = _ref;
11
- const prevIsOpenRef = useRef(false);
12
- const isPrimaryContrastRef = useRef(false);
12
+ const [isPrimaryContrast, setIsPrimaryContrast] = useState(false);
13
+ useIsomorphicLayoutEffect(() => {
14
+ if (!isOpen || !triggerRef.current) {
15
+ return;
16
+ }
13
17
 
14
- if (prevIsOpenRef.current !== isOpen && isOpen && triggerRef.current && typeof window !== 'undefined') {
15
18
  const isPrimaryContrastFromCss = getComputedStyle(triggerRef.current)?.getPropertyValue('--rs-select-contrast-primary');
16
- isPrimaryContrastRef.current = isPrimaryContrastFromCss.toString() === '1';
17
- prevIsOpenRef.current = true;
18
- }
19
-
20
- if (!isOpen) {
21
- prevIsOpenRef.current = false;
22
- }
23
-
19
+ setIsPrimaryContrast(isPrimaryContrastFromCss.toString() === '1');
20
+ }, [isOpen, triggerRef]);
24
21
  return {
25
- isPrimaryContrast: isPrimaryContrastRef.current
22
+ isPrimaryContrast
26
23
  };
27
24
  };
28
25
 
@@ -1,6 +1,4 @@
1
1
  import React from 'react';
2
- export declare const useFallbackId: {
3
- (): string;
4
- counter: number;
5
- };
6
- export declare const useSafeId: typeof React.useId;
2
+ declare function useFallbackId(): number;
3
+ export declare const useSafeId: typeof React.useId | typeof useFallbackId;
4
+ export {};
@@ -1,15 +1,10 @@
1
- import React, { useRef } from 'react';
1
+ import React, { useState } from 'react';
2
+ let nextFallbackId = 0;
2
3
 
3
- const useFallbackId = () => {
4
- const id = useRef(null);
4
+ function useFallbackId() {
5
+ const [id] = useState(() => nextFallbackId++);
6
+ return id;
7
+ }
5
8
 
6
- if (id.current === null) {
7
- id.current = useFallbackId.counter++;
8
- }
9
-
10
- return id.current.toString();
11
- };
12
-
13
- useFallbackId.counter = 0;
14
9
  const useSafeId = React.useId ?? useFallbackId;
15
- export { useFallbackId, useSafeId };
10
+ export { useSafeId };