@true-engineering/true-react-common-ui-kit 4.0.0-alpha37 → 4.0.0-alpha38

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.
Files changed (46) hide show
  1. package/dist/components/FiltersPane/components/FilterInterval/FilterInterval.d.ts +3 -11
  2. package/dist/components/FiltersPane/types.d.ts +2 -0
  3. package/dist/components/FlexibleTable/FlexibleTable.styles.d.ts +1 -1
  4. package/dist/components/FloatDocActions/FloatDocActions.d.ts +6 -0
  5. package/dist/components/FloatDocActions/FloatDocActions.styles.d.ts +8 -0
  6. package/dist/components/FloatDocActions/components/DocActions/DocActions.d.ts +12 -0
  7. package/dist/components/FloatDocActions/components/DocActions/DocActions.styles.d.ts +6 -0
  8. package/dist/components/FloatDocActions/components/DocActions/constants.d.ts +1 -0
  9. package/dist/components/FloatDocActions/components/DocActions/index.d.ts +4 -0
  10. package/dist/components/FloatDocActions/components/DocActions/types.d.ts +2 -0
  11. package/dist/components/FloatDocActions/components/index.d.ts +1 -0
  12. package/dist/components/FloatDocActions/constants.d.ts +1 -0
  13. package/dist/components/FloatDocActions/index.d.ts +3 -0
  14. package/dist/components/IconButton/IconButton.styles.d.ts +1 -1
  15. package/dist/components/IconButton/constants.d.ts +1 -1
  16. package/dist/components/Input/InputBase.d.ts +1 -1
  17. package/dist/components/Modal/Modal.styles.d.ts +1 -1
  18. package/dist/components/Notification/Notification.styles.d.ts +1 -1
  19. package/dist/components/Toaster/Toaster.styles.d.ts +1 -1
  20. package/dist/components/index.d.ts +1 -0
  21. package/dist/theme/types.d.ts +2 -1
  22. package/dist/true-react-common-ui-kit.js +917 -593
  23. package/dist/true-react-common-ui-kit.js.map +1 -1
  24. package/dist/true-react-common-ui-kit.umd.cjs +917 -593
  25. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  26. package/package.json +1 -1
  27. package/src/components/FiltersPane/components/FilterInterval/FilterInterval.tsx +5 -17
  28. package/src/components/FiltersPane/types.ts +6 -0
  29. package/src/components/FlexibleTable/FlexibleTable.styles.ts +4 -2
  30. package/src/components/FlexibleTable/FlexibleTable.tsx +4 -1
  31. package/src/components/FloatDocActions/FloatDocActions.stories.tsx +117 -0
  32. package/src/components/FloatDocActions/FloatDocActions.styles.ts +12 -0
  33. package/src/components/FloatDocActions/FloatDocActions.tsx +34 -0
  34. package/src/components/FloatDocActions/components/DocActions/DocActions.styles.ts +29 -0
  35. package/src/components/FloatDocActions/components/DocActions/DocActions.tsx +43 -0
  36. package/src/components/FloatDocActions/components/DocActions/constants.ts +1 -0
  37. package/src/components/FloatDocActions/components/DocActions/index.ts +4 -0
  38. package/src/components/FloatDocActions/components/DocActions/types.ts +3 -0
  39. package/src/components/FloatDocActions/components/index.ts +1 -0
  40. package/src/components/FloatDocActions/constants.ts +1 -0
  41. package/src/components/FloatDocActions/index.ts +3 -0
  42. package/src/components/IconButton/IconButton.styles.ts +15 -13
  43. package/src/components/IconButton/constants.ts +1 -1
  44. package/src/components/Input/InputBase.tsx +3 -3
  45. package/src/components/index.ts +1 -0
  46. package/src/theme/types.ts +2 -0
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-alpha37",
3
+ "version": "4.0.0-alpha38",
4
4
  "description": "True Engineering React UI Kit with theming support",
5
5
  "author": "True Engineering (https://trueengineering.ru)",
