@rescui/select 0.15.1-RUI-280-Update-select-component-separate-components-e772abaa1.56 → 0.15.1-RUI-280-Update-select-component-downshift-cd2a98813.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 (65) hide show
  1. package/lib/_virtual/index.css.js +12 -12
  2. package/lib/constants.d.ts +0 -1
  3. package/lib/constants.js +1 -2
  4. package/lib/hooks/use-a11y.d.ts +29 -0
  5. package/lib/hooks/use-a11y.js +53 -0
  6. package/lib/hooks/use-backward-compatible-id.d.ts +4 -0
  7. package/lib/hooks/use-backward-compatible-id.js +14 -0
  8. package/lib/hooks/use-label-focus.d.ts +1 -3
  9. package/lib/hooks/use-label-focus.js +3 -9
  10. package/lib/hooks/use-multi-handlers.d.ts +11 -0
  11. package/lib/hooks/use-multi-handlers.js +48 -0
  12. package/lib/hooks/use-options.d.ts +13 -0
  13. package/lib/hooks/use-options.js +89 -0
  14. package/lib/index.css +323 -371
  15. package/lib/multiselect.d.ts +3 -29
  16. package/lib/multiselect.js +249 -174
  17. package/lib/native-select.js +67 -46
  18. package/lib/parts/hidden-select.d.ts +13 -0
  19. package/lib/parts/hidden-select.js +45 -0
  20. package/lib/parts/icons.d.ts +3 -1
  21. package/lib/parts/icons.js +11 -14
  22. package/lib/parts/list-box.d.ts +7 -15
  23. package/lib/parts/list-box.js +50 -82
  24. package/lib/parts/multi-trigger.d.ts +5 -4
  25. package/lib/parts/multi-trigger.js +27 -15
  26. package/lib/parts/native-select-trigger.d.ts +6 -8
  27. package/lib/parts/native-select-trigger.js +14 -23
  28. package/lib/select-basic.d.ts +2 -2
  29. package/lib/select-basic.js +161 -97
  30. package/lib/select-searchable.d.ts +2 -2
  31. package/lib/select-searchable.js +208 -122
  32. package/lib/select.d.ts +1 -1
  33. package/lib/select.js +38 -31
  34. package/lib/styles/common.p.module.css.js +25 -24
  35. package/lib/styles/form-trigger.p.module.css.js +12 -12
  36. package/lib/styles/list-box.p.module.css.js +11 -13
  37. package/lib/styles/native-select-trigger.p.module.css.js +15 -14
  38. package/lib/styles/native-select.p.module.css.js +6 -6
  39. package/lib/types.d.ts +26 -27
  40. package/lib/utils/get-real-items-cnt.d.ts +2 -2
  41. package/lib/utils/get-real-items-cnt.js +8 -10
  42. package/lib/utils/item-to-string.d.ts +2 -0
  43. package/lib/utils/item-to-string.js +7 -0
  44. package/lib/utils/merge-props.d.ts +29 -0
  45. package/lib/utils/merge-props.js +106 -0
  46. package/package.json +13 -22
  47. package/lib/hooks/use-css-context-transfer.d.ts +0 -14
  48. package/lib/hooks/use-css-context-transfer.js +0 -40
  49. package/lib/hooks/use-multi-option-serialization.d.ts +0 -10
  50. package/lib/hooks/use-multi-option-serialization.js +0 -82
  51. package/lib/hooks/use-observable-force-rerender.d.ts +0 -2
  52. package/lib/hooks/use-observable-force-rerender.js +0 -16
  53. package/lib/hooks/use-option-serialization.d.ts +0 -10
  54. package/lib/hooks/use-option-serialization.js +0 -59
  55. package/lib/parts/popover.d.ts +0 -12
  56. package/lib/parts/popover.js +0 -64
  57. package/lib/parts/popup-content.d.ts +0 -19
  58. package/lib/parts/popup-content.js +0 -76
  59. package/lib/styles/popover.p.module.css.js +0 -10
  60. package/lib/utils/convert-options.d.ts +0 -3
  61. package/lib/utils/convert-options.js +0 -52
  62. package/lib/utils/convert-placement.d.ts +0 -3
  63. package/lib/utils/convert-placement.js +0 -22
  64. package/lib/utils/css-vars-utils.d.ts +0 -3
  65. package/lib/utils/css-vars-utils.js +0 -20
