@pixum/combobox 5.10.10 → 5.11.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/lib/ComboBox.d.ts +1 -1
- package/lib/ComboBox.module.css +1 -1
- package/lib/ComboBox.test.d.ts +1 -0
- package/lib/ComboBox.test.js +33 -0
- package/lib/ComboBox.test.js.map +1 -0
- package/lib/partials/ComboBoxNoResults.d.ts +1 -1
- package/lib/partials/ComboBoxOptions.d.ts +1 -1
- package/lib/partials/ComboBoxOptionsGroup.d.ts +1 -1
- package/lib/partials/ComboBoxOptionsItems.d.ts +1 -1
- package/lib/partials/ComboBoxOptionsSlot.d.ts +1 -1
- package/lib/partials/ComboBoxOptionsWithGrouping.d.ts +26 -0
- package/lib/partials/ComboBoxOptionsWithGrouping.js +14 -0
- package/lib/partials/ComboBoxOptionsWithGrouping.js.map +1 -0
- package/lib/styles.css +1 -0
- package/lib/utils/calculateListMaxHeight.d.ts +7 -0
- package/lib/utils/calculateListMaxHeight.js +14 -0
- package/lib/utils/calculateListMaxHeight.js.map +1 -0
- package/lib/utils/scrollOptionToViewport.d.ts +7 -0
- package/lib/utils/scrollOptionToViewport.js +26 -0
- package/lib/utils/scrollOptionToViewport.js.map +1 -0
- package/package.json +2 -2
package/lib/ComboBox.d.ts
CHANGED
|
@@ -33,5 +33,5 @@ import type { ComboBoxProps } from './types';
|
|
|
33
33
|
* @param props - The props for the ComboBox component
|
|
34
34
|
* @returns A responsive, accessible combobox
|
|
35
35
|
*/
|
|
36
|
-
export declare function ComboBox({ className, name, id, helperText, headline, label, options, isOpen, setIsOpen, value, selectedOption, multiple, placeholder, searchPattern, noResultsText, inputMode, leadingType, leadingIcon, optionDetails, optionsSlot, withSearch, openOnEnter, disabled, loading, theme, renderValue, onClick, onChange, onOptionItemClick, onOutsideClick, onSheetClose, }: ComboBoxProps): import("react
|
|
36
|
+
export declare function ComboBox({ className, name, id, helperText, headline, label, options, isOpen, setIsOpen, value, selectedOption, multiple, placeholder, searchPattern, noResultsText, inputMode, leadingType, leadingIcon, optionDetails, optionsSlot, withSearch, openOnEnter, disabled, loading, theme, renderValue, onClick, onChange, onOptionItemClick, onOutsideClick, onSheetClose, }: ComboBoxProps): import("react").JSX.Element;
|
|
37
37
|
export default ComboBox;
|
package/lib/ComboBox.module.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.comboBox{position:relative;width:100%}.comboBox .headline[class*=text--]+*{margin-top:var(--spacing)}:is(.comboBox,.sheet) :is(.panel,.optionsSlot,.header){position:relative;width:100%}:is(.comboBox,.sheet) .panel{display:flex;flex-direction:column;max-height:inherit;overflow:hidden}:is(.sheet) .panel{box-shadow:none}:is(.comboBox,.sheet) :is(.options,.optionsSlot){display:flex;flex:1 1 auto;flex-direction:column;min-height:0;overflow:auto;scroll-padding-block-start:var(--combobox-sticky-offset,2.75rem)}.sheet .header{align-items:flex-start;height:auto;margin:var(--spacing-5) auto var(--spacing-2);padding:0 var(--spacing-2)}:is(.comboBox,.sheet) ul.optionsSlot{list-style:none;padding:0}:is(.comboBox,.sheet) .option{cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none}:is(.comboBox,.sheet) .optionCheckbox[data-selected=true] :global(.menu-item){background-color:initial}:is(.comboBox,.sheet) .option.optionActive
|
|
1
|
+
.comboBox{position:relative;width:100%}.comboBox .headline[class*=text--]+*{margin-top:var(--spacing)}:is(.comboBox,.sheet) :is(.panel,.optionsSlot,.header){position:relative;width:100%}:is(.comboBox,.sheet) .panel{display:flex;flex-direction:column;max-height:inherit;overflow:hidden}:is(.sheet) .panel{box-shadow:none}:is(.comboBox,.sheet) :is(.options,.optionsSlot){display:flex;flex:1 1 auto;flex-direction:column;min-height:0;overflow:auto;scroll-padding-block-start:var(--combobox-sticky-offset,2.75rem)}.sheet .header{align-items:flex-start;height:auto;margin:var(--spacing-5) auto var(--spacing-2);padding:0 var(--spacing-2)}:is(.comboBox,.sheet) ul.optionsSlot{list-style:none;padding:0}:is(.comboBox,.sheet) .option{cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none}:is(.comboBox,.sheet) .optionCheckbox[data-selected=true] :global(.menu-item){background-color:initial}:is(.comboBox,.sheet) :is(.option.optionActive,.optionCheckbox.optionActive) :global(.menu-item){background-color:var(--color-canvas--hover)}:is(.comboBox,.sheet) .option[data-selected=true]:not(.optionCheckbox) :global(.menu-item){background-color:var(--color-accent);color:var(--color-surface)}:is(.comboBox,.sheet) .option[aria-disabled=true]{cursor:not-allowed;opacity:.5}@media (forced-colors:active){:is(.comboBox,.sheet) .option.optionActive :global(.menu-item){outline:2px solid Highlight;outline-offset:-2px}}:is(.comboBox,.sheet) .stickyHeader{background-color:var(--color-surface);border-bottom:1px solid var(--color-dim);padding:var(--spacing-1_25) var(--spacing-2);position:sticky;top:0}:is(.comboBox,.sheet) .options :global(.text--caption){color:var(--color-on-secondary)}:is(.comboBox,.sheet) .option[data-selected=true]:not(.optionCheckbox) :global(.menu-item .text--caption){color:var(--color-surface)}:is(.comboBox,.sheet) .options :global(.item-header){display:flex;justify-content:space-between}:is(.comboBox,.sheet) .optionDetails{background-color:var(--color-surface);border-top:1px solid var(--color-dim);flex:0 0 auto;padding:var(--spacing-1_25) var(--spacing)}:is(.comboBox,.sheet) .noResults{padding:var(--spacing-2) var(--spacing);text-align:center}@media screen and (min-width:960px){.comboBox :is(.panel,.optionsSlot){border-radius:var(--border-radius-3);margin-top:var(--spacing);max-height:330px;position:absolute}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/// <reference types="@testing-library/jest-dom" />
|
|
3
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
4
|
+
import { ComboBox } from './ComboBox';
|
|
5
|
+
// jsdom sets window.innerWidth to 0, so useIsDesktopScreenWidth returns false.
|
|
6
|
+
// When !isDesktop, showSelectField is always true — SelectInput always renders.
|
|
7
|
+
const baseProps = {
|
|
8
|
+
isOpen: false,
|
|
9
|
+
setIsOpen: jest.fn(),
|
|
10
|
+
options: [],
|
|
11
|
+
label: 'Test',
|
|
12
|
+
};
|
|
13
|
+
describe('ComboBox disabled', () => {
|
|
14
|
+
it('does not fire onClick when disabled', () => {
|
|
15
|
+
const onClick = jest.fn();
|
|
16
|
+
const { container } = render(_jsx(ComboBox, Object.assign({}, baseProps, { disabled: true, onClick: onClick })));
|
|
17
|
+
fireEvent.click(container.querySelector('.input-inner-container'));
|
|
18
|
+
expect(onClick).not.toHaveBeenCalled();
|
|
19
|
+
});
|
|
20
|
+
it('passes disabled to the trigger input', () => {
|
|
21
|
+
const { container } = render(_jsx(ComboBox, Object.assign({}, baseProps, { disabled: true, value: "some option" })));
|
|
22
|
+
expect(container.querySelector('input')).toBeDisabled();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('ComboBox enabled', () => {
|
|
26
|
+
it('fires onClick when not disabled', () => {
|
|
27
|
+
const onClick = jest.fn();
|
|
28
|
+
const { container } = render(_jsx(ComboBox, Object.assign({}, baseProps, { onClick: onClick })));
|
|
29
|
+
fireEvent.click(container.querySelector('.input-inner-container'));
|
|
30
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=ComboBox.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComboBox.test.js","sourceRoot":"","sources":["../src/ComboBox.test.tsx"],"names":[],"mappings":";AAAA,mDAAmD;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAGrC,+EAA+E;AAC/E,gFAAgF;AAEhF,MAAM,SAAS,GAAG;IAChB,MAAM,EAAE,KAAK;IACb,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE;IACpB,OAAO,EAAE,EAA+B;IACxC,KAAK,EAAE,MAAM;CACd,CAAA;AAED,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;QACzB,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAC1B,KAAC,QAAQ,oBAAK,SAAS,IAAE,QAAQ,QAAC,OAAO,EAAE,OAAO,IAAI,CACvD,CAAA;QACD,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,wBAAwB,CAAE,CAAC,CAAA;QACnE,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;IACxC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAC1B,KAAC,QAAQ,oBAAK,SAAS,IAAE,QAAQ,QAAC,KAAK,EAAC,aAAa,IAAG,CACzD,CAAA;QACD,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,EAAE,CAAA;IACzD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;QACzB,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAC1B,KAAC,QAAQ,oBAAK,SAAS,IAAE,OAAO,EAAE,OAAO,IAAI,CAC9C,CAAA;QACD,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,wBAAwB,CAAE,CAAC,CAAA;QACnE,MAAM,CAAC,OAAO,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;IAC1C,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -11,4 +11,4 @@ export interface ComboBoxNoResultsProps {
|
|
|
11
11
|
* @param props - The props for the ComboBoxNoResults component
|
|
12
12
|
* @returns The no-results message
|
|
13
13
|
*/
|
|
14
|
-
export declare function ComboBoxNoResults({ text }: ComboBoxNoResultsProps): import("react
|
|
14
|
+
export declare function ComboBoxNoResults({ text }: ComboBoxNoResultsProps): import("react").JSX.Element | null;
|
|
@@ -17,5 +17,5 @@ import type { ComboBoxOptionsPanelProps } from '../types';
|
|
|
17
17
|
* @param props - The props for the ComboBoxOptions component
|
|
18
18
|
* @returns The options panel
|
|
19
19
|
*/
|
|
20
|
-
export declare function ComboBoxOptions({ options, listboxAriaProps, selectedValues, activeOptionId, leadingType, optionDetails, onOptionClick, }: ComboBoxOptionsPanelProps): import("react
|
|
20
|
+
export declare function ComboBoxOptions({ options, listboxAriaProps, selectedValues, activeOptionId, leadingType, optionDetails, onOptionClick, }: ComboBoxOptionsPanelProps): import("react").JSX.Element;
|
|
21
21
|
export default ComboBoxOptions;
|
|
@@ -12,4 +12,4 @@ export interface ComboBoxOptionsGroupProps extends ComboBoxOptionsItemsProps {
|
|
|
12
12
|
* @param props - The props for the ComboBoxOptionsGroup component
|
|
13
13
|
* @returns A group container with an optional header and its options
|
|
14
14
|
*/
|
|
15
|
-
export declare function ComboBoxOptionsGroup({ group, ...itemProps }: ComboBoxOptionsGroupProps): import("react
|
|
15
|
+
export declare function ComboBoxOptionsGroup({ group, ...itemProps }: ComboBoxOptionsGroupProps): import("react").JSX.Element;
|
|
@@ -36,4 +36,4 @@ export interface ComboBoxOptionsItemsProps {
|
|
|
36
36
|
* @param props - The props for the ComboBoxOptionsItems component
|
|
37
37
|
* @returns A list of selectable options
|
|
38
38
|
*/
|
|
39
|
-
export declare function ComboBoxOptionsItems({ options, selectedValues, activeOptionId, leadingType, onOptionClick, }: ComboBoxOptionsItemsProps): import("react
|
|
39
|
+
export declare function ComboBoxOptionsItems({ options, selectedValues, activeOptionId, leadingType, onOptionClick, }: ComboBoxOptionsItemsProps): import("react").JSX.Element;
|
|
@@ -32,4 +32,4 @@ export interface ComboBoxOptionsSlotProps extends HTMLAttributes<HTMLElement> {
|
|
|
32
32
|
* @param props - The props for the ComboBoxOptionsSlot component
|
|
33
33
|
* @returns A styled wrapper matching the ComboBox dropdown look
|
|
34
34
|
*/
|
|
35
|
-
export declare function ComboBoxOptionsSlot({ children, className, tag, ...rest }: ComboBoxOptionsSlotProps): import("react
|
|
35
|
+
export declare function ComboBoxOptionsSlot({ children, className, tag, ...rest }: ComboBoxOptionsSlotProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { LeadingType } from '@pixum/menu-item';
|
|
2
|
+
import type { ComboBoxOptionItemProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the ComboBoxOptionsWithGrouping component
|
|
5
|
+
*/
|
|
6
|
+
interface ComboBoxOptionsWithGroupingProps {
|
|
7
|
+
/** Group name/header text */
|
|
8
|
+
group: string;
|
|
9
|
+
/** Array of option items in this group */
|
|
10
|
+
items: ComboBoxOptionItemProps[];
|
|
11
|
+
/** Currently selected option value */
|
|
12
|
+
selectedOption?: string;
|
|
13
|
+
/** Callback fired when an option is clicked */
|
|
14
|
+
onClick?: (value: string) => void;
|
|
15
|
+
/** Type of leading element to display (icon, avatar, etc.) */
|
|
16
|
+
leadingType?: LeadingType;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* ComboBoxOptionsWithGrouping component that renders a group of options with a header.
|
|
20
|
+
* Used to display categorized/grouped options in the combobox.
|
|
21
|
+
*
|
|
22
|
+
* @param props - The props for the ComboBoxOptionsWithGrouping component
|
|
23
|
+
* @returns A group container with a sticky header and option items
|
|
24
|
+
*/
|
|
25
|
+
export declare function ComboxBoxOptionsWithGrouping({ group, items, selectedOption, onClick, leadingType, }: ComboBoxOptionsWithGroupingProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Text, { TextVariant } from '@pixum/text';
|
|
3
|
+
import { ComboBoxOptionsItems } from './ComboBoxOptionsItems';
|
|
4
|
+
/**
|
|
5
|
+
* ComboBoxOptionsWithGrouping component that renders a group of options with a header.
|
|
6
|
+
* Used to display categorized/grouped options in the combobox.
|
|
7
|
+
*
|
|
8
|
+
* @param props - The props for the ComboBoxOptionsWithGrouping component
|
|
9
|
+
* @returns A group container with a sticky header and option items
|
|
10
|
+
*/
|
|
11
|
+
export function ComboxBoxOptionsWithGrouping({ group, items, selectedOption, onClick, leadingType, }) {
|
|
12
|
+
return (_jsxs("div", { className: "combobox__options-group", children: [group && (_jsx(Text, { variant: TextVariant.HEADLINE, className: "combobox__sticky-header", children: group })), _jsx(ComboBoxOptionsItems, { items: items, selectedOption: selectedOption, onClick: onClick, leadingType: leadingType })] }, `combobox__options-group-${group}`));
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=ComboBoxOptionsWithGrouping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComboBoxOptionsWithGrouping.js","sourceRoot":"","sources":["../../src/partials/ComboBoxOptionsWithGrouping.tsx"],"names":[],"mappings":";AACA,OAAO,IAAI,EAAE,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAkB7D;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B,CAAC,EAC3C,KAAK,EACL,KAAK,EACL,cAAc,EACd,OAAO,EACP,WAAW,GACsB;IACjC,OAAO,CACL,eACE,SAAS,EAAC,yBAAyB,aAGlC,KAAK,IAAI,CACR,KAAC,IAAI,IACH,OAAO,EAAE,WAAW,CAAC,QAAQ,EAC7B,SAAS,EAAC,yBAAyB,YAElC,KAAK,GACD,CACR,EACD,KAAC,oBAAoB,IACnB,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,GACxB,KAfG,2BAA2B,KAAK,EAAE,CAgBnC,CACP,CAAA;AACH,CAAC"}
|
package/lib/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.combobox{position:relative;width:100%}.combobox .combobox--headline[class*=text--]+*{margin-top:var(--spacing)}.combobox .combobox--header,.combobox .combobox__options,.combobox .combobox__options-slot,.combobox__bottom-sheet .combobox__options,.combobox__bottom-sheet .combobox__options-slot{position:relative}.combobox__bottom-sheet .combobox--header{align-items:flex-start;height:auto;margin:var(--spacing-5) auto var(--spacing-2);padding:0 var(--spacing-2);width:100%}.combobox .combobox__options,.combobox .combobox__options-slot,.combobox__bottom-sheet .combobox__options,.combobox__bottom-sheet .combobox__options-slot{display:flex;flex-direction:column;max-height:none;overflow:scroll;width:100%}.combobox__bottom-sheet ul.combobox__options-slot{margin:0;padding:0}.combobox .combobox__option-wrapper,.combobox__bottom-sheet .combobox__option-wrapper{touch-action:manipulation;-webkit-tap-highlight-color:transparent;cursor:pointer;-webkit-user-select:none;user-select:none}.combobox .combobox__options .combobox__sticky-header,.combobox__bottom-sheet .combobox__options .combobox__sticky-header{background-color:var(--color-surface);border-bottom:1px solid var(--color-dim);padding:var(--spacing-1_25) var(--spacing-2);position:-webkit-sticky;position:sticky;top:0}.combobox__options .text--caption{color:var(--color-on-secondary)}.combobox .combobox__options .item-header,.combobox__bottom-sheet .combobox__options .item-header{display:flex;justify-content:space-between}.combobox .combobox__options .combobox__option-details,.combobox__bottom-sheet .combobox__options .combobox__option-details{background-color:var(--color-surface);bottom:0;padding-left:var(--spacing);padding-right:var(--spacing);position:-webkit-sticky;position:sticky}.combobox .combobox--no-results-text,.combobox__bottom-sheet .combobox--no-results-text{padding:var(--spacing-2) var(--spacing);text-align:center}@media screen and (min-width:960px){.combobox .combobox__options,.combobox .combobox__options-slot{border-radius:12px;margin-top:var(--spacing);max-height:330px;overflow:auto;position:absolute}}.combobox ul.combobox__options-slot{list-style:none;padding:0}.combobox .combobox__options-slot{margin-top:var(--spacing)}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the maximum height for the options list based on viewport height.
|
|
3
|
+
* Subtracts the header and input field heights from the window height.
|
|
4
|
+
*
|
|
5
|
+
* @returns The maximum height in pixels for the options list
|
|
6
|
+
*/
|
|
7
|
+
export declare function calculateListMaxHeight(): number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the maximum height for the options list based on viewport height.
|
|
3
|
+
* Subtracts the header and input field heights from the window height.
|
|
4
|
+
*
|
|
5
|
+
* @returns The maximum height in pixels for the options list
|
|
6
|
+
*/
|
|
7
|
+
export function calculateListMaxHeight() {
|
|
8
|
+
const windowHeight = window.innerHeight;
|
|
9
|
+
const headerHeight = 50;
|
|
10
|
+
const inputFieldHeight = 35;
|
|
11
|
+
const maxListHeight = windowHeight - headerHeight - inputFieldHeight;
|
|
12
|
+
return maxListHeight;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=calculateListMaxHeight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculateListMaxHeight.js","sourceRoot":"","sources":["../../src/utils/calculateListMaxHeight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB;IAClC,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAA;IACvC,MAAM,YAAY,GAAG,EAAE,CAAA;IACvB,MAAM,gBAAgB,GAAG,EAAE,CAAA;IAC3B,MAAM,aAAa,GAAG,YAAY,GAAG,YAAY,GAAG,gBAAgB,CAAA;IAErE,OAAO,aAAa,CAAA;AACvB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scrolls the selected option into view within the options container.
|
|
3
|
+
* Handles both desktop dropdown and mobile bottom sheet layouts.
|
|
4
|
+
*
|
|
5
|
+
* @param isDesktop - Whether the viewport is desktop size
|
|
6
|
+
*/
|
|
7
|
+
export declare function scrollOptionToViewport(isDesktop: boolean): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scrolls the selected option into view within the options container.
|
|
3
|
+
* Handles both desktop dropdown and mobile bottom sheet layouts.
|
|
4
|
+
*
|
|
5
|
+
* @param isDesktop - Whether the viewport is desktop size
|
|
6
|
+
*/
|
|
7
|
+
export function scrollOptionToViewport(isDesktop) {
|
|
8
|
+
const comboboxOptions = isDesktop
|
|
9
|
+
? document.querySelector('.menu')
|
|
10
|
+
: document.querySelector('.menu.combobox__options');
|
|
11
|
+
const selectedItem = comboboxOptions.querySelector('.menu-item.selected');
|
|
12
|
+
if (selectedItem && comboboxOptions) {
|
|
13
|
+
let comboboxOptionWrapper = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.parentElement;
|
|
14
|
+
let comboboxOptionsGroup = comboboxOptionWrapper === null || comboboxOptionWrapper === void 0 ? void 0 : comboboxOptionWrapper.parentElement;
|
|
15
|
+
if (comboboxOptionsGroup) {
|
|
16
|
+
const stickyHeader = comboboxOptionsGroup === null || comboboxOptionsGroup === void 0 ? void 0 : comboboxOptionsGroup.querySelector('.combobox__sticky-header');
|
|
17
|
+
const stickyHeaderOffset = stickyHeader === null || stickyHeader === void 0 ? void 0 : stickyHeader.offsetTop;
|
|
18
|
+
comboboxOptions === null || comboboxOptions === void 0 ? void 0 : comboboxOptions.scrollTo({ top: stickyHeaderOffset, behavior: 'smooth' });
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const selectedItemOffset = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.offsetTop;
|
|
22
|
+
comboboxOptions === null || comboboxOptions === void 0 ? void 0 : comboboxOptions.scrollTo({ top: selectedItemOffset, behavior: 'smooth' });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=scrollOptionToViewport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollOptionToViewport.js","sourceRoot":"","sources":["../../src/utils/scrollOptionToViewport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,SAAkB;IACvD,MAAM,eAAe,GAAG,SAAS;QAC/B,CAAC,CAAE,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAiB;QAClD,CAAC,CAAE,QAAQ,CAAC,aAAa,CAAC,yBAAyB,CAAiB,CAAA;IAEtE,MAAM,YAAY,GAAG,eAAe,CAAC,aAAa,CAChD,qBAAqB,CACP,CAAA;IAEhB,IAAI,YAAY,IAAI,eAAe,EAAE,CAAC;QACpC,IAAI,qBAAqB,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,aAAa,CAAA;QACvD,IAAI,oBAAoB,GAAG,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,aAAa,CAAA;QAE/D,IAAI,oBAAoB,EAAE,CAAC;YACzB,MAAM,YAAY,GAAG,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAE,aAAa,CACtD,0BAA0B,CACZ,CAAA;YAEhB,MAAM,kBAAkB,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,SAAS,CAAA;YAElD,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,QAAQ,CAAC,EAAE,GAAG,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAA;QAC5E,CAAC;aAAM,CAAC;YACN,MAAM,kBAAkB,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,SAAS,CAAA;YAElD,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,QAAQ,CAAC,EAAE,GAAG,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAA;QAC5E,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixum/combobox",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.0",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
"sideEffects": [
|
|
19
19
|
"*.css"
|
|
20
20
|
],
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "5347608feb1ed7d5d2a3ad61408f605615050f08"
|
|
22
22
|
}
|