@true-engineering/true-react-common-ui-kit 3.41.0 → 3.42.0

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 (101) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +7 -0
  3. package/dist/components/FiltersPane/FiltersPane.stories.d.ts +2 -1
  4. package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.styles.d.ts +1 -1
  5. package/dist/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.styles.d.ts +1 -1
  6. package/dist/components/FiltersPane/types.d.ts +1 -0
  7. package/dist/components/Input/Input.styles.d.ts +1 -1
  8. package/dist/components/SearchInput/SearchInput.stories.d.ts +1 -1
  9. package/dist/components/Select/Select.styles.d.ts +3 -3
  10. package/dist/true-react-common-ui-kit.js +74 -59
  11. package/dist/true-react-common-ui-kit.js.map +1 -1
  12. package/dist/true-react-common-ui-kit.umd.cjs +74 -59
  13. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  14. package/package.json +99 -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/FiltersPane.stories.tsx +12 -0
  25. package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +166 -166
  26. package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +210 -210
  27. package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +177 -177
  28. package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.styles.ts +4 -0
  29. package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +20 -2
  30. package/src/components/FiltersPane/types.ts +1 -0
  31. package/src/components/Flag/Flag.stories.tsx +29 -29
  32. package/src/components/Flag/Flag.tsx +26 -26
  33. package/src/components/Flag/augment.d.ts +1 -1
  34. package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.ts +25 -25
  35. package/src/components/Icon/Icon.stories.tsx +86 -86
  36. package/src/components/Icon/complexIcons/augment.d.ts +1 -1
  37. package/src/components/Icon/complexIcons/avatarGreen.svg +57 -57
  38. package/src/components/Icon/complexIcons/index.ts +1 -1
  39. package/src/components/IncrementInput/IncrementInput.tsx +105 -105
  40. package/src/components/Input/types.ts +32 -32
  41. package/src/components/Modal/Modal.stories.tsx +105 -105
  42. package/src/components/MoreMenu/MoreMenu.tsx +93 -93
  43. package/src/components/MultiSelect/MultiSelect.stories.tsx +46 -46
  44. package/src/components/MultiSelect/MultiSelect.tsx +106 -106
  45. package/src/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.tsx +53 -53
  46. package/src/components/Notification/Notification.stories.tsx +55 -55
  47. package/src/components/Notification/Notification.styles.ts +57 -57
  48. package/src/components/Notification/Notification.tsx +77 -77
  49. package/src/components/Notification/types.ts +1 -1
  50. package/src/components/NumberInput/NumberInput.tsx +137 -137
  51. package/src/components/NumberInput/index.ts +1 -1
  52. package/src/components/PhoneInput/PhoneInput.tsx +214 -214
  53. package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.tsx +155 -155
  54. package/src/components/PhoneInput/types.ts +16 -16
  55. package/src/components/RadioButton/RadioButton.stories.tsx +46 -46
  56. package/src/components/RadioButton/RadioButton.tsx +57 -57
  57. package/src/components/ScrollIntoViewIfNeeded/index.ts +1 -1
  58. package/src/components/Select/constants.ts +2 -2
  59. package/src/components/Select/types.ts +1 -1
  60. package/src/components/Selector/Selector.stories.tsx +62 -62
  61. package/src/components/Selector/Selector.tsx +115 -115
  62. package/src/components/Selector/index.ts +2 -2
  63. package/src/components/Selector/types.ts +12 -12
  64. package/src/components/Skeleton/Skeleton.stories.tsx +19 -19
  65. package/src/components/SmartInput/SmartInput.stories.tsx +52 -52
  66. package/src/components/SmartInput/SmartInput.tsx +116 -116
  67. package/src/components/SmartInput/constants.ts +91 -91
  68. package/src/components/SmartInput/helpers.ts +26 -26
  69. package/src/components/SmartInput/types.ts +18 -18
  70. package/src/components/Status/Status.stories.tsx +73 -73
  71. package/src/components/Status/Status.styles.ts +143 -143
  72. package/src/components/Status/Status.tsx +49 -49
  73. package/src/components/Status/constants.ts +11 -11
  74. package/src/components/Status/index.ts +3 -3
  75. package/src/components/Status/types.ts +5 -5
  76. package/src/components/Switch/Switch.stories.tsx +40 -40
  77. package/src/components/Switch/Switch.tsx +75 -75
  78. package/src/components/TextWithInfo/TextWithInfo.stories.tsx +53 -53
  79. package/src/components/TextWithInfo/TextWithInfo.tsx +62 -62
  80. package/src/components/TextWithTooltip/TextWithTooltip.stories.tsx +58 -58
  81. package/src/components/TextWithTooltip/TextWithTooltip.tsx +156 -156
  82. package/src/components/ThemedPreloader/ThemedPreloader.stories.tsx +41 -41
  83. package/src/components/ThemedPreloader/ThemedPreloader.tsx +54 -54
  84. package/src/components/ThemedPreloader/components/DefaultPreloader/index.ts +1 -1
  85. package/src/components/Toaster/Toaster.stories.tsx +30 -30
  86. package/src/components/Tooltip/Tooltip.stories.tsx +19 -19
  87. package/src/components/Tooltip/Tooltip.tsx +35 -35
  88. package/src/components/Tooltip/types.ts +1 -1
  89. package/src/components/WithPopup/WithPopup.styles.ts +45 -45
  90. package/src/components/WithPopup/WithPopup.tsx +184 -184
  91. package/src/components/WithTooltip/WithTooltip.stories.tsx +56 -56
  92. package/src/components/WithTooltip/WithTooltip.styles.ts +7 -7
  93. package/src/components/WithTooltip/WithTooltip.tsx +67 -67
  94. package/src/components/WithTooltip/index.ts +2 -2
  95. package/src/components/index.ts +46 -46
  96. package/src/helpers/popper-helpers.ts +17 -17
  97. package/src/hooks/use-dropdown.ts +84 -84
  98. package/src/hooks/use-is-mounted.ts +15 -15
  99. package/src/theme/helpers.ts +76 -76
  100. package/src/theme/types.ts +158 -158
  101. 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
