@rescui/select 0.15.1-RUI-280-Update-select-component-downshift-2f40ef205.67 → 0.15.2-RUI-291-Update-next-js-to-the-latest-version-8f54dec0a.66

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 (59) hide show
  1. package/lib/_virtual/index.css.js +12 -12
  2. package/lib/common-prop-types.d.ts +29 -30
  3. package/lib/constants.d.ts +6 -6
  4. package/lib/hooks/use-a11y.d.ts +30 -29
  5. package/lib/hooks/use-a11y.js +10 -7
  6. package/lib/hooks/use-actual-size-from-css.d.ts +10 -0
  7. package/lib/hooks/use-actual-size-from-css.js +27 -0
  8. package/lib/hooks/use-focus.d.ts +10 -10
  9. package/lib/hooks/use-hover.d.ts +10 -10
  10. package/lib/hooks/use-label-focus.d.ts +9 -9
  11. package/lib/hooks/use-multi-handlers.d.ts +11 -11
  12. package/lib/hooks/use-multi-handlers.js +6 -10
  13. package/lib/hooks/use-options.d.ts +13 -13
  14. package/lib/hooks/use-options.js +7 -6
  15. package/lib/hooks/use-primary-contrast-css-var-transfer.d.ts +11 -0
  16. package/lib/hooks/use-primary-contrast-css-var-transfer.js +29 -0
  17. package/lib/hooks/use-safe-id.d.ts +6 -0
  18. package/lib/hooks/use-safe-id.js +15 -0
  19. package/lib/index.css +965 -932
  20. package/lib/index.d.ts +4 -4
  21. package/lib/multiselect.d.ts +3 -3
  22. package/lib/multiselect.js +34 -37
  23. package/lib/native-select.d.ts +4 -4
  24. package/lib/native-select.js +10 -13
  25. package/lib/parts/foldable.d.ts +34 -33
  26. package/lib/parts/form-trigger-wrapper.d.ts +34 -34
  27. package/lib/parts/hidden-select.d.ts +13 -13
  28. package/lib/parts/icons.d.ts +17 -17
  29. package/lib/parts/list-box.d.ts +13 -11
  30. package/lib/parts/list-box.js +12 -8
  31. package/lib/parts/multi-trigger.d.ts +12 -12
  32. package/lib/parts/multi-trigger.js +2 -6
  33. package/lib/parts/native-select-options-with-groups.d.ts +8 -8
  34. package/lib/parts/popup-content.d.ts +20 -0
  35. package/lib/parts/popup-content.js +68 -0
  36. package/lib/select-basic.d.ts +3 -3
  37. package/lib/select-basic.js +25 -24
  38. package/lib/select-searchable.d.ts +3 -3
  39. package/lib/select-searchable.js +22 -27
  40. package/lib/select.d.ts +28 -28
  41. package/lib/styles/common.p.module.css.js +29 -28
  42. package/lib/styles/form-trigger.p.module.css.js +12 -12
  43. package/lib/styles/list-box.p.module.css.js +13 -11
  44. package/lib/types.d.ts +202 -197
  45. package/lib/utils/calculate-max-height-by-items.d.ts +13 -13
  46. package/lib/utils/calculate-max-height-by-items.js +11 -11
  47. package/lib/utils/get-empty-message.d.ts +6 -6
  48. package/lib/utils/get-option-value.d.ts +2 -2
  49. package/lib/utils/get-real-items-cnt.d.ts +2 -2
  50. package/lib/utils/get-text-from-nodes.d.ts +2 -2
  51. package/lib/utils/get-text-from-nodes.js +1 -3
  52. package/lib/utils/is-option-a-group.d.ts +2 -2
  53. package/lib/utils/item-to-string.d.ts +2 -2
  54. package/lib/utils/merge-props.d.ts +19 -29
  55. package/lib/utils/merge-props.js +70 -72
  56. package/lib/utils/throttle.d.ts +1 -1
  57. package/package.json +8 -8
  58. package/lib/hooks/use-backward-compatible-id.d.ts +0 -4
  59. package/lib/hooks/use-backward-compatible-id.js +0 -14
@@ -1,15 +1,24 @@
1
1
  import cn from 'classnames';
