@pixum/combobox 1.6.0 → 1.6.4

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 CHANGED
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import { ComboBoxProps } from './types';
3
- import './styles.css';
4
- declare const ComboBox: React.FC<ComboBoxProps>;
5
- export default ComboBox;
1
+ import React from 'react';
2
+ import { ComboBoxProps } from './types';
3
+ import './styles.css';
4
+ declare const ComboBox: React.FC<ComboBoxProps>;
5
+ export default ComboBox;
package/lib/ComboBox.js CHANGED
@@ -1,106 +1,106 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- var react_1 = __importStar(require("react"));
30
- var bottom_sheet_1 = __importDefault(require("@pixum/bottom-sheet"));
31
- var text_1 = __importStar(require("@pixum/text"));
32
- var user_input_1 = require("@pixum/user-input");
33
- var ComboboxOptions_1 = __importDefault(require("./ComboboxOptions"));
34
- var useIsDesktopScreenWidth_1 = __importDefault(require("./helper/useIsDesktopScreenWidth"));
35
- require("./styles.css");
36
- var clsx_1 = __importDefault(require("clsx"));
37
- var ComboBox = function (_a) {
38
- var _b = _a.className, className = _b === void 0 ? '' : _b, headline = _a.headline, label = _a.label, onClick = _a.onClick, onChange = _a.onChange, onOutsideClick = _a.onOutsideClick, onOptionItemClick = _a.onOptionItemClick, onSheetClose = _a.onSheetClose, _c = _a.searchPattern, searchPattern = _c === void 0 ? '' : _c, id = _a.id, isOpen = _a.isOpen, setIsOpen = _a.setIsOpen, options = _a.options, placeholder = _a.placeholder, value = _a.value, inputMode = _a.inputMode, noResultsText = _a.noResultsText, leadingType = _a.leadingType, optionDetails = _a.optionDetails, _d = _a.withSearch, withSearch = _d === void 0 ? true : _d;
39
- var comboBoxRef = (0, react_1.useRef)(null);
40
- var bottomSheetRef = (0, react_1.useRef)(null);
41
- var _e = (0, react_1.useState)(''), searchQuery = _e[0], setSearchQuery = _e[1];
42
- var _f = (0, react_1.useState)(placeholder), inputPlaceholder = _f[0], setPlaceholder = _f[1];
43
- var isDesktop = (0, useIsDesktopScreenWidth_1.default)();
44
- var optionsExist = Object.keys(options).length > 0;
45
- var showSelectField = !withSearch || (isDesktop && !isOpen) || !isDesktop;
46
- (0, react_1.useEffect)(function () {
47
- !isOpen && (onSheetClose === null || onSheetClose === void 0 ? void 0 : onSheetClose());
48
- }, [isOpen]);
49
- var handleChange = function (e) {
50
- var searchValue = e.target.value;
51
- setSearchQuery(searchValue);
52
- onChange === null || onChange === void 0 ? void 0 : onChange(searchValue);
53
- };
54
- var handleClearInput = function () {
55
- setSearchQuery('');
56
- };
57
- var clearAndClose = function () {
58
- setSearchQuery('');
59
- setIsOpen(false);
60
- };
61
- var handleClickOutside = (0, react_1.useCallback)(function (event) {
62
- var _a;
63
- var node = event === null || event === void 0 ? void 0 : event.target;
64
- var isOutside = !((_a = comboBoxRef.current) === null || _a === void 0 ? void 0 : _a.contains(node));
65
- setPlaceholder(placeholder);
66
- isOutside && isDesktop && clearAndClose();
67
- isOutside && isDesktop && (onOutsideClick === null || onOutsideClick === void 0 ? void 0 : onOutsideClick());
68
- }, [comboBoxRef, bottomSheetRef, placeholder]);
69
- var handleOptionItemClick = function (optionValue) {
70
- onOptionItemClick === null || onOptionItemClick === void 0 ? void 0 : onOptionItemClick(optionValue);
71
- };
72
- var handleOnArrowClick = function () {
73
- clearAndClose();
74
- };
75
- var handleOnClick = function () {
76
- onClick === null || onClick === void 0 ? void 0 : onClick();
77
- };
78
- var NoResultsTextComponent = function () {
79
- return (react_1.default.createElement(text_1.default, { variant: text_1.TextVariant.SUBHEADLINE, className: "combobox--no-results-text" }, noResultsText));
80
- };
81
- var removePlaceholder = function () {
82
- setPlaceholder('');
83
- };
84
- var handleKeyDown = function (e) {
85
- var _a;
86
- if (e.key === 'Tab') {
87
- e.preventDefault();
88
- (_a = document.querySelector('.combobox__options .menu-item')) === null || _a === void 0 ? void 0 : _a.focus();
89
- }
90
- };
91
- return (react_1.default.createElement(react_1.default.Fragment, null,
92
- showSelectField && (react_1.default.createElement(user_input_1.SelectInput, { className: (0, clsx_1.default)(isOpen && 'active', className), label: label, value: value, onClick: handleOnClick, onOutsideClick: handleClickOutside, isCompact: true, id: id, readOnly: true })),
93
- isDesktop && isOpen && (react_1.default.createElement("div", { className: "combobox", ref: comboBoxRef },
94
- withSearch && (react_1.default.createElement(user_input_1.SmallSearchInput, { value: searchQuery, pattern: searchPattern, label: label, onChange: handleChange, onClear: handleClearInput, onKeyDown: handleKeyDown, onArrowClick: handleOnArrowClick, onOutsideClick: handleClickOutside, show: isOpen, inputMode: inputMode, autoFocus: true, isCompact: true })),
95
- optionsExist ? (react_1.default.createElement(ComboboxOptions_1.default, { options: options, onClick: handleOptionItemClick, selectedOption: value, leadingType: leadingType, optionDetails: optionDetails })) : (react_1.default.createElement(NoResultsTextComponent, null)),
96
- react_1.default.createElement("div", null))),
97
- !isDesktop && isOpen && (react_1.default.createElement(bottom_sheet_1.default, { open: isOpen, onClose: function () {
98
- setIsOpen(false);
99
- }, ref: bottomSheetRef },
100
- react_1.default.createElement("div", { className: "combobox--header" },
101
- react_1.default.createElement(text_1.default, { variant: text_1.TextVariant.HEADLINE, className: "combobox--headline" }, headline),
102
- withSearch && (react_1.default.createElement(user_input_1.SmallSearchInput, { value: searchQuery, pattern: searchPattern, onChange: handleChange, onClear: handleClearInput, onFocus: removePlaceholder, placeholder: inputPlaceholder, inputMode: inputMode, show: isOpen, isCompact: true }))),
103
- react_1.default.createElement("div", { className: "combobox__options scrollable" }, optionsExist ? (react_1.default.createElement(ComboboxOptions_1.default, { options: options, onClick: handleOptionItemClick, selectedOption: value, leadingType: leadingType, optionDetails: optionDetails })) : (react_1.default.createElement(NoResultsTextComponent, null)))))));
104
- };
105
- exports.default = ComboBox;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ var react_1 = __importStar(require("react"));
30
+ var bottom_sheet_1 = __importDefault(require("@pixum/bottom-sheet"));
31
+ var text_1 = __importStar(require("@pixum/text"));
32
+ var user_input_1 = require("@pixum/user-input");
33
+ var ComboboxOptions_1 = __importDefault(require("./ComboboxOptions"));
34
+ var useIsDesktopScreenWidth_1 = __importDefault(require("./helper/useIsDesktopScreenWidth"));
35
+ require("./styles.css");
36
+ var clsx_1 = __importDefault(require("clsx"));
37
+ var ComboBox = function (_a) {
38
+ var _b = _a.className, className = _b === void 0 ? '' : _b, headline = _a.headline, label = _a.label, onClick = _a.onClick, onChange = _a.onChange, onOutsideClick = _a.onOutsideClick, onOptionItemClick = _a.onOptionItemClick, onSheetClose = _a.onSheetClose, _c = _a.searchPattern, searchPattern = _c === void 0 ? '' : _c, id = _a.id, isOpen = _a.isOpen, setIsOpen = _a.setIsOpen, options = _a.options, placeholder = _a.placeholder, value = _a.value, inputMode = _a.inputMode, noResultsText = _a.noResultsText, leadingType = _a.leadingType, optionDetails = _a.optionDetails, _d = _a.withSearch, withSearch = _d === void 0 ? true : _d;
39
+ var comboBoxRef = (0, react_1.useRef)(null);
40
+ var bottomSheetRef = (0, react_1.useRef)(null);
41
+ var _e = (0, react_1.useState)(''), searchQuery = _e[0], setSearchQuery = _e[1];
42
+ var _f = (0, react_1.useState)(placeholder), inputPlaceholder = _f[0], setPlaceholder = _f[1];
43
+ var isDesktop = (0, useIsDesktopScreenWidth_1.default)();
44
+ var optionsExist = Object.keys(options).length > 0;
45
+ var showSelectField = !withSearch || (isDesktop && !isOpen) || !isDesktop;
46
+ (0, react_1.useEffect)(function () {
47
+ !isOpen && (onSheetClose === null || onSheetClose === void 0 ? void 0 : onSheetClose());
48
+ }, [isOpen]);
49
+ var handleChange = function (e) {
50
+ var searchValue = e.target.value;
51
+ setSearchQuery(searchValue);
52
+ onChange === null || onChange === void 0 ? void 0 : onChange(searchValue);
53
+ };
54
+ var handleClearInput = function () {
55
+ setSearchQuery('');
56
+ };
57
+ var clearAndClose = function () {
58
+ setSearchQuery('');
59
+ setIsOpen(false);
60
+ };
61
+ var handleClickOutside = (0, react_1.useCallback)(function (event) {
62
+ var _a;
63
+ var node = event === null || event === void 0 ? void 0 : event.target;
64
+ var isOutside = !((_a = comboBoxRef.current) === null || _a === void 0 ? void 0 : _a.contains(node));
65
+ setPlaceholder(placeholder);
66
+ isOutside && isDesktop && clearAndClose();
67
+ isOutside && isDesktop && (onOutsideClick === null || onOutsideClick === void 0 ? void 0 : onOutsideClick());
68
+ }, [comboBoxRef, bottomSheetRef, placeholder]);
69
+ var handleOptionItemClick = function (optionValue) {
70
+ onOptionItemClick === null || onOptionItemClick === void 0 ? void 0 : onOptionItemClick(optionValue);
71
+ };
72
+ var handleOnArrowClick = function () {
73
+ clearAndClose();
74
+ };
75
+ var handleOnClick = function () {
76
+ onClick === null || onClick === void 0 ? void 0 : onClick();
77
+ };
78
+ var NoResultsTextComponent = function () {
79
+ return (react_1.default.createElement(text_1.default, { variant: text_1.TextVariant.SUBHEADLINE, className: "combobox--no-results-text" }, noResultsText));
80
+ };
81
+ var removePlaceholder = function () {
82
+ setPlaceholder('');
83
+ };
84
+ var handleKeyDown = function (e) {
85
+ var _a;
86
+ if (e.key === 'Tab') {
87
+ e.preventDefault();
88
+ (_a = document.querySelector('.combobox__options .menu-item')) === null || _a === void 0 ? void 0 : _a.focus();
89
+ }
90
+ };
91
+ return (react_1.default.createElement(react_1.default.Fragment, null,
92
+ showSelectField && (react_1.default.createElement(user_input_1.SelectInput, { className: (0, clsx_1.default)(isOpen && 'active', className), label: label, value: value, onClick: handleOnClick, onOutsideClick: handleClickOutside, isCompact: true, id: id, readOnly: true })),
93
+ isDesktop && isOpen && (react_1.default.createElement("div", { className: "combobox", ref: comboBoxRef },
94
+ withSearch && (react_1.default.createElement(user_input_1.SmallSearchInput, { value: searchQuery, pattern: searchPattern, label: label, onChange: handleChange, onClear: handleClearInput, onKeyDown: handleKeyDown, onArrowClick: handleOnArrowClick, onOutsideClick: handleClickOutside, show: isOpen, inputMode: inputMode, autoFocus: true, isCompact: true })),
95
+ optionsExist ? (react_1.default.createElement(ComboboxOptions_1.default, { options: options, onClick: handleOptionItemClick, selectedOption: value, leadingType: leadingType, optionDetails: optionDetails })) : (react_1.default.createElement(NoResultsTextComponent, null)),
96
+ react_1.default.createElement("div", null))),
97
+ !isDesktop && isOpen && (react_1.default.createElement(bottom_sheet_1.default, { open: isOpen, onClose: function () {
98
+ setIsOpen(false);
99
+ }, ref: bottomSheetRef },
100
+ react_1.default.createElement("div", { className: "combobox--header" },
101
+ react_1.default.createElement(text_1.default, { variant: text_1.TextVariant.HEADLINE, className: "combobox--headline" }, headline),
102
+ withSearch && (react_1.default.createElement(user_input_1.SmallSearchInput, { value: searchQuery, pattern: searchPattern, onChange: handleChange, onClear: handleClearInput, onFocus: removePlaceholder, placeholder: inputPlaceholder, inputMode: inputMode, show: isOpen, isCompact: true }))),
103
+ react_1.default.createElement("div", { className: "combobox__options scrollable" }, optionsExist ? (react_1.default.createElement(ComboboxOptions_1.default, { options: options, onClick: handleOptionItemClick, selectedOption: value, leadingType: leadingType, optionDetails: optionDetails })) : (react_1.default.createElement(NoResultsTextComponent, null)))))));
104
+ };
105
+ exports.default = ComboBox;
106
106
  //# sourceMappingURL=ComboBox.js.map
