@skbkontur/react-ui 5.3.1 → 5.3.2
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/CHANGELOG.md +8 -0
- package/package.json +1 -6
- package/cjs/components/Autocomplete/Autocomplete.md +0 -113
- package/cjs/components/Button/Button.md +0 -261
- package/cjs/components/Calendar/Calendar.md +0 -276
- package/cjs/components/Calendar/CalendarDay.md +0 -70
- package/cjs/components/Center/Center.md +0 -26
- package/cjs/components/Checkbox/Checkbox.md +0 -171
- package/cjs/components/ComboBox/ComboBox.md +0 -574
- package/cjs/components/CurrencyInput/CurrencyInput.md +0 -39
- package/cjs/components/CurrencyLabel/CurrencyLabel.md +0 -29
- package/cjs/components/DateInput/DateInput.md +0 -111
- package/cjs/components/DatePicker/DatePicker.md +0 -368
- package/cjs/components/Dropdown/Dropdown.md +0 -45
- package/cjs/components/DropdownMenu/DropdownMenu.md +0 -290
- package/cjs/components/FileUploader/FileUploader.md +0 -131
- package/cjs/components/FxInput/FxInput.md +0 -31
- package/cjs/components/Gapped/Gapped.md +0 -44
- package/cjs/components/GlobalLoader/GlobalLoader.md +0 -97
- package/cjs/components/Group/Group.md +0 -19
- package/cjs/components/Hint/Hint.md +0 -86
- package/cjs/components/Input/Input.md +0 -86
- package/cjs/components/Kebab/Kebab.md +0 -306
- package/cjs/components/Link/Link.md +0 -182
- package/cjs/components/Loader/Loader.md +0 -33
- package/cjs/components/MaskedInput/MaskedInput.md +0 -114
- package/cjs/components/MenuFooter/MenuFooter.md +0 -27
- package/cjs/components/MenuHeader/MenuHeader.md +0 -35
- package/cjs/components/MenuItem/MenuItem.md +0 -139
- package/cjs/components/MenuSeparator/MenuSeparator.md +0 -14
- package/cjs/components/MiniModal/MiniModal.md +0 -231
- package/cjs/components/Modal/Modal.md +0 -56
- package/cjs/components/Paging/Paging.md +0 -57
- package/cjs/components/PasswordInput/PasswordInput.md +0 -29
- package/cjs/components/Radio/Radio.md +0 -57
- package/cjs/components/RadioGroup/RadioGroup.md +0 -44
- package/cjs/components/ResponsiveLayout/ResponsiveLayout.md +0 -75
- package/cjs/components/ScrollContainer/ScrollContainer.md +0 -224
- package/cjs/components/Select/Select.md +0 -113
- package/cjs/components/SidePage/SidePage.md +0 -65
- package/cjs/components/SingleToast/SingleToast.md +0 -36
- package/cjs/components/Spinner/Spinner.md +0 -36
- package/cjs/components/Sticky/Sticky.md +0 -28
- package/cjs/components/Switcher/Switcher.md +0 -111
- package/cjs/components/Tabs/Tab.md +0 -73
- package/cjs/components/Tabs/Tabs.md +0 -54
- package/cjs/components/Textarea/Textarea.md +0 -58
- package/cjs/components/Toast/Toast.md +0 -69
- package/cjs/components/Toggle/Toggle.md +0 -110
- package/cjs/components/Token/Token.md +0 -48
- package/cjs/components/TokenInput/TokenInput.md +0 -277
- package/cjs/components/Tooltip/Tooltip.md +0 -322
- package/cjs/components/TooltipMenu/TooltipMenu.md +0 -241
- package/cjs/internal/DataTids/DATATIDS.md +0 -12
- package/cjs/internal/DataTids/DataTids.d.ts +0 -12
- package/cjs/internal/DataTids/DataTids.js +0 -50
- package/cjs/internal/DataTids/DataTids.js.map +0 -1
- package/cjs/internal/DataTids/DataTids.styles.d.ts +0 -7
- package/cjs/internal/DataTids/DataTids.styles.js +0 -42
- package/cjs/internal/DataTids/DataTids.styles.js.map +0 -1
- package/cjs/internal/DataTids/componentsDataTids.d.ts +0 -5
- package/cjs/internal/DataTids/componentsDataTids.js +0 -15
- package/cjs/internal/DataTids/componentsDataTids.js.map +0 -1
- package/cjs/internal/ThemePlayground/Playground.md +0 -7
- package/cjs/lib/featureFlagsContext/FEATUREFLAGSCONTEXT.md +0 -64
- package/cjs/lib/locale/LOCALECONTEXT.md +0 -222
- package/cjs/lib/theming/ThemeContext.md +0 -265
- package/components/Autocomplete/Autocomplete.md +0 -113
- package/components/Button/Button.md +0 -261
- package/components/Calendar/Calendar.md +0 -276
- package/components/Calendar/CalendarDay.md +0 -70
- package/components/Center/Center.md +0 -26
- package/components/Checkbox/Checkbox.md +0 -171
- package/components/ComboBox/ComboBox.md +0 -574
- package/components/CurrencyInput/CurrencyInput.md +0 -39
- package/components/CurrencyLabel/CurrencyLabel.md +0 -29
- package/components/DateInput/DateInput.md +0 -111
- package/components/DatePicker/DatePicker.md +0 -368
- package/components/Dropdown/Dropdown.md +0 -45
- package/components/DropdownMenu/DropdownMenu.md +0 -290
- package/components/FileUploader/FileUploader.md +0 -131
- package/components/FxInput/FxInput.md +0 -31
- package/components/Gapped/Gapped.md +0 -44
- package/components/GlobalLoader/GlobalLoader.md +0 -97
- package/components/Group/Group.md +0 -19
- package/components/Hint/Hint.md +0 -86
- package/components/Input/Input.md +0 -86
- package/components/Kebab/Kebab.md +0 -306
- package/components/Link/Link.md +0 -182
- package/components/Loader/Loader.md +0 -33
- package/components/MaskedInput/MaskedInput.md +0 -114
- package/components/MenuFooter/MenuFooter.md +0 -27
- package/components/MenuHeader/MenuHeader.md +0 -35
- package/components/MenuItem/MenuItem.md +0 -139
- package/components/MenuSeparator/MenuSeparator.md +0 -14
- package/components/MiniModal/MiniModal.md +0 -231
- package/components/Modal/Modal.md +0 -56
- package/components/Paging/Paging.md +0 -57
- package/components/PasswordInput/PasswordInput.md +0 -29
- package/components/Radio/Radio.md +0 -57
- package/components/RadioGroup/RadioGroup.md +0 -44
- package/components/ResponsiveLayout/ResponsiveLayout.md +0 -75
- package/components/ScrollContainer/ScrollContainer.md +0 -224
- package/components/Select/Select.md +0 -113
- package/components/SidePage/SidePage.md +0 -65
- package/components/SingleToast/SingleToast.md +0 -36
- package/components/Spinner/Spinner.md +0 -36
- package/components/Sticky/Sticky.md +0 -28
- package/components/Switcher/Switcher.md +0 -111
- package/components/Tabs/Tab.md +0 -73
- package/components/Tabs/Tabs.md +0 -54
- package/components/Textarea/Textarea.md +0 -58
- package/components/Toast/Toast.md +0 -69
- package/components/Toggle/Toggle.md +0 -110
- package/components/Token/Token.md +0 -48
- package/components/TokenInput/TokenInput.md +0 -277
- package/components/Tooltip/Tooltip.md +0 -322
- package/components/TooltipMenu/TooltipMenu.md +0 -241
- package/internal/DataTids/DATATIDS.md +0 -12
- package/internal/DataTids/DataTids/DataTids.js +0 -69
- package/internal/DataTids/DataTids/DataTids.js.map +0 -1
- package/internal/DataTids/DataTids/package.json +0 -6
- package/internal/DataTids/DataTids.d.ts +0 -12
- package/internal/DataTids/DataTids.styles/DataTids.styles.js +0 -20
- package/internal/DataTids/DataTids.styles/DataTids.styles.js.map +0 -1
- package/internal/DataTids/DataTids.styles/package.json +0 -6
- package/internal/DataTids/DataTids.styles.d.ts +0 -7
- package/internal/DataTids/componentsDataTids/componentsDataTids.js +0 -12
- package/internal/DataTids/componentsDataTids/componentsDataTids.js.map +0 -1
- package/internal/DataTids/componentsDataTids/package.json +0 -6
- package/internal/DataTids/componentsDataTids.d.ts +0 -5
- package/internal/ThemePlayground/Playground.md +0 -7
- package/lib/featureFlagsContext/FEATUREFLAGSCONTEXT.md +0 -64
- package/lib/locale/LOCALECONTEXT.md +0 -222
- package/lib/theming/ThemeContext.md +0 -265
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
### Базовый пример
|
|
2
|
-
По умолчанию, кнопка принимает все пропы `HTMLButtonElement`.
|
|
3
|
-
|
|
4
|
-
```jsx harmony
|
|
5
|
-
import { Button } from '@skbkontur/react-ui';
|
|
6
|
-
|
|
7
|
-
<Button onClick={alert} name="report">Создать отчёт</Button>;
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
### Корневой компонент
|
|
11
|
-
Кнопка может рендерить ссылку в качестве корневого элемента, c помощью пропа `component`. Кнопка принимает все пропы переданного в `component` компонента.
|
|
12
|
-
|
|
13
|
-
```jsx harmony
|
|
14
|
-
import { Button } from '@skbkontur/react-ui';
|
|
15
|
-
|
|
16
|
-
<Button component='a' href='https://kontur.ru' target="_blank">Ссылка, но выглядит как кнопка</Button>
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Различные стили
|
|
20
|
-
|
|
21
|
-
```jsx harmony
|
|
22
|
-
import { Gapped } from '@skbkontur/react-ui';
|
|
23
|
-
|
|
24
|
-
const bgStyle = {
|
|
25
|
-
backgroundImage: `linear-gradient(to right, rgba(130, 130, 130, 0.5) 1px, transparent 1px),
|
|
26
|
-
linear-gradient(to bottom, rgba(130, 130, 130, 0.5) 1px, transparent 1px)`,
|
|
27
|
-
backgroundSize: `16px 16px`,
|
|
28
|
-
backgroundPosition: `-8px -8px`,
|
|
29
|
-
padding: 16
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
<Gapped vertical>
|
|
33
|
-
<Gapped>
|
|
34
|
-
<Button use="default">Default</Button>
|
|
35
|
-
<Button use="primary">Primary</Button>
|
|
36
|
-
<Button use="success">Success</Button>
|
|
37
|
-
<Button use="danger">Danger</Button>
|
|
38
|
-
<Button use="pay">Pay</Button>
|
|
39
|
-
<Button use="text">Text</Button>
|
|
40
|
-
<Button use="backless">Backless</Button>
|
|
41
|
-
<Button use="link">Link</Button>
|
|
42
|
-
</Gapped>
|
|
43
|
-
<Gapped style={bgStyle}>
|
|
44
|
-
<Button use="default">Default</Button>
|
|
45
|
-
<Button use="primary">Primary</Button>
|
|
46
|
-
<Button use="success">Success</Button>
|
|
47
|
-
<Button use="danger">Danger</Button>
|
|
48
|
-
<Button use="pay">Pay</Button>
|
|
49
|
-
<Button use="text">Text</Button>
|
|
50
|
-
<Button use="backless">Backless</Button>
|
|
51
|
-
<Button use="link">Link</Button>
|
|
52
|
-
</Gapped>
|
|
53
|
-
</Gapped>
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### Иконка
|
|
57
|
-
В кнопку можно передать иконку. Иконка может находиться как слева от текста кнопки, так и справа и даже в обоих позициях одновременно.
|
|
58
|
-
|
|
59
|
-
```jsx harmony
|
|
60
|
-
import { Button, Gapped } from '@skbkontur/react-ui';
|
|
61
|
-
import { XIcon16Regular } from '@skbkontur/icons/XIcon16Regular';
|
|
62
|
-
|
|
63
|
-
<Gapped gap={5}>
|
|
64
|
-
<Button icon={<XIcon16Regular />}>Закрыть</Button>
|
|
65
|
-
<Button icon={<XIcon16Regular />} rightIcon={<XIcon16Regular />}>Закрыть</Button>
|
|
66
|
-
<Button rightIcon={<XIcon16Regular />}>Закрыть</Button>
|
|
67
|
-
</Gapped>
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### Размер
|
|
71
|
-
|
|
72
|
-
```jsx harmony
|
|
73
|
-
<div
|
|
74
|
-
style={{
|
|
75
|
-
display: "flex",
|
|
76
|
-
alignItems: "end",
|
|
77
|
-
gap: '10px',
|
|
78
|
-
}}
|
|
79
|
-
>
|
|
80
|
-
<Button size="small">Маленькая</Button>
|
|
81
|
-
<Button size="medium">Средняя</Button>
|
|
82
|
-
<Button size="large">Большая</Button>
|
|
83
|
-
</div>
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### Ширина
|
|
87
|
-
|
|
88
|
-
```jsx harmony
|
|
89
|
-
<Button width={40}>Закрыть</Button>
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Состояние валидации
|
|
93
|
-
|
|
94
|
-
```jsx harmony
|
|
95
|
-
import { Gapped, Button } from '@skbkontur/react-ui';
|
|
96
|
-
<Gapped gap={5}>
|
|
97
|
-
<Button warning>Закрыть</Button>
|
|
98
|
-
<Button error>Закрыть</Button>
|
|
99
|
-
</Gapped>
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Стрелка
|
|
103
|
-
|
|
104
|
-
```jsx harmony
|
|
105
|
-
import { Gapped, Button } from '@skbkontur/react-ui';
|
|
106
|
-
|
|
107
|
-
<Gapped gap={5}>
|
|
108
|
-
<Button arrow="left" size="medium">
|
|
109
|
-
Назад
|
|
110
|
-
</Button>
|
|
111
|
-
<Button arrow size="medium">
|
|
112
|
-
Далее
|
|
113
|
-
</Button>
|
|
114
|
-
</Gapped>
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### Состояние загрузки
|
|
118
|
-
|
|
119
|
-
**Поведение:**
|
|
120
|
-
Кнопка на время нахождения в состоянии загрузки отключается.
|
|
121
|
-
Если в кнопке есть иконка, на время загрузки иконка заменяется на спиннер, если иконки нет — весь контент кнопки заменяется на спиннер. Когда иконки две — заменяется только левая.
|
|
122
|
-
|
|
123
|
-
```jsx harmony
|
|
124
|
-
import { Button, Gapped } from '@skbkontur/react-ui';
|
|
125
|
-
import { MinusCircleIcon16Light } from '@skbkontur/icons/MinusCircleIcon16Light';
|
|
126
|
-
|
|
127
|
-
const [loading, setLoading] = React.useState(false);
|
|
128
|
-
|
|
129
|
-
const delay = time => args => new Promise(resolve => setTimeout(resolve, time, args));
|
|
130
|
-
|
|
131
|
-
const handleLoadingStart = () => {
|
|
132
|
-
delay(2000)()
|
|
133
|
-
.then(() => {
|
|
134
|
-
setLoading(false);
|
|
135
|
-
})
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const handleClick = () => {
|
|
139
|
-
setLoading(true);
|
|
140
|
-
handleLoadingStart();
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
<Gapped>
|
|
144
|
-
<Button width={150} onClick={handleClick} loading={loading}>
|
|
145
|
-
Удалить
|
|
146
|
-
</Button>
|
|
147
|
-
<Button icon={<MinusCircleIcon16Light />} width={150} onClick={handleClick} loading={loading}>
|
|
148
|
-
Удалить
|
|
149
|
-
</Button>
|
|
150
|
-
<Button rightIcon={<MinusCircleIcon16Light />} width={150} onClick={handleClick} loading={loading}>
|
|
151
|
-
Удалить
|
|
152
|
-
</Button>
|
|
153
|
-
<Button icon={<MinusCircleIcon16Light />} rightIcon={<MinusCircleIcon16Light />} width={150} onClick={handleClick} loading={loading}>
|
|
154
|
-
Удалить
|
|
155
|
-
</Button>
|
|
156
|
-
</Gapped>
|
|
157
|
-
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
### Проп темы
|
|
161
|
-
|
|
162
|
-
```jsx harmony
|
|
163
|
-
import { Button, Gapped } from '@skbkontur/react-ui';
|
|
164
|
-
|
|
165
|
-
<Gapped>
|
|
166
|
-
<Button theme={{textColorDefault: '#C00000'}}>Ok</Button>
|
|
167
|
-
<Button use="link" theme={{linkColor: '#C00000'}}>Ok</Button>
|
|
168
|
-
<Button>Ok</Button>
|
|
169
|
-
</Gapped>
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### Кастомизация кнопки-ссылки
|
|
173
|
-
|
|
174
|
-
```jsx harmony
|
|
175
|
-
import { Toast } from "@skbkontur/react-ui";
|
|
176
|
-
import { CopyIcon16Regular } from "@skbkontur/icons/CopyIcon16Regular"
|
|
177
|
-
|
|
178
|
-
const textDecorationStyles = {
|
|
179
|
-
btnLinkTextUnderlineOffset: '1px',
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const underlineOnHoverStyles = {
|
|
183
|
-
btnLinkTextDecorationColor: 'transparent',
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const differentColorStyles = {
|
|
187
|
-
btnLinkColor: 'blue',
|
|
188
|
-
btnLinkHoverColor: 'blue',
|
|
189
|
-
btnLinkActiveColor: 'blue',
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const stringify = (styles) => {
|
|
193
|
-
return `${Object.entries(styles).map(([key, value]) => `${key}: "${value}"`).join(", ")}`
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const copyStyles = (styles) => {
|
|
197
|
-
navigator.clipboard.writeText(stringify(styles));
|
|
198
|
-
Toast.push('Copied');
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const tableStyle = {
|
|
202
|
-
borderCollapse: 'collapse',
|
|
203
|
-
width: '100%',
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
const tdStyle = {
|
|
207
|
-
border: '1px solid',
|
|
208
|
-
padding: '8px',
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
const renderExampleRow = (title, styles) => {
|
|
212
|
-
return (
|
|
213
|
-
<tr>
|
|
214
|
-
<td style={tdStyle}>{title}</td>
|
|
215
|
-
<td style={tdStyle}><Button use={'link'} theme={styles}>Button-link</Button></td>
|
|
216
|
-
<td style={tdStyle}>
|
|
217
|
-
<div style={{display: 'flex'}}>
|
|
218
|
-
<div style={{width: '80%', whiteSpace: 'pre-line'}}>{stringify(styles).replace(/, /g, '\n')}</div>
|
|
219
|
-
<Button icon={<CopyIcon16Regular />} use={'text'} onClick={() => copyStyles(styles)}/>
|
|
220
|
-
</div>
|
|
221
|
-
</td>
|
|
222
|
-
</tr>
|
|
223
|
-
)
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
<table style={tableStyle}>
|
|
227
|
-
<tr style={{textAlign: 'left'}}>
|
|
228
|
-
<th style={tdStyle}></th>
|
|
229
|
-
<th style={tdStyle}>Пример</th>
|
|
230
|
-
<th style={tdStyle}>Переменные темы</th>
|
|
231
|
-
</tr>
|
|
232
|
-
{renderExampleRow('Ссылка с подчеркиванием без отступа', textDecorationStyles)}
|
|
233
|
-
{renderExampleRow('Ссылка с подчеркиванием при наведении', underlineOnHoverStyles)}
|
|
234
|
-
{renderExampleRow('Изменение цвета ссылки', differentColorStyles)}
|
|
235
|
-
</table>
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### Узкая Кнопка
|
|
239
|
-
|
|
240
|
-
```jsx harmony
|
|
241
|
-
import { Button } from '@skbkontur/react-ui';
|
|
242
|
-
|
|
243
|
-
<Button narrow>
|
|
244
|
-
Создать отчет
|
|
245
|
-
</Button>
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
### Состояния валидации
|
|
249
|
-
|
|
250
|
-
```jsx harmony
|
|
251
|
-
import { Button, Gapped } from '@skbkontur/react-ui';
|
|
252
|
-
|
|
253
|
-
<Gapped gap={5}>
|
|
254
|
-
<Button warning>
|
|
255
|
-
Warning
|
|
256
|
-
</Button>
|
|
257
|
-
<Button error>
|
|
258
|
-
Error
|
|
259
|
-
</Button>
|
|
260
|
-
</Gapped>
|
|
261
|
-
```
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
### Календарь с заданной датой
|
|
2
|
-
|
|
3
|
-
```jsx harmony
|
|
4
|
-
const [date, setDate] = React.useState("01.11.2021");
|
|
5
|
-
|
|
6
|
-
<Calendar
|
|
7
|
-
value={date}
|
|
8
|
-
onValueChange={setDate}
|
|
9
|
-
/>
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
### initialMonth и initialYear
|
|
13
|
-
Вне зависимости от того, какая дата выбрана в календаре в данный момент - можно изменить отображение начального года и месяца с помощью пропов `initialMonth` и `initialYear`
|
|
14
|
-
|
|
15
|
-
```jsx harmony
|
|
16
|
-
import { Checkbox } from '@skbkontur/react-ui';
|
|
17
|
-
|
|
18
|
-
const [date, setDate] = React.useState("11.12.2021");
|
|
19
|
-
const initialMonth = 7;
|
|
20
|
-
const initialYear = 2000;
|
|
21
|
-
|
|
22
|
-
<div style={{ display: 'flex' }}>
|
|
23
|
-
<Calendar
|
|
24
|
-
value={date}
|
|
25
|
-
onValueChange={setDate}
|
|
26
|
-
initialMonth={initialMonth}
|
|
27
|
-
initialYear={initialYear}
|
|
28
|
-
/>
|
|
29
|
-
<div style={{ fontSize: '16px' }}>
|
|
30
|
-
<p>Выбранная дата: {date}</p>
|
|
31
|
-
<p>Начальный месяц: {initialMonth}</p>
|
|
32
|
-
<p>Начальный год: {initialYear}</p>
|
|
33
|
-
</div>
|
|
34
|
-
</div>
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### isHoliday
|
|
38
|
-
|
|
39
|
-
В компонент можно передать функцию `isHoliday`, которая будет получать день строкой формата `dd.mm.yyyy` и флаг `isWeekend`, и должна вернуть `true` для выходного и `false` для рабочего дня.
|
|
40
|
-
|
|
41
|
-
```jsx harmony
|
|
42
|
-
import * as DatePickerHelpers from '@skbkontur/react-ui/components/DatePicker/DatePickerHelpers';
|
|
43
|
-
|
|
44
|
-
const [date, setDate] = React.useState();
|
|
45
|
-
|
|
46
|
-
const createRandomHolidays = () => {
|
|
47
|
-
const holidays = new Array(10);
|
|
48
|
-
const today = new Date();
|
|
49
|
-
|
|
50
|
-
for (let index = 0; index < holidays.length; index++) {
|
|
51
|
-
const day = new Date(today.setDate(today.getDate() + 1 + index).valueOf());
|
|
52
|
-
|
|
53
|
-
const holiday = {
|
|
54
|
-
date: day.getDate(),
|
|
55
|
-
month: day.getMonth(),
|
|
56
|
-
year: day.getFullYear(),
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
holidays[index] = DatePickerHelpers.formatDate(holiday);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return holidays;
|
|
63
|
-
};
|
|
64
|
-
const holidays = createRandomHolidays();
|
|
65
|
-
|
|
66
|
-
const isHoliday = (day, isWeekend) => {
|
|
67
|
-
const today = new Date();
|
|
68
|
-
const holiday = {
|
|
69
|
-
date: today.getDate(),
|
|
70
|
-
month: today.getMonth(),
|
|
71
|
-
year: today.getFullYear(),
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
if (holidays.includes(day)) {
|
|
75
|
-
return !isWeekend;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return isWeekend;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
<Calendar isHoliday={isHoliday} value={date} onValueChange={setDate} />;
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Высота
|
|
85
|
-
Календарю можно задать кастомную высоту с помощью переменной темы `calendarWrapperHeight`
|
|
86
|
-
|
|
87
|
-
- Базовая высота календаря - `330px`
|
|
88
|
-
- Максимальная высота календаря - `450px`
|
|
89
|
-
|
|
90
|
-
```jsx harmony
|
|
91
|
-
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
92
|
-
import { ThemeFactory } from '@skbkontur/react-ui/lib/theming/ThemeFactory';
|
|
93
|
-
|
|
94
|
-
const [date, setDate] = React.useState("01.11.2021");
|
|
95
|
-
const theme = React.useContext(ThemeContext);
|
|
96
|
-
|
|
97
|
-
<ThemeContext.Provider
|
|
98
|
-
value={ThemeFactory.create({ calendarWrapperHeight: '450px' }, theme)}
|
|
99
|
-
>
|
|
100
|
-
<Calendar
|
|
101
|
-
value={date}
|
|
102
|
-
onValueChange={setDate}
|
|
103
|
-
/>
|
|
104
|
-
</ThemeContext.Provider>
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Кастомный рендер дня
|
|
108
|
-
Для кастомнизации дней в календаре используется метод `renderDay` и компонент [Calendar.Day](#/Components/Calendar/Calendar.Day)
|
|
109
|
-
|
|
110
|
-
```jsx harmony
|
|
111
|
-
import { Tooltip, Hint, CalendarDay } from '@skbkontur/react-ui';
|
|
112
|
-
|
|
113
|
-
const initialValue = "02.09.2023";
|
|
114
|
-
|
|
115
|
-
const [value, setValue] = React.useState(initialValue);
|
|
116
|
-
|
|
117
|
-
const renderDay = (props) => {
|
|
118
|
-
const [date, month, year] = props.date.split('.').map(Number);
|
|
119
|
-
|
|
120
|
-
if (month == 9 && date > 12 && date < 16) {
|
|
121
|
-
return (
|
|
122
|
-
<Tooltip render={() => "Кастомный день"}>
|
|
123
|
-
<CalendarDay {...props} style={{ background: 'darkgray' }} />
|
|
124
|
-
</Tooltip>
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (month == 8 && date == 20) {
|
|
129
|
-
return (
|
|
130
|
-
<Hint text={date} pos="right middle">
|
|
131
|
-
<CalendarDay {...props}>
|
|
132
|
-
<b style={{color: 'orange'}}>#</b>
|
|
133
|
-
</CalendarDay>
|
|
134
|
-
</Hint>
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return <CalendarDay {...props} />
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
<Calendar
|
|
142
|
-
value={value}
|
|
143
|
-
onValueChange={setValue}
|
|
144
|
-
renderDay={renderDay}
|
|
145
|
-
/>;
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### Календарь с ценами
|
|
149
|
-
Пример с кастомизацией темы и кастомным рендером дня.
|
|
150
|
-
|
|
151
|
-
```jsx harmony
|
|
152
|
-
import { CalendarDay } from '@skbkontur/react-ui';
|
|
153
|
-
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
154
|
-
import { ThemeFactory } from '@skbkontur/react-ui/lib/theming/ThemeFactory';
|
|
155
|
-
|
|
156
|
-
const theme = React.useContext(ThemeContext);
|
|
157
|
-
|
|
158
|
-
function renderDay(props) {
|
|
159
|
-
const [date, month] = props.date.split('.').map(Number);
|
|
160
|
-
const randomDay = date % 6 === 0 || date % 7 === 0 || date % 8 === 0;
|
|
161
|
-
const randomPrice = Math.round((date / month) * 1000);
|
|
162
|
-
|
|
163
|
-
return (
|
|
164
|
-
<CalendarDay {...props}>
|
|
165
|
-
<div style={{ fontSize: theme.calendarCellFontSize }}>{date}</div>
|
|
166
|
-
<div style={{ fontSize: '11px', fontFeatureSettings: 'tnum', fontVariantNumeric: 'tabular-nums' }}>
|
|
167
|
-
{randomDay ? <>{randomPrice} ₽</> : <span style={{ color: theme.tokenTextColorDisabled }}>—</span>}
|
|
168
|
-
</div>
|
|
169
|
-
</CalendarDay>
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const [value, setValue] = React.useState(null);
|
|
174
|
-
|
|
175
|
-
<ThemeContext.Provider
|
|
176
|
-
value={ThemeFactory.create({
|
|
177
|
-
calendarCellWidth: '56px',
|
|
178
|
-
calendarCellHeight: '56px',
|
|
179
|
-
calendarCellLineHeight: '1.5',
|
|
180
|
-
calendarWrapperHeight: '600px',
|
|
181
|
-
calendarCellBorderRadius: '8px'
|
|
182
|
-
}, theme)}
|
|
183
|
-
>
|
|
184
|
-
<Calendar value={value} renderDay={renderDay} onValueChange={setValue} />
|
|
185
|
-
</ThemeContext.Provider>
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### Локали по умолчанию
|
|
189
|
-
|
|
190
|
-
```typescript static
|
|
191
|
-
interface CalendarLocale {
|
|
192
|
-
months?: string[];
|
|
193
|
-
selectMonthAriaLabel?: string;
|
|
194
|
-
selectYearAriaLabel?: string;
|
|
195
|
-
selectChosenAriaLabel?: string;
|
|
196
|
-
dayCellChooseDateAriaLabel?: string;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const ru_RU = {
|
|
200
|
-
months: [
|
|
201
|
-
'Январь',
|
|
202
|
-
'Февраль',
|
|
203
|
-
'Март',
|
|
204
|
-
'Апрель',
|
|
205
|
-
'Май',
|
|
206
|
-
'Июнь',
|
|
207
|
-
'Июль',
|
|
208
|
-
'Август',
|
|
209
|
-
'Сентябрь',
|
|
210
|
-
'Октябрь',
|
|
211
|
-
'Ноябрь',
|
|
212
|
-
'Декабрь',
|
|
213
|
-
],
|
|
214
|
-
selectMonthAriaLabel: 'месяц',
|
|
215
|
-
selectYearAriaLabel: 'год',
|
|
216
|
-
selectChosenAriaLabel: 'Выбранный',
|
|
217
|
-
dayCellChooseDateAriaLabel: 'Выбрать дату',
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
const en_GB = {
|
|
221
|
-
months: [
|
|
222
|
-
'January',
|
|
223
|
-
'February',
|
|
224
|
-
'March',
|
|
225
|
-
'April',
|
|
226
|
-
'May',
|
|
227
|
-
'June',
|
|
228
|
-
'July',
|
|
229
|
-
'August',
|
|
230
|
-
'September',
|
|
231
|
-
'October',
|
|
232
|
-
'November',
|
|
233
|
-
'December',
|
|
234
|
-
],
|
|
235
|
-
selectMonthAriaLabel: 'месяц',
|
|
236
|
-
selectYearAriaLabel: 'год',
|
|
237
|
-
selectChosenAriaLabel: 'Выбранный',
|
|
238
|
-
dayCellChooseDateAriaLabel: 'Выбрать дату',
|
|
239
|
-
};
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
### Скролл к месяцу
|
|
244
|
-
|
|
245
|
-
```jsx harmony
|
|
246
|
-
import { Button, Gapped } from '@skbkontur/react-ui';
|
|
247
|
-
|
|
248
|
-
const initialValue = "02.09.2023";
|
|
249
|
-
const [value, setValue] = React.useState(initialValue);
|
|
250
|
-
const calendarRef = React.useRef(null);
|
|
251
|
-
|
|
252
|
-
<>
|
|
253
|
-
<Gapped gap={8} verticalAlign="top">
|
|
254
|
-
<Calendar
|
|
255
|
-
value={value}
|
|
256
|
-
ref={calendarRef}
|
|
257
|
-
onValueChange={setValue}
|
|
258
|
-
/>
|
|
259
|
-
|
|
260
|
-
<Gapped vertical gap={8}>
|
|
261
|
-
<Button onClick={() => calendarRef.current.scrollToMonth(1, 2023)}>
|
|
262
|
-
I квартал
|
|
263
|
-
</Button>
|
|
264
|
-
<Button onClick={() => calendarRef.current.scrollToMonth(4, 2023)}>
|
|
265
|
-
II квартал
|
|
266
|
-
</Button>
|
|
267
|
-
<Button onClick={() => calendarRef.current.scrollToMonth(7, 2023)}>
|
|
268
|
-
III квартал
|
|
269
|
-
</Button>
|
|
270
|
-
<Button onClick={() => calendarRef.current.scrollToMonth(10, 2023)}>
|
|
271
|
-
IV квартал
|
|
272
|
-
</Button>
|
|
273
|
-
</Gapped>
|
|
274
|
-
</Gapped>
|
|
275
|
-
</>;
|
|
276
|
-
```
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
Компонент для отрисовки дня в Calendar. Полезен при использовании вместе с его пропом `renderDay`.
|
|
2
|
-
|
|
3
|
-
### Базовый пример
|
|
4
|
-
```jsx harmony
|
|
5
|
-
import { CalendarDay, Gapped } from '@skbkontur/react-ui';
|
|
6
|
-
|
|
7
|
-
const date = '20.05.2024';
|
|
8
|
-
const style = { width: 32, height: 32 };
|
|
9
|
-
|
|
10
|
-
<Gapped>
|
|
11
|
-
<CalendarDay style={style} date={date} />
|
|
12
|
-
<CalendarDay style={style} date={date} isToday={true} />
|
|
13
|
-
<CalendarDay style={style} date={date} isSelected={true} />
|
|
14
|
-
<CalendarDay style={style} date={date} isDisabled={true} />
|
|
15
|
-
<CalendarDay style={style} date={date} isWeekend={true} />
|
|
16
|
-
<CalendarDay style={style}><b>20</b></CalendarDay>
|
|
17
|
-
</Gapped>
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### Функции для сравнения строковых дат
|
|
21
|
-
|
|
22
|
-
```jsx harmony
|
|
23
|
-
const { isBetween, isEqual, isGreater, isGreaterOrEqual, isLess, isLessOrEqual } = require('@skbkontur/react-ui/lib/date/comparison');
|
|
24
|
-
|
|
25
|
-
const date_a = '10.03.2017';
|
|
26
|
-
const date_b = '11.03.2017';
|
|
27
|
-
|
|
28
|
-
const Table = ({ children }) => (
|
|
29
|
-
<table>
|
|
30
|
-
<thead>
|
|
31
|
-
<tr>
|
|
32
|
-
<td>Функция</td>
|
|
33
|
-
<td>Результат</td>
|
|
34
|
-
</tr>
|
|
35
|
-
</thead>
|
|
36
|
-
<tbody>
|
|
37
|
-
{ children }
|
|
38
|
-
</tbody>
|
|
39
|
-
</table>
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
const Row = ({ code }) => (
|
|
43
|
-
<tr>
|
|
44
|
-
<td><code>{code}</code></td>
|
|
45
|
-
<td><code>{JSON.stringify(eval(code), null, 2)}</code></td>
|
|
46
|
-
</tr>
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
<Table>
|
|
50
|
-
<Row code={`isEqual("${date_a}", "${date_a}")`} />
|
|
51
|
-
<Row code={`isLess("${date_a}", "${date_b}")`} />
|
|
52
|
-
<Row code={`isLessOrEqual("${date_a}", "${date_b}")`} />
|
|
53
|
-
<Row code={`isGreater("${date_b}", "${date_a}")`} />
|
|
54
|
-
<Row code={`isGreaterOrEqual("${date_b}", "${date_a}")`} />
|
|
55
|
-
<Row code={`isBetween("${date_b}", "${date_a}", "${date_b}")`} />
|
|
56
|
-
</Table>
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
```typescript static
|
|
61
|
-
export function isEqual(left: string, right: string): boolean;
|
|
62
|
-
export function isLess(left: string, right: string): boolean;
|
|
63
|
-
export function isLessOrEqual(left: string, right: string): boolean;
|
|
64
|
-
export function isGreater(left: string, right: string): boolean;
|
|
65
|
-
export function isGreaterOrEqual(left: string, right: string): boolean;
|
|
66
|
-
export function isBetween(
|
|
67
|
-
date: string,
|
|
68
|
-
left?: string,
|
|
69
|
-
right?: string,
|
|
70
|
-
): boolean;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
### Пример использования
|
|
2
|
-
|
|
3
|
-
```jsx harmony
|
|
4
|
-
import { Switcher, Gapped } from '@skbkontur/react-ui';
|
|
5
|
-
|
|
6
|
-
const [alignAt, setAlignAt] = React.useState("center");
|
|
7
|
-
|
|
8
|
-
<Gapped vertical gap="12px">
|
|
9
|
-
<Switcher
|
|
10
|
-
items={[
|
|
11
|
-
{label: "Слева", value: "left"},
|
|
12
|
-
{label: "По центру", value: "center"},
|
|
13
|
-
{label: "Справа", value: "right"}
|
|
14
|
-
]}
|
|
15
|
-
value={alignAt}
|
|
16
|
-
onValueChange={setAlignAt}
|
|
17
|
-
/>
|
|
18
|
-
|
|
19
|
-
<Center
|
|
20
|
-
align={alignAt}
|
|
21
|
-
style={{ background: '#fdd', height: 150 }}
|
|
22
|
-
>
|
|
23
|
-
<div style={{ background: 'black', width: 30, height: 30 }} />
|
|
24
|
-
</Center>
|
|
25
|
-
</Gapped>
|
|
26
|
-
```
|