@true-engineering/true-react-common-ui-kit 4.0.0-alpha40 → 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-alpha40",
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,7 +1,10 @@
1
1
  import { useState, FC } from 'react';
2
2
  import type { Meta, StoryObj } from '@storybook/react';
3
+ import { IExtendableProps } from '../../types';
3
4
  import { Checkbox as CheckboxComponent, ICheckboxProps } from './Checkbox';
4
5
 
6
+ const CHECKBOX_SIZES = ['micro'] as const;
7
+
5
8
  const CheckboxComponentWithData: FC<ICheckboxProps<string>> = (props) => {
6
9
  const [isChecked, setIsChecked] = useState(false);
7
10
  const [isSemiChecked, setIsSemiChecked] = useState(false);
@@ -23,6 +26,7 @@ const CheckboxComponentWithData: FC<ICheckboxProps<string>> = (props) => {
23
26
  value={undefined}
24
27
  isChecked={isSemiChecked}
25
28
  onSelect={({ isSelected }) => setIsSemiChecked(isSelected)}
29
+ {...props}
26
30
  >
27
31
  Is Semi Checked
28
32
  </CheckboxComponent>
@@ -36,6 +40,7 @@ const meta: Meta<typeof CheckboxComponentWithData> = {
36
40
  args: {
37
41
  value: 'value',
38
42
  labelPosition: 'right',
43
+ size: undefined,
39
44
  isInvalid: false,
40
45
  isDisabled: false,
41
46
  isReadonly: false,
@@ -45,8 +50,16 @@ const meta: Meta<typeof CheckboxComponentWithData> = {
45
50
  exclude: ['data', 'tweakStyles', 'testId', 'onSelect'],
46
51
  },
47
52
  },
53
+ argTypes: {
54
+ size: { options: [undefined, ...CHECKBOX_SIZES], control: 'inline-radio' },
55
+ },
48
56
  };
49
57
 
58
+ declare module './types' {
59
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
60
+ export interface ICheckboxSizes extends IExtendableProps<typeof CHECKBOX_SIZES> {}
61
+ }
62
+
50
63
  export default meta;
51
64
 
52
65
  type Story = StoryObj<typeof CheckboxComponent>;
@@ -1,4 +1,5 @@
1
1
  import { createThemedStyles, ITweakStyles } from '../../theme';
2
+ import { ICheckboxSizes } from './types';
2
3
 
3
4
  export const useStyles = createThemedStyles('Checkbox', {
4
5
  root: {
@@ -46,4 +47,4 @@ export const useStyles = createThemedStyles('Checkbox', {
46
47
  },
47
48
  });
48
49
 
49
- export type ICheckboxStyles = ITweakStyles<typeof useStyles>;
50
+ export type ICheckboxStyles = ITweakStyles<typeof useStyles, ICheckboxSizes>;
@@ -1,18 +1,20 @@
1
1
  import { ReactNode, ChangeEvent, KeyboardEvent } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import {
4
- addDataTestId,
5
4
  getSelectKeyHandler,
5
+ isNotEmpty,
6
6
  isReactNodeNotEmpty,
7
+ addDataAttributes,
7
8
  } from '@true-engineering/true-react-platform-helpers';
8
- import { addDataAttributes } from '../../helpers';
9
9
  import { ICommonProps } from '../../types';
10
10
  import { Icon } from '../Icon';
11
+ import { ICheckboxSize } from './types';
11
12
  import { useStyles, ICheckboxStyles } from './Checkbox.styles';
12
13
 
13
14
  export interface ICheckboxProps<V> extends ICommonProps<ICheckboxStyles> {
14
15
  value?: V;
15
16
  children?: ReactNode;
17
+ size?: ICheckboxSize;
16
18
  /** @default false */
17
19
  isChecked?: boolean;
18
20
  /** @default false */
@@ -34,6 +36,7 @@ export interface ICheckboxProps<V> extends ICommonProps<ICheckboxStyles> {
34
36
  export function Checkbox<V>({
35
37
  value,
36
38
  children,
39
+ size,
37
40
  isChecked = false,
38
41
  isSemiChecked = false,
39
42
  isInvalid = false,
@@ -55,14 +58,13 @@ export function Checkbox<V>({
55
58
 
56
59
  return (
57
60
  <label
58
- className={clsx(classes.root, {
61
+ className={clsx(classes.root, isNotEmpty(size) && classes[size], {
59
62
  [classes.checked]: isSelected,
60
63
  [classes.invalid]: isInvalid,
61
64
  [classes.disabled]: isDisabled,
62
65
  [classes.labelPositionLeft]: labelPosition === 'left',
63
66
  })}
64
- {...addDataTestId(testId)}
65
- {...addDataAttributes(data)}
67
+ {...addDataAttributes(data, testId)}
66
68
  >
67
69
  <input
68
70
  className={classes.input}
@@ -0,0 +1,4 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
2
+ export interface ICheckboxSizes {}
3
+
4
+ export type ICheckboxSize = keyof ICheckboxSizes;
@@ -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,