@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,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
|
-
import { getClassName,
|
|
3
|
+
import { getClassName, isNotNullish, isNullOrEmpty } from "@bodynarf/utils";
|
|
4
4
|
import { ElementSize } from "../../../../../../types";
|
|
5
5
|
import Icon from "../../../../../icon";
|
|
6
6
|
import "./style.scss";
|
|
@@ -16,7 +16,7 @@ const DropdownLabelWithSearch = ({ caption, className, deselectable, lastSearch,
|
|
|
16
16
|
const onChange = useCallback((event) => onSearchChange(event.target.value), [onSearchChange]);
|
|
17
17
|
const inputClassName = getClassName([
|
|
18
18
|
"input",
|
|
19
|
-
deselectable &&
|
|
19
|
+
deselectable && isNotNullish(selectedItem) ? "px-2" : "pl-0"
|
|
20
20
|
]);
|
|
21
21
|
const containerOnClick = useCallback((event) => {
|
|
22
22
|
event.stopPropagation();
|
|
@@ -26,7 +26,7 @@ const DropdownLabelWithSearch = ({ caption, className, deselectable, lastSearch,
|
|
|
26
26
|
}
|
|
27
27
|
onClick(event);
|
|
28
28
|
}, [isListVisible, onClick]);
|
|
29
|
-
return (_jsxs("div", { className: elClassName, onClick: containerOnClick, children: [!!deselectable &&
|
|
29
|
+
return (_jsxs("div", { className: elClassName, onClick: containerOnClick, children: [!!deselectable && isNotNullish(selectedItem)
|
|
30
30
|
&&
|
|
31
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
32
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
+
import { BaseInputWithLabel } from "../../../../types";
|
|
2
3
|
import { DropdownProps } from "../..";
|
|
3
4
|
/** Dropdown component with label */
|
|
4
|
-
declare const DropdownWithLabel: FC<DropdownProps
|
|
5
|
+
declare const DropdownWithLabel: FC<BaseInputWithLabel<DropdownProps>>;
|
|
5
6
|
export default DropdownWithLabel;
|
|
6
7
|
//# 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":"AAAA,OAAO,EAAE,EAAE,EAAS,MAAM,OAAO,CAAC;
|
|
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;AAElC,OAAO,EAAE,kBAAkB,EAAe,MAAM,YAAY,CAAC;AAG7D,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC,oCAAoC;AACpC,QAAA,MAAM,iBAAiB,EAAE,EAAE,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAgB5D,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -6,6 +6,8 @@ import DropdownCompact from "../compact";
|
|
|
6
6
|
/** Dropdown component with label */
|
|
7
7
|
const DropdownWithLabel = (props) => {
|
|
8
8
|
const id = useId();
|
|
9
|
-
return (_jsx(LabelWrapper, { id: id,
|
|
9
|
+
return (_jsx(LabelWrapper, { id: id,
|
|
10
|
+
// eslint-disable-next-line react/destructuring-assignment
|
|
11
|
+
label: props.label, size: ElementSize.Normal, children: _jsx(DropdownCompact, { id: id, ...props }) }));
|
|
10
12
|
};
|
|
11
13
|
export default DropdownWithLabel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/file/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAAiC,MAAM,OAAO,CAAC;AAQvE,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAErC,oCAAoC;AACpC,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/file/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAAiC,MAAM,OAAO,CAAC;AAQvE,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAErC,oCAAoC;AACpC,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAoHnC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useRef, useState } from "react";
|
|
3
|
-
import { emptyFn, generateGuid, getClassName,
|
|
3
|
+
import { emptyFn, generateGuid, getClassName, isNotNullish } from "@bodynarf/utils";
|
|
4
4
|
import { ElementSize, ElementPosition } from "../../../types";
|
|
5
5
|
import { getSizeClassName, getStyleClassName, mapDataAttributes } from "../../../utils";
|
|
6
6
|
import Icon from "../../icon";
|
|
@@ -15,7 +15,7 @@ const FileUpload = ({ onValueChange = emptyFn, placeholder, name = generateGuid(
|
|
|
15
15
|
const onChange = useCallback((event) => {
|
|
16
16
|
const firstFile = event.target.files?.[0];
|
|
17
17
|
onValueChange(firstFile);
|
|
18
|
-
if (displayFileName &&
|
|
18
|
+
if (displayFileName && isNotNullish(firstFile)) {
|
|
19
19
|
const fileName = firstFile.name;
|
|
20
20
|
setSelectedFileName(fileName);
|
|
21
21
|
}
|
|
@@ -36,16 +36,14 @@ const FileUpload = ({ onValueChange = emptyFn, placeholder, name = generateGuid(
|
|
|
36
36
|
disabled ? "is-disabled" : "",
|
|
37
37
|
className,
|
|
38
38
|
]);
|
|
39
|
-
const dataAttributes =
|
|
40
|
-
|
|
41
|
-
: mapDataAttributes(data);
|
|
42
|
-
const shouldDisplayFileName = displayFileName && !isNullish(selectedFileName);
|
|
39
|
+
const dataAttributes = mapDataAttributes(data);
|
|
40
|
+
const shouldDisplayFileName = displayFileName && isNotNullish(selectedFileName);
|
|
43
41
|
return (_jsxs("div", { className: containerClassName, children: [!!shouldDisplayFileName && alignment === ElementPosition.Right
|
|
44
42
|
&&
|
|
45
|
-
_jsx(Icon, { name: "x-lg", className: "file-clear",
|
|
43
|
+
_jsx(Icon, { name: "x-lg", size: size, className: "file-clear", onClick: onClearClick, title: clearSelectionTitle }), _jsxs("label", { className: "file-label", children: [_jsx("input", { id: name, type: "file", name: name, title: title, ref: inputRef, accept: accept, disabled: disabled, onChange: onChange, ...dataAttributes, className: "file-input", placeholder: placeholder }), _jsxs("span", { className: "file-cta", children: [_jsx("span", { className: "file-icon", children: _jsx(Icon, { size: size, name: "upload" }) }), _jsx("span", { className: "file-label", children: placeholder })] }), !!shouldDisplayFileName
|
|
46
44
|
&&
|
|
47
45
|
_jsx("span", { className: "file-name", title: selectedFileName, children: selectedFileName })] }), !!shouldDisplayFileName && alignment === ElementPosition.Left
|
|
48
46
|
&&
|
|
49
|
-
_jsx(Icon, { name: "x-lg", className: "file-clear",
|
|
47
|
+
_jsx(Icon, { name: "x-lg", size: size, className: "file-clear", onClick: onClearClick, title: clearSelectionTitle })] }));
|
|
50
48
|
};
|
|
51
49
|
export default FileUpload;
|
|
@@ -1 +1 @@
|
|
|
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;AAEtB,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC;;GAEG;AACH,QAAA,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,
|
|
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;AAEtB,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC;;GAEG;AACH,QAAA,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAyBvB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -15,9 +15,7 @@ const Icon = ({ name, size = ElementSize.Normal, className, title, data, onClick
|
|
|
15
15
|
getSizeClassName(size),
|
|
16
16
|
isNullish(onClick) ? undefined : "is-clickable"
|
|
17
17
|
]);
|
|
18
|
-
const dataAttributes =
|
|
19
|
-
|
|
20
|
-
: mapDataAttributes(data);
|
|
21
|
-
return (_jsx("i", { className: classNames, title: title, onClick: onClick, ...dataAttributes }));
|
|
18
|
+
const dataAttributes = mapDataAttributes(data);
|
|
19
|
+
return (_jsx("i", { title: title, onClick: onClick, ...dataAttributes, className: classNames }));
|
|
22
20
|
};
|
|
23
21
|
export default Icon;
|
package/components/index.d.ts
CHANGED
|
@@ -1,11 +1,43 @@
|
|
|
1
|
+
export { default as Accordion } from "./accordion";
|
|
1
2
|
export * from "./accordion";
|
|
3
|
+
export { default as Anchor } from "./anchor";
|
|
2
4
|
export * from "./anchor";
|
|
5
|
+
export { default as Breadcrumbs } from "./breadcrumbs";
|
|
6
|
+
export * from "./breadcrumbs";
|
|
7
|
+
export { default as Button } from "./button";
|
|
3
8
|
export * from "./button";
|
|
9
|
+
export { default as Dropdown } from "./dropdown";
|
|
4
10
|
export * from "./dropdown";
|
|
11
|
+
export { default as File } from "./file";
|
|
12
|
+
export * from "./file";
|
|
13
|
+
export { default as Icon } from "./icon";
|
|
5
14
|
export * from "./icon";
|
|
15
|
+
export { default as Multiselect } from "./multiselect";
|
|
16
|
+
export * from "./multiselect";
|
|
17
|
+
export { default as Paginator } from "./paginator";
|
|
6
18
|
export * from "./paginator";
|
|
19
|
+
export { default as Search } from "./search";
|
|
7
20
|
export * from "./search";
|
|
21
|
+
export { default as Table } from "./table";
|
|
22
|
+
export * from "./table";
|
|
23
|
+
export { default as Tabs } from "./tabs";
|
|
8
24
|
export * from "./tabs";
|
|
25
|
+
export { default as Tag } from "./tag";
|
|
9
26
|
export * from "./tag";
|
|
10
|
-
export
|
|
27
|
+
export { default as Progress } from "./progress";
|
|
28
|
+
export * from "./progress";
|
|
29
|
+
export { default as Checkbox } from "./primitives/checkbox";
|
|
30
|
+
export * from "./primitives/checkbox";
|
|
31
|
+
export { default as Color } from "./primitives/color";
|
|
32
|
+
export * from "./primitives/color";
|
|
33
|
+
export { default as Date } from "./primitives/date";
|
|
34
|
+
export * from "./primitives/date";
|
|
35
|
+
export { default as Multiline } from "./primitives/multiline";
|
|
36
|
+
export * from "./primitives/multiline";
|
|
37
|
+
export { default as NumberInput } from "./primitives/number";
|
|
38
|
+
export * from "./primitives/number";
|
|
39
|
+
export { default as Password } from "./primitives/password";
|
|
40
|
+
export * from "./primitives/password";
|
|
41
|
+
export { default as Text } from "./primitives/text";
|
|
42
|
+
export * from "./primitives/text";
|
|
11
43
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,cAAc,aAAa,CAAC;AAE5B,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,cAAc,QAAQ,CAAC;AAEvB,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,cAAc,QAAQ,CAAC;AAEvB,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,cAAc,aAAa,CAAC;AAE5B,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,cAAc,QAAQ,CAAC;AAEvB,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAC;AACvC,cAAc,OAAO,CAAC;AAGtB,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,cAAc,YAAY,CAAC;AAG3B,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,cAAc,uBAAuB,CAAC;AAEtC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACtD,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,cAAc,wBAAwB,CAAC;AAEvC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC7D,cAAc,qBAAqB,CAAC;AAEpC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,cAAc,uBAAuB,CAAC;AAEtC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,mBAAmB,CAAC"}
|
package/components/index.js
CHANGED
|
@@ -1,10 +1,44 @@
|
|
|
1
|
+
export { default as Accordion } from "./accordion";
|
|
1
2
|
export * from "./accordion";
|
|
3
|
+
export { default as Anchor } from "./anchor";
|
|
2
4
|
export * from "./anchor";
|
|
5
|
+
export { default as Breadcrumbs } from "./breadcrumbs";
|
|
6
|
+
export * from "./breadcrumbs";
|
|
7
|
+
export { default as Button } from "./button";
|
|
3
8
|
export * from "./button";
|
|
9
|
+
export { default as Dropdown } from "./dropdown";
|
|
4
10
|
export * from "./dropdown";
|
|
11
|
+
export { default as File } from "./file";
|
|
12
|
+
export * from "./file";
|
|
13
|
+
export { default as Icon } from "./icon";
|
|
5
14
|
export * from "./icon";
|
|
15
|
+
export { default as Multiselect } from "./multiselect";
|
|
16
|
+
export * from "./multiselect";
|
|
17
|
+
export { default as Paginator } from "./paginator";
|
|
6
18
|
export * from "./paginator";
|
|
19
|
+
export { default as Search } from "./search";
|
|
7
20
|
export * from "./search";
|
|
21
|
+
export { default as Table } from "./table";
|
|
22
|
+
export * from "./table";
|
|
23
|
+
export { default as Tabs } from "./tabs";
|
|
8
24
|
export * from "./tabs";
|
|
25
|
+
export { default as Tag } from "./tag";
|
|
9
26
|
export * from "./tag";
|
|
10
|
-
|
|
27
|
+
// Progress/Loader component
|
|
28
|
+
export { default as Progress } from "./progress";
|
|
29
|
+
export * from "./progress";
|
|
30
|
+
// Primitives
|
|
31
|
+
export { default as Checkbox } from "./primitives/checkbox";
|
|
32
|
+
export * from "./primitives/checkbox";
|
|
33
|
+
export { default as Color } from "./primitives/color";
|
|
34
|
+
export * from "./primitives/color";
|
|
35
|
+
export { default as Date } from "./primitives/date";
|
|
36
|
+
export * from "./primitives/date";
|
|
37
|
+
export { default as Multiline } from "./primitives/multiline";
|
|
38
|
+
export * from "./primitives/multiline";
|
|
39
|
+
export { default as NumberInput } from "./primitives/number";
|
|
40
|
+
export * from "./primitives/number";
|
|
41
|
+
export { default as Password } from "./primitives/password";
|
|
42
|
+
export * from "./primitives/password";
|
|
43
|
+
export { default as Text } from "./primitives/text";
|
|
44
|
+
export * from "./primitives/text";
|
|
@@ -1 +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,
|
|
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,CAYrC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { isNullish } from "@bodynarf/utils";
|
|
3
3
|
import "../../dropdown/component/style.scss";
|
|
4
4
|
import "./style.scss";
|
|
5
5
|
import MultiselectWithoutLabel from "../components/withoutLabel";
|
|
6
6
|
import MultiselectWithLabel from "../components/withLabel";
|
|
7
7
|
/** Multiselect component */
|
|
8
8
|
const Multiselect = (props) => {
|
|
9
|
-
|
|
9
|
+
// eslint-disable-next-line react/destructuring-assignment
|
|
10
|
+
return isNullish(props.label)
|
|
10
11
|
? _jsx(MultiselectWithoutLabel, { ...props })
|
|
11
|
-
: _jsx(MultiselectWithLabel, { ...props
|
|
12
|
+
: (_jsx(MultiselectWithLabel, { ...props,
|
|
13
|
+
// eslint-disable-next-line react/destructuring-assignment
|
|
14
|
+
label: props.label }));
|
|
12
15
|
};
|
|
13
16
|
export default Multiselect;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/multiselect/components/item/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAe,MAAM,OAAO,CAAC;AAQxC,OAAO,EAAE,eAAe,IAAI,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAEnF,6BAA6B;AAC7B,KAAK,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,EAAE,EAAE,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/multiselect/components/item/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAe,MAAM,OAAO,CAAC;AAQxC,OAAO,EAAE,eAAe,IAAI,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAEnF,6BAA6B;AAC7B,KAAK,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,EAAE,EAAE,CAAC,oBAAoB,CA0D7C,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
|
-
import { getClassName,
|
|
3
|
+
import { getClassName, isNotNullish } from "@bodynarf/utils";
|
|
4
4
|
import { ElementPosition } from "../../../../types";
|
|
5
5
|
import Icon from "../../../icon";
|
|
6
6
|
import Checkbox from "../../../primitives/checkbox";
|
|
@@ -15,7 +15,7 @@ const MultiselectItem = ({ item, selected, rootId, onItemClick, onChange, checkb
|
|
|
15
15
|
event.stopPropagation();
|
|
16
16
|
}
|
|
17
17
|
}, [item, onItemClick]);
|
|
18
|
-
if (
|
|
18
|
+
if (isNotNullish(item.icon)) {
|
|
19
19
|
return (_jsx(MultiselectItemWithIcon, { item: item, rootId: rootId, onChange: onChange, selected: selected, onItemClick: onItemClick }));
|
|
20
20
|
}
|
|
21
21
|
const className = getClassName([
|
|
@@ -24,7 +24,7 @@ const MultiselectItem = ({ item, selected, rootId, onItemClick, onChange, checkb
|
|
|
24
24
|
selected ? "is-active" : "",
|
|
25
25
|
"is-flex",
|
|
26
26
|
]);
|
|
27
|
-
return (_jsxs("li", {
|
|
27
|
+
return (_jsxs("li", { onClick: onClick, title: item.title, className: className, "data-dropdown-id": rootId, children: [_jsx(Checkbox, { ...checkboxConfig, defaultValue: selected, onValueChange: onChecked }, item.id + selected), item.displayValue] }));
|
|
28
28
|
};
|
|
29
29
|
export default MultiselectItem;
|
|
30
30
|
/** Single item in multiselect component with icon */
|
|
@@ -57,7 +57,7 @@ const MultiselectItemWithIcon = ({ item, selected, rootId, onChange, onItemClick
|
|
|
57
57
|
"mb-1"
|
|
58
58
|
]);
|
|
59
59
|
if (icon.position === ElementPosition.Right) {
|
|
60
|
-
return (_jsxs("li", { onClick: onClick,
|
|
60
|
+
return (_jsxs("li", { onClick: onClick, title: item.title, className: className, 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 })] }));
|
|
61
61
|
}
|
|
62
|
-
return (_jsxs("li", { onClick: onClick,
|
|
62
|
+
return (_jsxs("li", { onClick: onClick, title: item.title, className: className, "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] }));
|
|
63
63
|
};
|
|
@@ -11,6 +11,6 @@ const EmptyLabel = ({ caption, onClick, className, }) => {
|
|
|
11
11
|
isNullOrEmpty(className) ? "" : `${className}--md`,
|
|
12
12
|
"bbr-dropdown__label--default",
|
|
13
13
|
]);
|
|
14
|
-
return (_jsxs("label", {
|
|
14
|
+
return (_jsxs("label", { onClick: onClick, className: elClassName, children: [_jsx("span", { className: "mr-2", children: caption }), _jsx(Icon, { name: "arrow-down", size: ElementSize.Medium })] }));
|
|
15
15
|
};
|
|
16
16
|
export default EmptyLabel;
|
|
@@ -10,7 +10,7 @@ const NonEmptyMultiselectLabel = ({ onClick, deselectable, className, caption })
|
|
|
10
10
|
"bbr-dropdown__label",
|
|
11
11
|
isNullOrEmpty(className) ? "" : `${className}--md`,
|
|
12
12
|
]);
|
|
13
|
-
return (_jsxs("label", {
|
|
13
|
+
return (_jsxs("label", { onClick: onClick, className: elClassName, children: [!!deselectable &&
|
|
14
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
15
|
};
|
|
16
16
|
export default NonEmptyMultiselectLabel;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
+
import { BaseInputWithLabel } from "../../../../types";
|
|
2
3
|
import { MultiselectProps } from "../../types";
|
|
3
4
|
/** Multiselect component with label */
|
|
4
|
-
declare const MultiselectWithLabel: FC<MultiselectProps
|
|
5
|
+
declare const MultiselectWithLabel: FC<BaseInputWithLabel<MultiselectProps>>;
|
|
5
6
|
export default MultiselectWithLabel;
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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;
|
|
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;AAElC,OAAO,EAAE,kBAAkB,EAAe,MAAM,YAAY,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,uCAAuC;AACvC,QAAA,MAAM,oBAAoB,EAAE,EAAE,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAelE,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -6,6 +6,8 @@ import MultiselectWithoutLabel from "../withoutLabel";
|
|
|
6
6
|
/** Multiselect component with label */
|
|
7
7
|
const MultiselectWithLabel = (props) => {
|
|
8
8
|
const id = useId();
|
|
9
|
-
return (_jsx(LabelWrapper, { id: id,
|
|
9
|
+
return (_jsx(LabelWrapper, { id: id,
|
|
10
|
+
// eslint-disable-next-line react/destructuring-assignment
|
|
11
|
+
label: props.label, size: ElementSize.Normal, children: _jsx(MultiselectWithoutLabel, { ...props }) }));
|
|
10
12
|
};
|
|
11
13
|
export default MultiselectWithLabel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/multiselect/components/withoutLabel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/multiselect/components/withoutLabel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAoD,MAAM,OAAO,CAAC;AAU7E,OAAO,EAAE,gBAAgB,EAA2C,MAAM,aAAa,CAAC;AAIxF,8CAA8C;AAC9C,KAAK,4BAA4B,GAAG,gBAAgB,GAAG;IACnD,kCAAkC;IAClC,EAAE,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,QAAA,MAAM,uBAAuB,EAAE,EAAE,CAAC,4BAA4B,CAqK7D,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useId, useState } from "react";
|
|
3
|
-
import { getClassName, isNullOrEmpty,
|
|
2
|
+
import { useCallback, useId, useState, useRef } from "react";
|
|
3
|
+
import { getClassName, isNotNullish, isNullOrEmpty, isNullish } from "@bodynarf/utils";
|
|
4
4
|
import { ElementSize } from "../../../../types";
|
|
5
5
|
import { getStyleClassName, mapDataAttributes } from "../../../../utils";
|
|
6
6
|
import { useComponentOutsideClick } from "../../../../hooks";
|
|
@@ -11,12 +11,14 @@ import MultiselectLabel from "../label/component";
|
|
|
11
11
|
const MultiselectWithoutLabel = ({ items, onChange, onClear, hideOnOuterClick, listMaxHeight, placeholder = "", noDataText = "No items found", selectionCaption = "{0} items selected", noDataByQuery = "No items found by specified search", compact = false, disabled = false, searchable = true, validationState, className, title, data, hint, id: propsId, checkboxConfig, }) => {
|
|
12
12
|
const generatedId = useId();
|
|
13
13
|
const id = propsId ?? generatedId;
|
|
14
|
+
const containerRef = useRef(null);
|
|
14
15
|
const [isListVisible, setListVisible] = useState(false);
|
|
15
16
|
const [selectedItems, setSelectedItems] = useState(items
|
|
16
17
|
.filter(({ selected }) => selected)
|
|
17
18
|
.map(({ id }) => id)
|
|
18
19
|
??
|
|
19
20
|
[]);
|
|
21
|
+
const [isOpenUp, setIsOpenUp] = useState(false);
|
|
20
22
|
const onItemClick = useCallback((item) => {
|
|
21
23
|
const isItemSelected = selectedItems.includes(item.id);
|
|
22
24
|
setSelectedItems(x => isItemSelected
|
|
@@ -32,12 +34,20 @@ const MultiselectWithoutLabel = ({ items, onChange, onClear, hideOnOuterClick, l
|
|
|
32
34
|
item.selected = selected;
|
|
33
35
|
onChange(item, selected);
|
|
34
36
|
}, [onChange]);
|
|
37
|
+
const shouldOpenUpward = useCallback((element) => {
|
|
38
|
+
const rect = element.getBoundingClientRect();
|
|
39
|
+
const spaceBelow = window.innerHeight - rect.bottom;
|
|
40
|
+
const spaceAbove = rect.top;
|
|
41
|
+
const estimatedHeight = Math.min(items.length, 8) * 33 // 33 = 21px item height + 12px padding, 8 - max items in list
|
|
42
|
+
+ 20; // 16px - padding top-bottom + 4px margin-top
|
|
43
|
+
return spaceBelow < estimatedHeight && spaceAbove > spaceBelow;
|
|
44
|
+
}, [items.length]);
|
|
35
45
|
const onLabelClick = useCallback((event) => {
|
|
36
46
|
if (disabled) {
|
|
37
47
|
return;
|
|
38
48
|
}
|
|
39
49
|
const target = event.target;
|
|
40
|
-
if (
|
|
50
|
+
if (isNullish(target)) {
|
|
41
51
|
return;
|
|
42
52
|
}
|
|
43
53
|
if (target.classList.contains("bi-plus-lg")) {
|
|
@@ -45,9 +55,14 @@ const MultiselectWithoutLabel = ({ items, onChange, onClear, hideOnOuterClick, l
|
|
|
45
55
|
onClear?.();
|
|
46
56
|
}
|
|
47
57
|
else {
|
|
58
|
+
// Check if we should open upward
|
|
59
|
+
if (containerRef.current) {
|
|
60
|
+
const openUp = shouldOpenUpward(containerRef.current);
|
|
61
|
+
setIsOpenUp(openUp);
|
|
62
|
+
}
|
|
48
63
|
setListVisible(state => !state);
|
|
49
64
|
}
|
|
50
|
-
}, [onClear, setListVisible, disabled]);
|
|
65
|
+
}, [onClear, setListVisible, disabled, shouldOpenUpward]);
|
|
51
66
|
useComponentOutsideClick(`[data-dropdown-id="${id}"]`, isListVisible, () => setListVisible(false), hideOnOuterClick);
|
|
52
67
|
const classNames = getClassName([
|
|
53
68
|
"bbr-multiselect",
|
|
@@ -57,15 +72,14 @@ const MultiselectWithoutLabel = ({ items, onChange, onClear, hideOnOuterClick, l
|
|
|
57
72
|
compact ? "bbr-dropdown--compact" : "",
|
|
58
73
|
isListVisible ? "is-active" : "",
|
|
59
74
|
isNullOrEmpty(listMaxHeight) ? "bbr-dropdown--height-default" : "",
|
|
75
|
+
isOpenUp ? "is-up" : "",
|
|
60
76
|
"dropdown",
|
|
61
77
|
]);
|
|
62
78
|
const labelComponentClassName = getStyleClassName(undefined, validationState);
|
|
63
79
|
const selectedItemsCount = selectedItems.length;
|
|
64
|
-
const dataAttributes =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const deselectable = !isNullOrUndefined(onClear);
|
|
68
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: classNames, "data-dropdown-id": id, title: title, ...dataAttributes, children: [_jsx(MultiselectLabel, { caption: placeholder, onClick: onLabelClick, deselectable: deselectable, className: labelComponentClassName, selectionCaption: selectionCaption, selectedItemsCount: selectedItemsCount }), _jsx("div", { className: "dropdown-menu", children: _jsx(DropdownContent, { id: id, items: items, searchable: searchable, noDataText: noDataText, onItemClick: onItemClick, noDataByQuery: noDataByQuery, selectedItems: selectedItems, listMaxHeight: listMaxHeight, checkboxConfig: checkboxConfig, onItemSelectChange: onItemSelectChange }) })] }, id), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
|
|
80
|
+
const dataAttributes = mapDataAttributes(data);
|
|
81
|
+
const deselectable = isNotNullish(onClear);
|
|
82
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { title: title, ref: containerRef, ...dataAttributes, "data-dropdown-id": id, className: classNames, children: [_jsx(MultiselectLabel, { caption: placeholder, onClick: onLabelClick, deselectable: deselectable, className: labelComponentClassName, selectionCaption: selectionCaption, selectedItemsCount: selectedItemsCount }), _jsx("div", { className: "dropdown-menu", children: _jsx(DropdownContent, { id: id, items: items, searchable: searchable, noDataText: noDataText, onItemClick: onItemClick, noDataByQuery: noDataByQuery, selectedItems: selectedItems, listMaxHeight: listMaxHeight, checkboxConfig: checkboxConfig, onItemSelectChange: onItemSelectChange }) })] }, id), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
|
|
69
83
|
};
|
|
70
84
|
export default MultiselectWithoutLabel;
|
|
71
85
|
// eslint-disable-next-line react/no-multi-comp
|
|
@@ -9,6 +9,14 @@ export type MultiselectItem = SelectableItem & {
|
|
|
9
9
|
export type MultiselectProps = Omit<DropdownProps, "items" | "onSelect" | "value" | "deselectable"> & {
|
|
10
10
|
/** Items which can be selected */
|
|
11
11
|
items: Array<MultiselectItem>;
|
|
12
|
+
/**
|
|
13
|
+
* Caption for label when some items are selected
|
|
14
|
+
* @example selectionCaption: "selected: {0}"
|
|
15
|
+
* @description Supports only 1 string parameter for number of selected items. Default is `{0} items selected`
|
|
16
|
+
*/
|
|
17
|
+
selectionCaption?: string;
|
|
18
|
+
/** Customization for checkbox */
|
|
19
|
+
checkboxConfig?: Pick<CheckBoxProps, "block" | "className" | "data" | "fixBackgroundColor" | "hasBackgroundColor" | "style" | "withoutBorder" | "rounded">;
|
|
12
20
|
/**
|
|
13
21
|
* Handler of changing select state of item
|
|
14
22
|
* @description `item.selected` will be set by component
|
|
@@ -21,13 +29,5 @@ export type MultiselectProps = Omit<DropdownProps, "items" | "onSelect" | "value
|
|
|
21
29
|
* When no handler specified - clear selection cannot be performed
|
|
22
30
|
*/
|
|
23
31
|
onClear?: () => void;
|
|
24
|
-
/**
|
|
25
|
-
* Caption for label when some items are selected
|
|
26
|
-
* @example selectionCaption: "selected: {0}"
|
|
27
|
-
* @description Supports only 1 string parameter for number of selected items. Default is `{0} items selected`
|
|
28
|
-
*/
|
|
29
|
-
selectionCaption?: string;
|
|
30
|
-
/** Customization for checkbox */
|
|
31
|
-
checkboxConfig?: Pick<CheckBoxProps, "block" | "className" | "data" | "fixBackgroundColor" | "hasBackgroundColor" | "style" | "withoutBorder" | "rounded">;
|
|
32
32
|
};
|
|
33
33
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/multiselect/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,mDAAmD;AACnD,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG;IAC3C,uBAAuB;IACvB,QAAQ,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,kCAAkC;AAClC,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAC/B,aAAa,EACX,OAAO,GAAG,UAAU,GACpB,OAAO,GAAG,cAAc,CAC7B,GAAG;IACA,kCAAkC;IAClC,KAAK,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAE9B
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/multiselect/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,mDAAmD;AACnD,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG;IAC3C,uBAAuB;IACvB,QAAQ,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,kCAAkC;AAClC,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAC/B,aAAa,EACX,OAAO,GAAG,UAAU,GACpB,OAAO,GAAG,cAAc,CAC7B,GAAG;IACA,kCAAkC;IAClC,KAAK,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAE9B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,iCAAiC;IACjC,cAAc,CAAC,EAAE,IAAI,CACjB,aAAa,EACX,OAAO,GAAG,WAAW,GAAG,MAAM,GAC9B,oBAAoB,GAAG,oBAAoB,GAC3C,OAAO,GAAG,eAAe,GACzB,SAAS,CACd,CAAC;IAEF;;;;;OAKG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAE7D;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/paginator/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoC,EAAE,EAAE,MAAM,OAAO,CAAC;AAO7D,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC;;;EAGE;AACF,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/paginator/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoC,EAAE,EAAE,MAAM,OAAO,CAAC;AAO7D,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC;;;EAGE;AACF,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAsIjC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useMemo } from "react";
|
|
3
|
-
import { getClassName, isNullOrEmpty,
|
|
4
|
-
import { getPositionClassName, mapDataAttributes } from "../../../utils";
|
|
3
|
+
import { getClassName, isNullOrEmpty, isNullish } from "@bodynarf/utils";
|
|
4
|
+
import { getPositionClassName, getSizeClassName, mapDataAttributes } from "../../../utils";
|
|
5
5
|
import { ElementPosition, ElementSize } from "../../../types";
|
|
6
6
|
/**
|
|
7
7
|
* Paginator component.
|
|
@@ -11,20 +11,20 @@ const Paginator = ({ count, onPageChange, currentPage = 0, position = ElementPos
|
|
|
11
11
|
if (currentPage > count) {
|
|
12
12
|
throw new Error(`Current page "${currentPage}" must be less than amount of pages "${count}"`);
|
|
13
13
|
}
|
|
14
|
+
const pageNumbers = useMemo(() => generatePageNumbers(currentPage, count, nearPagesCount), [currentPage, count, nearPagesCount]);
|
|
15
|
+
const canGoBack = useMemo(() => currentPage > 1, [currentPage]);
|
|
16
|
+
const canGoForward = useMemo(() => currentPage < count, [currentPage, count]);
|
|
14
17
|
const pageChange = useCallback((event) => {
|
|
15
18
|
const target = event.target;
|
|
16
19
|
const pageRaw = target.dataset["page"];
|
|
17
|
-
if (isNullOrEmpty(pageRaw)) {
|
|
20
|
+
if (isNullish(pageRaw) || isNullOrEmpty(pageRaw)) {
|
|
18
21
|
return;
|
|
19
22
|
}
|
|
20
|
-
const page = +pageRaw;
|
|
23
|
+
const page = +(pageRaw);
|
|
21
24
|
if (page !== currentPage && page > 0 && page <= count) {
|
|
22
25
|
onPageChange(page);
|
|
23
26
|
}
|
|
24
27
|
}, [onPageChange, currentPage, count]);
|
|
25
|
-
const pageNumbers = useMemo(() => generatePageNumbers(currentPage, count, nearPagesCount), [currentPage, count, nearPagesCount]);
|
|
26
|
-
const canGoBack = useMemo(() => currentPage > 1, [currentPage]);
|
|
27
|
-
const canGoForward = useMemo(() => currentPage < count, [currentPage, count]);
|
|
28
28
|
if (pageNumbers.length <= 1) {
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
@@ -34,12 +34,10 @@ const Paginator = ({ count, onPageChange, currentPage = 0, position = ElementPos
|
|
|
34
34
|
className,
|
|
35
35
|
getPositionClassName(position),
|
|
36
36
|
rounded ? "is-rounded" : "",
|
|
37
|
-
size
|
|
37
|
+
getSizeClassName(size),
|
|
38
38
|
]);
|
|
39
|
-
const dataAttributes =
|
|
40
|
-
|
|
41
|
-
: mapDataAttributes(data);
|
|
42
|
-
return (_jsxs("nav", { role: "navigation", className: classNames, "aria-label": "pagination", title: title, ...dataAttributes, children: [!!showNextButtons &&
|
|
39
|
+
const dataAttributes = mapDataAttributes(data);
|
|
40
|
+
return (_jsxs("nav", { title: title, role: "navigation", ...dataAttributes, className: classNames, "aria-label": "pagination", children: [!!showNextButtons &&
|
|
43
41
|
_jsxs(_Fragment, { children: [_jsx("a", { onClick: pageChange, "data-page": currentPage - 1, title: canGoBack ? resources?.previousPageTitle : undefined, className: `pagination-previous${canGoBack ? "" : " is-disabled"}`, children: resources?.previousPageCaption ?? "Previous" }), _jsx("a", { onClick: pageChange, "data-page": currentPage + 1, title: canGoForward ? resources?.nextPageTitle : undefined, className: `pagination-next${canGoForward ? "" : " is-disabled"}`, children: resources?.nextPageCaption ?? "Next page" })] }), _jsxs("ul", { className: "pagination-list", children: [currentPage !== 1 && !pageNumbers.includes(1) &&
|
|
44
42
|
_jsxs(_Fragment, { children: [_jsx("li", { children: _jsx("a", { "data-page": 1, onClick: pageChange, className: "pagination-link", title: resources?.openConcretePageTitleTemplate?.format(1), "aria-label": resources?.openConcretePageTitleTemplate?.format(1), children: "1" }) }), _jsx("li", { children: _jsx("span", { className: "pagination-ellipsis", children: "\u2026" }) })] }), pageNumbers.map(x => _jsx("li", { children: _jsx("a", { "data-page": x, onClick: pageChange, "aria-label": resources?.openConcretePageTitleTemplate?.format(x), className: `pagination-link${currentPage === x ? " is-current" : ""}`, title: currentPage === x ? undefined : resources?.openConcretePageTitleTemplate?.format(x), children: x }) }, x)), currentPage != count && !pageNumbers.includes(count) &&
|
|
45
43
|
_jsxs(_Fragment, { children: [_jsx("li", { children: _jsx("span", { className: "pagination-ellipsis", children: "\u2026" }) }), _jsx("li", { children: _jsx("a", { "data-page": count, onClick: pageChange, className: "pagination-link", title: resources?.openConcretePageTitleTemplate?.format(count), "aria-label": resources?.openConcretePageTitleTemplate?.format(count), children: count }) })] })] })] }));
|
|
@@ -2,8 +2,6 @@ import { BaseElementProps, ElementPosition, ElementSize } from "../../types";
|
|
|
2
2
|
export type PaginatorProps = BaseElementProps & {
|
|
3
3
|
/** Amount of pages */
|
|
4
4
|
count: number;
|
|
5
|
-
/** Page change handler */
|
|
6
|
-
onPageChange: (page: number) => void;
|
|
7
5
|
/** Current page */
|
|
8
6
|
currentPage: number;
|
|
9
7
|
/**
|
|
@@ -51,5 +49,7 @@ export type PaginatorProps = BaseElementProps & {
|
|
|
51
49
|
*/
|
|
52
50
|
openConcretePageTitleTemplate?: string;
|
|
53
51
|
};
|
|
52
|
+
/** Page change handler */
|
|
53
|
+
onPageChange: (page: number) => void;
|
|
54
54
|
};
|
|
55
55
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/paginator/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE5E,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG;IAC5C,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IAEd,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/paginator/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE5E,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG;IAC5C,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IAEd,mBAAmB;IACnB,WAAW,EAAE,MAAM,CAAC;IAEpB;;;MAGE;IACF,QAAQ,CAAC,EAAE,eAAe,CAAC;IAE3B,0CAA0C;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,0CAA0C;IAC1C,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;MAGE;IACF,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,qCAAqC;IACrC,SAAS,CAAC,EAAE;QACR;;;WAGG;QACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAE7B;;;WAGG;QACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAE3B;;;WAGG;QACH,eAAe,CAAC,EAAE,MAAM,CAAC;QAEzB;;;WAGG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;QAEvB;;;;WAIG;QACH,6BAA6B,CAAC,EAAE,MAAM,CAAC;KAC1C,CAAC;IAEF,0BAA0B;IAC1B,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/checkbox/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAAe,MAAM,OAAO,CAAC;AAQrD,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,8BAA8B;AAC9B,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/checkbox/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAAe,MAAM,OAAO,CAAC;AAQrD,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,8BAA8B;AAC9B,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAgG/B,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|