@tap-payments/os-micro-frontend-shared 0.1.392 → 0.1.393
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CustomRadioGroupProps } from './type';
|
|
3
|
-
declare function RadioGroup({ options, onOptionChange, size, customLabelRenderer, layout, spacing, labelPosition, showHoverEffects, customRadioProps, labelSx, onChange, sx, ...props }: CustomRadioGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare function RadioGroup({ options, onOptionChange, size, customLabelRenderer, layout, spacing, labelPosition, showHoverEffects, customRadioProps, labelSx, onChange, title, sx, ...props }: CustomRadioGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
declare const _default: import("react").MemoExoticComponent<typeof RadioGroup>;
|
|
5
5
|
export default _default;
|
|
@@ -9,23 +9,30 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { memo } from 'react';
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { memo, useMemo } from 'react';
|
|
14
14
|
import MuiRadioGroup from '@mui/material/RadioGroup';
|
|
15
15
|
import { StyledFormControlLabel } from './style';
|
|
16
16
|
import { RadioButton } from '../RadioButton';
|
|
17
|
+
import { FormControl, FormLabel, Stack } from '@mui/material';
|
|
17
18
|
function RadioItem(_a) {
|
|
18
|
-
var { option, size = 'small', customLabelRenderer, labelPosition = 'end', showHoverEffects = true, customRadioProps, labelSx } = _a, props = __rest(_a, ["option", "size", "customLabelRenderer", "labelPosition", "showHoverEffects", "customRadioProps", "labelSx"]);
|
|
19
|
+
var { option, size = 'small', customLabelRenderer, labelPosition = 'end', showHoverEffects = true, customRadioProps, labelSx, icon } = _a, props = __rest(_a, ["option", "size", "customLabelRenderer", "labelPosition", "showHoverEffects", "customRadioProps", "labelSx", "icon"]);
|
|
19
20
|
const label = customLabelRenderer ? customLabelRenderer(option) : option.label;
|
|
20
|
-
|
|
21
|
+
const labelContent = useMemo(() => {
|
|
22
|
+
if (icon) {
|
|
23
|
+
return (_jsxs(Stack, Object.assign({ direction: "row", alignItems: "center", justifyContent: "space-between" }, { children: [label, _jsx("img", Object.assign({ alt: "icon" }, icon))] })));
|
|
24
|
+
}
|
|
25
|
+
return label;
|
|
26
|
+
}, [icon, label]);
|
|
27
|
+
return (_jsx(StyledFormControlLabel, Object.assign({ value: option.value, control: _jsx(RadioButton, Object.assign({ size: size }, customRadioProps, option.customProps)), label: labelContent, disabled: option.disabled, size: size, labelPlacement: labelPosition, showHoverEffects: showHoverEffects, labelSx: labelSx }, props)));
|
|
21
28
|
}
|
|
22
29
|
function RadioGroup(_a) {
|
|
23
|
-
var { options, onOptionChange, size = 'small', customLabelRenderer, layout = 'vertical', spacing = 0, labelPosition = 'end', showHoverEffects = true, customRadioProps, labelSx, onChange, sx } = _a, props = __rest(_a, ["options", "onOptionChange", "size", "customLabelRenderer", "layout", "spacing", "labelPosition", "showHoverEffects", "customRadioProps", "labelSx", "onChange", "sx"]);
|
|
30
|
+
var { options, onOptionChange, size = 'small', customLabelRenderer, layout = 'vertical', spacing = 0, labelPosition = 'end', showHoverEffects = true, customRadioProps, labelSx, onChange, title, sx } = _a, props = __rest(_a, ["options", "onOptionChange", "size", "customLabelRenderer", "layout", "spacing", "labelPosition", "showHoverEffects", "customRadioProps", "labelSx", "onChange", "title", "sx"]);
|
|
24
31
|
const handleChange = (event) => {
|
|
25
32
|
const value = event.target.value;
|
|
26
33
|
onOptionChange === null || onOptionChange === void 0 ? void 0 : onOptionChange(value);
|
|
27
34
|
onChange === null || onChange === void 0 ? void 0 : onChange(event, value);
|
|
28
35
|
};
|
|
29
|
-
return (_jsx(MuiRadioGroup, Object.assign({ onChange: handleChange, sx: Object.assign({ display: 'flex', flexDirection: layout === 'horizontal' ? 'row' : 'column', gap: spacing }, sx) }, props, { children: options.map((option) => (_jsx(RadioItem, { option: option, size: size, customLabelRenderer: customLabelRenderer, labelPosition: labelPosition, showHoverEffects: showHoverEffects, customRadioProps: customRadioProps, labelSx: labelSx }, option.value))) })));
|
|
36
|
+
return (_jsxs(FormControl, { children: [typeof title === 'string' ? _jsx(FormLabel, { children: title }) : title, _jsx(MuiRadioGroup, Object.assign({ onChange: handleChange, sx: Object.assign({ display: 'flex', flexDirection: layout === 'horizontal' ? 'row' : 'column', gap: spacing }, sx) }, props, { children: options.map((option) => (_jsx(RadioItem, { icon: option.icon, option: option, size: size, customLabelRenderer: customLabelRenderer, labelPosition: labelPosition, showHoverEffects: showHoverEffects, customRadioProps: customRadioProps, labelSx: labelSx }, option.value))) }))] }));
|
|
30
37
|
}
|
|
31
38
|
export default memo(RadioGroup);
|
|
@@ -7,10 +7,10 @@ export interface RadioOption {
|
|
|
7
7
|
label: string;
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
description?: string;
|
|
10
|
-
icon?:
|
|
10
|
+
icon?: React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>;
|
|
11
11
|
customProps?: Partial<RadioButtonProps>;
|
|
12
12
|
}
|
|
13
|
-
export interface CustomRadioGroupProps extends Omit<RadioGroupProps, 'children'> {
|
|
13
|
+
export interface CustomRadioGroupProps extends Omit<RadioGroupProps, 'children' | 'title'> {
|
|
14
14
|
options: RadioOption[];
|
|
15
15
|
onOptionChange?: (value: string) => void;
|
|
16
16
|
size?: 'small' | 'medium' | 'large';
|
|
@@ -21,6 +21,7 @@ export interface CustomRadioGroupProps extends Omit<RadioGroupProps, 'children'>
|
|
|
21
21
|
showHoverEffects?: boolean;
|
|
22
22
|
customRadioProps?: Partial<RadioButtonProps>;
|
|
23
23
|
labelSx?: React.CSSProperties;
|
|
24
|
+
title?: React.ReactNode;
|
|
24
25
|
}
|
|
25
26
|
export interface RadioItemProps extends Omit<FormControlLabelProps, 'control' | 'label'> {
|
|
26
27
|
option: RadioOption;
|
|
@@ -30,4 +31,5 @@ export interface RadioItemProps extends Omit<FormControlLabelProps, 'control' |
|
|
|
30
31
|
showHoverEffects?: boolean;
|
|
31
32
|
customRadioProps?: Partial<RadioButtonProps>;
|
|
32
33
|
labelSx?: React.CSSProperties;
|
|
34
|
+
icon?: React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>;
|
|
33
35
|
}
|
package/package.json
CHANGED