@@ -1,12 +1,12 @@
1
- import { LeadingType } from '@pixum/menu-item';
2
- import React from 'react';
3
- import { ComboBoxOptionProps } from '../types';
4
- interface OptionsProps {
5
- items: ComboBoxOptionProps[];
6
- selectedOption?: string;
7
- onClick?: (value: string) => void;
8
- onKeyDown: (e: React.KeyboardEvent, value: string) => void;
9
- leadingType?: LeadingType;
10
- }
11
- declare const Options: React.FC<OptionsProps>;
12
- export default Options;
1
+ import { LeadingType } from '@pixum/menu-item';
2
+ import React from 'react';
3
+ import { ComboBoxOptionProps } from '../types';
4
+ interface OptionsProps {
5
+ items: ComboBoxOptionProps[];
6
+ selectedOption?: string;
7
+ onClick?: (value: string) => void;
8
+ onKeyDown: (e: React.KeyboardEvent, value: string) => void;
9
+ leadingType?: LeadingType;
10
+ }
11
+ declare const Options: React.FC<OptionsProps>;
12
+ export default Options;
@@ -1,24 +1,24 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var menu_item_1 = __importDefault(require("@pixum/menu-item"));
7
- var clsx_1 = __importDefault(require("clsx"));
8
- var react_1 = __importDefault(require("react"));
9
- var Options = function (_a) {
10
- var items = _a.items, selectedOption = _a.selectedOption, onClick = _a.onClick, onKeyDown = _a.onKeyDown, leadingType = _a.leadingType;
11
- return (react_1.default.createElement(react_1.default.Fragment, null, items.map(function (item, index) {
12
- var _a;
13
- return (react_1.default.createElement(menu_item_1.default, { key: "combobox-item-".concat(item.text), tabIndex: index, className: (0, clsx_1.default)(selectedOption === item.text && 'selected'), onClick: function () { return onClick === null || onClick === void 0 ? void 0 : onClick(item.text); }, onKeyDown: function (e) { return onKeyDown(e, item.text); }, onMouseEnter: item.onMouseEnter, leadingProps: leadingType
14
- ? {
15
- name: item.text,
16
- type: leadingType,
17
- }
18
- : undefined, selected: selectedOption === item.text, text: item.text, subtext: item.subtext, subItemProps: {
19
- text: (_a = item.subItemProps) === null || _a === void 0 ? void 0 : _a.text,
20
- } }));
21
- })));
22
- };
23
- exports.default = Options;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var menu_item_1 = __importDefault(require("@pixum/menu-item"));
7
+ var clsx_1 = __importDefault(require("clsx"));
8
+ var react_1 = __importDefault(require("react"));
9
+ var Options = function (_a) {
10
+ var items = _a.items, selectedOption = _a.selectedOption, onClick = _a.onClick, onKeyDown = _a.onKeyDown, leadingType = _a.leadingType;
11
+ return (react_1.default.createElement(react_1.default.Fragment, null, items.map(function (item, index) {
12
+ var _a;
13
+ return (react_1.default.createElement(menu_item_1.default, { key: "combobox-item-".concat(item.text), tabIndex: index, className: (0, clsx_1.default)(selectedOption === item.text && 'selected'), onClick: function () { return onClick === null || onClick === void 0 ? void 0 : onClick(item.text); }, onKeyDown: function (e) { return onKeyDown(e, item.text); }, onMouseEnter: item.onMouseEnter, leadingProps: leadingType
14
+ ? {
15
+ name: item.text,
16
+ type: leadingType,
17
+ }
18
+ : undefined, selected: selectedOption === item.text, text: item.text, subtext: item.subtext, subItemProps: {
19
+ text: (_a = item.subItemProps) === null || _a === void 0 ? void 0 : _a.text,
20
+ } }));
21
+ })));
22
+ };
23
+ exports.default = Options;
24
24
  //# sourceMappingURL=Options.js.map
