@bodynarf/react.components 1.13.4 → 1.13.6
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/components/accordion/component/index.d.ts.map +1 -1
- package/components/accordion/component/index.js +7 -9
- package/components/accordion/types.d.ts +2 -2
- package/components/accordion/types.d.ts.map +1 -1
- package/components/anchor/types.d.ts +1 -1
- package/components/breadcrumbs/component/index.d.ts.map +1 -1
- package/components/breadcrumbs/component/index.js +9 -11
- package/components/breadcrumbs/types.d.ts +16 -16
- package/components/breadcrumbs/types.d.ts.map +1 -1
- package/components/button/component/index.js +3 -3
- package/components/button/components/buttonWithIcon/index.d.ts.map +1 -1
- package/components/button/components/buttonWithIcon/index.js +4 -6
- package/components/button/components/simpleButton/index.d.ts.map +1 -1
- package/components/button/components/simpleButton/index.js +2 -5
- package/components/button/types.d.ts +2 -2
- package/components/button/types.d.ts.map +1 -1
- package/components/dropdown/component/index.d.ts.map +1 -1
- package/components/dropdown/component/index.js +6 -3
- package/components/dropdown/component/style.scss +13 -0
- package/components/dropdown/components/compact/index.d.ts.map +1 -1
- package/components/dropdown/components/compact/index.js +22 -11
- package/components/dropdown/components/item/index.js +6 -6
- package/components/dropdown/components/label/component/index.d.ts +4 -4
- package/components/dropdown/components/label/component/index.d.ts.map +1 -1
- package/components/dropdown/components/label/component/index.js +4 -4
- package/components/dropdown/components/label/components/selected/index.d.ts +1 -1
- package/components/dropdown/components/label/components/selected/index.d.ts.map +1 -1
- package/components/dropdown/components/label/components/selected/index.js +5 -5
- package/components/dropdown/components/label/components/selectedWithIcon/index.d.ts +1 -1
- package/components/dropdown/components/label/components/selectedWithIcon/index.d.ts.map +1 -1
- package/components/dropdown/components/label/components/selectedWithIcon/index.js +4 -4
- package/components/dropdown/components/label/components/withSearch/index.js +3 -3
- package/components/dropdown/components/withLabel/index.d.ts +2 -1
- package/components/dropdown/components/withLabel/index.d.ts.map +1 -1
- package/components/dropdown/components/withLabel/index.js +3 -1
- package/components/file/component/index.d.ts.map +1 -1
- package/components/file/component/index.js +6 -8
- package/components/icon/component/index.d.ts.map +1 -1
- package/components/icon/component/index.js +2 -4
- package/components/index.d.ts +33 -1
- package/components/index.d.ts.map +1 -1
- package/components/index.js +35 -1
- package/components/multiselect/component/index.d.ts.map +1 -1
- package/components/multiselect/component/index.js +6 -3
- package/components/multiselect/component/style.scss +13 -0
- package/components/multiselect/components/item/index.d.ts.map +1 -1
- package/components/multiselect/components/item/index.js +5 -5
- package/components/multiselect/components/label/components/empty/index.js +1 -1
- package/components/multiselect/components/label/components/nonEmpty/index.js +1 -1
- package/components/multiselect/components/withLabel/index.d.ts +2 -1
- package/components/multiselect/components/withLabel/index.d.ts.map +1 -1
- package/components/multiselect/components/withLabel/index.js +3 -1
- package/components/multiselect/components/withoutLabel/index.d.ts.map +1 -1
- package/components/multiselect/components/withoutLabel/index.js +23 -9
- package/components/multiselect/types.d.ts +8 -8
- package/components/multiselect/types.d.ts.map +1 -1
- package/components/paginator/component/index.d.ts.map +1 -1
- package/components/paginator/component/index.js +10 -12
- package/components/paginator/types.d.ts +2 -2
- package/components/paginator/types.d.ts.map +1 -1
- package/components/primitives/checkbox/component/index.d.ts.map +1 -1
- package/components/primitives/checkbox/component/index.js +9 -11
- package/components/primitives/color/component/index.d.ts.map +1 -1
- package/components/primitives/color/component/index.js +7 -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 +9 -10
- package/components/primitives/color/components/withLabel/index.d.ts +2 -1
- package/components/primitives/color/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/color/components/withLabel/index.js +5 -5
- package/components/primitives/color/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/color/components/withoutLabel/index.js +5 -4
- package/components/primitives/color/types.d.ts +1 -1
- package/components/primitives/color/types.d.ts.map +1 -1
- package/components/primitives/date/component/index.d.ts +2 -1
- package/components/primitives/date/component/index.d.ts.map +1 -1
- package/components/primitives/date/component/index.js +6 -6
- package/components/primitives/date/types.d.ts +2 -2
- 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.map +1 -1
- package/components/primitives/internal/hint/index.js +6 -6
- package/components/primitives/multiline/component/index.d.ts.map +1 -1
- package/components/primitives/multiline/component/index.js +6 -3
- package/components/primitives/multiline/components/withLabel/index.d.ts +2 -1
- package/components/primitives/multiline/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/multiline/components/withLabel/index.js +6 -6
- package/components/primitives/multiline/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/multiline/components/withoutLabel/index.js +6 -8
- package/components/primitives/multiline/types.d.ts +2 -2
- package/components/primitives/multiline/types.d.ts.map +1 -1
- package/components/primitives/number/component/index.d.ts.map +1 -1
- package/components/primitives/number/component/index.js +6 -3
- package/components/primitives/number/components/withLabel/index.d.ts +2 -1
- package/components/primitives/number/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/number/components/withLabel/index.js +6 -6
- package/components/primitives/number/components/withoutLabel/index.js +6 -8
- package/components/primitives/number/types.d.ts +2 -2
- package/components/primitives/number/types.d.ts.map +1 -1
- package/components/primitives/password/component/index.d.ts.map +1 -1
- package/components/primitives/password/component/index.js +6 -3
- package/components/primitives/password/components/withLabel/index.d.ts +2 -1
- package/components/primitives/password/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/password/components/withLabel/index.js +5 -7
- package/components/primitives/password/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/password/components/withoutLabel/index.js +5 -7
- package/components/primitives/password/types.d.ts +3 -3
- package/components/primitives/password/types.d.ts.map +1 -1
- package/components/primitives/text/component/index.d.ts.map +1 -1
- package/components/primitives/text/component/index.js +6 -3
- package/components/primitives/text/components/withLabel/index.d.ts +2 -1
- package/components/primitives/text/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/text/components/withLabel/index.js +6 -8
- package/components/primitives/text/components/withoutLabel/index.js +6 -8
- package/components/primitives/text/index.d.ts.map +1 -1
- package/components/primitives/text/types.d.ts +2 -2
- package/components/primitives/text/types.d.ts.map +1 -1
- package/components/progress/component/index.d.ts +7 -0
- package/components/progress/component/index.d.ts.map +1 -0
- package/components/progress/component/index.js +34 -0
- package/components/progress/component/style.scss +211 -0
- package/components/progress/index.d.ts +3 -0
- package/components/progress/index.d.ts.map +1 -0
- package/components/progress/index.js +2 -0
- package/components/progress/types.d.ts +23 -0
- package/components/progress/types.d.ts.map +1 -0
- package/components/progress/types.js +1 -0
- package/components/search/component/index.d.ts.map +1 -1
- package/components/search/component/index.js +7 -9
- package/components/search/types.d.ts +2 -2
- package/components/search/types.d.ts.map +1 -1
- package/components/table/component/index.d.ts.map +1 -1
- package/components/table/component/index.js +3 -5
- package/components/table/components/heading/index.js +4 -4
- package/components/tabs/component/index.d.ts.map +1 -1
- package/components/tabs/component/index.js +10 -31
- package/components/tabs/components/item/index.d.ts.map +1 -1
- package/components/tabs/components/item/index.js +2 -2
- package/components/tabs/types.d.ts +2 -2
- 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 +11 -13
- package/components/tag/component/style.scss +1 -1
- package/hooks/useComponentOutsideClick.d.ts.map +1 -1
- package/hooks/useComponentOutsideClick.js +3 -2
- package/hooks/useEventListener.d.ts.map +1 -1
- package/hooks/useEventListener.js +5 -2
- package/hooks/useMount.js +1 -1
- package/hooks/usePagination.d.ts +1 -1
- package/hooks/usePagination.d.ts.map +1 -1
- package/package.json +3 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/types/base/baseInputElementProps.d.ts +5 -4
- package/types/base/baseInputElementProps.d.ts.map +1 -1
- package/types/base/index.d.ts +2 -0
- package/types/base/index.d.ts.map +1 -1
- package/types/base/index.js +2 -0
- package/types/base/keyboardElement.d.ts +9 -0
- package/types/base/keyboardElement.d.ts.map +1 -0
- package/types/base/keyboardElement.js +1 -0
- package/types/base/labeledElement.d.ts +7 -0
- package/types/base/labeledElement.d.ts.map +1 -0
- package/types/base/labeledElement.js +1 -0
- package/utils/dataAttributes.d.ts +2 -1
- package/utils/dataAttributes.d.ts.map +1 -1
- package/utils/dataAttributes.js +5 -2
- package/utils/styles.d.ts +64 -8
- package/utils/styles.d.ts.map +1 -1
- package/utils/styles.js +93 -11
- package/utils/validation.js +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/accordion/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA4C,MAAM,OAAO,CAAC;AAQrE,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC;AAEpC,sBAAsB;AACtB,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/accordion/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA4C,MAAM,OAAO,CAAC;AAQrE,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC;AAEpC,sBAAsB;AACtB,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAkEjC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
-
import { emptyFn, getClassName,
|
|
3
|
+
import { emptyFn, getClassName, isNotNullish } from "@bodynarf/utils";
|
|
4
4
|
import { ElementSize } from "../../../types";
|
|
5
|
-
import { mapDataAttributes } from "../../../utils";
|
|
5
|
+
import { getElementColorClassName, getSizeClassName, mapDataAttributes } from "../../../utils";
|
|
6
6
|
import Icon from "../../icon";
|
|
7
7
|
import "./style.scss";
|
|
8
8
|
/** Accordion panel */
|
|
@@ -12,7 +12,7 @@ const Accordion = ({ children, caption, style, size = ElementSize.Normal, defaul
|
|
|
12
12
|
const [maxHeight, setMaxHeight] = useState(defaultExpanded ? undefined : 0);
|
|
13
13
|
const toggleCollapse = useCallback(() => setMaxHeight(isExpanded ? 0 : expandablePanelRef.current.scrollHeight), [isExpanded]);
|
|
14
14
|
useEffect(() => {
|
|
15
|
-
if (defaultExpanded &&
|
|
15
|
+
if (defaultExpanded && isNotNullish(expandablePanelRef.current)) {
|
|
16
16
|
setMaxHeight(expandablePanelRef.current.scrollHeight);
|
|
17
17
|
}
|
|
18
18
|
}, [defaultExpanded, size]);
|
|
@@ -21,13 +21,11 @@ const Accordion = ({ children, caption, style, size = ElementSize.Normal, defaul
|
|
|
21
21
|
const elClassName = getClassName([
|
|
22
22
|
"bbr-accordion",
|
|
23
23
|
"message",
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
getElementColorClassName(style),
|
|
25
|
+
getSizeClassName(size),
|
|
26
26
|
className,
|
|
27
27
|
]);
|
|
28
|
-
const dataAttributes =
|
|
29
|
-
|
|
30
|
-
: mapDataAttributes(data);
|
|
31
|
-
return (_jsxs("article", { className: elClassName, "aria-expanded": isExpanded, ...dataAttributes, children: [_jsxs("div", { className: "message-header is-unselectable", onClick: toggleCollapse, children: [_jsx("span", { title: title, children: caption }), _jsx(Icon, { name: "arrow-down", size: size })] }), _jsx("div", { className: "message-body", ref: expandablePanelRef, style: { maxHeight: `${maxHeight}px` }, children: _jsx("div", { className: "message-body__content", children: children }) })] }));
|
|
28
|
+
const dataAttributes = mapDataAttributes(data);
|
|
29
|
+
return (_jsxs("article", { ...dataAttributes, className: elClassName, "aria-expanded": isExpanded, children: [_jsxs("div", { onClick: toggleCollapse, className: "message-header is-unselectable", children: [_jsx("span", { title: title, children: caption }), _jsx(Icon, { size: size, name: "arrow-down" })] }), _jsx("div", { className: "message-body", ref: expandablePanelRef, style: { maxHeight: `${maxHeight}px` }, children: _jsx("div", { className: "message-body__content", children: children }) })] }));
|
|
32
30
|
};
|
|
33
31
|
export default Accordion;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseElementProps, ElementColor, ElementSize } from "../../types";
|
|
2
2
|
/** Accordion panel props type */
|
|
3
|
-
export
|
|
3
|
+
export type AccordionProps = BaseElementProps & {
|
|
4
4
|
/** Content that should be collapsed inside */
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
/** Collapsible panel caption */
|
|
@@ -13,5 +13,5 @@ export interface AccordionProps extends BaseElementProps {
|
|
|
13
13
|
style?: ElementColor;
|
|
14
14
|
/** Extra handler for toggling visibility. Doesn't affect component logic */
|
|
15
15
|
onToggle?: (collapsed: boolean) => void;
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/accordion/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzE,iCAAiC;AACjC,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/accordion/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzE,iCAAiC;AACjC,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG;IAC5C,8CAA8C;IAC9C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAEhB,6BAA6B;IAC7B,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,iBAAiB;IACjB,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,YAAY;IACZ,KAAK,CAAC,EAAE,YAAY,CAAC;IAErB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC3C,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseElementProps, ElementIcon } from "../../types";
|
|
2
2
|
/**
|
|
3
3
|
* Anchor component props type
|
|
4
|
-
* @deprecated Since v1.
|
|
4
|
+
* @deprecated Since v1.12.0. Use html element with custom formatting
|
|
5
5
|
*/
|
|
6
6
|
export interface AnchorProps extends BaseElementProps {
|
|
7
7
|
/** Configuration od inner icon */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/breadcrumbs/component/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAa,MAAM,OAAO,CAAC;AAQtC,OAAO,EAAc,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAIlD;;;EAGE;AACF,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/breadcrumbs/component/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAa,MAAM,OAAO,CAAC;AAQtC,OAAO,EAAc,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAIlD;;;EAGE;AACF,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CA0CrC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getClassName,
|
|
3
|
-
import { getPositionClassName, mapDataAttributes } from "../../../utils";
|
|
2
|
+
import { getClassName, isNullish } from "@bodynarf/utils";
|
|
3
|
+
import { getPositionClassName, getSizeClassName, mapDataAttributes } from "../../../utils";
|
|
4
4
|
import { ElementPosition, ElementSize } from "../../../types";
|
|
5
5
|
import Icon from "../../icon";
|
|
6
|
-
const
|
|
6
|
+
const DefaultElementGenerator = ((bc) => _jsx(BreadCrumbItem, { item: bc }));
|
|
7
7
|
/**
|
|
8
8
|
* Breadcrumbs navigation panel
|
|
9
9
|
* @description If items are not specified, an empty component will be displayed.
|
|
10
10
|
*/
|
|
11
|
-
const BreadCrumbs = ({ items, position = ElementPosition.Left, size = ElementSize.Normal, separator = "arrow", elementGenerator =
|
|
11
|
+
const BreadCrumbs = ({ items, position = ElementPosition.Left, size = ElementSize.Normal, separator = "arrow", elementGenerator = DefaultElementGenerator, className, title, data, }) => {
|
|
12
12
|
if (items.length <= 1) {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
@@ -16,22 +16,20 @@ const BreadCrumbs = ({ items, position = ElementPosition.Left, size = ElementSiz
|
|
|
16
16
|
"bbr-breadcrumbs",
|
|
17
17
|
"breadcrumb",
|
|
18
18
|
className,
|
|
19
|
-
size
|
|
19
|
+
getSizeClassName(size),
|
|
20
20
|
`has-${separator}-separator`,
|
|
21
21
|
getPositionClassName(position),
|
|
22
22
|
]);
|
|
23
|
-
const dataAttributes =
|
|
24
|
-
|
|
25
|
-
: mapDataAttributes(data);
|
|
26
|
-
return (_jsx("nav", { className: elClassName, "aria-label": "breadcrumbs", title: title, ...dataAttributes, children: _jsx("ul", { children: items.map((breadCrumb, i, a) => _jsx("li", { className: i === a.length - 1 ? "is-active" : undefined, children: elementGenerator(breadCrumb) }, breadCrumb.href ?? breadCrumb.path)) }) }));
|
|
23
|
+
const dataAttributes = mapDataAttributes(data);
|
|
24
|
+
return (_jsx("nav", { title: title, ...dataAttributes, className: elClassName, "aria-label": "breadcrumbs", children: _jsx("ul", { children: items.map((breadCrumb, i, a) => _jsx("li", { className: i === a.length - 1 ? "is-active" : undefined, children: elementGenerator(breadCrumb) }, breadCrumb.href ?? breadCrumb.path)) }) }));
|
|
27
25
|
};
|
|
28
26
|
export default BreadCrumbs;
|
|
29
27
|
/** Template for single breadcrumb */
|
|
30
28
|
const BreadCrumbItem = ({ item, icon }) => {
|
|
31
|
-
if (
|
|
29
|
+
if (isNullish(icon)) {
|
|
32
30
|
return (_jsx("a", { href: item.href ?? item.path, children: item.caption }));
|
|
33
31
|
}
|
|
34
|
-
if (icon
|
|
32
|
+
if (icon.position === ElementPosition.Right) {
|
|
35
33
|
return (_jsxs("a", { href: item.href ?? item.path, children: [item.caption, _jsx(Icon, { ...icon })] }));
|
|
36
34
|
}
|
|
37
35
|
return (_jsxs("a", { href: item.href ?? item.path, children: [_jsx(Icon, { ...icon }), item.caption] }));
|
|
@@ -2,18 +2,8 @@ import { ReactNode } from "react";
|
|
|
2
2
|
import { BaseElementProps, ElementIcon, ElementPosition, ElementSize } from "../../types";
|
|
3
3
|
/** Breadcrumb item */
|
|
4
4
|
export interface BreadCrumb {
|
|
5
|
-
/**
|
|
6
|
-
* Displayed text
|
|
7
|
-
* @deprecated Use `caption` instead
|
|
8
|
-
*/
|
|
9
|
-
title?: string;
|
|
10
5
|
/** Displayable caption */
|
|
11
6
|
caption: string;
|
|
12
|
-
/**
|
|
13
|
-
* Page address
|
|
14
|
-
* @deprecated Since v1.2.0 Use `href`
|
|
15
|
-
*/
|
|
16
|
-
path?: string;
|
|
17
7
|
/** Link address */
|
|
18
8
|
href: string;
|
|
19
9
|
/**
|
|
@@ -23,11 +13,27 @@ export interface BreadCrumb {
|
|
|
23
13
|
active?: boolean;
|
|
24
14
|
/** Bootstrap icon class name */
|
|
25
15
|
icon?: ElementIcon;
|
|
16
|
+
/**
|
|
17
|
+
* Displayed text
|
|
18
|
+
* @deprecated Use `caption` instead
|
|
19
|
+
*/
|
|
20
|
+
title?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Page address
|
|
23
|
+
* @deprecated Since v1.2.0 Use `href`
|
|
24
|
+
*/
|
|
25
|
+
path?: string;
|
|
26
26
|
}
|
|
27
27
|
/** Breadcrumbs component props type */
|
|
28
28
|
export type BreadcrumbsProps = BaseElementProps & {
|
|
29
29
|
/** Breadcrumbs items */
|
|
30
30
|
items: Array<BreadCrumb>;
|
|
31
|
+
/** Panel size */
|
|
32
|
+
size?: ElementSize;
|
|
33
|
+
/** Items position */
|
|
34
|
+
position?: ElementPosition;
|
|
35
|
+
/** Items separator. By default `arrow` */
|
|
36
|
+
separator?: "arrow" | "bullet" | "dot" | "succeeds";
|
|
31
37
|
/**
|
|
32
38
|
* Function that generates each element
|
|
33
39
|
* @example
|
|
@@ -45,11 +51,5 @@ export type BreadcrumbsProps = BaseElementProps & {
|
|
|
45
51
|
* }
|
|
46
52
|
*/
|
|
47
53
|
elementGenerator?: (bc: BreadCrumb) => ReactNode;
|
|
48
|
-
/** Panel size */
|
|
49
|
-
size?: ElementSize;
|
|
50
|
-
/** Items position */
|
|
51
|
-
position?: ElementPosition;
|
|
52
|
-
/** Items separator. By default `arrow` */
|
|
53
|
-
separator?: "arrow" | "bullet" | "dot" | "succeeds";
|
|
54
54
|
};
|
|
55
55
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/breadcrumbs/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzF,sBAAsB;AACtB,MAAM,WAAW,UAAU;IACvB
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/breadcrumbs/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzF,sBAAsB;AACtB,MAAM,WAAW,UAAU;IACvB,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAEhB,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,gCAAgC;IAChC,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,uCAAuC;AACvC,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG;IAC9C,wBAAwB;IACxB,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAEzB,iBAAiB;IACjB,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,eAAe,CAAC;IAE3B,0CAA0C;IAC1C,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,UAAU,CAAC;IAEpD;;;;;;;;;;;;;;;MAeE;IACF,gBAAgB,CAAC,EAAE,CAAC,EAAE,EAAE,UAAU,KAAK,SAAS,CAAC;CACpD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { isNullOrEmpty,
|
|
2
|
+
import { isNullOrEmpty, isNotNullish, isNullish, getClassName } from "@bodynarf/utils";
|
|
3
3
|
import { getSizeClassName } from "../../../utils";
|
|
4
4
|
import "./style.scss";
|
|
5
5
|
import ButtonWithIcon from "../components/buttonWithIcon";
|
|
@@ -9,7 +9,7 @@ import SimpleButton from "../components/simpleButton";
|
|
|
9
9
|
* @throws Caption is not defined and icon configuration is not defined at the same time
|
|
10
10
|
*/
|
|
11
11
|
const Button = (props) => {
|
|
12
|
-
if (isNullOrEmpty(props.caption) &&
|
|
12
|
+
if (isNullOrEmpty(props.caption) && isNullish(props.icon)) {
|
|
13
13
|
throw new Error("No button content provided.");
|
|
14
14
|
}
|
|
15
15
|
const { light = false, outlined = false, rounded = false, isLoading = false, static: isStatic = false } = props;
|
|
@@ -25,7 +25,7 @@ const Button = (props) => {
|
|
|
25
25
|
isLoading ? "is-loading" : "",
|
|
26
26
|
isStatic ? "is-static" : "",
|
|
27
27
|
]);
|
|
28
|
-
if (
|
|
28
|
+
if (isNotNullish(props.icon)) {
|
|
29
29
|
return (_jsx(ButtonWithIcon, { ...props, icon: props.icon, className: className }));
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/button/components/buttonWithIcon/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAQ3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAE5C,iCAAiC;AACjC,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/button/components/buttonWithIcon/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAQ3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAE5C,iCAAiC;AACjC,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CA2D3C,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getClassName, isNullOrEmpty
|
|
2
|
+
import { getClassName, isNullOrEmpty } from "@bodynarf/utils";
|
|
3
3
|
import { ElementPosition } from "../../../../types";
|
|
4
4
|
import { mapDataAttributes } from "../../../../utils";
|
|
5
5
|
import Icon from "../../../icon";
|
|
@@ -16,12 +16,10 @@ const ButtonWithIcon = ({ className, disabled, onClick, caption, icon, title, da
|
|
|
16
16
|
className = isNullOrEmpty(caption)
|
|
17
17
|
? getClassName([className, "bbr-button--icon-only"])
|
|
18
18
|
: className;
|
|
19
|
-
const dataAttributes =
|
|
20
|
-
? undefined
|
|
21
|
-
: mapDataAttributes(data);
|
|
19
|
+
const dataAttributes = mapDataAttributes(data);
|
|
22
20
|
if (icon.position === ElementPosition.Right) {
|
|
23
|
-
return (_jsxs("button", { type: "button", onClick: onClick, disabled: disabled, className: className,
|
|
21
|
+
return (_jsxs("button", { type: "button", title: title, onClick: onClick, disabled: disabled, ...dataAttributes, className: className, children: [caption, _jsx(Icon, { ...icon, className: iconClassName })] }));
|
|
24
22
|
}
|
|
25
|
-
return (_jsxs("button", { type: "button", onClick: onClick, disabled: disabled, className: className,
|
|
23
|
+
return (_jsxs("button", { type: "button", title: title, onClick: onClick, disabled: disabled, ...dataAttributes, className: className, children: [_jsx(Icon, { ...icon, className: iconClassName }), caption] }));
|
|
26
24
|
};
|
|
27
25
|
export default ButtonWithIcon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/button/components/simpleButton/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/button/components/simpleButton/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,4CAA4C;AAC5C,QAAA,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAqBvC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { isNullOrUndefined } from "@bodynarf/utils";
|
|
3
2
|
import { mapDataAttributes } from "../../../../utils";
|
|
4
3
|
/** Simple button component, without icon */
|
|
5
4
|
const SimpleButton = ({ className, disabled, onClick, caption, title, data }) => {
|
|
6
|
-
const dataAttributes =
|
|
7
|
-
|
|
8
|
-
: mapDataAttributes(data);
|
|
9
|
-
return (_jsx("button", { type: "button", onClick: onClick, disabled: disabled, className: className, title: title, ...dataAttributes, children: caption }));
|
|
5
|
+
const dataAttributes = mapDataAttributes(data);
|
|
6
|
+
return (_jsx("button", { type: "button", title: title, onClick: onClick, disabled: disabled, ...dataAttributes, className: className, children: caption }));
|
|
10
7
|
};
|
|
11
8
|
export default SimpleButton;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { BaseElementProps, ClickableElement, ElementIcon, ElementSize } from "../../types";
|
|
2
2
|
export type ButtonProps = BaseElementProps & ClickableElement & {
|
|
3
|
+
/** Style */
|
|
4
|
+
style: ButtonStyle;
|
|
3
5
|
/** Button displaying text */
|
|
4
6
|
caption?: string;
|
|
5
7
|
/**
|
|
@@ -7,8 +9,6 @@ export type ButtonProps = BaseElementProps & ClickableElement & {
|
|
|
7
9
|
* @deprecated Use `style` prop instead
|
|
8
10
|
*/
|
|
9
11
|
type?: ButtonType;
|
|
10
|
-
/** Style */
|
|
11
|
-
style: ButtonStyle;
|
|
12
12
|
/** Configuration of inner icon */
|
|
13
13
|
icon?: ElementIcon;
|
|
14
14
|
/** Button size */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/button/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE1F,MAAM,MAAM,WAAW,GACjB,gBAAgB,GAChB,gBAAgB,GAChB;IACE,6BAA6B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/button/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE1F,MAAM,MAAM,WAAW,GACjB,gBAAgB,GAChB,gBAAgB,GAChB;IACE,YAAY;IACZ,KAAK,EAAE,WAAW,CAAC;IAEnB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB,kCAAkC;IAClC,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,mBAAmB;IACnB,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,wCAAwC;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,gCAAgC;IAChC,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEN;;;GAGG;AACH,MAAM,MAAM,UAAU,GAChB,SAAS,CAAC,yBAAyB,GACnC,SAAS,CAAC,4BAA4B,GACtC,MAAM,CAAC,yBAAyB,GAChC,MAAM,CAAC,sBAAsB,GAC7B,SAAS,CAAC,mBAAmB,GAC7B,SAAS,CAAC,oBAAoB,GAC9B,QAAQ,CAAC,iBAAiB,GAC1B,OAAO,CAAC,mBAAmB,GAC3B,OAAO,CAAC,wBAAwB,GAChC,MAAM,CAAC,uBAAuB,GAC9B,OAAO,CAAC,mBAAmB,GAC3B,MAAM,CAAC,sCAAsC,GAC7C,OAAO,CAAC,kDAAkD,CAC3D;AAEL,+BAA+B;AAC/B,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,GAAG;IAC7D,uBAAuB;IACvB,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG;IAClD,yBAAyB;IACzB,IAAI,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,wBAAwB;AACxB,oBAAY,WAAW;IACnB,yBAAyB;IACzB,OAAO,YAAY;IAEnB,4BAA4B;IAC5B,OAAO,YAAY;IAEnB,yBAAyB;IACzB,IAAI,SAAS;IAEb,sBAAsB;IACtB,IAAI,SAAS;IAEb,mBAAmB;IACnB,OAAO,YAAY;IAEnB,oBAAoB;IACpB,OAAO,YAAY;IAEnB,iBAAiB;IACjB,MAAM,WAAW;IAEjB,mBAAmB;IACnB,KAAK,UAAU;IAEf,wBAAwB;IACxB,KAAK,UAAU;IAEf,uBAAuB;IACvB,IAAI,SAAS;IAEb,mBAAmB;IACnB,KAAK,UAAU;IAEf,sCAAsC;IACtC,IAAI,SAAS;IAEb,kDAAkD;IAClD,KAAK,UAAU;CAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/dropdown/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAInC,yBAAyB;AACzB,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/dropdown/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAInC,yBAAyB;AACzB,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAU/B,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { isNullish } from "@bodynarf/utils";
|
|
3
3
|
import "./style.scss";
|
|
4
4
|
import DropdownWithLabel from "../components/withLabel";
|
|
5
5
|
import DropdownCompact from "../components/compact";
|
|
6
6
|
/** Dropdown component */
|
|
7
7
|
const Dropdown = (props) => {
|
|
8
|
-
|
|
8
|
+
// eslint-disable-next-line react/destructuring-assignment
|
|
9
|
+
return isNullish(props.label)
|
|
9
10
|
? _jsx(DropdownCompact, { ...props })
|
|
10
|
-
: _jsx(DropdownWithLabel, { ...props
|
|
11
|
+
: (_jsx(DropdownWithLabel, { ...props,
|
|
12
|
+
// eslint-disable-next-line react/destructuring-assignment
|
|
13
|
+
label: props.label }));
|
|
11
14
|
};
|
|
12
15
|
export default Dropdown;
|
|
@@ -93,6 +93,19 @@
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
&.is-up {
|
|
97
|
+
.dropdown-menu {
|
|
98
|
+
top: auto;
|
|
99
|
+
bottom: 100%;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
&.is-active {
|
|
103
|
+
.bbr-dropdown__label .bbr-icon.bi-arrow-down::before {
|
|
104
|
+
transform: rotate(360deg);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
96
109
|
&--height-default {
|
|
97
110
|
.dropdown-menu .dropdown-content {
|
|
98
111
|
max-height: 15vw;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/dropdown/components/compact/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4C,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/dropdown/components/compact/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4C,EAAE,EAAmB,MAAM,OAAO,CAAC;AAQtF,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAItC,sCAAsC;AACtC,KAAK,oBAAoB,GAAG,aAAa,GAAG;IACxC,yCAAyC;IACzC,EAAE,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,uCAAuC;AACvC,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CA2L7C,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useId, useState, useMemo } from "react";
|
|
2
|
+
import { useCallback, useId, useState, useMemo, useRef } from "react";
|
|
3
3
|
import { getClassName, isNullOrEmpty, isNullish } from "@bodynarf/utils";
|
|
4
4
|
import { getStyleClassName, mapDataAttributes } from "../../../../utils";
|
|
5
5
|
import { useComponentOutsideClick } from "../../../../hooks";
|
|
@@ -10,8 +10,11 @@ import DropdownLabel from "../../components/label";
|
|
|
10
10
|
const DropdownCompact = ({ items, value, onSelect, hideOnOuterClick = true, listMaxHeight, placeholder = "", noDataText = "No items found", noDataByQuery = "No items found by specified search", compact = false, disabled = false, deselectable = false, searchable = false, validationState, className, title, data, hint, id: propsId, }) => {
|
|
11
11
|
const generatedId = useId();
|
|
12
12
|
const id = propsId ?? generatedId;
|
|
13
|
+
const containerRef = useRef(null);
|
|
13
14
|
const [isListVisible, setListVisible] = useState(false);
|
|
14
15
|
const [searchValue, setSearchValue] = useState("");
|
|
16
|
+
const [isOpenUp, setIsOpenUp] = useState(false);
|
|
17
|
+
const filteredItems = useMemo(() => items.filter(({ displayValue }) => displayValue.toLocaleLowerCase().includes(searchValue.toLocaleLowerCase())), [items, searchValue]);
|
|
15
18
|
const onItemClick = useCallback((event) => {
|
|
16
19
|
if (disabled) {
|
|
17
20
|
return;
|
|
@@ -36,6 +39,14 @@ const DropdownCompact = ({ items, value, onSelect, hideOnOuterClick = true, list
|
|
|
36
39
|
setSearchValue("");
|
|
37
40
|
setListVisible(false);
|
|
38
41
|
}, [setListVisible, value, items, onSelect, disabled]);
|
|
42
|
+
const shouldOpenUpward = useCallback((element) => {
|
|
43
|
+
const rect = element.getBoundingClientRect();
|
|
44
|
+
const spaceBelow = window.innerHeight - rect.bottom;
|
|
45
|
+
const spaceAbove = rect.top;
|
|
46
|
+
const estimatedHeight = Math.min(items.length, 8) * 33 // 33 = 21px item height + 12px padding, 8 - max items in list
|
|
47
|
+
+ 20; // 16px - padding top-bottom + 4px margin-top
|
|
48
|
+
return spaceBelow < estimatedHeight && spaceAbove > spaceBelow;
|
|
49
|
+
}, [items.length]);
|
|
39
50
|
const onLabelClick = useCallback((event) => {
|
|
40
51
|
if (disabled) {
|
|
41
52
|
return;
|
|
@@ -49,9 +60,13 @@ const DropdownCompact = ({ items, value, onSelect, hideOnOuterClick = true, list
|
|
|
49
60
|
setSearchValue("");
|
|
50
61
|
}
|
|
51
62
|
else {
|
|
63
|
+
if (containerRef.current) {
|
|
64
|
+
const openUp = shouldOpenUpward(containerRef.current);
|
|
65
|
+
setIsOpenUp(openUp);
|
|
66
|
+
}
|
|
52
67
|
setListVisible(state => !state);
|
|
53
68
|
}
|
|
54
|
-
}, [onSelect, setListVisible, disabled]);
|
|
69
|
+
}, [onSelect, setListVisible, disabled, shouldOpenUpward]);
|
|
55
70
|
const onSearchChange = useCallback((value) => {
|
|
56
71
|
setSearchValue(value);
|
|
57
72
|
onSelect(undefined);
|
|
@@ -64,17 +79,13 @@ const DropdownCompact = ({ items, value, onSelect, hideOnOuterClick = true, list
|
|
|
64
79
|
compact ? "bbr-dropdown--compact" : "",
|
|
65
80
|
isListVisible ? "is-active" : "",
|
|
66
81
|
isNullOrEmpty(listMaxHeight) ? "bbr-dropdown--height-default" : "",
|
|
82
|
+
isOpenUp ? "is-up" : "",
|
|
67
83
|
"dropdown",
|
|
68
84
|
]);
|
|
69
85
|
const labelComponentClassName = getStyleClassName(undefined, validationState);
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: classNames, "data-dropdown-id": id, title: title, ...dataAttributes, children: [_jsx(DropdownLabel, { selectedItem: value, caption: placeholder, onClick: onLabelClick, searchable: searchable, lastSearch: searchValue, deselectable: deselectable, isListVisible: isListVisible, onSearchChange: onSearchChange, className: labelComponentClassName }), _jsx("div", { className: "dropdown-menu", children: filteredItems.length > 0
|
|
75
|
-
?
|
|
76
|
-
_jsx("ul", { className: "dropdown-content", style: { maxHeight: listMaxHeight }, children: filteredItems.map(item => _jsx(DropdownItem, { item: item, onClick: onItemClick, selected: value?.value === item.value }, item.id)) })
|
|
77
|
-
:
|
|
78
|
-
_jsx("span", { className: "dropdown-content dropdown-item is-italic has-text-grey", children: isNullOrEmpty(searchValue) ? noDataText : noDataByQuery }) })] }, id), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
|
|
86
|
+
const dataAttributes = mapDataAttributes(data);
|
|
87
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { title: title, ref: containerRef, ...dataAttributes, "data-dropdown-id": id, className: classNames, children: [_jsx(DropdownLabel, { selectedItem: value, caption: placeholder, onClick: onLabelClick, searchable: searchable, lastSearch: searchValue, deselectable: deselectable, isListVisible: isListVisible, onSearchChange: onSearchChange, className: labelComponentClassName }), _jsx("div", { className: "dropdown-menu", children: filteredItems.length > 0
|
|
88
|
+
? (_jsx("ul", { className: "dropdown-content", style: { maxHeight: listMaxHeight }, children: filteredItems.map(item => _jsx(DropdownItem, { item: item, onClick: onItemClick, selected: value?.value === item.value }, item.id)) }))
|
|
89
|
+
: (_jsx("span", { className: "dropdown-content dropdown-item is-italic has-text-grey", children: isNullOrEmpty(searchValue) ? noDataText : noDataByQuery })) })] }, id), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
|
|
79
90
|
};
|
|
80
91
|
export default DropdownCompact;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getClassName,
|
|
2
|
+
import { getClassName, isNotNullish } from "@bodynarf/utils";
|
|
3
3
|
import { ElementPosition } from "../../../../types";
|
|
4
4
|
import Icon from "../../../icon/component";
|
|
5
5
|
/** Single item in dropdown component */
|
|
6
6
|
const DropdownItem = ({ item, selected, onClick }) => {
|
|
7
|
-
if (
|
|
8
|
-
return (_jsx(DropdownItemWithIcon, { item: item,
|
|
7
|
+
if (isNotNullish(item.icon)) {
|
|
8
|
+
return (_jsx(DropdownItemWithIcon, { item: item, onClick: onClick, selected: selected }));
|
|
9
9
|
}
|
|
10
10
|
const className = getClassName([
|
|
11
11
|
"bbr-dropdown-item",
|
|
@@ -13,7 +13,7 @@ const DropdownItem = ({ item, selected, onClick }) => {
|
|
|
13
13
|
selected ? "is-active" : "",
|
|
14
14
|
"is-flex is-align-items-center",
|
|
15
15
|
]);
|
|
16
|
-
return (_jsx("li", { onClick: onClick, className: className, "data-dropdown-item-value": item.value,
|
|
16
|
+
return (_jsx("li", { onClick: onClick, title: item.title, className: className, "data-dropdown-item-value": item.value, children: item.displayValue }, item.id));
|
|
17
17
|
};
|
|
18
18
|
export default DropdownItem;
|
|
19
19
|
/** Single item in dropdown component with icon */
|
|
@@ -33,7 +33,7 @@ const DropdownItemWithIcon = ({ item, selected, onClick }) => {
|
|
|
33
33
|
: "bbr-icon--left",
|
|
34
34
|
]);
|
|
35
35
|
if (icon.position === ElementPosition.Right) {
|
|
36
|
-
return (_jsxs("li", { onClick: onClick, className: className, "data-dropdown-item-value": item.value,
|
|
36
|
+
return (_jsxs("li", { onClick: onClick, title: item.title, className: className, "data-dropdown-item-value": item.value, children: [item.displayValue, _jsx(Icon, { name: icon.name, size: icon.size, className: iconClassName })] }, item.id));
|
|
37
37
|
}
|
|
38
|
-
return (_jsxs("li", { onClick: onClick, className: className, "data-dropdown-item-value": item.value,
|
|
38
|
+
return (_jsxs("li", { onClick: onClick, title: item.title, className: className, "data-dropdown-item-value": item.value, children: [_jsx(Icon, { name: icon.name, size: icon.size, className: iconClassName }), item.displayValue] }, item.id));
|
|
39
39
|
};
|
|
@@ -8,16 +8,16 @@ export type DropdownLabelProps = {
|
|
|
8
8
|
deselectable: boolean;
|
|
9
9
|
/** Is search through items enabled */
|
|
10
10
|
searchable: boolean;
|
|
11
|
+
/** Last user search */
|
|
12
|
+
lastSearch: string;
|
|
13
|
+
/** Is items list visible */
|
|
14
|
+
isListVisible: boolean;
|
|
11
15
|
/** Selected item */
|
|
12
16
|
selectedItem?: SelectableItem;
|
|
13
17
|
/** Element classnames */
|
|
14
18
|
className?: string;
|
|
15
19
|
/** Click handler*/
|
|
16
20
|
onClick: (event: MouseEvent<HTMLElement>) => void;
|
|
17
|
-
/** Last user search */
|
|
18
|
-
lastSearch: string;
|
|
19
|
-
/** Is items list visible */
|
|
20
|
-
isListVisible: boolean;
|
|
21
21
|
/** Handler of search value change by user */
|
|
22
22
|
onSearchChange: (value: string) => void;
|
|
23
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/dropdown/components/label/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAMjD,oCAAoC;AACpC,MAAM,MAAM,kBAAkB,GAAG;IAC7B,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAEhB,wBAAwB;IACxB,YAAY,EAAE,OAAO,CAAC;IAEtB,sCAAsC;IACtC,UAAU,EAAE,OAAO,CAAC;IAEpB,oBAAoB;IACpB,YAAY,CAAC,EAAE,cAAc,CAAC;IAE9B,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,mBAAmB;IACnB,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAElD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/dropdown/components/label/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAMjD,oCAAoC;AACpC,MAAM,MAAM,kBAAkB,GAAG;IAC7B,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAEhB,wBAAwB;IACxB,YAAY,EAAE,OAAO,CAAC;IAEtB,sCAAsC;IACtC,UAAU,EAAE,OAAO,CAAC;IAEpB,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAC;IAEnB,4BAA4B;IAC5B,aAAa,EAAE,OAAO,CAAC;IAEvB,oBAAoB;IACpB,YAAY,CAAC,EAAE,cAAc,CAAC;IAE9B,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,mBAAmB;IACnB,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAElD,6CAA6C;IAC7C,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF,sBAAsB;AACtB,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAwCzC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { isNullish } from "@bodynarf/utils";
|
|
3
3
|
import SelectedItemLabel from "../components/selected";
|
|
4
4
|
import EmptyLabel from "../components/empty";
|
|
5
5
|
import DropdownLabelWithSearch from "../components/withSearch";
|
|
6
6
|
/** Label component */
|
|
7
7
|
const DropdownLabel = ({ caption, selectedItem, onClick, deselectable, className, searchable, onSearchChange, lastSearch, isListVisible, }) => {
|
|
8
8
|
if (searchable) {
|
|
9
|
-
return (_jsx(DropdownLabelWithSearch, { caption: caption, onClick: onClick, className: className,
|
|
9
|
+
return (_jsx(DropdownLabelWithSearch, { caption: caption, onClick: onClick, className: className, lastSearch: lastSearch, deselectable: deselectable, selectedItem: selectedItem, isListVisible: isListVisible, onSearchChange: onSearchChange }));
|
|
10
10
|
}
|
|
11
|
-
if (
|
|
11
|
+
if (isNullish(selectedItem)) {
|
|
12
12
|
return (_jsx(EmptyLabel, { caption: caption, onClick: onClick, className: className }));
|
|
13
13
|
}
|
|
14
|
-
return (_jsx(SelectedItemLabel, {
|
|
14
|
+
return (_jsx(SelectedItemLabel, { onClick: onClick, className: className, deselectable: deselectable, selectedItem: selectedItem }));
|
|
15
15
|
};
|
|
16
16
|
export default DropdownLabel;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
2
|
import { DropdownLabelProps } from "../../component";
|
|
3
3
|
/** Props type of `SelectedItemLabel` */
|
|
4
|
-
type SelectedItemLabelProps = Pick<DropdownLabelProps, "
|
|
4
|
+
type SelectedItemLabelProps = Pick<DropdownLabelProps, "onClick" | "deselectable" | "className"> & Required<Pick<DropdownLabelProps, "selectedItem">>;
|
|
5
5
|
/** Dropdown label when item is selected */
|
|
6
6
|
declare const SelectedItemLabel: FC<SelectedItemLabelProps>;
|
|
7
7
|
export default SelectedItemLabel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/dropdown/components/label/components/selected/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAQ3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,wCAAwC;AACxC,KAAK,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/dropdown/components/label/components/selected/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAQ3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,wCAAwC;AACxC,KAAK,sBAAsB,GACrB,IAAI,CACF,kBAAkB,EAChB,SAAS,GACT,cAAc,GAAG,WAAW,CACjC,GACC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC,CAAC;AAEzD,2CAA2C;AAC3C,QAAA,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CA6CjD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getClassName,
|
|
2
|
+
import { getClassName, isNotNullish, isNullOrEmpty } from "@bodynarf/utils";
|
|
3
3
|
import { ElementSize } from "../../../../../../types";
|
|
4
4
|
import Icon from "../../../../../icon";
|
|
5
5
|
import SelectedItemLabelWithIcon from "../selectedWithIcon";
|
|
6
6
|
/** Dropdown label when item is selected */
|
|
7
7
|
const SelectedItemLabel = ({ selectedItem, onClick, deselectable, className, }) => {
|
|
8
|
-
if (
|
|
9
|
-
return (_jsx(SelectedItemLabelWithIcon, {
|
|
8
|
+
if (isNotNullish(selectedItem.icon)) {
|
|
9
|
+
return (_jsx(SelectedItemLabelWithIcon, { onClick: onClick, className: className, deselectable: deselectable, selectedItem: selectedItem }));
|
|
10
10
|
}
|
|
11
11
|
const elClassName = getClassName([
|
|
12
12
|
"button",
|
|
@@ -14,7 +14,7 @@ const SelectedItemLabel = ({ selectedItem, onClick, deselectable, className, })
|
|
|
14
14
|
"bbr-dropdown__label",
|
|
15
15
|
isNullOrEmpty(className) ? "" : `${className}--md`,
|
|
16
16
|
]);
|
|
17
|
-
return (_jsxs("label", {
|
|
18
|
-
_jsx(Icon, { name: "plus-lg", size: ElementSize.Medium }), _jsx("span", { className: deselectable ? "px-2" : "pr-2",
|
|
17
|
+
return (_jsxs("label", { onClick: onClick, className: elClassName, children: [!!deselectable &&
|
|
18
|
+
_jsx(Icon, { name: "plus-lg", size: ElementSize.Medium }), _jsx("span", { title: selectedItem.title, className: deselectable ? "px-2" : "pr-2", children: selectedItem.displayValue }), _jsx(Icon, { name: "arrow-down", size: ElementSize.Medium })] }));
|
|
19
19
|
};
|
|
20
20
|
export default SelectedItemLabel;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
2
|
import { DropdownLabelProps } from "../../component";
|
|
3
3
|
/** Props type of `SelectedItemLabelWithIcon` */
|
|
4
|
-
type SelectedItemLabelWithIconProps = Pick<DropdownLabelProps, "
|
|
4
|
+
type SelectedItemLabelWithIconProps = Pick<DropdownLabelProps, "onClick" | "deselectable" | "className"> & Required<Pick<DropdownLabelProps, "selectedItem">>;
|
|
5
5
|
/** Dropdown label when item is selected and it's have icon */
|
|
6
6
|
declare const SelectedItemLabelWithIcon: FC<SelectedItemLabelWithIconProps>;
|
|
7
7
|
export default SelectedItemLabelWithIcon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/dropdown/components/label/components/selectedWithIcon/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAO3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,gDAAgD;AAChD,KAAK,8BAA8B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/dropdown/components/label/components/selectedWithIcon/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAO3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,gDAAgD;AAChD,KAAK,8BAA8B,GAC7B,IAAI,CACF,kBAAkB,EAChB,SAAS,GACT,cAAc,GAAG,WAAW,CACjC,GACC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC,CAAC;AAEzD,8DAA8D;AAC9D,QAAA,MAAM,yBAAyB,EAAE,EAAE,CAAC,8BAA8B,CAgFjE,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
|
|
@@ -19,10 +19,10 @@ const SelectedItemLabelWithIcon = ({ selectedItem, onClick, deselectable, classN
|
|
|
19
19
|
"bbr-dropdown-item__icon"
|
|
20
20
|
]);
|
|
21
21
|
if (icon.position === ElementPosition.Right) {
|
|
22
|
-
return (_jsxs("label", {
|
|
23
|
-
_jsx(Icon, { name: "plus-lg", size: ElementSize.Medium }), _jsxs("span", { className: deselectable ? "px-2" : "pr-2",
|
|
22
|
+
return (_jsxs("label", { onClick: onClick, className: elClassName, children: [!!deselectable &&
|
|
23
|
+
_jsx(Icon, { name: "plus-lg", size: ElementSize.Medium }), _jsxs("span", { title: selectedItem.title, className: deselectable ? "px-2" : "pr-2", children: [selectedItem.displayValue, _jsx(Icon, { name: icon.name, size: icon.size, className: iconClassName })] }), _jsx(Icon, { name: "arrow-down", size: ElementSize.Medium })] }));
|
|
24
24
|
}
|
|
25
|
-
return (_jsxs("label", {
|
|
26
|
-
_jsx(Icon, { name: "plus-lg", size: ElementSize.Medium }), _jsxs("span", { className: deselectable ? "mx-2" : "mr-2",
|
|
25
|
+
return (_jsxs("label", { onClick: onClick, className: elClassName, children: [!!deselectable &&
|
|
26
|
+
_jsx(Icon, { name: "plus-lg", size: ElementSize.Medium }), _jsxs("span", { title: selectedItem.title, className: deselectable ? "mx-2" : "mr-2", children: [_jsx(Icon, { name: icon.name, size: icon.size, className: iconClassName }), selectedItem.displayValue] }), _jsx(Icon, { name: "arrow-down", size: ElementSize.Medium })] }));
|
|
27
27
|
};
|
|
28
28
|
export default SelectedItemLabelWithIcon;
|