@true-engineering/true-react-common-ui-kit 3.45.1 → 3.45.3
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 +7 -1
- package/dist/components/Flag/customFlags/customFlags.d.ts +10 -0
- package/dist/components/Flag/customFlags/index.d.ts +1 -0
- package/dist/true-react-common-ui-kit.js +63 -9
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +63 -9
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- 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/PhoneInput/PhoneInput.stories.tsx +1 -0
- package/src/components/PhoneInput/PhoneInput.tsx +1 -1
- package/src/constants/phone-info.ts +17 -0
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { countries } from 'country-flag-icons';
|
|
2
2
|
import { ComponentStory } from '@storybook/react';
|
|
3
3
|
import { Flag } from './Flag';
|
|
4
|
+
import { customFlags } from './customFlags';
|
|
4
5
|
|
|
5
6
|
export default {
|
|
6
7
|
title: 'Data Display/Flag',
|
|
7
8
|
component: Flag,
|
|
8
9
|
argTypes: {
|
|
9
|
-
countryCode: { control: 'select', options: countries },
|
|
10
|
+
countryCode: { control: 'select', options: [...countries, ...Object.keys(customFlags)] },
|
|
10
11
|
},
|
|
11
12
|
};
|
|
12
13
|
|
|
@@ -2,6 +2,10 @@ import { colors, ITweakStyles, createThemedStyles } from '../../theme';
|
|
|
2
2
|
|
|
3
3
|
export const useStyles = createThemedStyles('Flag', {
|
|
4
4
|
root: {
|
|
5
|
+
display: 'flex',
|
|
6
|
+
width: '100%',
|
|
7
|
+
height: '100%',
|
|
8
|
+
boxSizing: 'border-box',
|
|
5
9
|
// приходится хардкодить в компоненте, тк либа Flags выдает флаги с 2-3 пиксельным отступом снизу
|
|
6
10
|
// если будет нужно, то можно вынести border на уровень пропсов
|
|
7
11
|
border: [1, 'solid', colors.BORDER_MAIN],
|
|
@@ -3,6 +3,7 @@ import { hasFlag } from 'country-flag-icons';
|
|
|
3
3
|
import Flags from 'country-flag-icons/react/3x2';
|
|
4
4
|
import { ICommonProps } from '../../types';
|
|
5
5
|
import { Icon } from '../Icon';
|
|
6
|
+
import { customFlags } from './customFlags';
|
|
6
7
|
import { useStyles, IFlagStyles } from './Flag.styles';
|
|
7
8
|
|
|
8
9
|
export interface IFlagProps extends Pick<ICommonProps<IFlagStyles>, 'tweakStyles'> {
|
|
@@ -12,15 +13,28 @@ export interface IFlagProps extends Pick<ICommonProps<IFlagStyles>, 'tweakStyles
|
|
|
12
13
|
|
|
13
14
|
export const Flag: FC<IFlagProps> = ({ countryCode = '', tweakStyles }) => {
|
|
14
15
|
const classes = useStyles({ theme: tweakStyles });
|
|
15
|
-
const
|
|
16
|
+
const countryFlagKey = countryCode.toUpperCase();
|
|
16
17
|
|
|
17
|
-
const
|
|
18
|
-
? Flags[CC as keyof typeof Flags]
|
|
19
|
-
: () => (
|
|
20
|
-
<div className={classes.noFlag}>
|
|
21
|
-
<Icon type="minus" />
|
|
22
|
-
</div>
|
|
23
|
-
);
|
|
18
|
+
const hasFlagInLibrary = hasFlag(countryFlagKey);
|
|
24
19
|
|
|
25
|
-
|
|
20
|
+
if (hasFlagInLibrary) {
|
|
21
|
+
const FlagComponent = Flags[countryFlagKey as keyof typeof Flags];
|
|
22
|
+
return (
|
|
23
|
+
<div className={classes.root}>
|
|
24
|
+
<FlagComponent />
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const CustomFlag = customFlags[countryFlagKey as keyof typeof customFlags];
|
|
30
|
+
|
|
31
|
+
if (CustomFlag !== undefined) {
|
|
32
|
+
return <div className={classes.root} dangerouslySetInnerHTML={{ __html: CustomFlag }} />;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className={classes.noFlag}>
|
|
37
|
+
<Icon type="minus" />
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
26
40
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#FFF" d="M0 0h512v341.3H0z"/><g fill="#6DA544"><path d="M0 0h512v48.8H0zM0 97.5h512v48.8H0zM0 195h512v48.8H0zM0 292.6h512v48.8H0z"/></g><path fill="#D80027" d="M0 0h256v146.3H0z"/><path fill="#FFF" d="m116.9 114.4-7.5-14.8V69.9L128 59l18.6 10.9v22.3l7.4-7.4 4.2 3-4.2 11.8-14.9 14.8z"/><circle fill="#FFF" cx="82" cy="82.8" r="5.4"/><circle fill="#FFF" cx="90.8" cy="61.7" r="5.4"/><circle fill="#FFF" cx="106.6" cy="46.2" r="5.4"/><circle fill="#FFF" cx="128" cy="40.8" r="5.4"/><circle fill="#FFF" cx="149.4" cy="46.2" r="5.4"/><circle fill="#FFF" cx="165.2" cy="61.7" r="5.4"/><circle fill="#FFF" cx="174" cy="82.8" r="5.4"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 450 300"><path fill="#FFF" d="M0 0h450v300H0z"/><path fill="red" d="M0 100h450v200H0z"/><path fill="#FFDF00" d="M0 200h450v100H0z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module '*.svg?raw';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './customFlags';
|
|
@@ -27,6 +27,7 @@ const Template: ComponentStory<typeof PhoneInput> = (args) => {
|
|
|
27
27
|
const [value, setValue] = useState<IPhoneValue>({
|
|
28
28
|
dialCode: '7',
|
|
29
29
|
phoneNumber: '1234567890',
|
|
30
|
+
countryCode: 'RU',
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
return <PhoneInput {...args} value={value} onChange={setValue} />;
|
|
@@ -79,7 +79,7 @@ export const PhoneInput: FC<IPhoneInputProps> = ({
|
|
|
79
79
|
|
|
80
80
|
const countryCode = useMemo(
|
|
81
81
|
() => value?.countryCode ?? getCountryCodeFromPhone(phoneWithCode),
|
|
82
|
-
[value.dialCode, value.phoneNumber],
|
|
82
|
+
[value.countryCode, value.dialCode, value.phoneNumber],
|
|
83
83
|
);
|
|
84
84
|
|
|
85
85
|
const handleClose = () => {
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import type { IPhoneInfo } from '../components';
|
|
2
2
|
|
|
3
3
|
export const phoneInfo: IPhoneInfo[] = [
|
|
4
|
+
{
|
|
5
|
+
countryEn: 'Abkhazia',
|
|
6
|
+
countryRu: 'Абхазия',
|
|
7
|
+
countryCode: 'AB',
|
|
8
|
+
phoneMask: '999 999-99-99',
|
|
9
|
+
dialCode: '7',
|
|
10
|
+
areaCodes: ['840', '940'],
|
|
11
|
+
fullCodes: ['7840', '7940'],
|
|
12
|
+
},
|
|
4
13
|
{
|
|
5
14
|
countryEn: 'Afghanistan',
|
|
6
15
|
countryRu: 'Афганистан',
|
|
@@ -1404,6 +1413,14 @@ export const phoneInfo: IPhoneInfo[] = [
|
|
|
1404
1413
|
phoneMask: '999 9999 9999',
|
|
1405
1414
|
fullCodes: ['82'],
|
|
1406
1415
|
},
|
|
1416
|
+
{
|
|
1417
|
+
countryCode: 'OS',
|
|
1418
|
+
countryEn: 'South Ossetia',
|
|
1419
|
+
countryRu: 'Южная Осетия',
|
|
1420
|
+
phoneMask: '999 999-99-99',
|
|
1421
|
+
dialCode: '7',
|
|
1422
|
+
fullCodes: ['7'],
|
|
1423
|
+
},
|
|
1407
1424
|
{
|
|
1408
1425
|
countryEn: 'South Sudan',
|
|
1409
1426
|
countryRu: 'Южный Судан',
|