@cleartrip/ct-design-radio 4.0.0 → 5.0.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/README.md +63 -0
- package/dist/Radio.d.ts +2 -3
- package/dist/Radio.d.ts.map +1 -1
- package/dist/Radio.native.d.ts +5 -0
- package/dist/Radio.native.d.ts.map +1 -0
- package/dist/ct-design-radio.browser.cjs.js +1 -1
- package/dist/ct-design-radio.browser.cjs.js.map +1 -1
- package/dist/ct-design-radio.browser.esm.js +1 -1
- package/dist/ct-design-radio.browser.esm.js.map +1 -1
- package/dist/ct-design-radio.cjs.js +91 -75
- package/dist/ct-design-radio.cjs.js.map +1 -1
- package/dist/ct-design-radio.esm.js +93 -73
- package/dist/ct-design-radio.esm.js.map +1 -1
- package/dist/ct-design-radio.umd.js +91 -116
- package/dist/ct-design-radio.umd.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.native.d.ts +3 -0
- package/dist/index.native.d.ts.map +1 -0
- package/dist/style.d.ts +10 -37
- package/dist/style.d.ts.map +1 -1
- package/dist/type.d.ts +14 -20
- package/dist/type.d.ts.map +1 -1
- package/package.json +22 -12
- package/src/Radio.native.tsx +91 -0
- package/src/Radio.tsx +121 -0
- package/src/index.native.ts +2 -0
- package/src/index.ts +2 -0
- package/src/style.ts +54 -0
- package/src/type.ts +50 -0
- package/dist/BaseRadio/BaseRadio.d.ts +0 -10
- package/dist/BaseRadio/BaseRadio.d.ts.map +0 -1
- package/dist/BaseRadio/index.d.ts +0 -2
- package/dist/BaseRadio/index.d.ts.map +0 -1
- package/dist/BaseRadio/style.d.ts +0 -6
- package/dist/BaseRadio/style.d.ts.map +0 -1
- package/dist/BaseRadio/type.d.ts +0 -12
- package/dist/BaseRadio/type.d.ts.map +0 -1
package/dist/style.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../packages/components/Radio/src/style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../packages/components/Radio/src/style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAmB,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEvF,KAAK,gBAAgB,GAAG;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,KAAK,EAAE,YAAY,OAAO,EAAE,YAAY,OAAO,KAAG,gBAqCxF,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,YAAY,OAAO,KAAG,mBAKnD,CAAC"}
|
package/dist/type.d.ts
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
id
|
|
6
|
-
name?: string;
|
|
7
|
-
value?: string;
|
|
8
|
-
label?: string;
|
|
9
|
-
labelCTA?: ReactNode;
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import type { Styles } from '@cleartrip/ct-design-types';
|
|
3
|
+
import type { TypographyVariantType } from '@cleartrip/ct-design-typography';
|
|
4
|
+
export interface IRadio {
|
|
5
|
+
id: string;
|
|
10
6
|
checked?: boolean;
|
|
11
7
|
disabled?: boolean;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
labelVariant?:
|
|
8
|
+
onChange?: () => void;
|
|
9
|
+
label: ReactNode | string;
|
|
10
|
+
labelVariant?: TypographyVariantType;
|
|
11
|
+
labelCTA?: ReactNode;
|
|
15
12
|
styleConfig?: {
|
|
16
|
-
root?:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
radioContainer?: BaseStyleConfigProps;
|
|
20
|
-
radio?: BaseStyleConfigProps;
|
|
21
|
-
radioWrapper?: BaseStyleConfigProps;
|
|
22
|
-
labelContainer?: BaseStyleConfigProps;
|
|
23
|
-
labelTypography?: TypographyStyleConfigProps;
|
|
13
|
+
root?: Styles[];
|
|
14
|
+
radioBtn?: Styles[];
|
|
15
|
+
labelContainer?: Styles[];
|
|
24
16
|
};
|
|
17
|
+
rootProps?: Record<string, unknown>;
|
|
25
18
|
}
|
|
19
|
+
export type RadioProps = IRadio;
|
|
26
20
|
//# sourceMappingURL=type.d.ts.map
|
package/dist/type.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../packages/components/Radio/src/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../packages/components/Radio/src/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAK7E,MAAM,WAAW,MAAM;IAErB,EAAE,EAAE,MAAM,CAAC;IAGX,OAAO,CAAC,EAAE,OAAO,CAAC;IAGlB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAGnB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IAGtB,KAAK,EAAE,SAAS,GAAG,MAAM,CAAC;IAG1B,YAAY,CAAC,EAAE,qBAAqB,CAAC;IAGrC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAGrB,WAAW,CAAC,EAAE;QAEZ,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAGhB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QAGpB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;KAC3B,CAAC;IAGF,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAKD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,31 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cleartrip/ct-design-radio",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Radio Component",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
|
-
"main": "dist/ct-design-radio.cjs.js",
|
|
6
|
+
"main": "./dist/ct-design-radio.cjs.js",
|
|
7
7
|
"jsnext:main": "dist/ct-design-radio.esm.js",
|
|
8
8
|
"module": "dist/ct-design-radio.esm.js",
|
|
9
|
+
"react-native": "src/index.native.ts",
|
|
9
10
|
"sideEffects": false,
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/ct-design-radio.esm.js",
|
|
15
|
+
"default": "./dist/ct-design-radio.cjs.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
10
18
|
"browser": {
|
|
11
19
|
"./dist/ct-design-radio.esm.js": "./dist/ct-design-radio.browser.esm.js",
|
|
12
20
|
"./dist/ct-design-radio.cjs.js": "./dist/ct-design-radio.browser.cjs.js"
|
|
13
21
|
},
|
|
14
22
|
"files": [
|
|
15
|
-
"dist"
|
|
23
|
+
"dist",
|
|
24
|
+
"src"
|
|
16
25
|
],
|
|
17
26
|
"dependencies": {
|
|
18
|
-
"@
|
|
19
|
-
"@cleartrip/ct-design-
|
|
20
|
-
"@cleartrip/ct-design-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"@cleartrip/ct-design-
|
|
27
|
+
"@emotion/css": "11.13.4",
|
|
28
|
+
"@cleartrip/ct-design-theme": "5.0.0",
|
|
29
|
+
"@cleartrip/ct-design-container": "5.0.0",
|
|
30
|
+
"@cleartrip/ct-design-types": "5.0.0",
|
|
31
|
+
"@cleartrip/ct-design-typography": "5.0.0",
|
|
32
|
+
"@cleartrip/ct-design-style-manager": "5.0.0"
|
|
24
33
|
},
|
|
25
34
|
"peerDependencies": {
|
|
26
35
|
"react": ">=16.8.0",
|
|
27
|
-
"react-dom": ">=16.8.0"
|
|
28
|
-
"styled-components": "^5.3.6"
|
|
36
|
+
"react-dom": ">=16.8.0"
|
|
29
37
|
},
|
|
30
38
|
"publishConfig": {
|
|
31
39
|
"access": "public"
|
|
@@ -36,6 +44,8 @@
|
|
|
36
44
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
37
45
|
"watch-package": "rollup -c -w",
|
|
38
46
|
"build-package": "rollup -c",
|
|
39
|
-
"build-package:clean": "rm -rf dist && rollup -c"
|
|
47
|
+
"build-package:clean": "rm -rf dist && rollup -c",
|
|
48
|
+
"publish-package:local": "yalc publish --no-scripts",
|
|
49
|
+
"publish-package:local:registry": "pnpm publish --registry http://localhost:4873 --no-git-checks --access public"
|
|
40
50
|
}
|
|
41
51
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Pressable, View } from 'react-native';
|
|
4
|
+
import { Container } from '@cleartrip/ct-design-container';
|
|
5
|
+
import { Typography, TypographyVariant } from '@cleartrip/ct-design-typography';
|
|
6
|
+
import { makeStyles, useNativeMergeStyles, useStyles } from '@cleartrip/ct-design-style-manager';
|
|
7
|
+
import { useTheme } from '@cleartrip/ct-design-theme';
|
|
8
|
+
|
|
9
|
+
import { getBorderStyles, getLabelColor } from './style';
|
|
10
|
+
import { IRadio } from './type';
|
|
11
|
+
|
|
12
|
+
const staticRadioStyles = makeStyles((theme) => ({
|
|
13
|
+
root: {
|
|
14
|
+
display: 'flex',
|
|
15
|
+
flexDirection: 'row',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
gap: theme?.spacing[2],
|
|
18
|
+
},
|
|
19
|
+
radioBtn: {
|
|
20
|
+
width: theme?.spacing[5],
|
|
21
|
+
height: theme?.spacing[5],
|
|
22
|
+
borderRadius: theme?.border.radius[32],
|
|
23
|
+
borderStyle: theme?.border.style.solid,
|
|
24
|
+
},
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
const Radio = forwardRef<View, IRadio>(
|
|
28
|
+
(
|
|
29
|
+
{ id, label, labelCTA, labelVariant, onChange, disabled = false, checked = false, styleConfig, rootProps = {} },
|
|
30
|
+
ref,
|
|
31
|
+
) => {
|
|
32
|
+
const theme = useTheme();
|
|
33
|
+
|
|
34
|
+
const radioBtnStyles = useStyles(
|
|
35
|
+
(themeArg) => ({
|
|
36
|
+
root: getBorderStyles(themeArg, checked, disabled),
|
|
37
|
+
}),
|
|
38
|
+
[disabled, checked],
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
root: customRootStyles = [],
|
|
43
|
+
radioBtn: customRadioBtnStyles = [],
|
|
44
|
+
labelContainer: customLabelContainerStyles = [],
|
|
45
|
+
} = styleConfig || {};
|
|
46
|
+
|
|
47
|
+
const mergedRootStyles = useNativeMergeStyles([staticRadioStyles?.root, ...customRootStyles], [customRootStyles]);
|
|
48
|
+
|
|
49
|
+
const handleOnRadioClick = () => {
|
|
50
|
+
if (disabled) return;
|
|
51
|
+
onChange?.();
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Pressable
|
|
56
|
+
hitSlop={{ top: theme?.spacing[3], bottom: theme?.spacing[3] }}
|
|
57
|
+
ref={ref}
|
|
58
|
+
id={id}
|
|
59
|
+
style={mergedRootStyles}
|
|
60
|
+
disabled={disabled}
|
|
61
|
+
onPress={handleOnRadioClick}
|
|
62
|
+
{...rootProps}
|
|
63
|
+
>
|
|
64
|
+
<Container
|
|
65
|
+
styleConfig={{ root: [staticRadioStyles?.radioBtn, radioBtnStyles.root, ...customRadioBtnStyles] }}
|
|
66
|
+
onClick={handleOnRadioClick}
|
|
67
|
+
/>
|
|
68
|
+
<Container styleConfig={{ root: [...customLabelContainerStyles] }} onClick={handleOnRadioClick}>
|
|
69
|
+
{typeof label === 'string' ? (
|
|
70
|
+
<Typography variant={TypographyVariant.B2} color={getLabelColor(disabled)}>
|
|
71
|
+
{label}
|
|
72
|
+
</Typography>
|
|
73
|
+
) : (
|
|
74
|
+
label
|
|
75
|
+
)}
|
|
76
|
+
{typeof labelCTA === 'string' ? (
|
|
77
|
+
<Typography variant={labelVariant || TypographyVariant.B2} color={getLabelColor(disabled)}>
|
|
78
|
+
{labelCTA}
|
|
79
|
+
</Typography>
|
|
80
|
+
) : (
|
|
81
|
+
labelCTA
|
|
82
|
+
)}
|
|
83
|
+
</Container>
|
|
84
|
+
</Pressable>
|
|
85
|
+
);
|
|
86
|
+
},
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
Radio.displayName = 'Radio';
|
|
90
|
+
|
|
91
|
+
export default Radio;
|
package/src/Radio.tsx
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Container } from '@cleartrip/ct-design-container';
|
|
4
|
+
import { Typography, TypographyVariant } from '@cleartrip/ct-design-typography';
|
|
5
|
+
import { makeStyles, useStyles, useWebMergeStyles } from '@cleartrip/ct-design-style-manager';
|
|
6
|
+
import { css } from '@emotion/css';
|
|
7
|
+
|
|
8
|
+
import { getBorderStyles, getLabelColor } from './style';
|
|
9
|
+
import { IRadio } from './type';
|
|
10
|
+
|
|
11
|
+
const webStaticStyles = {
|
|
12
|
+
disabledRoot: css({
|
|
13
|
+
cursor: 'not-allowed',
|
|
14
|
+
}),
|
|
15
|
+
hiddenInput: css({
|
|
16
|
+
position: 'absolute',
|
|
17
|
+
opacity: 0,
|
|
18
|
+
width: 0,
|
|
19
|
+
height: 0,
|
|
20
|
+
margin: 0,
|
|
21
|
+
padding: 0,
|
|
22
|
+
border: 'none',
|
|
23
|
+
pointerEvents: 'none',
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const staticRadioStyles = makeStyles((theme) => ({
|
|
28
|
+
root: {
|
|
29
|
+
display: 'flex',
|
|
30
|
+
flexDirection: 'row',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
gap: theme?.spacing[2],
|
|
33
|
+
cursor: 'pointer',
|
|
34
|
+
userSelect: 'none',
|
|
35
|
+
},
|
|
36
|
+
radioBtn: {
|
|
37
|
+
width: theme?.spacing[5],
|
|
38
|
+
height: theme?.spacing[5],
|
|
39
|
+
borderRadius: theme?.border.radius[32],
|
|
40
|
+
borderStyle: theme?.border.style.solid,
|
|
41
|
+
display: 'flex',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
justifyContent: 'center',
|
|
44
|
+
},
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
const Radio = forwardRef<HTMLInputElement, IRadio>(
|
|
48
|
+
(
|
|
49
|
+
{ id, label, labelCTA, labelVariant, onChange, disabled = false, checked = false, styleConfig, rootProps = {} },
|
|
50
|
+
ref,
|
|
51
|
+
) => {
|
|
52
|
+
const dynamicStyles = useStyles(
|
|
53
|
+
(theme) => ({
|
|
54
|
+
radioBtn: getBorderStyles(theme, checked, disabled),
|
|
55
|
+
label: {
|
|
56
|
+
color: getLabelColor(disabled),
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
59
|
+
[checked, disabled],
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const {
|
|
63
|
+
root: customRootStyles = [],
|
|
64
|
+
radioBtn: customRadioBtnStyles = [],
|
|
65
|
+
labelContainer: customLabelContainerStyles = [],
|
|
66
|
+
} = styleConfig || {};
|
|
67
|
+
|
|
68
|
+
const handleRadioChange = () => {
|
|
69
|
+
if (disabled) return;
|
|
70
|
+
onChange?.();
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const mergedRootClassName = useWebMergeStyles(
|
|
74
|
+
[staticRadioStyles.root, ...(disabled ? [webStaticStyles.disabledRoot] : []), ...customRootStyles],
|
|
75
|
+
[disabled, customRootStyles],
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const mergedInputClassName = useWebMergeStyles([webStaticStyles.hiddenInput], []);
|
|
79
|
+
|
|
80
|
+
const mergedRadioBtnClassName = useWebMergeStyles(
|
|
81
|
+
[staticRadioStyles.radioBtn, dynamicStyles.radioBtn, ...customRadioBtnStyles],
|
|
82
|
+
[dynamicStyles.radioBtn, customRadioBtnStyles],
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div id={`${id}-root`} className={mergedRootClassName} onClick={handleRadioChange} {...rootProps}>
|
|
87
|
+
<input
|
|
88
|
+
ref={ref}
|
|
89
|
+
id={id}
|
|
90
|
+
type='radio'
|
|
91
|
+
checked={checked}
|
|
92
|
+
disabled={disabled}
|
|
93
|
+
onChange={handleRadioChange}
|
|
94
|
+
className={mergedInputClassName}
|
|
95
|
+
aria-labelledby={`${id}-label`}
|
|
96
|
+
/>
|
|
97
|
+
<span className={mergedRadioBtnClassName} />
|
|
98
|
+
<Container styleConfig={{ root: customLabelContainerStyles }}>
|
|
99
|
+
{typeof label === 'string' ? (
|
|
100
|
+
<Typography variant={TypographyVariant.B2} styleConfig={{ root: [dynamicStyles.label] }}>
|
|
101
|
+
{label}
|
|
102
|
+
</Typography>
|
|
103
|
+
) : (
|
|
104
|
+
label
|
|
105
|
+
)}
|
|
106
|
+
{typeof labelCTA === 'string' ? (
|
|
107
|
+
<Typography variant={labelVariant || TypographyVariant.B2} styleConfig={{ root: [dynamicStyles.label] }}>
|
|
108
|
+
{labelCTA}
|
|
109
|
+
</Typography>
|
|
110
|
+
) : (
|
|
111
|
+
labelCTA
|
|
112
|
+
)}
|
|
113
|
+
</Container>
|
|
114
|
+
</div>
|
|
115
|
+
);
|
|
116
|
+
},
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
Radio.displayName = 'Radio';
|
|
120
|
+
|
|
121
|
+
export default Radio;
|
package/src/index.ts
ADDED
package/src/style.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Theme } from '@cleartrip/ct-design-theme';
|
|
2
|
+
import { TypographyColor, TypographyColorType } from '@cleartrip/ct-design-typography';
|
|
3
|
+
|
|
4
|
+
type RadioBorderStyle = {
|
|
5
|
+
borderWidth: number;
|
|
6
|
+
borderColor?: string;
|
|
7
|
+
backgroundColor?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const getBorderStyles = (theme: Theme, isSelected: boolean, isDisabled: boolean): RadioBorderStyle => {
|
|
11
|
+
switch (true) {
|
|
12
|
+
case isDisabled: {
|
|
13
|
+
if (isSelected) {
|
|
14
|
+
return {
|
|
15
|
+
borderWidth: theme.border.width.xl,
|
|
16
|
+
borderColor: theme.color.border.disabled,
|
|
17
|
+
// @ts-ignore web only property
|
|
18
|
+
cursor: 'not-allowed',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
borderWidth: theme.border.width.sm,
|
|
23
|
+
borderColor: theme.color.border.disabled,
|
|
24
|
+
backgroundColor: theme.color.background.neutral,
|
|
25
|
+
// @ts-ignore web only property
|
|
26
|
+
cursor: 'not-allowed',
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
case isSelected: {
|
|
30
|
+
return {
|
|
31
|
+
borderWidth: theme.border.width.xl,
|
|
32
|
+
borderColor: theme.color.border.primary,
|
|
33
|
+
// @ts-ignore web only property
|
|
34
|
+
cursor: 'pointer',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
default: {
|
|
38
|
+
return {
|
|
39
|
+
borderWidth: theme.border.width.sm,
|
|
40
|
+
borderColor: theme.color.border.defaultDark,
|
|
41
|
+
backgroundColor: theme.color.background.neutral,
|
|
42
|
+
// @ts-ignore web only property
|
|
43
|
+
cursor: 'pointer',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const getLabelColor = (isDisabled: boolean): TypographyColorType => {
|
|
50
|
+
if (isDisabled) {
|
|
51
|
+
return TypographyColor.DISABLED;
|
|
52
|
+
}
|
|
53
|
+
return TypographyColor.PRIMARY;
|
|
54
|
+
};
|
package/src/type.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { Styles } from '@cleartrip/ct-design-types';
|
|
4
|
+
import type { TypographyVariantType } from '@cleartrip/ct-design-typography';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Interface for Radio component props
|
|
8
|
+
*/
|
|
9
|
+
export interface IRadio {
|
|
10
|
+
/** Unique identifier for the radio button */
|
|
11
|
+
id: string;
|
|
12
|
+
|
|
13
|
+
/** Determines if the radio button is checked */
|
|
14
|
+
checked?: boolean;
|
|
15
|
+
|
|
16
|
+
/** Disables the radio button when true */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
|
|
19
|
+
/** Callback function triggered on selection change */
|
|
20
|
+
onChange?: () => void;
|
|
21
|
+
|
|
22
|
+
/** Label content, can be a string or React node */
|
|
23
|
+
label: ReactNode | string;
|
|
24
|
+
|
|
25
|
+
/** Typography variant for the label */
|
|
26
|
+
labelVariant?: TypographyVariantType;
|
|
27
|
+
|
|
28
|
+
/** Call-to-action content within the label */
|
|
29
|
+
labelCTA?: ReactNode;
|
|
30
|
+
|
|
31
|
+
/** Custom styles for different parts of the radio button */
|
|
32
|
+
styleConfig?: {
|
|
33
|
+
/** Root container styles */
|
|
34
|
+
root?: Styles[];
|
|
35
|
+
|
|
36
|
+
/** Radio button styles */
|
|
37
|
+
radioBtn?: Styles[];
|
|
38
|
+
|
|
39
|
+
/** Label container styles */
|
|
40
|
+
labelContainer?: Styles[];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** Additional props forwarded to the root element */
|
|
44
|
+
rootProps?: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Use `IRadio` instead — kept as an alias for backward type compatibility.
|
|
49
|
+
*/
|
|
50
|
+
export type RadioProps = IRadio;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { CSSProperties } from 'styled-components';
|
|
2
|
-
import { BaseRadioProps, StyledRadioProps } from './type';
|
|
3
|
-
export declare const BaseRadio: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, {
|
|
4
|
-
type: "radio";
|
|
5
|
-
css: {};
|
|
6
|
-
} & BaseRadioProps, "type" | "css">;
|
|
7
|
-
export declare const StyledRadio: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, StyledRadioProps & {
|
|
8
|
-
css?: CSSProperties | undefined;
|
|
9
|
-
}, never>;
|
|
10
|
-
//# sourceMappingURL=BaseRadio.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseRadio.d.ts","sourceRoot":"","sources":["../../packages/components/Radio/src/BaseRadio/BaseRadio.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAa,aAAa,EAAC,MAAO,mBAAmB,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAE1D,eAAO,MAAM,SAAS;;;mCAkBrB,CAAC;AAGF,eAAO,MAAM,WAAW;;SAMrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/components/Radio/src/BaseRadio/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Theme } from '@cleartrip/ct-design-theme';
|
|
2
|
-
import { StyledRadioProps } from './type';
|
|
3
|
-
export declare const getStyledRadioStyles: ({ backgroundColor, cursor, borderWidth, borderColor, theme, }: StyledRadioProps & {
|
|
4
|
-
theme: Theme;
|
|
5
|
-
}) => import("styled-components").FlattenSimpleInterpolation;
|
|
6
|
-
//# sourceMappingURL=style.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../packages/components/Radio/src/BaseRadio/style.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAE1C,eAAO,MAAM,oBAAoB;WAMF,KAAK;4DAyBnC,CAAC"}
|
package/dist/BaseRadio/type.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { CSSObject, CSSProperties } from 'styled-components';
|
|
2
|
-
export interface BaseRadioProps {
|
|
3
|
-
cursor?: CSSObject['cursor'];
|
|
4
|
-
css?: CSSProperties;
|
|
5
|
-
}
|
|
6
|
-
export interface StyledRadioProps {
|
|
7
|
-
cursor: CSSObject['cursor'];
|
|
8
|
-
backgroundColor: string;
|
|
9
|
-
borderWidth?: string;
|
|
10
|
-
borderColor?: string;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=type.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../packages/components/Radio/src/BaseRadio/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE7D,MAAM,WAAW,cAAc;IAC9B,MAAM,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC7B,GAAG,CAAC,EAAE,aAAa,CAAA;CACnB;AACD,MAAM,WAAW,gBAAgB;IAChC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB"}
|