@bodynarf/react.components 1.13.7 → 1.14.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/changelog.md +55 -0
- package/components/index.d.ts +14 -0
- package/components/index.d.ts.map +1 -1
- package/components/index.js +14 -0
- 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.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/components/withoutLabel/index.js +2 -2
- 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/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/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.scss +269 -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.scss +319 -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.scss +214 -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.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/search/component/index.d.ts.map +1 -1
- package/components/search/component/index.js +9 -3
- 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.scss +430 -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/tabs/component/index.js +1 -1
- 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.scss +395 -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 +1 -1
- package/readme.md +18 -3
- package/tsconfig.tsbuildinfo +1 -1
package/changelog.md
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
# Change log
|
|
2
2
|
All changes will be published here in reverse chronological order
|
|
3
3
|
|
|
4
|
+
## v1.3.0
|
|
5
|
+
- **ModalWrapper** *(new)*
|
|
6
|
+
- Added new modal window wrapper component based on Bulma modal.
|
|
7
|
+
- Supports `title`, `size`, `className`, `data` props.
|
|
8
|
+
- Action buttons in footer via `actions` prop (array of ButtonProps).
|
|
9
|
+
- Close behavior options: `showCloseButton`, `closeOnBackgroundClick`, `closeOnEscape`.
|
|
10
|
+
- Keyboard support: close on Escape, optional `onEnterPress` handler.
|
|
11
|
+
|
|
12
|
+
- **Number**
|
|
13
|
+
- Added the `resetToDefaultOnBlur` prop: when enabled, resets the value to `defaultValue` (or `0` if not specified) on focus out if the field is empty.
|
|
14
|
+
|
|
15
|
+
- **Search**
|
|
16
|
+
- Added optional search icon (magnifying glass) via `showIcon` prop. Icon size matches the input field size.
|
|
17
|
+
|
|
18
|
+
- **Switch** *(new)*
|
|
19
|
+
- Added new toggle/switch component with Bulma styling.
|
|
20
|
+
- Supports `size`, `style` (color), `label`, `name`, `onValueChange`, `defaultValue`, `className` props.
|
|
21
|
+
- Additional style options: `rounded` (pill shape), `outlined`, `thin`, `rtl` (right-to-left mode).
|
|
22
|
+
- Supports form label mode via `isFormLabel` prop.
|
|
23
|
+
|
|
24
|
+
- **Slider** *(new)*
|
|
25
|
+
- Added new range/slider component with Bulma styling.
|
|
26
|
+
- Supports `min`, `max`, `step`, `size`, `style` (color), `defaultValue`, `onValueChange`, `className` props.
|
|
27
|
+
- Additional options: `showValue` (tooltip with current value), `showMinMax` (min/max labels), `showProgress` (filled track).
|
|
28
|
+
- Supports vertical mode via `vertical` prop with configurable height.
|
|
29
|
+
- Circle style thumb available via `circle` prop.
|
|
30
|
+
|
|
31
|
+
- **RadioGroup** *(new)*
|
|
32
|
+
- Added new radio group component for single selection from multiple options.
|
|
33
|
+
- Supports `items`, `value`, `onValueChange`, `size`, `style` (color), `name`, `className` props.
|
|
34
|
+
- Additional style options: `horizontal` (row layout), `block` (filled background), `circle`, `withoutBorder`, `hasBackgroundColor`.
|
|
35
|
+
- Each item can be individually disabled.
|
|
36
|
+
|
|
37
|
+
- **Stepper** *(new)*
|
|
38
|
+
- Added new stepper/progress indicator component for multi-step workflows.
|
|
39
|
+
- Supports `steps`, `currentStep`, `size`, `color`, `className` props.
|
|
40
|
+
- Additional options: `vertical` (vertical layout), `showNumbers` (step numbers vs checkmarks), `showConnectors` (lines between steps), `animated` (connector animations).
|
|
41
|
+
- Clickable steps support via `clickable` and `onStepClick` props for navigating to completed steps.
|
|
42
|
+
- Each step can have a title, description, and optional custom icon.
|
|
43
|
+
|
|
44
|
+
- **Timeline** *(new)*
|
|
45
|
+
- Added new timeline component for displaying chronological events.
|
|
46
|
+
- Supports `items`, `size`, `color`, `className` props.
|
|
47
|
+
- Layout options: `leftAligned` (default, markers on left) or centered mode with alternating content.
|
|
48
|
+
- Additional options: `showConnectors`, `animated` (fade-in animation), `hollow` (outlined markers).
|
|
49
|
+
- Supports `showTimestampsSeparate` for displaying timestamps on opposite side in centered mode.
|
|
50
|
+
- Each item can have title, content, timestamp, icon, marker, and individual color override.
|
|
51
|
+
|
|
52
|
+
- **TimePicker** *(new)*
|
|
53
|
+
- Added new time input component for hours/minutes/seconds selection.
|
|
54
|
+
- Supports `defaultValue`, `onValueChange`, `size`, `style`, `name`, `className` props.
|
|
55
|
+
- Time value represented as object with `hours`, `minutes`, and optional `seconds` fields.
|
|
56
|
+
- Additional options: `showSeconds` (enable seconds input), `step` (value increment in seconds), `min`, `max` (time range limits).
|
|
57
|
+
- Supports all standard input features: `rounded`, `loading`, `disabled`, `readonly`, validation states, labels, and hints.
|
|
58
|
+
|
|
4
59
|
## v1.2.0
|
|
5
60
|
- **Accordion**
|
|
6
61
|
- Fixed an issue where the height changed incorrectly when the component’s `size` prop was updated.
|
package/components/index.d.ts
CHANGED
|
@@ -12,18 +12,24 @@ export { default as File } from "./file";
|
|
|
12
12
|
export * from "./file";
|
|
13
13
|
export { default as Icon } from "./icon";
|
|
14
14
|
export * from "./icon";
|
|
15
|
+
export { default as ModalWrapper } from "./modal";
|
|
16
|
+
export * from "./modal";
|
|
15
17
|
export { default as Multiselect } from "./multiselect";
|
|
16
18
|
export * from "./multiselect";
|
|
17
19
|
export { default as Paginator } from "./paginator";
|
|
18
20
|
export * from "./paginator";
|
|
19
21
|
export { default as Search } from "./search";
|
|
20
22
|
export * from "./search";
|
|
23
|
+
export { default as Stepper } from "./stepper";
|
|
24
|
+
export * from "./stepper";
|
|
21
25
|
export { default as Table } from "./table";
|
|
22
26
|
export * from "./table";
|
|
23
27
|
export { default as Tabs } from "./tabs";
|
|
24
28
|
export * from "./tabs";
|
|
25
29
|
export { default as Tag } from "./tag";
|
|
26
30
|
export * from "./tag";
|
|
31
|
+
export { default as Timeline } from "./timeline";
|
|
32
|
+
export * from "./timeline";
|
|
27
33
|
export { default as Progress } from "./progress";
|
|
28
34
|
export * from "./progress";
|
|
29
35
|
export { default as Checkbox } from "./primitives/checkbox";
|
|
@@ -38,6 +44,14 @@ export { default as NumberInput } from "./primitives/number";
|
|
|
38
44
|
export * from "./primitives/number";
|
|
39
45
|
export { default as Password } from "./primitives/password";
|
|
40
46
|
export * from "./primitives/password";
|
|
47
|
+
export { default as RadioGroup } from "./primitives/radioGroup";
|
|
48
|
+
export * from "./primitives/radioGroup";
|
|
49
|
+
export { default as Slider } from "./primitives/slider";
|
|
50
|
+
export * from "./primitives/slider";
|
|
51
|
+
export { default as Switch } from "./primitives/switch";
|
|
52
|
+
export * from "./primitives/switch";
|
|
41
53
|
export { default as Text } from "./primitives/text";
|
|
42
54
|
export * from "./primitives/text";
|
|
55
|
+
export { default as TimePicker } from "./primitives/timePicker";
|
|
56
|
+
export * from "./primitives/timePicker";
|
|
43
57
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,cAAc,aAAa,CAAC;AAE5B,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,cAAc,QAAQ,CAAC;AAEvB,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,cAAc,QAAQ,CAAC;AAEvB,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,cAAc,aAAa,CAAC;AAE5B,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,cAAc,QAAQ,CAAC;AAEvB,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAC;AACvC,cAAc,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"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"}
|
package/components/index.js
CHANGED
|
@@ -12,18 +12,24 @@ export { default as File } from "./file";
|
|
|
12
12
|
export * from "./file";
|
|
13
13
|
export { default as Icon } from "./icon";
|
|
14
14
|
export * from "./icon";
|
|
15
|
+
export { default as ModalWrapper } from "./modal";
|
|
16
|
+
export * from "./modal";
|
|
15
17
|
export { default as Multiselect } from "./multiselect";
|
|
16
18
|
export * from "./multiselect";
|
|
17
19
|
export { default as Paginator } from "./paginator";
|
|
18
20
|
export * from "./paginator";
|
|
19
21
|
export { default as Search } from "./search";
|
|
20
22
|
export * from "./search";
|
|
23
|
+
export { default as Stepper } from "./stepper";
|
|
24
|
+
export * from "./stepper";
|
|
21
25
|
export { default as Table } from "./table";
|
|
22
26
|
export * from "./table";
|
|
23
27
|
export { default as Tabs } from "./tabs";
|
|
24
28
|
export * from "./tabs";
|
|
25
29
|
export { default as Tag } from "./tag";
|
|
26
30
|
export * from "./tag";
|
|
31
|
+
export { default as Timeline } from "./timeline";
|
|
32
|
+
export * from "./timeline";
|
|
27
33
|
// Progress/Loader component
|
|
28
34
|
export { default as Progress } from "./progress";
|
|
29
35
|
export * from "./progress";
|
|
@@ -40,5 +46,13 @@ export { default as NumberInput } from "./primitives/number";
|
|
|
40
46
|
export * from "./primitives/number";
|
|
41
47
|
export { default as Password } from "./primitives/password";
|
|
42
48
|
export * from "./primitives/password";
|
|
49
|
+
export { default as RadioGroup } from "./primitives/radioGroup";
|
|
50
|
+
export * from "./primitives/radioGroup";
|
|
51
|
+
export { default as Slider } from "./primitives/slider";
|
|
52
|
+
export * from "./primitives/slider";
|
|
53
|
+
export { default as Switch } from "./primitives/switch";
|
|
54
|
+
export * from "./primitives/switch";
|
|
43
55
|
export { default as Text } from "./primitives/text";
|
|
44
56
|
export * from "./primitives/text";
|
|
57
|
+
export { default as TimePicker } from "./primitives/timePicker";
|
|
58
|
+
export * from "./primitives/timePicker";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/modal/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA0B,MAAM,OAAO,CAAC;AAQnD,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAC;AAEvC,qCAAqC;AACrC,QAAA,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CA6FvC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect } from "react";
|
|
3
|
+
import { getClassName, isNotNullish, isNotNullOrEmpty } from "@bodynarf/utils";
|
|
4
|
+
import { ElementSize } from "../../../types";
|
|
5
|
+
import { getSizeClassName, mapDataAttributes } from "../../../utils";
|
|
6
|
+
import Button from "../../button";
|
|
7
|
+
import "./style.scss";
|
|
8
|
+
/** Modal window wrapper component */
|
|
9
|
+
const ModalWrapper = ({ children, actions, onCloseClick, title, size = ElementSize.Normal, showCloseButton = true, closeOnBackgroundClick = true, closeOnEscape = true, onEnterPress, className, data, }) => {
|
|
10
|
+
const onBackgroundClick = useCallback(() => {
|
|
11
|
+
if (closeOnBackgroundClick) {
|
|
12
|
+
onCloseClick();
|
|
13
|
+
}
|
|
14
|
+
}, [closeOnBackgroundClick, onCloseClick]);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const handleKeyDown = (event) => {
|
|
17
|
+
if (event.key === "Escape" && closeOnEscape) {
|
|
18
|
+
onCloseClick();
|
|
19
|
+
}
|
|
20
|
+
else if (event.key === "Enter" && isNotNullish(onEnterPress)) {
|
|
21
|
+
onEnterPress();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
25
|
+
return () => {
|
|
26
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
27
|
+
};
|
|
28
|
+
}, [closeOnEscape, onCloseClick, onEnterPress]);
|
|
29
|
+
const elClassName = getClassName([
|
|
30
|
+
"bbr-modal",
|
|
31
|
+
"modal",
|
|
32
|
+
"is-active",
|
|
33
|
+
getSizeClassName(size),
|
|
34
|
+
className,
|
|
35
|
+
]);
|
|
36
|
+
const dataAttributes = mapDataAttributes(data);
|
|
37
|
+
const hasTitle = isNotNullOrEmpty(title);
|
|
38
|
+
const hasHeader = hasTitle || showCloseButton;
|
|
39
|
+
const hasActions = actions.length > 0;
|
|
40
|
+
return (_jsxs("div", { ...dataAttributes, className: elClassName, children: [_jsx("div", { onClick: onBackgroundClick, className: "modal-background" }), _jsxs("div", { className: "modal-card", children: [!!hasHeader && (_jsxs("header", { className: "modal-card-head", children: [!!hasTitle && (_jsx("p", { className: "modal-card-title", children: title })), !!showCloseButton && (_jsx("button", { type: "button", className: "delete", "aria-label": "close", onClick: onCloseClick }))] })), _jsx("section", { className: "modal-card-body", children: children }), !!hasActions && (_jsx("footer", { className: "modal-card-foot", children: actions.map((buttonProps) => (_jsx(Button, { ...buttonProps }, buttonProps.caption ?? buttonProps.icon?.className))) }))] })] }));
|
|
41
|
+
};
|
|
42
|
+
export default ModalWrapper;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.bbr-modal {
|
|
2
|
+
&.modal {
|
|
3
|
+
z-index: 1000;
|
|
4
|
+
|
|
5
|
+
.modal-card {
|
|
6
|
+
max-height: calc(100vh - 40px);
|
|
7
|
+
width: auto;
|
|
8
|
+
min-width: 300px;
|
|
9
|
+
max-width: calc(100vw - 40px);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.modal-card-head {
|
|
13
|
+
border-bottom: 1px solid #dbdbdb;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.modal-card-foot {
|
|
17
|
+
border-top: 1px solid #dbdbdb;
|
|
18
|
+
justify-content: flex-end;
|
|
19
|
+
gap: 0.5rem;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.modal-card-body {
|
|
23
|
+
overflow-y: auto;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Size modifiers
|
|
27
|
+
&.is-small .modal-card {
|
|
28
|
+
min-width: 250px;
|
|
29
|
+
max-width: 400px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&.is-medium .modal-card {
|
|
33
|
+
min-width: 400px;
|
|
34
|
+
max-width: 640px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&.is-large .modal-card {
|
|
38
|
+
min-width: 600px;
|
|
39
|
+
max-width: 960px;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/modal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,cAAc,SAAS,CAAC"}
|
|
@@ -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 {};
|
|
@@ -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)) })] }));
|
|
@@ -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;
|