@@ -1,76 +0,0 @@
1
- import React from 'react';
2
- import { useResizeObserver } from '@rescui/use-resize-observer';
3
- import { useObservableForceRerender } from '../hooks/use-observable-force-rerender.js';
4
- import { useCssContextTransfer } from '../hooks/use-css-context-transfer.js';
5
- import { getRealItemsCnt } from '../utils/get-real-items-cnt.js';
6
- import styles from '../styles/popover.p.module.css.js';
7
- import { Popover } from './popover.js';
8
- import { ListBox, EmptyListBox } from './list-box.js'; // eslint-disable-next-line complexity
9
-
10
- const PopupContent = _ref => {
11
- let {
12
- theme: themeFromProps,
13
- state,
14
- triggerRef,
15
- popoverRef,
16
- listBoxRef,
17
- placement,
18
- size: sizeFromProps,
19
- mode,
20
- listBoxProps,
21
- emptyListMessage,
22
- maxVisibleItems = 5,
23
- selectionMode
24
- } = _ref;
25
- const isOpen = state.isOpen;
26
- const [triggerWidth, setTriggerWidth] = React.useState(null);
27
- useResizeObserver(triggerRef, () => {
28
- setTriggerWidth(`${triggerRef.current.offsetWidth}px`);
29
- }); // We use invisible and "untouchable" dummy element to observe `size` changes from css to trigger force rerenders
30
-
31
- const observableRef = useObservableForceRerender();
32
- const {
33
- theme,
34
- size,
35
- primaryColors
36
- } = useCssContextTransfer({
37
- triggerRef,
38
- isOpen,
39
- themeFromProps,
40
- sizeFromProps
41
- });
42
- const isEmpty = getRealItemsCnt(state) === 0;
43
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
44
- ref: observableRef,
45
- className: styles.observable
46
- }), isOpen && /*#__PURE__*/React.createElement(Popover, {
47
- state: state,
48
- triggerRef: triggerRef,
49
- popoverRef: popoverRef,
50
- placement: placement,
51
- style: {
52
- '--_rs-select-trigger-width': triggerWidth || 'auto',
53
- '--rs-theme-dark': theme === 'dark' ? '1' : '0',
54
- ...primaryColors
55
- },
56
- mode: mode
57
- }, !isEmpty ? /*#__PURE__*/React.createElement(ListBox, {
58
- listBoxRef: listBoxRef,
59
- ariaListBoxProps: listBoxProps,
60
- size: size,
61
- mode: mode,
62
- state: state,
63
- maxVisibleItems: maxVisibleItems,
64
- selectionMode: selectionMode
65
- }) : /*#__PURE__*/React.createElement(EmptyListBox, {
66
- listBoxRef: listBoxRef,
67
- ariaListBoxProps: listBoxProps,
68
- size: size,
69
- mode: mode,
70
- emptyListMessage: emptyListMessage,
71
- maxVisibleItems: maxVisibleItems,
72
- selectionMode: selectionMode
73
- })));
74
- };
75
-
76
- export { PopupContent };
@@ -1,10 +0,0 @@
1
- var styles = {
2
- "classic": "_classic_fve5ja_32",
3
- "rock": "_rock_fve5ja_35",
4
- "popover": "_popover_fve5ja_39",
5
- "contentWrapper": "_contentWrapper_fve5ja_46",
6
- "fadeInBottomToTop": "_fadeInBottomToTop_fve5ja_1",
7
- "fadeInTopToBottom": "_fadeInTopToBottom_fve5ja_1",
8
- "observable": "_observable_fve5ja_62"
9
- };
10
- export { styles as default };
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { SelectOption, SelectOptionOrGroup } from '../types';
3
- export declare const convertOptions: (options: SelectOptionOrGroup[], virtualOptions: SelectOption[]) => JSX.Element[];
@@ -1,52 +0,0 @@
1
- import React from 'react';
2
- import { Section, Item } from 'react-stately';
3
- import { getOptionValue } from './get-option-value.js';
4
- import { getTextFromNodes } from './get-text-from-nodes.js';
5
- import { isOptionAGroup } from './is-option-a-group.js';
6
- import { VIRTUAL_ITEMS_SECTION_KEY } from '../constants.js';
7
-
8
- const convertOptions = (options, virtualOptions) => [...options.map((item, index) => {
9
- // Check if it's a group
10
- if (isOptionAGroup(item)) {
11
- const group = item;
12
-
13
- if (!group.options || group.options.length === 0) {
14
- return null;
15
- } // Render as Section (with or without label)
16
-
17
-
18
- const groupLabelText = group.label ? getTextFromNodes(group.label) : ''; // Use a special prefix that's unlikely to collide with user values
19
-
20
- const sectionKey = `\0__rs_section_${index}_${groupLabelText}`;
21
- return /*#__PURE__*/React.createElement(Section, {
22
- key: sectionKey,
23
- title: group.label,
24
- "aria-label": groupLabelText || undefined
25
- }, group.options.map(option => {
26
- const key = getOptionValue(option);
27
- return /*#__PURE__*/React.createElement(Item, {
28
- key: key,
29
- textValue: getTextFromNodes(option.label)
30
- }, option.label);
31
- }));
32
- } // It's a single option
33
-
34
-
35
- const option = item;
36
- const key = getOptionValue(option);
37
- return /*#__PURE__*/React.createElement(Item, {
38
- key: key,
39
- textValue: getTextFromNodes(option.label)
40
- }, option.label);
41
- }), virtualOptions.length > 0 && /*#__PURE__*/React.createElement(Section, {
42
- key: VIRTUAL_ITEMS_SECTION_KEY,
43
- title: ''
44
- }, virtualOptions.map(option => {
45
- const key = getOptionValue(option);
46
- return /*#__PURE__*/React.createElement(Item, {
47
- key: key,
48
- textValue: getTextFromNodes(option.label)
49
- }, option.label);
50
- }))].filter(Boolean);
51
-
52
- export { convertOptions };
@@ -1,3 +0,0 @@
1
- import { type AriaPositionProps } from 'react-aria';
2
- import { Placement } from '../types';
3
- export declare const convertPlacement: (outsidePlacement: Placement) => AriaPositionProps['placement'];
@@ -1,22 +0,0 @@
1
- const convertPlacement = outsidePlacement => {
2
- const placementMap = {
3
- top: 'top',
4
- 'top-start': 'top start',
5
- 'top-end': 'top end',
6
- bottom: 'bottom',
7
- 'bottom-start': 'bottom start',
8
- 'bottom-end': 'bottom end',
9
- left: 'left',
10
- 'left-start': 'left top',
11
- 'left-end': 'left bottom',
12
- right: 'right',
13
- 'right-start': 'right top',
14
- 'right-end': 'right bottom',
15
- auto: null,
16
- 'auto-start': 'start',
17
- 'auto-end': 'end'
18
- };
19
- return placementMap[outsidePlacement] || 'bottom';
20
- };
21
-
22
- export { convertPlacement };
@@ -1,3 +0,0 @@
1
- export declare const extractPrimaryColors: (styles: CSSStyleDeclaration) => Record<string, string>;
2
- /** Check out `@rescui/colors/src/public-api.p.css` file */
3
- export declare const extractThemeFromCss: (styles: CSSStyleDeclaration) => "dark" | "light";
@@ -1,20 +0,0 @@
1
- const PRIMARY_COLORS = ['--rs-color-primary-light-theme', '--rs-color-primary-dim-light-theme', '--rs-color-primary-fog-light-theme', '--rs-color-primary-t-dim-light-theme', '--rs-color-primary-t-fog-light-theme', '--rs-color-primary-dark-theme', '--rs-color-primary-dim-dark-theme', '--rs-color-primary-fog-dark-theme', '--rs-color-primary-t-dim-dark-theme', '--rs-color-primary-t-fog-dark-theme'];
2
-
3
- const extractPrimaryColors = styles => {
4
- const colors = {};
5
- PRIMARY_COLORS.forEach(varName => {
6
- colors[varName] = styles.getPropertyValue(varName) || 'initial';
7
- });
8
- return colors;
9
- };
10
- /** Check out `@rescui/colors/src/public-api.p.css` file */
11
-
12
-
13
- const extractThemeFromCss = styles => {
14
- const themeDark = parseInt(styles.getPropertyValue('--rs-theme-dark'), 10) || 0;
15
- const themeFlip = parseInt(styles.getPropertyValue('--rs-theme-flip'), 10) || 0;
16
- const themeDarkCoefficient = themeDark * (1 - themeFlip) + themeFlip * (1 - themeDark);
17
- return themeDarkCoefficient === 1 ? 'dark' : 'light';
18
- };
19
-
20
- export { extractPrimaryColors, extractThemeFromCss };