@bolttech/molecules-dropdown 0.34.2 → 0.36.0
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/index.cjs.js
CHANGED
|
@@ -2678,7 +2678,7 @@ const ClickableElement = /*#__PURE__*/styled__default.default.div.withConfig({
|
|
|
2678
2678
|
const ContainerDropdown = /*#__PURE__*/styled__default.default.section.withConfig({
|
|
2679
2679
|
displayName: "molecules-dropdownstyles__ContainerDropdown",
|
|
2680
2680
|
componentId: "sc-3wugi4-1"
|
|
2681
|
-
})(["display:flex;padding-top:", ";padding-bottom:", ";padding-right:", ";padding-left:", ";gap:", ";background-color:", ";outline:", ";outline-offset:calc(", "* -1);border-radius:", ";box-shadow:", ";margin-bottom:", ";input{display:inline-block;text-overflow:ellipsis;white-space:nowrap;width:100%;overflow-x:hidden;}.fieldLabel{color:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";}.requiredLabel{color:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";}label.material-symbols-sharp{color:", ";}&:focus-within{background-color:", ";outline:", ";", "}", " ", ""], ({
|
|
2681
|
+
})(["display:flex;padding-top:", ";padding-bottom:", ";padding-right:", ";padding-left:", ";gap:", ";background-color:", ";outline:", ";outline-offset:calc(", "* -1);border-radius:", ";box-shadow:", ";margin-bottom:", ";input{display:inline-block;text-overflow:ellipsis;white-space:nowrap;width:100%;overflow-x:hidden;}.fieldLabel{color:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";margin:0;}.requiredLabel{color:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";}label.material-symbols-sharp{color:", ";}&:focus-within{background-color:", ";outline:", ";", "}", " ", ""], ({
|
|
2682
2682
|
theme
|
|
2683
2683
|
}) => theme.components.dropdown.paddingVertical, ({
|
|
2684
2684
|
theme
|
|
@@ -2758,7 +2758,7 @@ const ContainerDropdown = /*#__PURE__*/styled__default.default.section.withConfi
|
|
|
2758
2758
|
}) => theme.components.dropdown[$variant].icon.color.focus), ({
|
|
2759
2759
|
$hasError,
|
|
2760
2760
|
$hasValue
|
|
2761
|
-
}) => $hasError && styled.css(["outline:", ";background-color:", ";.fieldLabel{color:", ";}.requiredLabel{color:", ";}label.material-symbols-sharp{color:", ";}"], ({
|
|
2761
|
+
}) => $hasError && styled.css(["outline:", ";background-color:", ";.fieldLabel{color:", ";}.requiredLabel{color:", ";}span.material-symbols-sharp,label.material-symbols-sharp{color:", ";}"], ({
|
|
2762
2762
|
theme,
|
|
2763
2763
|
$variant
|
|
2764
2764
|
}) => `${theme.components.dropdown.borderWidth.default} solid ${theme.components.dropdown[$variant].container.border[$hasValue ? 'errorFilled' : 'error']}`, ({
|
|
@@ -2802,7 +2802,7 @@ const ContainerDropdown = /*#__PURE__*/styled__default.default.section.withConfi
|
|
|
2802
2802
|
const SectionContainer = /*#__PURE__*/styled__default.default.section.withConfig({
|
|
2803
2803
|
displayName: "molecules-dropdownstyles__SectionContainer",
|
|
2804
2804
|
componentId: "sc-3wugi4-2"
|
|
2805
|
-
})(["position:relative;.top{top:-", ";transform:translateY(-100%);}.bottom{top:", ";}.errorMessage{padding-right:", ";padding-left:", ";
|
|
2805
|
+
})(["position:relative;.top{top:-", ";transform:translateY(-100%);}.bottom{top:", ";}.errorMessage{padding-right:", ";padding-left:", ";p{color:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";}}.helperMessage{padding-right:", ";padding-left:", ";margin-top:", ";p{color:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";}}"], ({
|
|
2806
2806
|
theme
|
|
2807
2807
|
}) => theme.components.dropdown.borderWidth.default, ({
|
|
2808
2808
|
theme
|
|
@@ -2906,8 +2906,8 @@ const ReusableDropdownComponent = _a => {
|
|
|
2906
2906
|
},
|
|
2907
2907
|
children: [jsxRuntime.jsxs(ContentDropdown, {
|
|
2908
2908
|
children: [label && jsxRuntime.jsxs(FieldLabelAndRequiredLabelDropdown, {
|
|
2909
|
-
children: [jsxRuntime.jsx("
|
|
2910
|
-
|
|
2909
|
+
children: [jsxRuntime.jsx("p", {
|
|
2910
|
+
id: `${id}-label`,
|
|
2911
2911
|
className: "fieldLabel",
|
|
2912
2912
|
"data-testid": `${dataTestId}-label`,
|
|
2913
2913
|
children: label
|
|
@@ -2918,6 +2918,14 @@ const ReusableDropdownComponent = _a => {
|
|
|
2918
2918
|
})]
|
|
2919
2919
|
}), jsxRuntime.jsx(InputAndIconDropdown, {
|
|
2920
2920
|
children: jsxRuntime.jsx(atomsInput.InputStyled, Object.assign({
|
|
2921
|
+
role: "combobox",
|
|
2922
|
+
"aria-haspopup": "listbox",
|
|
2923
|
+
"aria-owns": `${id}-listbox`,
|
|
2924
|
+
"aria-disabled": disabled,
|
|
2925
|
+
"aria-invalid": hasError,
|
|
2926
|
+
"aria-required": required,
|
|
2927
|
+
"aria-describedby": hasError ? `${id}-error` : helperMessage ? `${id}-helper` : undefined,
|
|
2928
|
+
"aria-expanded": showSelectComponent,
|
|
2921
2929
|
id: `${id}-input`,
|
|
2922
2930
|
"data-testid": `${dataTestId}-input`,
|
|
2923
2931
|
ref: inputRef,
|
|
@@ -2955,20 +2963,25 @@ const ReusableDropdownComponent = _a => {
|
|
|
2955
2963
|
})]
|
|
2956
2964
|
}), jsxRuntime.jsx(ClickableElement, {
|
|
2957
2965
|
children: jsxRuntime.jsx(atomsIcon.Icon, {
|
|
2966
|
+
ariaHidden: true,
|
|
2958
2967
|
dataTestId: `${dataTestId}-icon`,
|
|
2959
2968
|
size: sizeIcon,
|
|
2960
2969
|
icon: showSelectComponent ? 'keyboard_arrow_up' : 'keyboard_arrow_down'
|
|
2961
2970
|
})
|
|
2962
2971
|
})]
|
|
2963
2972
|
}), !showSelectComponent && hasError && errorMessage && jsxRuntime.jsx("div", {
|
|
2973
|
+
id: `${id}-error`,
|
|
2974
|
+
role: "alert",
|
|
2964
2975
|
className: "errorMessage",
|
|
2965
|
-
children: jsxRuntime.jsx("
|
|
2976
|
+
children: jsxRuntime.jsx("p", {
|
|
2966
2977
|
"data-testid": `${dataTestId}-label-error-message`,
|
|
2967
2978
|
children: errorMessage
|
|
2968
2979
|
})
|
|
2969
2980
|
}), !showSelectComponent && !errorMessage && helperMessage && jsxRuntime.jsx("div", {
|
|
2981
|
+
id: `${id}-helper`,
|
|
2982
|
+
role: "status",
|
|
2970
2983
|
className: "helperMessage",
|
|
2971
|
-
children: jsxRuntime.jsx("
|
|
2984
|
+
children: jsxRuntime.jsx("p", {
|
|
2972
2985
|
"data-testid": `${dataTestId}-label-helper-message`,
|
|
2973
2986
|
children: helperMessage
|
|
2974
2987
|
})
|
|
@@ -3410,6 +3423,35 @@ const Dropdown = /*#__PURE__*/react.forwardRef((_a, ref) => {
|
|
|
3410
3423
|
setInternalSelectedOption(currentOptionList.find(option => option.id === value));
|
|
3411
3424
|
setIsFirstRender(false);
|
|
3412
3425
|
}, [currentOptionList, setSelectedOptionOnInputValue, value, internalSelectedOption, optionList, isFirstRender, onKeyUp, onKeyDown, asyncOptionList]);
|
|
3426
|
+
const [focusedIndex, setFocusedIndex] = react.useState(0);
|
|
3427
|
+
const flatOptions = currentOptionList;
|
|
3428
|
+
const handleKeyDown = event => {
|
|
3429
|
+
var _a;
|
|
3430
|
+
const total = flatOptions.length;
|
|
3431
|
+
if (event.key === 'ArrowDown') {
|
|
3432
|
+
event.preventDefault();
|
|
3433
|
+
setFocusedIndex(prev => (prev + 1) % total);
|
|
3434
|
+
}
|
|
3435
|
+
if (event.key === 'ArrowUp') {
|
|
3436
|
+
event.preventDefault();
|
|
3437
|
+
setFocusedIndex(prev => (prev - 1 + total) % total);
|
|
3438
|
+
}
|
|
3439
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
3440
|
+
event.preventDefault();
|
|
3441
|
+
const selected = flatOptions[focusedIndex];
|
|
3442
|
+
if (selected && !selected.disabled) {
|
|
3443
|
+
setInputValue(selected.value);
|
|
3444
|
+
setInputLabel(selected.label);
|
|
3445
|
+
setInternalSelectedOption(selected);
|
|
3446
|
+
reactDom.flushSync(() => {
|
|
3447
|
+
onChange(selected);
|
|
3448
|
+
});
|
|
3449
|
+
setShowSelectComponent(false);
|
|
3450
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
3453
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
3454
|
+
};
|
|
3413
3455
|
return jsxRuntime.jsxs(SectionContainer, Object.assign({
|
|
3414
3456
|
"$variant": variant,
|
|
3415
3457
|
id: `${id}-container`,
|
|
@@ -3451,7 +3493,7 @@ const Dropdown = /*#__PURE__*/react.forwardRef((_a, ref) => {
|
|
|
3451
3493
|
onBlur: onBlur,
|
|
3452
3494
|
onFocus: onFocus,
|
|
3453
3495
|
onKeyUp: onKeyUp,
|
|
3454
|
-
onKeyDown: onKeyDown,
|
|
3496
|
+
onKeyDown: onKeyDown ? onKeyDown : handleKeyDown,
|
|
3455
3497
|
disableSearch: disableSearch
|
|
3456
3498
|
}, props)), showSelectComponent && !disabled && jsxRuntime.jsx(atomsSelect.Select, Object.assign({
|
|
3457
3499
|
id: `${id}-select`,
|
|
@@ -3462,6 +3504,8 @@ const Dropdown = /*#__PURE__*/react.forwardRef((_a, ref) => {
|
|
|
3462
3504
|
setInputValue(selectedValue.value);
|
|
3463
3505
|
setInputLabel(selectedValue.label);
|
|
3464
3506
|
setInternalSelectedOption(Object.assign({}, selectedValue));
|
|
3507
|
+
const selectedIndex = flatOptions.findIndex(flatOption => flatOption.id === selectedValue.id);
|
|
3508
|
+
setFocusedIndex(selectedIndex);
|
|
3465
3509
|
reactDom.flushSync(() => {
|
|
3466
3510
|
onChange(selectedValue);
|
|
3467
3511
|
});
|
|
@@ -3469,7 +3513,7 @@ const Dropdown = /*#__PURE__*/react.forwardRef((_a, ref) => {
|
|
|
3469
3513
|
}
|
|
3470
3514
|
},
|
|
3471
3515
|
ref: selectRef,
|
|
3472
|
-
active:
|
|
3516
|
+
active: flatOptions[focusedIndex],
|
|
3473
3517
|
options: currentOptionList
|
|
3474
3518
|
}, uiUtils.applyDataAttributes(props, 'select')))]
|
|
3475
3519
|
}));
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolttech/molecules-dropdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"react": "19.1.
|
|
6
|
-
"@bolttech/atoms-select": "0.
|
|
7
|
-
"react-dom": "19.1.
|
|
8
|
-
"@bolttech/ui-utils": "0.6.
|
|
5
|
+
"react": "19.1.2",
|
|
6
|
+
"@bolttech/atoms-select": "0.27.1",
|
|
7
|
+
"react-dom": "19.1.2",
|
|
8
|
+
"@bolttech/ui-utils": "0.6.4",
|
|
9
9
|
"styled-components": "6.1.1",
|
|
10
|
-
"@bolttech/atoms-icon": "0.24.
|
|
11
|
-
"@bolttech/atoms-input": "0.
|
|
12
|
-
"@bolttech/default-theme": "0.
|
|
10
|
+
"@bolttech/atoms-icon": "0.24.7",
|
|
11
|
+
"@bolttech/atoms-input": "0.30.2",
|
|
12
|
+
"@bolttech/default-theme": "0.18.1"
|
|
13
13
|
},
|
|
14
14
|
"main": "./index.cjs.js",
|
|
15
15
|
"type": "commonjs",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OptionWithHeaderType, OptionType } from '@bolttech/atoms-select';
|
|
2
|
-
export declare const DropdownWithHeaders: import("react").ForwardRefExoticComponent<Pick<import("react").DOMAttributes<
|
|
2
|
+
export declare const DropdownWithHeaders: import("react").ForwardRefExoticComponent<Pick<import("react").DOMAttributes<Element>, "onKeyUp" | "onKeyDown"> & import("@bolttech/ui-utils").DefaultProps & {
|
|
3
3
|
label: string;
|
|
4
4
|
placeholder?: string;
|
|
5
5
|
disabled?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OptionType } from '@bolttech/atoms-select';
|
|
2
|
-
export declare const Dropdown: import("react").ForwardRefExoticComponent<Pick<import("react").DOMAttributes<
|
|
2
|
+
export declare const Dropdown: import("react").ForwardRefExoticComponent<Pick<import("react").DOMAttributes<Element>, "onKeyUp" | "onKeyDown"> & import("@bolttech/ui-utils").DefaultProps & {
|
|
3
3
|
label: string;
|
|
4
4
|
placeholder?: string;
|
|
5
5
|
disabled?: boolean;
|
|
@@ -43,7 +43,7 @@ type DefaultDropdownProps = {
|
|
|
43
43
|
@property selectedOption - An optional object representing the currently selected option
|
|
44
44
|
@property asyncOptionList - A boolean prop that controls a different behavior when OptionList are set by an API request
|
|
45
45
|
*/
|
|
46
|
-
export type DropdownProps = Pick<DOMAttributes<
|
|
46
|
+
export type DropdownProps = Pick<DOMAttributes<Element>, 'onKeyUp' | 'onKeyDown'> & DefaultProps & DefaultDropdownProps & {
|
|
47
47
|
optionList?: OptionType[];
|
|
48
48
|
/**
|
|
49
49
|
* An optional function that filters the option list based on input value
|
|
@@ -108,7 +108,7 @@ export type DropdownProps = Pick<DOMAttributes<HTMLInputElement>, 'onKeyUp' | 'o
|
|
|
108
108
|
@property selectedOption - An optional object representing the currently selected option
|
|
109
109
|
@property asyncOptionList - A boolean prop that controls a different behavior when OptionList are set by an API request
|
|
110
110
|
*/
|
|
111
|
-
export type DropdownWithHeadersProps = Pick<DOMAttributes<
|
|
111
|
+
export type DropdownWithHeadersProps = Pick<DOMAttributes<Element>, 'onKeyUp' | 'onKeyDown'> & DefaultProps & DefaultDropdownProps & {
|
|
112
112
|
optionList?: OptionWithHeaderType[];
|
|
113
113
|
/**
|
|
114
114
|
* An optional function that filters the option list based on input value
|
|
@@ -182,7 +182,7 @@ export type DropdownWithHeadersProps = Pick<DOMAttributes<HTMLInputElement>, 'on
|
|
|
182
182
|
@property setSelectedOptionOnInputValue - A function to set the selected option based on the input value
|
|
183
183
|
@property inputRef - A ref to the input element of the dropdown
|
|
184
184
|
*/
|
|
185
|
-
export type ReusableDropdownComponentProps = DefaultProps & Pick<DOMAttributes<
|
|
185
|
+
export type ReusableDropdownComponentProps = DefaultProps & Pick<DOMAttributes<Element>, 'onKeyUp' | 'onKeyDown'> & DefaultDropdownProps & {
|
|
186
186
|
setShowSelectComponent: (show: boolean) => void;
|
|
187
187
|
showSelectComponent: boolean;
|
|
188
188
|
onChangeInputValue: React.Dispatch<React.SetStateAction<string>>;
|