@true-engineering/true-react-common-ui-kit 4.0.0-alpha42 → 4.0.0-alpha43

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@true-engineering/true-react-common-ui-kit",
3
- "version": "4.0.0-alpha42",
3
+ "version": "4.0.0-alpha43",
4
4
  "description": "True Engineering React UI Kit with theming support",
5
5
  "author": "True Engineering (https://trueengineering.ru)",
6
6
  "keywords": [
@@ -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 { addDataTestId, isReactNodeNotEmpty } from '@true-engineering/true-react-platform-helpers';
4
- import { addDataAttributes } from '../../helpers';
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, isDisabled && classes.isDisabled)}
42
+ className={clsx(classes.label, isNotEmpty(size) && classes[size], {
43
+ [classes.isDisabled]: isDisabled,
44
+ })}
37
45
  htmlFor={`${groupName}--${value}`}
38
- {...addDataTestId(testId)}
39
- {...addDataAttributes(data)}
46
+ {...addDataAttributes(data, testId)}
40
47
  >
41
48
  <input
42
49
  id={`${groupName}--${value}`}
@@ -0,0 +1,4 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
2
+ export interface IRadioButtonSizes {}
3
+
4
+ export type IRadioButtonSize = keyof IRadioButtonSizes;
@@ -10,7 +10,7 @@ export default {
10
10
  component: TextButton,
11
11
  args: {
12
12
  children: 'Text Button',
13
- icon: 'chevron-right-small',
13
+ icon: 'calendar',
14
14
  size: 'l',
15
15
  view: 'primary',
16
16
  isBold: false,