2
- /* eslint-disable @typescript-eslint/no-explicit-any,consistent-return */
2
+ /**
3
+ * Assigns a value to a single ref — handles callback refs, object refs, null, and undefined.
4
+ * Returns the cleanup function if the callback ref returned one.
5
+ */
6
+
7
+ function assignRef(ref, value) {
8
+ if (ref == null) {
9
+ return;
10
+ }
3
11
 
4
- function setRef(ref, value) {
5
12
  if (typeof ref === 'function') {
6
13
  return ref(value);
7
- } else if (ref !== null) {
8
- ref.current = value;
9
14
  }
15
+
16
+ ref.current = value;
10
17
  }
11
- /**
12
- * Merges multiple refs into one. Works with either callback or object refs.
18
+ /**
19
+ * Merges multiple refs into a single callback ref.
20
+ * All provided refs are assigned in left-to-right order.
21
+ * Cleanup functions returned by callback refs are called on detach.
13
22
  */
14
23
 
15
24
 
@@ -18,89 +27,78 @@ function mergeRefs() {
18
27
  refs[_key] = arguments[_key];
19
28
  }
20
29
 
21
- if (refs.length === 1 && refs[0]) {
22
- return refs[0];
23
- }
24
-
25
30
  return value => {
26
- let hasCleanup = false;
27
- const cleanups = refs.map(ref => {
28
- const cleanup = setRef(ref, value);
29
- hasCleanup = hasCleanup || typeof cleanup === 'function';
30
- return cleanup;
31
- });
32
-
33
- if (hasCleanup) {
34
- return () => {
35
- cleanups.forEach((cleanup, i) => {
36
- if (typeof cleanup === 'function') {
37
- cleanup();
38
- } else {
39
- setRef(refs[i], null);
40
- }
41
- });
42
- };
31
+ const cleanups = refs.map(ref => assignRef(ref, value)); // return a combined cleanup only if at least one callback ref provided one.
32
+ // when React uses the cleanup API it will NOT call our merged ref with null on unmount,
33
+ // so we must manually null-out every ref that had no cleanup of its own.
34
+
35
+ if (cleanups.some(Boolean)) {
36
+ return () => cleanups.forEach((cleanup, i) => {
37
+ if (typeof cleanup === 'function') {
38
+ cleanup();
39
+ } else {
40
+ // simulate the ref(null) call that React skips when a cleanup is returned
41
+ assignRef(refs[i], null);
42
+ }
43
+ });
43
44
  }
44
45
  };
45
46
  }
46
47
 
47
- function chain() {
48
- for (var _len2 = arguments.length, callbacks = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
49
- callbacks[_key2] = arguments[_key2];
48
+ function pushProp(target, key, value) {
49
+ if (key === 'ref') {
50
+ target.ref = target.ref ? mergeRefs(target.ref, value) : value;
51
+ } else if (key === 'className') {
52
+ target.className = cn(target.className, value);
53
+ } else if (key === 'style') {
54
+ target.style = { ...target.style,
55
+ ...value
56
+ };
57
+ } else if (typeof value === 'function') {
58
+ const oldFn = target[key];
59
+ target[key] = oldFn ? function () {
60
+ oldFn(...arguments);
61
+ value(...arguments);
62
+ } : value;
63
+ } else if (!(key in target) || value !== undefined) {
64
+ // for any other duplicate prop, the value from the later object takes precedence;
65
+ // undefined is ignored on duplicated so it cannot erase an existing value
66
+ target[key] = value;
50
67
  }
51
-
52
- return function () {
53
- for (const callback of callbacks) {
54
- if (typeof callback === 'function') {
55
- callback(...arguments);
56
- }
57
- }
58
- };
59
68
  }
60
- /**
61
- * Merges multiple props objects together. Event handlers are chained,
62
- * classNames are combined, ids are deduplicated, and refs are merged.
63
- * For all other props, the last prop object overrides all previous ones.
64
- * @param args - Multiple sets of props to merge together.
69
+ /**
70
+ * Combines multiple sets of props into a single object:
71
+ * - conflicting `className` values are joined with a space
72
+ * - conflicting `style` objects are shallow-merged (rightmost wins on conflict)
73
+ * - conflicting function props (event handlers) are composed and called left to right
74
+ * - conflicting `ref` props (object refs, callback refs, or null) are merged into a single
75
+ * callback ref that assigns all of them; cleanup functions returned by callback refs are
76
+ * collected and called together on detach
77
+ * - any other conflicting prop is resolved by taking the value from the rightmost props object
78
+ * @param props One or more props objects to merge. Props further to the right take precedence.
65
79
  */
66
- // eslint-disable-next-line complexity
67
80
 
68
81
 
69
82
  function mergeProps() {
70
- // Start with a base clone of the first argument. This is a lot faster than starting
71
- // with an empty object and adding properties as we go.
72
- const result = { ...(arguments.length <= 0 ? undefined : arguments[0])
73
- };
83
+ for (var _len2 = arguments.length, props = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
84
+ props[_key2] = arguments[_key2];
85
+ }
74
86
 
75
- for (let i = 1; i < arguments.length; i++) {
76
- const props = i < 0 || arguments.length <= i ? undefined : arguments[i];
87
+ if (props.length === 1) {
88
+ return props[0];
89
+ }
77
90
 
78
- for (const key in props) {
79
- if (!props.hasOwnProperty(key)) {
91
+ return props.reduce((merged, ps) => {
92
+ for (const key in ps) {
93
+ if (!ps.hasOwnProperty(key)) {
80
94
  continue;
81
95
  }
82
96
 
83
- const a = result[key];
84
- const b = props[key]; // Chain events
85
-
86
- if (typeof a === 'function' && typeof b === 'function' && // This is a lot faster than a regex.
87
- key[0] === 'o' && key[1] === 'n' && key.charCodeAt(2) >=
88
- /* 'A' */
89
- 65 && key.charCodeAt(2) <=
90
- /* 'Z' */
91
- 90) {
92
- result[key] = chain(a, b); // Merge classnames, sometimes classNames are empty string which eval to false, so we just need to do a type check
93
- } else if (key === 'className' && typeof a === 'string' && typeof b === 'string') {
94
- result[key] = cn(a, b);
95
- } else if (key === 'ref' && a && b) {
96
- result.ref = mergeRefs(a, b); // Override others
97
- } else {
98
- result[key] = b !== undefined ? b : a;
99
- }
97
+ pushProp(merged, key, ps[key]);
100
98
  }
101
- }
102
99
 
103
- return result;
100
+ return merged;
101
+ }, {});
104
102
  }
105
103
 
106
- export { chain, mergeProps, mergeRefs };
104
+ export { mergeProps };
@@ -1 +1 @@
1
- export declare function throttle<A extends unknown[], R>(func: (...args: A) => R, wait: number): (...args: A) => R;
1
+ export declare function throttle<A extends unknown[], R>(func: (...args: A) => R, wait: number): (...args: A) => R;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rescui/select",
3
- "version": "0.15.1-RUI-280-Update-select-component-downshift-2f40ef205.67+2f40ef205",
3
+ "version": "0.15.2-RUI-291-Update-next-js-to-the-latest-version-8f54dec0a.66+8f54dec0a",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "author": "JetBrains",
@@ -16,10 +16,10 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@babel/runtime-corejs3": "^7.26.0",
19
- "@rescui/dropdown": "0.9.5-RUI-280-Update-select-component-downshift-2f40ef205.67+2f40ef205",
20
- "@rescui/form-field": "0.1.1-RUI-280-Update-select-component-downshift-2f40ef205.67+2f40ef205",
21
- "@rescui/tag": "0.13.5-RUI-280-Update-select-component-downshift-2f40ef205.67+2f40ef205",
22
- "@rescui/use-resize-observer": "0.3.1-RUI-280-Update-select-component-downshift-2f40ef205.179+2f40ef205",
19
+ "@rescui/dropdown": "0.9.6-RUI-291-Update-next-js-to-the-latest-version-8f54dec0a.66+8f54dec0a",
20
+ "@rescui/form-field": "0.1.2-RUI-291-Update-next-js-to-the-latest-version-8f54dec0a.66+8f54dec0a",
21
+ "@rescui/tag": "0.13.6-RUI-291-Update-next-js-to-the-latest-version-8f54dec0a.66+8f54dec0a",
22
+ "@rescui/use-resize-observer": "0.3.1-RUI-291-Update-next-js-to-the-latest-version-8f54dec0a.191+8f54dec0a",
23
23
  "classnames": "^2.2.6",
24
24
  "downshift": "^9.3.2",
25
25
  "scroll-into-view-if-needed": "3.1.0"
@@ -30,9 +30,9 @@
30
30
  "react": ">=16.8.0 <20"
31
31
  },
32
32
  "devDependencies": {
33
- "@rescui/colors": "0.3.1-RUI-280-Update-select-component-downshift-2f40ef205.67+2f40ef205",
33
+ "@rescui/colors": "0.3.1-RUI-291-Update-next-js-to-the-latest-version-8f54dec0a.79+8f54dec0a",
34
34
  "@rescui/scripts": "0.5.1",
35
- "@rescui/typography": "0.24.5-RUI-280-Update-select-component-downshift-2f40ef205.67+2f40ef205",
35
+ "@rescui/typography": "0.25.1-RUI-291-Update-next-js-to-the-latest-version-8f54dec0a.66+8f54dec0a",
36
36
  "@rescui/visual-regression": "0.1.4",
37
37
  "sniffr": "^1.2.0"
38
38
  },
@@ -41,5 +41,5 @@
41
41
  "build-pcss-api": "rescui-scripts build-pcss-api --file public-api.p.css"
42
42
  },
43
43
  "nx": {},
44
- "gitHead": "2f40ef205f94c200019ec963e3fd0ca47fe1cdcb"
44
+ "gitHead": "8f54dec0a450da30835485cba2edfd0037cccd25"
45
45
  }
@@ -1,4 +0,0 @@
1
- export declare const useBackwardCompatibleId: {
2
- (): string | number;
3
- counter: number;
4
- };
@@ -1,14 +0,0 @@
1
- import React, { useRef } from 'react';
2
-
3
- const useBackwardCompatibleId = () => {
4
- const id = useRef(null);
5
-
6
- if (id.current === null) {
7
- id.current = useBackwardCompatibleId.counter++;
8
- }
9
-
10
- return (React.useId ? React.useId : () => id.current)();
11
- };
12
-
13
- useBackwardCompatibleId.counter = 0;
14
- export { useBackwardCompatibleId };