@true-engineering/true-react-common-ui-kit 3.32.0 → 3.33.1

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 (99) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +15 -0
  3. package/dist/components/FlexibleTable/FlexibleTable.stories.d.ts +2 -0
  4. package/dist/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.d.ts +1 -1
  5. package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +2 -1
  6. package/dist/components/SearchInput/SearchInput.stories.d.ts +1 -1
  7. package/dist/components/WithPopup/WithPopup.styles.d.ts +1 -1
  8. package/dist/components/WithPopup/types.d.ts +9 -3
  9. package/dist/true-react-common-ui-kit.js +144 -171
  10. package/dist/true-react-common-ui-kit.js.map +1 -1
  11. package/dist/true-react-common-ui-kit.umd.cjs +143 -170
  12. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  13. package/dist/types.d.ts +7 -2
  14. package/package.json +98 -98
  15. package/src/components/AccountInfo/AccountInfo.stories.tsx +32 -32
  16. package/src/components/AccountInfo/AccountInfo.tsx +80 -80
  17. package/src/components/AddButton/AddButton.stories.tsx +21 -21
  18. package/src/components/AddButton/AddButton.tsx +52 -52
  19. package/src/components/Colors/Colors.stories.tsx +7 -7
  20. package/src/components/DateInput/DateInput.tsx +90 -90
  21. package/src/components/DateInput/constants.ts +2 -2
  22. package/src/components/Description/Description.stories.tsx +27 -27
  23. package/src/components/Description/Description.tsx +61 -61
  24. package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +166 -166
  25. package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +210 -210
  26. package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +177 -177
  27. package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +2 -2
  28. package/src/components/Flag/Flag.stories.tsx +29 -29
  29. package/src/components/Flag/Flag.tsx +26 -26
  30. package/src/components/Flag/augment.d.ts +1 -1
  31. package/src/components/FlexibleTable/FlexibleTable.stories.tsx +14 -1
  32. package/src/components/FlexibleTable/FlexibleTable.tsx +22 -10
  33. package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.styles.ts +39 -38
  34. package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.tsx +4 -2
  35. package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.ts +25 -25
  36. package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +2 -1
  37. package/src/components/FlexibleTable/types.ts +70 -70
  38. package/src/components/Icon/Icon.stories.tsx +86 -86
  39. package/src/components/Icon/complexIcons/augment.d.ts +1 -1
  40. package/src/components/Icon/complexIcons/avatarGreen.svg +57 -57
  41. package/src/components/Icon/complexIcons/index.ts +1 -1
  42. package/src/components/Icon/icons-list.ts +855 -856
  43. package/src/components/IncrementInput/IncrementInput.tsx +105 -105
  44. package/src/components/Input/types.ts +32 -32
  45. package/src/components/List/List.tsx +3 -1
  46. package/src/components/Modal/Modal.stories.tsx +105 -105
  47. package/src/components/MultiSelect/MultiSelect.stories.tsx +46 -46
  48. package/src/components/MultiSelect/MultiSelect.tsx +106 -106
  49. package/src/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.tsx +53 -53
  50. package/src/components/NewMoreMenu/NewMoreMenu.tsx +5 -5
  51. package/src/components/Notification/Notification.stories.tsx +55 -55
  52. package/src/components/Notification/Notification.styles.ts +57 -57
  53. package/src/components/Notification/Notification.tsx +77 -77
  54. package/src/components/Notification/types.ts +1 -1
  55. package/src/components/NumberInput/NumberInput.tsx +137 -137
  56. package/src/components/NumberInput/index.ts +1 -1
  57. package/src/components/PhoneInput/PhoneInput.tsx +214 -214
  58. package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.tsx +155 -155
  59. package/src/components/PhoneInput/types.ts +16 -16
  60. package/src/components/RadioButton/RadioButton.stories.tsx +46 -46
  61. package/src/components/RadioButton/RadioButton.tsx +57 -57
  62. package/src/components/ScrollIntoViewIfNeeded/index.ts +1 -1
  63. package/src/components/Select/Select.stories.tsx +235 -235
  64. package/src/components/Select/constants.ts +2 -2
  65. package/src/components/Select/types.ts +1 -1
  66. package/src/components/Selector/Selector.stories.tsx +62 -62
  67. package/src/components/Selector/Selector.tsx +115 -115
  68. package/src/components/Selector/index.ts +2 -2
  69. package/src/components/Selector/types.ts +12 -12
  70. package/src/components/Skeleton/Skeleton.stories.tsx +19 -19
  71. package/src/components/SmartInput/SmartInput.tsx +134 -134
  72. package/src/components/Status/Status.stories.tsx +73 -73
  73. package/src/components/Status/Status.styles.ts +143 -143
  74. package/src/components/Status/Status.tsx +49 -49
  75. package/src/components/Status/constants.ts +11 -11
  76. package/src/components/Status/index.ts +3 -3
  77. package/src/components/Status/types.ts +5 -5
  78. package/src/components/Switch/Switch.stories.tsx +40 -40
  79. package/src/components/Switch/Switch.tsx +75 -75
  80. package/src/components/TextWithInfo/TextWithInfo.stories.tsx +53 -53
  81. package/src/components/TextWithInfo/TextWithInfo.tsx +62 -62
  82. package/src/components/TextWithTooltip/TextWithTooltip.stories.tsx +58 -58
  83. package/src/components/ThemedPreloader/ThemedPreloader.stories.tsx +41 -41
  84. package/src/components/ThemedPreloader/ThemedPreloader.tsx +54 -54
  85. package/src/components/ThemedPreloader/components/DefaultPreloader/index.ts +1 -1
  86. package/src/components/Toaster/Toaster.stories.tsx +30 -30
  87. package/src/components/Tooltip/Tooltip.stories.tsx +19 -19
  88. package/src/components/Tooltip/Tooltip.tsx +35 -35
  89. package/src/components/Tooltip/types.ts +1 -1
  90. package/src/components/WithPopup/WithPopup.stories.tsx +3 -3
  91. package/src/components/WithPopup/WithPopup.styles.ts +2 -0
  92. package/src/components/WithPopup/WithPopup.tsx +18 -8
  93. package/src/components/WithPopup/types.ts +11 -3
  94. package/src/helpers/popper-helpers.ts +17 -17
  95. package/src/hooks/use-dropdown.ts +84 -84
  96. package/src/hooks/use-is-mounted.ts +15 -15
  97. package/src/theme/helpers.ts +76 -76
  98. package/src/types.ts +10 -2
  99. package/src/vite-env.d.ts +1 -1
