@bodynarf/react.components 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bodynarf-react.components-1.10.0.tgz +0 -0
- package/components/accordion/component/index.js +3 -3
- package/components/anchor/component/index.js +2 -2
- package/components/anchor/components/anchorWithIcon/index.d.ts +8 -2
- package/components/anchor/components/anchorWithIcon/index.d.ts.map +1 -1
- package/components/anchor/components/anchorWithIcon/index.js +2 -2
- package/components/anchor/components/simpleAnchor/index.d.ts +2 -2
- package/components/anchor/components/simpleAnchor/index.d.ts.map +1 -1
- package/components/anchor/components/simpleAnchor/index.js +1 -1
- package/components/anchor/types.d.ts +3 -11
- package/components/anchor/types.d.ts.map +1 -1
- package/components/breadcrumbs/component/index.d.ts +7 -32
- package/components/breadcrumbs/component/index.d.ts.map +1 -1
- package/components/breadcrumbs/component/index.js +22 -6
- package/components/breadcrumbs/types.d.ts +30 -1
- package/components/breadcrumbs/types.d.ts.map +1 -1
- package/components/button/component/index.d.ts.map +1 -1
- package/components/button/component/index.js +3 -3
- package/components/button/types.d.ts +1 -1
- package/components/dropdown/component/style.scss +3 -3
- package/components/dropdown/components/compact/index.d.ts +8 -2
- package/components/dropdown/components/compact/index.d.ts.map +1 -1
- package/components/dropdown/components/compact/index.js +17 -5
- package/components/dropdown/components/label/component/index.d.ts +27 -0
- package/components/dropdown/components/label/component/index.d.ts.map +1 -0
- package/components/dropdown/components/label/component/index.js +16 -0
- package/components/dropdown/components/label/components/empty/index.d.ts +8 -0
- package/components/dropdown/components/label/components/empty/index.d.ts.map +1 -0
- package/components/dropdown/components/label/components/empty/index.js +16 -0
- package/components/dropdown/components/label/components/selected/index.d.ts +8 -0
- package/components/dropdown/components/label/components/selected/index.d.ts.map +1 -0
- package/components/dropdown/components/label/components/selected/index.js +20 -0
- package/components/dropdown/components/label/components/selectedWithIcon/index.d.ts +8 -0
- package/components/dropdown/components/label/components/selectedWithIcon/index.d.ts.map +1 -0
- package/components/dropdown/components/label/components/selectedWithIcon/index.js +28 -0
- package/components/dropdown/components/label/components/withSearch/index.d.ts +16 -0
- package/components/dropdown/components/label/components/withSearch/index.d.ts.map +1 -0
- package/components/dropdown/components/label/components/withSearch/index.js +33 -0
- package/components/dropdown/components/label/components/withSearch/style.scss +29 -0
- package/components/dropdown/components/label/index.d.ts +1 -17
- package/components/dropdown/components/label/index.d.ts.map +1 -1
- package/components/dropdown/components/label/index.js +1 -54
- package/components/dropdown/components/withLabel/index.d.ts +3 -2
- package/components/dropdown/components/withLabel/index.d.ts.map +1 -1
- package/components/dropdown/components/withLabel/index.js +8 -82
- package/components/dropdown/types.d.ts +8 -0
- package/components/dropdown/types.d.ts.map +1 -1
- package/components/icon/component/index.d.ts +3 -2
- package/components/icon/component/index.d.ts.map +1 -1
- package/components/icon/component/index.js +4 -3
- package/components/icon/types.d.ts +2 -0
- package/components/icon/types.d.ts.map +1 -1
- package/components/multiselect/component/index.d.ts +8 -0
- package/components/multiselect/component/index.d.ts.map +1 -0
- package/components/multiselect/component/index.js +13 -0
- package/components/multiselect/component/style.scss +20 -0
- package/components/multiselect/components/item/index.d.ts +25 -0
- package/components/multiselect/components/item/index.d.ts.map +1 -0
- package/components/multiselect/components/item/index.js +62 -0
- package/components/multiselect/components/label/component/index.d.ts +20 -0
- package/components/multiselect/components/label/component/index.d.ts.map +1 -0
- package/components/multiselect/components/label/component/index.js +12 -0
- package/components/multiselect/components/label/components/empty/index.d.ts +8 -0
- package/components/multiselect/components/label/components/empty/index.d.ts.map +1 -0
- package/components/multiselect/components/label/components/empty/index.js +16 -0
- package/components/multiselect/components/label/components/nonEmpty/index.d.ts +8 -0
- package/components/multiselect/components/label/components/nonEmpty/index.d.ts.map +1 -0
- package/components/multiselect/components/label/components/nonEmpty/index.js +16 -0
- package/components/multiselect/components/label/index.d.ts +2 -0
- package/components/multiselect/components/label/index.d.ts.map +1 -0
- package/components/multiselect/components/label/index.js +1 -0
- package/components/multiselect/components/withLabel/index.d.ts +6 -0
- package/components/multiselect/components/withLabel/index.d.ts.map +1 -0
- package/components/multiselect/components/withLabel/index.js +11 -0
- package/components/multiselect/components/withoutLabel/index.d.ts +10 -0
- package/components/multiselect/components/withoutLabel/index.d.ts.map +1 -0
- package/components/multiselect/components/withoutLabel/index.js +84 -0
- package/components/multiselect/index.d.ts +3 -0
- package/components/multiselect/index.d.ts.map +1 -0
- package/components/multiselect/index.js +2 -0
- package/components/multiselect/types.d.ts +41 -0
- package/components/multiselect/types.d.ts.map +1 -0
- package/components/multiselect/types.js +1 -0
- package/components/paginator/component/index.d.ts.map +1 -1
- package/components/paginator/component/index.js +22 -5
- package/components/paginator/index.d.ts +0 -1
- package/components/paginator/index.d.ts.map +1 -1
- package/components/paginator/index.js +0 -1
- package/components/primitives/checkbox/component/index.d.ts +1 -1
- package/components/primitives/checkbox/component/index.d.ts.map +1 -1
- package/components/primitives/checkbox/component/index.js +8 -6
- package/components/primitives/checkbox/component/style.scss +22 -3
- package/components/primitives/color/components/picker/index.d.ts +3 -3
- package/components/primitives/color/components/picker/index.d.ts.map +1 -1
- package/components/primitives/color/components/picker/index.js +8 -8
- package/components/primitives/color/components/withLabel/index.d.ts +1 -1
- package/components/primitives/color/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/color/components/withLabel/index.js +3 -4
- package/components/primitives/color/components/withoutLabel/index.d.ts +1 -1
- package/components/primitives/color/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/color/components/withoutLabel/index.js +2 -3
- package/components/primitives/date/component/index.d.ts +2 -2
- package/components/primitives/date/component/index.d.ts.map +1 -1
- package/components/primitives/date/component/index.js +5 -7
- package/components/primitives/date/component/style.scss +11 -0
- package/components/primitives/date/types.d.ts +1 -1
- package/components/primitives/date/types.d.ts.map +1 -1
- package/components/primitives/internal/componentWithLabel/index.d.ts.map +1 -1
- package/components/primitives/internal/componentWithLabel/index.js +2 -2
- package/components/primitives/internal/hint/index.d.ts +3 -7
- package/components/primitives/internal/hint/index.d.ts.map +1 -1
- package/components/primitives/internal/hint/index.js +1 -0
- package/components/primitives/internal/hint/style.scss +4 -0
- package/components/primitives/multiline/component/index.d.ts +0 -1
- package/components/primitives/multiline/component/index.d.ts.map +1 -1
- package/components/primitives/multiline/component/index.js +0 -1
- package/components/primitives/multiline/components/withLabel/index.d.ts +1 -1
- package/components/primitives/multiline/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/multiline/components/withLabel/index.js +4 -6
- package/components/primitives/multiline/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/multiline/components/withoutLabel/index.js +4 -5
- package/components/primitives/number/components/withLabel/index.d.ts +1 -1
- package/components/primitives/number/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/number/components/withLabel/index.js +4 -6
- package/components/primitives/number/components/withoutLabel/index.d.ts +1 -1
- package/components/primitives/number/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/number/components/withoutLabel/index.js +5 -6
- package/components/primitives/password/components/withLabel/index.d.ts +1 -1
- package/components/primitives/password/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/password/components/withLabel/index.js +5 -6
- package/components/primitives/password/components/withoutLabel/index.js +6 -7
- package/components/primitives/text/component/index.d.ts +0 -1
- package/components/primitives/text/component/index.d.ts.map +1 -1
- package/components/primitives/text/component/index.js +0 -1
- package/components/primitives/text/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/text/components/withLabel/index.js +4 -6
- package/components/primitives/text/components/withoutLabel/index.d.ts +1 -1
- package/components/primitives/text/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/text/components/withoutLabel/index.js +5 -6
- package/components/search/component/index.d.ts.map +1 -1
- package/components/search/component/index.js +6 -8
- package/components/table/component/index.d.ts +2 -35
- package/components/table/component/index.d.ts.map +1 -1
- package/components/table/component/index.js +4 -2
- package/components/table/component/style.scss +21 -0
- package/components/table/components/heading/index.d.ts.map +1 -1
- package/components/table/components/heading/index.js +3 -3
- package/components/table/types.d.ts +36 -1
- package/components/table/types.d.ts.map +1 -1
- package/components/tabs/component/index.d.ts +3 -27
- package/components/tabs/component/index.d.ts.map +1 -1
- package/components/tabs/component/index.js +3 -3
- package/components/tabs/types.d.ts +24 -1
- package/components/tabs/types.d.ts.map +1 -1
- package/components/tag/component/index.d.ts.map +1 -1
- package/components/tag/component/index.js +3 -3
- package/components/tag/types.d.ts +3 -3
- package/components/tag/types.d.ts.map +1 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.d.ts.map +1 -1
- package/hooks/index.js +1 -0
- package/hooks/useComponentOutsideClick.d.ts.map +1 -1
- package/hooks/useComponentOutsideClick.js +2 -3
- package/hooks/useUnmount.d.ts +8 -0
- package/hooks/useUnmount.d.ts.map +1 -0
- package/hooks/useUnmount.js +22 -0
- package/package.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/common.scss +0 -8
- package/components/paginator/utils.d.ts +0 -10
- package/components/paginator/utils.d.ts.map +0 -1
- package/components/paginator/utils.js +0 -18
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { MultiselectProps } from "../../types";
|
|
3
|
+
/** Props type of `MultiselectWithoutLabel` */
|
|
4
|
+
declare type MultiselectWithoutLabelProps = MultiselectProps & {
|
|
5
|
+
/** Manual component identifier */
|
|
6
|
+
id?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const MultiselectWithoutLabel: FC<MultiselectWithoutLabelProps>;
|
|
9
|
+
export default MultiselectWithoutLabel;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/multiselect/components/withoutLabel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA4C,MAAM,OAAO,CAAC;AAUrE,OAAO,EAAE,gBAAgB,EAA2C,MAAM,aAAa,CAAC;AAIxF,8CAA8C;AAC9C,aAAK,4BAA4B,GAAG,gBAAgB,GAAG;IACnD,kCAAkC;IAClC,EAAE,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,QAAA,MAAM,uBAAuB,EAAE,EAAE,CAAC,4BAA4B,CAiJ7D,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
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, isNullOrUndefined } from "@bodynarf/utils";
|
|
4
|
+
import { ElementSize } from "../../../../types";
|
|
5
|
+
import { getStyleClassName, mapDataAttributes } from "../../../../utils";
|
|
6
|
+
import { useComponentOutsideClick } from "../../../../hooks";
|
|
7
|
+
import Search from "../../../search";
|
|
8
|
+
import InternalHint from "../../../primitives/internal/hint";
|
|
9
|
+
import MultiselectItem from "../item";
|
|
10
|
+
import MultiselectLabel from "../label/component";
|
|
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
|
+
const generatedId = useId();
|
|
13
|
+
const id = propsId ?? generatedId;
|
|
14
|
+
const [isListVisible, setListVisible] = useState(false);
|
|
15
|
+
const [selectedItems, setSelectedItems] = useState(items
|
|
16
|
+
.filter(({ selected }) => selected)
|
|
17
|
+
.map(({ id }) => id)
|
|
18
|
+
??
|
|
19
|
+
[]);
|
|
20
|
+
const onItemClick = useCallback((item) => {
|
|
21
|
+
const isItemSelected = selectedItems.includes(item.id);
|
|
22
|
+
setSelectedItems(x => isItemSelected
|
|
23
|
+
? x.filter(x => x !== item.id)
|
|
24
|
+
: [...x, item.id]);
|
|
25
|
+
item.selected = isItemSelected;
|
|
26
|
+
onChange(item, isItemSelected);
|
|
27
|
+
}, [onChange, selectedItems]);
|
|
28
|
+
const onItemSelectChange = useCallback((item, selected) => {
|
|
29
|
+
setSelectedItems(x => selected
|
|
30
|
+
? [...x, item.id]
|
|
31
|
+
: x.filter(x => x !== item.id));
|
|
32
|
+
item.selected = selected;
|
|
33
|
+
onChange(item, selected);
|
|
34
|
+
}, [onChange]);
|
|
35
|
+
const onLabelClick = useCallback((event) => {
|
|
36
|
+
if (disabled) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const target = event.target;
|
|
40
|
+
if (isNullOrUndefined(target)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (target.classList.contains("bi-plus-lg")) {
|
|
44
|
+
setSelectedItems([]);
|
|
45
|
+
onClear?.();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
setListVisible(state => !state);
|
|
49
|
+
}
|
|
50
|
+
}, [onClear, setListVisible, disabled]);
|
|
51
|
+
useComponentOutsideClick(`[data-dropdown-id="${id}"]`, isListVisible, () => setListVisible(false), hideOnOuterClick);
|
|
52
|
+
const classNames = getClassName([
|
|
53
|
+
"bbr-multiselect",
|
|
54
|
+
"bbr-dropdown",
|
|
55
|
+
className,
|
|
56
|
+
disabled ? "bbr-dropdown--disabled" : "",
|
|
57
|
+
compact ? "bbr-dropdown--compact" : "",
|
|
58
|
+
isListVisible ? "is-active" : "",
|
|
59
|
+
isNullOrEmpty(listMaxHeight) ? "bbr-dropdown--height-default" : "",
|
|
60
|
+
"dropdown",
|
|
61
|
+
]);
|
|
62
|
+
const labelComponentClassName = getStyleClassName(undefined, validationState);
|
|
63
|
+
const selectedItemsCount = selectedItems.length;
|
|
64
|
+
const dataAttributes = isNullOrUndefined(data)
|
|
65
|
+
? undefined
|
|
66
|
+
: mapDataAttributes(data);
|
|
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 })] }));
|
|
69
|
+
};
|
|
70
|
+
export default MultiselectWithoutLabel;
|
|
71
|
+
const DropdownContent = ({ noDataText, id, listMaxHeight, noDataByQuery, items, selectedItems, onItemClick, onItemSelectChange, searchable = true, checkboxConfig, }) => {
|
|
72
|
+
const [search, setSearch] = useState("");
|
|
73
|
+
if (items.length === 0) {
|
|
74
|
+
return (_jsx("div", { className: "dropdown-content", children: _jsx("span", { className: "dropdown-item", children: noDataText }) }));
|
|
75
|
+
}
|
|
76
|
+
const filteredItems = isNullOrEmpty(search)
|
|
77
|
+
? items
|
|
78
|
+
: items.filter(({ displayValue }) => displayValue.toLocaleLowerCase().includes(search.toLocaleLowerCase()));
|
|
79
|
+
if (filteredItems.length === 0) {
|
|
80
|
+
return (_jsxs("div", { className: "dropdown-content", style: { maxHeight: listMaxHeight }, children: [_jsx("div", { className: "mx-2 my-1", children: _jsx(Search, { caption: "search", onSearch: setSearch, searchType: "byTyping", size: ElementSize.Small }) }), _jsx("span", { className: "dropdown-item", children: noDataByQuery })] }));
|
|
81
|
+
}
|
|
82
|
+
return (_jsxs("div", { className: "dropdown-content", style: { maxHeight: listMaxHeight }, children: [searchable &&
|
|
83
|
+
_jsx("div", { className: "mx-2 my-1", children: _jsx(Search, { caption: "search", onSearch: setSearch, searchType: "byTyping", size: ElementSize.Small }) }), _jsx("ul", { children: filteredItems.map(item => _jsx(MultiselectItem, { item: item, rootId: id, onItemClick: onItemClick, onChange: onItemSelectChange, checkboxConfig: checkboxConfig, selected: selectedItems.includes(item.id) }, item.id)) })] }));
|
|
84
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/multiselect/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DropdownProps, SelectableItem } from "../dropdown";
|
|
2
|
+
import { CheckBoxProps } from "../primitives";
|
|
3
|
+
/** Single multiselect item that user can select */
|
|
4
|
+
export declare type MultiselectItem = SelectableItem & {
|
|
5
|
+
/** Is item selected */
|
|
6
|
+
selected: boolean;
|
|
7
|
+
};
|
|
8
|
+
/** Props type of `Multiselect` */
|
|
9
|
+
export declare type MultiselectProps = Omit<DropdownProps, "items" | "onSelect" | "value" | "deselectable" | "searchable"> & {
|
|
10
|
+
/** Items which can be selected */
|
|
11
|
+
items: Array<MultiselectItem>;
|
|
12
|
+
/**
|
|
13
|
+
* Handler of changing select state of item
|
|
14
|
+
* @description `item.selected` will be set by component
|
|
15
|
+
* @param item Item that triggered event
|
|
16
|
+
* @param selected New select flag value
|
|
17
|
+
*/
|
|
18
|
+
onChange: (item: MultiselectItem, selected: boolean) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Handler of clear selection event.
|
|
21
|
+
* When no handler specified - clear selection cannot be performed
|
|
22
|
+
*/
|
|
23
|
+
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
|
+
/**
|
|
31
|
+
* Text which would be displayed when search query applied and no items found
|
|
32
|
+
*/
|
|
33
|
+
noDataByQuery?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Is search through items enabled. Default is `true`
|
|
36
|
+
*/
|
|
37
|
+
searchable?: boolean;
|
|
38
|
+
/** Customization for checkbox */
|
|
39
|
+
checkboxConfig?: Pick<CheckBoxProps, "block" | "className" | "data" | "fixBackgroundColor" | "hasBackgroundColor" | "style" | "withoutBorder" | "rounded">;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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,oBAAY,eAAe,GAAG,cAAc,GAAG;IAC3C,uBAAuB;IACvB,QAAQ,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,kCAAkC;AAClC,oBAAY,gBAAgB,GAAG,IAAI,CAC/B,aAAa,EACX,OAAO,GAAG,UAAU,GACpB,OAAO,GAAG,cAAc,GACxB,YAAY,CACjB,GAAG;IACA,kCAAkC;IAClC,KAAK,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAE9B;;;;;OAKG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAE7D;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,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;CACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/paginator/component/index.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/paginator/component/index.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC;;;EAGE;AACF,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAC9B,KAAK,EAAE,YAAY,EAAE,WAAe,EACpC,QAA+B,EAAE,IAAyB,EAC1D,OAAe,EAAE,eAAuB,EACxC,cAAkB,EAElB,SAAS,EAAE,KAAK,EAAE,IAAI,GACzB,EAAE,cAAc,GAAG,GAAG,CAAC,OAAO,CAqH9B"}
|
|
@@ -2,13 +2,12 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { useCallback, useMemo } from "react";
|
|
3
3
|
import { getClassName, isNullOrEmpty, isNullOrUndefined } from "@bodynarf/utils";
|
|
4
4
|
import { mapDataAttributes } from "../../../utils";
|
|
5
|
-
import { ElementPosition } from "../../../types";
|
|
6
|
-
import { generatePageNumbers } from "../..";
|
|
5
|
+
import { ElementPosition, ElementSize } from "../../../types";
|
|
7
6
|
/**
|
|
8
7
|
* Paginator component.
|
|
9
8
|
* Used for visualization of paging configuration
|
|
10
9
|
*/
|
|
11
|
-
export default function Paginator({ count, onPageChange, currentPage = 0, position = ElementPosition.Left, size, rounded = false, showNextButtons = false, nearPagesCount, className, title, data, }) {
|
|
10
|
+
export default function Paginator({ count, onPageChange, currentPage = 0, position = ElementPosition.Left, size = ElementSize.Normal, rounded = false, showNextButtons = false, nearPagesCount = 3, className, title, data, }) {
|
|
12
11
|
const pageChange = useCallback((event) => {
|
|
13
12
|
const target = event.target;
|
|
14
13
|
const pageRaw = target.dataset["page"];
|
|
@@ -32,12 +31,12 @@ export default function Paginator({ count, onPageChange, currentPage = 0, positi
|
|
|
32
31
|
className,
|
|
33
32
|
paginationPositionToClassMap.get(position),
|
|
34
33
|
rounded ? "is-rounded" : "",
|
|
35
|
-
|
|
34
|
+
size === ElementSize.Normal ? "" : `is-${size}`,
|
|
36
35
|
]);
|
|
37
36
|
const dataAttributes = isNullOrUndefined(data)
|
|
38
37
|
? undefined
|
|
39
38
|
: mapDataAttributes(data);
|
|
40
|
-
return (_jsxs("nav", {
|
|
39
|
+
return (_jsxs("nav", { role: "navigation", className: classNames, "aria-label": "pagination", title: title, ...dataAttributes, children: [showNextButtons &&
|
|
41
40
|
_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
41
|
_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) &&
|
|
43
42
|
_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 }) })] })] })] }));
|
|
@@ -50,3 +49,21 @@ const paginationPositionToClassMap = new Map([
|
|
|
50
49
|
[ElementPosition.Center, "is-centered"],
|
|
51
50
|
[ElementPosition.Right, "is-right"]
|
|
52
51
|
]);
|
|
52
|
+
/**
|
|
53
|
+
* Get nearest numbers from each side (left & right)
|
|
54
|
+
* @param page Number of current page
|
|
55
|
+
* @param count Amount of pages
|
|
56
|
+
* @param size Amount of pages from left & right to current page
|
|
57
|
+
* @throws Current page is greater than pages amount
|
|
58
|
+
* @returns Array of nearest numbers to current page
|
|
59
|
+
*/
|
|
60
|
+
const generatePageNumbers = (page, count, size) => {
|
|
61
|
+
if (page < 0 || count <= 0 || page > count) {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
return [
|
|
65
|
+
...new Array(size).fill(page).map((_, i) => page - i - 1).filter(x => x > 0 && x < page).reverse(),
|
|
66
|
+
page,
|
|
67
|
+
...new Array(size).fill(page).map((_, i) => page + i + 1).filter(x => x > 0 && x > page && x <= count)
|
|
68
|
+
];
|
|
69
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/paginator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,cAAc,SAAS,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/paginator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,cAAc,SAAS,CAAC"}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
import "./style.scss";
|
|
3
3
|
import { CheckBoxProps } from "../..";
|
|
4
4
|
/** Boolean input component */
|
|
5
|
-
declare const CheckBox: ({
|
|
5
|
+
declare const CheckBox: ({ onValueChange, defaultValue, label, name, size, style, disabled, rounded, block, withoutBorder, hasBackgroundColor, fixBackgroundColor, isFormLabel, className, title, data, }: CheckBoxProps) => JSX.Element;
|
|
6
6
|
export default CheckBox;
|
|
7
7
|
//# 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":";AAQA,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,8BAA8B;AAC9B,QAAA,MAAM,QAAQ,
|
|
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,qLAWX,aAAa,KAAG,WAoFlB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -6,16 +6,15 @@ import { mapDataAttributes } from "../../../../utils";
|
|
|
6
6
|
import ComponentWithLabel from "../../internal/componentWithLabel";
|
|
7
7
|
import "./style.scss";
|
|
8
8
|
/** Boolean input component */
|
|
9
|
-
const CheckBox = ({
|
|
9
|
+
const CheckBox = ({ onValueChange, defaultValue, label, name = generateGuid(), size = ElementSize.Normal, style, disabled = false, rounded = false, block = false, withoutBorder = false, hasBackgroundColor = false, fixBackgroundColor = false, isFormLabel = false, className, title, data, }) => {
|
|
10
10
|
const onChecked = useCallback((event) => onValueChange(event.target.checked), [onValueChange]);
|
|
11
|
-
const id = name ?? generateGuid();
|
|
12
11
|
const elClassName = getClassName([
|
|
13
12
|
"is-checkradio",
|
|
14
13
|
"m-check-radio",
|
|
15
14
|
className,
|
|
16
15
|
hasBackgroundColor ? "has-background-color" : "",
|
|
17
16
|
fixBackgroundColor && hasBackgroundColor ? "m-has-background-color" : "",
|
|
18
|
-
|
|
17
|
+
size === ElementSize.Normal ? "" : `is-${size}`,
|
|
19
18
|
rounded ? "is-circle" : "",
|
|
20
19
|
isNullOrUndefined(style) ? "" : `is-${style}`,
|
|
21
20
|
block ? "is-block" : "",
|
|
@@ -25,11 +24,14 @@ const CheckBox = ({ label, onValueChange, defaultValue, name, disabled, size, st
|
|
|
25
24
|
? undefined
|
|
26
25
|
: mapDataAttributes(data);
|
|
27
26
|
if (!isNullOrUndefined(label) && isFormLabel) {
|
|
28
|
-
return (_jsxs(ComponentWithLabel, { id:
|
|
27
|
+
return (_jsxs(ComponentWithLabel, { id: name, label: {
|
|
29
28
|
...label,
|
|
30
29
|
horizontalContainerClassName: getClassName([label.horizontalContainerClassName, "p-0"]),
|
|
31
|
-
}, size: ElementSize.Normal, children: [_jsx("input", { type: "checkbox", id:
|
|
30
|
+
}, size: ElementSize.Normal, children: [_jsx("input", { type: "checkbox", id: name, name: name, disabled: disabled, onChange: onChecked, className: elClassName, defaultChecked: defaultValue, title: title, ...dataAttributes }), _jsx("label", { className: "is-empty", htmlFor: name })] }));
|
|
32
31
|
}
|
|
33
|
-
|
|
32
|
+
const labelClassName = isNullOrUndefined(label)
|
|
33
|
+
? "is-empty"
|
|
34
|
+
: undefined;
|
|
35
|
+
return (_jsxs("div", { className: "bbr-field bbr-input field mr-2", children: [_jsx("input", { type: "checkbox", id: name, name: name, disabled: disabled, onChange: onChecked, className: elClassName, defaultChecked: defaultValue, title: title, ...dataAttributes }), _jsx("label", { htmlFor: name, className: labelClassName, children: label?.caption })] }));
|
|
34
36
|
};
|
|
35
37
|
export default CheckBox;
|
|
@@ -3,8 +3,27 @@
|
|
|
3
3
|
border-color: #dbdbdb !important;
|
|
4
4
|
background-color: transparent !important;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
|
|
7
|
+
&.is-block + label.is-empty {
|
|
8
|
+
&::before {
|
|
9
|
+
left: 0.25rem !important;
|
|
10
|
+
top: 0.25rem !important;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&::after {
|
|
14
|
+
top: 0.45rem;
|
|
15
|
+
left: 0.7rem;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&:not(.is-block) + label {
|
|
20
|
+
&::after {
|
|
21
|
+
top: 0.275rem;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
& + label.is-empty {
|
|
26
|
+
padding-left: 1rem;
|
|
27
|
+
margin: 0 !important;
|
|
9
28
|
}
|
|
10
29
|
}
|
|
@@ -3,8 +3,6 @@ import { BaseInputElementProps } from "../../../../../types";
|
|
|
3
3
|
import { ColorPickerPreviewConfig } from "../..";
|
|
4
4
|
/** Props of `ColorPickerControl` */
|
|
5
5
|
export interface ColorPickerControlProps extends Omit<BaseInputElementProps<string>, "onValueChange" | "placeholder" | "rounded" | "readonly" | "loading" | "className"> {
|
|
6
|
-
/** Preview element configuration */
|
|
7
|
-
previewConfig?: ColorPickerPreviewConfig;
|
|
8
6
|
/** Current color value */
|
|
9
7
|
value: string;
|
|
10
8
|
/** Control unique identifier */
|
|
@@ -13,8 +11,10 @@ export interface ColorPickerControlProps extends Omit<BaseInputElementProps<stri
|
|
|
13
11
|
elementClassName: string;
|
|
14
12
|
/** Handler of control value change*/
|
|
15
13
|
onValueChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
14
|
+
/** Preview element configuration */
|
|
15
|
+
previewConfig?: ColorPickerPreviewConfig;
|
|
16
16
|
}
|
|
17
17
|
/** Color picker container component */
|
|
18
|
-
declare const ColorPickerControl: ({
|
|
18
|
+
declare const ColorPickerControl: ({ value, defaultValue, onValueChange, elementClassName, disabled, previewConfig, size, id, title, data, hint, validationState, }: ColorPickerControlProps) => JSX.Element;
|
|
19
19
|
export default ColorPickerControl;
|
|
20
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,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,
|
|
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,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;IAE9D,oCAAoC;IACpC,aAAa,CAAC,EAAE,wBAAwB,CAAC;CAC5C;AAED,uCAAuC;AACvC,QAAA,MAAM,kBAAkB,qIAQrB,uBAAuB,KAAG,WA0C5B,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -4,11 +4,11 @@ import { ElementPosition } from "../../../../../types";
|
|
|
4
4
|
import { mapDataAttributes } from "../../../../../utils";
|
|
5
5
|
import InternalHint from "../../../internal/hint";
|
|
6
6
|
/** Color picker container component */
|
|
7
|
-
const ColorPickerControl = ({
|
|
7
|
+
const ColorPickerControl = ({ value, defaultValue, onValueChange, elementClassName, disabled = false, previewConfig, size, id, title, data, hint, validationState, }) => {
|
|
8
8
|
if (!isNullOrUndefined(previewConfig)) {
|
|
9
|
-
return (_jsx(PickerWithPreview, { id: id, size: size, value: value, disabled: disabled,
|
|
9
|
+
return (_jsx(PickerWithPreview, { id: id, size: size, value: value, disabled: disabled, defaultValue: defaultValue, onValueChange: onValueChange, previewConfig: previewConfig, elementClassName: elementClassName, data: data, title: title }));
|
|
10
10
|
}
|
|
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
|
|
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, ...data, title: title }) }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
|
|
12
12
|
};
|
|
13
13
|
export default ColorPickerControl;
|
|
14
14
|
/** Picker sub component with preview */
|
|
@@ -29,14 +29,14 @@ const PickerWithPreview = ({ elementClassName, disabled, size, defaultValue, onV
|
|
|
29
29
|
"is-flex-grow-1",
|
|
30
30
|
previewConfig.position === ElementPosition.Left ? "ml-1" : "mr-1",
|
|
31
31
|
]);
|
|
32
|
-
if (previewConfig.position === ElementPosition.
|
|
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: {
|
|
32
|
+
if (previewConfig.position === ElementPosition.Right) {
|
|
33
|
+
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: {
|
|
34
34
|
"--color-picker__background-color": value,
|
|
35
35
|
"--color-picker__color": color,
|
|
36
|
-
}, children: value }), _jsx(
|
|
36
|
+
}, children: value }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
|
|
37
37
|
}
|
|
38
|
-
return (_jsxs("div", { className: "is-flex is-flex-direction-row is-flex-wrap-nowrap is-justify-content-start", children: [_jsx("
|
|
38
|
+
return (_jsxs("div", { className: "is-flex is-flex-direction-row is-flex-wrap-nowrap is-justify-content-start", children: [_jsx("button", { className: classNames, style: {
|
|
39
39
|
"--color-picker__background-color": value,
|
|
40
40
|
"--color-picker__color": color,
|
|
41
|
-
}, children: value }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
|
|
41
|
+
}, 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 })] }));
|
|
42
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({ preview, name, defaultValue,
|
|
4
|
+
declare function ColorPickerWithLabel({ preview, name, defaultValue, onValueChange, validationState, disabled, rounded, size, label, hint, className, title, data, }: 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":";AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAGzC,6CAA6C;AAC7C,iBAAS,oBAAoB,CAAC,EAC1B,OAAO,EACP,
|
|
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,IAAqB,EACrB,YAAY,EAAE,aAAa,EAC3B,eAAe,EACf,QAAgB,EAAE,OAAe,EAAE,IAAyB,EAC5D,KAAK,EAEL,IAAI,EACJ,SAAS,EAAE,KAAK,EAAE,IAAI,GACzB,EAAE,gBAAgB,eAgDlB;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { getStyleClassName } from "../../../../../utils";
|
|
|
6
6
|
import ComponentWithLabel from "../../../internal/componentWithLabel";
|
|
7
7
|
import ColorPickerControl from "../picker";
|
|
8
8
|
/** Color picker component with form label */
|
|
9
|
-
function ColorPickerWithLabel({ preview, name, defaultValue,
|
|
9
|
+
function ColorPickerWithLabel({ preview, name = generateGuid(), defaultValue, onValueChange, validationState, disabled = false, rounded = false, size = ElementSize.Normal, label, hint, className, title, data, }) {
|
|
10
10
|
const defaultColor = isNullOrUndefined(defaultValue)
|
|
11
11
|
? whiteHex
|
|
12
12
|
: rgbToHex(defaultValue);
|
|
@@ -17,10 +17,9 @@ function ColorPickerWithLabel({ preview, name, defaultValue, validationState, on
|
|
|
17
17
|
className,
|
|
18
18
|
rounded ? "is-rounded" : "",
|
|
19
19
|
getStyleClassName(undefined, validationState),
|
|
20
|
-
|
|
20
|
+
size === ElementSize.Normal ? "" : `is-${size}`,
|
|
21
21
|
"input",
|
|
22
22
|
]);
|
|
23
|
-
|
|
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 }) }));
|
|
23
|
+
return (_jsx(ComponentWithLabel, { id: name, size: size, label: label, children: _jsx(ColorPickerControl, { id: name, value: value, disabled: disabled, previewConfig: preview, onValueChange: onChange, defaultValue: defaultColor, elementClassName: elClassName, hint: hint, validationState: validationState, data: data, title: title }) }));
|
|
25
24
|
}
|
|
26
25
|
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({ preview, name, defaultValue,
|
|
4
|
+
declare function ColorPickerWithoutLabel({ preview, name, defaultValue, onValueChange, validationState, 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":";AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAGzC,gDAAgD;AAChD,iBAAS,uBAAuB,CAAC,EAC7B,OAAO,EACP,
|
|
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,IAAqB,EACrB,YAAY,EAAE,aAAa,EAC3B,eAAe,EACf,QAAgB,EAAE,OAAe,EAAE,IAAI,EAEvC,SAAS,EAAE,KAAK,EAAE,IAAI,EACtB,IAAI,GACP,EAAE,gBAAgB,eA6ClB;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { useCallback, useEffect, useState } from "react";
|
|
|
3
3
|
import { generateGuid, getClassName, hexToRgb, isNullOrUndefined, rgbToHex, whiteHex } from "@bodynarf/utils";
|
|
4
4
|
import ColorPickerControl from "../picker";
|
|
5
5
|
/** Color picker component without form label */
|
|
6
|
-
function ColorPickerWithoutLabel({ preview, name, defaultValue,
|
|
6
|
+
function ColorPickerWithoutLabel({ preview, name = generateGuid(), defaultValue, onValueChange, validationState, disabled = false, rounded = false, size, className, title, data, hint, }) {
|
|
7
7
|
const defaultColor = isNullOrUndefined(defaultValue)
|
|
8
8
|
? whiteHex
|
|
9
9
|
: rgbToHex(defaultValue);
|
|
@@ -16,7 +16,6 @@ function ColorPickerWithoutLabel({ preview, name, defaultValue, validationState,
|
|
|
16
16
|
isNullOrUndefined(size) ? "" : `is-${size}`,
|
|
17
17
|
"input",
|
|
18
18
|
]);
|
|
19
|
-
|
|
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 }) }));
|
|
19
|
+
return (_jsx("div", { className: "bbr-color-picker", children: _jsx(ColorPickerControl, { id: name, value: value, disabled: disabled, previewConfig: preview, onValueChange: onChange, defaultValue: defaultColor, elementClassName: elClassName, data: data, title: title, hint: hint, validationState: validationState }) }));
|
|
21
20
|
}
|
|
22
21
|
export default ColorPickerWithoutLabel;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import "
|
|
2
|
+
import "./style.scss";
|
|
3
3
|
import { DateProps } from "../..";
|
|
4
4
|
/** Date input component */
|
|
5
|
-
declare const DatePicker: ({ defaultValue, onValueChange,
|
|
5
|
+
declare const DatePicker: ({ defaultValue, onValueChange, validationState, name, style, size, readonly, disabled, rounded, loading, label, onBlur, className, title, data, hint, }: DateProps) => JSX.Element;
|
|
6
6
|
export default DatePicker;
|
|
7
7
|
//# 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":";AASA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/date/component/index.tsx"],"names":[],"mappings":";AASA,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,2BAA2B;AAC3B,QAAA,MAAM,UAAU,4JAWb,SAAS,KAAG,WA2Dd,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
|
-
import { generateGuid, getClassName,
|
|
3
|
+
import { generateGuid, getClassName, isNullOrUndefined, isStringEmpty } from "@bodynarf/utils";
|
|
4
4
|
import { ElementSize } from "../../../../types";
|
|
5
5
|
import { getStyleClassName, mapDataAttributes } from "../../../../utils";
|
|
6
6
|
import ComponentWithLabel from "../../internal/componentWithLabel";
|
|
7
7
|
import InternalHint from "../../internal/hint";
|
|
8
|
-
import "
|
|
8
|
+
import "./style.scss";
|
|
9
9
|
/** Date input component */
|
|
10
|
-
const DatePicker = ({ defaultValue, onValueChange,
|
|
10
|
+
const DatePicker = ({ defaultValue, onValueChange, validationState, name = generateGuid(), style, size = ElementSize.Normal, readonly = false, disabled = false, rounded = false, loading = false, label, onBlur, className, title, data, hint, }) => {
|
|
11
11
|
const onChange = useCallback((event) => onValueChange(isStringEmpty(event.target.value)
|
|
12
12
|
? undefined
|
|
13
13
|
: new Date(event.target.value)), [onValueChange]);
|
|
14
|
-
const id = name ?? generateGuid();
|
|
15
|
-
const elSizeClassName = "is-{0}".format(getValueOrDefault(size, ElementSize.Normal));
|
|
16
14
|
const elClassName = getClassName([
|
|
17
15
|
className,
|
|
18
|
-
|
|
16
|
+
size === ElementSize.Normal ? "" : `is-${size}`,
|
|
19
17
|
getStyleClassName(style, validationState),
|
|
20
18
|
rounded ? "is-rounded" : "",
|
|
21
19
|
"input",
|
|
@@ -28,6 +26,6 @@ const DatePicker = ({ defaultValue, onValueChange, readonly, disabled, validatio
|
|
|
28
26
|
const dataAttributes = isNullOrUndefined(data)
|
|
29
27
|
? undefined
|
|
30
28
|
: mapDataAttributes(data);
|
|
31
|
-
return (_jsxs(ComponentWithLabel, { id:
|
|
29
|
+
return (_jsxs(ComponentWithLabel, { id: name, size: size, label: label, children: [_jsx("div", { className: inputContainerClassName, children: _jsx("input", { type: "date", id: name, name: name, onBlur: onBlur, readOnly: readonly, disabled: disabled, onChange: onChange, className: elClassName, defaultValue: stringifiedDefValue, title: title, ...dataAttributes }) }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
|
|
32
30
|
};
|
|
33
31
|
export default DatePicker;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseInputElementProps, LabelConfiguration } from "../../../types";
|
|
2
2
|
/** Date input component props type */
|
|
3
|
-
export interface DateProps extends Omit<BaseInputElementProps<Date | undefined>, "placeholder"> {
|
|
3
|
+
export interface DateProps extends Omit<BaseInputElementProps<Date | undefined>, "placeholder" | "label"> {
|
|
4
4
|
/** Label configuration */
|
|
5
5
|
label: LabelConfiguration;
|
|
6
6
|
/** Focus out event handler */
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CACnC,qBAAqB,CAAC,IAAI,GAAG,SAAS,CAAC,EACvC,aAAa,GAAG,OAAO,CAC1B;IACG,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/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,
|
|
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,mCAGrB,uBAAuB,KAAG,WAwD5B,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -19,8 +19,8 @@ const ComponentWithLabel = ({ label, id, size, children, }) => {
|
|
|
19
19
|
"field-body",
|
|
20
20
|
label.horizontalFieldContainerClassName
|
|
21
21
|
]);
|
|
22
|
-
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: _jsx("div", { className: "field", children: children }) })] }));
|
|
22
|
+
return (_jsxs("div", { className: "bbr-field 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: children }) })] }));
|
|
23
23
|
}
|
|
24
|
-
return (_jsxs("div", { className: "bbr-input field", children: [_jsx("label", { className: labelClassName, htmlFor: id, children: label.caption }), children] }));
|
|
24
|
+
return (_jsxs("div", { className: "bbr-field bbr-input field", children: [_jsx("label", { className: labelClassName, htmlFor: id, children: label.caption }), children] }));
|
|
25
25
|
};
|
|
26
26
|
export default ComponentWithLabel;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { BaseInputElementProps } from "../../../../types";
|
|
3
|
+
import "./style.scss";
|
|
3
4
|
/** Props of `InternalHint` */
|
|
4
|
-
|
|
5
|
-
/** @inheritdoc BaseInputElementProps.validationState */
|
|
6
|
-
validationState?: ValidationState;
|
|
7
|
-
/** @inheritdoc BaseInputElementProps.hint */
|
|
8
|
-
hint?: HintConfiguration;
|
|
9
|
-
}
|
|
5
|
+
declare type HintProps = Pick<BaseInputElementProps<any>, "validationState" | "hint">;
|
|
10
6
|
/** Hint component for internal use (as form input elements hints) */
|
|
11
7
|
declare const InternalHint: ({ validationState, hint, }: HintProps) => JSX.Element;
|
|
12
8
|
export default InternalHint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/internal/hint/index.tsx"],"names":[],"mappings":";AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/internal/hint/index.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,qBAAqB,EAAqE,MAAM,YAAY,CAAC;AAGtH,OAAO,cAAc,CAAC;AAEtB,8BAA8B;AAC9B,aAAK,SAAS,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAAC,CAAC;AAE9E,qEAAqE;AACrE,QAAA,MAAM,YAAY,+BAEf,SAAS,KAAG,WAgDd,CAAC;AAEF,eAAe,YAAY,CAAC"}
|