@true-engineering/true-react-common-ui-kit 4.0.0-alpha42 → 4.0.0-alpha44
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/dist/components/Checkbox/index.d.ts +1 -0
- package/dist/components/RadioButton/RadioButton.d.ts +3 -1
- package/dist/components/RadioButton/RadioButton.styles.d.ts +2 -1
- package/dist/components/RadioButton/index.d.ts +1 -0
- package/dist/components/RadioButton/types.d.ts +3 -0
- package/dist/true-react-common-ui-kit.js +3 -3
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +3 -3
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/Checkbox/index.ts +1 -0
- package/src/components/RadioButton/RadioButton.stories.tsx +13 -0
- package/src/components/RadioButton/RadioButton.styles.ts +2 -1
- package/src/components/RadioButton/RadioButton.tsx +12 -5
- package/src/components/RadioButton/index.ts +1 -0
- package/src/components/RadioButton/types.ts +4 -0
- package/src/components/TextButton/TextButton.stories.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { ComponentStory } from '@storybook/react';
|
|
3
|
+
import { IExtendableProps } from '../../types';
|
|
3
4
|
import { RadioButton } from './RadioButton';
|
|
4
5
|
|
|
6
|
+
const RADIO_SIZES = [undefined, 'micro'] as const;
|
|
7
|
+
|
|
5
8
|
export default {
|
|
6
9
|
title: 'Controls/RadioButton',
|
|
7
10
|
component: RadioButton,
|
|
8
11
|
};
|
|
9
12
|
|
|
13
|
+
declare module './types' {
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
15
|
+
export interface IRadioButtonSizes extends IExtendableProps<typeof RADIO_SIZES> {}
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
const options = ['one', 'two', 'three'];
|
|
11
19
|
|
|
12
20
|
const Template: ComponentStory<typeof RadioButton> = (args) => {
|
|
@@ -34,11 +42,16 @@ export const Default = Template.bind({});
|
|
|
34
42
|
|
|
35
43
|
Default.args = {
|
|
36
44
|
children: 'Label',
|
|
45
|
+
size: undefined,
|
|
37
46
|
// isChecked: false,
|
|
38
47
|
isInvalid: false,
|
|
39
48
|
isDisabled: false,
|
|
40
49
|
};
|
|
41
50
|
|
|
51
|
+
Default.argTypes = {
|
|
52
|
+
size: { options: [undefined, ...RADIO_SIZES], control: 'inline-radio' },
|
|
53
|
+
};
|
|
54
|
+
|
|
42
55
|
Default.parameters = {
|
|
43
56
|
controls: {
|
|
44
57
|
exclude: ['data', 'value', 'groupName', 'isChecked', 'onChange'],
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ITweakStyles, createThemedStyles } from '../../theme';
|
|
2
|
+
import { IRadioButtonSizes } from './types';
|
|
2
3
|
|
|
3
4
|
export const useStyles = createThemedStyles('RadioButton', {
|
|
4
5
|
input: {
|
|
@@ -34,4 +35,4 @@ export const useStyles = createThemedStyles('RadioButton', {
|
|
|
34
35
|
isInvalid: {},
|
|
35
36
|
});
|
|
36
37
|
|
|
37
|
-
export type IRadioButtonStyles = ITweakStyles<typeof useStyles>;
|
|
38
|
+
export type IRadioButtonStyles = ITweakStyles<typeof useStyles, IRadioButtonSizes>;
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
isNotEmpty,
|
|
5
|
+
isReactNodeNotEmpty,
|
|
6
|
+
addDataAttributes,
|
|
7
|
+
} from '@true-engineering/true-react-platform-helpers';
|
|
5
8
|
import { ICommonProps } from '../../types';
|
|
9
|
+
import { IRadioButtonSize } from './types';
|
|
6
10
|
import { useStyles, IRadioButtonStyles } from './RadioButton.styles';
|
|
7
11
|
|
|
8
12
|
export interface IRadioButtonProps<Value extends string> extends ICommonProps<IRadioButtonStyles> {
|
|
9
13
|
children?: ReactNode;
|
|
10
14
|
value: Value;
|
|
11
15
|
groupName: string;
|
|
16
|
+
size?: IRadioButtonSize;
|
|
12
17
|
isChecked?: boolean;
|
|
13
18
|
/** @default false */
|
|
14
19
|
isDisabled?: boolean;
|
|
@@ -21,6 +26,7 @@ export function RadioButton<Value extends string>({
|
|
|
21
26
|
children,
|
|
22
27
|
value,
|
|
23
28
|
groupName,
|
|
29
|
+
size,
|
|
24
30
|
isChecked,
|
|
25
31
|
isDisabled = false,
|
|
26
32
|
isInvalid = false,
|
|
@@ -33,10 +39,11 @@ export function RadioButton<Value extends string>({
|
|
|
33
39
|
|
|
34
40
|
return (
|
|
35
41
|
<label
|
|
36
|
-
className={clsx(classes.label,
|
|
42
|
+
className={clsx(classes.label, isNotEmpty(size) && classes[size], {
|
|
43
|
+
[classes.isDisabled]: isDisabled,
|
|
44
|
+
})}
|
|
37
45
|
htmlFor={`${groupName}--${value}`}
|
|
38
|
-
{...
|
|
39
|
-
{...addDataAttributes(data)}
|
|
46
|
+
{...addDataAttributes(data, testId)}
|
|
40
47
|
>
|
|
41
48
|
<input
|
|
42
49
|
id={`${groupName}--${value}`}
|