@@ -1,177 +1,177 @@
1
- import { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
- import { useOnClickOutside, useTweakStyles } from '../../../../hooks';
3
- import { ICommonProps } from '../../../../types';
4
- import { PERIODS, PERIODS_GETTERS } from '../../constants';
5
- import { getLocale } from '../../helpers';
6
- import {
7
- IDatePeriod,
8
- IFilterLocaleKey,
9
- IPartialFilterLocale,
10
- IPeriod,
11
- IPeriodGetter,
12
- IPeriodsList,
13
- } from '../../types';
14
- import { FilterSelect } from '../FilterSelect';
15
- import { FilterWithDates } from '../FilterWithDates';
16
- import { useStyles, IFilterWithPeriodStyles, filterSelectStyles } from './FilterWithPeriod.styles';
17
-
18
- export interface IFilterWithPeriodProps extends ICommonProps<IFilterWithPeriodStyles> {
19
- value?: IPeriod;
20
- localeKey?: IFilterLocaleKey;
21
- locale?: IPartialFilterLocale;
22
- periods?: IPeriodsList;
23
- onChange: (period?: IPeriod) => void;
24
- onClose?: () => void;
25
- }
26
-
27
- export const FilterWithPeriod: FC<IFilterWithPeriodProps> = ({
28
- value,
29
- localeKey,
30
- locale,
31
- onChange,
32
- onClose,
33
- periods,
34
- tweakStyles,
35
- testId,
36
- }) => {
37
- const classes = useStyles({ theme: tweakStyles });
38
-
39
- const translates = useMemo(() => getLocale(localeKey, locale), [localeKey, locale]);
40
-
41
- const [isPeriodPickerShown, setIsPeriodPickerShown] = useState(value?.periodType !== 'CUSTOM');
42
-
43
- const [isDatePickerShown, setIsDatePickerShown] = useState(value?.periodType === 'CUSTOM');
44
-
45
- const [period, setPeriod] = useState(value);
46
-
47
- const periodGetters = useMemo(() => {
48
- const result: Record<string, IPeriodGetter> = { ...PERIODS_GETTERS };
49
- periods?.forEach((p) => {
50
- if (Array.isArray(p)) {
51
- result[p[0]] = p[1];
52
- }
53
- });
54
- return result;
55
- }, [periods]);
56
-
57
- const periodsList = useMemo(() => {
58
- if (periods === undefined) {
59
- return [...PERIODS];
60
- }
61
- return periods.map((p) => (Array.isArray(p) ? p[0] : p));
62
- }, [periods]);
63
-
64
- const getPeriodTranslate = useCallback(
65
- (val: string) => translates.periods[val] ?? val,
66
- [translates.periods],
67
- );
68
-
69
- const handlePeriodChange = (periodType: string) => {
70
- let from = null;
71
- let to = null;
72
-
73
- if (periodType in periodGetters) {
74
- const newPeriod = periodGetters[periodType]();
75
- from = newPeriod.from;
76
- to = newPeriod.to;
77
- }
78
-
79
- const p = { from, to, periodType };
80
- setPeriod(p);
81
-
82
- if (periodType === 'CUSTOM') {
83
- setIsDatePickerShown(true);
84
- } else {
85
- if (onClose !== undefined) {
86
- onClose();
87
- }
88
- onChange({ ...p, label: getPeriodTranslate(periodType) });
89
- }
90
-
91
- setIsPeriodPickerShown(false);
92
- };
93
-
94
- const refPeriodPicker = useRef<HTMLDivElement>(null);
95
- const refDatePicker = useRef<HTMLDivElement>(null);
96
-
97
- const onPeriodChange = (val?: string) => {
98
- if (val !== undefined) {
99
- handlePeriodChange(val);
100
- } else {
101
- onChange(undefined);
102
- if (onClose !== undefined) {
103
- onClose();
104
- }
105
- }
106
- };
107
-
108
- const handleCustomDateChange = (val: IDatePeriod): void => {
109
- if (val.from || val.to) {
110
- onChange({
111
- ...val,
112
- periodType: 'CUSTOM',
113
- });
114
- } else {
115
- onChange(undefined);
116
- }
117
- };
118
-
119
- useOnClickOutside(refDatePicker, () => {
120
- if (!period?.from && !period?.to) {
121
- setPeriod(undefined);
122
- }
123
- setIsDatePickerShown(false);
124
- });
125
-
126
- useEffect(() => {
127
- setPeriod(value);
128
- }, [value, value?.from, value?.to, value?.periodType]);
129
-
130
- const tweakSelectStyles = useTweakStyles({
131
- innerStyles: filterSelectStyles,
132
- tweakStyles,
133
- className: 'tweakFilterSelect',
134
- currentComponentName: 'FilterWithPeriod',
135
- });
136
-
137
- return (
138
- <div className={classes.root}>
139
- {isPeriodPickerShown && (
140
- <div className={classes.main} ref={refPeriodPicker}>
141
- <FilterSelect
142
- options={periodsList}
143
- value={period?.periodType}
144
- onChange={onPeriodChange}
145
- localeKey={localeKey}
146
- locale={translates}
147
- tweakStyles={tweakSelectStyles}
148
- getValueView={getPeriodTranslate}
149
- testId={testId !== undefined ? `${testId}-select` : undefined}
150
- />
151
- </div>
152
- )}
153
- {isDatePickerShown && (
154
- <div className={classes.picker} style={{ width: 320 }} ref={refDatePicker}>
155
- <FilterWithDates
156
- onStartBtnSubmit={() => {
157
- setIsDatePickerShown(false);
158
- setIsPeriodPickerShown(true);
159
- }}
160
- onEndBtnSubmit={() => {
161
- onChange(undefined);
162
- setIsDatePickerShown(false);
163
- if (onClose !== undefined) {
164
- onClose();
165
- }
166
- }}
167
- value={period}
168
- onChange={handleCustomDateChange}
169
- localeKey={localeKey}
170
- locale={translates}
171
- testId={testId !== undefined ? `${testId}-dates` : undefined}
172
- />
173
- </div>
174
- )}
175
- </div>
176
- );
177
- };
1
+ import { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import { useOnClickOutside, useTweakStyles } from '../../../../hooks';
3
+ import { ICommonProps } from '../../../../types';
4
+ import { PERIODS, PERIODS_GETTERS } from '../../constants';
5
+ import { getLocale } from '../../helpers';
6
+ import {
7
+ IDatePeriod,
8
+ IFilterLocaleKey,
9
+ IPartialFilterLocale,
10
+ IPeriod,
11
+ IPeriodGetter,
12
+ IPeriodsList,
13
+ } from '../../types';
14
+ import { FilterSelect } from '../FilterSelect';
15
+ import { FilterWithDates } from '../FilterWithDates';
16
+ import { useStyles, IFilterWithPeriodStyles, filterSelectStyles } from './FilterWithPeriod.styles';
17
+
18
+ export interface IFilterWithPeriodProps extends ICommonProps<IFilterWithPeriodStyles> {
19
+ value?: IPeriod;
20
+ localeKey?: IFilterLocaleKey;
21
+ locale?: IPartialFilterLocale;
22
+ periods?: IPeriodsList;
23
+ onChange: (period?: IPeriod) => void;
24
+ onClose?: () => void;
25
+ }
26
+
27
+ export const FilterWithPeriod: FC<IFilterWithPeriodProps> = ({
28
+ value,
29
+ localeKey,
30
+ locale,
31
+ onChange,
32
+ onClose,
33
+ periods,
34
+ tweakStyles,
35
+ testId,
36
+ }) => {
37
+ const classes = useStyles({ theme: tweakStyles });
38
+
39
+ const translates = useMemo(() => getLocale(localeKey, locale), [localeKey, locale]);
40
+
41
+ const [isPeriodPickerShown, setIsPeriodPickerShown] = useState(value?.periodType !== 'CUSTOM');
42
+
43
+ const [isDatePickerShown, setIsDatePickerShown] = useState(value?.periodType === 'CUSTOM');
44
+
45
+ const [period, setPeriod] = useState(value);
46
+
47
+ const periodGetters = useMemo(() => {
48
+ const result: Record<string, IPeriodGetter> = { ...PERIODS_GETTERS };
49
+ periods?.forEach((p) => {
50
+ if (Array.isArray(p)) {
51
+ result[p[0]] = p[1];
52
+ }
53
+ });
54
+ return result;
55
+ }, [periods]);
56
+
57
+ const periodsList = useMemo(() => {
58
+ if (periods === undefined) {
59
+ return [...PERIODS];
60
+ }
61
+ return periods.map((p) => (Array.isArray(p) ? p[0] : p));
62
+ }, [periods]);
63
+
64
+ const getPeriodTranslate = useCallback(
65
+ (val: string) => translates.periods[val] ?? val,
66
+ [translates.periods],
67
+ );
68
+
69
+ const handlePeriodChange = (periodType: string) => {
70
+ let from = null;
71
+ let to = null;
72
+
73
+ if (periodType in periodGetters) {
74
+ const newPeriod = periodGetters[periodType]();
75
+ from = newPeriod.from;
76
+ to = newPeriod.to;
77
+ }
78
+
79
+ const p = { from, to, periodType };
80
+ setPeriod(p);
81
+
82
+ if (periodType === 'CUSTOM') {
83
+ setIsDatePickerShown(true);
84
+ } else {
85
+ if (onClose !== undefined) {
86
+ onClose();
87
+ }
88
+ onChange({ ...p, label: getPeriodTranslate(periodType) });
89
+ }
90
+
91
+ setIsPeriodPickerShown(false);
92
+ };
93
+
94
+ const refPeriodPicker = useRef<HTMLDivElement>(null);
95
+ const refDatePicker = useRef<HTMLDivElement>(null);
96
+
97
+ const onPeriodChange = (val?: string) => {
98
+ if (val !== undefined) {
99
+ handlePeriodChange(val);
100
+ } else {
101
+ onChange(undefined);
102
+ if (onClose !== undefined) {
103
+ onClose();
104
+ }
105
+ }
106
+ };
107
+
108
+ const handleCustomDateChange = (val: IDatePeriod): void => {
109
+ if (val.from || val.to) {
110
+ onChange({
111
+ ...val,
112
+ periodType: 'CUSTOM',
113
+ });
114
+ } else {
115
+ onChange(undefined);
116
+ }
117
+ };
118
+
119
+ useOnClickOutside(refDatePicker, () => {
120
+ if (!period?.from && !period?.to) {
121
+ setPeriod(undefined);
122
+ }
123
+ setIsDatePickerShown(false);
124
+ });
125
+
126
+ useEffect(() => {
127
+ setPeriod(value);
128
+ }, [value, value?.from, value?.to, value?.periodType]);
129
+
130
+ const tweakSelectStyles = useTweakStyles({
131
+ innerStyles: filterSelectStyles,
132
+ tweakStyles,
133
+ className: 'tweakFilterSelect',
134
+ currentComponentName: 'FilterWithPeriod',
135
+ });
136
+
137
+ return (
138
+ <div className={classes.root}>
139
+ {isPeriodPickerShown && (
140
+ <div className={classes.main} ref={refPeriodPicker}>
141
+ <FilterSelect
142
+ options={periodsList}
143
+ value={period?.periodType}
144
+ onChange={onPeriodChange}
145
+ localeKey={localeKey}
146
+ locale={translates}
147
+ tweakStyles={tweakSelectStyles}
148
+ getValueView={getPeriodTranslate}
149
+ testId={testId !== undefined ? `${testId}-select` : undefined}
150
+ />
151
+ </div>
152
+ )}
153
+ {isDatePickerShown && (
154
+ <div className={classes.picker} style={{ width: 320 }} ref={refDatePicker}>
155
+ <FilterWithDates
156
+ onStartBtnSubmit={() => {
157
+ setIsDatePickerShown(false);
158
+ setIsPeriodPickerShown(true);
159
+ }}
160
+ onEndBtnSubmit={() => {
161
+ onChange(undefined);
162
+ setIsDatePickerShown(false);
163
+ if (onClose !== undefined) {
164
+ onClose();
165
+ }
166
+ }}
167
+ value={period}
168
+ onChange={handleCustomDateChange}
169
+ localeKey={localeKey}
170
+ locale={translates}
171
+ testId={testId !== undefined ? `${testId}-dates` : undefined}
172
+ />
173
+ </div>
174
+ )}
175
+ </div>
176
+ );
177
+ };
@@ -75,7 +75,7 @@ export function FilterWrapper<Values, Key extends keyof Values>({
75
75
  canBeFlipped
76
76
  isDisabled={isBoolean || isDisabled}
77
77
  tweakStyles={tweakWithPopupStyles}
78
- trigger={({ isActive, isDisabled: _isDisabled, ...props }) => (
78
+ trigger={({ triggerProps: { isActive }, referenceProps }) => (
79
79
  <div
80
80
  className={clsx(classes.root, {
81
81
  [classes.noValue]: !hasValue,
@@ -87,7 +87,7 @@ export function FilterWrapper<Values, Key extends keyof Values>({
87
87
  })}
88
88
  {...addDataTestId(testId)}
89
89
  {...addDataAttributes(data)}
90
- {...props}
90
+ {...referenceProps}
91
91
  >
92
92
  <div
93
93
  onClick={handleLabelClick}
@@ -1,29 +1,29 @@
1
- import { countries } from 'country-flag-icons';
2
- import { ComponentStory } from '@storybook/react';
3
- import { Flag } from './Flag';
4
-
5
- export default {
6
- title: 'Data Display/Flag',
7
- component: Flag,
8
- argTypes: {
9
- countryCode: { control: 'select', options: countries },
10
- },
11
- };
12
-
13
- const Template: ComponentStory<typeof Flag> = (args) => (
14
- <div style={{ width: 60, height: 40 }}>
15
- <Flag {...args} />
16
- </div>
17
- );
18
-
19
- export const Default = Template.bind({});
20
-
21
- Default.args = {
22
- countryCode: 'ug',
23
- };
24
-
25
- Default.parameters = {
26
- controls: {
27
- exclude: ['data'],
28
- },
29
- };
1
+ import { countries } from 'country-flag-icons';
2
+ import { ComponentStory } from '@storybook/react';
3
+ import { Flag } from './Flag';
4
+
5
+ export default {
6
+ title: 'Data Display/Flag',
7
+ component: Flag,
8
+ argTypes: {
9
+ countryCode: { control: 'select', options: countries },
10
+ },
11
+ };
12
+
13
+ const Template: ComponentStory<typeof Flag> = (args) => (
14
+ <div style={{ width: 60, height: 40 }}>
15
+ <Flag {...args} />
16
+ </div>
17
+ );
18
+
19
+ export const Default = Template.bind({});
20
+
21
+ Default.args = {
22
+ countryCode: 'ug',
23
+ };
24
+
25
+ Default.parameters = {
26
+ controls: {
27
+ exclude: ['data'],
28
+ },
29
+ };
@@ -1,26 +1,26 @@
1
- import { FC } from 'react';
2
- import { hasFlag } from 'country-flag-icons';
3
- import Flags from 'country-flag-icons/react/3x2';
4
- import { ICommonProps } from '../../types';
5
- import { Icon } from '../Icon';
6
- import { useStyles, IFlagStyles } from './Flag.styles';
7
-
8
- export interface IFlagProps extends Pick<ICommonProps<IFlagStyles>, 'tweakStyles'> {
9
- /** @default '' */
10
- countryCode?: string;
11
- }
12
-
13
- export const Flag: FC<IFlagProps> = ({ countryCode = '', tweakStyles }) => {
14
- const classes = useStyles({ theme: tweakStyles });
15
- const CC = countryCode.toUpperCase();
16
-
17
- const TheFlag = hasFlag(CC)
18
- ? Flags[CC as keyof typeof Flags]
19
- : () => (
20
- <div className={classes.noFlag}>
21
- <Icon type="minus" />
22
- </div>
23
- );
24
-
25
- return <TheFlag className={classes.root} />;
26
- };
1
+ import { FC } from 'react';
2
+ import { hasFlag } from 'country-flag-icons';
3
+ import Flags from 'country-flag-icons/react/3x2';
4
+ import { ICommonProps } from '../../types';
5
+ import { Icon } from '../Icon';
6
+ import { useStyles, IFlagStyles } from './Flag.styles';
7
+
8
+ export interface IFlagProps extends Pick<ICommonProps<IFlagStyles>, 'tweakStyles'> {
9
+ /** @default '' */
10
+ countryCode?: string;
11
+ }
12
+
13
+ export const Flag: FC<IFlagProps> = ({ countryCode = '', tweakStyles }) => {
14
+ const classes = useStyles({ theme: tweakStyles });
15
+ const CC = countryCode.toUpperCase();
16
+
17
+ const TheFlag = hasFlag(CC)
18
+ ? Flags[CC as keyof typeof Flags]
19
+ : () => (
20
+ <div className={classes.noFlag}>
21
+ <Icon type="minus" />
22
+ </div>
23
+ );
24
+
25
+ return <TheFlag className={classes.root} />;
26
+ };
@@ -1 +1 @@
1
- declare module 'country-flag-icons/react/3x2';
1
+ declare module 'country-flag-icons/react/3x2';
@@ -12,6 +12,8 @@ interface ITableContent {
12
12
  contractCode: string;
13
13
  validFrom: Date;
14
14
  validTo: Date;
15
+ validTo1?: Date;
16
+ validTo2?: Date;
15
17
  title: string;
16
18
  signDate: Date;
17
19
  partner: string;
@@ -26,11 +28,16 @@ const Temp: FC<IValueComponentProps<ITableContent, string>> = ({ value }) => <>{
26
28
  const config: IFlexibleTableConfigType<ITableContent> = {
27
29
  contractCode: {
28
30
  title: 'Contract Code',
31
+ minWidth: 150,
32
+ maxWidth: 150,
33
+ position: 'sticky',
29
34
  },
30
35
  title: {
31
36
  component: Temp,
32
37
  title: 'Title',
33
- minWidth: 320,
38
+ minWidth: 100,
39
+ position: 'sticky',
40
+ left: 186,
34
41
  },
35
42
  validFrom: {
36
43
  title: 'Valid From',
@@ -39,6 +46,12 @@ const config: IFlexibleTableConfigType<ITableContent> = {
39
46
  validTo: {
40
47
  title: 'Valid From',
41
48
  },
49
+ validTo1: {
50
+ title: 'Valid To1',
51
+ },
52
+ validTo2: {
53
+ title: 'Valid To2',
54
+ },
42
55
  signDate: {
43
56
  title: 'Sign Date',
44
57
  },
@@ -222,27 +222,39 @@ export function FlexibleTable<
222
222
  <Table.Head className={classes.head}>
223
223
  <Table.Row className={classes.headerRow}>
224
224
  {columns.map((key, i) => {
225
- const itemConfig = config?.[key];
225
+ const {
226
+ position,
227
+ minWidth,
228
+ width,
229
+ maxWidth,
230
+ titleAlign = 'left',
231
+ right,
232
+ left,
233
+ title = '',
234
+ shouldRenderDataId,
235
+ } = config?.[key] ?? {};
236
+ const isSticky = position === 'sticky' || (isFirstColumnSticky && i === 0);
226
237
 
227
238
  return (
228
239
  <Table.Header
229
240
  key={key}
230
241
  className={clsx(classes.header, {
231
- [classes.headerSticky]: isFirstColumnSticky && i === 0,
242
+ [classes.headerSticky]: isSticky,
232
243
  [classes.headerSecond]: isFirstColumnSticky && i === 1,
233
244
  })}
234
245
  style={{
235
- minWidth: itemConfig?.minWidth,
236
- width: itemConfig?.width,
237
- maxWidth: itemConfig?.maxWidth,
238
- textAlign: itemConfig?.titleAlign ?? 'left',
246
+ minWidth,
247
+ width,
248
+ maxWidth,
249
+ textAlign: titleAlign,
250
+ position: isSticky ? 'sticky' : position,
251
+ right,
252
+ left,
239
253
  }}
240
254
  onClick={isNotEmpty(onHeadClick) ? () => onHeadClick(key) : undefined}
241
- {...addDataAttributes({ id: itemConfig?.shouldRenderDataId ? key : undefined })}
255
+ {...addDataAttributes({ id: shouldRenderDataId ? key : undefined })}
242
256
  >
243
- {applyAction(itemConfig?.title ?? '', {
244
- value: headerContent?.[key] as HeaderContent[string],
245
- })}
257
+ {applyAction(title, { value: headerContent?.[key] as HeaderContent[string] })}
246
258
  </Table.Header>
247
259
  );
248
260
  })}
@@ -1,38 +1,39 @@
1
- import { getTransition } from '@true-engineering/true-react-platform-helpers';
2
- import { ITweakStyles, createThemedStyles } from '../../../../theme';
3
- import { STICKY_SHADOW_PADDING } from '../../FlexibleTable.styles';
4
-
5
- export const useStyles = createThemedStyles('FlexibleTableCell', {
6
- root: {
7
- position: 'relative',
8
- boxSizing: 'content-box',
9
- padding: [14, 7],
10
- fontSize: 14,
11
- lineHeight: 1.42,
12
- zIndex: 5,
13
- verticalAlign: 'top',
14
- },
15
-
16
- sticky: {
17
- zIndex: 19,
18
- paddingLeft: 24,
19
- paddingRight: 12,
20
- ...getTransition(['box-shadow']),
21
-
22
- '[data-scrolled] &': {
23
- boxShadow: '4px 0 4px rgba(0, 0, 0, 0.05)',
24
- },
25
- },
26
-
27
- second: {
28
- paddingLeft: STICKY_SHADOW_PADDING,
29
- },
30
-
31
- loading: {},
32
-
33
- skeleton: {
34
- height: 21,
35
- },
36
- });
37
-
38
- export type IFlexibleTableCellStyles = ITweakStyles<typeof useStyles>;
1
+ import { getTransition } from '@true-engineering/true-react-platform-helpers';
2
+ import { ITweakStyles, createThemedStyles } from '../../../../theme';
3
+ import { STICKY_SHADOW_PADDING } from '../../FlexibleTable.styles';
4
+
5
+ export const useStyles = createThemedStyles('FlexibleTableCell', {
6
+ root: {
7
+ position: 'relative',
8
+ boxSizing: 'content-box',
9
+ padding: [14, 7],
10
+ fontSize: 14,
11
+ lineHeight: 1.42,
12
+ zIndex: 5,
13
+ verticalAlign: 'top',
14
+ },
15
+
16
+ sticky: {
17
+ zIndex: 19,
18
+ paddingLeft: 24,
19
+ paddingRight: 12,
20
+ left: 0,
21
+ ...getTransition(['box-shadow']),
22
+
23
+ '[data-scrolled] &': {
24
+ boxShadow: '4px 0 4px rgba(0, 0, 0, 0.05)',
25
+ },
26
+ },
27
+
28
+ second: {
29
+ paddingLeft: STICKY_SHADOW_PADDING,
30
+ },
31
+
32
+ loading: {},
33
+
34
+ skeleton: {
35
+ height: 21,
36
+ },
37
+ });
38
+
39
+ export type IFlexibleTableCellStyles = ITweakStyles<typeof useStyles>;