@bodynarf/react.components 1.13.8 → 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/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
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { LabeledElement } from "../../../../types";
|
|
3
|
+
import "./style.scss";
|
|
4
|
+
import { TimePickerProps } from "../types";
|
|
5
|
+
/** TimePicker input component */
|
|
6
|
+
declare const TimePicker: FC<Omit<TimePickerProps, "label"> & LabeledElement>;
|
|
7
|
+
export default TimePicker;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/timePicker/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAAwB,MAAM,OAAO,CAAC;AAI9D,OAAO,EAAe,cAAc,EAAE,MAAM,YAAY,CAAC;AAKzD,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,eAAe,EAAa,MAAM,UAAU,CAAC;AA+CtD,iCAAiC;AACjC,QAAA,MAAM,UAAU,EAAE,EAAE,CAChB,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,GAAG,cAAc,CA6FlD,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo } from "react";
|
|
3
|
+
import { emptyFn, generateGuid, getClassName, isNullish, isStringEmpty } from "@bodynarf/utils";
|
|
4
|
+
import { ElementSize } from "../../../../types";
|
|
5
|
+
import { getSizeClassName, getStyleClassName, mapDataAttributes } from "../../../../utils";
|
|
6
|
+
import ComponentWithLabel from "../../internal/componentWithLabel";
|
|
7
|
+
import InternalHint from "../../internal/hint";
|
|
8
|
+
import "./style.scss";
|
|
9
|
+
/** Parse time string to TimeValue */
|
|
10
|
+
const parseTimeString = (timeString, showSeconds) => {
|
|
11
|
+
if (isStringEmpty(timeString)) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
const parts = timeString.split(":");
|
|
15
|
+
if (parts.length < 2) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const hours = parseInt(parts[0], 10);
|
|
19
|
+
const minutes = parseInt(parts[1], 10);
|
|
20
|
+
const seconds = showSeconds && parts.length >= 3 ? parseInt(parts[2], 10) : undefined;
|
|
21
|
+
if (isNaN(hours) || isNaN(minutes)) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
hours,
|
|
26
|
+
minutes,
|
|
27
|
+
seconds: showSeconds ? (seconds ?? 0) : undefined,
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/** Format TimeValue to string */
|
|
31
|
+
const formatTimeValue = (value, showSeconds) => {
|
|
32
|
+
if (isNullish(value)) {
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
const hours = value.hours.toString().padStart(2, "0");
|
|
36
|
+
const minutes = value.minutes.toString().padStart(2, "0");
|
|
37
|
+
if (showSeconds) {
|
|
38
|
+
const seconds = (value.seconds ?? 0).toString().padStart(2, "0");
|
|
39
|
+
return `${hours}:${minutes}:${seconds}`;
|
|
40
|
+
}
|
|
41
|
+
return `${hours}:${minutes}`;
|
|
42
|
+
};
|
|
43
|
+
/** TimePicker input component */
|
|
44
|
+
const TimePicker = ({ defaultValue, onValueChange = emptyFn, validationState, name = generateGuid(), style, size = ElementSize.Normal, readonly = false, disabled = false, rounded = false, loading = false, autoFocus = false, label, onBlur, onKeyDown, onKeyUp, showSeconds = false, step = 1, min, max, placeholder, className, title, data, hint, }) => {
|
|
45
|
+
const elClassName = useMemo(() => getClassName([
|
|
46
|
+
className,
|
|
47
|
+
getSizeClassName(size, ElementSize.Normal),
|
|
48
|
+
getStyleClassName(style, validationState),
|
|
49
|
+
rounded === true ? "is-rounded" : "",
|
|
50
|
+
"input",
|
|
51
|
+
"bbr-time-picker",
|
|
52
|
+
]), [className, size, style, validationState, rounded]);
|
|
53
|
+
const inputContainerClassName = useMemo(() => getClassName([
|
|
54
|
+
"control",
|
|
55
|
+
loading === true ? "is-loading" : "",
|
|
56
|
+
]), [loading]);
|
|
57
|
+
const stringifiedDefValue = useMemo(() => formatTimeValue(defaultValue, showSeconds), [defaultValue, showSeconds]);
|
|
58
|
+
const onChange = useCallback((event) => {
|
|
59
|
+
const parsed = parseTimeString(event.target.value, showSeconds);
|
|
60
|
+
onValueChange(parsed);
|
|
61
|
+
}, [onValueChange, showSeconds]);
|
|
62
|
+
const dataAttributes = mapDataAttributes(data);
|
|
63
|
+
return (_jsxs(ComponentWithLabel, { id: name, size: size, label: label, children: [_jsx("div", { className: inputContainerClassName, children: _jsx("input", { id: name, min: min, max: max, type: "time", name: name, title: title, onBlur: onBlur, onKeyUp: onKeyUp, ...dataAttributes, onChange: onChange, readOnly: readonly, disabled: disabled, onKeyDown: onKeyDown, autoFocus: autoFocus, className: elClassName, placeholder: placeholder, defaultValue: stringifiedDefValue, step: showSeconds === true ? step : step * 60 }) }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
|
|
64
|
+
};
|
|
65
|
+
export default TimePicker;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.control.is-loading input[type="time"]::-webkit-calendar-picker-indicator {
|
|
2
|
+
display: none;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.control input[type="time"] {
|
|
6
|
+
// Extra padding for AM/PM text to not overlap with clock icon
|
|
7
|
+
padding-right: 2.5rem;
|
|
8
|
+
|
|
9
|
+
&::-webkit-calendar-picker-indicator {
|
|
10
|
+
position: absolute;
|
|
11
|
+
right: 0.75rem;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&.is-small {
|
|
16
|
+
padding-right: 2rem;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.is-medium {
|
|
20
|
+
padding-right: 3rem;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.is-large {
|
|
24
|
+
padding-right: 3.5rem;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/timePicker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BaseNullableInputElementProps, BlurableElement, KeyboardElement } from "../../../types";
|
|
2
|
+
/** Time value representation */
|
|
3
|
+
export interface TimeValue {
|
|
4
|
+
/** Hours (0-23) */
|
|
5
|
+
hours: number;
|
|
6
|
+
/** Minutes (0-59) */
|
|
7
|
+
minutes: number;
|
|
8
|
+
/** Seconds (0-59), optional */
|
|
9
|
+
seconds?: number;
|
|
10
|
+
}
|
|
11
|
+
/** TimePicker component props type */
|
|
12
|
+
export type TimePickerProps = BaseNullableInputElementProps<TimeValue> & BlurableElement & KeyboardElement & {
|
|
13
|
+
/**
|
|
14
|
+
* Show seconds input.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
showSeconds?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Step for minutes (and seconds if shown).
|
|
20
|
+
* See html input step documentation.
|
|
21
|
+
* @default 1
|
|
22
|
+
*/
|
|
23
|
+
step?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Minimum time value (format: "HH:MM" or "HH:MM:SS").
|
|
26
|
+
*/
|
|
27
|
+
min?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Maximum time value (format: "HH:MM" or "HH:MM:SS").
|
|
30
|
+
*/
|
|
31
|
+
max?: string;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/timePicker/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7F,gCAAgC;AAChC,MAAM,WAAW,SAAS;IACtB,mBAAmB;IACnB,KAAK,EAAE,MAAM,CAAC;IAEd,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAEhB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,sCAAsC;AACtC,MAAM,MAAM,eAAe,GAAG,6BAA6B,CAAC,SAAS,CAAC,GAChE,eAAe,GACf,eAAe,GACf;IACE;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/search/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAAyB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/search/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAAyB,MAAM,OAAO,CAAC;AAS/D,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAEjC,uBAAuB;AACvB,QAAA,MAAM,MAAM,EAAE,EAAE,CAAC,WAAW,CAsH3B,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -4,9 +4,10 @@ import { getClassName } from "@bodynarf/utils";
|
|
|
4
4
|
import { ElementSize } from "../../../types";
|
|
5
5
|
import { getSizeClassName, mapDataAttributes } from "../../../utils";
|
|
6
6
|
import Button, { ButtonStyle } from "../../button";
|
|
7
|
+
import Icon from "../../icon";
|
|
7
8
|
import "./style.scss";
|
|
8
9
|
/** Search component */
|
|
9
|
-
const Search = ({ searchType, onSearch, caption, defaultValue = "", size = ElementSize.Normal, isLoading = false, rounded = false, disabled = false, autoFocus = false, searchButtonCaption = "Search", searchButtonTitle, className, title, data, }) => {
|
|
10
|
+
const Search = ({ searchType, onSearch, caption, defaultValue = "", size = ElementSize.Normal, isLoading = false, rounded = false, disabled = false, autoFocus = false, searchButtonCaption = "Search", searchButtonTitle, showIcon = false, className, title, data, }) => {
|
|
10
11
|
const [searchValue, setSearchValue] = useState(defaultValue);
|
|
11
12
|
const onChange = useCallback((event) => {
|
|
12
13
|
const elementValue = event.target.value;
|
|
@@ -23,6 +24,7 @@ const Search = ({ searchType, onSearch, caption, defaultValue = "", size = Eleme
|
|
|
23
24
|
getSizeClassName(size),
|
|
24
25
|
isLoading ? "is-loading" : "",
|
|
25
26
|
searchType === "byButton" ? "is-expanded" : "",
|
|
27
|
+
showIcon ? "has-icons-left" : "",
|
|
26
28
|
]);
|
|
27
29
|
const inputClassName = getClassName([
|
|
28
30
|
"input",
|
|
@@ -32,8 +34,12 @@ const Search = ({ searchType, onSearch, caption, defaultValue = "", size = Eleme
|
|
|
32
34
|
]);
|
|
33
35
|
const dataAttributes = mapDataAttributes(data);
|
|
34
36
|
if (searchType === "byButton") {
|
|
35
|
-
return (_jsxs("div", { className: "field has-addons", children: [
|
|
37
|
+
return (_jsxs("div", { className: "field has-addons", children: [_jsxs("div", { className: elClassName, children: [_jsx("input", { type: "search", title: title, disabled: disabled, onChange: onChange, ...dataAttributes, placeholder: caption, autoFocus: autoFocus, defaultValue: searchValue, className: inputClassName }), showIcon
|
|
38
|
+
? (_jsx("span", { className: `icon is-left ${getSizeClassName(size)}`, children: _jsx(Icon, { size: size, name: "search" }) }))
|
|
39
|
+
: null] }), _jsx("div", { className: "control", children: _jsx(Button, { size: size, rounded: rounded, disabled: disabled, isLoading: isLoading, style: ButtonStyle.Info, title: searchButtonTitle, caption: searchButtonCaption, onClick: onSearchButtonClick }) })] }));
|
|
36
40
|
}
|
|
37
|
-
return (
|
|
41
|
+
return (_jsxs("div", { className: elClassName, children: [_jsx("input", { type: "search", title: title, disabled: disabled, onChange: onChange, ...dataAttributes, placeholder: caption, autoFocus: autoFocus, defaultValue: searchValue, className: inputClassName }), showIcon
|
|
42
|
+
? (_jsx("span", { className: `icon is-left ${getSizeClassName(size)}`, children: _jsx(Icon, { size: size, name: "search" }) }))
|
|
43
|
+
: null] }));
|
|
38
44
|
};
|
|
39
45
|
export default Search;
|
|
@@ -36,6 +36,11 @@ export type SearchProps = BaseElementProps & {
|
|
|
36
36
|
* Visible only in `searchType = "byButton"`
|
|
37
37
|
*/
|
|
38
38
|
searchButtonTitle?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Should search icon (magnifying glass) be displayed
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
showIcon?: boolean;
|
|
39
44
|
/** Search handler */
|
|
40
45
|
onSearch: (searchPattern: string) => void;
|
|
41
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/search/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE3D,kCAAkC;AAClC,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG;IACzC;;;;MAIE;IACF,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;IAEpC,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAEhB,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,yBAAyB;IACzB,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,mCAAmC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,qDAAqD;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,qBAAqB;IACrB,QAAQ,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/search/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE3D,kCAAkC;AAClC,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG;IACzC;;;;MAIE;IACF,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;IAEpC,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAEhB,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,yBAAyB;IACzB,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,mCAAmC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,qDAAqD;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,qBAAqB;IACrB,QAAQ,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/stepper/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAwB,MAAM,OAAO,CAAC;AAOjD,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAY,YAAY,EAAc,MAAM,UAAU,CAAC;AAsB9D,6DAA6D;AAC7D,QAAA,MAAM,OAAO,EAAE,EAAE,CAAC,YAAY,CA4G7B,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo } from "react";
|
|
3
|
+
import { getClassName, isNullish } from "@bodynarf/utils";
|
|
4
|
+
import { ElementColor, ElementSize } from "../../../types";
|
|
5
|
+
import { getElementColorClassName, getSizeClassName, mapDataAttributes } from "../../../utils";
|
|
6
|
+
import "./style.scss";
|
|
7
|
+
/** Get step status based on current step */
|
|
8
|
+
const getStepStatus = (steps, currentStepId, stepId) => {
|
|
9
|
+
const currentIndex = steps.findIndex(s => s.id === currentStepId);
|
|
10
|
+
const stepIndex = steps.findIndex(s => s.id === stepId);
|
|
11
|
+
if (stepIndex < currentIndex) {
|
|
12
|
+
return "completed";
|
|
13
|
+
}
|
|
14
|
+
if (stepIndex === currentIndex) {
|
|
15
|
+
return "current";
|
|
16
|
+
}
|
|
17
|
+
return "upcoming";
|
|
18
|
+
};
|
|
19
|
+
/** Stepper component for displaying step-by-step progress */
|
|
20
|
+
const Stepper = ({ steps, currentStep, size = ElementSize.Normal, color = ElementColor.Primary, vertical = false, showNumbers = true, clickable = false, showConnectors = true, animated = false, showArrows = false, onStepClick, className, title, data, }) => {
|
|
21
|
+
const containerClassName = useMemo(() => getClassName([
|
|
22
|
+
"bbr-stepper",
|
|
23
|
+
className,
|
|
24
|
+
getSizeClassName(size, ElementSize.Normal),
|
|
25
|
+
getElementColorClassName(color),
|
|
26
|
+
vertical ? "is-vertical" : "",
|
|
27
|
+
showConnectors === true || showArrows === true ? "has-connectors" : "",
|
|
28
|
+
animated ? "is-animated" : "",
|
|
29
|
+
]), [className, size, color, vertical, showConnectors, animated, showArrows]);
|
|
30
|
+
const handleStepClick = useCallback((step, index, status) => {
|
|
31
|
+
if (!clickable || isNullish(onStepClick)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const isStepClickable = step.clickable !== false && status === "completed";
|
|
35
|
+
if (isStepClickable) {
|
|
36
|
+
onStepClick(step, index);
|
|
37
|
+
}
|
|
38
|
+
}, [clickable, onStepClick]);
|
|
39
|
+
const dataAttributes = mapDataAttributes(data);
|
|
40
|
+
return (_jsx("div", { title: title, ...dataAttributes, className: containerClassName, children: steps.map((step, index) => {
|
|
41
|
+
const status = getStepStatus(steps, currentStep, step.id);
|
|
42
|
+
const isClickable = clickable && step.clickable !== false && status === "completed";
|
|
43
|
+
const stepClassName = getClassName([
|
|
44
|
+
"bbr-stepper-step",
|
|
45
|
+
`is-${status}`,
|
|
46
|
+
isClickable ? "is-clickable" : "",
|
|
47
|
+
]);
|
|
48
|
+
return (_jsxs("div", { className: stepClassName, onClick: () => handleStepClick(step, index, status), children: [_jsx("div", { className: "bbr-stepper-marker", children: status === "completed" && !showNumbers ? (_jsx("span", { className: "bbr-stepper-icon", children: _jsx("i", { className: "fas fa-check" }) })) : step.icon && !showNumbers ? (_jsx("span", { className: "bbr-stepper-icon", children: _jsx("i", { className: `fas ${step.icon}` }) })) : (_jsx("span", { className: "bbr-stepper-number", children: index + 1 })) }), _jsxs("div", { className: "bbr-stepper-content", children: [_jsx("div", { className: "bbr-stepper-title", children: step.title }), step.description !== undefined && step.description !== "" && (_jsx("div", { className: "bbr-stepper-description", children: step.description }))] }), index < steps.length - 1 && (_jsx("div", { className: getClassName([
|
|
49
|
+
"bbr-stepper-connector",
|
|
50
|
+
status === "completed" ? "is-completed" : "",
|
|
51
|
+
showArrows === true ? "has-arrow" : "",
|
|
52
|
+
showConnectors !== true && showArrows !== true ? "is-hidden" : "",
|
|
53
|
+
]) }))] }, step.id));
|
|
54
|
+
}) }));
|
|
55
|
+
};
|
|
56
|
+
export default Stepper;
|