6
6
  "keywords": [
@@ -6,7 +6,7 @@ import { ICommonProps } from '../../../../types';
6
6
  import { Button } from '../../../Button';
7
7
  import { NumberInput } from '../../../NumberInput';
8
8
  import { getLocale, sortValues } from '../../helpers';
9
- import { IFilterLocaleKey, IPartialFilterLocale } from '../../types';
9
+ import { IFilterLocaleKey, IFilterNumberInputProps, IPartialFilterLocale } from '../../types';
10
10
  import {
11
11
  clearButtonStyles,
12
12
  IFilterIntervalStyles,
@@ -22,16 +22,8 @@ export interface IFilterIntervalProps extends ICommonProps<IFilterIntervalStyles
22
22
  locale?: IPartialFilterLocale;
23
23
  withFieldNameInLabel?: boolean;
24
24
  canBeFloat?: boolean;
25
- fromInput?: {
26
- min?: number;
27
- max?: number;
28
- maxLength?: number;
29
- };
30
- toInput?: {
31
- min?: number;
32
- max?: number;
33
- maxLength?: number;
34
- };
25
+ fromInput?: IFilterNumberInputProps;
26
+ toInput?: IFilterNumberInputProps;
35
27
  }
36
28
 
37
29
  export const FilterInterval: FC<IFilterIntervalProps> = ({
@@ -100,11 +92,9 @@ export const FilterInterval: FC<IFilterIntervalProps> = ({
100
92
  }
101
93
  canBeFloat={canBeFloat}
102
94
  isClearable
103
- min={fromInput?.min}
104
- max={fromInput?.max}
105
- maxLength={fromInput?.maxLength}
106
95
  tweakStyles={tweakInputStyles}
107
96
  testId={getTestId(testId, 'start')}
97
+ {...fromInput}
108
98
  />
109
99
  {withFieldNameInLabel && (
110
100
  <div className={classes.autosize}>
@@ -123,11 +113,9 @@ export const FilterInterval: FC<IFilterIntervalProps> = ({
123
113
  }
124
114
  canBeFloat={canBeFloat}
125
115
  isClearable
126
- min={toInput?.min}
127
- max={toInput?.max}
128
- maxLength={toInput?.maxLength}
129
116
  tweakStyles={tweakInputStyles}
130
117
  testId={getTestId(testId, 'end')}
118
+ {...toInput}
131
119
  />
132
120
  {withFieldNameInLabel && (
133
121
  <div className={classes.autosize}>
@@ -2,6 +2,7 @@ import { FC, ReactNode } from 'react';
2
2
  import { ITestIdProps } from '../../types';
3
3
  import { IDatePickerProps } from '../DatePicker';
4
4
  import { IMultiSelectListValues } from '../MultiSelectList';
5
+ import { INumberInputProps } from '../NumberInput';
5
6
  import type {
6
7
  IFilterIntervalProps,
7
8
  IFilterMultiSelectProps,
@@ -175,3 +176,8 @@ export type IFilterWithDateDatePickerProps = Omit<
175
176
  IDatePickerProps,
176
177
  'onChange' | 'value' | 'locale' | 'months' | 'selectedDate' | 'tweakStyles'
177
178
  >;
179
+
180
+ export type IFilterNumberInputProps = Omit<
181
+ INumberInputProps,
182
+ 'onChange' | 'value' | 'label' | 'testId' | 'tweakStyles'
183
+ >;
@@ -1,10 +1,12 @@
1
1
  import { rgba } from '../../helpers';
2
- import { colors, ITweakStyles, createThemedStyles, animations } from '../../theme';
2
+ import { colors, ITweakStyles, createThemedStyles, animations, helpers } from '../../theme';
3
3
  import type { IFlexibleTableRowStyles } from './components';
4
4
 
5
5
  export const STICKY_SHADOW_PADDING = 12;
6
6
 
7
7
  export const useStyles = createThemedStyles('FlexibleTable', {
8
+ flexibleTableWrapper: {},
9
+
8
10
  root: {
9
11
  width: '100%',
10
12
  position: 'relative',
@@ -13,7 +15,7 @@ export const useStyles = createThemedStyles('FlexibleTable', {
13
15
  },
14
16
 
15
17
  scroll: {
16
- overflow: 'auto',
18
+ ...helpers.withScrollBar,
17
19
  /*
18
20
  Чтобы сделать таблицу на всю высоту проставьте
19
21
  height у родителя таблицы у себя в проекте.
@@ -201,7 +201,10 @@ export function FlexibleTable<
201
201
  const Table = TableRenders[renderMode];
202
202
 
203
203
  return (
204
- <div ref={ref} className={clsx({ [classes.scroll]: isHorizontallyScrollable })}>
204
+ <div
205
+ ref={ref}
206
+ className={clsx(classes.flexibleTableWrapper, { [classes.scroll]: isHorizontallyScrollable })}
207
+ >
205
208
  <Table.Root className={classes.root} {...addDataAttributes({ ...data, isLoading }, testId)}>
206
209
  {shouldRenderHeader && (
207
210
  <Table.Head className={classes.head}>
@@ -0,0 +1,117 @@
1
+ import { FC, useState } from 'react';
2
+ import { isNotEmpty } from '@true-engineering/true-react-platform-helpers';
3
+ import type { Meta, StoryObj } from '@storybook/react';
4
+ import { Button } from '../Button';
5
+ import { Checkbox, ICheckboxProps } from '../Checkbox';
6
+ import { NewMoreMenu } from '../NewMoreMenu';
7
+ import { TextButton } from '../TextButton';
8
+ import {
9
+ FloatDocActions as FloatDocActionsComponent,
10
+ IFloatDocActionsProps,
11
+ } from './FloatDocActions';
12
+ import { DOC_ACTIONS_VIEWS } from './components';
13
+
14
+ const DATA_LENGTH = 300;
15
+
16
+ const Actions: FC = () => (
17
+ <div style={{ display: 'flex', alignItems: 'center', gap: '12px' }}>
18
+ <TextButton icon="trash-can" view="custom">
19
+ Удалить
20
+ </TextButton>
21
+ <TextButton icon="pencil">Редактировать</TextButton>
22
+ <Button view="secondary">Отказать</Button>
23
+ <Button>Одобрить</Button>
24
+ <NewMoreMenu items={[]} />
25
+ </div>
26
+ );
27
+
28
+ const DocActionsWithData: FC<IFloatDocActionsProps> = (props) => {
29
+ const [isOpen, setIsOpen] = useState(false);
30
+ const [state, setState] = useState<Set<number>>(new Set());
31
+
32
+ const handleToggle = () => {
33
+ setIsOpen((prevState) => !prevState);
34
+ };
35
+
36
+ const handleSelectRow: ICheckboxProps<number>['onSelect'] = ({ value }) => {
37
+ if (isNotEmpty(value)) {
38
+ setState((prev) => {
39
+ const newSet = new Set(prev);
40
+ if (newSet.has(value)) {
41
+ newSet.delete(value);
42
+ } else {
43
+ newSet.add(value);
44
+ }
45
+ return newSet;
46
+ });
47
+ }
48
+ };
49
+
50
+ const handleSelectAll: ICheckboxProps<never>['onSelect'] = ({ isSelected }) => {
51
+ console.log('isSelected:', isSelected);
52
+
53
+ setState(
54
+ isSelected ? new Set<number>(Array.from({ length: DATA_LENGTH }, (_, i) => i)) : new Set(),
55
+ );
56
+ };
57
+
58
+ const isAllRowsSelected = state.size === DATA_LENGTH;
59
+ const title = props.title + ': ' + state.size;
60
+
61
+ return (
62
+ <div style={{ display: 'flex', gap: '50px' }}>
63
+ <div style={{ position: 'sticky', top: '50px', height: '50px' }}>
64
+ <Button onClick={handleToggle}>Toggle</Button>
65
+ </div>
66
+ <div style={{ width: '1000px' }}>
67
+ <table style={{ width: '100%', borderCollapse: 'collapse' }}>
68
+ {Array.from({ length: DATA_LENGTH }, (_, index) => (
69
+ <tr key={index} style={{ border: '1px solid skyblue' }}>
70
+ <td style={{ padding: '5px', display: 'flex', gap: '12px' }}>
71
+ {isOpen && (
72
+ <Checkbox value={index} isChecked={state.has(index)} onSelect={handleSelectRow} />
73
+ )}
74
+ <div>Строка {index + 1}</div>
75
+ </td>
76
+ </tr>
77
+ ))}
78
+ </table>
79
+ <div style={{ position: 'sticky', bottom: '12px', left: '8px', right: '18px' }}>
80
+ <FloatDocActionsComponent
81
+ {...props}
82
+ title={title}
83
+ isOpen={isOpen}
84
+ isChecked={isAllRowsSelected}
85
+ isSemiChecked={!isAllRowsSelected && state.size !== 0}
86
+ onSelect={handleSelectAll}
87
+ >
88
+ <Actions />
89
+ </FloatDocActionsComponent>
90
+ </div>
91
+ </div>
92
+ </div>
93
+ );
94
+ };
95
+
96
+ const meta: Meta<typeof DocActionsWithData> = {
97
+ title: 'Table/FloatDocActions',
98
+ component: DocActionsWithData,
99
+ args: {
100
+ title: 'Выбрано',
101
+ view: 'neutral',
102
+ },
103
+ argTypes: {
104
+ view: { options: DOC_ACTIONS_VIEWS, control: 'inline-radio' },
105
+ },
106
+ parameters: {
107
+ controls: {
108
+ exclude: ['actions'],
109
+ },
110
+ },
111
+ };
112
+
113
+ export default meta;
114
+
115
+ type Story = StoryObj<typeof FloatDocActionsComponent>;
116
+
117
+ export const Default: Story = {};
@@ -0,0 +1,12 @@
1
+ import { createUseStyles } from 'react-jss';
2
+ import { animations, ITweakStyles } from '../../theme';
3
+ import { IDocActionsStyles } from './components';
4
+
5
+ export const useStyles = createUseStyles({
6
+ ...animations.slideUp,
7
+ });
8
+
9
+ export type IFloatDocActionsStyles = ITweakStyles<
10
+ typeof useStyles,
11
+ { tweakDocActions: IDocActionsStyles }
12
+ >;
@@ -0,0 +1,34 @@
1
+ import { FC } from 'react';
2
+ import { CSSTransition } from 'react-transition-group';
3
+ import { DocActions, IDocActionsProps } from './components';
4
+ import { DEFAULT_TIMEOUT } from './constants';
5
+ import { useStyles } from './FloatDocActions.styles';
6
+
7
+ export interface IFloatDocActionsProps extends IDocActionsProps {
8
+ isOpen: boolean;
9
+ }
10
+
11
+ export const FloatDocActions: FC<IFloatDocActionsProps> = ({
12
+ isOpen,
13
+ children,
14
+ ...docActionsProps
15
+ }) => {
16
+ const classes = useStyles();
17
+
18
+ return (
19
+ <CSSTransition
20
+ in={isOpen}
21
+ timeout={DEFAULT_TIMEOUT}
22
+ mountOnEnter
23
+ unmountOnExit
24
+ classNames={{
25
+ enter: classes['slide-up-enter'],
26
+ enterActive: classes['slide-up-enter-active'],
27
+ exit: classes['slide-up-exit'],
28
+ exitActive: classes['slide-up-exit-active'],
29
+ }}
30
+ >
31
+ <DocActions {...docActionsProps}>{children}</DocActions>
32
+ </CSSTransition>
33
+ );
34
+ };
@@ -0,0 +1,29 @@
1
+ import { createThemedStyles, ITweakStyles } from '../../../../theme';
2
+ import { ICheckboxStyles } from '../../../Checkbox';
3
+
4
+ export const useStyles = createThemedStyles('DocActions', {
5
+ docActions: {
6
+ display: 'grid',
7
+ alignItems: 'center',
8
+ gridTemplateColumns: 'max-content 1fr',
9
+ },
10
+
11
+ neutral: {},
12
+
13
+ inverse: {},
14
+
15
+ counterWrapper: {},
16
+
17
+ title: {},
18
+
19
+ actionsWrapper: {
20
+ justifySelf: 'end',
21
+ },
22
+ });
23
+
24
+ export type IDocActionsStyles = ITweakStyles<
25
+ typeof useStyles,
26
+ {
27
+ tweakCheckbox: ICheckboxStyles;
28
+ }
29
+ >;
@@ -0,0 +1,43 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import clsx from 'clsx';
3
+ import { useTweakStyles } from '../../../../hooks';
4
+ import { ICommonProps } from '../../../../types';
5
+ import { Checkbox, ICheckboxProps } from '../../../Checkbox';
6
+ import { IDocActionsView } from './types';
7
+ import { IDocActionsStyles, useStyles } from './DocActions.styles';
8
+
9
+ export interface IDocActionsProps
10
+ extends Omit<ICheckboxProps<never>, 'tweakStyles'>,
11
+ ICommonProps<IDocActionsStyles> {
12
+ title: string;
13
+ /** @default 'neutral' */
14
+ view?: IDocActionsView;
15
+ children: ReactNode;
16
+ }
17
+
18
+ export const DocActions: FC<IDocActionsProps> = ({
19
+ title,
20
+ view = 'neutral',
21
+ children,
22
+ tweakStyles,
23
+ ...checkBoxProps
24
+ }) => {
25
+ const classes = useStyles({ theme: tweakStyles });
26
+
27
+ const tweakCheckboxStyles = useTweakStyles({
28
+ tweakStyles,
29
+ className: 'tweakCheckbox',
30
+ currentComponentName: 'DocActions',
31
+ });
32
+
33
+ return (
34
+ <div className={clsx(classes.docActions, classes[view])}>
35
+ <div className={classes.counterWrapper}>
36
+ <Checkbox tweakStyles={tweakCheckboxStyles} {...checkBoxProps}>
37
+ <span className={classes.title}>{title}</span>
38
+ </Checkbox>
39
+ </div>
40
+ <div className={classes.actionsWrapper}>{children}</div>
41
+ </div>
42
+ );
43
+ };
@@ -0,0 +1 @@
1
+ export const DOC_ACTIONS_VIEWS = ['neutral', 'inverse'] as const;
@@ -0,0 +1,4 @@
1
+ export * from './DocActions';
2
+ export * from './types';
3
+ export * from './constants';
4
+ export type { IDocActionsStyles } from './DocActions.styles';
@@ -0,0 +1,3 @@
1
+ import { DOC_ACTIONS_VIEWS } from './constants';
2
+
3
+ export type IDocActionsView = (typeof DOC_ACTIONS_VIEWS)[number];
@@ -0,0 +1 @@
1
+ export * from './DocActions';
@@ -0,0 +1 @@
1
+ export const DEFAULT_TIMEOUT = 150;
@@ -0,0 +1,3 @@
1
+ export * from './FloatDocActions';
2
+ export * from './components';
3
+ export type { IFloatDocActionsStyles } from './FloatDocActions.styles';
@@ -1,9 +1,5 @@
1
1
  import { ITweakStyles, animations, createThemedStyles } from '../../theme';
2
2
 
3
- const BUTTON_SIZE_S = 24;
4
- const BUTTON_SIZE_M = 32;
5
- const ICON_SIZE = 20;
6
-
7
3
  export const useStyles = createThemedStyles('IconButton', {
8
4
  root: {
9
5
  display: 'flex',
@@ -13,7 +9,7 @@ export const useStyles = createThemedStyles('IconButton', {
13
9
  outline: 'none',
14
10
  boxSizing: 'border-box',
15
11
  transition: animations.defaultTransition,
16
- transitionProperty: 'background-color, color, border-color',
12
+ transitionProperty: 'background-color, color, border-color, opacity, visibility',
17
13
  border: 'none',
18
14
  position: 'relative',
19
15
  boxShadow: 'none',
@@ -29,6 +25,10 @@ export const useStyles = createThemedStyles('IconButton', {
29
25
  '&:active': {
30
26
  extend: 'active',
31
27
  },
28
+
29
+ width: 'var(--icon-button-size)',
30
+ height: 'var(--icon-button-size)',
31
+ '--icon-button-icon-size': '20px',
32
32
  },
33
33
 
34
34
  'cancel-light': {},
@@ -55,8 +55,8 @@ export const useStyles = createThemedStyles('IconButton', {
55
55
  icon: {
56
56
  display: 'flex',
57
57
  alignItems: 'center',
58
- width: ICON_SIZE,
59
- height: ICON_SIZE,
58
+ width: 'var(--icon-button-icon-size)',
59
+ height: 'var(--icon-button-icon-size)',
60
60
  },
61
61
 
62
62
  loader: {
@@ -66,18 +66,20 @@ export const useStyles = createThemedStyles('IconButton', {
66
66
  top: '50%',
67
67
  transform: 'translate(-50%, -50%)',
68
68
 
69
- width: ICON_SIZE,
70
- height: ICON_SIZE,
69
+ width: 'var(--icon-button-icon-size)',
70
+ height: 'var(--icon-button-icon-size)',
71
71
  },
72
72
 
73
73
  s: {
74
- width: BUTTON_SIZE_S,
75
- height: BUTTON_SIZE_S,
74
+ '--icon-button-size': '24px',
76
75
  },
77
76
 
78
77
  m: {
79
- width: BUTTON_SIZE_M,
80
- height: BUTTON_SIZE_M,
78
+ '--icon-button-size': '32px',
79
+ },
80
+
81
+ l: {
82
+ '--icon-button-size': '40px',
81
83
  },
82
84
  });
83
85
 
@@ -1,3 +1,3 @@
1
- export const ICON_BUTTON_SIZES = ['s', 'm'] as const;
1
+ export const ICON_BUTTON_SIZES = ['s', 'm', 'l'] as const;
2
2
 
3
3
  export const ICON_BUTTON_VIEWS = ['cancel', 'cancel-light', 'main', 'custom'] as const;
@@ -58,7 +58,7 @@ export interface IInputBaseProps
58
58
  isAutoSized?: boolean;
59
59
  /** @default false */
60
60
  shouldAlwaysShowPlaceholder?: boolean;
61
- onChange: (value: string, event: IChangeInputEvent) => void;
61
+ onChange: (value: string, event: IChangeInputEvent, eventType: 'change' | 'clear') => void;
62
62
  }
63
63
 
64
64
  export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
@@ -133,7 +133,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
133
133
  isStringNotEmpty(placeholder);
134
134
 
135
135
  const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
136
- onChange(event.currentTarget.value, event);
136
+ onChange(event.currentTarget.value, event, 'change');
137
137
  };
138
138
 
139
139
  const handleFocus = (event: FocusEvent<HTMLInputElement>) => {
@@ -149,7 +149,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
149
149
  // для SmartInput нужен event, иначе onChange не вызовется
150
150
  const handleInputClear = async (event: IClickHandlerEvent) => {
151
151
  // await не убирать (важно для порядка выполнения (сначала onChange, затем focus)
152
- await onChange('', event);
152
+ await onChange('', event, 'clear');
153
153
  inputRef.current?.focus();
154
154
  };
155
155
 
@@ -13,6 +13,7 @@ export * from './FileItem';
13
13
  export * from './FiltersPane';
14
14
  export * from './Flag';
15
15
  export * from './FlexibleTable';
16
+ export * from './FloatDocActions';
16
17
  export * from './Icon';
17
18
  export * from './IconButton';
18
19
  export * from './IncrementInput';
@@ -12,6 +12,7 @@ import type {
12
12
  IDatePickerHeaderStyles,
13
13
  IDatePickerStyles,
14
14
  IDescriptionStyles,
15
+ IDocActionsStyles,
15
16
  IDotsPreloaderStyles,
16
17
  IFileInputStyles,
17
18
  IFileItemStyles,
@@ -92,6 +93,7 @@ export interface IComponentStyles {
92
93
  DatePicker: IDatePickerStyles;
93
94
  DatePickerHeader: IDatePickerHeaderStyles;
94
95
  Description: IDescriptionStyles;
96
+ DocActions: IDocActionsStyles;
95
97
  DotsPreloader: IDotsPreloaderStyles;
96
98
  SvgPreloader: ISvgPreloaderStyles;
97
99
  FileInput: IFileInputStyles;