@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
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Select } from './select';
|
|
2
|
-
export { Multiselect } from './multiselect';
|
|
3
|
-
export { NativeSelect } from './native-select';
|
|
4
|
-
export type { SelectProps, MultiselectProps, NativeSelectProps, SelectOption, Key } from './types';
|
|
1
|
+
export { Select } from './select';
|
|
2
|
+
export { Multiselect } from './multiselect';
|
|
3
|
+
export { NativeSelect } from './native-select';
|
|
4
|
+
export type { SelectProps, MultiselectProps, NativeSelectProps, SelectOption, Key } from './types';
|
package/lib/multiselect.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import type { MultiselectProps } from './types';
|
|
3
|
-
export declare function Multiselect({ options, value
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { MultiselectProps } from './types';
|
|
3
|
+
export declare function Multiselect({ options, value, onChange, error, label, note, size, mode, theme: themeFromProps, placement, isSingleLine, boldLabel, reserveErrorLine, maxVisibleItems, isClearable, isLoading, isDisabled, name, noOptionsMessage, className, id, style, placeholder, ...rest }: MultiselectProps): React.JSX.Element;
|
package/lib/multiselect.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { useMemo, useRef } from 'react';
|
|
2
3
|
import cn from 'classnames';
|
|
3
|
-
import { Dropdown } from '@rescui/dropdown';
|
|
4
4
|
import { useSelect } from 'downshift';
|
|
5
5
|
import { useThemeWithUndefined } from '@rescui/ui-contexts';
|
|
6
6
|
import scrollIntoView from 'scroll-into-view-if-needed';
|
|
@@ -8,11 +8,11 @@ import { useLabelFocus } from './hooks/use-label-focus.js';
|
|
|
8
8
|
import { useOptions } from './hooks/use-options.js';
|
|
9
9
|
import { useMultiHandlers } from './hooks/use-multi-handlers.js';
|
|
10
10
|
import { useA11y } from './hooks/use-a11y.js';
|
|
11
|
-
import { ListBox } from './parts/list-box.js';
|
|
12
11
|
import { Icons } from './parts/icons.js';
|
|
13
12
|
import { MultiTrigger } from './parts/multi-trigger.js';
|
|
14
13
|
import { HiddenSelect } from './parts/hidden-select.js';
|
|
15
14
|
import { FormTriggerWrapper } from './parts/form-trigger-wrapper.js';
|
|
15
|
+
import { PopupContent } from './parts/popup-content.js';
|
|
16
16
|
import { getEmptyMessage } from './utils/get-empty-message.js';
|
|
17
17
|
import { mergeProps } from './utils/merge-props.js';
|
|
18
18
|
import { itemToString } from './utils/item-to-string.js';
|
|
@@ -37,7 +37,7 @@ const stateReducer = (state, actionAndChanges) => {
|
|
|
37
37
|
const {
|
|
38
38
|
changes,
|
|
39
39
|
type
|
|
40
|
-
} = actionAndChanges;
|
|
40
|
+
} = actionAndChanges;
|
|
41
41
|
|
|
42
42
|
switch (type) {
|
|
43
43
|
case useSelect.stateChangeTypes.ToggleButtonKeyDownEnter:
|
|
@@ -45,6 +45,7 @@ const stateReducer = (state, actionAndChanges) => {
|
|
|
45
45
|
case useSelect.stateChangeTypes.ItemClick:
|
|
46
46
|
return { ...changes,
|
|
47
47
|
isOpen: true,
|
|
48
|
+
// Keep menu open after selection.
|
|
48
49
|
highlightedIndex: state.highlightedIndex
|
|
49
50
|
};
|
|
50
51
|
|
|
@@ -59,7 +60,7 @@ const stateReducer = (state, actionAndChanges) => {
|
|
|
59
60
|
function Multiselect(_ref) {
|
|
60
61
|
let {
|
|
61
62
|
options = [],
|
|
62
|
-
value
|
|
63
|
+
value,
|
|
63
64
|
onChange,
|
|
64
65
|
error,
|
|
65
66
|
label,
|
|
@@ -83,10 +84,11 @@ function Multiselect(_ref) {
|
|
|
83
84
|
placeholder,
|
|
84
85
|
...rest
|
|
85
86
|
} = _ref;
|
|
87
|
+
const selectedItems = useMemo(() => value ?? [], [value]);
|
|
86
88
|
const theme = useThemeWithUndefined(themeFromProps);
|
|
87
|
-
const triggerRef =
|
|
88
|
-
const menuRef =
|
|
89
|
-
const dropdownRef =
|
|
89
|
+
const triggerRef = useRef(null);
|
|
90
|
+
const menuRef = useRef(null);
|
|
91
|
+
const dropdownRef = useRef(null);
|
|
90
92
|
const {
|
|
91
93
|
selectedMap,
|
|
92
94
|
removeItem: removeSelectedItem,
|
|
@@ -109,7 +111,8 @@ function Multiselect(_ref) {
|
|
|
109
111
|
} = useA11y({
|
|
110
112
|
prefix: 'multiselect',
|
|
111
113
|
error,
|
|
112
|
-
description: note
|
|
114
|
+
description: note,
|
|
115
|
+
isDisabled
|
|
113
116
|
});
|
|
114
117
|
const {
|
|
115
118
|
isOpen,
|
|
@@ -122,6 +125,7 @@ function Multiselect(_ref) {
|
|
|
122
125
|
} = useSelect({
|
|
123
126
|
items: flattenedOptions,
|
|
124
127
|
itemToString,
|
|
128
|
+
itemToKey: getOptionValue,
|
|
125
129
|
id: baseId,
|
|
126
130
|
|
|
127
131
|
onIsOpenChange(newIsOpen) {
|
|
@@ -180,7 +184,13 @@ function Multiselect(_ref) {
|
|
|
180
184
|
ref: triggerRef,
|
|
181
185
|
// eslint-disable-next-line complexity
|
|
182
186
|
onKeyDown: event => {
|
|
183
|
-
//
|
|
187
|
+
// prevent default behavior of Downshift when pressing Ctrl
|
|
188
|
+
if (event.ctrlKey || event.metaKey) {
|
|
189
|
+
event.preventDownshiftDefault = true;
|
|
190
|
+
return;
|
|
191
|
+
} // shift + arrow up/down selection (when popup is open)
|
|
192
|
+
|
|
193
|
+
|
|
184
194
|
if (isOpen && event.shiftKey && (event.key === 'ArrowUp' || event.key === 'ArrowDown')) {
|
|
185
195
|
const newHighlightedIndex = event.key === 'ArrowUp' ? Math.max(highlightedIndex - 1, 0) : Math.min(highlightedIndex + 1, flattenedOptions.length - 1);
|
|
186
196
|
|
|
@@ -205,13 +215,7 @@ function Multiselect(_ref) {
|
|
|
205
215
|
...(isOpen && isListBoxEmpty ? {
|
|
206
216
|
'aria-activedescendant': menuProps.id
|
|
207
217
|
} : {})
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
useEffect(() => {
|
|
211
|
-
if (dropdownRef.current) {
|
|
212
|
-
dropdownRef.current.scheduleUpdate();
|
|
213
|
-
}
|
|
214
|
-
}, [selectedItems]);
|
|
218
|
+
});
|
|
215
219
|
const {
|
|
216
220
|
isFocusedByLabel,
|
|
217
221
|
labelClickProps,
|
|
@@ -224,7 +228,6 @@ function Multiselect(_ref) {
|
|
|
224
228
|
});
|
|
225
229
|
const listBoxState = {
|
|
226
230
|
selectedMap,
|
|
227
|
-
selectionMode: 'multiple',
|
|
228
231
|
highlightedIndex,
|
|
229
232
|
getItemProps,
|
|
230
233
|
menuProps
|
|
@@ -251,16 +254,19 @@ function Multiselect(_ref) {
|
|
|
251
254
|
value: selectedItems,
|
|
252
255
|
isMultiple: true,
|
|
253
256
|
options: flattenedOptions
|
|
254
|
-
}), /*#__PURE__*/React.createElement(
|
|
255
|
-
mode: mode,
|
|
257
|
+
}), /*#__PURE__*/React.createElement(PopupContent, {
|
|
256
258
|
theme: theme,
|
|
257
|
-
|
|
259
|
+
size: size,
|
|
260
|
+
mode: mode,
|
|
261
|
+
dropdownRef: dropdownRef,
|
|
262
|
+
triggerRef: triggerRef,
|
|
258
263
|
placement: placement,
|
|
259
|
-
maxWidth: "trigger",
|
|
260
|
-
minWidth: "trigger",
|
|
261
264
|
isOpen: isOpen,
|
|
262
|
-
|
|
263
|
-
|
|
265
|
+
listBoxState: listBoxState,
|
|
266
|
+
maxVisibleItems: maxVisibleItems,
|
|
267
|
+
emptyListMessage: emptyListMessage,
|
|
268
|
+
listBoxItems: listBoxItems,
|
|
269
|
+
dropdownUpdateDeps: [selectedItems],
|
|
264
270
|
trigger: _ref3 => {
|
|
265
271
|
let {
|
|
266
272
|
ref: triggerRefForDropdown
|
|
@@ -274,9 +280,8 @@ function Multiselect(_ref) {
|
|
|
274
280
|
triggerProps, labelFocusForTriggerProps, {
|
|
275
281
|
ref: triggerRefForDropdown
|
|
276
282
|
}),
|
|
283
|
+
tabIndex: isDisabled ? undefined : 0,
|
|
277
284
|
className: cn(styles.trigger, !isSingleLine && styles.canBeMultiline),
|
|
278
|
-
"data-open": isOpen,
|
|
279
|
-
"data-label-focused": isFocusedByLabel,
|
|
280
285
|
"data-test": "multiselect__trigger"
|
|
281
286
|
}, /*#__PURE__*/React.createElement(MultiTrigger, {
|
|
282
287
|
selectedItems: selectedItems,
|
|
@@ -290,23 +295,15 @@ function Multiselect(_ref) {
|
|
|
290
295
|
isLoading: isLoading,
|
|
291
296
|
canHaveClearIcon: isClearable && !isDisabled && selectedItems.length > 0,
|
|
292
297
|
onClear: () => {
|
|
293
|
-
var _triggerRef$current;
|
|
294
|
-
|
|
295
298
|
reset();
|
|
296
|
-
|
|
299
|
+
triggerRef.current?.focus({
|
|
297
300
|
focusVisible: false
|
|
298
301
|
});
|
|
299
302
|
},
|
|
300
303
|
triggerId: triggerProps.id
|
|
301
304
|
})));
|
|
302
305
|
}
|
|
303
|
-
}
|
|
304
|
-
state: listBoxState,
|
|
305
|
-
size: size,
|
|
306
|
-
maxVisibleItems: maxVisibleItems,
|
|
307
|
-
emptyListMessage: emptyListMessage,
|
|
308
|
-
items: listBoxItems
|
|
309
|
-
}))));
|
|
306
|
+
})));
|
|
310
307
|
}
|
|
311
308
|
|
|
312
309
|
export { Multiselect };
|
package/lib/native-select.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { NativeSelectProps } from './types';
|
|
3
|
-
export declare const NativeSelect: React.FC<NativeSelectProps>;
|
|
4
|
-
export default NativeSelect;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { NativeSelectProps } from './types';
|
|
3
|
+
export declare const NativeSelect: React.FC<NativeSelectProps>;
|
|
4
|
+
export default NativeSelect;
|
package/lib/native-select.js
CHANGED
|
@@ -27,10 +27,8 @@ function findSelectedOption(options, selectedValue) {
|
|
|
27
27
|
|
|
28
28
|
options.forEach(optionOrGroup => {
|
|
29
29
|
if (isOptionAGroup(optionOrGroup)) {
|
|
30
|
-
var _group$options;
|
|
31
|
-
|
|
32
30
|
const group = optionOrGroup;
|
|
33
|
-
|
|
31
|
+
group.options?.forEach(checkOption);
|
|
34
32
|
} else {
|
|
35
33
|
checkOption(optionOrGroup);
|
|
36
34
|
}
|
|
@@ -83,7 +81,8 @@ const NativeSelect = _ref => {
|
|
|
83
81
|
error,
|
|
84
82
|
description: note,
|
|
85
83
|
label,
|
|
86
|
-
fieldRef: triggerRef
|
|
84
|
+
fieldRef: triggerRef,
|
|
85
|
+
isDisabled
|
|
87
86
|
});
|
|
88
87
|
|
|
89
88
|
const reset = () => onChange(null);
|
|
@@ -154,7 +153,7 @@ const NativeSelect = _ref => {
|
|
|
154
153
|
disabled: isDisabled ? true : undefined,
|
|
155
154
|
onChange: handleChange,
|
|
156
155
|
name: name,
|
|
157
|
-
value:
|
|
156
|
+
value: value?.value ?? ''
|
|
158
157
|
}, /*#__PURE__*/React.createElement(NativeSelectOptionsWithGroups, {
|
|
159
158
|
optionsWithGroups: options,
|
|
160
159
|
placeholder: placeholder,
|
|
@@ -162,29 +161,27 @@ const NativeSelect = _ref => {
|
|
|
162
161
|
})), trigger ? trigger({
|
|
163
162
|
focused: isFocused,
|
|
164
163
|
hovered: isHovered,
|
|
165
|
-
selectedLabel: value
|
|
166
|
-
selectedValue: value
|
|
164
|
+
selectedLabel: value?.label,
|
|
165
|
+
selectedValue: value?.value,
|
|
167
166
|
placeholder
|
|
168
167
|
}) : /*#__PURE__*/React.createElement("div", {
|
|
169
168
|
className: cn(styles.trigger),
|
|
170
169
|
"data-test": 'native-select_trigger',
|
|
171
170
|
"data-rs-internal": 'select-native-trigger'
|
|
172
171
|
}, /*#__PURE__*/React.createElement("span", {
|
|
173
|
-
className: cn(styles.triggerText, !
|
|
172
|
+
className: cn(styles.triggerText, !value?.value && styles.labelNotSelected),
|
|
174
173
|
"data-test": 'native-select_trigger_text',
|
|
175
174
|
"aria-hidden": "true"
|
|
176
|
-
},
|
|
175
|
+
}, value?.label ?? placeholder), /*#__PURE__*/React.createElement(Icons, {
|
|
177
176
|
isLoading: isLoading,
|
|
178
177
|
triggerId: fieldProps.id,
|
|
179
178
|
onClear: () => {
|
|
180
|
-
var _triggerRef$current;
|
|
181
|
-
|
|
182
179
|
reset();
|
|
183
|
-
|
|
180
|
+
triggerRef.current?.focus({
|
|
184
181
|
focusVisible: false
|
|
185
182
|
});
|
|
186
183
|
},
|
|
187
|
-
canHaveClearIcon: isClearable && !isDisabled && Boolean(value
|
|
184
|
+
canHaveClearIcon: isClearable && !isDisabled && Boolean(value?.value)
|
|
188
185
|
})))));
|
|
189
186
|
};
|
|
190
187
|
|
package/lib/parts/foldable.d.ts
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
import React, { Component } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import type { JSX } from 'react';
|
|
3
|
+
export type FoldableProps = {
|
|
4
|
+
className?: string;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
renderHiddenCounter?: (num: number, ref: React.Ref<HTMLElement>) => React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
type FoldableState = {
|
|
9
|
+
lastVisible: number;
|
|
10
|
+
renderingStage: number;
|
|
11
|
+
prevChildren: React.ReactNode;
|
|
12
|
+
};
|
|
13
|
+
export default class Foldable extends Component<FoldableProps, FoldableState> {
|
|
14
|
+
containerRef: React.RefObject<HTMLDivElement>;
|
|
15
|
+
plusNRef: React.RefObject<HTMLElement>;
|
|
16
|
+
childrenEls: HTMLElement[];
|
|
17
|
+
childrenWidths: number[];
|
|
18
|
+
resizeObserver: ResizeObserver;
|
|
19
|
+
tagsResizeObserver: ResizeObserver;
|
|
20
|
+
constructor(props: FoldableProps);
|
|
21
|
+
static getDerivedStateFromProps(props: FoldableProps, state: FoldableState): {
|
|
22
|
+
prevChildren: React.ReactNode;
|
|
23
|
+
renderingStage: number;
|
|
24
|
+
};
|
|
25
|
+
observeChildren(): void;
|
|
26
|
+
componentDidMount(): void;
|
|
27
|
+
componentDidUpdate(): void;
|
|
28
|
+
componentWillUnmount(): void;
|
|
29
|
+
measureChildren: () => void;
|
|
30
|
+
recalculateLastVisibleAndSetStage: (nextStage?: number) => void;
|
|
31
|
+
renderChildren(lastVisible: number): React.FunctionComponentElement<any>[];
|
|
32
|
+
render(): JSX.Element;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Theme } from '@rescui/ui-contexts';
|
|
3
|
-
import { SelectSize } from '../types';
|
|
4
|
-
export
|
|
5
|
-
size?: SelectSize;
|
|
6
|
-
theme?: Theme;
|
|
7
|
-
className?: string;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
error?: boolean | React.ReactNode;
|
|
10
|
-
reserveErrorLine?: boolean;
|
|
11
|
-
errorMessageProps?: object;
|
|
12
|
-
label?: React.ReactNode;
|
|
13
|
-
labelProps?: object;
|
|
14
|
-
note?: React.ReactNode;
|
|
15
|
-
descriptionProps?: object;
|
|
16
|
-
boldLabel?: boolean;
|
|
17
|
-
children?: React.ReactNode;
|
|
18
|
-
} & React.HTMLAttributes<HTMLDivElement>;
|
|
19
|
-
export declare const FormTriggerWrapper: React.ForwardRefExoticComponent<{
|
|
20
|
-
size?: SelectSize;
|
|
21
|
-
theme?: Theme;
|
|
22
|
-
className?: string;
|
|
23
|
-
disabled?: boolean;
|
|
24
|
-
error?: boolean | React.ReactNode;
|
|
25
|
-
reserveErrorLine?: boolean;
|
|
26
|
-
errorMessageProps?: object;
|
|
27
|
-
label?: React.ReactNode;
|
|
28
|
-
labelProps?: object;
|
|
29
|
-
note?: React.ReactNode;
|
|
30
|
-
descriptionProps?: object;
|
|
31
|
-
boldLabel?: boolean;
|
|
32
|
-
children?: React.ReactNode;
|
|
33
|
-
} & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
34
|
-
export default FormTriggerWrapper;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Theme } from '@rescui/ui-contexts';
|
|
3
|
+
import { SelectSize } from '../types';
|
|
4
|
+
export type FormTriggerWrapperProps = {
|
|
5
|
+
size?: SelectSize;
|
|
6
|
+
theme?: Theme;
|
|
7
|
+
className?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
error?: boolean | React.ReactNode;
|
|
10
|
+
reserveErrorLine?: boolean;
|
|
11
|
+
errorMessageProps?: object;
|
|
12
|
+
label?: React.ReactNode;
|
|
13
|
+
labelProps?: object;
|
|
14
|
+
note?: React.ReactNode;
|
|
15
|
+
descriptionProps?: object;
|
|
16
|
+
boldLabel?: boolean;
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
} & React.HTMLAttributes<HTMLDivElement>;
|
|
19
|
+
export declare const FormTriggerWrapper: React.ForwardRefExoticComponent<{
|
|
20
|
+
size?: SelectSize;
|
|
21
|
+
theme?: Theme;
|
|
22
|
+
className?: string;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
error?: boolean | React.ReactNode;
|
|
25
|
+
reserveErrorLine?: boolean;
|
|
26
|
+
errorMessageProps?: object;
|
|
27
|
+
label?: React.ReactNode;
|
|
28
|
+
labelProps?: object;
|
|
29
|
+
note?: React.ReactNode;
|
|
30
|
+
descriptionProps?: object;
|
|
31
|
+
boldLabel?: boolean;
|
|
32
|
+
children?: React.ReactNode;
|
|
33
|
+
} & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
34
|
+
export default FormTriggerWrapper;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import type { SelectOption } from '../types';
|
|
3
|
-
export
|
|
4
|
-
name?: string;
|
|
5
|
-
options: SelectOption[];
|
|
6
|
-
} & ({
|
|
7
|
-
value: SelectOption[];
|
|
8
|
-
isMultiple: true;
|
|
9
|
-
} | {
|
|
10
|
-
value: SelectOption;
|
|
11
|
-
isMultiple: false;
|
|
12
|
-
});
|
|
13
|
-
export declare const HiddenSelect: ({ name, options, value, isMultiple }: HiddenSelectProps) => JSX.Element;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { SelectOption } from '../types';
|
|
3
|
+
export type HiddenSelectProps = {
|
|
4
|
+
name?: string;
|
|
5
|
+
options: SelectOption[];
|
|
6
|
+
} & ({
|
|
7
|
+
value: SelectOption[];
|
|
8
|
+
isMultiple: true;
|
|
9
|
+
} | {
|
|
10
|
+
value: SelectOption;
|
|
11
|
+
isMultiple: false;
|
|
12
|
+
});
|
|
13
|
+
export declare const HiddenSelect: ({ name, options, value, isMultiple }: HiddenSelectProps) => React.JSX.Element;
|
package/lib/parts/icons.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
isLoading: boolean;
|
|
4
|
-
canHaveClearIcon: boolean;
|
|
5
|
-
onClearClick: () => void;
|
|
6
|
-
triggerId?: string;
|
|
7
|
-
className?: string;
|
|
8
|
-
};
|
|
9
|
-
export declare const ClearOrLoading: React.FC<ClearOrLoadingProps>;
|
|
10
|
-
export
|
|
11
|
-
isLoading?: boolean;
|
|
12
|
-
canHaveClearIcon?: boolean;
|
|
13
|
-
onClear?: () => void;
|
|
14
|
-
triggerId?: string;
|
|
15
|
-
};
|
|
16
|
-
export declare const Icons: ({ isLoading, canHaveClearIcon, onClear, triggerId }: IconsProps) => JSX.Element;
|
|
17
|
-
export {};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type ClearOrLoadingProps = {
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
canHaveClearIcon: boolean;
|
|
5
|
+
onClearClick: () => void;
|
|
6
|
+
triggerId?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const ClearOrLoading: React.FC<ClearOrLoadingProps>;
|
|
10
|
+
export type IconsProps = {
|
|
11
|
+
isLoading?: boolean;
|
|
12
|
+
canHaveClearIcon?: boolean;
|
|
13
|
+
onClear?: () => void;
|
|
14
|
+
triggerId?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const Icons: ({ isLoading, canHaveClearIcon, onClear, triggerId }: IconsProps) => React.JSX.Element;
|
|
17
|
+
export {};
|
package/lib/parts/list-box.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import { SelectSize, ListBoxItem, ListBoxState } from '../types';
|
|
3
|
-
export
|
|
4
|
-
state: ListBoxState;
|
|
5
|
-
items: ListBoxItem[];
|
|
6
|
-
size?: SelectSize;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SelectSize, SelectMode, ListBoxItem, ListBoxState } from '../types';
|
|
3
|
+
export type ListBoxProps = {
|
|
4
|
+
state: ListBoxState;
|
|
5
|
+
items: ListBoxItem[];
|
|
6
|
+
size?: SelectSize;
|
|
7
|
+
mode?: SelectMode;
|
|
8
|
+
className?: string;
|
|
9
|
+
maxVisibleItems?: number;
|
|
10
|
+
emptyListMessage: string;
|
|
11
|
+
isPrimaryContrast?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function ListBox({ state, items, size, mode, maxVisibleItems, emptyListMessage, isPrimaryContrast }: ListBoxProps): React.JSX.Element;
|
package/lib/parts/list-box.js
CHANGED
|
@@ -10,6 +10,10 @@ const SIZE_STYLES = {
|
|
|
10
10
|
m: styles.sizeM,
|
|
11
11
|
l: styles.sizeL
|
|
12
12
|
};
|
|
13
|
+
const MODE_STYLES = {
|
|
14
|
+
classic: styles.classic,
|
|
15
|
+
rock: styles.rock
|
|
16
|
+
};
|
|
13
17
|
|
|
14
18
|
function Option(_ref) {
|
|
15
19
|
let {
|
|
@@ -20,7 +24,6 @@ function Option(_ref) {
|
|
|
20
24
|
const ref = useRef(null);
|
|
21
25
|
const {
|
|
22
26
|
selectedMap,
|
|
23
|
-
selectionMode,
|
|
24
27
|
getItemProps,
|
|
25
28
|
highlightedIndex
|
|
26
29
|
} = state;
|
|
@@ -39,7 +42,7 @@ function Option(_ref) {
|
|
|
39
42
|
"data-rs-internal": "select-list-box__item",
|
|
40
43
|
"data-focused": isHighlighted,
|
|
41
44
|
"data-test": `select-options-list__item_${item.key}`
|
|
42
|
-
}, /*#__PURE__*/React.createElement("span", null, item.label),
|
|
45
|
+
}, /*#__PURE__*/React.createElement("span", null, item.label), /*#__PURE__*/React.createElement(CheckOutlineIcon, {
|
|
43
46
|
"data-rs-internal": "select-list-box__check-icon",
|
|
44
47
|
className: cn(styles.checkIcon, isSelected && styles.visible)
|
|
45
48
|
}));
|
|
@@ -77,24 +80,25 @@ function ListBoxGroup(_ref2) {
|
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
function ListBox(_ref3) {
|
|
80
|
-
var _items$find;
|
|
81
|
-
|
|
82
83
|
let {
|
|
83
84
|
state,
|
|
84
85
|
items,
|
|
85
86
|
size,
|
|
87
|
+
mode,
|
|
86
88
|
maxVisibleItems = 5,
|
|
87
|
-
emptyListMessage
|
|
89
|
+
emptyListMessage,
|
|
90
|
+
isPrimaryContrast = false
|
|
88
91
|
} = _ref3;
|
|
89
92
|
const {
|
|
90
93
|
menuProps
|
|
91
94
|
} = state;
|
|
92
|
-
const firstGroupKey =
|
|
95
|
+
const firstGroupKey = items.find(item => item.type === 'group')?.key;
|
|
93
96
|
const itemsCount = getRealItemsCnt(items);
|
|
94
97
|
return /*#__PURE__*/React.createElement("ul", { ...menuProps,
|
|
95
|
-
className: cn(styles.listBox, SIZE_STYLES[size]),
|
|
98
|
+
className: cn(styles.listBox, SIZE_STYLES[size], MODE_STYLES[mode]),
|
|
96
99
|
style: {
|
|
97
|
-
'--_rs-select-list-box-max-height-by-items': calculateMaxHeightByItems(itemsCount, maxVisibleItems)
|
|
100
|
+
'--_rs-select-list-box-max-height-by-items': calculateMaxHeightByItems(itemsCount, maxVisibleItems),
|
|
101
|
+
'--rs-select-contrast-primary': isPrimaryContrast ? '1' : '0'
|
|
98
102
|
},
|
|
99
103
|
"data-rs-internal": "select-list-box",
|
|
100
104
|
"data-test": "select-options-list"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { SelectOption } from '../types';
|
|
3
|
-
export interface MultiTriggerProps {
|
|
4
|
-
selectedItems: SelectOption[];
|
|
5
|
-
removeSelectedItem: (item: SelectOption) => void;
|
|
6
|
-
valueProps: object;
|
|
7
|
-
isSingleLine: boolean;
|
|
8
|
-
isDisabled: boolean;
|
|
9
|
-
placeholder?: string;
|
|
10
|
-
triggerRef?: React.RefObject<HTMLDivElement>;
|
|
11
|
-
}
|
|
12
|
-
export declare function MultiTrigger({ selectedItems, valueProps, isSingleLine, isDisabled, placeholder, triggerRef, removeSelectedItem }: MultiTriggerProps): JSX.Element;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { SelectOption } from '../types';
|
|
3
|
+
export interface MultiTriggerProps {
|
|
4
|
+
selectedItems: SelectOption[];
|
|
5
|
+
removeSelectedItem: (item: SelectOption) => void;
|
|
6
|
+
valueProps: object;
|
|
7
|
+
isSingleLine: boolean;
|
|
8
|
+
isDisabled: boolean;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
triggerRef?: React.RefObject<HTMLDivElement>;
|
|
11
|
+
}
|
|
12
|
+
export declare function MultiTrigger({ selectedItems, valueProps, isSingleLine, isDisabled, placeholder, triggerRef, removeSelectedItem }: MultiTriggerProps): React.JSX.Element;
|
|
@@ -34,10 +34,8 @@ function MultiTrigger(_ref) {
|
|
|
34
34
|
className: styles.tag,
|
|
35
35
|
disabled: isDisabled,
|
|
36
36
|
onRemoveClick: () => {
|
|
37
|
-
var _triggerRef$current;
|
|
38
|
-
|
|
39
37
|
removeSelectedItem(option);
|
|
40
|
-
|
|
38
|
+
triggerRef.current?.focus({
|
|
41
39
|
focusVisible: false
|
|
42
40
|
});
|
|
43
41
|
},
|
|
@@ -46,9 +44,7 @@ function MultiTrigger(_ref) {
|
|
|
46
44
|
"aria-label": getTextFromNodes(option.label),
|
|
47
45
|
onFocus: e => {
|
|
48
46
|
if (e.target.getAttribute('tabindex') === '-1') {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
(_triggerRef$current2 = triggerRef.current) === null || _triggerRef$current2 === void 0 || _triggerRef$current2.focus({
|
|
47
|
+
triggerRef.current?.focus({
|
|
52
48
|
focusVisible: false
|
|
53
49
|
});
|
|
54
50
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { NativeSelectOptionOrGroup } from '../types';
|
|
3
|
-
export
|
|
4
|
-
optionsWithGroups: NativeSelectOptionOrGroup[];
|
|
5
|
-
placeholder?: string;
|
|
6
|
-
emptyListMessage?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare const NativeSelectOptionsWithGroups: React.FC<NativeSelectOptionsWithGroupsProps>;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { NativeSelectOptionOrGroup } from '../types';
|
|
3
|
+
export type NativeSelectOptionsWithGroupsProps = {
|
|
4
|
+
optionsWithGroups: NativeSelectOptionOrGroup[];
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
emptyListMessage?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const NativeSelectOptionsWithGroups: React.FC<NativeSelectOptionsWithGroupsProps>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Theme } from '@rescui/ui-contexts';
|
|
3
|
+
import type { DropdownProps, DropdownImperativeHandle } from '@rescui/dropdown';
|
|
4
|
+
import type { SelectMode, SelectSize, ListBoxState, ListBoxItem, Placement } from '../types';
|
|
5
|
+
export type PopupContentProps = {
|
|
6
|
+
theme: Theme;
|
|
7
|
+
listBoxState: ListBoxState;
|
|
8
|
+
triggerRef: React.RefObject<HTMLElement>;
|
|
9
|
+
dropdownRef?: React.RefObject<DropdownImperativeHandle>;
|
|
10
|
+
listBoxItems?: ListBoxItem[];
|
|
11
|
+
placement: Placement;
|
|
12
|
+
size?: SelectSize;
|
|
13
|
+
mode?: SelectMode;
|
|
14
|
+
emptyListMessage: string;
|
|
15
|
+
maxVisibleItems?: number;
|
|
16
|
+
trigger?: DropdownProps['trigger'];
|
|
17
|
+
isOpen?: boolean;
|
|
18
|
+
dropdownUpdateDeps?: unknown[];
|
|
19
|
+
};
|
|
20
|
+
export declare const PopupContent: ({ theme, listBoxState, triggerRef, dropdownRef, listBoxItems, placement, size: sizeFromProps, mode, emptyListMessage, maxVisibleItems, trigger, isOpen, dropdownUpdateDeps }: PopupContentProps) => React.JSX.Element;
|