@bodynarf/react.components 1.9.0 → 1.10.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/bodynarf-react.components-1.10.0.tgz +0 -0
- package/components/accordion/component/index.js +3 -3
- package/components/anchor/component/index.js +2 -2
- package/components/anchor/components/anchorWithIcon/index.d.ts +8 -2
- package/components/anchor/components/anchorWithIcon/index.d.ts.map +1 -1
- package/components/anchor/components/anchorWithIcon/index.js +2 -2
- package/components/anchor/components/simpleAnchor/index.d.ts +2 -2
- package/components/anchor/components/simpleAnchor/index.d.ts.map +1 -1
- package/components/anchor/components/simpleAnchor/index.js +1 -1
- package/components/anchor/types.d.ts +3 -11
- package/components/anchor/types.d.ts.map +1 -1
- package/components/breadcrumbs/component/index.d.ts +7 -32
- package/components/breadcrumbs/component/index.d.ts.map +1 -1
- package/components/breadcrumbs/component/index.js +22 -6
- package/components/breadcrumbs/types.d.ts +30 -1
- package/components/breadcrumbs/types.d.ts.map +1 -1
- package/components/button/component/index.d.ts.map +1 -1
- package/components/button/component/index.js +3 -3
- package/components/button/types.d.ts +1 -1
- package/components/dropdown/component/style.scss +3 -3
- package/components/dropdown/components/compact/index.d.ts +8 -2
- package/components/dropdown/components/compact/index.d.ts.map +1 -1
- package/components/dropdown/components/compact/index.js +17 -5
- package/components/dropdown/components/label/component/index.d.ts +27 -0
- package/components/dropdown/components/label/component/index.d.ts.map +1 -0
- package/components/dropdown/components/label/component/index.js +16 -0
- package/components/dropdown/components/label/components/empty/index.d.ts +8 -0
- package/components/dropdown/components/label/components/empty/index.d.ts.map +1 -0
- package/components/dropdown/components/label/components/empty/index.js +16 -0
- package/components/dropdown/components/label/components/selected/index.d.ts +8 -0
- package/components/dropdown/components/label/components/selected/index.d.ts.map +1 -0
- package/components/dropdown/components/label/components/selected/index.js +20 -0
- package/components/dropdown/components/label/components/selectedWithIcon/index.d.ts +8 -0
- package/components/dropdown/components/label/components/selectedWithIcon/index.d.ts.map +1 -0
- package/components/dropdown/components/label/components/selectedWithIcon/index.js +28 -0
- package/components/dropdown/components/label/components/withSearch/index.d.ts +16 -0
- package/components/dropdown/components/label/components/withSearch/index.d.ts.map +1 -0
- package/components/dropdown/components/label/components/withSearch/index.js +33 -0
- package/components/dropdown/components/label/components/withSearch/style.scss +29 -0
- package/components/dropdown/components/label/index.d.ts +1 -17
- package/components/dropdown/components/label/index.d.ts.map +1 -1
- package/components/dropdown/components/label/index.js +1 -54
- package/components/dropdown/components/withLabel/index.d.ts +3 -2
- package/components/dropdown/components/withLabel/index.d.ts.map +1 -1
- package/components/dropdown/components/withLabel/index.js +8 -82
- package/components/dropdown/types.d.ts +8 -0
- package/components/dropdown/types.d.ts.map +1 -1
- package/components/icon/component/index.d.ts +3 -2
- package/components/icon/component/index.d.ts.map +1 -1
- package/components/icon/component/index.js +4 -3
- package/components/icon/types.d.ts +2 -0
- package/components/icon/types.d.ts.map +1 -1
- package/components/multiselect/component/index.d.ts +8 -0
- package/components/multiselect/component/index.d.ts.map +1 -0
- package/components/multiselect/component/index.js +13 -0
- package/components/multiselect/component/style.scss +20 -0
- package/components/multiselect/components/item/index.d.ts +25 -0
- package/components/multiselect/components/item/index.d.ts.map +1 -0
- package/components/multiselect/components/item/index.js +62 -0
- package/components/multiselect/components/label/component/index.d.ts +20 -0
- package/components/multiselect/components/label/component/index.d.ts.map +1 -0
- package/components/multiselect/components/label/component/index.js +12 -0
- package/components/multiselect/components/label/components/empty/index.d.ts +8 -0
- package/components/multiselect/components/label/components/empty/index.d.ts.map +1 -0
- package/components/multiselect/components/label/components/empty/index.js +16 -0
- package/components/multiselect/components/label/components/nonEmpty/index.d.ts +8 -0
- package/components/multiselect/components/label/components/nonEmpty/index.d.ts.map +1 -0
- package/components/multiselect/components/label/components/nonEmpty/index.js +16 -0
- package/components/multiselect/components/label/index.d.ts +2 -0
- package/components/multiselect/components/label/index.d.ts.map +1 -0
- package/components/multiselect/components/label/index.js +1 -0
- package/components/multiselect/components/withLabel/index.d.ts +6 -0
- package/components/multiselect/components/withLabel/index.d.ts.map +1 -0
- package/components/multiselect/components/withLabel/index.js +11 -0
- package/components/multiselect/components/withoutLabel/index.d.ts +10 -0
- package/components/multiselect/components/withoutLabel/index.d.ts.map +1 -0
- package/components/multiselect/components/withoutLabel/index.js +84 -0
- package/components/multiselect/index.d.ts +3 -0
- package/components/multiselect/index.d.ts.map +1 -0
- package/components/multiselect/index.js +2 -0
- package/components/multiselect/types.d.ts +41 -0
- package/components/multiselect/types.d.ts.map +1 -0
- package/components/multiselect/types.js +1 -0
- package/components/paginator/component/index.d.ts.map +1 -1
- package/components/paginator/component/index.js +22 -5
- package/components/paginator/index.d.ts +0 -1
- package/components/paginator/index.d.ts.map +1 -1
- package/components/paginator/index.js +0 -1
- package/components/primitives/checkbox/component/index.d.ts +1 -1
- package/components/primitives/checkbox/component/index.d.ts.map +1 -1
- package/components/primitives/checkbox/component/index.js +8 -6
- package/components/primitives/checkbox/component/style.scss +22 -3
- package/components/primitives/color/components/picker/index.d.ts +3 -3
- package/components/primitives/color/components/picker/index.d.ts.map +1 -1
- package/components/primitives/color/components/picker/index.js +8 -8
- package/components/primitives/color/components/withLabel/index.d.ts +1 -1
- package/components/primitives/color/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/color/components/withLabel/index.js +3 -4
- package/components/primitives/color/components/withoutLabel/index.d.ts +1 -1
- package/components/primitives/color/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/color/components/withoutLabel/index.js +2 -3
- package/components/primitives/date/component/index.d.ts +2 -2
- package/components/primitives/date/component/index.d.ts.map +1 -1
- package/components/primitives/date/component/index.js +5 -7
- package/components/primitives/date/component/style.scss +11 -0
- package/components/primitives/date/types.d.ts +1 -1
- package/components/primitives/date/types.d.ts.map +1 -1
- package/components/primitives/internal/componentWithLabel/index.d.ts.map +1 -1
- package/components/primitives/internal/componentWithLabel/index.js +2 -2
- package/components/primitives/internal/hint/index.d.ts +3 -7
- package/components/primitives/internal/hint/index.d.ts.map +1 -1
- package/components/primitives/internal/hint/index.js +1 -0
- package/components/primitives/internal/hint/style.scss +4 -0
- package/components/primitives/multiline/component/index.d.ts +0 -1
- package/components/primitives/multiline/component/index.d.ts.map +1 -1
- package/components/primitives/multiline/component/index.js +0 -1
- package/components/primitives/multiline/components/withLabel/index.d.ts +1 -1
- package/components/primitives/multiline/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/multiline/components/withLabel/index.js +4 -6
- package/components/primitives/multiline/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/multiline/components/withoutLabel/index.js +4 -5
- package/components/primitives/number/components/withLabel/index.d.ts +1 -1
- package/components/primitives/number/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/number/components/withLabel/index.js +4 -6
- package/components/primitives/number/components/withoutLabel/index.d.ts +1 -1
- package/components/primitives/number/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/number/components/withoutLabel/index.js +5 -6
- package/components/primitives/password/components/withLabel/index.d.ts +1 -1
- package/components/primitives/password/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/password/components/withLabel/index.js +5 -6
- package/components/primitives/password/components/withoutLabel/index.js +6 -7
- package/components/primitives/text/component/index.d.ts +0 -1
- package/components/primitives/text/component/index.d.ts.map +1 -1
- package/components/primitives/text/component/index.js +0 -1
- package/components/primitives/text/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/text/components/withLabel/index.js +4 -6
- package/components/primitives/text/components/withoutLabel/index.d.ts +1 -1
- package/components/primitives/text/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/text/components/withoutLabel/index.js +5 -6
- package/components/search/component/index.d.ts.map +1 -1
- package/components/search/component/index.js +6 -8
- package/components/table/component/index.d.ts +2 -35
- package/components/table/component/index.d.ts.map +1 -1
- package/components/table/component/index.js +4 -2
- package/components/table/component/style.scss +21 -0
- package/components/table/components/heading/index.d.ts.map +1 -1
- package/components/table/components/heading/index.js +3 -3
- package/components/table/types.d.ts +36 -1
- package/components/table/types.d.ts.map +1 -1
- package/components/tabs/component/index.d.ts +3 -27
- package/components/tabs/component/index.d.ts.map +1 -1
- package/components/tabs/component/index.js +3 -3
- package/components/tabs/types.d.ts +24 -1
- package/components/tabs/types.d.ts.map +1 -1
- package/components/tag/component/index.d.ts.map +1 -1
- package/components/tag/component/index.js +3 -3
- package/components/tag/types.d.ts +3 -3
- package/components/tag/types.d.ts.map +1 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.d.ts.map +1 -1
- package/hooks/index.js +1 -0
- package/hooks/useComponentOutsideClick.d.ts.map +1 -1
- package/hooks/useComponentOutsideClick.js +2 -3
- package/hooks/useUnmount.d.ts +8 -0
- package/hooks/useUnmount.d.ts.map +1 -0
- package/hooks/useUnmount.js +22 -0
- package/package.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/common.scss +0 -8
- package/components/paginator/utils.d.ts +0 -10
- package/components/paginator/utils.d.ts.map +0 -1
- package/components/paginator/utils.js +0 -18
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { getClassName, isNullOrEmpty, isNullOrUndefined } from "@bodynarf/utils";
|
|
4
|
+
import { ElementSize } from "../../../../../../types";
|
|
5
|
+
import Icon from "../../../../../icon";
|
|
6
|
+
import "./style.scss";
|
|
7
|
+
/** Label component with search */
|
|
8
|
+
const DropdownLabelWithSearch = ({ caption, className, deselectable, lastSearch, onSearchChange, isListVisible, onClick, selectedItem, }) => {
|
|
9
|
+
const elClassName = getClassName([
|
|
10
|
+
"dropdown-trigger",
|
|
11
|
+
"bbr-dropdown__label",
|
|
12
|
+
isNullOrEmpty(className) ? "" : `${className}--md`,
|
|
13
|
+
"button",
|
|
14
|
+
"bbr-dropdown__search"
|
|
15
|
+
]);
|
|
16
|
+
const onChange = useCallback((event) => onSearchChange(event.target.value), [onSearchChange]);
|
|
17
|
+
const inputClassName = getClassName([
|
|
18
|
+
"input",
|
|
19
|
+
deselectable && !isNullOrUndefined(selectedItem) ? "px-2" : "pl-0"
|
|
20
|
+
]);
|
|
21
|
+
const containerOnClick = useCallback((event) => {
|
|
22
|
+
event.stopPropagation();
|
|
23
|
+
const target = event.target;
|
|
24
|
+
if (target.nodeName !== "I" && isListVisible) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
onClick(event);
|
|
28
|
+
}, [isListVisible, onClick]);
|
|
29
|
+
return (_jsxs("div", { className: elClassName, onClick: containerOnClick, children: [deselectable && !isNullOrUndefined(selectedItem)
|
|
30
|
+
&&
|
|
31
|
+
_jsx(Icon, { name: "plus-lg", size: ElementSize.Medium }), _jsx("input", { type: "text", onChange: onChange, placeholder: caption, className: inputClassName, value: selectedItem?.displayValue ?? lastSearch ?? "" }), _jsx(Icon, { name: "arrow-down", size: ElementSize.Medium })] }));
|
|
32
|
+
};
|
|
33
|
+
export default DropdownLabelWithSearch;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.bbr-dropdown__search {
|
|
2
|
+
input {
|
|
3
|
+
border-left: 0;
|
|
4
|
+
border-right: 0;
|
|
5
|
+
border-radius: 0;
|
|
6
|
+
box-shadow: none !important;
|
|
7
|
+
|
|
8
|
+
background: transparent;
|
|
9
|
+
|
|
10
|
+
&::-webkit-input-placeholder {
|
|
11
|
+
color: gray;
|
|
12
|
+
font-style: italic;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&:focus, &:hover, &:active {
|
|
16
|
+
border-color: inherit !important;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&:hover {
|
|
21
|
+
input {
|
|
22
|
+
border-color: inherit !important;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.bbr-dropdown.is-active .bbr-dropdown__search {
|
|
28
|
+
background: rgba(0, 0, 0, 0.05);
|
|
29
|
+
}
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { SelectableItem } from "../..";
|
|
3
|
-
export interface DropdownLabelProps {
|
|
4
|
-
/** Caption when no items selected */
|
|
5
|
-
caption: string;
|
|
6
|
-
/** Can user deselect */
|
|
7
|
-
deselectable: boolean;
|
|
8
|
-
/** Selected item */
|
|
9
|
-
selectedItem?: SelectableItem;
|
|
10
|
-
/** Element classnames */
|
|
11
|
-
className?: string;
|
|
12
|
-
/** Click handler*/
|
|
13
|
-
onClick: (event: MouseEvent<HTMLLabelElement>) => void;
|
|
14
|
-
}
|
|
15
|
-
/** Label component */
|
|
16
|
-
declare const DropdownLabel: ({ caption, selectedItem, onClick, deselectable, className, }: DropdownLabelProps) => JSX.Element;
|
|
17
|
-
export default DropdownLabel;
|
|
1
|
+
export { default } from "./component";
|
|
18
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/dropdown/components/label/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/dropdown/components/label/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,54 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { getClassName, isNullOrEmpty, isNullOrUndefined } from "@bodynarf/utils";
|
|
3
|
-
import { ElementPosition, ElementSize } from "../../../../types";
|
|
4
|
-
import Icon from "../../../icon";
|
|
5
|
-
/** Label component */
|
|
6
|
-
const DropdownLabel = ({ caption, selectedItem, onClick, deselectable, className, }) => {
|
|
7
|
-
if (isNullOrUndefined(selectedItem)) {
|
|
8
|
-
return _jsx(EmptyLabel, { caption: caption, deselectable: deselectable, onClick: onClick, className: className });
|
|
9
|
-
}
|
|
10
|
-
if (!isNullOrUndefined(selectedItem.icon)) {
|
|
11
|
-
return _jsx(SelectedItemLabelWithIcon, { caption: caption, deselectable: deselectable, onClick: onClick, className: className, selectedItem: selectedItem });
|
|
12
|
-
}
|
|
13
|
-
const elClassName = getClassName([
|
|
14
|
-
"dropdown-trigger",
|
|
15
|
-
"bbr-dropdown__label",
|
|
16
|
-
isNullOrEmpty(className) ? "" : `${className}--md`,
|
|
17
|
-
"button"
|
|
18
|
-
]);
|
|
19
|
-
return (_jsxs("label", { className: elClassName, onClick: onClick, children: [deselectable &&
|
|
20
|
-
_jsx(Icon, { name: "plus-lg", size: ElementSize.Medium }), _jsx("span", { className: deselectable ? "px-2" : "pr-2", title: selectedItem.title, children: selectedItem.displayValue }), _jsx(Icon, { name: "arrow-down", size: ElementSize.Medium })] }));
|
|
21
|
-
};
|
|
22
|
-
export default DropdownLabel;
|
|
23
|
-
const EmptyLabel = ({ caption, onClick, className, }) => {
|
|
24
|
-
const elClassName = getClassName([
|
|
25
|
-
"dropdown-trigger",
|
|
26
|
-
"bbr-dropdown__label",
|
|
27
|
-
isNullOrEmpty(className) ? "" : `${className}--md`,
|
|
28
|
-
"bbr-dropdown__label--default",
|
|
29
|
-
"button"
|
|
30
|
-
]);
|
|
31
|
-
return (_jsxs("label", { className: elClassName, onClick: onClick, children: [_jsx("span", { className: "mr-2", children: caption }), _jsx(Icon, { name: "arrow-down", size: ElementSize.Medium })] }));
|
|
32
|
-
};
|
|
33
|
-
const SelectedItemLabelWithIcon = ({ selectedItem, onClick, deselectable, className, }) => {
|
|
34
|
-
const elClassName = getClassName([
|
|
35
|
-
"dropdown-trigger",
|
|
36
|
-
"bbr-dropdown__label",
|
|
37
|
-
isNullOrEmpty(className) ? "" : `${className}--md`,
|
|
38
|
-
"button"
|
|
39
|
-
]);
|
|
40
|
-
const icon = selectedItem.icon;
|
|
41
|
-
const iconClassName = getClassName([
|
|
42
|
-
icon.className,
|
|
43
|
-
icon.position === ElementPosition.Right
|
|
44
|
-
? "bbr-icon--right"
|
|
45
|
-
: "bbr-icon--left",
|
|
46
|
-
"bbr-dropdown-item__icon"
|
|
47
|
-
]);
|
|
48
|
-
if (icon.position === ElementPosition.Right) {
|
|
49
|
-
return (_jsxs("label", { className: elClassName, onClick: onClick, children: [deselectable &&
|
|
50
|
-
_jsx(Icon, { name: "plus-lg", size: ElementSize.Medium }), _jsxs("span", { className: deselectable ? "px-2" : "pr-2", title: selectedItem.title, children: [selectedItem.displayValue, _jsx(Icon, { name: icon.name, size: icon.size, className: iconClassName })] }), _jsx(Icon, { name: "arrow-down", size: ElementSize.Medium })] }));
|
|
51
|
-
}
|
|
52
|
-
return (_jsxs("label", { className: elClassName, onClick: onClick, children: [deselectable &&
|
|
53
|
-
_jsx(Icon, { name: "plus-lg", size: ElementSize.Medium }), _jsxs("span", { className: deselectable ? "mx-2" : "mr-2", title: selectedItem.title, children: [_jsx(Icon, { name: icon.name, size: icon.size, className: iconClassName }), selectedItem.displayValue] }), _jsx(Icon, { name: "arrow-down", size: ElementSize.Medium })] }));
|
|
54
|
-
};
|
|
1
|
+
export { default } from "./component";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { FC } from "react";
|
|
2
2
|
import { DropdownProps } from "../..";
|
|
3
|
-
|
|
3
|
+
/** Dropdown component with label */
|
|
4
|
+
declare const DropdownWithLabel: FC<DropdownProps>;
|
|
4
5
|
export default DropdownWithLabel;
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/dropdown/components/withLabel/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/dropdown/components/withLabel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAS,MAAM,OAAO,CAAC;AAKlC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC,oCAAoC;AACpC,QAAA,MAAM,iBAAiB,EAAE,EAAE,CAAC,aAAa,CAgBxC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,85 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import DropdownLabel from "../../components/label";
|
|
9
|
-
const DropdownWithLabel = ({ items, value, onSelect, validationState, deselectable = false, hideOnOuterClick, listMaxHeight, label, placeholder, disabled = false, className, title, data, hint, }) => {
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { ElementSize } from "../../../../types";
|
|
4
|
+
import LabelWrapper from "../../../primitives/internal/componentWithLabel";
|
|
5
|
+
import DropdownCompact from "../compact";
|
|
6
|
+
/** Dropdown component with label */
|
|
7
|
+
const DropdownWithLabel = (props) => {
|
|
10
8
|
const id = useId();
|
|
11
|
-
|
|
12
|
-
const onItemClick = useCallback((event) => {
|
|
13
|
-
if (disabled) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const target = event.target;
|
|
17
|
-
if (isNullOrUndefined(target)) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const dataValue = target.dataset["dropdownItemValue"];
|
|
21
|
-
if (isNullOrEmpty(dataValue)) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const item = items.find(x => x.value === dataValue);
|
|
25
|
-
if (isNullOrUndefined(item)) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (value === item) {
|
|
29
|
-
setListVisible(false);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
onSelect(item);
|
|
33
|
-
setListVisible(false);
|
|
34
|
-
}, [setListVisible, value, items, onSelect, disabled]);
|
|
35
|
-
const onLabelClick = useCallback((event) => {
|
|
36
|
-
if (disabled) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const target = event.target;
|
|
40
|
-
if (isNullOrUndefined(target)) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (target.classList.contains("bi-plus-lg")) {
|
|
44
|
-
onSelect(undefined);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
setListVisible(state => !state);
|
|
48
|
-
}
|
|
49
|
-
}, [onSelect, setListVisible, disabled]);
|
|
50
|
-
useComponentOutsideClick(`[data-dropdown-id="${id}"]`, isListVisible, () => setListVisible(false), hideOnOuterClick);
|
|
51
|
-
const classNames = getClassName([
|
|
52
|
-
"bbr-dropdown",
|
|
53
|
-
className,
|
|
54
|
-
disabled ? "bbr-dropdown--disabled" : "",
|
|
55
|
-
isListVisible ? "is-active" : "",
|
|
56
|
-
isNullOrEmpty(listMaxHeight) ? "bbr-dropdown--height-default" : "",
|
|
57
|
-
"dropdown"
|
|
58
|
-
]);
|
|
59
|
-
const labelClassName = getClassName([
|
|
60
|
-
"label",
|
|
61
|
-
label.className
|
|
62
|
-
]);
|
|
63
|
-
const labelComponentClassName = getStyleClassName(undefined, validationState);
|
|
64
|
-
const dataAttributes = isNullOrUndefined(data)
|
|
65
|
-
? undefined
|
|
66
|
-
: mapDataAttributes(data);
|
|
67
|
-
if (label.horizontal) {
|
|
68
|
-
const labelContainerClassName = getClassName([
|
|
69
|
-
"field-label",
|
|
70
|
-
"is-normal",
|
|
71
|
-
label.horizontalContainerClassName
|
|
72
|
-
]);
|
|
73
|
-
const fieldContainerClassName = getClassName([
|
|
74
|
-
"field-body",
|
|
75
|
-
label.horizontalFieldContainerClassName
|
|
76
|
-
]);
|
|
77
|
-
return (_jsxs("div", { className: "bbr-dropdown__root-container--with-label bbr-input field is-horizontal", children: [_jsx("div", { className: labelContainerClassName, children: _jsx("label", { className: labelClassName, htmlFor: id, children: label.caption }) }), _jsx("div", { className: fieldContainerClassName, children: _jsxs("div", { className: "field", children: [_jsxs("div", { className: classNames, "data-dropdown-id": id, title: title, ...dataAttributes, children: [_jsx(DropdownLabel, { selectedItem: value, caption: placeholder, onClick: onLabelClick, deselectable: deselectable, className: labelComponentClassName }), _jsx("div", { className: "dropdown-menu", children: items.length > 0
|
|
78
|
-
? _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)) })
|
|
79
|
-
: _jsx("span", { className: "dropdown-content dropdown-item", children: "No items found" }) })] }, id), _jsx(InternalHint, { hint: hint, validationState: validationState })] }) })] }));
|
|
80
|
-
}
|
|
81
|
-
return (_jsxs("div", { className: "field", children: [_jsx("label", { className: labelClassName, htmlFor: id, children: label.caption }), _jsxs("div", { className: classNames, "data-dropdown-id": id, title: title, ...dataAttributes, children: [_jsx(DropdownLabel, { selectedItem: value, caption: placeholder, onClick: onLabelClick, deselectable: deselectable, className: labelComponentClassName }), _jsx("div", { className: "dropdown-menu", children: items.length > 0
|
|
82
|
-
? _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)) })
|
|
83
|
-
: _jsx("span", { className: "dropdown-content dropdown-item", children: "No items found" }) })] }, id), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
|
|
9
|
+
return (_jsx(LabelWrapper, { id: id, label: props.label, size: ElementSize.Normal, children: _jsx(DropdownCompact, { ...props, id: id }) }));
|
|
84
10
|
};
|
|
85
11
|
export default DropdownWithLabel;
|
|
@@ -53,5 +53,13 @@ export interface DropdownProps extends BaseElementProps {
|
|
|
53
53
|
* (!) Hint will be overridden by the validation state, if specified
|
|
54
54
|
*/
|
|
55
55
|
hint?: HintConfiguration;
|
|
56
|
+
/** Caption for dropdown list when there's no data to display */
|
|
57
|
+
noDataText?: string;
|
|
58
|
+
/** Is search through items enabled */
|
|
59
|
+
searchable?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Text which would be displayed when search query applied and no items found
|
|
62
|
+
*/
|
|
63
|
+
noDataByQuery?: string;
|
|
56
64
|
}
|
|
57
65
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEnH,oBAAoB;AACpB,MAAM,WAAW,cAAc;IAC3B,6BAA6B;IAC7B,EAAE,EAAE,MAAM,CAAC;IAEX,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;IAEd,sBAAsB;IACtB,YAAY,EAAE,MAAM,CAAC;IAErB,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,iCAAiC;IACjC,IAAI,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,oCAAoC;AACpC,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACnD,kCAAkC;IAClC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAE7B,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAC;IAEpB;;MAEE;IACF,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAE1C;;;MAGE;IACF,KAAK,CAAC,EAAE,cAAc,CAAC;IAEvB,gEAAgE;IAChE,gBAAgB,EAAE,OAAO,CAAC;IAE1B,wBAAwB;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,+CAA+C;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAE3B,+BAA+B;IAC/B,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEnH,oBAAoB;AACpB,MAAM,WAAW,cAAc;IAC3B,6BAA6B;IAC7B,EAAE,EAAE,MAAM,CAAC;IAEX,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;IAEd,sBAAsB;IACtB,YAAY,EAAE,MAAM,CAAC;IAErB,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,iCAAiC;IACjC,IAAI,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,oCAAoC;AACpC,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACnD,kCAAkC;IAClC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAE7B,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAC;IAEpB;;MAEE;IACF,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAE1C;;;MAGE;IACF,KAAK,CAAC,EAAE,cAAc,CAAC;IAEvB,gEAAgE;IAChE,gBAAgB,EAAE,OAAO,CAAC;IAE1B,wBAAwB;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,+CAA+C;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAE3B,+BAA+B;IAC/B,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAC;IAEzB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,sCAAsC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { FC } from "react";
|
|
2
2
|
import "./style.scss";
|
|
3
3
|
import { IconProps } from "../..";
|
|
4
4
|
/**
|
|
5
5
|
* Icon component. Based on bootstrap icons
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
declare const Icon: FC<IconProps>;
|
|
8
|
+
export default Icon;
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/icon/component/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/icon/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAO3B,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASlC;;GAEG;AACH,QAAA,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CA2BvB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -12,7 +12,7 @@ const sizeToClassMap = new Map([
|
|
|
12
12
|
/**
|
|
13
13
|
* Icon component. Based on bootstrap icons
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
const Icon = ({ name, size = ElementSize.Normal, className, title, data, onClick, }) => {
|
|
16
16
|
const classNames = getClassName([
|
|
17
17
|
"bbr-icon",
|
|
18
18
|
"bi",
|
|
@@ -23,5 +23,6 @@ export default function Icon({ name, size = ElementSize.Normal, className, title
|
|
|
23
23
|
const dataAttributes = isNullOrUndefined(data)
|
|
24
24
|
? undefined
|
|
25
25
|
: mapDataAttributes(data);
|
|
26
|
-
return (_jsx("i", { className: classNames, title: title, ...dataAttributes }));
|
|
27
|
-
}
|
|
26
|
+
return (_jsx("i", { className: classNames, title: title, onClick: onClick, ...dataAttributes }));
|
|
27
|
+
};
|
|
28
|
+
export default Icon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/icon/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE3D,2BAA2B;AAC3B,MAAM,WAAW,SAAU,SAAQ,gBAAgB;IAC/C;;;;;MAKE;IACF,IAAI,EAAE,MAAM,CAAC;IAEb,gBAAgB;IAChB,IAAI,CAAC,EAAE,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/icon/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE3D,2BAA2B;AAC3B,MAAM,WAAW,SAAU,SAAQ,gBAAgB;IAC/C;;;;;MAKE;IACF,IAAI,EAAE,MAAM,CAAC;IAEb,gBAAgB;IAChB,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,oBAAoB;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import "../../dropdown/component/style.scss";
|
|
3
|
+
import "./style.scss";
|
|
4
|
+
import { MultiselectProps } from "../types";
|
|
5
|
+
/** Multiselect component */
|
|
6
|
+
declare const Multiselect: FC<MultiselectProps>;
|
|
7
|
+
export default Multiselect;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/multiselect/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,OAAO,qCAAqC,CAAC;AAC7C,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAI5C,4BAA4B;AAC5B,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAKrC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { isNullOrUndefined } from "@bodynarf/utils";
|
|
3
|
+
import "../../dropdown/component/style.scss";
|
|
4
|
+
import "./style.scss";
|
|
5
|
+
import MultiselectWithoutLabel from "../components/withoutLabel";
|
|
6
|
+
import MultiselectWithLabel from "../components/withLabel";
|
|
7
|
+
/** Multiselect component */
|
|
8
|
+
const Multiselect = (props) => {
|
|
9
|
+
return isNullOrUndefined(props.label)
|
|
10
|
+
? _jsx(MultiselectWithoutLabel, { ...props })
|
|
11
|
+
: _jsx(MultiselectWithLabel, { ...props });
|
|
12
|
+
};
|
|
13
|
+
export default Multiselect;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.bbr-multiselect {
|
|
2
|
+
.dropdown-content {
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
|
|
5
|
+
ul {
|
|
6
|
+
max-height: 13.5rem;
|
|
7
|
+
overflow: auto;
|
|
8
|
+
|
|
9
|
+
li.bbr-dropdown-item {
|
|
10
|
+
.field:not(:last-child) {
|
|
11
|
+
margin-bottom: 0 !important;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.bbr-icon {
|
|
15
|
+
transition: none;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MultiselectItem as MultiselectItemModel, MultiselectProps } from "../../";
|
|
3
|
+
/** Multiselect item props */
|
|
4
|
+
declare type MultiselectItemProps = Pick<MultiselectProps, "checkboxConfig"> & {
|
|
5
|
+
rootId: string;
|
|
6
|
+
/** Item to present in multiselect */
|
|
7
|
+
item: MultiselectItemModel;
|
|
8
|
+
/** Is item selected */
|
|
9
|
+
selected: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Handler of item selection change event
|
|
12
|
+
* @param item Current item
|
|
13
|
+
* @param checked New checked state
|
|
14
|
+
*/
|
|
15
|
+
onChange: (item: MultiselectItemModel, checked: boolean) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Handler of item click event
|
|
18
|
+
* @param item Current item
|
|
19
|
+
*/
|
|
20
|
+
onItemClick: (item: MultiselectItemModel) => void;
|
|
21
|
+
};
|
|
22
|
+
/** Single item in multiselect component */
|
|
23
|
+
declare const MultiselectItem: ({ item, selected, rootId, onItemClick, onChange, checkboxConfig, }: MultiselectItemProps) => JSX.Element;
|
|
24
|
+
export default MultiselectItem;
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/multiselect/components/item/index.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,eAAe,IAAI,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAEnF,6BAA6B;AAC7B,aAAK,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,GAAG;IACnE,MAAM,EAAE,MAAM,CAAC;IAEf,qCAAqC;IACrC,IAAI,EAAE,oBAAoB,CAAC;IAE3B,uBAAuB;IACvB,QAAQ,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAEjE;;;OAGG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;CACrD,CAAC;AAEF,2CAA2C;AAC3C,QAAA,MAAM,eAAe,uEAIlB,oBAAoB,KAAG,WAqDzB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { getClassName, isNullOrUndefined } from "@bodynarf/utils";
|
|
4
|
+
import { ElementPosition } from "../../../../types";
|
|
5
|
+
import Icon from "../../../icon";
|
|
6
|
+
import Checkbox from "../../../primitives/checkbox";
|
|
7
|
+
/** Single item in multiselect component */
|
|
8
|
+
const MultiselectItem = ({ item, selected, rootId, onItemClick, onChange, checkboxConfig, }) => {
|
|
9
|
+
const onChecked = useCallback((value) => onChange(item, value ?? false), [item, onChange]);
|
|
10
|
+
const onClick = useCallback((event) => {
|
|
11
|
+
if (event.target instanceof HTMLLIElement) {
|
|
12
|
+
onItemClick(item);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
event.stopPropagation();
|
|
16
|
+
}
|
|
17
|
+
}, [item, onItemClick]);
|
|
18
|
+
if (!isNullOrUndefined(item.icon)) {
|
|
19
|
+
return _jsx(MultiselectItemWithIcon, { item: item, rootId: rootId, onChange: onChange, selected: selected, onItemClick: onItemClick });
|
|
20
|
+
}
|
|
21
|
+
const className = getClassName([
|
|
22
|
+
"bbr-dropdown-item",
|
|
23
|
+
"dropdown-item",
|
|
24
|
+
selected ? "is-active" : "",
|
|
25
|
+
"is-flex",
|
|
26
|
+
]);
|
|
27
|
+
return (_jsxs("li", { className: className, onClick: onClick, title: item.title, "data-dropdown-id": rootId, children: [_jsx(Checkbox, { ...checkboxConfig, defaultValue: selected, onValueChange: onChecked }, item.id + selected), item.displayValue] }));
|
|
28
|
+
};
|
|
29
|
+
export default MultiselectItem;
|
|
30
|
+
/** Single item in multiselect component with icon */
|
|
31
|
+
const MultiselectItemWithIcon = ({ item, selected, rootId, onChange, onItemClick, checkboxConfig, }) => {
|
|
32
|
+
const icon = item.icon;
|
|
33
|
+
const className = getClassName([
|
|
34
|
+
"bbr-dropdown-item",
|
|
35
|
+
"dropdown-item",
|
|
36
|
+
selected ? "is-active" : "",
|
|
37
|
+
"is-flex is-align-items-center",
|
|
38
|
+
]);
|
|
39
|
+
const iconClassName = getClassName([
|
|
40
|
+
icon.className,
|
|
41
|
+
icon.position === ElementPosition.Right
|
|
42
|
+
? "bbr-icon--right"
|
|
43
|
+
: "bbr-icon--left",
|
|
44
|
+
]);
|
|
45
|
+
const onChecked = useCallback((value) => onChange(item, value ?? false), [item, onChange]);
|
|
46
|
+
const onClick = useCallback((event) => {
|
|
47
|
+
if (event.target instanceof HTMLLIElement) {
|
|
48
|
+
onItemClick(item);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
event.stopPropagation();
|
|
52
|
+
}
|
|
53
|
+
}, [item, onItemClick]);
|
|
54
|
+
const checkboxClassName = getClassName([
|
|
55
|
+
checkboxConfig?.className,
|
|
56
|
+
"mb-1"
|
|
57
|
+
]);
|
|
58
|
+
if (icon.position === ElementPosition.Right) {
|
|
59
|
+
return (_jsxs("li", { onClick: onClick, className: className, title: item.title, children: [_jsx(Checkbox, { ...checkboxConfig, defaultValue: selected, onValueChange: onChecked, className: checkboxClassName }, item.id + selected), item.displayValue, _jsx(Icon, { name: icon.name, size: icon.size, className: iconClassName })] }));
|
|
60
|
+
}
|
|
61
|
+
return (_jsxs("li", { onClick: onClick, className: className, title: item.title, "data-dropdown-id": rootId, children: [_jsx(Checkbox, { ...checkboxConfig, defaultValue: selected, onValueChange: onChecked, className: checkboxClassName }, item.id + selected), _jsx(Icon, { name: icon.name, size: icon.size, className: iconClassName }), item.displayValue] }));
|
|
62
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FC, MouseEvent } from "react";
|
|
2
|
+
/** Props type of `MultiselectLabel` */
|
|
3
|
+
export interface MultiselectLabelProps {
|
|
4
|
+
/** Caption when no items selected */
|
|
5
|
+
caption: string;
|
|
6
|
+
/** Caption when some items were selected */
|
|
7
|
+
selectionCaption: string;
|
|
8
|
+
/** Amount of selected items */
|
|
9
|
+
selectedItemsCount: number;
|
|
10
|
+
/** Can user deselect */
|
|
11
|
+
deselectable: boolean;
|
|
12
|
+
/** Element classnames */
|
|
13
|
+
className?: string;
|
|
14
|
+
/** Click handler*/
|
|
15
|
+
onClick: (event: MouseEvent<HTMLElement>) => void;
|
|
16
|
+
}
|
|
17
|
+
/** Label component */
|
|
18
|
+
declare const MultiselectLabel: FC<MultiselectLabelProps>;
|
|
19
|
+
export default MultiselectLabel;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/multiselect/components/label/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAKvC,uCAAuC;AACvC,MAAM,WAAW,qBAAqB;IAClC,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAEhB,4CAA4C;IAC5C,gBAAgB,EAAE,MAAM,CAAC;IAEzB,+BAA+B;IAC/B,kBAAkB,EAAE,MAAM,CAAC;IAE3B,wBAAwB;IACxB,YAAY,EAAE,OAAO,CAAC;IAEtB,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,mBAAmB;IACnB,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CACrD;AAED,sBAAsB;AACtB,QAAA,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAqB/C,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import SelectedItemLabel from "../components/nonEmpty";
|
|
3
|
+
import EmptyLabel from "../components/empty";
|
|
4
|
+
/** Label component */
|
|
5
|
+
const MultiselectLabel = ({ caption, selectionCaption, selectedItemsCount, onClick, deselectable, className, }) => {
|
|
6
|
+
if (selectedItemsCount === 0) {
|
|
7
|
+
return _jsx(EmptyLabel, { caption: caption, onClick: onClick, className: className });
|
|
8
|
+
}
|
|
9
|
+
const captionWhenItemsSelected = selectionCaption.format(`${selectedItemsCount}`);
|
|
10
|
+
return _jsx(SelectedItemLabel, { onClick: onClick, className: className, deselectable: deselectable, caption: captionWhenItemsSelected });
|
|
11
|
+
};
|
|
12
|
+
export default MultiselectLabel;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { MultiselectLabelProps } from "../../component";
|
|
3
|
+
/** Props type of `EmptyLabel` */
|
|
4
|
+
declare type EmptyLabelProps = Pick<MultiselectLabelProps, "caption" | "onClick" | "className">;
|
|
5
|
+
/** Empty multiselect label component (no item selected) */
|
|
6
|
+
declare const EmptyLabel: FC<EmptyLabelProps>;
|
|
7
|
+
export default EmptyLabel;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/multiselect/components/label/components/empty/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAO3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,iCAAiC;AACjC,aAAK,eAAe,GAAG,IAAI,CAAC,qBAAqB,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC,CAAC;AAExF,2DAA2D;AAC3D,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAsBnC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getClassName, isNullOrEmpty } from "@bodynarf/utils";
|
|
3
|
+
import { ElementSize } from "../../../../../../types";
|
|
4
|
+
import Icon from "../../../../../icon";
|
|
5
|
+
/** Empty multiselect label component (no item selected) */
|
|
6
|
+
const EmptyLabel = ({ caption, onClick, className, }) => {
|
|
7
|
+
const elClassName = getClassName([
|
|
8
|
+
"dropdown-trigger",
|
|
9
|
+
"bbr-dropdown__label",
|
|
10
|
+
isNullOrEmpty(className) ? "" : `${className}--md`,
|
|
11
|
+
"bbr-dropdown__label--default",
|
|
12
|
+
"button"
|
|
13
|
+
]);
|
|
14
|
+
return (_jsxs("label", { className: elClassName, onClick: onClick, children: [_jsx("span", { className: "mr-2", children: caption }), _jsx(Icon, { name: "arrow-down", size: ElementSize.Medium })] }));
|
|
15
|
+
};
|
|
16
|
+
export default EmptyLabel;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { MultiselectLabelProps } from "../../component";
|
|
3
|
+
/** Props type of `NonEmptyMultiselectLabel` */
|
|
4
|
+
declare type NonEmptyMultiselectLabelProps = Pick<MultiselectLabelProps, "onClick" | "caption" | "deselectable" | "className">;
|
|
5
|
+
/** Dropdown label when item is selected */
|
|
6
|
+
declare const NonEmptyMultiselectLabel: FC<NonEmptyMultiselectLabelProps>;
|
|
7
|
+
export default NonEmptyMultiselectLabel;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/multiselect/components/label/components/nonEmpty/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAO3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,+CAA+C;AAC/C,aAAK,6BAA6B,GAAG,IAAI,CACrC,qBAAqB,EACnB,SAAS,GAAG,SAAS,GACrB,cAAc,GAAG,WAAW,CACjC,CAAC;AAEF,2CAA2C;AAC3C,QAAA,MAAM,wBAAwB,EAAE,EAAE,CAAC,6BAA6B,CA2B/D,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getClassName, isNullOrEmpty } from "@bodynarf/utils";
|
|
3
|
+
import { ElementSize } from "../../../../../../types";
|
|
4
|
+
import Icon from "../../../../../icon";
|
|
5
|
+
/** Dropdown label when item is selected */
|
|
6
|
+
const NonEmptyMultiselectLabel = ({ onClick, deselectable, className, caption }) => {
|
|
7
|
+
const elClassName = getClassName([
|
|
8
|
+
"dropdown-trigger",
|
|
9
|
+
"bbr-dropdown__label",
|
|
10
|
+
isNullOrEmpty(className) ? "" : `${className}--md`,
|
|
11
|
+
"button"
|
|
12
|
+
]);
|
|
13
|
+
return (_jsxs("label", { className: elClassName, onClick: onClick, children: [deselectable &&
|
|
14
|
+
_jsx(Icon, { name: "plus-lg", size: ElementSize.Medium }), _jsx("span", { className: deselectable ? "px-2" : "pr-2", children: caption }), _jsx(Icon, { name: "arrow-down", size: ElementSize.Medium })] }));
|
|
15
|
+
};
|
|
16
|
+
export default NonEmptyMultiselectLabel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/multiselect/components/label/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/multiselect/components/withLabel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAS,MAAM,OAAO,CAAC;AAKlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,uCAAuC;AACvC,QAAA,MAAM,oBAAoB,EAAE,EAAE,CAAC,gBAAgB,CAc9C,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { ElementSize } from "../../../../types";
|
|
4
|
+
import LabelWrapper from "../../../primitives/internal/componentWithLabel";
|
|
5
|
+
import MultiselectWithoutLabel from "../withoutLabel";
|
|
6
|
+
/** Multiselect component with label */
|
|
7
|
+
const MultiselectWithLabel = (props) => {
|
|
8
|
+
const id = useId();
|
|
9
|
+
return (_jsx(LabelWrapper, { id: id, label: props.label, size: ElementSize.Normal, children: _jsx(MultiselectWithoutLabel, { ...props }) }));
|
|
10
|
+
};
|
|
11
|
+
export default MultiselectWithLabel;
|