@true-engineering/true-react-common-ui-kit 4.0.0-alpha3 → 4.0.0-alpha30
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 +11 -607
- package/dist/components/Button/Button.styles.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.styles.d.ts +1 -1
- package/dist/components/ControlWrapper/ControlWrapper.d.ts +4 -2
- package/dist/components/ControlWrapper/ControlWrapper.styles.d.ts +2 -1
- package/dist/components/ControlWrapper/helpers.d.ts +4 -0
- package/dist/components/ControlWrapper/index.d.ts +2 -0
- package/dist/components/ControlWrapper/types.d.ts +12 -0
- package/dist/components/DatePicker/DatePicker.d.ts +3 -3
- package/dist/components/DatePicker/DatePicker.styles.d.ts +1 -1
- package/dist/components/DatePicker/components/PopperContainer/PopperContainer.d.ts +2 -4
- package/dist/components/DatePicker/helpers.d.ts +3 -0
- package/dist/components/DatePicker/types.d.ts +5 -3
- package/dist/components/FiltersPane/FiltersPane.d.ts +7 -2
- package/dist/components/FiltersPane/components/Filter/Filter.d.ts +2 -2
- package/dist/components/FiltersPane/components/Filter/helpers.d.ts +4 -0
- package/dist/components/FiltersPane/components/FilterInterval/FilterInterval.styles.d.ts +1 -1
- package/dist/components/FiltersPane/components/FilterSelect/FilterSelect.styles.d.ts +1 -1
- package/dist/components/FiltersPane/components/FilterValueView/FilterValueView.d.ts +3 -1
- package/dist/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.d.ts +2 -2
- package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.d.ts +2 -2
- package/dist/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.styles.d.ts +1 -1
- package/dist/components/FiltersPane/types.d.ts +16 -5
- package/dist/components/Flag/customFlags/customFlags.d.ts +10 -0
- package/dist/components/Flag/customFlags/index.d.ts +1 -0
- package/dist/components/FlexibleTable/FlexibleTable.d.ts +4 -2
- package/dist/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.d.ts +4 -3
- package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +6 -6
- package/dist/components/FlexibleTable/constants.d.ts +18 -2
- package/dist/components/FlexibleTable/types.d.ts +20 -12
- package/dist/components/Icon/icons-list.d.ts +1 -1
- package/dist/components/IconButton/IconButton.styles.d.ts +1 -1
- package/dist/components/IncrementInput/IncrementInput.styles.d.ts +1 -3
- package/dist/components/Input/Input.d.ts +3 -2
- package/dist/components/Input/InputBase.d.ts +2 -2
- package/dist/components/List/List.d.ts +1 -1
- package/dist/components/List/index.d.ts +2 -1
- package/dist/components/List/types.d.ts +4 -0
- package/dist/components/Modal/Modal.styles.d.ts +1 -1
- package/dist/components/Notification/Notification.styles.d.ts +1 -1
- package/dist/components/ScrollIntoViewIfNeeded/ScrollIntoViewIfNeeded.d.ts +1 -1
- package/dist/components/SearchInput/SearchInput.d.ts +2 -2
- package/dist/components/Select/Select.d.ts +5 -3
- package/dist/components/Select/Select.styles.d.ts +5 -5
- package/dist/components/Select/components/SelectListItem/SelectListItem.d.ts +2 -1
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Status/Status.styles.d.ts +3 -2
- package/dist/components/Status/constants.d.ts +0 -1
- package/dist/components/Status/index.d.ts +1 -0
- package/dist/components/Status/types.d.ts +5 -2
- package/dist/components/TextArea/TextArea.d.ts +4 -5
- package/dist/components/TextArea/TextArea.styles.d.ts +5 -4
- package/dist/components/TextArea/index.d.ts +1 -1
- package/dist/components/TextArea/types.d.ts +4 -2
- package/dist/components/TextButton/TextButton.styles.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.styles.d.ts +1 -1
- package/dist/components/WithMessages/WithMessages.styles.d.ts +1 -1
- package/dist/components/WithPopup/WithPopup.d.ts +11 -3
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/use-intersection-ref.d.ts +8 -0
- package/dist/hooks/use-merge.d.ts +1 -0
- package/dist/hooks/use-mixed-styles.d.ts +3 -1
- package/dist/hooks/use-tweak-styles.d.ts +5 -5
- package/dist/style.css +78 -142
- package/dist/theme/Provider.d.ts +6 -3
- package/dist/theme/create-themed-styles.d.ts +2 -0
- package/dist/theme/helpers.d.ts +9 -3
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/true-jss/ThemedStylesManager.d.ts +18 -0
- package/dist/theme/true-jss/TweakStylesManager.d.ts +34 -0
- package/dist/theme/true-jss/index.d.ts +2 -0
- package/dist/theme/true-jss/jss-context.d.ts +9 -0
- package/dist/theme/types.d.ts +5 -3
- package/dist/true-react-common-ui-kit.js +7593 -6483
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +7618 -6509
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/dist/types.d.ts +10 -3
- package/package.json +4 -5
- package/src/components/ControlWrapper/ControlWrapper.stories.tsx +8 -3
- package/src/components/ControlWrapper/ControlWrapper.styles.ts +7 -6
- package/src/components/ControlWrapper/ControlWrapper.tsx +31 -20
- package/src/components/ControlWrapper/helpers.ts +11 -0
- package/src/components/ControlWrapper/index.ts +2 -0
- package/src/components/ControlWrapper/types.ts +16 -0
- package/src/components/DateInput/DateInput.stories.tsx +0 -1
- package/src/components/DatePicker/DatePicker.stories.tsx +24 -11
- package/src/components/DatePicker/DatePicker.styles.ts +3 -1
- package/src/components/DatePicker/DatePicker.tsx +18 -10
- package/src/components/DatePicker/components/PopperContainer/PopperContainer.tsx +4 -4
- package/src/components/DatePicker/helpers.ts +13 -1
- package/src/components/DatePicker/types.ts +9 -4
- package/src/components/FiltersPane/FiltersPane.stories.tsx +4 -2
- package/src/components/FiltersPane/FiltersPane.tsx +28 -19
- package/src/components/FiltersPane/components/Filter/Filter.tsx +36 -30
- package/src/components/FiltersPane/components/Filter/helpers.ts +18 -0
- package/src/components/FiltersPane/components/FilterSelect/FilterSelect.tsx +22 -23
- package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +27 -22
- package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.ts +2 -1
- package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +3 -4
- package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +4 -3
- package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +14 -10
- package/src/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.styles.ts +5 -0
- package/src/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.tsx +16 -19
- package/src/components/FiltersPane/types.ts +24 -5
- package/src/components/Flag/Flag.stories.tsx +2 -1
- package/src/components/Flag/Flag.styles.ts +4 -0
- package/src/components/Flag/Flag.tsx +23 -9
- package/src/components/Flag/customFlags/AB.svg +1 -0
- package/src/components/Flag/customFlags/OS.svg +1 -0
- package/src/components/Flag/customFlags/augment.d.ts +1 -0
- package/src/components/Flag/customFlags/customFlags.ts +13 -0
- package/src/components/Flag/customFlags/index.ts +1 -0
- package/src/components/FlexibleTable/FlexibleTable.tsx +40 -63
- package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.tsx +8 -5
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +13 -12
- package/src/components/FlexibleTable/constants.ts +6 -3
- package/src/components/FlexibleTable/types.ts +20 -16
- package/src/components/IncrementInput/IncrementInput.stories.tsx +2 -0
- package/src/components/IncrementInput/IncrementInput.styles.ts +31 -39
- package/src/components/IncrementInput/IncrementInput.tsx +28 -25
- package/src/components/Input/Input.stories.tsx +1 -6
- package/src/components/Input/Input.tsx +5 -3
- package/src/components/Input/InputBase.tsx +27 -25
- package/src/components/List/List.tsx +5 -2
- package/src/components/List/index.ts +2 -1
- package/src/components/List/types.ts +5 -0
- package/src/components/MultiSelectList/MultiSelectList.tsx +15 -11
- package/src/components/NumberInput/NumberInput.stories.tsx +5 -1
- package/src/components/PhoneInput/PhoneInput.stories.tsx +2 -1
- package/src/components/PhoneInput/PhoneInput.tsx +5 -2
- package/src/components/SearchInput/SearchInput.tsx +20 -29
- package/src/components/Select/CustomSelect.stories.tsx +1 -0
- package/src/components/Select/MultiSelect.stories.tsx +5 -0
- package/src/components/Select/Select.stories.tsx +6 -0
- package/src/components/Select/Select.styles.ts +5 -40
- package/src/components/Select/Select.tsx +36 -22
- package/src/components/Select/components/SelectList/SelectList.tsx +4 -2
- package/src/components/Select/components/SelectListItem/SelectListItem.tsx +5 -2
- package/src/components/Select/index.ts +1 -1
- package/src/components/Status/Status.stories.tsx +54 -1
- package/src/components/Status/Status.styles.ts +2 -37
- package/src/components/Status/constants.ts +0 -10
- package/src/components/Status/index.ts +1 -1
- package/src/components/Status/types.ts +7 -3
- package/src/components/TextArea/TextArea.stories.tsx +15 -1
- package/src/components/TextArea/TextArea.styles.ts +15 -8
- package/src/components/TextArea/TextArea.tsx +96 -62
- package/src/components/TextArea/index.ts +1 -1
- package/src/components/TextArea/types.ts +5 -5
- package/src/components/TextButton/TextButton.styles.ts +1 -0
- package/src/components/Tooltip/Tooltip.styles.ts +2 -0
- package/src/components/Tooltip/Tooltip.tsx +1 -1
- package/src/components/WithMessages/WithMessages.stories.tsx +1 -1
- package/src/components/WithPopup/WithPopup.tsx +36 -15
- package/src/constants/phone-info.ts +20 -33
- package/src/helpers/phone.ts +19 -15
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-intersection-ref.ts +30 -0
- package/src/hooks/use-merge.ts +8 -0
- package/src/hooks/use-mixed-styles.ts +9 -11
- package/src/hooks/use-tweak-styles.ts +49 -27
- package/src/theme/Provider.tsx +10 -5
- package/src/theme/create-themed-styles.ts +78 -0
- package/src/theme/helpers.ts +39 -39
- package/src/theme/index.ts +2 -0
- package/src/theme/true-jss/ThemedStylesManager.ts +92 -0
- package/src/theme/true-jss/TweakStylesManager.ts +157 -0
- package/src/theme/true-jss/index.ts +2 -0
- package/src/theme/true-jss/jss-context.tsx +34 -0
- package/src/theme/types.ts +5 -3
- package/src/types.ts +17 -4
- package/dist/components/AccountInfo/AccountInfo.stories.d.ts +0 -6
- package/dist/components/AddButton/AddButton.stories.d.ts +0 -6
- package/dist/components/Button/Button.stories.d.ts +0 -6
- package/dist/components/Checkbox/Checkbox.stories.d.ts +0 -8
- package/dist/components/CloseButton/CloseButton.stories.d.ts +0 -5
- package/dist/components/Colors/Colors.stories.d.ts +0 -5
- package/dist/components/ControlWrapper/ControlWrapper.stories.d.ts +0 -6
- package/dist/components/DateInput/DateInput.stories.d.ts +0 -7
- package/dist/components/DatePicker/DatePicker.stories.d.ts +0 -7
- package/dist/components/Description/Description.stories.d.ts +0 -16
- package/dist/components/FileInput/FileInput.stories.d.ts +0 -7
- package/dist/components/FileItem/FileItem.stories.d.ts +0 -8
- package/dist/components/FiltersPane/FiltersPane.stories.d.ts +0 -31
- package/dist/components/Flag/Flag.stories.d.ts +0 -12
- package/dist/components/FlexibleTable/FlexibleTable.stories.d.ts +0 -19
- package/dist/components/Icon/Icon.stories.d.ts +0 -6
- package/dist/components/IconButton/IconButton.stories.d.ts +0 -6
- package/dist/components/IncrementInput/IncrementInput.stories.d.ts +0 -6
- package/dist/components/Input/Input.stories.d.ts +0 -25
- package/dist/components/List/List.stories.d.ts +0 -5
- package/dist/components/Modal/Modal.stories.d.ts +0 -29
- package/dist/components/MoreMenu/MoreMenu.stories.d.ts +0 -6
- package/dist/components/MultiSelect/MultiSelect.stories.d.ts +0 -13
- package/dist/components/NewMoreMenu/NewMoreMenu.stories.d.ts +0 -12
- package/dist/components/Notification/Notification.stories.d.ts +0 -8
- package/dist/components/NumberInput/NumberInput.stories.d.ts +0 -7
- package/dist/components/PhoneInput/PhoneInput.stories.d.ts +0 -28
- package/dist/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.stories.d.ts +0 -5
- package/dist/components/RadioButton/RadioButton.stories.d.ts +0 -7
- package/dist/components/SearchInput/SearchInput.stories.d.ts +0 -6
- package/dist/components/Select/CustomSelect.stories.d.ts +0 -11
- package/dist/components/Select/MultiSelect.stories.d.ts +0 -15
- package/dist/components/Select/Select.stories.d.ts +0 -15
- package/dist/components/Selector/Selector.stories.d.ts +0 -7
- package/dist/components/Skeleton/Skeleton.stories.d.ts +0 -6
- package/dist/components/SmartInput/SmartInput.stories.d.ts +0 -18
- package/dist/components/Status/Status.stories.d.ts +0 -6
- package/dist/components/Switch/Switch.stories.d.ts +0 -16
- package/dist/components/TextArea/TextArea.stories.d.ts +0 -17
- package/dist/components/TextButton/TextButton.stories.d.ts +0 -6
- package/dist/components/TextWithInfo/TextWithInfo.stories.d.ts +0 -12
- package/dist/components/TextWithTooltip/TextWithTooltip.stories.d.ts +0 -24
- package/dist/components/ThemedPreloader/ThemedPreloader.stories.d.ts +0 -17
- package/dist/components/Toaster/Toaster.stories.d.ts +0 -5
- package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -5
- package/dist/components/WithMessages/WithMessages.stories.d.ts +0 -7
- package/dist/components/WithPopup/WithPopup.stories.d.ts +0 -16
- package/dist/components/WithTooltip/WithTooltip.stories.d.ts +0 -6
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { FocusEventHandler,
|
|
2
|
-
import { Modifier, Placement } from 'react-overlays/usePopper';
|
|
1
|
+
import type { FocusEventHandler, KeyboardEvent, KeyboardEventHandler, MouseEvent, MouseEventHandler, PointerEventHandler, ReactNode } from 'react';
|
|
2
|
+
import type { Modifier, Placement } from 'react-overlays/usePopper';
|
|
3
|
+
import type { JssStyle } from 'jss';
|
|
4
|
+
import type { IMaybeArray } from './theme';
|
|
3
5
|
export interface ITestIdProps {
|
|
4
6
|
testId?: string;
|
|
5
7
|
}
|
|
@@ -10,7 +12,7 @@ export interface IDataAttributesProps extends ITestIdProps {
|
|
|
10
12
|
data?: IDataAttributes;
|
|
11
13
|
}
|
|
12
14
|
export interface ITweakStylesProps<TweakStyles> {
|
|
13
|
-
tweakStyles?: TweakStyles
|
|
15
|
+
tweakStyles?: IMaybeArray<TweakStyles>;
|
|
14
16
|
}
|
|
15
17
|
export type ICommonProps<TweakStyles> = IDataAttributesProps & ITweakStylesProps<TweakStyles>;
|
|
16
18
|
export interface IDropdownWithPopperOptions {
|
|
@@ -43,3 +45,8 @@ export interface IDomElementInteractions<T> {
|
|
|
43
45
|
onPointerUp?: PointerEventHandler<T>;
|
|
44
46
|
}
|
|
45
47
|
export type IRenderNode<T> = ReactNode | ((props: T) => ReactNode);
|
|
48
|
+
export type IExtendableProps<T extends string | readonly string[]> = Record<T extends ReadonlyArray<infer P> ? P : T, JssStyle>;
|
|
49
|
+
export type IDefaultExtendableProps = IExtendableProps<'custom'>;
|
|
50
|
+
export type IWithPrefix<T, P extends string> = {
|
|
51
|
+
[K in keyof T as `${P}${K & string}`]: T[K];
|
|
52
|
+
};
|
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-
|
|
3
|
+
"version": "4.0.0-alpha30",
|
|
4
4
|
"description": "True Engineering React UI Kit with theming support",
|
|
5
5
|
"author": "True Engineering (https://trueengineering.ru)",
|
|
6
6
|
"keywords": [
|
|
@@ -42,17 +42,17 @@
|
|
|
42
42
|
"types-check": "tsc --noEmit"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@floating-ui/react": "0.
|
|
45
|
+
"@floating-ui/react": "0.27.13",
|
|
46
46
|
"@true-engineering/true-react-platform-helpers": "0.4.4",
|
|
47
47
|
"clsx": "1.2.1",
|
|
48
48
|
"country-flag-icons": "1.5.5",
|
|
49
|
-
"date-fns": "
|
|
49
|
+
"date-fns": "4.1.0",
|
|
50
50
|
"filesize": "10.1.1",
|
|
51
51
|
"hex-to-rgba": "2.0.1",
|
|
52
52
|
"jss": "10.10.0",
|
|
53
53
|
"lodash-es": "4.17.21",
|
|
54
54
|
"react": "18.2.0",
|
|
55
|
-
"react-datepicker": "4.
|
|
55
|
+
"react-datepicker": "8.4.0",
|
|
56
56
|
"react-dom": "18.2.0",
|
|
57
57
|
"react-input-mask": "3.0.0-alpha.2",
|
|
58
58
|
"react-jss": "10.10.0",
|
|
@@ -73,7 +73,6 @@
|
|
|
73
73
|
"@trivago/prettier-plugin-sort-imports": "4.3.0",
|
|
74
74
|
"@types/lodash-es": "4.17.11",
|
|
75
75
|
"@types/react": "18.2.79",
|
|
76
|
-
"@types/react-datepicker": "4.19.4",
|
|
77
76
|
"@types/react-dom": "18.2.25",
|
|
78
77
|
"@types/react-input-mask": "3.0.2",
|
|
79
78
|
"@types/react-transition-group": "4.4.10",
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { doNothing } from '@true-engineering/true-react-platform-helpers';
|
|
2
2
|
import { ComponentStory } from '@storybook/react';
|
|
3
|
-
import { iconsList } from '../Icon';
|
|
3
|
+
import { Icon, iconsList } from '../Icon';
|
|
4
4
|
import { ControlWrapper } from './ControlWrapper';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
|
-
title: 'ControlWrapper',
|
|
7
|
+
title: 'Controls/ControlWrapper',
|
|
8
8
|
component: ControlWrapper,
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const Template: ComponentStory<typeof ControlWrapper> = (args) => (
|
|
12
|
-
<ControlWrapper {...args} onClear={doNothing}
|
|
12
|
+
<ControlWrapper {...args} onClear={doNothing}>
|
|
13
13
|
<div style={{ minWidth: 200, height: 48 }} />
|
|
14
14
|
</ControlWrapper>
|
|
15
15
|
);
|
|
@@ -24,6 +24,11 @@ Default.args = {
|
|
|
24
24
|
isLoading: false,
|
|
25
25
|
isDisabled: false,
|
|
26
26
|
hasValue: false,
|
|
27
|
+
icon: [
|
|
28
|
+
{ iconComponent: <div>Бу</div>, onClick: () => console.log('close'), shouldResetSize: true },
|
|
29
|
+
{ iconComponent: <Icon type="question" /> },
|
|
30
|
+
{ iconComponent: 'search', onClick: () => console.log('search') },
|
|
31
|
+
],
|
|
27
32
|
};
|
|
28
33
|
|
|
29
34
|
Default.argTypes = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { animations, createThemedStyles, dimensions, ITweakStyles } from '../../theme';
|
|
2
2
|
import { IThemedPreloaderStyles } from '../ThemedPreloader';
|
|
3
|
+
import { IControlWrapperSizes } from './types';
|
|
3
4
|
|
|
4
5
|
const { CONTROL, Z_INDEX } = dimensions;
|
|
5
6
|
|
|
@@ -20,10 +21,6 @@ export const useStyles = createThemedStyles('ControlWrapper', {
|
|
|
20
21
|
zIndex: 0,
|
|
21
22
|
},
|
|
22
23
|
|
|
23
|
-
invalid: {
|
|
24
|
-
zIndex: Z_INDEX.CONTROL_INVALID,
|
|
25
|
-
},
|
|
26
|
-
|
|
27
24
|
disabled: {},
|
|
28
25
|
|
|
29
26
|
focused: {
|
|
@@ -31,6 +28,10 @@ export const useStyles = createThemedStyles('ControlWrapper', {
|
|
|
31
28
|
zIndex: Z_INDEX.CONTROL_FOCUS,
|
|
32
29
|
},
|
|
33
30
|
|
|
31
|
+
invalid: {
|
|
32
|
+
zIndex: Z_INDEX.CONTROL_INVALID,
|
|
33
|
+
},
|
|
34
|
+
|
|
34
35
|
withValue: {},
|
|
35
36
|
|
|
36
37
|
loading: {},
|
|
@@ -43,7 +44,7 @@ export const useStyles = createThemedStyles('ControlWrapper', {
|
|
|
43
44
|
position: 'absolute',
|
|
44
45
|
pointerEvents: 'none',
|
|
45
46
|
left: 'var(--control-padding)',
|
|
46
|
-
top: '
|
|
47
|
+
top: 'calc(var(--control-height) / 2)',
|
|
47
48
|
transformOrigin: 'top left',
|
|
48
49
|
transform: 'translateY(-50%)',
|
|
49
50
|
transition: animations.defaultTransition,
|
|
@@ -181,5 +182,5 @@ export const useStyles = createThemedStyles('ControlWrapper', {
|
|
|
181
182
|
|
|
182
183
|
export type IControlWrapperStyles = ITweakStyles<
|
|
183
184
|
typeof useStyles,
|
|
184
|
-
{ tweakPreloader: IThemedPreloaderStyles }
|
|
185
|
+
{ tweakPreloader: IThemedPreloaderStyles } & IControlWrapperSizes
|
|
185
186
|
>;
|
|
@@ -4,20 +4,25 @@ import {
|
|
|
4
4
|
addClickHandler,
|
|
5
5
|
addDataAttributes,
|
|
6
6
|
addDataTestId,
|
|
7
|
+
getArray,
|
|
8
|
+
isArrayNotEmpty,
|
|
7
9
|
isNotEmpty,
|
|
8
10
|
isReactNodeNotEmpty,
|
|
9
|
-
isString,
|
|
10
11
|
} from '@true-engineering/true-react-platform-helpers';
|
|
11
12
|
import { useTweakStyles } from '../../hooks';
|
|
13
|
+
import { IMaybeArray } from '../../theme';
|
|
12
14
|
import { IClickHandlerEvent, ICommonProps } from '../../types';
|
|
13
15
|
import { Icon, IIcon, renderIcon } from '../Icon';
|
|
14
16
|
import { ThemedPreloader } from '../ThemedPreloader';
|
|
17
|
+
import { convertToControlWrapperIcon } from './helpers';
|
|
18
|
+
import { IControlWrapperIcon, IControlWrapperSize } from './types';
|
|
15
19
|
import { IControlWrapperStyles, useStyles } from './ControlWrapper.styles';
|
|
16
20
|
|
|
17
21
|
export interface IControlWrapperProps extends ICommonProps<IControlWrapperStyles> {
|
|
18
22
|
children: ReactNode;
|
|
19
23
|
label?: ReactNode;
|
|
20
|
-
icon?: IIcon
|
|
24
|
+
icon?: IMaybeArray<IIcon | IControlWrapperIcon>;
|
|
25
|
+
size?: IControlWrapperSize;
|
|
21
26
|
groupPlacement?:
|
|
22
27
|
| 'left'
|
|
23
28
|
| 'right'
|
|
@@ -42,7 +47,6 @@ export interface IControlWrapperProps extends ICommonProps<IControlWrapperStyles
|
|
|
42
47
|
isLoading?: boolean;
|
|
43
48
|
/** @default false */
|
|
44
49
|
isDisabled?: boolean;
|
|
45
|
-
onIconClick?: (event: IClickHandlerEvent) => void;
|
|
46
50
|
onClear?: (event: IClickHandlerEvent) => void;
|
|
47
51
|
}
|
|
48
52
|
|
|
@@ -57,18 +61,22 @@ export const ControlWrapper: FC<IControlWrapperProps> = ({
|
|
|
57
61
|
isFullWidth,
|
|
58
62
|
isDisabled,
|
|
59
63
|
hasValue,
|
|
64
|
+
size,
|
|
60
65
|
testId,
|
|
61
66
|
children,
|
|
62
67
|
tweakStyles,
|
|
63
68
|
data,
|
|
64
|
-
onIconClick,
|
|
65
69
|
onClear,
|
|
66
70
|
}) => {
|
|
67
71
|
const classes = useStyles({ theme: tweakStyles });
|
|
68
72
|
|
|
69
|
-
const
|
|
73
|
+
const icons = getArray(icon).map(convertToControlWrapperIcon);
|
|
74
|
+
|
|
75
|
+
const hasIcons = !isLoading && isArrayNotEmpty(icons);
|
|
70
76
|
const hasClearButton = !isDisabled && !isLoading && hasValue && isNotEmpty(onClear);
|
|
71
|
-
const hasControls =
|
|
77
|
+
const hasControls = hasIcons || hasClearButton || isLoading;
|
|
78
|
+
|
|
79
|
+
const isActive = isFocused || hasValue;
|
|
72
80
|
|
|
73
81
|
const tweakPreloaderStyles = useTweakStyles({
|
|
74
82
|
tweakStyles,
|
|
@@ -80,7 +88,8 @@ export const ControlWrapper: FC<IControlWrapperProps> = ({
|
|
|
80
88
|
<div
|
|
81
89
|
className={clsx(
|
|
82
90
|
classes.controlWrapper,
|
|
83
|
-
isNotEmpty(groupPlacement) &&
|
|
91
|
+
isNotEmpty(groupPlacement) && classes[`placement-${groupPlacement}`],
|
|
92
|
+
isNotEmpty(size) && classes[size],
|
|
84
93
|
{
|
|
85
94
|
[classes.invalid]: isInvalid,
|
|
86
95
|
[classes.focused]: isFocused,
|
|
@@ -97,7 +106,7 @@ export const ControlWrapper: FC<IControlWrapperProps> = ({
|
|
|
97
106
|
className={clsx(classes.label, {
|
|
98
107
|
[classes.requiredLabel]: isRequired,
|
|
99
108
|
[classes.disabledLabel]: isDisabled,
|
|
100
|
-
[classes.activeLabel]:
|
|
109
|
+
[classes.activeLabel]: isActive,
|
|
101
110
|
})}
|
|
102
111
|
>
|
|
103
112
|
{label}
|
|
@@ -120,18 +129,20 @@ export const ControlWrapper: FC<IControlWrapperProps> = ({
|
|
|
120
129
|
</div>
|
|
121
130
|
)}
|
|
122
131
|
|
|
123
|
-
{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
{hasIcons &&
|
|
133
|
+
icons.map(({ key, iconComponent, onClick, shouldResetSize = false }, index) => (
|
|
134
|
+
<div
|
|
135
|
+
key={key ?? index}
|
|
136
|
+
className={clsx(classes.icon, classes.endIcon, {
|
|
137
|
+
[classes.activeIcon]: !isDisabled && isNotEmpty(onClick),
|
|
138
|
+
[classes.customIcon]: shouldResetSize,
|
|
139
|
+
})}
|
|
140
|
+
{...addClickHandler(onClick, !isDisabled)}
|
|
141
|
+
{...addDataTestId(testId, 'icon')}
|
|
142
|
+
>
|
|
143
|
+
<div className={classes.iconInner}>{renderIcon(iconComponent)}</div>
|
|
144
|
+
</div>
|
|
145
|
+
))}
|
|
135
146
|
|
|
136
147
|
{isLoading && (
|
|
137
148
|
<div
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isObject } from 'lodash-es';
|
|
2
|
+
import { IIcon } from '../Icon';
|
|
3
|
+
import { IControlWrapperIcon } from './types';
|
|
4
|
+
|
|
5
|
+
export const isControlWrapperIcon = (
|
|
6
|
+
iconItem: IIcon | IControlWrapperIcon,
|
|
7
|
+
): iconItem is IControlWrapperIcon => isObject(iconItem) && 'iconComponent' in iconItem;
|
|
8
|
+
|
|
9
|
+
export const convertToControlWrapperIcon = (
|
|
10
|
+
iconItem: IIcon | IControlWrapperIcon,
|
|
11
|
+
): IControlWrapperIcon => (isControlWrapperIcon(iconItem) ? iconItem : { iconComponent: iconItem });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Key } from 'react';
|
|
2
|
+
import { IClickHandlerEvent } from '../../types';
|
|
3
|
+
import { IIcon } from '../Icon';
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
6
|
+
export interface IControlWrapperSizes {}
|
|
7
|
+
|
|
8
|
+
export type IControlWrapperSize = keyof IControlWrapperSizes;
|
|
9
|
+
|
|
10
|
+
// подумать над extend HTMLAttributes<HTMLDivElement>
|
|
11
|
+
export interface IControlWrapperIcon {
|
|
12
|
+
key?: Key;
|
|
13
|
+
iconComponent: IIcon;
|
|
14
|
+
onClick?: (event: IClickHandlerEvent) => void;
|
|
15
|
+
shouldResetSize?: boolean;
|
|
16
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import ru from 'date-fns/locale
|
|
2
|
+
import { ru } from 'date-fns/locale';
|
|
3
3
|
import { ComponentStory } from '@storybook/react';
|
|
4
4
|
import { DatePicker } from './DatePicker';
|
|
5
5
|
|
|
@@ -52,6 +52,7 @@ const Template: ComponentStory<typeof DatePicker> = (args) => {
|
|
|
52
52
|
selectedDate={date}
|
|
53
53
|
startDate={startDate}
|
|
54
54
|
endDate={endDate}
|
|
55
|
+
minDate={new Date()}
|
|
55
56
|
onChangeDate={setDate}
|
|
56
57
|
onChangeRange={(dates) => {
|
|
57
58
|
setStartDate(dates?.[0] ?? null);
|
|
@@ -70,19 +71,31 @@ Default.args = {
|
|
|
70
71
|
isRange: false,
|
|
71
72
|
isClearable: true,
|
|
72
73
|
shouldRenderPopperInBody: false,
|
|
74
|
+
popperPlacement: 'bottom-start',
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
Default.argTypes = {
|
|
78
|
+
popperPlacement: {
|
|
79
|
+
options: [
|
|
80
|
+
'bottom-start',
|
|
81
|
+
'bottom',
|
|
82
|
+
'bottom-end',
|
|
83
|
+
'top-start',
|
|
84
|
+
'top',
|
|
85
|
+
'top-end',
|
|
86
|
+
'right-start',
|
|
87
|
+
'right',
|
|
88
|
+
'right-end',
|
|
89
|
+
'left-start',
|
|
90
|
+
'left',
|
|
91
|
+
'left-end',
|
|
92
|
+
],
|
|
93
|
+
control: 'select',
|
|
94
|
+
},
|
|
73
95
|
};
|
|
74
96
|
|
|
75
97
|
Default.parameters = {
|
|
76
98
|
controls: {
|
|
77
|
-
exclude: [
|
|
78
|
-
'data',
|
|
79
|
-
'testId',
|
|
80
|
-
'tabIndex',
|
|
81
|
-
'onFocus',
|
|
82
|
-
'onBlur',
|
|
83
|
-
'onPaste',
|
|
84
|
-
'onIconClick',
|
|
85
|
-
'onKeyDown',
|
|
86
|
-
],
|
|
99
|
+
exclude: ['data', 'testId', 'tabIndex', 'onFocus', 'onBlur', 'onPaste', 'onKeyDown'],
|
|
87
100
|
},
|
|
88
101
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createThemedStyles, ITweakStyles } from '../../theme';
|
|
2
2
|
import { IDateInputStyles } from '../DateInput';
|
|
3
3
|
|
|
4
4
|
export const useStyles = createThemedStyles('DatePicker', {
|
|
@@ -9,6 +9,8 @@ export const useStyles = createThemedStyles('DatePicker', {
|
|
|
9
9
|
|
|
10
10
|
day: {},
|
|
11
11
|
|
|
12
|
+
dayInner: {},
|
|
13
|
+
|
|
12
14
|
datepicker: {},
|
|
13
15
|
|
|
14
16
|
popper: {
|
|
@@ -8,19 +8,25 @@ import {
|
|
|
8
8
|
isNotEmpty,
|
|
9
9
|
isStringNotEmpty,
|
|
10
10
|
} from '@true-engineering/true-react-platform-helpers';
|
|
11
|
+
import { offset } from '@floating-ui/react';
|
|
11
12
|
import { addDataAttributes } from '../../helpers';
|
|
12
13
|
import { useTweakStyles } from '../../hooks';
|
|
13
14
|
import { ICommonProps } from '../../types';
|
|
14
15
|
import { DateInput, EMPTY_DATE_INPUT_VALUE, IDateInputProps } from '../DateInput';
|
|
15
16
|
import { DatePickerHeader, PopperContainer } from './components';
|
|
16
17
|
import { DatePickerComponent, DEFAULT_DATE_FORMAT } from './constants';
|
|
17
|
-
import {
|
|
18
|
-
|
|
18
|
+
import {
|
|
19
|
+
areDatesEquals,
|
|
20
|
+
getDateFormatter,
|
|
21
|
+
getDateValueParser,
|
|
22
|
+
preparateDatePickerLocale,
|
|
23
|
+
} from './helpers';
|
|
24
|
+
import { IDatePickerBaseProps, IDatePickerLocale, IRange } from './types';
|
|
19
25
|
import { IDatePickerStyles, useStyles } from './DatePicker.styles';
|
|
20
26
|
|
|
21
27
|
export interface IDatePickerProps extends IDatePickerBaseProps, ICommonProps<IDatePickerStyles> {
|
|
22
28
|
selectedDate?: Date | null;
|
|
23
|
-
locale:
|
|
29
|
+
locale: IDatePickerLocale;
|
|
24
30
|
months?: string[];
|
|
25
31
|
/** @default 'dd.MM.yyyy' */
|
|
26
32
|
dateFormat?: string;
|
|
@@ -58,7 +64,6 @@ export const DatePicker = forwardRef<ReactDatePicker, IDatePickerProps>(
|
|
|
58
64
|
isClearable,
|
|
59
65
|
strictParsing,
|
|
60
66
|
fixedHeight,
|
|
61
|
-
excludeScrollbar,
|
|
62
67
|
focusSelectedMonth,
|
|
63
68
|
disabledKeyboardNavigation,
|
|
64
69
|
shouldRenderPopperInBody = false,
|
|
@@ -66,8 +71,8 @@ export const DatePicker = forwardRef<ReactDatePicker, IDatePickerProps>(
|
|
|
66
71
|
shouldCloseOnSelect,
|
|
67
72
|
showPreviousMonths,
|
|
68
73
|
preventOpenOnFocus,
|
|
69
|
-
popperModifiers,
|
|
70
|
-
popperPlacement,
|
|
74
|
+
popperModifiers = [],
|
|
75
|
+
popperPlacement = 'bottom-start',
|
|
71
76
|
todayButton,
|
|
72
77
|
highlightDates,
|
|
73
78
|
calendarContainer,
|
|
@@ -153,6 +158,7 @@ export const DatePicker = forwardRef<ReactDatePicker, IDatePickerProps>(
|
|
|
153
158
|
}
|
|
154
159
|
};
|
|
155
160
|
|
|
161
|
+
// TODO: кажется это можно улучшить, т.к проблему пофиксили (https://github.com/Hacker0x01/react-datepicker/pull/5060)
|
|
156
162
|
const handleChangeDateRangeInput = (value: string) => {
|
|
157
163
|
const newStartDateValue = value.slice(0, 10);
|
|
158
164
|
let newStart = parseDateValue(newStartDateValue);
|
|
@@ -242,14 +248,13 @@ export const DatePicker = forwardRef<ReactDatePicker, IDatePickerProps>(
|
|
|
242
248
|
ref={ref}
|
|
243
249
|
minDate={minDate}
|
|
244
250
|
maxDate={maxDate}
|
|
245
|
-
locale={locale}
|
|
251
|
+
locale={preparateDatePickerLocale(locale)}
|
|
246
252
|
dateFormat={dateFormat}
|
|
247
253
|
placeholderText={placeholder}
|
|
248
254
|
calendarStartDay={calendarStartDay}
|
|
249
255
|
inline={isInline}
|
|
250
256
|
disabled={isDisabled}
|
|
251
257
|
fixedHeight={fixedHeight}
|
|
252
|
-
excludeScrollbar={excludeScrollbar}
|
|
253
258
|
showPreviousMonths={showPreviousMonths}
|
|
254
259
|
focusSelectedMonth={focusSelectedMonth}
|
|
255
260
|
monthsShown={monthsShown}
|
|
@@ -260,14 +265,16 @@ export const DatePicker = forwardRef<ReactDatePicker, IDatePickerProps>(
|
|
|
260
265
|
dayClassName={(v) => clsx(classes.day, dayClassName?.(v))}
|
|
261
266
|
disabledKeyboardNavigation={disabledKeyboardNavigation}
|
|
262
267
|
popperContainer={shouldRenderPopperInBody ? PopperContainer : undefined}
|
|
263
|
-
|
|
268
|
+
// Убираем дефолтный отступ в 10px из либы
|
|
269
|
+
// https://github.com/Hacker0x01/react-datepicker/blob/db67a58de2b05d2681bdf0a4977b606095d514c4/src/with_floating.tsx#L58
|
|
270
|
+
popperModifiers={[offset(-10), ...popperModifiers]}
|
|
264
271
|
popperPlacement={popperPlacement}
|
|
265
|
-
selectsRange={isRange}
|
|
266
272
|
strictParsing={strictParsing}
|
|
267
273
|
preventOpenOnFocus={preventOpenOnFocus}
|
|
268
274
|
shouldCloseOnSelect={shouldCloseOnSelect}
|
|
269
275
|
customInputRef={customInputRef}
|
|
270
276
|
customInput={<CustomInput {...dateInputProps} />}
|
|
277
|
+
renderDayContents={(day) => <div className={classes.dayInner}>{day}</div>}
|
|
271
278
|
renderCustomHeader={
|
|
272
279
|
renderCustomHeader ??
|
|
273
280
|
((baseProps) => <DatePickerHeader {...baseProps} months={months} />)
|
|
@@ -299,6 +306,7 @@ export const DatePicker = forwardRef<ReactDatePicker, IDatePickerProps>(
|
|
|
299
306
|
startDate: start,
|
|
300
307
|
endDate: end,
|
|
301
308
|
selected: start,
|
|
309
|
+
selectsRange: true,
|
|
302
310
|
onBlur: handleDateRangeInputBlur,
|
|
303
311
|
onChange: handleChangeRange,
|
|
304
312
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FC,
|
|
2
|
-
import {
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { FloatingPortal } from '@floating-ui/react';
|
|
3
3
|
|
|
4
|
-
export const PopperContainer: FC<
|
|
5
|
-
<
|
|
4
|
+
export const PopperContainer: FC<PropsWithChildren> = (props) => (
|
|
5
|
+
<FloatingPortal root={document.body} {...props} />
|
|
6
6
|
);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { parse, format, isSameDay } from 'date-fns';
|
|
1
|
+
import { parse, format, isSameDay, type Locale } from 'date-fns';
|
|
2
|
+
import { ru as ruLocale, enUS as enLocale } from 'date-fns/locale';
|
|
2
3
|
import {
|
|
3
4
|
isEmpty,
|
|
4
5
|
isNotEmpty,
|
|
5
6
|
isStringNotEmpty,
|
|
6
7
|
} from '@true-engineering/true-react-platform-helpers';
|
|
7
8
|
import { EMPTY_DATE_INPUT_VALUE } from '../DateInput';
|
|
9
|
+
import { IDatePickerLocale } from './types';
|
|
8
10
|
|
|
9
11
|
export const getDateFormatter =
|
|
10
12
|
(dateFormat: string) =>
|
|
@@ -21,3 +23,13 @@ export const getDateValueParser =
|
|
|
21
23
|
export const areDatesEquals = (date1?: Date | null, date2?: Date | null): boolean =>
|
|
22
24
|
(isEmpty(date1) && isEmpty(date2)) ||
|
|
23
25
|
(isNotEmpty(date1) && isNotEmpty(date2) && isSameDay(date1, date2));
|
|
26
|
+
|
|
27
|
+
export const preparateDatePickerLocale = (locale: IDatePickerLocale): Locale => {
|
|
28
|
+
if (locale === 'ru') {
|
|
29
|
+
return ruLocale;
|
|
30
|
+
}
|
|
31
|
+
if (locale === 'en') {
|
|
32
|
+
return enLocale;
|
|
33
|
+
}
|
|
34
|
+
return locale;
|
|
35
|
+
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DatePickerProps } from 'react-datepicker';
|
|
2
|
+
import { type Locale } from 'date-fns';
|
|
3
|
+
import { type IDateInputProps } from '../DateInput';
|
|
3
4
|
|
|
4
5
|
export type IRange = [Date | null, Date | null] | null;
|
|
5
6
|
|
|
7
|
+
export type IDatePickerLocale = 'ru' | 'en' | Locale;
|
|
8
|
+
|
|
6
9
|
export type IDatePickerBaseProps = Pick<
|
|
7
|
-
|
|
10
|
+
DatePickerProps,
|
|
8
11
|
| 'startDate'
|
|
9
12
|
| 'endDate'
|
|
10
13
|
| 'minDate'
|
|
@@ -31,7 +34,8 @@ export type IDatePickerBaseProps = Pick<
|
|
|
31
34
|
| 'strictParsing'
|
|
32
35
|
| 'highlightDates'
|
|
33
36
|
| 'fixedHeight'
|
|
34
|
-
| '
|
|
37
|
+
| 'swapRange'
|
|
38
|
+
| 'onKeyDown'
|
|
35
39
|
> &
|
|
36
40
|
Omit<
|
|
37
41
|
IDateInputProps,
|
|
@@ -45,4 +49,5 @@ export type IDatePickerBaseProps = Pick<
|
|
|
45
49
|
| 'onChange'
|
|
46
50
|
| 'onClick'
|
|
47
51
|
| 'tweakStyles'
|
|
52
|
+
| 'onKeyDown'
|
|
48
53
|
>;
|
|
@@ -70,7 +70,8 @@ type ConfigValues = {
|
|
|
70
70
|
custom: string;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
interface IFiltersPaneWithCustomProps<Values
|
|
73
|
+
interface IFiltersPaneWithCustomProps<Values extends Record<string, unknown>, Content>
|
|
74
|
+
extends IFiltersPaneProps<Values, Content> {
|
|
74
75
|
containerWidth: number;
|
|
75
76
|
isSearchDisabled: boolean;
|
|
76
77
|
shouldShowSettingsButton: boolean;
|
|
@@ -80,7 +81,7 @@ interface IFiltersPaneWithCustomProps<Values, Content> extends IFiltersPaneProps
|
|
|
80
81
|
isClearableFields: boolean;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
function FiltersPaneWithCustomProps<Values, Content>({
|
|
84
|
+
function FiltersPaneWithCustomProps<Values extends Record<string, unknown>, Content>({
|
|
84
85
|
containerWidth,
|
|
85
86
|
isSearchDisabled,
|
|
86
87
|
shouldShowSettingsButton,
|
|
@@ -288,6 +289,7 @@ Default.args = {
|
|
|
288
289
|
hasClearButton: true,
|
|
289
290
|
isClearableFields: false,
|
|
290
291
|
isDisabled: false,
|
|
292
|
+
shouldRenderDataId: false,
|
|
291
293
|
containerWidth: 400,
|
|
292
294
|
withFieldNameInLabel: true,
|
|
293
295
|
isGroupingEnabled: true,
|