@bodynarf/react.components 1.13.8 → 1.14.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/changelog.md +55 -0
- package/components/accordion/component/index.js +1 -1
- package/components/accordion/component/style.css +21 -0
- package/components/anchor/component/style.css +12 -0
- package/components/button/component/style.css +10 -0
- package/components/dropdown/component/style.css +101 -0
- package/components/dropdown/components/compact/index.d.ts.map +1 -1
- package/components/dropdown/components/compact/index.js +3 -3
- package/components/dropdown/components/label/components/empty/index.js +1 -1
- package/components/dropdown/components/label/components/withSearch/style.css +21 -0
- package/components/dropdown/types.d.ts +6 -6
- package/components/dropdown/types.d.ts.map +1 -1
- package/components/file/component/styles.css +74 -0
- package/components/icon/component/style.css +19 -0
- package/components/index.d.ts +14 -2
- package/components/index.d.ts.map +1 -1
- package/components/index.js +14 -2
- package/components/modal/component/index.d.ts +7 -0
- package/components/modal/component/index.d.ts.map +1 -0
- package/components/modal/component/index.js +42 -0
- package/components/modal/component/style.css +32 -0
- package/components/modal/component/style.scss +42 -0
- package/components/modal/index.d.ts +3 -0
- package/components/modal/index.d.ts.map +1 -0
- package/components/modal/index.js +2 -0
- package/components/modal/types.d.ts +44 -0
- package/components/modal/types.d.ts.map +1 -0
- package/components/modal/types.js +1 -0
- package/components/multiselect/component/style.css +20 -0
- package/components/multiselect/components/withoutLabel/index.d.ts.map +1 -1
- package/components/multiselect/components/withoutLabel/index.js +5 -5
- package/components/primitives/checkbox/component/style.css +19 -0
- package/components/primitives/color/component/style.css +15 -0
- package/components/primitives/date/component/style.css +9 -0
- package/components/primitives/index.d.ts +4 -0
- package/components/primitives/index.d.ts.map +1 -1
- package/components/primitives/index.js +4 -0
- package/components/primitives/internal/hint/style.css +4 -0
- package/components/primitives/number/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/number/components/withLabel/index.js +10 -2
- package/components/primitives/number/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/number/components/withoutLabel/index.js +12 -4
- package/components/primitives/number/types.d.ts +6 -0
- package/components/primitives/number/types.d.ts.map +1 -1
- package/components/primitives/password/component/style.css +10 -0
- package/components/primitives/radioGroup/component/index.d.ts +7 -0
- package/components/primitives/radioGroup/component/index.d.ts.map +1 -0
- package/components/primitives/radioGroup/component/index.js +42 -0
- package/components/primitives/radioGroup/component/style.css +382 -0
- package/components/primitives/radioGroup/component/style.scss +271 -0
- package/components/primitives/radioGroup/index.d.ts +3 -0
- package/components/primitives/radioGroup/index.d.ts.map +1 -0
- package/components/primitives/radioGroup/index.js +2 -0
- package/components/primitives/radioGroup/types.d.ts +61 -0
- package/components/primitives/radioGroup/types.d.ts.map +1 -0
- package/components/primitives/radioGroup/types.js +1 -0
- package/components/primitives/slider/component/index.d.ts +7 -0
- package/components/primitives/slider/component/index.d.ts.map +1 -0
- package/components/primitives/slider/component/index.js +47 -0
- package/components/primitives/slider/component/style.css +438 -0
- package/components/primitives/slider/component/style.scss +321 -0
- package/components/primitives/slider/index.d.ts +3 -0
- package/components/primitives/slider/index.d.ts.map +1 -0
- package/components/primitives/slider/index.js +2 -0
- package/components/primitives/slider/types.d.ts +51 -0
- package/components/primitives/slider/types.d.ts.map +1 -0
- package/components/primitives/slider/types.js +1 -0
- package/components/primitives/switch/component/index.d.ts +7 -0
- package/components/primitives/switch/component/index.d.ts.map +1 -0
- package/components/primitives/switch/component/index.js +39 -0
- package/components/primitives/switch/component/style.css +482 -0
- package/components/primitives/switch/component/style.scss +216 -0
- package/components/primitives/switch/index.d.ts +3 -0
- package/components/primitives/switch/index.d.ts.map +1 -0
- package/components/primitives/switch/index.js +2 -0
- package/components/primitives/switch/types.d.ts +23 -0
- package/components/primitives/switch/types.d.ts.map +1 -0
- package/components/primitives/switch/types.js +1 -0
- package/components/primitives/timePicker/component/index.d.ts +8 -0
- package/components/primitives/timePicker/component/index.d.ts.map +1 -0
- package/components/primitives/timePicker/component/index.js +65 -0
- package/components/primitives/timePicker/component/style.css +21 -0
- package/components/primitives/timePicker/component/style.scss +26 -0
- package/components/primitives/timePicker/index.d.ts +3 -0
- package/components/primitives/timePicker/index.d.ts.map +1 -0
- package/components/primitives/timePicker/index.js +2 -0
- package/components/primitives/timePicker/types.d.ts +33 -0
- package/components/primitives/timePicker/types.d.ts.map +1 -0
- package/components/primitives/timePicker/types.js +1 -0
- package/components/progress/component/style.css +167 -0
- package/components/search/component/index.d.ts.map +1 -1
- package/components/search/component/index.js +9 -3
- package/components/search/component/style.css +18 -0
- package/components/search/types.d.ts +5 -0
- package/components/search/types.d.ts.map +1 -1
- package/components/stepper/component/index.d.ts +7 -0
- package/components/stepper/component/index.d.ts.map +1 -0
- package/components/stepper/component/index.js +56 -0
- package/components/stepper/component/style.css +510 -0
- package/components/stepper/component/style.scss +432 -0
- package/components/stepper/index.d.ts +3 -0
- package/components/stepper/index.d.ts.map +1 -0
- package/components/stepper/index.js +2 -0
- package/components/stepper/types.d.ts +65 -0
- package/components/stepper/types.d.ts.map +1 -0
- package/components/stepper/types.js +1 -0
- package/components/table/component/style.css +14 -0
- package/components/tabs/component/style.css +6 -0
- package/components/tag/component/style.css +19 -0
- package/components/timeline/component/index.d.ts +7 -0
- package/components/timeline/component/index.d.ts.map +1 -0
- package/components/timeline/component/index.js +36 -0
- package/components/timeline/component/style.css +488 -0
- package/components/timeline/component/style.scss +397 -0
- package/components/timeline/index.d.ts +3 -0
- package/components/timeline/index.d.ts.map +1 -0
- package/components/timeline/index.js +2 -0
- package/components/timeline/types.d.ts +55 -0
- package/components/timeline/types.d.ts.map +1 -0
- package/components/timeline/types.js +1 -0
- package/components/tooltip/component/index.d.ts +6 -0
- package/components/tooltip/component/index.d.ts.map +1 -0
- package/components/tooltip/component/index.js +80 -0
- package/components/tooltip/index.d.ts +3 -0
- package/components/tooltip/index.d.ts.map +1 -0
- package/components/tooltip/index.js +2 -0
- package/components/tooltip/types.d.ts +31 -0
- package/components/tooltip/types.d.ts.map +1 -0
- package/components/tooltip/types.js +1 -0
- package/package.json +10 -3
- package/readme.md +18 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { ActionFn } from "@bodynarf/utils";
|
|
3
|
+
import { BaseElementProps, ElementSize } from "../../types";
|
|
4
|
+
import { ButtonProps } from "../button";
|
|
5
|
+
/** Modal window component props */
|
|
6
|
+
export type ModalWrapperProps = BaseElementProps & {
|
|
7
|
+
/** Modal window body content */
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/** Action buttons in the footer */
|
|
10
|
+
actions: Array<ButtonProps>;
|
|
11
|
+
/**
|
|
12
|
+
* Modal window title.
|
|
13
|
+
* If not provided - header will not be displayed
|
|
14
|
+
*/
|
|
15
|
+
title?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Modal window size.
|
|
18
|
+
* @default Normal
|
|
19
|
+
*/
|
|
20
|
+
size?: ElementSize;
|
|
21
|
+
/**
|
|
22
|
+
* Show close button in the header.
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
showCloseButton?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Close modal when clicking on background overlay.
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
|
+
closeOnBackgroundClick?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Close modal on Escape key press.
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
closeOnEscape?: boolean;
|
|
36
|
+
/** Close button click handler */
|
|
37
|
+
onCloseClick: ActionFn;
|
|
38
|
+
/**
|
|
39
|
+
* Handler for Enter key press.
|
|
40
|
+
* If not provided - Enter key will not be handled
|
|
41
|
+
*/
|
|
42
|
+
onEnterPress?: ActionFn;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/modal/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,mCAAmC;AACnC,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,GAAG;IAC/C,gCAAgC;IAChC,QAAQ,EAAE,SAAS,CAAC;IAEpB,mCAAmC;IACnC,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAE5B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,iCAAiC;IACjC,YAAY,EAAE,QAAQ,CAAC;IAEvB;;;OAGG;IACH,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.bbr-multiselect .dropdown-content {
|
|
2
|
+
overflow: hidden;
|
|
3
|
+
}
|
|
4
|
+
.bbr-multiselect .dropdown-content ul {
|
|
5
|
+
max-height: 13.5rem;
|
|
6
|
+
overflow: auto;
|
|
7
|
+
}
|
|
8
|
+
.bbr-multiselect .dropdown-content ul li.bbr-dropdown-item .field:not(:last-child) {
|
|
9
|
+
margin-bottom: 0 !important;
|
|
10
|
+
}
|
|
11
|
+
.bbr-multiselect .dropdown-content ul li.bbr-dropdown-item .bbr-icon {
|
|
12
|
+
transition: none;
|
|
13
|
+
}
|
|
14
|
+
.bbr-multiselect.is-up .dropdown-menu {
|
|
15
|
+
top: auto;
|
|
16
|
+
bottom: 100%;
|
|
17
|
+
}
|
|
18
|
+
.bbr-multiselect.is-up.is-active .bbr-dropdown__label .bbr-icon.bi-arrow-down::before {
|
|
19
|
+
transform: rotate(360deg);
|
|
20
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/multiselect/components/withoutLabel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAoD,MAAM,OAAO,CAAC;AAU7E,OAAO,EAAE,gBAAgB,EAA2C,MAAM,aAAa,CAAC;AAIxF,8CAA8C;AAC9C,KAAK,4BAA4B,GAAG,gBAAgB,GAAG;IACnD,kCAAkC;IAClC,EAAE,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,QAAA,MAAM,uBAAuB,EAAE,EAAE,CAAC,4BAA4B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/multiselect/components/withoutLabel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAoD,MAAM,OAAO,CAAC;AAU7E,OAAO,EAAE,gBAAgB,EAA2C,MAAM,aAAa,CAAC;AAIxF,8CAA8C;AAC9C,KAAK,4BAA4B,GAAG,gBAAgB,GAAG;IACnD,kCAAkC;IAClC,EAAE,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,QAAA,MAAM,uBAAuB,EAAE,EAAE,CAAC,4BAA4B,CAsK7D,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -9,9 +9,6 @@ import InternalHint from "../../../primitives/internal/hint";
|
|
|
9
9
|
import MultiselectItem from "../item";
|
|
10
10
|
import MultiselectLabel from "../label/component";
|
|
11
11
|
const MultiselectWithoutLabel = ({ items, onChange, onClear, hideOnOuterClick, listMaxHeight, placeholder = "", noDataText = "No items found", selectionCaption = "{0} items selected", noDataByQuery = "No items found by specified search", compact = false, disabled = false, searchable = true, validationState, className, title, data, hint, id: propsId, checkboxConfig, }) => {
|
|
12
|
-
const generatedId = useId();
|
|
13
|
-
const id = propsId ?? generatedId;
|
|
14
|
-
const containerRef = useRef(null);
|
|
15
12
|
const [isListVisible, setListVisible] = useState(false);
|
|
16
13
|
const [selectedItems, setSelectedItems] = useState(items
|
|
17
14
|
.filter(({ selected }) => selected)
|
|
@@ -19,6 +16,9 @@ const MultiselectWithoutLabel = ({ items, onChange, onClear, hideOnOuterClick, l
|
|
|
19
16
|
??
|
|
20
17
|
[]);
|
|
21
18
|
const [isOpenUp, setIsOpenUp] = useState(false);
|
|
19
|
+
const containerRef = useRef(null);
|
|
20
|
+
const generatedId = useId();
|
|
21
|
+
const id = propsId ?? generatedId;
|
|
22
22
|
const onItemClick = useCallback((item) => {
|
|
23
23
|
const isItemSelected = selectedItems.includes(item.id);
|
|
24
24
|
setSelectedItems(x => isItemSelected
|
|
@@ -86,13 +86,13 @@ export default MultiselectWithoutLabel;
|
|
|
86
86
|
const DropdownContent = ({ noDataText, id, listMaxHeight, noDataByQuery, items, selectedItems, onItemClick, onItemSelectChange, searchable = true, checkboxConfig, }) => {
|
|
87
87
|
const [search, setSearch] = useState("");
|
|
88
88
|
if (items.length === 0) {
|
|
89
|
-
return (_jsx("
|
|
89
|
+
return (_jsx("span", { className: "dropdown-content dropdown-item is-italic has-text-grey", children: noDataText }));
|
|
90
90
|
}
|
|
91
91
|
const filteredItems = isNullOrEmpty(search)
|
|
92
92
|
? items
|
|
93
93
|
: items.filter(({ displayValue }) => displayValue.toLocaleLowerCase().includes(search.toLocaleLowerCase()));
|
|
94
94
|
if (filteredItems.length === 0) {
|
|
95
|
-
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 })] }));
|
|
95
|
+
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 is-italic has-text-grey", children: noDataByQuery })] }));
|
|
96
96
|
}
|
|
97
97
|
return (_jsxs("div", { className: "dropdown-content", style: { maxHeight: listMaxHeight }, children: [!!searchable &&
|
|
98
98
|
_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)) })] }));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.is-checkradio.m-check-radio[type=checkbox].has-background-color.m-has-background-color:not(:checked) + label::before {
|
|
2
|
+
border-color: #dbdbdb !important;
|
|
3
|
+
background-color: transparent !important;
|
|
4
|
+
}
|
|
5
|
+
.is-checkradio.m-check-radio[type=checkbox].is-block + label.is-empty::before {
|
|
6
|
+
left: 0.25rem !important;
|
|
7
|
+
top: 0.25rem !important;
|
|
8
|
+
}
|
|
9
|
+
.is-checkradio.m-check-radio[type=checkbox].is-block + label.is-empty::after {
|
|
10
|
+
top: 0.45rem;
|
|
11
|
+
left: 0.7rem;
|
|
12
|
+
}
|
|
13
|
+
.is-checkradio.m-check-radio[type=checkbox]:not(.is-block) + label::after {
|
|
14
|
+
top: 0.275rem;
|
|
15
|
+
}
|
|
16
|
+
.is-checkradio.m-check-radio[type=checkbox] + label.is-empty {
|
|
17
|
+
padding-left: 1rem;
|
|
18
|
+
margin: 0 !important;
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.bbr-color-picker input[type=color]:not([disabled]) {
|
|
2
|
+
cursor: pointer;
|
|
3
|
+
}
|
|
4
|
+
.bbr-color-picker__preview {
|
|
5
|
+
--color-picker__background-color: transparent;
|
|
6
|
+
--color-picker__color: black;
|
|
7
|
+
transition: 0.15s ease-in-out;
|
|
8
|
+
transition-property: background-color, color;
|
|
9
|
+
background-color: var(--color-picker__background-color) !important;
|
|
10
|
+
color: var(--color-picker__color) !important;
|
|
11
|
+
}
|
|
12
|
+
.bbr-color-picker__preview:focus {
|
|
13
|
+
box-shadow: none !important;
|
|
14
|
+
border-color: hsl(0, 0%, 86%) !important;
|
|
15
|
+
}
|
|
@@ -4,5 +4,9 @@ export * from "./date";
|
|
|
4
4
|
export * from "./multiline";
|
|
5
5
|
export * from "./number";
|
|
6
6
|
export * from "./password";
|
|
7
|
+
export * from "./radioGroup";
|
|
8
|
+
export * from "./slider";
|
|
9
|
+
export * from "./switch";
|
|
7
10
|
export * from "./text";
|
|
11
|
+
export * from "./timePicker";
|
|
8
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/number/components/withLabel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/number/components/withLabel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAA2B,MAAM,OAAO,CAAC;AAIjE,OAAO,EAAe,cAAc,EAAE,MAAM,YAAY,CAAC;AAKzD,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,kCAAkC;AAClC,QAAA,MAAM,eAAe,EAAE,EAAE,CACrB,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,cAAc,CAmF1C,CAAC;AAEN,eAAe,eAAe,CAAC"}
|
|
@@ -6,8 +6,16 @@ import { getSizeClassName, getStyleClassName, mapDataAttributes } from "../../..
|
|
|
6
6
|
import ComponentWithLabel from "../../../internal/componentWithLabel";
|
|
7
7
|
import InternalHint from "../../../internal/hint";
|
|
8
8
|
/** Number component with label */
|
|
9
|
-
const NumberWithLabel = ({ onValueChange = emptyFn, defaultValue, validationState, name = generateGuid(), label, placeholder, size = ElementSize.Normal, style, rounded = false, loading = false, readonly = false, disabled = false, autoFocus = false, onBlur, onKeyDown, onKeyUp, step = 1, className, title, data, hint, }) => {
|
|
9
|
+
const NumberWithLabel = ({ onValueChange = emptyFn, defaultValue, validationState, name = generateGuid(), label, placeholder, size = ElementSize.Normal, style, rounded = false, loading = false, readonly = false, disabled = false, autoFocus = false, onBlur, onKeyDown, onKeyUp, step = 1, resetToDefaultOnBlur = false, className, title, data, hint, }) => {
|
|
10
10
|
const onChange = useCallback((event) => onValueChange(isStringEmpty(event.target.value) ? undefined : +event.target.value), [onValueChange]);
|
|
11
|
+
const onInputBlur = useCallback((event) => {
|
|
12
|
+
if (resetToDefaultOnBlur && isStringEmpty(event.target.value)) {
|
|
13
|
+
const resetValue = defaultValue ?? 0;
|
|
14
|
+
event.target.value = resetValue.toString();
|
|
15
|
+
onValueChange(resetValue);
|
|
16
|
+
}
|
|
17
|
+
onBlur?.();
|
|
18
|
+
}, [resetToDefaultOnBlur, defaultValue, onValueChange, onBlur]);
|
|
11
19
|
const elClassName = getClassName([
|
|
12
20
|
className,
|
|
13
21
|
getSizeClassName(size, ElementSize.Normal),
|
|
@@ -22,6 +30,6 @@ const NumberWithLabel = ({ onValueChange = emptyFn, defaultValue, validationStat
|
|
|
22
30
|
const dataAttributes = isNullish(data)
|
|
23
31
|
? undefined
|
|
24
32
|
: mapDataAttributes(data);
|
|
25
|
-
return (_jsxs(ComponentWithLabel, { id: name, size: size, label: label, children: [_jsx("div", { className: inputContainerClassName, children: _jsx("input", { id: name,
|
|
33
|
+
return (_jsxs(ComponentWithLabel, { id: name, size: size, label: label, children: [_jsx("div", { className: inputContainerClassName, children: _jsx("input", { id: name, step: step, name: name, title: title, type: "number", onKeyUp: onKeyUp, onChange: onChange, readOnly: readonly, disabled: disabled, ...dataAttributes, onBlur: onInputBlur, onKeyDown: onKeyDown, autoFocus: autoFocus, className: elClassName, placeholder: placeholder, defaultValue: defaultValue }) }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
|
|
26
34
|
};
|
|
27
35
|
export default NumberWithLabel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/number/components/withoutLabel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/number/components/withoutLabel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAA2B,MAAM,OAAO,CAAC;AAQjE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,qCAAqC;AACrC,QAAA,MAAM,kBAAkB,EAAE,EAAE,CAAC,WAAW,CAgFvC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
|
-
import { emptyFn, generateGuid, getClassName } from "@bodynarf/utils";
|
|
3
|
+
import { emptyFn, generateGuid, getClassName, isStringEmpty } from "@bodynarf/utils";
|
|
4
4
|
import { ElementSize } from "../../../../../types";
|
|
5
5
|
import { getSizeClassName, getStyleClassName, mapDataAttributes } from "../../../../../utils";
|
|
6
6
|
import InternalHint from "../../../internal/hint";
|
|
7
7
|
/** Number component without label */
|
|
8
|
-
const NumberWithoutLabel = ({ onValueChange = emptyFn, defaultValue, validationState, name = generateGuid(), size, style, readonly = false, disabled = false, autoFocus = false, rounded = false, loading = false, placeholder, onBlur, onKeyDown, onKeyUp, step = 1, className, title, data, hint, }) => {
|
|
9
|
-
const onChange = useCallback((event) => onValueChange(+event.target.value), [onValueChange]);
|
|
8
|
+
const NumberWithoutLabel = ({ onValueChange = emptyFn, defaultValue, validationState, name = generateGuid(), size, style, readonly = false, disabled = false, autoFocus = false, rounded = false, loading = false, placeholder, onBlur, onKeyDown, onKeyUp, step = 1, resetToDefaultOnBlur = false, className, title, data, hint, }) => {
|
|
9
|
+
const onChange = useCallback((event) => onValueChange(isStringEmpty(event.target.value) ? undefined : +event.target.value), [onValueChange]);
|
|
10
|
+
const onInputBlur = useCallback((event) => {
|
|
11
|
+
if (resetToDefaultOnBlur && isStringEmpty(event.target.value)) {
|
|
12
|
+
const resetValue = defaultValue ?? 0;
|
|
13
|
+
event.target.value = resetValue.toString();
|
|
14
|
+
onValueChange(resetValue);
|
|
15
|
+
}
|
|
16
|
+
onBlur?.();
|
|
17
|
+
}, [resetToDefaultOnBlur, defaultValue, onValueChange, onBlur]);
|
|
10
18
|
const elClassName = getClassName([
|
|
11
19
|
className,
|
|
12
20
|
getSizeClassName(size, ElementSize.Normal),
|
|
@@ -20,6 +28,6 @@ const NumberWithoutLabel = ({ onValueChange = emptyFn, defaultValue, validationS
|
|
|
20
28
|
loading ? "is-loading" : "",
|
|
21
29
|
]);
|
|
22
30
|
const dataAttributes = mapDataAttributes(data);
|
|
23
|
-
return (_jsxs("div", { className: "bbr-field field", children: [_jsx("div", { className: containerClassName, children: _jsx("input", { id: name,
|
|
31
|
+
return (_jsxs("div", { className: "bbr-field field", children: [_jsx("div", { className: containerClassName, children: _jsx("input", { id: name, step: step, name: name, title: title, type: "number", onKeyUp: onKeyUp, onChange: onChange, readOnly: readonly, disabled: disabled, ...dataAttributes, onBlur: onInputBlur, onKeyDown: onKeyDown, autoFocus: autoFocus, className: elClassName, placeholder: placeholder, defaultValue: defaultValue }) }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
|
|
24
32
|
};
|
|
25
33
|
export default NumberWithoutLabel;
|
|
@@ -7,5 +7,11 @@ export type NumberProps = BaseNullableInputElementProps<number> & BlurableElemen
|
|
|
7
7
|
* @default 1
|
|
8
8
|
*/
|
|
9
9
|
step?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Reset value to `defaultValue` (or `0` if not specified) on focus out when the field is empty.
|
|
12
|
+
* Prevents the input from having no value.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
resetToDefaultOnBlur?: boolean;
|
|
10
16
|
};
|
|
11
17
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/number/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7F,kCAAkC;AAClC,MAAM,MAAM,WAAW,GAAG,6BAA6B,CAAC,MAAM,CAAC,GACzD,eAAe,GACf,eAAe,GACf;IACE;;;;MAIE;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/number/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7F,kCAAkC;AAClC,MAAM,MAAM,WAAW,GAAG,6BAA6B,CAAC,MAAM,CAAC,GACzD,eAAe,GACf,eAAe,GACf;IACE;;;;MAIE;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import "./style.scss";
|
|
3
|
+
import { RadioGroupProps } from "../types";
|
|
4
|
+
/** RadioGroup component for selecting one option from multiple */
|
|
5
|
+
declare const RadioGroup: FC<RadioGroupProps>;
|
|
6
|
+
export default RadioGroup;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/radioGroup/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAAe,MAAM,OAAO,CAAC;AAOrD,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,kEAAkE;AAClE,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA2FnC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { emptyFn, generateGuid, getClassName, isNullish } from "@bodynarf/utils";
|
|
4
|
+
import { ElementSize } from "../../../../types";
|
|
5
|
+
import { getElementColorClassName, getSizeClassName, mapDataAttributes } from "../../../../utils";
|
|
6
|
+
import "./style.scss";
|
|
7
|
+
/** RadioGroup component for selecting one option from multiple */
|
|
8
|
+
const RadioGroup = ({ items, value, onValueChange = emptyFn, name = generateGuid(), size = ElementSize.Normal, style, disabled = false, horizontal = false, block = false, circle = true, withoutBorder = false, hasBackgroundColor = false, className, data, title, }) => {
|
|
9
|
+
const onChange = useCallback((event) => {
|
|
10
|
+
const selectedId = event.target.value;
|
|
11
|
+
const selectedItem = items.find(item => item.id === selectedId);
|
|
12
|
+
if (selectedItem) {
|
|
13
|
+
onValueChange(selectedItem);
|
|
14
|
+
}
|
|
15
|
+
}, [items, onValueChange]);
|
|
16
|
+
const containerClassName = getClassName([
|
|
17
|
+
"bbr-radio-group",
|
|
18
|
+
className,
|
|
19
|
+
horizontal ? "is-horizontal" : "",
|
|
20
|
+
]);
|
|
21
|
+
const radioClassName = getClassName([
|
|
22
|
+
"is-checkradio",
|
|
23
|
+
"bbr-radio",
|
|
24
|
+
getSizeClassName(size, ElementSize.Normal),
|
|
25
|
+
getElementColorClassName(style),
|
|
26
|
+
circle ? "is-circle" : "",
|
|
27
|
+
block ? "is-block" : "",
|
|
28
|
+
withoutBorder ? "has-no-border" : "",
|
|
29
|
+
hasBackgroundColor ? "has-background-color" : "",
|
|
30
|
+
]);
|
|
31
|
+
const dataAttributes = mapDataAttributes(data);
|
|
32
|
+
return (_jsx("div", { title: title, ...dataAttributes, className: containerClassName, children: items.map((item) => {
|
|
33
|
+
const itemId = `${name}-${item.id}`;
|
|
34
|
+
const isDisabled = disabled || item.disabled;
|
|
35
|
+
const isChecked = value === item.id;
|
|
36
|
+
const itemDataAttributes = isNullish(item.title)
|
|
37
|
+
? undefined
|
|
38
|
+
: { title: item.title };
|
|
39
|
+
return (_jsxs("div", { className: "bbr-radio-item", children: [_jsx("input", { id: itemId, name: name, type: "radio", value: item.id, checked: isChecked, onChange: onChange, disabled: isDisabled, className: radioClassName }), _jsx("label", { htmlFor: itemId, ...itemDataAttributes, children: item.displayValue })] }, item.id));
|
|
40
|
+
}) }));
|
|
41
|
+
};
|
|
42
|
+
export default RadioGroup;
|