@@ -1,13 +1,13 @@
1
- import { LeadingType } from '@pixum/menu-item';
2
- import React from 'react';
3
- import { ComboBoxOptionProps } from '../types';
4
- interface OptionsGroupProps {
5
- group: string;
6
- items: ComboBoxOptionProps[];
7
- selectedOption?: string;
8
- onClick?: (value: string) => void;
9
- onKeyDown: (e: React.KeyboardEvent, value: string) => void;
10
- leadingType?: LeadingType;
11
- }
12
- declare const OptionsGroup: React.FC<OptionsGroupProps>;
13
- export default OptionsGroup;
1
+ import { LeadingType } from '@pixum/menu-item';
2
+ import React from 'react';
3
+ import { ComboBoxOptionProps } from '../types';
4
+ interface OptionsGroupProps {
5
+ group: string;
6
+ items: ComboBoxOptionProps[];
7
+ selectedOption?: string;
8
+ onClick?: (value: string) => void;
9
+ onKeyDown: (e: React.KeyboardEvent, value: string) => void;
10
+ leadingType?: LeadingType;
11
+ }
12
+ declare const OptionsGroup: React.FC<OptionsGroupProps>;
13
+ export default OptionsGroup;
@@ -1,39 +1,39 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- var text_1 = __importStar(require("@pixum/text"));
30
- var react_1 = __importDefault(require("react"));
31
- var Options_1 = __importDefault(require("./Options"));
32
- var OptionsGroup = function (_a) {
33
- var group = _a.group, items = _a.items, selectedOption = _a.selectedOption, onClick = _a.onClick, onKeyDown = _a.onKeyDown, leadingType = _a.leadingType;
34
- return (react_1.default.createElement("div", { className: "combobox__options-group", key: "combobox__options-group-".concat(group) },
35
- react_1.default.createElement(text_1.default, { variant: text_1.TextVariant.HEADLINE, className: "combobox__sticky-header" }, group),
36
- react_1.default.createElement(Options_1.default, { items: items, selectedOption: selectedOption, onClick: onClick, onKeyDown: onKeyDown, leadingType: leadingType })));
37
- };
38
- exports.default = OptionsGroup;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ var text_1 = __importStar(require("@pixum/text"));
30
+ var react_1 = __importDefault(require("react"));
31
+ var Options_1 = __importDefault(require("./Options"));
32
+ var OptionsGroup = function (_a) {
33
+ var group = _a.group, items = _a.items, selectedOption = _a.selectedOption, onClick = _a.onClick, onKeyDown = _a.onKeyDown, leadingType = _a.leadingType;
34
+ return (react_1.default.createElement("div", { className: "combobox__options-group", key: "combobox__options-group-".concat(group) },
35
+ react_1.default.createElement(text_1.default, { variant: text_1.TextVariant.HEADLINE, className: "combobox__sticky-header" }, group),
36
+ react_1.default.createElement(Options_1.default, { items: items, selectedOption: selectedOption, onClick: onClick, onKeyDown: onKeyDown, leadingType: leadingType })));
37
+ };
38
+ exports.default = OptionsGroup;
39
39
  //# sourceMappingURL=OptionsGroup.js.map