+ };
@@ -59,6 +59,10 @@ export const useStyles = createThemedStyles('FilterWrapper', {
59
59
  flexShrink: 0,
60
60
  },
61
61
 
62
+ chevronIcon: {},
63
+
64
+ clearIcon: {},
65
+
62
66
  open: {
63
67
  transform: 'rotate(180deg)',
64
68
  },
@@ -1,3 +1,4 @@
1
+ import { MouseEventHandler } from 'react';
1
2
  import clsx from 'clsx';
2
3
  import { addDataTestId, getTestId } from '@true-engineering/true-react-platform-helpers';
3
4
  import { addDataAttributes } from '../../../../helpers';
@@ -66,8 +67,13 @@ export function FilterWrapper<Values, Key extends keyof Values>({
66
67
  onChange(!value);
67
68
  }
68
69
  };
70
+ const handleClearIconClick: MouseEventHandler<HTMLDivElement> = (event) => {
71
+ event.stopPropagation();
72
+ onChange(undefined);
73
+ };
69
74
 
70
75
  const hasValue = isContentNotEmpty(value);
76
+ const hasClearIcon = (filter.isClearable ?? false) && hasValue;
71
77
 
72
78
  return (
73
79
  <WithPopup
@@ -106,11 +112,23 @@ export function FilterWrapper<Values, Key extends keyof Values>({
106
112
  />
107
113
  </div>
108
114
  )}
109
- {!isBoolean && (
110
- <div className={clsx(classes.iconContainer, { [classes.open]: isActive })}>
115
+ {!isBoolean && !hasClearIcon && (
116
+ <div
117
+ className={clsx(classes.iconContainer, classes.chevronIcon, {
118
+ [classes.open]: isActive,
119
+ })}
120
+ >
111
121
  <Icon type="chevron-down" />
112
122
  </div>
113
123
  )}
124
+ {hasClearIcon && (
125
+ <div
126
+ className={clsx(classes.iconContainer, classes.clearIcon)}
127
+ onClick={handleClearIconClick}
128
+ >
129
+ <Icon type="close-large" />
130
+ </div>
131
+ )}
114
132
  </div>
115
133
  </div>
116
134
  )}
@@ -49,6 +49,7 @@ export type MultiSelectOptionType<Value> = Value | undefined extends
49
49
  export interface IConfigItemBasicBase<Value> {
50
50
  name: string;
51
51
  isInline?: boolean;
52
+ isClearable?: boolean;
52
53
  requiredFilledFilters?: string[];
53
54
  localeKey?: IFilterLocaleKey;
54
55
  locale?: IPartialFilterLocale;
@@ -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';
@@ -1,25 +1,25 @@
1
- import { ITweakStyles, createThemedStyles } from '../../../../theme';
2
- import { IFlexibleTableCellStyles } from '../FlexibleTableCell';
3
-
4
- export const useStyles = createThemedStyles('FlexibleTableRow', {
5
- root: {
6
- position: 'relative',
7
- },
8
-
9
- active: {},
10
-
11
- editable: {
12
- cursor: 'pointer',
13
- },
14
-
15
- clickable: {
16
- cursor: 'pointer',
17
- },
18
-
19
- nestedComponent: {},
20
- });
21
-
22
- export type IFlexibleTableRowStyles = ITweakStyles<
23
- typeof useStyles,
24
- { tweakTableCell: IFlexibleTableCellStyles }
25
- >;
1
+ import { ITweakStyles, createThemedStyles } from '../../../../theme';
2
+ import { IFlexibleTableCellStyles } from '../FlexibleTableCell';
3
+
4
+ export const useStyles = createThemedStyles('FlexibleTableRow', {
5
+ root: {
6
+ position: 'relative',
7
+ },
8
+
9
+ active: {},
10
+
11
+ editable: {
12
+ cursor: 'pointer',
13
+ },
14
+
15
+ clickable: {
16
+ cursor: 'pointer',
17
+ },
18
+
19
+ nestedComponent: {},
20
+ });
21
+
22
+ export type IFlexibleTableRowStyles = ITweakStyles<
23
+ typeof useStyles,
24
+ { tweakTableCell: IFlexibleTableCellStyles }
25
+ >;