@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.
- package/lib/_virtual/index.css.js +12 -12
- package/lib/common-prop-types.d.ts +29 -30
- package/lib/constants.d.ts +6 -6
- package/lib/hooks/use-a11y.d.ts +30 -29
- package/lib/hooks/use-a11y.js +10 -7
- package/lib/hooks/use-actual-size-from-css.d.ts +10 -0
- package/lib/hooks/use-actual-size-from-css.js +27 -0
- package/lib/hooks/use-focus.d.ts +10 -10
- package/lib/hooks/use-hover.d.ts +10 -10
- package/lib/hooks/use-label-focus.d.ts +9 -9
- package/lib/hooks/use-multi-handlers.d.ts +11 -11
- package/lib/hooks/use-multi-handlers.js +6 -10
- package/lib/hooks/use-options.d.ts +13 -13
- package/lib/hooks/use-options.js +7 -6
- package/lib/hooks/use-primary-contrast-css-var-transfer.d.ts +11 -0
- package/lib/hooks/use-primary-contrast-css-var-transfer.js +29 -0
- package/lib/hooks/use-safe-id.d.ts +6 -0
- package/lib/hooks/use-safe-id.js +15 -0
- package/lib/index.css +965 -932
- package/lib/index.d.ts +4 -4
- package/lib/multiselect.d.ts +3 -3
- package/lib/multiselect.js +34 -37
- package/lib/native-select.d.ts +4 -4
- package/lib/native-select.js +10 -13
- package/lib/parts/foldable.d.ts +34 -33
- package/lib/parts/form-trigger-wrapper.d.ts +34 -34
- package/lib/parts/hidden-select.d.ts +13 -13
- package/lib/parts/icons.d.ts +17 -17
- package/lib/parts/list-box.d.ts +13 -11
- package/lib/parts/list-box.js +12 -8
- package/lib/parts/multi-trigger.d.ts +12 -12
- package/lib/parts/multi-trigger.js +2 -6
- package/lib/parts/native-select-options-with-groups.d.ts +8 -8
- package/lib/parts/popup-content.d.ts +20 -0
- package/lib/parts/popup-content.js +68 -0
- package/lib/select-basic.d.ts +3 -3
- package/lib/select-basic.js +25 -24
- package/lib/select-searchable.d.ts +3 -3
- package/lib/select-searchable.js +22 -27
- package/lib/select.d.ts +28 -28
- package/lib/styles/common.p.module.css.js +29 -28
- package/lib/styles/form-trigger.p.module.css.js +12 -12
- package/lib/styles/list-box.p.module.css.js +13 -11
- package/lib/types.d.ts +202 -197
- package/lib/utils/calculate-max-height-by-items.d.ts +13 -13
- package/lib/utils/calculate-max-height-by-items.js +11 -11
- package/lib/utils/get-empty-message.d.ts +6 -6
- package/lib/utils/get-option-value.d.ts +2 -2
- package/lib/utils/get-real-items-cnt.d.ts +2 -2
- package/lib/utils/get-text-from-nodes.d.ts +2 -2
- package/lib/utils/get-text-from-nodes.js +1 -3
- package/lib/utils/is-option-a-group.d.ts +2 -2
- package/lib/utils/item-to-string.d.ts +2 -2
- package/lib/utils/merge-props.d.ts +19 -29
- package/lib/utils/merge-props.js +70 -72
- package/lib/utils/throttle.d.ts +1 -1
- package/package.json +8 -8
- package/lib/hooks/use-backward-compatible-id.d.ts +0 -4
- package/lib/hooks/use-backward-compatible-id.js +0 -14
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"icon": "
|
|
3
|
-
"sizeXS": "
|
|
4
|
-
"sizeS": "
|
|
5
|
-
"sizeM": "
|
|
6
|
-
"sizeL": "
|
|
7
|
-
"light": "
|
|
8
|
-
"dark": "
|
|
9
|
-
"allVariants": "
|
|
10
|
-
"variant16": "
|
|
11
|
-
"variant20": "
|
|
12
|
-
"variant24": "
|
|
13
|
-
"variant28": "
|
|
2
|
+
"icon": "_icon_m1f5bg_4",
|
|
3
|
+
"sizeXS": "_sizeXS_m1f5bg_14",
|
|
4
|
+
"sizeS": "_sizeS_m1f5bg_18",
|
|
5
|
+
"sizeM": "_sizeM_m1f5bg_22",
|
|
6
|
+
"sizeL": "_sizeL_m1f5bg_26",
|
|
7
|
+
"light": "_light_m1f5bg_30",
|
|
8
|
+
"dark": "_dark_m1f5bg_34",
|
|
9
|
+
"allVariants": "_allVariants_m1f5bg_48",
|
|
10
|
+
"variant16": "_variant16_m1f5bg_53",
|
|
11
|
+
"variant20": "_variant20_m1f5bg_54",
|
|
12
|
+
"variant24": "_variant24_m1f5bg_55",
|
|
13
|
+
"variant28": "_variant28_m1f5bg_58"
|
|
14
14
|
};
|
|
15
15
|
export { styles as default };
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export declare const
|
|
30
|
-
export declare const noOptionsMessageType: React.Validator<NoOptionsMessage>;
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import type { NoOptionsMessage, NoOptionsMessageConfig } from './types';
|
|
3
|
+
export declare const keyType: PropTypes.Requireable<NonNullable<string | number>>;
|
|
4
|
+
export declare const optionType: PropTypes.Requireable<PropTypes.InferProps<{
|
|
5
|
+
label: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
6
|
+
value: PropTypes.Requireable<NonNullable<string | number>>;
|
|
7
|
+
}>>;
|
|
8
|
+
export declare const optionsGroupType: PropTypes.Requireable<PropTypes.InferProps<{
|
|
9
|
+
label: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
10
|
+
options: PropTypes.Requireable<PropTypes.InferProps<{
|
|
11
|
+
label: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
12
|
+
value: PropTypes.Requireable<NonNullable<string | number>>;
|
|
13
|
+
}>[]>;
|
|
14
|
+
}>>;
|
|
15
|
+
export declare const nativeOptionType: PropTypes.Requireable<PropTypes.InferProps<{
|
|
16
|
+
label: PropTypes.Validator<string>;
|
|
17
|
+
value: PropTypes.Requireable<NonNullable<string | number>>;
|
|
18
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
19
|
+
}>>;
|
|
20
|
+
export declare const nativeOptionsGroupType: PropTypes.Requireable<PropTypes.InferProps<{
|
|
21
|
+
label: PropTypes.Requireable<string>;
|
|
22
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
23
|
+
options: PropTypes.Requireable<PropTypes.InferProps<{
|
|
24
|
+
label: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
25
|
+
value: PropTypes.Requireable<NonNullable<string | number>>;
|
|
26
|
+
}>[]>;
|
|
27
|
+
}>>;
|
|
28
|
+
export declare const noOptionsMessageConfigType: PropTypes.Validator<NoOptionsMessageConfig>;
|
|
29
|
+
export declare const noOptionsMessageType: PropTypes.Validator<NoOptionsMessage>;
|
package/lib/constants.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare const NO_OPTIONS_VALUE = "\0__rs_select_no_options__";
|
|
2
|
-
export declare const DEFAULT_NO_OPTIONS_MESSAGES: {
|
|
3
|
-
noOptions: string;
|
|
4
|
-
nothingFound: string;
|
|
5
|
-
loading: string;
|
|
6
|
-
};
|
|
1
|
+
export declare const NO_OPTIONS_VALUE = "\0__rs_select_no_options__";
|
|
2
|
+
export declare const DEFAULT_NO_OPTIONS_MESSAGES: {
|
|
3
|
+
noOptions: string;
|
|
4
|
+
nothingFound: string;
|
|
5
|
+
loading: string;
|
|
6
|
+
};
|
package/lib/hooks/use-a11y.d.ts
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export
|
|
3
|
-
prefix?: string;
|
|
4
|
-
baseId?: string;
|
|
5
|
-
description?: React.ReactNode;
|
|
6
|
-
error?: React.ReactNode;
|
|
7
|
-
label?: React.ReactNode;
|
|
8
|
-
fieldRef?: React.RefObject<HTMLElement>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
'aria-
|
|
15
|
-
'aria-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type UseA11yArgs = {
|
|
3
|
+
prefix?: string;
|
|
4
|
+
baseId?: string;
|
|
5
|
+
description?: React.ReactNode;
|
|
6
|
+
error?: React.ReactNode;
|
|
7
|
+
label?: React.ReactNode;
|
|
8
|
+
fieldRef?: React.RefObject<HTMLElement>;
|
|
9
|
+
isDisabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const useA11y: ({ baseId: baseIdFromProps, prefix, description, error, label, fieldRef, isDisabled }: UseA11yArgs) => {
|
|
12
|
+
baseId: string;
|
|
13
|
+
fieldProps: {
|
|
14
|
+
'aria-invalid': boolean;
|
|
15
|
+
'aria-describedby': string;
|
|
16
|
+
'aria-labelledby': string;
|
|
17
|
+
id: string;
|
|
18
|
+
};
|
|
19
|
+
descriptionProps: {
|
|
20
|
+
id: string;
|
|
21
|
+
};
|
|
22
|
+
errorMessageProps: {
|
|
23
|
+
id: string;
|
|
24
|
+
};
|
|
25
|
+
labelProps: {
|
|
26
|
+
id: string;
|
|
27
|
+
htmlFor: string;
|
|
28
|
+
onClick: () => void;
|
|
29
|
+
};
|
|
30
|
+
};
|
package/lib/hooks/use-a11y.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useSafeId } from './use-safe-id.js'; // eslint-disable-next-line complexity
|
|
2
2
|
|
|
3
3
|
const useA11y = _ref => {
|
|
4
4
|
let {
|
|
@@ -7,9 +7,10 @@ const useA11y = _ref => {
|
|
|
7
7
|
description,
|
|
8
8
|
error,
|
|
9
9
|
label,
|
|
10
|
-
fieldRef
|
|
10
|
+
fieldRef,
|
|
11
|
+
isDisabled = false
|
|
11
12
|
} = _ref;
|
|
12
|
-
const uniqueId = `${prefix ? `${prefix}-` : ''}${
|
|
13
|
+
const uniqueId = `${prefix ? `${prefix}-` : ''}${useSafeId()}`;
|
|
13
14
|
const baseId = baseIdFromProps ?? uniqueId;
|
|
14
15
|
const fieldId = `${baseId}-field`;
|
|
15
16
|
const descriptionId = description ? `${baseId}-description` : undefined;
|
|
@@ -32,12 +33,14 @@ const useA11y = _ref => {
|
|
|
32
33
|
id: labelId,
|
|
33
34
|
htmlFor: fieldId,
|
|
34
35
|
onClick: () => {
|
|
35
|
-
if (
|
|
36
|
+
if (isDisabled) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (fieldRef?.current) {
|
|
36
41
|
fieldRef.current.focus();
|
|
37
42
|
} else {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
(_document$getElementB = document.getElementById(fieldId)) === null || _document$getElementB === void 0 || _document$getElementB.focus();
|
|
43
|
+
document.getElementById(fieldId)?.focus();
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { SelectSize } from '../types';
|
|
3
|
+
export type UseActualSizeFromCssParams = {
|
|
4
|
+
sizeFromProps: SelectSize;
|
|
5
|
+
triggerRef: React.RefObject<HTMLElement>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useActualSizeFromCss: ({ sizeFromProps, triggerRef }: UseActualSizeFromCssParams) => {
|
|
8
|
+
observableRef: React.RefObject<HTMLDivElement>;
|
|
9
|
+
size: "l" | "m" | "s";
|
|
10
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
2
|
+
import { useRef, useState } from 'react';
|
|
3
|
+
import { useResizeObserver } from '@rescui/use-resize-observer';
|
|
4
|
+
|
|
5
|
+
const useActualSizeFromCss = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
sizeFromProps,
|
|
8
|
+
triggerRef
|
|
9
|
+
} = _ref;
|
|
10
|
+
// We use invisible and "untouchable" dummy element to observe `size` changes from css to fetch the actual size
|
|
11
|
+
const observableRef = useRef(null);
|
|
12
|
+
const [size, setSize] = useState(sizeFromProps);
|
|
13
|
+
useResizeObserver(observableRef, () => {
|
|
14
|
+
var _context;
|
|
15
|
+
|
|
16
|
+
const triggerFormWrapperStyles = getComputedStyle(triggerRef.current);
|
|
17
|
+
const rawSizeFromCss = triggerFormWrapperStyles.getPropertyValue('--_rs-select-size');
|
|
18
|
+
const sizeFromCss = _includesInstanceProperty(_context = ['s', 'm', 'l']).call(_context, rawSizeFromCss) ? rawSizeFromCss : null;
|
|
19
|
+
setSize(sizeFromCss || sizeFromProps);
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
observableRef,
|
|
23
|
+
size
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { useActualSizeFromCss };
|
package/lib/hooks/use-focus.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
isDisabled?: boolean;
|
|
3
|
-
};
|
|
4
|
-
export declare const useFocus: ({ isDisabled }: UseFocusParams) => {
|
|
5
|
-
isFocused: boolean;
|
|
6
|
-
focusProps: {
|
|
7
|
-
onFocus: () => void;
|
|
8
|
-
onBlur: () => void;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
1
|
+
export type UseFocusParams = {
|
|
2
|
+
isDisabled?: boolean;
|
|
3
|
+
};
|
|
4
|
+
export declare const useFocus: ({ isDisabled }: UseFocusParams) => {
|
|
5
|
+
isFocused: boolean;
|
|
6
|
+
focusProps: {
|
|
7
|
+
onFocus: () => void;
|
|
8
|
+
onBlur: () => void;
|
|
9
|
+
};
|
|
10
|
+
};
|
package/lib/hooks/use-hover.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
isDisabled?: boolean;
|
|
3
|
-
};
|
|
4
|
-
export declare const useHover: ({ isDisabled }: UseHoverParams) => {
|
|
5
|
-
isHovered: boolean;
|
|
6
|
-
hoverProps: {
|
|
7
|
-
onMouseEnter: () => void;
|
|
8
|
-
onMouseLeave: () => void;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
1
|
+
export type UseHoverParams = {
|
|
2
|
+
isDisabled?: boolean;
|
|
3
|
+
};
|
|
4
|
+
export declare const useHover: ({ isDisabled }: UseHoverParams) => {
|
|
5
|
+
isHovered: boolean;
|
|
6
|
+
hoverProps: {
|
|
7
|
+
onMouseEnter: () => void;
|
|
8
|
+
onMouseLeave: () => void;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export declare const useLabelFocus: () => {
|
|
2
|
-
isFocusedByLabel: boolean;
|
|
3
|
-
triggerFocusProps: {
|
|
4
|
-
onBlur: () => void;
|
|
5
|
-
};
|
|
6
|
-
labelClickProps: {
|
|
7
|
-
onClick: () => void;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
1
|
+
export declare const useLabelFocus: () => {
|
|
2
|
+
isFocusedByLabel: boolean;
|
|
3
|
+
triggerFocusProps: {
|
|
4
|
+
onBlur: () => void;
|
|
5
|
+
};
|
|
6
|
+
labelClickProps: {
|
|
7
|
+
onClick: () => void;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { SelectOption } from '../types';
|
|
2
|
-
export
|
|
3
|
-
selectedItems: SelectOption[];
|
|
4
|
-
onChange: (value: SelectOption[]) => void;
|
|
5
|
-
};
|
|
6
|
-
export declare const useMultiHandlers: ({ selectedItems, onChange }: UseMultiHandlersArgs) => {
|
|
7
|
-
selectedMap: Map<import("../types").Key, SelectOption>;
|
|
8
|
-
addItem: (item: SelectOption) => void;
|
|
9
|
-
removeItem: (item: SelectOption) => void;
|
|
10
|
-
removeAllItems: () => void;
|
|
11
|
-
};
|
|
1
|
+
import type { SelectOption } from '../types';
|
|
2
|
+
export type UseMultiHandlersArgs = {
|
|
3
|
+
selectedItems: SelectOption[];
|
|
4
|
+
onChange: (value: SelectOption[]) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const useMultiHandlers: ({ selectedItems, onChange }: UseMultiHandlersArgs) => {
|
|
7
|
+
selectedMap: Map<import("../types").Key, SelectOption>;
|
|
8
|
+
addItem: (item: SelectOption) => void;
|
|
9
|
+
removeItem: (item: SelectOption) => void;
|
|
10
|
+
removeAllItems: () => void;
|
|
11
|
+
};
|
|
@@ -10,31 +10,27 @@ const useMultiHandlers = _ref => {
|
|
|
10
10
|
onChangeRef.current = onChange;
|
|
11
11
|
const selectedMap = useMemo(() => new Map(selectedItems.map(item => [getOptionValue(item), item])), [selectedItems]);
|
|
12
12
|
const addItem = useCallback(item => {
|
|
13
|
-
var _onChangeRef$current;
|
|
14
|
-
|
|
15
13
|
if (selectedMap.has(getOptionValue(item))) {
|
|
16
14
|
return;
|
|
17
15
|
}
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
const newValues = [...selectedMap.values(), item];
|
|
18
|
+
onChangeRef.current?.(newValues);
|
|
20
19
|
}, [selectedMap]);
|
|
21
20
|
const removeItem = useCallback(item => {
|
|
22
|
-
var _onChangeRef$current2;
|
|
23
|
-
|
|
24
21
|
const key = getOptionValue(item);
|
|
25
|
-
|
|
22
|
+
const newValues = [...selectedMap.entries()].filter(_ref2 => {
|
|
26
23
|
let [k] = _ref2;
|
|
27
24
|
return k !== key;
|
|
28
25
|
}).map(_ref3 => {
|
|
29
26
|
let [, v] = _ref3;
|
|
30
27
|
return v;
|
|
31
|
-
})
|
|
28
|
+
});
|
|
29
|
+
onChangeRef.current?.(newValues);
|
|
32
30
|
}, [selectedMap]);
|
|
33
31
|
|
|
34
32
|
const removeAllItems = () => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
(_onChangeRef$current3 = onChangeRef.current) === null || _onChangeRef$current3 === void 0 || _onChangeRef$current3.call(onChangeRef, []);
|
|
33
|
+
onChangeRef.current?.([]);
|
|
38
34
|
};
|
|
39
35
|
|
|
40
36
|
return {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
flattenedOptions: SelectOption[];
|
|
12
|
-
listBoxItems: ListBoxItem[];
|
|
13
|
-
};
|
|
1
|
+
import type { SelectOptionOrGroup, SelectOption, ListBoxItem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Convert an array of options with possible groups to the flat array of options, stripping them of the groups.
|
|
4
|
+
* Also creating a list for ListBox component with indexes and keys.
|
|
5
|
+
* Supports filtering by returning the setFilterString function.
|
|
6
|
+
* @param options
|
|
7
|
+
*/
|
|
8
|
+
export declare const useOptions: (options: SelectOptionOrGroup[]) => {
|
|
9
|
+
setFilterString: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
10
|
+
filterString: string;
|
|
11
|
+
flattenedOptions: SelectOption[];
|
|
12
|
+
listBoxItems: ListBoxItem[];
|
|
13
|
+
};
|
package/lib/hooks/use-options.js
CHANGED
|
@@ -16,11 +16,11 @@ const createFilter = substring => {
|
|
|
16
16
|
return _includesInstanceProperty(_context = string.toLowerCase()).call(_context, lowerSubstring);
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
-
/**
|
|
20
|
-
* Convert an array of options with possible groups to the flat array of options, stripping them of the groups.
|
|
21
|
-
* Also creating a list for ListBox component with indexes and keys.
|
|
22
|
-
* Supports filtering by returning the setFilterString function.
|
|
23
|
-
* @param options
|
|
19
|
+
/**
|
|
20
|
+
* Convert an array of options with possible groups to the flat array of options, stripping them of the groups.
|
|
21
|
+
* Also creating a list for ListBox component with indexes and keys.
|
|
22
|
+
* Supports filtering by returning the setFilterString function.
|
|
23
|
+
* @param options
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
|
|
@@ -82,7 +82,8 @@ const useOptions = options => {
|
|
|
82
82
|
};
|
|
83
83
|
}, [options, filterFn]);
|
|
84
84
|
return { ...processedOptions,
|
|
85
|
-
setFilterString
|
|
85
|
+
setFilterString,
|
|
86
|
+
filterString
|
|
86
87
|
};
|
|
87
88
|
};
|
|
88
89
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type UsePrimaryContrastCssVarTransferParams = {
|
|
3
|
+
triggerRef: React.RefObject<HTMLElement>;
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Transfer primary contrast css var to the dropdown, but only when the dropdown opens
|
|
8
|
+
*/
|
|
9
|
+
export declare const usePrimaryContrastCssVarTransfer: ({ triggerRef, isOpen }: UsePrimaryContrastCssVarTransferParams) => {
|
|
10
|
+
isPrimaryContrast: boolean;
|
|
11
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Transfer primary contrast css var to the dropdown, but only when the dropdown opens
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const usePrimaryContrastCssVarTransfer = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
triggerRef,
|
|
9
|
+
isOpen
|
|
10
|
+
} = _ref;
|
|
11
|
+
const prevIsOpenRef = useRef(false);
|
|
12
|
+
const isPrimaryContrastRef = useRef(false);
|
|
13
|
+
|
|
14
|
+
if (prevIsOpenRef.current !== isOpen && isOpen && triggerRef.current && typeof window !== 'undefined') {
|
|
15
|
+
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
|
+
|
|
24
|
+
return {
|
|
25
|
+
isPrimaryContrast: isPrimaryContrastRef.current
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { usePrimaryContrastCssVarTransfer };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
const useFallbackId = () => {
|
|
4
|
+
const id = useRef(null);
|
|
5
|
+
|
|
6
|
+
if (id.current === null) {
|
|
7
|
+
id.current = useFallbackId.counter++;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return id.current.toString();
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
useFallbackId.counter = 0;
|
|
14
|
+
const useSafeId = React.useId ?? useFallbackId;
|
|
15
|
+
export { useFallbackId, useSafeId };
|