@@ -1,4 +1,4 @@
1
- import React from 'react';
2
- import { ComboBoxOptionsProps } from '../types';
3
- declare const ComboBoxOptions: React.FC<ComboBoxOptionsProps>;
4
- export default ComboBoxOptions;
1
+ import React from 'react';
2
+ import { ComboBoxOptionsProps } from '../types';
3
+ declare const ComboBoxOptions: React.FC<ComboBoxOptionsProps>;
4
+ export default ComboBoxOptions;
@@ -1,54 +1,54 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- var react_1 = __importStar(require("react"));
30
- var menu_1 = __importDefault(require("@pixum/menu"));
31
- var scrollOptionToViewport_1 = require("../helper/scrollOptionToViewport");
32
- var OptionsGroup_1 = __importDefault(require("./OptionsGroup"));
33
- var Options_1 = __importDefault(require("./Options"));
34
- var useIsDesktopScreenWidth_1 = __importDefault(require("../helper/useIsDesktopScreenWidth"));
35
- var ComboBoxOptions = function (_a) {
36
- var options = _a.options, onClick = _a.onClick, selectedOption = _a.selectedOption, leadingType = _a.leadingType, optionDetails = _a.optionDetails;
37
- var isDesktop = (0, useIsDesktopScreenWidth_1.default)();
38
- var handleOnKeyDown = function (e, value) {
39
- if (e.key === 'Enter') {
40
- onClick === null || onClick === void 0 ? void 0 : onClick(value);
41
- }
42
- };
43
- (0, react_1.useEffect)(function () {
44
- (0, scrollOptionToViewport_1.scrollOptionToViewport)(isDesktop);
45
- }, [isDesktop]);
46
- return (react_1.default.createElement(menu_1.default, { className: "combobox__options" },
47
- Array.isArray(options) ? (react_1.default.createElement(Options_1.default, { items: options, selectedOption: selectedOption, onClick: onClick, onKeyDown: handleOnKeyDown, leadingType: leadingType })) : (react_1.default.createElement(react_1.default.Fragment, null, Object.entries(options).map(function (_a) {
48
- var group = _a[0], items = _a[1];
49
- return (react_1.default.createElement(OptionsGroup_1.default, { group: group, items: items, selectedOption: selectedOption, onClick: onClick, onKeyDown: handleOnKeyDown, leadingType: leadingType }));
50
- }))),
51
- optionDetails && (react_1.default.createElement("div", { className: "combobox__option-details text--caption" }, optionDetails))));
52
- };
53
- exports.default = ComboBoxOptions;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ var react_1 = __importStar(require("react"));
30
+ var menu_1 = __importDefault(require("@pixum/menu"));
31
+ var scrollOptionToViewport_1 = require("../helper/scrollOptionToViewport");
32
+ var OptionsGroup_1 = __importDefault(require("./OptionsGroup"));
33
+ var Options_1 = __importDefault(require("./Options"));
34
+ var useIsDesktopScreenWidth_1 = __importDefault(require("../helper/useIsDesktopScreenWidth"));
35
+ var ComboBoxOptions = function (_a) {
36
+ var options = _a.options, onClick = _a.onClick, selectedOption = _a.selectedOption, leadingType = _a.leadingType, optionDetails = _a.optionDetails;
37
+ var isDesktop = (0, useIsDesktopScreenWidth_1.default)();
38
+ var handleOnKeyDown = function (e, value) {
39
+ if (e.key === 'Enter') {
40
+ onClick === null || onClick === void 0 ? void 0 : onClick(value);
41
+ }
42
+ };
43
+ (0, react_1.useEffect)(function () {
44
+ (0, scrollOptionToViewport_1.scrollOptionToViewport)(isDesktop);
45
+ }, [isDesktop]);
46
+ return (react_1.default.createElement(menu_1.default, { className: "combobox__options" },
47
+ Array.isArray(options) ? (react_1.default.createElement(Options_1.default, { items: options, selectedOption: selectedOption, onClick: onClick, onKeyDown: handleOnKeyDown, leadingType: leadingType })) : (react_1.default.createElement(react_1.default.Fragment, null, Object.entries(options).map(function (_a) {
48
+ var group = _a[0], items = _a[1];
49
+ return (react_1.default.createElement(OptionsGroup_1.default, { group: group, items: items, selectedOption: selectedOption, onClick: onClick, onKeyDown: handleOnKeyDown, leadingType: leadingType }));
50
+ }))),
51
+ optionDetails && (react_1.default.createElement("div", { className: "combobox__option-details text--caption" }, optionDetails))));
52
+ };
53
+ exports.default = ComboBoxOptions;
54
54
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- export declare const calculateListMaxHeight: () => number;
1
+ export declare const calculateListMaxHeight: () => number;
@@ -1,12 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateListMaxHeight = void 0;
4
- var calculateListMaxHeight = function () {
5
- var windowHeight = window.innerHeight;
6
- var headerHeight = 50;
7
- var inputFieldHeight = 35;
8
- var maxListHeight = windowHeight - headerHeight - inputFieldHeight;
9
- return maxListHeight;
10
- };
11
- exports.calculateListMaxHeight = calculateListMaxHeight;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateListMaxHeight = void 0;
4
+ var calculateListMaxHeight = function () {
5
+ var windowHeight = window.innerHeight;
6
+ var headerHeight = 50;
7
+ var inputFieldHeight = 35;
8
+ var maxListHeight = windowHeight - headerHeight - inputFieldHeight;
9
+ return maxListHeight;
10
+ };
11
+ exports.calculateListMaxHeight = calculateListMaxHeight;
12
12
  //# sourceMappingURL=calculateListMaxHeight.js.map
