@bodynarf/react.components 1.8.22 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bodynarf-react.components-1.9.3.tgz +0 -0
- package/common.scss +3 -2
- package/components/accordion/component/index.d.ts +2 -3
- package/components/accordion/component/index.d.ts.map +1 -1
- package/components/accordion/component/index.js +4 -4
- package/components/accordion/types.d.ts +1 -1
- package/components/accordion/types.d.ts.map +1 -1
- package/components/anchor/component/index.d.ts +1 -1
- package/components/anchor/component/index.d.ts.map +1 -1
- package/components/anchor/component/index.js +6 -6
- package/components/anchor/components/anchorWithIcon/index.d.ts +3 -3
- package/components/anchor/components/anchorWithIcon/index.d.ts.map +1 -1
- package/components/anchor/components/anchorWithIcon/index.js +14 -9
- package/components/anchor/components/simpleAnchor/index.d.ts +3 -3
- package/components/anchor/components/simpleAnchor/index.d.ts.map +1 -1
- package/components/anchor/components/simpleAnchor/index.js +8 -2
- package/components/anchor/types.d.ts +2 -6
- package/components/anchor/types.d.ts.map +1 -1
- package/components/breadcrumbs/component/index.d.ts +34 -0
- package/components/breadcrumbs/component/index.d.ts.map +1 -0
- package/components/breadcrumbs/component/index.js +21 -0
- package/components/breadcrumbs/index.d.ts +3 -0
- package/components/breadcrumbs/index.d.ts.map +1 -0
- package/components/breadcrumbs/index.js +2 -0
- package/components/breadcrumbs/types.d.ts +13 -0
- package/components/breadcrumbs/types.d.ts.map +1 -0
- package/components/button/component/index.d.ts +1 -1
- package/components/button/component/index.d.ts.map +1 -1
- package/components/button/component/index.js +4 -8
- package/components/button/components/buttonWithIcon/index.d.ts +3 -2
- package/components/button/components/buttonWithIcon/index.d.ts.map +1 -1
- package/components/button/components/buttonWithIcon/index.js +14 -9
- package/components/button/components/simpleButton/index.d.ts +3 -2
- package/components/button/components/simpleButton/index.d.ts.map +1 -1
- package/components/button/components/simpleButton/index.js +8 -2
- package/components/button/types.d.ts +1 -1
- package/components/button/types.d.ts.map +1 -1
- package/components/button/types.js +0 -3
- package/components/dropdown/component/index.d.ts +1 -1
- package/components/dropdown/component/index.d.ts.map +1 -1
- package/components/dropdown/component/index.js +5 -8
- package/components/dropdown/component/style.scss +5 -1
- package/components/dropdown/components/compact/index.d.ts +2 -3
- package/components/dropdown/components/compact/index.d.ts.map +1 -1
- package/components/dropdown/components/compact/index.js +12 -9
- package/components/dropdown/components/item/index.d.ts +1 -1
- package/components/dropdown/components/item/index.d.ts.map +1 -1
- package/components/dropdown/components/item/index.js +34 -2
- package/components/dropdown/components/label/component/index.d.ts +27 -0
- package/components/dropdown/components/label/component/index.d.ts.map +1 -0
- package/components/dropdown/components/label/component/index.js +16 -0
- package/components/dropdown/components/label/components/empty/index.d.ts +8 -0
- package/components/dropdown/components/label/components/empty/index.d.ts.map +1 -0
- package/components/dropdown/components/label/components/empty/index.js +16 -0
- package/components/dropdown/components/label/components/selected/index.d.ts +8 -0
- package/components/dropdown/components/label/components/selected/index.d.ts.map +1 -0
- package/components/dropdown/components/label/components/selected/index.js +20 -0
- package/components/dropdown/components/label/components/selectedWithIcon/index.d.ts +8 -0
- package/components/dropdown/components/label/components/selectedWithIcon/index.d.ts.map +1 -0
- package/components/dropdown/components/label/components/selectedWithIcon/index.js +28 -0
- package/components/dropdown/components/label/components/withSearch/index.d.ts +16 -0
- package/components/dropdown/components/label/components/withSearch/index.d.ts.map +1 -0
- package/components/dropdown/components/label/components/withSearch/index.js +33 -0
- package/components/dropdown/components/label/components/withSearch/style.scss +29 -0
- package/components/dropdown/components/label/index.d.ts +1 -1
- package/components/dropdown/components/label/index.d.ts.map +1 -1
- package/components/dropdown/components/label/index.js +41 -9
- package/components/dropdown/components/withLabel/index.d.ts +2 -3
- package/components/dropdown/components/withLabel/index.d.ts.map +1 -1
- package/components/dropdown/components/withLabel/index.js +14 -12
- package/components/dropdown/types.d.ts +13 -2
- package/components/dropdown/types.d.ts.map +1 -1
- package/components/icon/component/index.d.ts +2 -2
- package/components/icon/component/index.d.ts.map +1 -1
- package/components/icon/component/index.js +9 -5
- package/components/icon/types.d.ts +2 -4
- package/components/icon/types.d.ts.map +1 -1
- package/components/index.d.ts +0 -1
- package/components/index.d.ts.map +1 -1
- package/components/index.js +0 -1
- package/components/paginator/component/index.d.ts +2 -2
- package/components/paginator/component/index.d.ts.map +1 -1
- package/components/paginator/component/index.js +19 -14
- package/components/paginator/types.d.ts +3 -5
- package/components/paginator/types.d.ts.map +1 -1
- package/components/primitives/checkbox/component/index.d.ts +2 -3
- package/components/primitives/checkbox/component/index.d.ts.map +1 -1
- package/components/primitives/checkbox/component/index.js +15 -17
- package/components/primitives/checkbox/types.d.ts +2 -2
- package/components/primitives/checkbox/types.d.ts.map +1 -1
- package/components/primitives/color/component/index.d.ts.map +1 -1
- package/components/primitives/color/components/picker/index.d.ts +11 -29
- package/components/primitives/color/components/picker/index.d.ts.map +1 -1
- package/components/primitives/color/components/picker/index.js +15 -12
- package/components/primitives/color/components/withLabel/index.d.ts +1 -1
- package/components/primitives/color/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/color/components/withLabel/index.js +8 -30
- package/components/primitives/color/components/withoutLabel/index.d.ts +1 -1
- package/components/primitives/color/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/color/components/withoutLabel/index.js +3 -13
- 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 -3
- package/components/primitives/date/component/index.d.ts.map +1 -1
- package/components/primitives/date/component/index.js +12 -27
- package/components/primitives/date/types.d.ts +2 -2
- package/components/primitives/date/types.d.ts.map +1 -1
- package/components/primitives/index.d.ts +0 -1
- package/components/primitives/index.d.ts.map +1 -1
- package/components/primitives/index.js +0 -1
- package/components/primitives/internal/componentWithLabel/index.d.ts +17 -0
- package/components/primitives/internal/componentWithLabel/index.d.ts.map +1 -0
- package/components/primitives/internal/componentWithLabel/index.js +26 -0
- package/components/primitives/internal/hint/index.d.ts +12 -0
- package/components/primitives/internal/hint/index.d.ts.map +1 -0
- package/components/primitives/internal/hint/index.js +47 -0
- package/components/primitives/multiline/component/index.d.ts +1 -1
- package/components/primitives/multiline/component/index.d.ts.map +1 -1
- package/components/primitives/multiline/component/index.js +5 -8
- package/components/primitives/multiline/components/withLabel/index.d.ts +5 -0
- package/components/primitives/multiline/components/withLabel/index.d.ts.map +1 -0
- package/components/primitives/multiline/components/withLabel/index.js +29 -0
- package/components/primitives/multiline/components/withoutLabel/index.d.ts +5 -0
- package/components/primitives/multiline/components/withoutLabel/index.d.ts.map +1 -0
- package/components/primitives/multiline/components/withoutLabel/index.js +28 -0
- package/components/primitives/multiline/types.d.ts +1 -1
- package/components/primitives/multiline/types.d.ts.map +1 -1
- package/components/primitives/number/component/index.d.ts +1 -1
- package/components/primitives/number/component/index.d.ts.map +1 -1
- package/components/primitives/number/component/index.js +5 -8
- package/components/primitives/number/components/withLabel/index.d.ts +2 -3
- package/components/primitives/number/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/number/components/withLabel/index.js +12 -27
- package/components/primitives/number/components/withoutLabel/index.d.ts +2 -3
- package/components/primitives/number/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/number/components/withoutLabel/index.js +11 -9
- package/components/primitives/number/types.d.ts +1 -1
- package/components/primitives/number/types.d.ts.map +1 -1
- package/components/primitives/password/component/index.d.ts +1 -1
- package/components/primitives/password/component/index.d.ts.map +1 -1
- package/components/primitives/password/component/index.js +5 -6
- package/components/primitives/password/components/withLabel/index.d.ts +2 -3
- package/components/primitives/password/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/password/components/withLabel/index.js +14 -30
- package/components/primitives/password/components/withoutLabel/index.d.ts +2 -3
- package/components/primitives/password/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/password/components/withoutLabel/index.js +13 -11
- package/components/primitives/password/types.d.ts +1 -1
- package/components/primitives/password/types.d.ts.map +1 -1
- package/components/primitives/text/component/index.d.ts +1 -1
- package/components/primitives/text/component/index.d.ts.map +1 -1
- package/components/primitives/text/component/index.js +5 -8
- package/components/primitives/text/components/withLabel/index.d.ts +5 -0
- package/components/primitives/text/components/withLabel/index.d.ts.map +1 -0
- package/components/primitives/text/components/withLabel/index.js +29 -0
- package/components/primitives/text/components/withoutLabel/index.d.ts +5 -0
- package/components/primitives/text/components/withoutLabel/index.d.ts.map +1 -0
- package/components/primitives/text/components/withoutLabel/index.js +28 -0
- package/components/primitives/text/types.d.ts +1 -1
- package/components/primitives/text/types.d.ts.map +1 -1
- package/components/search/component/index.d.ts +2 -2
- package/components/search/component/index.d.ts.map +1 -1
- package/components/search/component/index.js +16 -10
- package/components/search/types.d.ts +2 -2
- package/components/search/types.d.ts.map +1 -1
- package/components/table/component/index.d.ts +44 -0
- package/components/table/component/index.d.ts.map +1 -0
- package/components/table/component/index.js +29 -0
- package/components/table/component/style.scss +21 -0
- package/components/table/components/heading/index.d.ts +13 -0
- package/components/table/components/heading/index.d.ts.map +1 -0
- package/components/table/components/heading/index.js +21 -0
- package/components/table/index.d.ts +3 -0
- package/components/table/index.d.ts.map +1 -0
- package/components/table/index.js +2 -0
- package/components/table/types.d.ts +18 -0
- package/components/table/types.d.ts.map +1 -0
- package/components/tabs/component/index.d.ts +3 -4
- package/components/tabs/component/index.d.ts.map +1 -1
- package/components/tabs/component/index.js +14 -8
- package/components/tabs/components/item/index.d.ts +1 -1
- package/components/tabs/components/item/index.d.ts.map +1 -1
- package/components/tabs/components/item/index.js +4 -3
- package/components/tabs/types.d.ts +1 -12
- package/components/tabs/types.d.ts.map +1 -1
- package/components/tabs/types.js +0 -12
- package/components/tag/component/index.d.ts +2 -3
- package/components/tag/component/index.d.ts.map +1 -1
- package/components/tag/component/index.js +13 -7
- package/components/tag/types.d.ts +1 -1
- package/components/tag/types.d.ts.map +1 -1
- package/hooks/usePagination.d.ts.map +1 -1
- package/hooks/usePagination.js +11 -2
- package/hooks/useUnmount.d.ts +8 -0
- package/hooks/useUnmount.d.ts.map +1 -0
- package/hooks/useUnmount.js +22 -0
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/package.json +11 -4
- package/readme.md +2 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/types/baseElementProps.d.ts +11 -0
- package/types/baseElementProps.d.ts.map +1 -0
- package/types/baseElementProps.js +1 -0
- package/{components/primitives/types/baseProps.d.ts → types/baseInputElementProps.d.ts} +10 -4
- package/types/baseInputElementProps.d.ts.map +1 -0
- package/types/baseInputElementProps.js +1 -0
- package/types/dataAttributes.d.ts +9 -0
- package/types/dataAttributes.d.ts.map +1 -0
- package/types/dataAttributes.js +1 -0
- package/types/elementColor.d.ts +18 -0
- package/types/elementColor.d.ts.map +1 -0
- package/types/elementColor.js +18 -0
- package/types/elementIcon.d.ts +22 -0
- package/types/elementIcon.d.ts.map +1 -0
- package/types/elementIcon.js +1 -0
- package/types/elementPosition.d.ts +12 -0
- package/types/elementPosition.d.ts.map +1 -0
- package/types/elementPosition.js +10 -0
- package/types/elementSize.d.ts +12 -0
- package/types/elementSize.d.ts.map +1 -0
- package/types/elementSize.js +12 -0
- package/types/hintConfiguration.d.ts +13 -0
- package/types/hintConfiguration.d.ts.map +1 -0
- package/types/hintConfiguration.js +1 -0
- package/types/index.d.ts +11 -0
- package/types/index.d.ts.map +1 -0
- package/types/index.js +10 -0
- package/{components/primitives/types/label.d.ts → types/labelConfiguration.d.ts} +3 -3
- package/types/labelConfiguration.d.ts.map +1 -0
- package/types/labelConfiguration.js +1 -0
- package/{components/primitives/types → types}/validation/index.d.ts +1 -1
- package/types/validation/index.d.ts.map +1 -0
- package/{components/primitives/types → types}/validation/index.js +1 -1
- package/{components/primitives/types → types}/validation/state.d.ts +2 -2
- package/types/validation/state.d.ts.map +1 -0
- package/{components/primitives/types → types}/validation/state.js +0 -1
- package/{components/primitives/types → types}/validation/status.d.ts +1 -1
- package/types/validation/status.d.ts.map +1 -0
- package/{components/primitives/types → types}/validation/status.js +1 -2
- package/utils/dataAttributes.d.ts +1 -1
- package/utils/dataAttributes.d.ts.map +1 -1
- package/utils/index.d.ts +1 -1
- package/utils/index.d.ts.map +1 -1
- package/utils/index.js +1 -1
- package/utils/validation.d.ts +11 -0
- package/utils/validation.d.ts.map +1 -0
- package/utils/validation.js +20 -0
- package/components/primitives/multiline/components/multilineWithLabel/index.d.ts +0 -6
- package/components/primitives/multiline/components/multilineWithLabel/index.d.ts.map +0 -1
- package/components/primitives/multiline/components/multilineWithLabel/index.js +0 -44
- package/components/primitives/multiline/components/multilineWithoutLabel/index.d.ts +0 -6
- package/components/primitives/multiline/components/multilineWithoutLabel/index.d.ts.map +0 -1
- package/components/primitives/multiline/components/multilineWithoutLabel/index.js +0 -26
- package/components/primitives/text/components/textWithLabel/index.d.ts +0 -6
- package/components/primitives/text/components/textWithLabel/index.d.ts.map +0 -1
- package/components/primitives/text/components/textWithLabel/index.js +0 -44
- package/components/primitives/text/components/textWithoutLabel/index.d.ts +0 -6
- package/components/primitives/text/components/textWithoutLabel/index.d.ts.map +0 -1
- package/components/primitives/text/components/textWithoutLabel/index.js +0 -26
- package/components/primitives/types/baseProps.d.ts.map +0 -1
- package/components/primitives/types/index.d.ts +0 -4
- package/components/primitives/types/index.d.ts.map +0 -1
- package/components/primitives/types/index.js +0 -3
- package/components/primitives/types/label.d.ts.map +0 -1
- package/components/primitives/types/validation/index.d.ts.map +0 -1
- package/components/primitives/types/validation/state.d.ts.map +0 -1
- package/components/primitives/types/validation/status.d.ts.map +0 -1
- package/components/types.d.ts +0 -78
- package/components/types.d.ts.map +0 -1
- package/components/types.js +0 -41
- package/utils/formValidation.d.ts +0 -16
- package/utils/formValidation.d.ts.map +0 -1
- package/utils/formValidation.js +0 -35
- /package/components/{primitives/types/baseProps.js → breadcrumbs/types.js} +0 -0
- /package/components/{primitives/types/label.js → table/types.js} +0 -0
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useMemo } from "react";
|
|
3
|
-
import { getClassName, isNullOrEmpty } from "@bodynarf/utils";
|
|
4
|
-
import {
|
|
3
|
+
import { getClassName, isNullOrEmpty, isNullOrUndefined } from "@bodynarf/utils";
|
|
4
|
+
import { mapDataAttributes } from "../../../utils";
|
|
5
|
+
import { ElementPosition } from "../../../types";
|
|
6
|
+
import { generatePageNumbers } from "../..";
|
|
5
7
|
/**
|
|
6
8
|
* Paginator component.
|
|
7
9
|
* Used for visualization of paging configuration
|
|
8
10
|
*/
|
|
9
|
-
export default function Paginator({ count, onPageChange, currentPage, position, size,
|
|
10
|
-
const page = currentPage || 0;
|
|
11
|
+
export default function Paginator({ count, onPageChange, currentPage = 0, position = ElementPosition.Left, size, rounded = false, showNextButtons = false, nearPagesCount, className, title, data, }) {
|
|
11
12
|
const pageChange = useCallback((event) => {
|
|
12
13
|
const target = event.target;
|
|
13
14
|
const pageRaw = target.dataset["page"];
|
|
@@ -19,29 +20,33 @@ export default function Paginator({ count, onPageChange, currentPage, position,
|
|
|
19
20
|
onPageChange(page);
|
|
20
21
|
}
|
|
21
22
|
}, [onPageChange, currentPage, count]);
|
|
22
|
-
const pageNumbers = useMemo(() => generatePageNumbers(
|
|
23
|
-
const canGoBack = useMemo(() =>
|
|
24
|
-
const canGoForward = useMemo(() =>
|
|
23
|
+
const pageNumbers = useMemo(() => generatePageNumbers(currentPage, count, nearPagesCount), [currentPage, count, nearPagesCount]);
|
|
24
|
+
const canGoBack = useMemo(() => currentPage > 1, [currentPage]);
|
|
25
|
+
const canGoForward = useMemo(() => currentPage < count, [currentPage, count]);
|
|
25
26
|
if (pageNumbers.length <= 1) {
|
|
26
27
|
return _jsx(_Fragment, {});
|
|
27
28
|
}
|
|
28
29
|
const classNames = getClassName([
|
|
29
30
|
"bbr-paginator",
|
|
30
31
|
"pagination",
|
|
31
|
-
|
|
32
|
+
className,
|
|
33
|
+
paginationPositionToClassMap.get(position),
|
|
32
34
|
rounded ? "is-rounded" : "",
|
|
33
35
|
isNullOrEmpty(size) ? "" : `is-${size}`,
|
|
34
|
-
className
|
|
35
36
|
]);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const dataAttributes = isNullOrUndefined(data)
|
|
38
|
+
? undefined
|
|
39
|
+
: mapDataAttributes(data);
|
|
40
|
+
return (_jsxs("nav", { className: classNames, role: "navigation", "aria-label": "pagination", title: title, ...dataAttributes, children: [showNextButtons &&
|
|
41
|
+
_jsxs(_Fragment, { children: [_jsx("a", { className: `pagination-previous${canGoBack ? "" : " is-disabled"}`, "data-page": currentPage - 1, onClick: pageChange, children: "Previous" }), _jsx("a", { className: `pagination-next${canGoForward ? "" : " is-disabled"}`, "data-page": currentPage + 1, onClick: pageChange, children: "Next page" })] }), _jsxs("ul", { className: "pagination-list", children: [currentPage !== 1 && !pageNumbers.includes(1) &&
|
|
42
|
+
_jsxs(_Fragment, { children: [_jsx("li", { children: _jsx("a", { className: "pagination-link", "aria-label": "Goto page 1", "data-page": 1, onClick: pageChange, children: "1" }) }), _jsx("li", { children: _jsx("span", { className: "pagination-ellipsis", children: "\u2026" }) })] }), pageNumbers.map(x => _jsx("li", { children: _jsx("a", { className: `pagination-link${currentPage === x ? " is-current" : ""}`, "aria-label": `Goto page ${x}`, "data-page": x, onClick: pageChange, children: x }) }, x)), currentPage != count && !pageNumbers.includes(count) &&
|
|
39
43
|
_jsxs(_Fragment, { children: [_jsx("li", { children: _jsx("span", { className: "pagination-ellipsis", children: "\u2026" }) }), _jsx("li", { children: _jsx("a", { className: "pagination-link", "aria-label": `Goto page ${count}`, "data-page": count, onClick: pageChange, children: count }) })] })] })] }));
|
|
40
44
|
}
|
|
41
45
|
/**
|
|
42
46
|
* Position setting to css class name map
|
|
43
47
|
*/
|
|
44
48
|
const paginationPositionToClassMap = new Map([
|
|
45
|
-
[
|
|
46
|
-
[
|
|
49
|
+
[ElementPosition.Left, ""],
|
|
50
|
+
[ElementPosition.Center, "is-centered"],
|
|
51
|
+
[ElementPosition.Right, "is-right"]
|
|
47
52
|
]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ElementSize } from "
|
|
2
|
-
export interface PaginatorProps {
|
|
1
|
+
import { BaseElementProps, ElementPosition, ElementSize } from "../../types";
|
|
2
|
+
export interface PaginatorProps extends BaseElementProps {
|
|
3
3
|
/** Amount of pages */
|
|
4
4
|
count: number;
|
|
5
5
|
/** Page change handler */
|
|
@@ -10,13 +10,11 @@ export interface PaginatorProps {
|
|
|
10
10
|
* Page numbers position.
|
|
11
11
|
* Useful with `showNextButtons = true`
|
|
12
12
|
*/
|
|
13
|
-
position?:
|
|
13
|
+
position?: ElementPosition;
|
|
14
14
|
/** Buttons should have rounded borders */
|
|
15
15
|
rounded?: boolean;
|
|
16
16
|
/** Size of paginator component elements */
|
|
17
17
|
size?: ElementSize;
|
|
18
|
-
/** Additional class names */
|
|
19
|
-
className?: string;
|
|
20
18
|
/** Display "Previous" \ "Next" buttons */
|
|
21
19
|
showNextButtons?: boolean;
|
|
22
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/paginator/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
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,WAAW,cAAe,SAAQ,gBAAgB;IACpD,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IAEd,0BAA0B;IAC1B,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAErC,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;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;CAC3B"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import "./style.scss";
|
|
3
|
-
import { CheckBoxProps } from "
|
|
2
|
+
import { CheckBoxProps } from "../..";
|
|
4
3
|
/** Boolean input component */
|
|
5
|
-
declare const CheckBox: ({ label, onValueChange, defaultValue, name, disabled, size, style, rounded, block, withoutBorder, hasBackgroundColor, fixBackgroundColor, isFormLabel, }: CheckBoxProps) => JSX.Element;
|
|
4
|
+
declare const CheckBox: ({ label, onValueChange, defaultValue, name, disabled, size, style, rounded, block, withoutBorder, hasBackgroundColor, fixBackgroundColor, isFormLabel, className, title, data, }: CheckBoxProps) => JSX.Element;
|
|
6
5
|
export default CheckBox;
|
|
7
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/checkbox/component/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/checkbox/component/index.tsx"],"names":[],"mappings":"AAQA,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,8BAA8B;AAC9B,QAAA,MAAM,QAAQ,qLASX,aAAa,KAAG,WA8ElB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { generateGuid, getClassName, isNullOrUndefined } from "@bodynarf/utils";
|
|
4
|
+
import { ElementSize } from "../../../../types";
|
|
5
|
+
import { mapDataAttributes } from "../../../../utils";
|
|
6
|
+
import ComponentWithLabel from "../../internal/componentWithLabel";
|
|
4
7
|
import "./style.scss";
|
|
5
8
|
/** Boolean input component */
|
|
6
|
-
const CheckBox = ({ label, onValueChange, defaultValue, name, disabled, size, style, rounded = false, block = false, withoutBorder = false, hasBackgroundColor = false, fixBackgroundColor = false, isFormLabel = false, }) => {
|
|
9
|
+
const CheckBox = ({ label, onValueChange, defaultValue, name, disabled, size, style, rounded = false, block = false, withoutBorder = false, hasBackgroundColor = false, fixBackgroundColor = false, isFormLabel = false, className, title, data, }) => {
|
|
7
10
|
const onChecked = useCallback((event) => onValueChange(event.target.checked), [onValueChange]);
|
|
8
|
-
const id = name
|
|
9
|
-
const
|
|
11
|
+
const id = name ?? generateGuid();
|
|
12
|
+
const elClassName = getClassName([
|
|
10
13
|
"is-checkradio",
|
|
11
14
|
"m-check-radio",
|
|
15
|
+
className,
|
|
12
16
|
hasBackgroundColor ? "has-background-color" : "",
|
|
13
17
|
fixBackgroundColor && hasBackgroundColor ? "m-has-background-color" : "",
|
|
14
18
|
isNullOrUndefined(size) ? "" : size === "normal" ? "" : `is-${size}`,
|
|
@@ -17,21 +21,15 @@ const CheckBox = ({ label, onValueChange, defaultValue, name, disabled, size, st
|
|
|
17
21
|
block ? "is-block" : "",
|
|
18
22
|
withoutBorder ? "has-no-border" : "",
|
|
19
23
|
]);
|
|
24
|
+
const dataAttributes = isNullOrUndefined(data)
|
|
25
|
+
? undefined
|
|
26
|
+
: mapDataAttributes(data);
|
|
20
27
|
if (!isNullOrUndefined(label) && isFormLabel) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const labelContainerClassName = getClassName([
|
|
26
|
-
"field-label",
|
|
27
|
-
label.horizontalContainerClassName
|
|
28
|
-
]);
|
|
29
|
-
const fieldContainerClassName = getClassName([
|
|
30
|
-
"field-body",
|
|
31
|
-
label.horizontalFieldContainerClassName
|
|
32
|
-
]);
|
|
33
|
-
return (_jsxs("div", { className: "bbr-input field is-horizontal", children: [_jsx("div", { className: labelContainerClassName, children: _jsx("label", { className: labelClassName, children: label.caption }) }), _jsx("div", { className: fieldContainerClassName, children: _jsxs("div", { className: "field", children: [_jsx("input", { type: "checkbox", name: id, id: id, disabled: disabled, onChange: onChecked, className: className, defaultChecked: defaultValue }), _jsx("label", { htmlFor: id })] }) })] }));
|
|
28
|
+
return (_jsxs(ComponentWithLabel, { id: id, label: {
|
|
29
|
+
...label,
|
|
30
|
+
horizontalContainerClassName: getClassName([label.horizontalContainerClassName, "p-0"]),
|
|
31
|
+
}, size: ElementSize.Normal, children: [_jsx("input", { type: "checkbox", id: id, name: id, disabled: disabled, onChange: onChecked, className: elClassName, defaultChecked: defaultValue, title: title, ...dataAttributes }), _jsx("label", { htmlFor: id })] }));
|
|
34
32
|
}
|
|
35
|
-
return (_jsxs("div", { className: "bbr-input field", children: [_jsx("input", { type: "checkbox",
|
|
33
|
+
return (_jsxs("div", { className: "bbr-input field", children: [_jsx("input", { type: "checkbox", id: id, name: id, disabled: disabled, onChange: onChecked, className: elClassName, defaultChecked: defaultValue, title: title, ...dataAttributes }), _jsx("label", { htmlFor: id, children: label?.caption })] }));
|
|
36
34
|
};
|
|
37
35
|
export default CheckBox;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseInputElementProps } from "
|
|
1
|
+
import { BaseInputElementProps } from "../../../types";
|
|
2
2
|
/** Checkbox component props type */
|
|
3
|
-
export interface CheckBoxProps extends Omit<BaseInputElementProps<boolean>, "readonly" | "validationState" | "loading" | "placeholder"> {
|
|
3
|
+
export interface CheckBoxProps extends Omit<BaseInputElementProps<boolean>, "readonly" | "validationState" | "loading" | "placeholder" | "hint"> {
|
|
4
4
|
/** Is full colored checkbox */
|
|
5
5
|
block?: boolean;
|
|
6
6
|
/** Remove the checkbox border */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/checkbox/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/checkbox/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,oCAAoC;AACpC,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EACtE,UAAU,GAAG,iBAAiB,GAC5B,SAAS,GAAG,aAAa,GACzB,MAAM,CACX;IACG,+BAA+B;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,iCAAiC;IACjC,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;MAGE;IACF,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;MAIE;IACF,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/color/component/index.tsx"],"names":[],"mappings":";AAEA,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/color/component/index.tsx"],"names":[],"mappings":";AAEA,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAItC,6BAA6B;AAC7B,QAAA,MAAM,WAAW,UAAW,gBAAgB,KAAG,WAGF,CACxC;AAEL,eAAe,WAAW,CAAC"}
|
|
@@ -1,38 +1,20 @@
|
|
|
1
1
|
import { ChangeEvent } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { BaseInputElementProps } from "../../../../../types";
|
|
3
3
|
import { ColorPickerPreviewConfig } from "../..";
|
|
4
|
-
/**
|
|
5
|
-
export interface ColorPickerControlProps {
|
|
6
|
-
/**
|
|
7
|
-
|
|
4
|
+
/** Props of `ColorPickerControl` */
|
|
5
|
+
export interface ColorPickerControlProps extends Omit<BaseInputElementProps<string>, "onValueChange" | "placeholder" | "rounded" | "readonly" | "loading" | "className"> {
|
|
6
|
+
/** Preview element configuration */
|
|
7
|
+
previewConfig?: ColorPickerPreviewConfig;
|
|
8
|
+
/** Current color value */
|
|
9
|
+
value: string;
|
|
10
|
+
/** Control unique identifier */
|
|
11
|
+
id: string;
|
|
8
12
|
/** Class names of control */
|
|
9
|
-
|
|
10
|
-
/** Default value for color control */
|
|
11
|
-
defaultColor: string;
|
|
13
|
+
elementClassName: string;
|
|
12
14
|
/** Handler of control value change*/
|
|
13
15
|
onValueChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
14
|
-
/** Control unique identifier */
|
|
15
|
-
id: string;
|
|
16
|
-
/** Extra data-* attributes */
|
|
17
|
-
dataAttributes?: object;
|
|
18
|
-
/** Is validation should be displayed */
|
|
19
|
-
isValidationDefined: boolean;
|
|
20
|
-
/** Validation messages */
|
|
21
|
-
validationMessages: Array<string>;
|
|
22
|
-
/** Validation style class name */
|
|
23
|
-
styleClassName: string;
|
|
24
|
-
/** Current color value */
|
|
25
|
-
value: string;
|
|
26
|
-
/** Should be component disabled. Selecting is not allowed */
|
|
27
|
-
disabled?: boolean;
|
|
28
|
-
/** Preview element configuration */
|
|
29
|
-
previewConfig?: ColorPickerPreviewConfig;
|
|
30
|
-
/** Component size */
|
|
31
|
-
size?: ElementSize;
|
|
32
|
-
/** Title */
|
|
33
|
-
title?: string;
|
|
34
16
|
}
|
|
35
17
|
/** Color picker container component */
|
|
36
|
-
declare const ColorPickerControl: ({
|
|
18
|
+
declare const ColorPickerControl: ({ elementClassName, disabled, previewConfig, size, defaultValue, onValueChange, value, id, title, data, hint, validationState, }: ColorPickerControlProps) => JSX.Element;
|
|
37
19
|
export default ColorPickerControl;
|
|
38
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/color/components/picker/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAIpC,OAAO,EAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/color/components/picker/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAIpC,OAAO,EAAmB,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAIpE,OAAO,EAA4B,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAE3E,oCAAoC;AACpC,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CACjD,qBAAqB,CAAC,MAAM,CAAC,EAC3B,eAAe,GAAG,aAAa,GAC/B,SAAS,GAAG,UAAU,GACtB,SAAS,GAAG,WAAW,CAC5B;IACG,oCAAoC;IACpC,aAAa,CAAC,EAAE,wBAAwB,CAAC;IAEzC,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;IAEd,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IAEX,6BAA6B;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IAEzB,qCAAqC;IACrC,aAAa,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CACjE;AAED,uCAAuC;AACvC,QAAA,MAAM,kBAAkB,qIAOrB,uBAAuB,KAAG,WA0C5B,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { getClassName, getFontColorFromString, isNullOrUndefined } from "@bodynarf/utils";
|
|
3
|
-
import { ElementPosition } from "
|
|
3
|
+
import { ElementPosition } from "../../../../../types";
|
|
4
|
+
import { mapDataAttributes } from "../../../../../utils";
|
|
5
|
+
import InternalHint from "../../../internal/hint";
|
|
4
6
|
/** Color picker container component */
|
|
5
|
-
const ColorPickerControl = ({
|
|
7
|
+
const ColorPickerControl = ({ elementClassName, disabled, previewConfig, size, defaultValue, onValueChange, value, id, title, data, hint, validationState, }) => {
|
|
6
8
|
if (!isNullOrUndefined(previewConfig)) {
|
|
7
|
-
return _jsx(PickerWithPreview, {
|
|
9
|
+
return (_jsx(PickerWithPreview, { id: id, size: size, value: value, disabled: disabled, elementClassName: elementClassName, defaultValue: defaultValue, onValueChange: onValueChange, previewConfig: previewConfig, title: title, data: data }));
|
|
8
10
|
}
|
|
9
|
-
return (_jsxs(_Fragment, { children: [_jsx("div", { className:
|
|
10
|
-
_jsx("p", { className: `help m-help ${styleClassName}`, children: validationMessages.join("\n") })] }));
|
|
11
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "control bbr-input", children: _jsx("input", { type: "color", id: id, name: id, disabled: disabled, className: elementClassName, onChange: onValueChange, defaultValue: defaultValue, title: title, ...data }) }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
|
|
11
12
|
};
|
|
12
13
|
export default ColorPickerControl;
|
|
13
14
|
/** Picker sub component with preview */
|
|
14
|
-
const PickerWithPreview = ({
|
|
15
|
+
const PickerWithPreview = ({ elementClassName, disabled, size, defaultValue, onValueChange, value, id, title, data, previewConfig, hint, validationState, }) => {
|
|
15
16
|
const classNames = getClassName([
|
|
16
17
|
"bbr-color-picker__preview",
|
|
17
18
|
"button",
|
|
@@ -19,8 +20,12 @@ const PickerWithPreview = ({ containerClassName, className, disabled, size, defa
|
|
|
19
20
|
isNullOrUndefined(size) ? "" : `is-${size}`
|
|
20
21
|
]);
|
|
21
22
|
const color = getFontColorFromString(value);
|
|
23
|
+
const dataAttributes = isNullOrUndefined(data)
|
|
24
|
+
? undefined
|
|
25
|
+
: mapDataAttributes(data);
|
|
22
26
|
const controlContainerClassName = getClassName([
|
|
23
|
-
|
|
27
|
+
"control",
|
|
28
|
+
"bbr-input",
|
|
24
29
|
"is-flex-grow-1",
|
|
25
30
|
previewConfig.position === ElementPosition.Left ? "ml-1" : "mr-1",
|
|
26
31
|
]);
|
|
@@ -28,12 +33,10 @@ const PickerWithPreview = ({ containerClassName, className, disabled, size, defa
|
|
|
28
33
|
return (_jsxs("div", { className: "is-flex is-flex-direction-row is-flex-wrap-nowrap is-justify-content-start", children: [_jsx("button", { className: classNames, style: {
|
|
29
34
|
"--color-picker__background-color": value,
|
|
30
35
|
"--color-picker__color": color,
|
|
31
|
-
}, children: value }), _jsx("div", { className: controlContainerClassName, children: _jsx("input", { type: "color",
|
|
32
|
-
_jsx("p", { className: `help m-help ${styleClassName}`, children: validationMessages.join("\n") })] }));
|
|
36
|
+
}, children: value }), _jsx("div", { className: controlContainerClassName, children: _jsx("input", { type: "color", id: id, name: id, disabled: disabled, onChange: onValueChange, defaultValue: defaultValue, className: elementClassName, title: title, ...dataAttributes }) }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
|
|
33
37
|
}
|
|
34
|
-
return (_jsxs("div", { className: "is-flex is-flex-direction-row is-flex-wrap-nowrap is-justify-content-start", children: [_jsx("div", { className: controlContainerClassName, children: _jsx("input", { type: "color",
|
|
38
|
+
return (_jsxs("div", { className: "is-flex is-flex-direction-row is-flex-wrap-nowrap is-justify-content-start", children: [_jsx("div", { className: controlContainerClassName, children: _jsx("input", { type: "color", id: id, name: id, disabled: disabled, onChange: onValueChange, defaultValue: defaultValue, className: elementClassName, title: title, ...dataAttributes }) }), _jsx("button", { className: classNames, style: {
|
|
35
39
|
"--color-picker__background-color": value,
|
|
36
40
|
"--color-picker__color": color,
|
|
37
|
-
}, children: value }),
|
|
38
|
-
_jsx("p", { className: `help m-help ${styleClassName}`, children: validationMessages.join("\n") })] }));
|
|
41
|
+
}, children: value }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
|
|
39
42
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ColorPickerProps } from "../..";
|
|
3
3
|
/** Color picker component with form label */
|
|
4
|
-
declare function ColorPickerWithLabel({
|
|
4
|
+
declare function ColorPickerWithLabel({ preview, name, defaultValue, validationState, onValueChange, disabled, rounded, size, label, className, title, data, hint, }: ColorPickerProps): JSX.Element;
|
|
5
5
|
export default ColorPickerWithLabel;
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/color/components/withLabel/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/color/components/withLabel/index.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAGzC,6CAA6C;AAC7C,iBAAS,oBAAoB,CAAC,EAC1B,OAAO,EACP,IAAI,EACJ,YAAY,EAAE,eAAe,EAC7B,aAAa,EACb,QAAgB,EAAE,OAAe,EAAE,IAAI,EACvC,KAAK,EAEL,SAAS,EAAE,KAAK,EAAE,IAAI,EACtB,IAAI,GACP,EAAE,gBAAgB,eAmDlB;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,48 +1,26 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useState } from "react";
|
|
3
3
|
import { generateGuid, getClassName, hexToRgb, isNullOrUndefined, rgbToHex, whiteHex } from "@bodynarf/utils";
|
|
4
|
-
import {
|
|
4
|
+
import { ElementSize } from "../../../../../types";
|
|
5
|
+
import { getStyleClassName } from "../../../../../utils";
|
|
6
|
+
import ComponentWithLabel from "../../../internal/componentWithLabel";
|
|
5
7
|
import ColorPickerControl from "../picker";
|
|
6
8
|
/** Color picker component with form label */
|
|
7
|
-
function ColorPickerWithLabel({
|
|
9
|
+
function ColorPickerWithLabel({ preview, name, defaultValue, validationState, onValueChange, disabled = false, rounded = false, size, label, className, title, data, hint, }) {
|
|
8
10
|
const defaultColor = isNullOrUndefined(defaultValue)
|
|
9
11
|
? whiteHex
|
|
10
12
|
: rgbToHex(defaultValue);
|
|
11
13
|
const [value, setValue] = useState(defaultColor);
|
|
12
14
|
const onChange = useCallback((event) => setValue(event.target.value), [setValue]);
|
|
13
15
|
useEffect(() => onValueChange(hexToRgb(value)), [onValueChange, value]);
|
|
14
|
-
const [isValidationDefined, styleClassName, validationMessages] = getValidationValues(undefined, validationState);
|
|
15
16
|
const elClassName = getClassName([
|
|
16
17
|
className,
|
|
17
|
-
styleClassName,
|
|
18
18
|
rounded ? "is-rounded" : "",
|
|
19
|
+
getStyleClassName(undefined, validationState),
|
|
19
20
|
isNullOrUndefined(size) ? "" : `is-${size}`,
|
|
20
21
|
"input",
|
|
21
22
|
]);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
"bbr-input",
|
|
25
|
-
]);
|
|
26
|
-
const dataAttributes = isNullOrUndefined(data)
|
|
27
|
-
? undefined
|
|
28
|
-
: mapDataAttributes(data);
|
|
29
|
-
const id = name || generateGuid();
|
|
30
|
-
const labelClassName = getClassName([
|
|
31
|
-
"label",
|
|
32
|
-
label.className
|
|
33
|
-
]);
|
|
34
|
-
if (label.horizontal) {
|
|
35
|
-
const labelContainerClassName = getClassName([
|
|
36
|
-
"field-label",
|
|
37
|
-
"is-normal",
|
|
38
|
-
label.horizontalContainerClassName
|
|
39
|
-
]);
|
|
40
|
-
const fieldContainerClassName = getClassName([
|
|
41
|
-
"field-body",
|
|
42
|
-
label.horizontalFieldContainerClassName
|
|
43
|
-
]);
|
|
44
|
-
return (_jsxs("div", { className: "bbr-color-picker bbr-input field is-horizontal", children: [_jsx("div", { className: labelContainerClassName, children: _jsx("label", { className: labelClassName, htmlFor: id, children: label.caption }) }), _jsx("div", { className: fieldContainerClassName, children: _jsx("div", { className: "field", children: _jsx(ColorPickerControl, { id: id, value: value, title: title, disabled: disabled, previewConfig: preview, className: elClassName, onValueChange: onChange, defaultColor: defaultColor, styleClassName: styleClassName, dataAttributes: dataAttributes, validationMessages: validationMessages, isValidationDefined: isValidationDefined, containerClassName: inputContainerClassName }) }) })] }));
|
|
45
|
-
}
|
|
46
|
-
return (_jsxs("div", { className: "bbr-color-picker bbr-input field", children: [_jsx("label", { className: labelClassName, htmlFor: id, children: label.caption }), _jsx(ColorPickerControl, { id: id, value: value, title: title, disabled: disabled, previewConfig: preview, className: elClassName, onValueChange: onChange, defaultColor: defaultColor, dataAttributes: dataAttributes, styleClassName: styleClassName, validationMessages: validationMessages, isValidationDefined: isValidationDefined, containerClassName: inputContainerClassName })] }));
|
|
23
|
+
const id = name ?? generateGuid();
|
|
24
|
+
return (_jsx(ComponentWithLabel, { id: id, label: label, size: size ?? ElementSize.Normal, children: _jsx(ColorPickerControl, { id: id, value: value, disabled: disabled, previewConfig: preview, elementClassName: elClassName, onValueChange: onChange, defaultValue: defaultColor, hint: hint, validationState: validationState, data: data, title: title }) }));
|
|
47
25
|
}
|
|
48
26
|
export default ColorPickerWithLabel;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ColorPickerProps } from "../..";
|
|
3
3
|
/** Color picker component without form label */
|
|
4
|
-
declare function ColorPickerWithoutLabel({
|
|
4
|
+
declare function ColorPickerWithoutLabel({ preview, name, defaultValue, validationState, onValueChange, disabled, rounded, size, className, title, data, hint, }: ColorPickerProps): JSX.Element;
|
|
5
5
|
export default ColorPickerWithoutLabel;
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/color/components/withoutLabel/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/color/components/withoutLabel/index.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAGzC,gDAAgD;AAChD,iBAAS,uBAAuB,CAAC,EAC7B,OAAO,EACP,IAAI,EACJ,YAAY,EAAE,eAAe,EAC7B,aAAa,EACb,QAAgB,EAAE,OAAe,EAAE,IAAI,EAEvC,SAAS,EAAE,KAAK,EAAE,IAAI,EACtB,IAAI,GACP,EAAE,gBAAgB,eA6ClB;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -1,32 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useState } from "react";
|
|
3
3
|
import { generateGuid, getClassName, hexToRgb, isNullOrUndefined, rgbToHex, whiteHex } from "@bodynarf/utils";
|
|
4
|
-
import { getValidationValues, mapDataAttributes } from "../../../../..";
|
|
5
4
|
import ColorPickerControl from "../picker";
|
|
6
5
|
/** Color picker component without form label */
|
|
7
|
-
function ColorPickerWithoutLabel({
|
|
6
|
+
function ColorPickerWithoutLabel({ preview, name, defaultValue, validationState, onValueChange, disabled = false, rounded = false, size, className, title, data, hint, }) {
|
|
8
7
|
const defaultColor = isNullOrUndefined(defaultValue)
|
|
9
8
|
? whiteHex
|
|
10
9
|
: rgbToHex(defaultValue);
|
|
11
10
|
const [value, setValue] = useState(defaultColor);
|
|
12
11
|
const onChange = useCallback((event) => setValue(event.target.value), [setValue]);
|
|
13
12
|
useEffect(() => onValueChange(hexToRgb(value)), [onValueChange, value]);
|
|
14
|
-
const [isValidationDefined, styleClassName, validationMessages] = getValidationValues(undefined, validationState);
|
|
15
13
|
const elClassName = getClassName([
|
|
16
14
|
className,
|
|
17
|
-
styleClassName,
|
|
18
15
|
rounded ? "is-rounded" : "",
|
|
19
16
|
isNullOrUndefined(size) ? "" : `is-${size}`,
|
|
20
17
|
"input",
|
|
21
18
|
]);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
"bbr-input",
|
|
25
|
-
]);
|
|
26
|
-
const dataAttributes = isNullOrUndefined(data)
|
|
27
|
-
? undefined
|
|
28
|
-
: mapDataAttributes(data);
|
|
29
|
-
const id = name || generateGuid();
|
|
30
|
-
return (_jsx("div", { className: "bbr-color-picker", children: _jsx(ColorPickerControl, { id: id, title: title, value: value, disabled: disabled, className: elClassName, previewConfig: preview, onValueChange: onChange, defaultColor: defaultColor, dataAttributes: dataAttributes, styleClassName: styleClassName, validationMessages: validationMessages, containerClassName: containerClassName, isValidationDefined: isValidationDefined }) }));
|
|
19
|
+
const id = name ?? generateGuid();
|
|
20
|
+
return (_jsx("div", { className: "bbr-color-picker", children: _jsx(ColorPickerControl, { id: id, value: value, disabled: disabled, previewConfig: preview, onValueChange: onChange, defaultValue: defaultColor, elementClassName: elClassName, data: data, title: title, hint: hint, validationState: validationState }) }));
|
|
31
21
|
}
|
|
32
22
|
export default ColorPickerWithoutLabel;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CSSProperties } from "react";
|
|
2
2
|
import { Color } from "@bodynarf/utils";
|
|
3
|
-
import {
|
|
3
|
+
import { ElementFloatPosition, BaseInputElementProps } from "../../../types";
|
|
4
4
|
/** Color picker props type */
|
|
5
5
|
export interface ColorPickerProps extends Omit<BaseInputElementProps<Color>, "style" | "loading" | "readonly" | "placeholder"> {
|
|
6
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/color/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/color/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEzE,8BAA8B;AAC9B,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,EACrE,OAAO,GAAG,SAAS,GACnB,UAAU,GAAG,aAAa,CAC/B;IACG;;;OAGG;IACH,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACtC;AAED,yCAAyC;AACzC,MAAM,WAAW,wBAAyB,SAAQ,aAAa;IAC3D,gDAAgD;IAChD,kCAAkC,EAAE,MAAM,CAAC;IAE3C,sDAAsD;IACtD,uBAAuB,EAAE,MAAM,CAAC;CACnC;AAED,6DAA6D;AAC7D,MAAM,WAAW,wBAAwB;IACrC,mCAAmC;IACnC,QAAQ,EAAE,oBAAoB,CAAC;CAClC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import "../../../../common.scss";
|
|
3
|
-
import { DateProps } from "
|
|
2
|
+
import { DateProps } from "../..";
|
|
4
3
|
/** Date input component */
|
|
5
|
-
declare const DatePicker: ({ defaultValue, onValueChange, readonly, disabled, validationState, name, size,
|
|
4
|
+
declare const DatePicker: ({ defaultValue, onValueChange, readonly, disabled, validationState, name, size, rounded, loading, style, label, onBlur, className, title, data, hint, }: DateProps) => JSX.Element;
|
|
6
5
|
export default DatePicker;
|
|
7
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/date/component/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/date/component/index.tsx"],"names":[],"mappings":"AASA,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,2BAA2B;AAC3B,QAAA,MAAM,UAAU,4JASb,SAAS,KAAG,WA8Dd,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
|
-
import { generateGuid, getClassName, getValueOrDefault, isStringEmpty } from "@bodynarf/utils";
|
|
3
|
+
import { generateGuid, getClassName, getValueOrDefault, isNullOrUndefined, isStringEmpty } from "@bodynarf/utils";
|
|
4
|
+
import { ElementSize } from "../../../../types";
|
|
5
|
+
import { getStyleClassName, mapDataAttributes } from "../../../../utils";
|
|
6
|
+
import ComponentWithLabel from "../../internal/componentWithLabel";
|
|
7
|
+
import InternalHint from "../../internal/hint";
|
|
4
8
|
import "../../../../common.scss";
|
|
5
|
-
import { ElementSize } from "../../..";
|
|
6
|
-
import { getValidationValues } from "../../../../utils";
|
|
7
9
|
/** Date input component */
|
|
8
|
-
const DatePicker = ({ defaultValue, onValueChange, readonly, disabled, validationState, name, size,
|
|
10
|
+
const DatePicker = ({ defaultValue, onValueChange, readonly, disabled, validationState, name, size, rounded = false, loading = false, style, label, onBlur, className, title, data, hint, }) => {
|
|
9
11
|
const onChange = useCallback((event) => onValueChange(isStringEmpty(event.target.value)
|
|
10
12
|
? undefined
|
|
11
13
|
: new Date(event.target.value)), [onValueChange]);
|
|
12
|
-
const id = name
|
|
14
|
+
const id = name ?? generateGuid();
|
|
13
15
|
const elSizeClassName = "is-{0}".format(getValueOrDefault(size, ElementSize.Normal));
|
|
14
|
-
const [isValidationDefined, styleClassName, validationMessages] = getValidationValues(style, validationState);
|
|
15
16
|
const elClassName = getClassName([
|
|
16
17
|
className,
|
|
17
18
|
elSizeClassName,
|
|
18
|
-
|
|
19
|
+
getStyleClassName(style, validationState),
|
|
19
20
|
rounded ? "is-rounded" : "",
|
|
20
21
|
"input",
|
|
21
22
|
]);
|
|
@@ -24,25 +25,9 @@ const DatePicker = ({ defaultValue, onValueChange, readonly, disabled, validatio
|
|
|
24
25
|
loading ? "is-loading" : "",
|
|
25
26
|
]);
|
|
26
27
|
const stringifiedDefValue = defaultValue?.toISOString().split("T")[0];
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
]);
|
|
32
|
-
if (label.horizontal) {
|
|
33
|
-
const labelContainerClassName = getClassName([
|
|
34
|
-
"field-label",
|
|
35
|
-
elSizeClassName,
|
|
36
|
-
label.horizontalContainerClassName
|
|
37
|
-
]);
|
|
38
|
-
const fieldContainerClassName = getClassName([
|
|
39
|
-
"field-body",
|
|
40
|
-
label.horizontalFieldContainerClassName
|
|
41
|
-
]);
|
|
42
|
-
return (_jsxs("div", { className: "bbr-input field is-horizontal", children: [_jsx("div", { className: labelContainerClassName, children: _jsx("label", { className: labelClassName, htmlFor: id, children: label.caption }) }), _jsx("div", { className: fieldContainerClassName, children: _jsxs("div", { className: "field", children: [_jsx("div", { className: inputContainerClassName, children: _jsx("input", { type: "date", className: elClassName, readOnly: readonly, disabled: disabled, defaultValue: stringifiedDefValue, onChange: onChange, onBlur: onBlur, name: id, id: id }) }), isValidationDefined && validationMessages.length > 0 &&
|
|
43
|
-
_jsx("p", { className: `help m-help ${styleClassName}`, children: validationMessages.join("\n") })] }) })] }));
|
|
44
|
-
}
|
|
45
|
-
return (_jsxs("div", { className: "bbr-input field", children: [_jsx("label", { className: labelClassName, htmlFor: id, children: label.caption }), _jsx("div", { className: inputContainerClassName, children: _jsx("input", { type: "date", className: elClassName, readOnly: readonly, disabled: disabled, defaultValue: stringifiedDefValue, onChange: onChange, onBlur: onBlur, name: id, id: id }) }), isValidationDefined && validationMessages.length > 0 &&
|
|
46
|
-
_jsx("p", { className: `help m-help ${styleClassName}`, children: validationMessages.join("\n") })] }));
|
|
28
|
+
const dataAttributes = isNullOrUndefined(data)
|
|
29
|
+
? undefined
|
|
30
|
+
: mapDataAttributes(data);
|
|
31
|
+
return (_jsxs(ComponentWithLabel, { id: id, label: label, size: getValueOrDefault(size, ElementSize.Normal), children: [_jsx("div", { className: inputContainerClassName, children: _jsx("input", { type: "date", id: id, name: id, onBlur: onBlur, readOnly: readonly, disabled: disabled, onChange: onChange, className: elClassName, defaultValue: stringifiedDefValue, title: title, ...dataAttributes }) }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
|
|
47
32
|
};
|
|
48
33
|
export default DatePicker;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { BaseInputElementProps,
|
|
1
|
+
import { BaseInputElementProps, LabelConfiguration } from "../../../types";
|
|
2
2
|
/** Date input component props type */
|
|
3
3
|
export interface DateProps extends Omit<BaseInputElementProps<Date | undefined>, "placeholder"> {
|
|
4
4
|
/** Label configuration */
|
|
5
|
-
label:
|
|
5
|
+
label: LabelConfiguration;
|
|
6
6
|
/** Focus out event handler */
|
|
7
7
|
onBlur?: () => void;
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/date/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/date/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEvE,sCAAsC;AACtC,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,qBAAqB,CAAC,IAAI,GAAG,SAAS,CAAC,EAAE,aAAa,CAAC;IAC3F,0BAA0B;IAC1B,KAAK,EAAE,kBAAkB,CAAC;IAE1B,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/primitives/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/primitives/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ElementSize, LabelConfiguration } from "../../../../types";
|
|
3
|
+
/** Form input component with label props */
|
|
4
|
+
export interface ComponentWithLabelProps {
|
|
5
|
+
/** Label configuration */
|
|
6
|
+
label: LabelConfiguration;
|
|
7
|
+
/** Component size */
|
|
8
|
+
size: ElementSize;
|
|
9
|
+
/** Unique component identifier */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Node element with input element */
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
/** Form input component with describing label */
|
|
15
|
+
declare const ComponentWithLabel: ({ label, id, size, children, }: ComponentWithLabelProps) => JSX.Element;
|
|
16
|
+
export default ComponentWithLabel;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/internal/componentWithLabel/index.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE7D,4CAA4C;AAC5C,MAAM,WAAW,uBAAuB;IACpC,0BAA0B;IAC1B,KAAK,EAAE,kBAAkB,CAAC;IAE1B,qBAAqB;IACrB,IAAI,EAAE,WAAW,CAAC;IAElB,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IAEX,sCAAsC;IACtC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAED,iDAAiD;AACjD,QAAA,MAAM,kBAAkB,mCAIrB,uBAAuB,KAAG,WAoD5B,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|