@cdek-it/react-native-ui-kit 0.2.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.
- package/LICENSE +21 -0
- package/README.md +151 -0
- package/dist/components/Accordion/Accordion.d.ts +39 -0
- package/dist/components/Accordion/Accordion.js +103 -0
- package/dist/components/Accordion/index.d.ts +1 -0
- package/dist/components/Accordion/index.js +1 -0
- package/dist/components/Avatar/Avatar.d.ts +96 -0
- package/dist/components/Avatar/Avatar.js +121 -0
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Avatar/index.js +1 -0
- package/dist/components/Badge/Badge.d.ts +35 -0
- package/dist/components/Badge/Badge.js +74 -0
- package/dist/components/Badge/index.d.ts +1 -0
- package/dist/components/Badge/index.js +1 -0
- package/dist/components/Button/BaseButton.d.ts +5 -0
- package/dist/components/Button/BaseButton.js +62 -0
- package/dist/components/Button/Button.d.ts +16 -0
- package/dist/components/Button/Button.js +21 -0
- package/dist/components/Button/ButtonBadge.d.ts +21 -0
- package/dist/components/Button/ButtonBadge.js +53 -0
- package/dist/components/Button/ButtonSeverity.d.ts +17 -0
- package/dist/components/Button/ButtonSeverity.js +22 -0
- package/dist/components/Button/index.d.ts +4 -0
- package/dist/components/Button/index.js +3 -0
- package/dist/components/Button/styles/index.d.ts +2 -0
- package/dist/components/Button/styles/index.js +2 -0
- package/dist/components/Button/styles/useBasicButtonStyles.d.ts +98 -0
- package/dist/components/Button/styles/useBasicButtonStyles.js +81 -0
- package/dist/components/Button/styles/useDangerButtonStyles.d.ts +63 -0
- package/dist/components/Button/styles/useDangerButtonStyles.js +57 -0
- package/dist/components/Button/styles/useInfoButtonStyles.d.ts +63 -0
- package/dist/components/Button/styles/useInfoButtonStyles.js +56 -0
- package/dist/components/Button/styles/useSeverityButtonStyles.d.ts +64 -0
- package/dist/components/Button/styles/useSeverityButtonStyles.js +29 -0
- package/dist/components/Button/styles/useSuccessButtonStyles.d.ts +63 -0
- package/dist/components/Button/styles/useSuccessButtonStyles.js +61 -0
- package/dist/components/Button/styles/useWarningButtonStyles.d.ts +63 -0
- package/dist/components/Button/styles/useWarningButtonStyles.js +61 -0
- package/dist/components/Button/types.d.ts +107 -0
- package/dist/components/Button/types.js +0 -0
- package/dist/components/Button/utils/ButtonActivityIndicator.d.ts +3 -0
- package/dist/components/Button/utils/ButtonActivityIndicator.js +17 -0
- package/dist/components/Button/utils/ButtonContainer.d.ts +7 -0
- package/dist/components/Button/utils/ButtonContainer.js +10 -0
- package/dist/components/Button/utils/ButtonIcon.d.ts +4 -0
- package/dist/components/Button/utils/ButtonIcon.js +11 -0
- package/dist/components/Button/utils/ButtonLabel.d.ts +4 -0
- package/dist/components/Button/utils/ButtonLabel.js +13 -0
- package/dist/components/Button/utils/ButtonLeftArea.d.ts +4 -0
- package/dist/components/Button/utils/ButtonLeftArea.js +13 -0
- package/dist/components/Button/utils/ButtonRightArea.d.ts +3 -0
- package/dist/components/Button/utils/ButtonRightArea.js +13 -0
- package/dist/components/Button/utils/index.d.ts +4 -0
- package/dist/components/Button/utils/index.js +4 -0
- package/dist/components/Button/utils/useButtonContainerCallbackStyle.d.ts +3 -0
- package/dist/components/Button/utils/useButtonContainerCallbackStyle.js +141 -0
- package/dist/components/Button/utils/useButtonLabelStyle.d.ts +3 -0
- package/dist/components/Button/utils/useButtonLabelStyle.js +40 -0
- package/dist/components/Button/utils/useIconStyle.d.ts +7 -0
- package/dist/components/Button/utils/useIconStyle.js +35 -0
- package/dist/components/Button/utils/useTypeBasedStyle.d.ts +2 -0
- package/dist/components/Button/utils/useTypeBasedStyle.js +4 -0
- package/dist/components/Checkbox/Checkbox.d.ts +31 -0
- package/dist/components/Checkbox/Checkbox.js +55 -0
- package/dist/components/Checkbox/hooks/usePressableStyles.d.ts +15 -0
- package/dist/components/Checkbox/hooks/usePressableStyles.js +91 -0
- package/dist/components/Checkbox/index.d.ts +1 -0
- package/dist/components/Checkbox/index.js +1 -0
- package/dist/components/Chip/Chip.d.ts +30 -0
- package/dist/components/Chip/Chip.js +70 -0
- package/dist/components/Chip/index.d.ts +1 -0
- package/dist/components/Chip/index.js +1 -0
- package/dist/components/Dialog/Dialog.d.ts +14 -0
- package/dist/components/Dialog/Dialog.js +96 -0
- package/dist/components/Dialog/DialogComponent.d.ts +7 -0
- package/dist/components/Dialog/DialogComponent.js +34 -0
- package/dist/components/Dialog/DialogHeader.d.ts +12 -0
- package/dist/components/Dialog/DialogHeader.js +68 -0
- package/dist/components/Dialog/index.d.ts +3 -0
- package/dist/components/Dialog/index.js +3 -0
- package/dist/components/Divider/Divider.d.ts +42 -0
- package/dist/components/Divider/Divider.js +95 -0
- package/dist/components/Divider/index.d.ts +1 -0
- package/dist/components/Divider/index.js +1 -0
- package/dist/components/Input/FloatLabel.d.ts +22 -0
- package/dist/components/Input/FloatLabel.js +19 -0
- package/dist/components/Input/InputGroup.d.ts +21 -0
- package/dist/components/Input/InputGroup.js +52 -0
- package/dist/components/Input/InputGroupAddon.d.ts +17 -0
- package/dist/components/Input/InputGroupAddon.js +57 -0
- package/dist/components/Input/InputSwitch/InputSwitch.d.ts +8 -0
- package/dist/components/Input/InputSwitch/InputSwitch.js +16 -0
- package/dist/components/Input/InputSwitch/index.d.ts +1 -0
- package/dist/components/Input/InputSwitch/index.js +1 -0
- package/dist/components/Input/InputSwitch/styles/index.d.ts +2 -0
- package/dist/components/Input/InputSwitch/styles/index.js +2 -0
- package/dist/components/Input/InputSwitch/styles/useHandleStyles.d.ts +13 -0
- package/dist/components/Input/InputSwitch/styles/useHandleStyles.js +47 -0
- package/dist/components/Input/InputSwitch/styles/useSliderStyles.d.ts +17 -0
- package/dist/components/Input/InputSwitch/styles/useSliderStyles.js +95 -0
- package/dist/components/Input/InputText.d.ts +13 -0
- package/dist/components/Input/InputText.js +14 -0
- package/dist/components/Input/InputTextBase/InputTextBase.d.ts +13 -0
- package/dist/components/Input/InputTextBase/InputTextBase.js +124 -0
- package/dist/components/Input/InputTextBase/testIds.d.ts +11 -0
- package/dist/components/Input/InputTextBase/testIds.js +11 -0
- package/dist/components/Input/InputTextBase/types.d.ts +41 -0
- package/dist/components/Input/InputTextBase/types.js +0 -0
- package/dist/components/Input/InputTextBase/useStyles.d.ts +86 -0
- package/dist/components/Input/InputTextBase/useStyles.js +78 -0
- package/dist/components/Input/index.d.ts +5 -0
- package/dist/components/Input/index.js +4 -0
- package/dist/components/List/Base/ListBase.d.ts +32 -0
- package/dist/components/List/Base/ListBase.js +88 -0
- package/dist/components/List/Base/index.d.ts +1 -0
- package/dist/components/List/Base/index.js +1 -0
- package/dist/components/MenuItem/MenuItemAccessory.d.ts +11 -0
- package/dist/components/MenuItem/MenuItemAccessory.js +23 -0
- package/dist/components/MenuItem/MenuItemIcon.d.ts +36 -0
- package/dist/components/MenuItem/MenuItemIcon.js +33 -0
- package/dist/components/MenuItem/Template/MenuItemTemplate.d.ts +42 -0
- package/dist/components/MenuItem/Template/MenuItemTemplate.js +79 -0
- package/dist/components/MenuItem/index.d.ts +1 -0
- package/dist/components/MenuItem/index.js +1 -0
- package/dist/components/Message/Message.d.ts +65 -0
- package/dist/components/Message/Message.js +126 -0
- package/dist/components/Message/index.d.ts +1 -0
- package/dist/components/Message/index.js +1 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +33 -0
- package/dist/components/ProgressBar/ProgressBar.js +62 -0
- package/dist/components/ProgressBar/index.d.ts +1 -0
- package/dist/components/ProgressBar/index.js +1 -0
- package/dist/components/ProgressSpinner/ProgressSpinner.d.ts +17 -0
- package/dist/components/ProgressSpinner/ProgressSpinner.js +68 -0
- package/dist/components/ProgressSpinner/index.d.ts +1 -0
- package/dist/components/ProgressSpinner/index.js +1 -0
- package/dist/components/RadioButton/RadioButton.d.ts +18 -0
- package/dist/components/RadioButton/RadioButton.js +134 -0
- package/dist/components/RadioButton/index.d.ts +1 -0
- package/dist/components/RadioButton/index.js +1 -0
- package/dist/components/Rating/Rating.d.ts +48 -0
- package/dist/components/Rating/Rating.js +37 -0
- package/dist/components/Rating/RatingClear.d.ts +14 -0
- package/dist/components/Rating/RatingClear.js +28 -0
- package/dist/components/Rating/RatingItem.d.ts +19 -0
- package/dist/components/Rating/RatingItem.js +44 -0
- package/dist/components/Rating/RatingItemContainer.d.ts +37 -0
- package/dist/components/Rating/RatingItemContainer.js +30 -0
- package/dist/components/Rating/index.d.ts +1 -0
- package/dist/components/Rating/index.js +1 -0
- package/dist/components/SelectButton/SelectButton.d.ts +32 -0
- package/dist/components/SelectButton/SelectButton.js +75 -0
- package/dist/components/SelectButton/SelectButtonItem.d.ts +35 -0
- package/dist/components/SelectButton/SelectButtonItem.js +133 -0
- package/dist/components/SelectButton/index.d.ts +1 -0
- package/dist/components/SelectButton/index.js +1 -0
- package/dist/components/Skeleton/Skeleton.d.ts +15 -0
- package/dist/components/Skeleton/Skeleton.js +53 -0
- package/dist/components/Skeleton/index.d.ts +1 -0
- package/dist/components/Skeleton/index.js +1 -0
- package/dist/components/Slider/Slider.d.ts +36 -0
- package/dist/components/Slider/Slider.js +153 -0
- package/dist/components/Slider/index.d.ts +1 -0
- package/dist/components/Slider/index.js +1 -0
- package/dist/components/Tabs/TabItem/TabItem.d.ts +24 -0
- package/dist/components/Tabs/TabItem/TabItem.js +82 -0
- package/dist/components/Tabs/TabItem/index.d.ts +1 -0
- package/dist/components/Tabs/TabItem/index.js +1 -0
- package/dist/components/Tabs/TabPanel/TabPanel.d.ts +9 -0
- package/dist/components/Tabs/TabPanel/TabPanel.js +11 -0
- package/dist/components/Tabs/TabPanel/index.d.ts +1 -0
- package/dist/components/Tabs/TabPanel/index.js +1 -0
- package/dist/components/Tabs/Tabs.d.ts +15 -0
- package/dist/components/Tabs/Tabs.js +48 -0
- package/dist/components/Tabs/index.d.ts +2 -0
- package/dist/components/Tabs/index.js +2 -0
- package/dist/components/Tag/Tag.d.ts +33 -0
- package/dist/components/Tag/Tag.js +71 -0
- package/dist/components/Tag/index.d.ts +1 -0
- package/dist/components/Tag/index.js +1 -0
- package/dist/components/Timer/Timer.d.ts +18 -0
- package/dist/components/Timer/Timer.js +74 -0
- package/dist/components/Timer/TimerFlip.d.ts +7 -0
- package/dist/components/Timer/TimerFlip.js +69 -0
- package/dist/components/Timer/constants.d.ts +1 -0
- package/dist/components/Timer/constants.js +1 -0
- package/dist/components/ToggleButton/ToggleButton.d.ts +45 -0
- package/dist/components/ToggleButton/ToggleButton.js +85 -0
- package/dist/components/ToggleButton/hooks/useIconSize.d.ts +14 -0
- package/dist/components/ToggleButton/hooks/useIconSize.js +26 -0
- package/dist/components/ToggleButton/hooks/useLabelSize.d.ts +8 -0
- package/dist/components/ToggleButton/hooks/useLabelSize.js +19 -0
- package/dist/components/ToggleButton/hooks/useStateStyles.d.ts +11 -0
- package/dist/components/ToggleButton/hooks/useStateStyles.js +92 -0
- package/dist/components/ToggleButton/index.d.ts +1 -0
- package/dist/components/ToggleButton/index.js +1 -0
- package/dist/components/Typography/Anchor.d.ts +31 -0
- package/dist/components/Typography/Anchor.js +75 -0
- package/dist/components/Typography/Body.d.ts +9 -0
- package/dist/components/Typography/Body.js +32 -0
- package/dist/components/Typography/Caption.d.ts +9 -0
- package/dist/components/Typography/Caption.js +38 -0
- package/dist/components/Typography/Service.d.ts +25 -0
- package/dist/components/Typography/Service.js +63 -0
- package/dist/components/Typography/Subtitle.d.ts +18 -0
- package/dist/components/Typography/Subtitle.js +23 -0
- package/dist/components/Typography/Title.d.ts +5 -0
- package/dist/components/Typography/Title.js +24 -0
- package/dist/components/Typography/index.d.ts +6 -0
- package/dist/components/Typography/index.js +6 -0
- package/dist/components/index.d.ts +23 -0
- package/dist/components/index.js +23 -0
- package/dist/hooks/useChangeTheme.d.ts +1 -0
- package/dist/hooks/useChangeTheme.js +5 -0
- package/dist/hooks/useFonts.d.ts +1 -0
- package/dist/hooks/useFonts.js +5 -0
- package/dist/hooks/useLoadingRotationAnimation.d.ts +5 -0
- package/dist/hooks/useLoadingRotationAnimation.js +19 -0
- package/dist/hooks/useMakeTestId.d.ts +3 -0
- package/dist/hooks/useMakeTestId.js +7 -0
- package/dist/hooks/useTheme.d.ts +1 -0
- package/dist/hooks/useTheme.js +5 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/theme/ThemeContext.d.ts +15 -0
- package/dist/theme/ThemeContext.js +20 -0
- package/dist/theme/assets/background.json +149 -0
- package/dist/theme/assets/border.json +103 -0
- package/dist/theme/assets/customCommon.d.ts +4 -0
- package/dist/theme/assets/customCommon.js +4 -0
- package/dist/theme/assets/customDark.d.ts +5 -0
- package/dist/theme/assets/customDark.js +15 -0
- package/dist/theme/assets/customLight.d.ts +15 -0
- package/dist/theme/assets/customLight.js +15 -0
- package/dist/theme/assets/effects.json +15 -0
- package/dist/theme/assets/global.json +114 -0
- package/dist/theme/assets/primaryColors.json +14 -0
- package/dist/theme/assets/shadow.d.ts +6 -0
- package/dist/theme/assets/shadow.js +6 -0
- package/dist/theme/assets/sizing.json +78 -0
- package/dist/theme/assets/spacing.json +48 -0
- package/dist/theme/assets/themeDark.json +1141 -0
- package/dist/theme/assets/themeLight.json +1141 -0
- package/dist/theme/assets/typography.json +45 -0
- package/dist/theme/commonTheme.d.ts +582 -0
- package/dist/theme/commonTheme.js +22 -0
- package/dist/theme/darkTheme.d.ts +2 -0
- package/dist/theme/darkTheme.js +7 -0
- package/dist/theme/index.d.ts +4 -0
- package/dist/theme/index.js +4 -0
- package/dist/theme/lightTheme.d.ts +2 -0
- package/dist/theme/lightTheme.js +7 -0
- package/dist/theme/types.d.ts +40 -0
- package/dist/theme/types.js +5 -0
- package/dist/utils/SvgUniversal.d.ts +29 -0
- package/dist/utils/SvgUniversal.js +28 -0
- package/dist/utils/genericMemo.d.ts +1 -0
- package/dist/utils/genericMemo.js +2 -0
- package/dist/utils/makeStyles.d.ts +11 -0
- package/dist/utils/makeStyles.js +19 -0
- package/package.json +159 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 CDEK-IT
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# react-native-ui-kit
|
|
2
|
+
|
|
3
|
+
Репозиторий UI kit на основе Prime Faces, Prime Flex для React Native
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
yarn add --save-exact @cdek-it/react-native-prime-ui-kit
|
|
9
|
+
yarn add react react-native @tabler/icons-react-native react-native-svg react-native-reanimateds
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Шрифты
|
|
13
|
+
|
|
14
|
+
UI kit использует следующие виды шрифтов.
|
|
15
|
+
|
|
16
|
+
| Тип шрифта | Используемые начертания | Рекомендуемый шрифт | Рекомендуемый аналог |
|
|
17
|
+
| ----------- | ---------------------------------------------- | ------------------- | -------------------- |
|
|
18
|
+
| `primary` | – regular<br/>– demibold<br/>– demibold italic | TT Fellows | PT Sans |
|
|
19
|
+
| `secondary` | – regular<br/>– bold | PT Sans | — |
|
|
20
|
+
|
|
21
|
+
Исходники шрифтов не поставляются вместе с пакетом, их требуется подключать
|
|
22
|
+
отдельно. После подключения шрифтов в проект, необходимо указать их в
|
|
23
|
+
`ThemeContextProvider`.
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
<ThemeContextProvider
|
|
27
|
+
fonts={{ primary: 'MyFont', secondary: 'MySecondaryFont' }}
|
|
28
|
+
/>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Пример подключения шрифтов с помощью expo-fonts через плагин
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
[
|
|
35
|
+
'expo-font',
|
|
36
|
+
{
|
|
37
|
+
android: {
|
|
38
|
+
fonts: [
|
|
39
|
+
{
|
|
40
|
+
fontFamily: 'TT Fellows',
|
|
41
|
+
fontDefinitions: [
|
|
42
|
+
{
|
|
43
|
+
path: './assets/fonts/TTFellows-DemiBoldItalic.ttf',
|
|
44
|
+
weight: 600,
|
|
45
|
+
style: 'italic',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
path: './assets/fonts/TTFellows-DemiBold.ttf',
|
|
49
|
+
weight: 600,
|
|
50
|
+
},
|
|
51
|
+
{ path: './assets/fonts/TTFellows-Regular.ttf', weight: 400 },
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
fontFamily: 'PT Sans',
|
|
56
|
+
fontDefinitions: [
|
|
57
|
+
{ path: './assets/fonts/PTSans-Bold.ttf', weight: 700 },
|
|
58
|
+
{ path: './assets/fonts/PTSans-Regular.ttf', weight: 400 },
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Ручная установка
|
|
68
|
+
|
|
69
|
+
#### Android
|
|
70
|
+
|
|
71
|
+
1. Скопировать нужные шрифты в директорию `android/app/src/main/res/font`
|
|
72
|
+
2. Создать XML-ресурс для каждого шрифта
|
|
73
|
+
|
|
74
|
+
```xml
|
|
75
|
+
<!-- xml_pt_sans.xml -->
|
|
76
|
+
<font-family xmlns:app="http://schemas.android.com/apk/res-auto">
|
|
77
|
+
<font app:font="@font/pt_sans_bold" app:fontStyle="normal" app:fontWeight="700"/>
|
|
78
|
+
<font app:font="@font/pt_sans_regular" app:fontStyle="normal" app:fontWeight="400"/>
|
|
79
|
+
</font-family>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```xml
|
|
83
|
+
<!-- xml_tt_fellows.xml -->
|
|
84
|
+
<font-family xmlns:app="http://schemas.android.com/apk/res-auto">
|
|
85
|
+
<font app:font="@font/tt_fellows_demi_bold_italic" app:fontStyle="italic" app:fontWeight="600"/>
|
|
86
|
+
<font app:font="@font/tt_fellows_demi_bold" app:fontStyle="normal" app:fontWeight="600"/>
|
|
87
|
+
<font app:font="@font/tt_fellows_regular" app:fontStyle="normal" app:fontWeight="400"/>
|
|
88
|
+
</font-family>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
3. Добавить в метод `onCreate()` класса
|
|
92
|
+
[MainApplication](./android/app/src/main/java/ru/cdek/uikit/prime/MainApplication.kt)
|
|
93
|
+
следующий код:
|
|
94
|
+
|
|
95
|
+
```kotlin
|
|
96
|
+
override fun onCreate() {
|
|
97
|
+
super.onCreate()
|
|
98
|
+
|
|
99
|
+
//подключение шрифтов
|
|
100
|
+
ReactFontManager.getInstance().addCustomFont(this, "TT Fellows", R.font.xml_tt_fellows)
|
|
101
|
+
ReactFontManager.getInstance().addCustomFont(this, "PT Sans", R.font.xml_pt_sans)
|
|
102
|
+
|
|
103
|
+
// остальной код...
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### iOS
|
|
108
|
+
|
|
109
|
+
1. Добавить шрифты в проект Xcode
|
|
110
|
+
|
|
111
|
+
Для этого открыть Xcode вашего проекта, создать новую группу Resources
|
|
112
|
+
(опционально), перетащить туда файлы с шрифтами.
|
|
113
|
+
|
|
114
|
+
Можно выбрать Copy files или Reference files, на ваш выбор
|
|
115
|
+
|
|
116
|
+

|
|
117
|
+
|
|
118
|
+
2. Добавить информацию о шрифтах в [Info.plist](./ios/CDEKUI/Info.plist)
|
|
119
|
+
|
|
120
|
+
```xml
|
|
121
|
+
<key>UIAppFonts</key>
|
|
122
|
+
<array>
|
|
123
|
+
<string>TTFellows-DemiBold.ttf</string>
|
|
124
|
+
<string>TTFellows-DemiBoldItalic.ttf</string>
|
|
125
|
+
<string>TTFellows-Regular.ttf</string>
|
|
126
|
+
<string>PTSans-Bold.ttf</string>
|
|
127
|
+
<string>PTSans-Regular.ttf</string>
|
|
128
|
+
</array>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Dependencies
|
|
132
|
+
|
|
133
|
+
Для использования данной библиотеки необходимо:
|
|
134
|
+
|
|
135
|
+
- react версии - начиная с 18 major версии (от 18.0.0)
|
|
136
|
+
- react-native - любой версии(оптимально - от 0.74)
|
|
137
|
+
- @tabler/icons-react-native - начиная с 3 major версии(от 3.0.0)
|
|
138
|
+
- react-native-svg - начиная с 15 major версии(от 15.0.0)
|
|
139
|
+
- react-native-reanimated - начиная с 3 major версии(от 3.0.0)
|
|
140
|
+
|
|
141
|
+
## Development
|
|
142
|
+
|
|
143
|
+
`yarn install` - установка зависимостей `yarn start` - запуск Metro Bundler для
|
|
144
|
+
Storybook `yarn ios` - запуск Storybook на iOS `yarn android` - запуск Storybook
|
|
145
|
+
на Android\
|
|
146
|
+
|
|
147
|
+
Storybook проект создан с помощью Expo
|
|
148
|
+
|
|
149
|
+
### Макеты
|
|
150
|
+
|
|
151
|
+
[https://developer.cdek.ru/design-system](https://developer.cdek.ru/design-system)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ViewProps } from 'react-native-svg/lib/typescript/fabric/utils';
|
|
3
|
+
import { type SvgSource } from '../../utils/SvgUniversal';
|
|
4
|
+
export interface AccordionProps extends ViewProps {
|
|
5
|
+
/** Иконка слева от заголовка */
|
|
6
|
+
readonly Icon?: SvgSource;
|
|
7
|
+
/** Текст заголовка */
|
|
8
|
+
readonly title: string;
|
|
9
|
+
/** Состояние при первом рендере. true - контент раскрыт, false - контент свернут */
|
|
10
|
+
readonly isInitiallyExpanded?: boolean;
|
|
11
|
+
/** Наличие разделитель. Когда true, верхняя граница заголовка становится разделителем */
|
|
12
|
+
readonly withSeparator?: boolean;
|
|
13
|
+
/** Отключенное состояние. Когда true компонент рендерится в соответствии со значением isInitiallyExpanded и не реагирует на нажатия */
|
|
14
|
+
readonly disabled?: boolean;
|
|
15
|
+
/** Дополнительный элемент справа от заголовка */
|
|
16
|
+
readonly titleExtra?: React.ReactNode;
|
|
17
|
+
readonly children: React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Компонент Гармошка - умеет скрывать и раскрывать контент по нажатию на заголовок
|
|
21
|
+
* @param title - Текст заголовка
|
|
22
|
+
* @param Icon - Иконка слева от заголовка
|
|
23
|
+
* @param isInitiallyExpanded - Состояние при первом рендере. true - контент раскрыт, false - контент свернут
|
|
24
|
+
* @param extra - Дополнительный элемент справа от заголовка
|
|
25
|
+
* @param withSeparator - Наличие разделитель. Когда true, верхняя граница заголовка становится разделителем
|
|
26
|
+
* @param disabled - Отключенное состояние. Когда true компонент рендерится в соответствии со значением isInitiallyExpanded и не реагирует на нажатия
|
|
27
|
+
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace--DS-?node-id=1207-1852&m=dev
|
|
28
|
+
*/
|
|
29
|
+
export declare const Accordion: React.FC<AccordionProps>;
|
|
30
|
+
export declare const AccordionTestIds: {
|
|
31
|
+
component: string;
|
|
32
|
+
header: string;
|
|
33
|
+
arrow: string;
|
|
34
|
+
icon: string;
|
|
35
|
+
titleExtra: string;
|
|
36
|
+
content: string;
|
|
37
|
+
contentWrapper: string;
|
|
38
|
+
separator: string;
|
|
39
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { IconChevronRight } from '@tabler/icons-react-native';
|
|
2
|
+
import React, { useCallback, useState } from 'react';
|
|
3
|
+
import { View, Text, Pressable } from 'react-native';
|
|
4
|
+
import Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated';
|
|
5
|
+
import { SvgUniversal } from '../../utils/SvgUniversal';
|
|
6
|
+
import { makeStyles } from '../../utils/makeStyles';
|
|
7
|
+
/**
|
|
8
|
+
* Компонент Гармошка - умеет скрывать и раскрывать контент по нажатию на заголовок
|
|
9
|
+
* @param title - Текст заголовка
|
|
10
|
+
* @param Icon - Иконка слева от заголовка
|
|
11
|
+
* @param isInitiallyExpanded - Состояние при первом рендере. true - контент раскрыт, false - контент свернут
|
|
12
|
+
* @param extra - Дополнительный элемент справа от заголовка
|
|
13
|
+
* @param withSeparator - Наличие разделитель. Когда true, верхняя граница заголовка становится разделителем
|
|
14
|
+
* @param disabled - Отключенное состояние. Когда true компонент рендерится в соответствии со значением isInitiallyExpanded и не реагирует на нажатия
|
|
15
|
+
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace--DS-?node-id=1207-1852&m=dev
|
|
16
|
+
*/
|
|
17
|
+
export const Accordion = ({ Icon, title, isInitiallyExpanded: initiallyExpanded = false, withSeparator = false, disabled = false, titleExtra, testID, children, ...rest }) => {
|
|
18
|
+
const styles = useStyles();
|
|
19
|
+
const contentHeight = useSharedValue(0);
|
|
20
|
+
const contentOpenFraction = useSharedValue(initiallyExpanded ? 1 : 0);
|
|
21
|
+
const [isExpanded, setIsExpanded] = useState(initiallyExpanded);
|
|
22
|
+
const onLayout = useCallback((event) => {
|
|
23
|
+
contentHeight.value = event.nativeEvent.layout.height;
|
|
24
|
+
}, [contentHeight]);
|
|
25
|
+
const toggle = useCallback(() => {
|
|
26
|
+
contentOpenFraction.value = withTiming(contentOpenFraction.value > 0 ? 0 : 1);
|
|
27
|
+
setIsExpanded((value) => !value);
|
|
28
|
+
}, [contentOpenFraction]);
|
|
29
|
+
const arrowAnimatedStyle = useAnimatedStyle(() => ({
|
|
30
|
+
transform: [
|
|
31
|
+
{
|
|
32
|
+
rotate: `${interpolate(contentOpenFraction.value, [0, 1], [0, 90])}deg`,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
}));
|
|
36
|
+
const contentAnimatedStyle = useAnimatedStyle(() => ({
|
|
37
|
+
height: interpolate(contentOpenFraction.value, [0, 1], [0, contentHeight.value]),
|
|
38
|
+
opacity: contentOpenFraction.value,
|
|
39
|
+
}));
|
|
40
|
+
return (<View style={[styles.component, withSeparator ? styles.separator : {}]} testID={testID || AccordionTestIds.component} {...rest}>
|
|
41
|
+
<Pressable accessible accessibilityLabel={title} accessibilityRole='button' accessibilityState={isExpanded ? { expanded: true } : {}} disabled={disabled} style={[styles.header, disabled ? styles.disabled : {}]} testID={AccordionTestIds.header} onPress={toggle}>
|
|
42
|
+
<Animated.View style={arrowAnimatedStyle} testID={AccordionTestIds.arrow}>
|
|
43
|
+
<IconChevronRight {...styles.icon}/>
|
|
44
|
+
</Animated.View>
|
|
45
|
+
{Icon ? (<SvgUniversal source={Icon} {...styles.icon} testID={AccordionTestIds.icon}/>) : null}
|
|
46
|
+
<Text style={styles.title}>{title}</Text>
|
|
47
|
+
{titleExtra ? (<View testID={AccordionTestIds.titleExtra}>{titleExtra}</View>) : null}
|
|
48
|
+
</Pressable>
|
|
49
|
+
|
|
50
|
+
<Animated.View accessibilityElementsHidden={!isExpanded} importantForAccessibility={isExpanded ? 'yes' : 'no-hide-descendants'} style={[styles.contentAnimated, contentAnimatedStyle]} testID={AccordionTestIds.content}>
|
|
51
|
+
<View style={styles.contentWrapper} testID={AccordionTestIds.contentWrapper} onLayout={onLayout}>
|
|
52
|
+
{children}
|
|
53
|
+
</View>
|
|
54
|
+
</Animated.View>
|
|
55
|
+
</View>);
|
|
56
|
+
};
|
|
57
|
+
export const AccordionTestIds = {
|
|
58
|
+
component: 'Accordion',
|
|
59
|
+
header: 'Header',
|
|
60
|
+
arrow: 'Arrow',
|
|
61
|
+
icon: 'TitleIcon',
|
|
62
|
+
titleExtra: 'Extra',
|
|
63
|
+
content: 'Content',
|
|
64
|
+
contentWrapper: 'ContentWrapper',
|
|
65
|
+
separator: 'Separator',
|
|
66
|
+
};
|
|
67
|
+
const useStyles = makeStyles(({ theme, fonts }) => ({
|
|
68
|
+
component: { width: '100%' },
|
|
69
|
+
header: {
|
|
70
|
+
paddingVertical: theme.Panel.Accordion.accordionHeaderPaddingTopBottom,
|
|
71
|
+
gap: 7,
|
|
72
|
+
flexDirection: 'row',
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
backgroundColor: theme.Panel.Accordion.accordionHeaderBg,
|
|
75
|
+
},
|
|
76
|
+
icon: {
|
|
77
|
+
width: 17.5,
|
|
78
|
+
height: 17.5,
|
|
79
|
+
color: theme.Panel.Accordion.accordionHeaderTextColor,
|
|
80
|
+
},
|
|
81
|
+
title: {
|
|
82
|
+
fontSize: 15.75,
|
|
83
|
+
includeFontPadding: false,
|
|
84
|
+
verticalAlign: 'middle',
|
|
85
|
+
fontWeight: 700,
|
|
86
|
+
color: theme.Panel.Accordion.accordionHeaderTextColor,
|
|
87
|
+
fontFamily: fonts.secondary,
|
|
88
|
+
},
|
|
89
|
+
contentAnimated: { overflow: 'hidden' },
|
|
90
|
+
contentWrapper: {
|
|
91
|
+
position: 'absolute',
|
|
92
|
+
width: '100%',
|
|
93
|
+
paddingLeft: theme.Panel.Accordion.accordionContentPaddingLeft,
|
|
94
|
+
paddingTop: theme.Panel.Accordion.accordionContentPaddingTop,
|
|
95
|
+
paddingRight: theme.Panel.Accordion.accordionContentPaddingRight,
|
|
96
|
+
paddingBottom: theme.Panel.Accordion.accordionContentPaddingBottom,
|
|
97
|
+
},
|
|
98
|
+
separator: {
|
|
99
|
+
borderTopColor: theme.Panel.Accordion.accordionHeaderBorderColor,
|
|
100
|
+
borderTopWidth: 1,
|
|
101
|
+
},
|
|
102
|
+
disabled: { mixBlendMode: 'luminosity', opacity: 0.6 },
|
|
103
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type AccordionProps, Accordion } from './Accordion';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Accordion } from './Accordion';
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
|
+
import { type AccessibilityProps, type ColorValue, Image, type ImageSourcePropType, type ViewStyle } from 'react-native';
|
|
3
|
+
import { type SvgSource } from '../../utils/SvgUniversal';
|
|
4
|
+
export type AvatarSize = 'xlarge' | 'large' | 'normal';
|
|
5
|
+
interface AvatarBase extends AccessibilityProps {
|
|
6
|
+
/**
|
|
7
|
+
* Выбор размера компонента
|
|
8
|
+
* Можно передать число для кастомного размера аватара
|
|
9
|
+
* @default 'normal'
|
|
10
|
+
*/
|
|
11
|
+
size?: AvatarSize | number;
|
|
12
|
+
/**
|
|
13
|
+
* Выбор форм-фактора компонента
|
|
14
|
+
* @default 'circle'
|
|
15
|
+
*/
|
|
16
|
+
shape?: 'square' | 'circle';
|
|
17
|
+
/** Дополнительная стилизация для контейнера компонента */
|
|
18
|
+
style?: ViewStyle;
|
|
19
|
+
testID?: string;
|
|
20
|
+
/** Callback функция при ошибке загрузки картинки */
|
|
21
|
+
onError?: ComponentProps<typeof Image>['onError'];
|
|
22
|
+
}
|
|
23
|
+
interface LabelAvatar extends AvatarBase {
|
|
24
|
+
/** Тип контента внутри компонента */
|
|
25
|
+
type: 'label';
|
|
26
|
+
/** Текст лейбла */
|
|
27
|
+
children: string;
|
|
28
|
+
/** Картинка */
|
|
29
|
+
source?: never;
|
|
30
|
+
/** SVG-иконка */
|
|
31
|
+
Icon?: never;
|
|
32
|
+
iconColor?: never;
|
|
33
|
+
}
|
|
34
|
+
interface IconAvatar extends AvatarBase {
|
|
35
|
+
/** Тип контента внутри компонента */
|
|
36
|
+
type: 'icon';
|
|
37
|
+
/** Текст лейбла */
|
|
38
|
+
children?: never;
|
|
39
|
+
/** Картинка */
|
|
40
|
+
source?: never;
|
|
41
|
+
/** SVG-иконка */
|
|
42
|
+
Icon: SvgSource;
|
|
43
|
+
/** Цвет иконки */
|
|
44
|
+
iconColor?: ColorValue;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Свойства компонента с картинкой внутри
|
|
48
|
+
*/
|
|
49
|
+
interface ImageAvatar extends AvatarBase {
|
|
50
|
+
/** Тип контента внутри компонент */
|
|
51
|
+
type: 'image';
|
|
52
|
+
/** Картинка */
|
|
53
|
+
source?: ImageSourcePropType;
|
|
54
|
+
/** Текст лейбла */
|
|
55
|
+
children?: never;
|
|
56
|
+
/** SVG-иконка */
|
|
57
|
+
Icon?: never;
|
|
58
|
+
iconColor?: never;
|
|
59
|
+
}
|
|
60
|
+
interface BadgeAvatar {
|
|
61
|
+
/** Компонент бейджа **/
|
|
62
|
+
badge: ReactNode;
|
|
63
|
+
/** Показывать бейдж или нет */
|
|
64
|
+
showBadge?: boolean;
|
|
65
|
+
}
|
|
66
|
+
interface NoBadgeAvatar {
|
|
67
|
+
/** Компонент бейджа **/
|
|
68
|
+
badge?: never;
|
|
69
|
+
/** Показывать бейдж или нет */
|
|
70
|
+
showBadge?: never;
|
|
71
|
+
}
|
|
72
|
+
export type AvatarProps = (LabelAvatar | IconAvatar | ImageAvatar) & (BadgeAvatar | NoBadgeAvatar);
|
|
73
|
+
/**
|
|
74
|
+
* Компонент Avatar
|
|
75
|
+
* @param type - Тип контента внутри компонента
|
|
76
|
+
* @param size - Выбор размера компонента
|
|
77
|
+
* @param shape - Выбор форм-фактора компонента
|
|
78
|
+
* @param style - Дополнительная стилизация для контейнера компонента
|
|
79
|
+
* @param children - Текст лейбла
|
|
80
|
+
* @param source - Картинка
|
|
81
|
+
* @param Icon - Иконка из набора Tabler
|
|
82
|
+
* @param badge - Компонент бейджа
|
|
83
|
+
* @param showBadge - Показывать бейдж или нет
|
|
84
|
+
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-4972&m=dev
|
|
85
|
+
*/
|
|
86
|
+
export declare const Avatar: import("react").NamedExoticComponent<AvatarProps>;
|
|
87
|
+
export declare const AvatarTestId: {
|
|
88
|
+
root: string;
|
|
89
|
+
icon: string;
|
|
90
|
+
container: string;
|
|
91
|
+
text: string;
|
|
92
|
+
image: string;
|
|
93
|
+
badgeContainer: string;
|
|
94
|
+
badgeInnerContainer: string;
|
|
95
|
+
};
|
|
96
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { memo, useCallback, useEffect, useMemo, useState, } from 'react';
|
|
2
|
+
import { Image, Text, useWindowDimensions, View, } from 'react-native';
|
|
3
|
+
import { SvgUniversal } from '../../utils/SvgUniversal';
|
|
4
|
+
import { makeStyles } from '../../utils/makeStyles';
|
|
5
|
+
const SizeMap = {
|
|
6
|
+
normal: 28,
|
|
7
|
+
large: 35,
|
|
8
|
+
xlarge: 49,
|
|
9
|
+
};
|
|
10
|
+
const ICON_MULTIPLIER = 0.43;
|
|
11
|
+
/**
|
|
12
|
+
* Компонент Avatar
|
|
13
|
+
* @param type - Тип контента внутри компонента
|
|
14
|
+
* @param size - Выбор размера компонента
|
|
15
|
+
* @param shape - Выбор форм-фактора компонента
|
|
16
|
+
* @param style - Дополнительная стилизация для контейнера компонента
|
|
17
|
+
* @param children - Текст лейбла
|
|
18
|
+
* @param source - Картинка
|
|
19
|
+
* @param Icon - Иконка из набора Tabler
|
|
20
|
+
* @param badge - Компонент бейджа
|
|
21
|
+
* @param showBadge - Показывать бейдж или нет
|
|
22
|
+
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-4972&m=dev
|
|
23
|
+
*/
|
|
24
|
+
export const Avatar = memo(({ type, size = 'normal', shape = 'circle', style, children, source, Icon, badge, showBadge = true, testID, onError, iconColor, }) => {
|
|
25
|
+
const styles = useStyles();
|
|
26
|
+
const window = useWindowDimensions();
|
|
27
|
+
const [badgeLayout, setBadgeLayout] = useState();
|
|
28
|
+
const calculatedSize = useMemo(() => {
|
|
29
|
+
if (typeof size === 'number') {
|
|
30
|
+
return size;
|
|
31
|
+
}
|
|
32
|
+
return SizeMap[size];
|
|
33
|
+
}, [size]);
|
|
34
|
+
const sizeStyle = useMemo(() => ({ width: calculatedSize, height: calculatedSize }), [calculatedSize]);
|
|
35
|
+
const badgeContainerStyle = useMemo(() => ({
|
|
36
|
+
left: badgeLayout?.width
|
|
37
|
+
? Math.round(calculatedSize - badgeLayout.width / 2)
|
|
38
|
+
: 0,
|
|
39
|
+
width: badgeLayout?.width ? badgeLayout.width : window.width,
|
|
40
|
+
height: badgeLayout?.width ? 'auto' : 0,
|
|
41
|
+
}), [badgeLayout?.width, calculatedSize, window.width]);
|
|
42
|
+
const handleBadgeLayout = useCallback((e) => setBadgeLayout(e.nativeEvent.layout), []);
|
|
43
|
+
const icon = useMemo(() => {
|
|
44
|
+
if (type !== 'icon') {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
let iconSize = styles.icon.width;
|
|
48
|
+
if (typeof size === 'number' && size > SizeMap.xlarge) {
|
|
49
|
+
iconSize = Math.round(calculatedSize * ICON_MULTIPLIER);
|
|
50
|
+
}
|
|
51
|
+
else if (size === 'xlarge') {
|
|
52
|
+
iconSize = styles.iconXLarge.width;
|
|
53
|
+
}
|
|
54
|
+
return (<SvgUniversal color={iconColor || styles.icon.color} height={iconSize} source={Icon} testID={AvatarTestId.icon} width={iconSize}/>);
|
|
55
|
+
}, [Icon, calculatedSize, iconColor, size, styles, type]);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (badge) {
|
|
58
|
+
setBadgeLayout(undefined);
|
|
59
|
+
}
|
|
60
|
+
}, [badge]);
|
|
61
|
+
return (<View collapsable={false} testID={testID || AvatarTestId.root}>
|
|
62
|
+
<View style={[
|
|
63
|
+
styles.container,
|
|
64
|
+
sizeStyle,
|
|
65
|
+
type !== 'image' && styles.backgroundFill,
|
|
66
|
+
shape === 'circle' && styles.circle,
|
|
67
|
+
style,
|
|
68
|
+
]} testID={AvatarTestId.container}>
|
|
69
|
+
{type === 'label' && (<Text ellipsizeMode='clip' numberOfLines={1} style={styles.text} testID={AvatarTestId.text}>
|
|
70
|
+
{children}
|
|
71
|
+
</Text>)}
|
|
72
|
+
|
|
73
|
+
{icon}
|
|
74
|
+
|
|
75
|
+
{type === 'image' && (<Image resizeMode='cover' source={source} style={sizeStyle} testID={AvatarTestId.image} onError={onError}/>)}
|
|
76
|
+
</View>
|
|
77
|
+
|
|
78
|
+
{badge && showBadge ? (<View style={[styles.badgeContainer, badgeContainerStyle]} testID={AvatarTestId.badgeContainer}>
|
|
79
|
+
<View style={styles.badgeMeasureContainer} testID={AvatarTestId.badgeInnerContainer} onLayout={handleBadgeLayout}>
|
|
80
|
+
{badge}
|
|
81
|
+
</View>
|
|
82
|
+
</View>) : null}
|
|
83
|
+
</View>);
|
|
84
|
+
});
|
|
85
|
+
const useStyles = makeStyles(({ theme, border, typography, fonts }) => ({
|
|
86
|
+
container: {
|
|
87
|
+
justifyContent: 'center',
|
|
88
|
+
alignItems: 'center',
|
|
89
|
+
borderRadius: theme.General.borderRadiusXL,
|
|
90
|
+
borderWidth: 1,
|
|
91
|
+
borderColor: theme.Misc.Avatar.avatarBorderColor,
|
|
92
|
+
backgroundColor: theme.Misc.Avatar.avatarBg,
|
|
93
|
+
overflow: 'hidden',
|
|
94
|
+
},
|
|
95
|
+
backgroundFill: { backgroundColor: theme.Misc.Avatar.avatarBg },
|
|
96
|
+
circle: { borderRadius: border.Radius['rounded-full'] },
|
|
97
|
+
text: {
|
|
98
|
+
fontSize: typography.Size['text-base'],
|
|
99
|
+
textTransform: 'uppercase',
|
|
100
|
+
color: theme.Misc.Avatar.avatarTextColor,
|
|
101
|
+
includeFontPadding: false,
|
|
102
|
+
verticalAlign: 'middle',
|
|
103
|
+
fontFamily: fonts.secondary,
|
|
104
|
+
},
|
|
105
|
+
badgeContainer: { position: 'absolute', right: 0, top: -7 },
|
|
106
|
+
badgeMeasureContainer: { alignSelf: 'flex-start' },
|
|
107
|
+
icon: {
|
|
108
|
+
width: typography.Size['text-base'],
|
|
109
|
+
color: theme.Misc.Avatar.avatarTextColor,
|
|
110
|
+
},
|
|
111
|
+
iconXLarge: { width: typography.Size['text-2xl'] },
|
|
112
|
+
}));
|
|
113
|
+
export const AvatarTestId = {
|
|
114
|
+
root: 'Avatar',
|
|
115
|
+
icon: 'Avatar.icon',
|
|
116
|
+
container: 'Avatar.container',
|
|
117
|
+
text: 'Avatar.text',
|
|
118
|
+
image: 'Avatar.image',
|
|
119
|
+
badgeContainer: 'Avatar.badgeContainer',
|
|
120
|
+
badgeInnerContainer: 'Avatar.badgeInnerContainer',
|
|
121
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Avatar, type AvatarProps } from './Avatar';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Avatar } from './Avatar';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type AccessibilityProps, type ViewStyle } from 'react-native';
|
|
2
|
+
import type { ViewProps } from 'react-native-svg/lib/typescript/fabric/utils';
|
|
3
|
+
export type BadgeSeverity = 'basic' | 'info' | 'success' | 'warning' | 'danger';
|
|
4
|
+
export interface BadgeBase extends AccessibilityProps, Pick<ViewProps, 'onLayout' | 'testID'> {
|
|
5
|
+
/**
|
|
6
|
+
* Выбор варианта стиля компонента
|
|
7
|
+
* @default 'basic'
|
|
8
|
+
*/
|
|
9
|
+
severity?: BadgeSeverity;
|
|
10
|
+
/** Дополнительная стилизация для контейнера компонента */
|
|
11
|
+
style?: ViewStyle;
|
|
12
|
+
}
|
|
13
|
+
interface BadgeText extends BadgeBase {
|
|
14
|
+
/** Текст внутри бейджа **/
|
|
15
|
+
children: string;
|
|
16
|
+
/** Отображать бейдж в форме точки **/
|
|
17
|
+
dot?: false;
|
|
18
|
+
}
|
|
19
|
+
interface BadgeDot extends BadgeBase {
|
|
20
|
+
/** Отображать бейдж в форме точки **/
|
|
21
|
+
dot: true;
|
|
22
|
+
/** Текст внутри бейджа **/
|
|
23
|
+
children?: never;
|
|
24
|
+
}
|
|
25
|
+
export type BadgeProps = BadgeText | BadgeDot;
|
|
26
|
+
/**
|
|
27
|
+
* Компонент Badge
|
|
28
|
+
* @param children - Текст внутри бейджа
|
|
29
|
+
* @param dot - Отображать бейдж в форме точки
|
|
30
|
+
* @param severiy - Выбор варианта стиля компонента
|
|
31
|
+
* @param style - Дополнительная стилизация для контейнера компонента
|
|
32
|
+
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-4871&m=dev
|
|
33
|
+
*/
|
|
34
|
+
export declare const Badge: import("react").NamedExoticComponent<BadgeProps>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { memo, useCallback, useState } from 'react';
|
|
2
|
+
import { Dimensions, Text, View, } from 'react-native';
|
|
3
|
+
import { makeStyles } from '../../utils/makeStyles';
|
|
4
|
+
/**
|
|
5
|
+
* Компонент Badge
|
|
6
|
+
* @param children - Текст внутри бейджа
|
|
7
|
+
* @param dot - Отображать бейдж в форме точки
|
|
8
|
+
* @param severiy - Выбор варианта стиля компонента
|
|
9
|
+
* @param style - Дополнительная стилизация для контейнера компонента
|
|
10
|
+
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-4871&m=dev
|
|
11
|
+
*/
|
|
12
|
+
export const Badge = memo(({ children, dot, severity = 'basic', style, testID, ...rest }) => {
|
|
13
|
+
const styles = useStyles();
|
|
14
|
+
const [textLayout, setTextLayout] = useState();
|
|
15
|
+
const onTextLayout = useCallback((e) => {
|
|
16
|
+
setTextLayout(e.nativeEvent.layout);
|
|
17
|
+
}, []);
|
|
18
|
+
return (<View style={[styles.container, style]} {...rest}>
|
|
19
|
+
{dot ? (<View style={[styles.dot, styles[severity]]} testID={testID}/>) : (<>
|
|
20
|
+
<View style={[styles.textBadgeContainer, styles[severity]]} testID={testID}>
|
|
21
|
+
<Text numberOfLines={1} style={[styles.textBadge, { minWidth: textLayout?.width }]}>
|
|
22
|
+
{children}
|
|
23
|
+
</Text>
|
|
24
|
+
</View>
|
|
25
|
+
|
|
26
|
+
{/* скрытый элемент для подсчета ширины текста в 1 строку */}
|
|
27
|
+
<View accessibilityElementsHidden importantForAccessibility='no-hide-descendants' style={styles.hiddenContainer}>
|
|
28
|
+
<View collapsable={false}>
|
|
29
|
+
<Text numberOfLines={1} style={styles.textBadge} onLayout={onTextLayout}>
|
|
30
|
+
{children}
|
|
31
|
+
</Text>
|
|
32
|
+
</View>
|
|
33
|
+
</View>
|
|
34
|
+
</>)}
|
|
35
|
+
</View>);
|
|
36
|
+
});
|
|
37
|
+
const useStyles = makeStyles(({ theme, border, typography, fonts }) => ({
|
|
38
|
+
container: { alignItems: 'flex-start' },
|
|
39
|
+
dot: {
|
|
40
|
+
width: theme.Misc.Badge.badgeDotSize,
|
|
41
|
+
height: theme.Misc.Badge.badgeDotSize,
|
|
42
|
+
borderRadius: border.Radius['rounded-full'],
|
|
43
|
+
},
|
|
44
|
+
textBadgeContainer: {
|
|
45
|
+
height: theme.Misc.Badge.badgeHeight,
|
|
46
|
+
paddingHorizontal: theme.Misc.Tag.tagPadding,
|
|
47
|
+
justifyContent: 'center',
|
|
48
|
+
borderRadius: border.Radius['rounded-full'],
|
|
49
|
+
},
|
|
50
|
+
textBadge: {
|
|
51
|
+
color: theme.Misc.Badge.badgeTextColor,
|
|
52
|
+
fontSize: typography.Size['text-xs'],
|
|
53
|
+
includeFontPadding: false,
|
|
54
|
+
verticalAlign: 'middle',
|
|
55
|
+
fontFamily: fonts.primary,
|
|
56
|
+
},
|
|
57
|
+
basic: { backgroundColor: theme.Misc.Badge.badgeBg },
|
|
58
|
+
info: { backgroundColor: theme.Button.Severity.Info.Basic.infoButtonBg },
|
|
59
|
+
success: {
|
|
60
|
+
backgroundColor: theme.Button.Severity.Success.Basic.successButtonBg,
|
|
61
|
+
},
|
|
62
|
+
warning: {
|
|
63
|
+
backgroundColor: theme.Button.Severity.Warning.Basic.warningButtonBg,
|
|
64
|
+
},
|
|
65
|
+
danger: {
|
|
66
|
+
backgroundColor: theme.Button.Severity.Danger.Basic.dangerButtonBg,
|
|
67
|
+
},
|
|
68
|
+
hiddenContainer: {
|
|
69
|
+
width: Dimensions.get('window').width,
|
|
70
|
+
height: 0,
|
|
71
|
+
flexDirection: 'row',
|
|
72
|
+
position: 'absolute',
|
|
73
|
+
},
|
|
74
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Badge, type BadgeProps } from './Badge';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Badge } from './Badge';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ButtonProps, ButtonVariant, VariantStyles } from './types';
|
|
2
|
+
export type BaseButtonComponentProps<Variant extends ButtonVariant> = Omit<ButtonProps<Variant>, 'variant'> & {
|
|
3
|
+
readonly variant: Variant;
|
|
4
|
+
} & VariantStyles<Variant>;
|
|
5
|
+
export declare const BaseButton: <Variant extends ButtonVariant>({ size, shape, loading, variant, disabled, iconOnly, iconPosition, Icon, label, style, containerVariantStyles, labelVariantStyles, pressedVariantStyles, iconVariantStyles, pressedLabelVariantStyles, onPressIn: onPressInProp, onPressOut: onPressOutProp, ...props }: BaseButtonComponentProps<Variant>) => import("react").JSX.Element;
|