@@ -1 +1 @@
1
- export declare const scrollOptionToViewport: (isDesktop: boolean) => void;
1
+ export declare const scrollOptionToViewport: (isDesktop: boolean) => void;
@@ -1,22 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.scrollOptionToViewport = void 0;
4
- var scrollOptionToViewport = function (isDesktop) {
5
- var comboboxOptions = isDesktop ? document.querySelector('.menu') :
6
- document.querySelector('.combobox__options');
7
- var selectedItem = document.querySelector(".menu-item.selected");
8
- if (selectedItem && comboboxOptions) {
9
- var comboboxOptionsGroup = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.parentElement;
10
- if (comboboxOptionsGroup) {
11
- var stickyHeader = comboboxOptionsGroup === null || comboboxOptionsGroup === void 0 ? void 0 : comboboxOptionsGroup.querySelector('.sticky-header');
12
- var stickyHeaderOffset = stickyHeader === null || stickyHeader === void 0 ? void 0 : stickyHeader.offsetTop;
13
- comboboxOptions === null || comboboxOptions === void 0 ? void 0 : comboboxOptions.scrollTo({ top: stickyHeaderOffset });
14
- }
15
- else {
16
- var selectedItemOffset = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.offsetTop;
17
- comboboxOptions === null || comboboxOptions === void 0 ? void 0 : comboboxOptions.scrollTo({ top: selectedItemOffset });
18
- }
19
- }
20
- };
21
- exports.scrollOptionToViewport = scrollOptionToViewport;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scrollOptionToViewport = void 0;
4
+ var scrollOptionToViewport = function (isDesktop) {
5
+ var comboboxOptions = isDesktop ? document.querySelector('.menu') :
6
+ document.querySelector('.combobox__options');
7
+ var selectedItem = document.querySelector(".menu-item.selected");
8
+ if (selectedItem && comboboxOptions) {
9
+ var comboboxOptionsGroup = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.parentElement;
10
+ if (comboboxOptionsGroup) {
11
+ var stickyHeader = comboboxOptionsGroup === null || comboboxOptionsGroup === void 0 ? void 0 : comboboxOptionsGroup.querySelector('.sticky-header');
12
+ var stickyHeaderOffset = stickyHeader === null || stickyHeader === void 0 ? void 0 : stickyHeader.offsetTop;
13
+ comboboxOptions === null || comboboxOptions === void 0 ? void 0 : comboboxOptions.scrollTo({ top: stickyHeaderOffset });
14
+ }
15
+ else {
16
+ var selectedItemOffset = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.offsetTop;
17
+ comboboxOptions === null || comboboxOptions === void 0 ? void 0 : comboboxOptions.scrollTo({ top: selectedItemOffset });
18
+ }
19
+ }
20
+ };
21
+ exports.scrollOptionToViewport = scrollOptionToViewport;
22
22
  //# sourceMappingURL=scrollOptionToViewport.js.map
@@ -1,2 +1,2 @@
1
- declare const useIsDesktopScreenWidth: () => boolean;
2
- export default useIsDesktopScreenWidth;
1
+ declare const useIsDesktopScreenWidth: () => boolean;
2
+ export default useIsDesktopScreenWidth;