@bodynarf/react.components 1.3.8 → 1.3.9
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.
|
@@ -22,10 +22,10 @@ export declare type DropdownProps = BaseElementProps & {
|
|
|
22
22
|
hideOnOuterClick: boolean;
|
|
23
23
|
/** Can user deselect */
|
|
24
24
|
deselectable?: boolean;
|
|
25
|
-
/** Custom dropdown list height property */
|
|
26
|
-
|
|
25
|
+
/** Custom dropdown list max-height property */
|
|
26
|
+
listMaxHeight?: string;
|
|
27
27
|
};
|
|
28
28
|
/** Dropdown component */
|
|
29
|
-
declare const Dropdown: ({ value, items, onSelect, caption, deselectable, className, hideOnOuterClick,
|
|
29
|
+
declare const Dropdown: ({ value, items, onSelect, caption, deselectable, className, hideOnOuterClick, listMaxHeight }: DropdownProps) => JSX.Element;
|
|
30
30
|
export default Dropdown;
|
|
31
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/index.tsx"],"names":[],"mappings":"AAIA,OAAO,iBAAiB,CAAC;AAIzB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAK5C,oBAAY,aAAa,GAAG,gBAAgB,GAAG;IAC3C,kCAAkC;IAClC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAE7B;;;MAGE;IACF,KAAK,CAAC,EAAE,cAAc,CAAC;IAEvB;;MAEE;IACF,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAE1C;;;MAGE;IACF,OAAO,EAAE,MAAM,CAAC;IAEhB,gEAAgE;IAChE,gBAAgB,EAAE,OAAO,CAAC;IAE1B,wBAAwB;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/index.tsx"],"names":[],"mappings":"AAIA,OAAO,iBAAiB,CAAC;AAIzB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAK5C,oBAAY,aAAa,GAAG,gBAAgB,GAAG;IAC3C,kCAAkC;IAClC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAE7B;;;MAGE;IACF,KAAK,CAAC,EAAE,cAAc,CAAC;IAEvB;;MAEE;IACF,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAE1C;;;MAGE;IACF,OAAO,EAAE,MAAM,CAAC;IAEhB,gEAAgE;IAChE,gBAAgB,EAAE,OAAO,CAAC;IAE1B,wBAAwB;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,+CAA+C;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAA;AAED,yBAAyB;AACzB,QAAA,MAAM,QAAQ,kGAAmG,aAAa,KAAG,WA4FhI,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { useComponentOutsideClick } from '../../hooks/useComponentOutsideClick';
|
|
|
6
6
|
import DropdownItem from './components/dropdownItem';
|
|
7
7
|
import DropdownLabel from './components/dropdownLabel';
|
|
8
8
|
/** Dropdown component */
|
|
9
|
-
const Dropdown = ({ value, items, onSelect, caption, deselectable, className, hideOnOuterClick,
|
|
9
|
+
const Dropdown = ({ value, items, onSelect, caption, deselectable, className, hideOnOuterClick, listMaxHeight }) => {
|
|
10
10
|
const id = useId();
|
|
11
11
|
const [isListVisible, setListVisible] = useState(false);
|
|
12
12
|
const onItemClick = useCallback((event) => {
|
|
@@ -45,12 +45,12 @@ const Dropdown = ({ value, items, onSelect, caption, deselectable, className, hi
|
|
|
45
45
|
const classNames = getClassName([
|
|
46
46
|
"app-dropdown",
|
|
47
47
|
isListVisible ? "is-active" : "",
|
|
48
|
-
isNullOrEmpty(
|
|
48
|
+
isNullOrEmpty(listMaxHeight) ? "app-dropdown--height-default" : "",
|
|
49
49
|
className,
|
|
50
50
|
"dropdown"
|
|
51
51
|
]);
|
|
52
52
|
return (_jsxs("div", { className: classNames, "data-dropdown-id": id, children: [_jsx(DropdownLabel, { caption: caption, deselectable: deselectable === true, selectedItem: value, onClick: onLabelClick }), _jsx("div", { className: "dropdown-menu", children: items.length > 0
|
|
53
|
-
? _jsx("ul", { className: "dropdown-content", style: {
|
|
53
|
+
? _jsx("ul", { className: "dropdown-content", style: { maxHeight: listMaxHeight }, children: items.map(item => _jsx(DropdownItem, { item: item, selected: value?.value === item.value, onClick: onItemClick }, item.id)) })
|
|
54
54
|
: _jsx("span", { className: "dropdown-content dropdown-item", children: "No items found" }) })] }, id));
|
|
55
55
|
};
|
|
56
56
|
export default Dropdown;
|