@rescui/select 0.18.4 → 0.19.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.
Files changed (37) hide show
  1. package/lib/_virtual/check-outline.js +294 -63
  2. package/lib/_virtual/close-outline.js +294 -63
  3. package/lib/_virtual/down-outline.js +294 -63
  4. package/lib/_virtual/index.css.js +12 -12
  5. package/lib/_virtual/loading-outline.js +310 -79
  6. package/lib/hooks/use-a11y.d.ts +2 -2
  7. package/lib/hooks/use-a11y.js +124 -36
  8. package/lib/hooks/use-actual-size-from-css.d.ts +3 -4
  9. package/lib/hooks/use-actual-size-from-css.js +47 -18
  10. package/lib/hooks/use-focus.js +54 -10
  11. package/lib/hooks/use-hover.js +54 -10
  12. package/lib/hooks/use-label-focus.js +45 -15
  13. package/lib/hooks/use-multi-handlers.js +113 -38
  14. package/lib/hooks/use-options.d.ts +2 -1
  15. package/lib/hooks/use-options.js +92 -56
  16. package/lib/hooks/use-primary-contrast-css-var-transfer.d.ts +2 -3
  17. package/lib/hooks/use-primary-contrast-css-var-transfer.js +45 -15
  18. package/lib/index.css +194 -194
  19. package/lib/multiselect.js +527 -174
  20. package/lib/native-select.js +416 -118
  21. package/lib/parts/form-trigger-wrapper.js +159 -39
  22. package/lib/parts/hidden-select.js +105 -29
  23. package/lib/parts/icons.js +191 -49
  24. package/lib/parts/list-box.js +277 -74
  25. package/lib/parts/multi-trigger.d.ts +2 -2
  26. package/lib/parts/multi-trigger.js +125 -48
  27. package/lib/parts/native-select-options-with-groups.js +154 -52
  28. package/lib/parts/popup-content.d.ts +3 -3
  29. package/lib/parts/popup-content.js +146 -46
  30. package/lib/select-basic.js +456 -147
  31. package/lib/select-searchable.js +448 -155
  32. package/lib/select.js +228 -56
  33. package/lib/styles/common.p.module.css.js +29 -29
  34. package/lib/styles/form-trigger.p.module.css.js +12 -12
  35. package/lib/styles/list-box.p.module.css.js +13 -13
  36. package/lib/utils/get-text-from-nodes.js +1 -1
  37. package/package.json +13 -12
@@ -1,26 +1,56 @@
1
+ import { c } from 'react-compiler-runtime';
1
2
  import { useState, useEffect, useLayoutEffect } from 'react';
2
3
  const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
3
4
  /**
4
5
  * Transfer primary contrast css var to the dropdown, but only when the dropdown opens
5
6
  */
6
7
 
7
- const usePrimaryContrastCssVarTransfer = _ref => {
8
- let {
9
- triggerRef,
8
+ const usePrimaryContrastCssVarTransfer = t0 => {
9
+ const $ = c(6);
10
+ const {
11
+ triggerEl,
10
12
  isOpen
11
- } = _ref;
13
+ } = t0;
12
14
  const [isPrimaryContrast, setIsPrimaryContrast] = useState(false);
13
- useIsomorphicLayoutEffect(() => {
14
- if (!isOpen || !triggerRef.current) {
15
- return;
16
- }
17
-
18
- const isPrimaryContrastFromCss = getComputedStyle(triggerRef.current)?.getPropertyValue('--rs-select-contrast-primary');
19
- setIsPrimaryContrast(isPrimaryContrastFromCss.toString() === '1');
20
- }, [isOpen, triggerRef]);
21
- return {
22
- isPrimaryContrast
23
- };
15
+ let t1;
16
+ let t2;
17
+
18
+ if ($[0] !== isOpen || $[1] !== triggerEl) {
19
+ t1 = () => {
20
+ const ownerWindow = triggerEl?.ownerDocument.defaultView;
21
+
22
+ if (!isOpen || !ownerWindow) {
23
+ return;
24
+ }
25
+
26
+ const isPrimaryContrastFromCss = ownerWindow.getComputedStyle(triggerEl).getPropertyValue("--rs-select-contrast-primary");
27
+ setIsPrimaryContrast(isPrimaryContrastFromCss === "1");
28
+ };
29
+
30
+ t2 = [isOpen, triggerEl];
31
+ $[0] = isOpen;
32
+ $[1] = triggerEl;
33
+ $[2] = t1;
34
+ $[3] = t2;
35
+ } else {
36
+ t1 = $[2];
37
+ t2 = $[3];
38
+ }
39
+
40
+ useIsomorphicLayoutEffect(t1, t2);
41
+ let t3;
42
+
43
+ if ($[4] !== isPrimaryContrast) {
44
+ t3 = {
45
+ isPrimaryContrast
46
+ };
47
+ $[4] = isPrimaryContrast;
48
+ $[5] = t3;
49
+ } else {
50
+ t3 = $[5];
51
+ }
52
+
53
+ return t3;
24
54
  };
25
55
 
26
56
  export { usePrimaryContrastCssVarTransfer };